shandong_common.js 102 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855
  1. // INTERFACE_EXPORT =,必须这么写,这样才能在导出时动态加载脚本后,覆盖前端代码
  2. // 参考广东中山导出接口
  3. INTERFACE_EXPORT = (() => {
  4. "use strict";
  5. const feeRateMap = {
  6. 冬季施工增加费: "DJSGZJFFL",
  7. 冬季施工: "DJSGZJFFL",
  8. 雨季施工增加费: "YUJSGZJFFL",
  9. 雨季施工: "YUJSGZJFFL",
  10. 夜间施工增加费: "YEJSGZJFFL",
  11. 夜间施工: "YEJSGZJFFL",
  12. 高原地区施工增加费: "GYDQSGZJFFL",
  13. 高原施工: "GYDQSGZJFFL",
  14. 风沙地区施工增加费: "FSDQSGZJFFL",
  15. 风沙施工: "FSDQSGZJFFL",
  16. 沿海地区施工增加费: "YHDQSGZJFFL",
  17. 沿海施工: "YHDQSGZJFFL",
  18. 行车干扰施工增加费: "XCGRGCSGZJFFL",
  19. 行车干扰: "XCGRGCSGZJFFL",
  20. 工地转移费: "GDZYFFL",
  21. '工地转移(km)': "GDZYFFL",
  22. 施工辅助费: "SGFZFFL",
  23. 施工辅助: "SGFZFFL",
  24. 基本费用: "JBFYFL",
  25. 主副食运费补贴: "ZFSYFBTFL",
  26. '综合里程(km)': "ZFSYFBTFL",
  27. 职工探亲路费: "ZGTQLFFL",
  28. 职工探亲: "ZGTQLFFL",
  29. 职工取暖补贴: "ZGQNBTFL",
  30. 职工取暖: "ZGQNBTFL",
  31. 财务费用: "CWFYFL",
  32. 养老保险费: "YANGLBXFFL",
  33. 失业保险费: "SYBXFFL",
  34. 医疗保险费: "YILBXFFL",
  35. 工伤保险费: "GSBXFL",
  36. 养老保险: "YANGLBXFFL",
  37. 失业保险: "SYBXFFL",
  38. 医疗保险: "YILBXFFL",
  39. 工伤保险: "GSBXFL",
  40. 住房公积金: "ZFGJJFL",
  41. 规费: "GFZHFL",
  42. 利润: "LRL",
  43. 税金: "SL",
  44. 土方: "TF",
  45. 石方: "SF",
  46. 运输: "YS",
  47. 路面: "LM",
  48. "路面(不计雨)": "LM",
  49. 隧道: "SD",
  50. 构造物I: "GZW1",
  51. "构造物I(不计冬)": "GZW1",
  52. "构造物I(不计雨)": "GZW1",
  53. 构造物II: "GZW2",
  54. "构造物III(桥梁)": "GZW3",
  55. "构造物III(除桥以外)": "GZW3",
  56. "构造物III(除桥以外不计雨夜)": "GZW3",
  57. 技术复杂大桥: "JSFZDQ",
  58. "钢材及钢结构(桥梁)": "GJG",
  59. "钢材及钢结构(除桥以外)": "GJG",
  60. "钢材及钢结构(除桥以外不计夜)": "GJG",
  61. };
  62. //计算程序有,这里没有:施工机械使用费\施工机械人工费\定额人工费\定额材料费\定额施工机械使用费
  63. const itemFeeMap = {
  64. 'marketLabour': 'RGF',
  65. 'marketMaterial': 'CLF',
  66. 'marketMachine': 'JXSYF',
  67. 'marketEquipment': 'SBGZF',
  68. 'direct': 'DEZJF',
  69. 'equipment': 'DESBF',
  70. 'marketDirect': 'ZJF',
  71. 'measure': 'CSF',
  72. 'measure1': 'CSF1',
  73. 'measure2': 'CSF2',
  74. 'manage': 'QYGLF',
  75. 'force': 'GF',
  76. 'profit': 'LR',
  77. 'tax': 'SJ',
  78. 'common': 'JAF',
  79. 'rationCommon': 'DEJAF'
  80. };
  81. const feeLibNoMap = {
  82. 'eba0e7c0-cfe6-11ea-ba15-739be477d1fe': 'GYSFL-000000-2018-86',
  83. '451d3180-e02e-11ea-8056-1514dfc2f39e': 'GYSFL-340000-2019-210',
  84. '32923ff0-e912-11ea-8b20-d93bc370e960': 'GYSFL-440000-2019-544'
  85. };
  86. const FixedCostMap = {
  87. //折旧费、检修费、维护费、安拆辅助费
  88. '折旧费': 1,
  89. '检修费': 1,
  90. '维护费': 1,
  91. '安拆辅助费': 1
  92. }
  93. const RoadGradeMap = {
  94. "高速公路": "0",
  95. "一级公路": "1",
  96. "二级公路": "2",
  97. "三级公路": "3",
  98. "四级公路": "4",
  99. "等外公路": "5",
  100. "独立桥梁": "6",
  101. "独立隧道": "7"
  102. }
  103. const sectionNameMap = {
  104. "清单第100章总则": true,
  105. "清单第200章路基": true,
  106. "清单第300章路面": true,
  107. "清单第400章桥梁、涵洞": true,
  108. "清单第500章隧道": true,
  109. "清单第600章安全设施及预埋管线": true,
  110. "清单第700章绿化及环境保护设施": true,
  111. // "清单 第800章 机电工程": true,
  112. // "清单 第900章 附属区房建工程":true
  113. }
  114. const ListCodeMap = {
  115. "第100章至700章清单": "1",
  116. // "清单 第100章 总则": "一",
  117. // "清单 第200章 路基": "二",
  118. // "清单 第300章 路面": "三",
  119. // "清单 第400章 桥梁、涵洞": "四",
  120. // "清单 第500章 隧道": "五",
  121. // "清单 第600章 安全设施及预埋管线": "六",
  122. // "清单 第700章 绿化及环境保护设施": "七",
  123. // "清单 第800章 机电工程": "八",
  124. // "清单 第900章 附属区房建工程": "九",
  125. "清单第100章总则": "100",
  126. "清单第200章路基": "200",
  127. "清单第300章路面": "300",
  128. "清单第400章桥梁、涵洞": "400",
  129. "清单第500章隧道": "500",
  130. "清单第600章安全设施及预埋管线": "600",
  131. "清单第700章绿化及环境保护设施": "700",
  132. "已包含在清单合计中的材料、工程设备、专业工程暂估价合计": "13",
  133. "清单合计减去材料、工程设备、专业工程暂估价合计": "14",
  134. "计日工合计": "15",
  135. "劳务": "15.1",
  136. "材料": "15.2",
  137. "机械": "15.3",
  138. "暂列金额(不含计日工总额)": "16",
  139. "投标报价": "17"
  140. }
  141. const ratioCodeMap = {
  142. "01ZJF": "0",
  143. "02JXF": "1",
  144. "03WHF": "2",
  145. "04ACFZF": "3"
  146. }
  147. const reg1 = new RegExp('\n', 'g'), reg2 = new RegExp('\r', 'g')
  148. , reg3 = new RegExp(' ', 'g'), reg4 = new RegExp('\t', 'g')
  149. , reg5 = new RegExp('(', 'g'), reg6 = new RegExp(')', 'g')
  150. , regRt1 = new RegExp('\n\r', 'g'), regRt2 = new RegExp('\r\n', 'g')
  151. ;
  152. function getXMLTransitCharacters(orgStr) {
  153. if ( typeof orgStr === 'string') {
  154. return orgStr.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/'/g, '&apos;');
  155. }
  156. return orgStr;
  157. }
  158. function getBasePrice(projectGLJID, tenderProject) {
  159. let glj = _.find(tenderProject.projectGLJ.datas.gljList, {
  160. id: projectGLJID
  161. })
  162. return glj ? gljUtil.getBasePrice(glj, null, null, null, decimalObj, false, _, scMathUtil) : 0;
  163. }
  164. function getFeeRate(programID, fieldName, tenderProject) {
  165. let rate = 0;
  166. let template = tenderProject.calcProgram.compiledTemplates;
  167. if (template[programID]) {
  168. let item = _.find(template[programID].calcItems, {
  169. fieldName: fieldName
  170. })
  171. if (item) rate = item.feeRate;
  172. }
  173. return rate;
  174. }
  175. function _billStrFilter(billStr) {
  176. let rst = billStr || '';
  177. if (typeof billStr === 'string') {
  178. rst = billStr.replace(reg1, '').replace(reg2, '').replace(reg3, '').replace(reg4, '').replace(reg5, '(').replace(reg6, ')');
  179. }
  180. return rst;
  181. }
  182. function _chkAdhocChapterBillCode(billStr) {
  183. let rst = false;
  184. rst = (typeof billStr === 'string' &&
  185. (billStr.indexOf('800章') >= 0 || billStr.indexOf('900章') >= 0 || billStr.indexOf('1000章') >= 0 || billStr.indexOf('1100章') >= 0 || billStr.indexOf('1200章') >= 0)
  186. )
  187. return rst;
  188. }
  189. function _extractAdhocChapter(billStr) {
  190. let rst = '';
  191. if (typeof billStr === 'string') {
  192. if (billStr.indexOf('800章') >= 0) {
  193. rst = '800';
  194. } else if (billStr.indexOf('900章') >= 0) {
  195. rst = '900';
  196. } else if (billStr.indexOf('1000章') >= 0) {
  197. rst = '1000';
  198. } else if (billStr.indexOf('1100章') >= 0) {
  199. rst = '1100';
  200. } else if (billStr.indexOf('1200章') >= 0) {
  201. rst = '1200';
  202. }
  203. }
  204. return rst;
  205. }
  206. function billNameChecking(bNode, projectName, fixedFlag) {
  207. let data = bNode.data;
  208. let fail = null;
  209. let pass = true;
  210. if (data.flagsIndex && data.flagsIndex.fixed) {
  211. let flag = data.flagsIndex.fixed.flag;
  212. switch (flag) {
  213. case fixedFlag.ONE_SEVEN_BILLS:
  214. // pass = data.name == "第100章至700章清单" || data.name == "第100章至700章清单合计";
  215. pass = typeof data.name === 'string' && data.name.includes('第100章至');
  216. break;
  217. case fixedFlag.PROVISIONAL_TOTAL:
  218. pass = data.name == "已包含在清单合计中的材料、工程设备、专业工程暂估价合计";
  219. break;
  220. case fixedFlag.BILLS_TOTAL_WT_PROV:
  221. pass = data.name == "清单合计减去材料、工程设备、专业工程暂估价合计";
  222. break;
  223. case fixedFlag.DAYWORK_LABOR:
  224. pass = data.name == "计日工合计";
  225. break;
  226. /* case fixedFlag.LABOUR_SERVICE:
  227. pass = data.name == "劳务";
  228. break;
  229. case fixedFlag.MATERIAL:
  230. pass = data.name == "材料";
  231. break;
  232. case fixedFlag.CONSTRUCTION_MACHINE:
  233. pass = data.name == "机械";
  234. break; */
  235. case fixedFlag.PROVISIONAL:
  236. pass = data.name == "暂列金额(不含计日工总额)";
  237. break;
  238. case fixedFlag.TOTAL_COST:
  239. pass = data.name == "投标报价";
  240. break;
  241. case fixedFlag.ONE_HUNDRED_BILLS:
  242. // pass = data.name == "清单 第100章 总则";
  243. pass = _billStrFilter(data.name) == "清单第100章总则";
  244. break;
  245. }
  246. } else {
  247. if (bNode.parent) {
  248. const pdata = bNode.parent.data;
  249. if (pdata.flagsIndex && pdata.flagsIndex.fixed && pdata.flagsIndex.fixed.flag == fixedFlag.ONE_SEVEN_BILLS) {
  250. if (!sectionNameMap[_billStrFilter(data.name)]) {
  251. pass = _chkAdhocChapterBillCode(data.name);
  252. }
  253. }
  254. }
  255. }
  256. // if(pass == false)fail = { hint: `清单:"${data.name?data.name:""}",名字不符合规范!`, type: projectName } // 不检测了,有问题不管,2022-12-28与潘林QQ中立贴为证
  257. return fail;
  258. }
  259. /**
  260. *
  261. * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
  262. * @param {Number} exportKind - 导出类型,招标、投标、控制价
  263. * @param {Object} projectData - 项目表数据:{ 建设项目Data, children: [单位工程...] }
  264. * @param {Object} tenderDetailMap - 单位工程ID与getData接口数据(projectObj.project的结构)的映射。
  265. * @return {Promise<Array>} - 返回的数据结构必须按照规定:[{ data, exportKind, fileName }],参考web\building_saas\standard_interface\index.js中的注释说明
  266. */
  267. async function entry(areaKey, exportKind, projectData, tenderDetailMap) {
  268. const {
  269. CONFIG: {
  270. TYPE
  271. },
  272. UTIL,
  273. Element
  274. } = INTERFACE_EXPORT_BASE;
  275. const {
  276. isGLYun
  277. } = window.commonUtil;
  278. const {
  279. EXPORT_KIND: {
  280. BID_INVITATION,
  281. BID_SUBMISSION,
  282. CONTROL
  283. },
  284. fixedFlag,
  285. } = window.commonConstants;
  286. let cprjType = {
  287. 1: "GCLQD", // 招标
  288. 2: "TBBJ", // 投标
  289. 3: "ZBKZJ", // 控制价
  290. }; // 默认是公路云的
  291. if (!isGLYun()) {
  292. // 养护云
  293. cprjType[1] = 'YHGCLQD';
  294. cprjType[2] = 'YHTBBJ';
  295. cprjType[3] = 'YHZBKZJ';
  296. }
  297. const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  298. const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  299. const isControl = exportKind === CONTROL; // 是否是控制价
  300. function emptyElement(name) {
  301. this.name = name;
  302. this.attrs = [];
  303. this.children = [];
  304. }
  305. // 建设项目根节点信息
  306. function CprjInfo(projectName) {
  307. const attrs = [{
  308. name: "CprjName",
  309. value: projectName,
  310. },
  311. {
  312. name: "CprjType",
  313. value: cprjType[exportKind],
  314. },
  315. ];
  316. Element.call(this, "CprjInfo", attrs);
  317. }
  318. // 项目基本信息
  319. function SystemInfo(projectData) {
  320. let baseInfo = _.find(projectData.property.basicInformation, {
  321. dispName: "基本信息",
  322. });
  323. //“招标工程量清单”、“招标控制价”时,输出该字段,为导出该文件的当前时间
  324. let makeData = {
  325. value: UTIL.getNowFormatTime(true)
  326. }
  327. //投标的时候取基本信息的makeData字段
  328. // if (isBidSubmission) makeData = _.find(baseInfo.items, { "key": "makeDate" });
  329. // 山东需求调整,取当前时间
  330. // 取编制软件序列号所属单位。读取项目属性-建设项目基本信息的“投标单位”字段。该字段需要模板中新增。等确定后再修改
  331. // let softwareNumHolder = _.find(baseInfo.items, { "key": "bidderName" });
  332. let softwareNumHolder = userCompany; // userCompany是在main界面上已经有现成的(类似userAccount, userID)
  333. let hardID = UTIL.generateHardwareId();
  334. let [cpuId, diskId, macId] = hardID.split(";");
  335. // const orgScretInfoStr = `SoftwareName=纵横公路工程造价管理软件,SoftwareVer=V${VERSION},SoftwareCompany=珠海纵横创新软件有限公司,SoftwareNumber=${userID},HardNumber=${diskId},MacAddress=${macId},SoftwareNumberHolder=${softwareNumHolder}`
  336. const orgScretInfoStr = `SoftwareName=纵横公路工程造价管理软件,SoftwareVer=V${VERSION},SoftwareCompany=珠海纵横创新软件有限公司,SoftwareNumber=${window.btoa(userID)},HardNumber=${window.btoa(diskId)},MacAddress=${window.btoa(macId)},SoftwareNumberHolder=${softwareNumHolder}`
  337. let scretInfo = sm3Digest(orgScretInfoStr);
  338. const attrs = [{
  339. name: "Name",
  340. value: "公路工程造价数据标准",
  341. },
  342. {
  343. name: "Version",
  344. value: "1.0",
  345. },
  346. {
  347. name: "SoftwareName",
  348. value: "纵横公路工程造价管理软件",
  349. },
  350. {
  351. name: "SoftwareVer",
  352. value: "V" + VERSION,
  353. },
  354. {
  355. name: "SoftwareCompany",
  356. value: "珠海纵横创新软件有限公司",
  357. },
  358. {
  359. name: "MakeDate",
  360. value: makeData ? makeData.value : "",
  361. },
  362. {
  363. name: "SoftwareNumber",
  364. value: window.btoa(userID),
  365. },
  366. {
  367. name: "HardNumber",
  368. value: window.btoa(diskId),
  369. },
  370. {
  371. name: "MacAddress",
  372. value: window.btoa(macId),
  373. },
  374. {
  375. name: "SoftwareNumberHolder",
  376. value: softwareNumHolder,
  377. },
  378. {
  379. name: "SecretInfo",
  380. value: scretInfo,
  381. },
  382. ];
  383. Element.call(this, "SystemInfo", attrs);
  384. }
  385. //造价依据
  386. function CostBasis() {
  387. // ItemStandardNo="GYSFX-000000-2018-86"
  388. const attrs = [{
  389. name: "MakeRuleNo",
  390. value: "GYSBB-000000-2018-86",
  391. },
  392. {
  393. name: "MakeRuleName",
  394. value: "公路工程建设项目概算预算编制办法",
  395. },
  396. {
  397. name: "ItemStandardNo",
  398. value: "GYSFX-000000-2018-86",
  399. },
  400. ];
  401. Element.call(this, "CostBasis", attrs);
  402. //定额库信息
  403. //to do 改成实际的值
  404. function NormLib() {
  405. const attrs = [{
  406. name: "NormLibNo",
  407. value: "YSDE-000000-2018-86",
  408. },
  409. {
  410. name: "NormLibName",
  411. value: "部颁公路工程预算定额(2018)",
  412. },
  413. {
  414. name: "Type",
  415. value: "ZDEK",
  416. },
  417. ];
  418. Element.call(this, "NormLib", attrs);
  419. }
  420. this.children.push(new NormLib());
  421. }
  422. function Rate(tenderProject, feeRateInfo, seirNo) {
  423. //RateNo="1" Name="纵横软件测试版本" RateLibNo="GYSFL-000000-2018-86"
  424. const attrs = [{
  425. name: "RateNo",
  426. value: seirNo,
  427. },
  428. {
  429. name: "Name",
  430. value: feeRateInfo.name,
  431. },
  432. {
  433. name: "RateLibNo",
  434. value: feeLibNoMap[feeRateInfo.libID],
  435. },
  436. ];
  437. Element.call(this, "Rate", attrs);
  438. let RateParams = new emptyElement("RateParams");
  439. let subRates = projectObj.project.FeeRate.getAllSubRates(feeRateInfo.rates);
  440. for (let s of subRates) {
  441. let sname = s.name.replace("(%)", "");
  442. sname = sname.replace("(%)", "");
  443. if (feeRateMap[sname]) {
  444. let value = "";
  445. if (s.editable) {
  446. let sel = _.find(s.optionList, {
  447. selected: true,
  448. });
  449. if (sel) {
  450. value = sel.name;
  451. } else if (gljUtil.isDef(s.value)) {
  452. value = s.value;
  453. }
  454. } else {
  455. value = _.findIndex(s.optionList, {
  456. selected: true,
  457. });
  458. if (value == -1) value = 0;
  459. }
  460. /* if (sname == '利润') tenderProject.ProfitRate = value;
  461. if (sname == '税金') tenderProject.TaxRate = value; */
  462. RateParams.children.push(new RateParam(feeRateMap[sname], value));
  463. }
  464. }
  465. this.children.push(RateParams);
  466. function RateParam(RateTypeNo, RateParamNo) {
  467. //<RateParam RateTypeNo="DJSGZJFFL" RateParamNo="0" Ratio="100"/>
  468. const attrs = [{
  469. name: "RateTypeNo",
  470. value: RateTypeNo,
  471. },
  472. {
  473. name: "RateParamNo",
  474. value: RateParamNo,
  475. },
  476. {
  477. name: "Ratio",
  478. value: "100",
  479. },
  480. ];
  481. Element.call(this, "RateParam", attrs);
  482. }
  483. let RateValues = new emptyElement("RateValues");
  484. function RateValue(CostTypeNo, RateTypeNo, value) {
  485. const attrs = [{
  486. name: "CostTypeNo",
  487. value: CostTypeNo,
  488. },
  489. {
  490. name: "RateTypeNo",
  491. value: RateTypeNo,
  492. },
  493. {
  494. name: "RateValue",
  495. value: value,
  496. },
  497. ];
  498. Element.call(this, "RateValue", attrs);
  499. }
  500. let prefix = "";
  501. for (let r of feeRateInfo.rates) {
  502. if (!r.ParentID && feeRateMap[r.name]) prefix = feeRateMap[r.name];
  503. if (feeRateMap[r.name] && r.ParentID) {
  504. RateValues.children.push(new RateValue(prefix, feeRateMap[r.name], r.rate));
  505. }
  506. }
  507. this.children.push(RateValues);
  508. }
  509. function Pract(tpdata, seriNo) {
  510. let pgljData = tpdata.projectGLJ.datas;
  511. let decimalObj = tpdata.property.decimal;
  512. const attrs = [{
  513. name: "PractNo",
  514. value: seriNo,
  515. },
  516. {
  517. name: "Name",
  518. value: pgljData.constData.usedUnitPriceInfo.name,
  519. },
  520. ];
  521. Element.call(this, "Pract", attrs);
  522. let Param = {
  523. name: "Param",
  524. attrs: [{
  525. name: "TaxLibNo",
  526. value: "CCSBZ-440000-2019-544",
  527. },
  528. {
  529. name: "AuxRate",
  530. value: pgljData.constData.assistProductionFeeRate,
  531. },
  532. ],
  533. children: [],
  534. };
  535. if (isBidSubmission || isControl) { //导出到招标文件中,不输出这一部分。
  536. let elecDatas = electrovalenceObj.getElectrovalenceDatas(null, pgljData.com_electrovalence, pgljData.gljList);
  537. electrovalenceObj.calcPertElectrovalenceMarketPrice(elecDatas);
  538. for (let e of elecDatas) {
  539. let Electro = {
  540. name: "Electro",
  541. attrs: [{
  542. name: "Code",
  543. value: e.code,
  544. },
  545. {
  546. name: "Price",
  547. value: e.electPrice,
  548. },
  549. {
  550. name: "Ratio",
  551. value: e.coe,
  552. },
  553. ],
  554. children: [],
  555. };
  556. Param.children.push(Electro);
  557. }
  558. }
  559. this.children.push(Param);
  560. function Mp(g) {
  561. const attrs = [{
  562. name: "Code",
  563. value: g.code,
  564. },
  565. {
  566. name: "PractName",
  567. value: getXMLTransitCharacters(g.name || ''),
  568. },
  569. {
  570. name: "Spec",
  571. value: getXMLTransitCharacters(g.specs || ''),
  572. },
  573. {
  574. name: "Unit",
  575. value: g.unit,
  576. },
  577. {
  578. name: "BudgetPrice",
  579. value: g.priceInfo.tenderPrice,
  580. },
  581. {
  582. name: "NormPrice",
  583. value: g.priceInfo.basePrice,
  584. },
  585. {
  586. name: "IsAdd",
  587. value: g.unit_price.is_add,
  588. },
  589. ];
  590. Element.call(this, "Mp", attrs);
  591. }
  592. function Material(g) {
  593. const attrs = [{
  594. name: "Code",
  595. value: g.code,
  596. },
  597. {
  598. name: "PractName",
  599. value: getXMLTransitCharacters(g.name || ''),
  600. },
  601. {
  602. name: "Spec",
  603. value: getXMLTransitCharacters(g.specs || ''),
  604. },
  605. {
  606. name: "Unit",
  607. value: g.unit,
  608. },
  609. {
  610. name: "BudgetPrice",
  611. value: g.priceInfo.tenderPrice,
  612. },
  613. {
  614. name: "NormPrice",
  615. value: g.priceInfo.basePrice,
  616. },
  617. {
  618. name: "IsAdd",
  619. value: g.unit_price.is_add,
  620. },
  621. {
  622. name: "OrgPrice",
  623. value: g.unit_price.originalPrice ? g.unit_price.originalPrice : 0,
  624. },
  625. {
  626. name: "TransFee",
  627. value: g.unit_price.unitFreight ? g.unit_price.unitFreight : 0,
  628. },
  629. {
  630. name: "GwRate",
  631. value: g.unit_price.grossWeightCoe_n ? g.unit_price.grossWeightCoe_n : 0,
  632. },
  633. {
  634. name: "OffSiteLf",
  635. value: g.unit_price.offSiteTransportLossRate_n ? g.unit_price.offSiteTransportLossRate_n : 0,
  636. },
  637. {
  638. name: "OnSiteLf",
  639. value: 0,
  640. },
  641. {
  642. name: "LoadLf",
  643. value: g.unit_price.handlingLossRate_n ? g.unit_price.handlingLossRate_n : 0,
  644. },
  645. {
  646. name: "StoreRate",
  647. value: g.unit_price.purchaseStorageRate_n ? g.unit_price.purchaseStorageRate_n : 0,
  648. },
  649. {
  650. name: "PackageRecycleFee",
  651. value: g.unit_price.packageRecoverValue ? g.unit_price.packageRecoverValue : 0,
  652. },
  653. ];
  654. Element.call(this, "Material", attrs);
  655. // if (g.unit_price.calcMaterial == 1) { //有材料计算
  656. // let index = gljUtil.getIndex(g);
  657. // let orList = [];
  658. // for (let o of pgljData.originalList) {
  659. // if (o.connect_key == index) orList.push(new OrgPrices(o));
  660. // }
  661. // if (orList.length > 0) this.children = orList;
  662. // }
  663. function CostStructure(r) {
  664. //待获取
  665. this.name = "CostStructure";
  666. this.attrs = [];
  667. this.children = [];
  668. }
  669. function Consume(r, o) {
  670. this.name = "Consume";
  671. this.attrs = [];
  672. this.children = [];
  673. for (let g of o.ration_gljs) {
  674. if (g.rationID == r.ID) {
  675. let r_quantity = scMathUtil.roundForObj(r.quantity, tpdata.property.decimal.ration.quantity);
  676. this.children.push(new ConsumeItem(g, r_quantity));
  677. }
  678. }
  679. }
  680. function ConsumeItem(g, ration_quantity) {
  681. const attrs = [{
  682. name: "Code", //待获取
  683. value: g.code,
  684. },
  685. {
  686. name: "Consumption",
  687. value: scMathUtil.roundForObj(ration_quantity * parseFloat(g.quantity), tpdata.property.decimal.glj.quantity),
  688. },
  689. ];
  690. Element.call(this, "ConsumeItem", attrs);
  691. }
  692. function Norm(r, o) {
  693. const attrs = [{
  694. name: "NormLibNo", //待获取
  695. value: "",
  696. },
  697. {
  698. name: "DisplayCode",
  699. value: r.code,
  700. },
  701. {
  702. name: "Name",
  703. value: r.name,
  704. },
  705. {
  706. name: "Unit",
  707. value: r.unit,
  708. },
  709. {
  710. name: "Num",
  711. value: r.quantity,
  712. },
  713. {
  714. name: "CostTypeNo",
  715. value: "", //待获取
  716. },
  717. {
  718. name: "FabricationCost", //待获取
  719. value: "",
  720. },
  721. {
  722. name: "AdjustStatus",
  723. value: "",
  724. },
  725. ];
  726. Element.call(this, "Norm", attrs);
  727. this.children.push(new CostStructure(r));
  728. this.children.push(new Consume(r, o));
  729. }
  730. function SelfCollect(o) {
  731. const attrs = [{
  732. name: "OtherCost",
  733. value: 0,
  734. },];
  735. Element.call(this, "SelfCollect", attrs);
  736. for (let r of o.rations) {
  737. this.children.push(new Norm(r, o));
  738. }
  739. }
  740. function OrgPrices(o) {
  741. const attrs = [{
  742. name: "OrgPricevalue",
  743. value: o.supplyPrice,
  744. },
  745. {
  746. name: "Ratio",
  747. value: o.coe,
  748. },
  749. ];
  750. Element.call(this, "OrgPrices", attrs);
  751. if (!o.rations) return;
  752. this.children.push(new SelfCollect(o));
  753. }
  754. }
  755. function Mech(g, gljKeyMap) {
  756. const attrs = [{
  757. name: "Code",
  758. value: g.code,
  759. },
  760. {
  761. name: "PractName",
  762. value: getXMLTransitCharacters(g.name || ''),
  763. },
  764. {
  765. name: "Spec",
  766. value: getXMLTransitCharacters(g.specs || ''),
  767. },
  768. {
  769. name: "Unit",
  770. value: g.unit,
  771. },
  772. {
  773. name: "BudgetPrice",
  774. value: g.priceInfo.tenderPrice,
  775. },
  776. {
  777. name: "NormPrice",
  778. value: g.priceInfo.basePrice,
  779. },
  780. {
  781. name: "IsAdd",
  782. value: g.unit_price.is_add,
  783. },
  784. ];
  785. Element.call(this, "Mech", attrs);
  786. let FixedCostItems = [];
  787. let fcsum = 0;
  788. let VariableCostItems = [];
  789. let vcsum = 0;
  790. if (g.ratio_data && g.ratio_data.length > 0) {
  791. for (let ratio of g.ratio_data) {
  792. let rIndex = gljUtil.getIndex(ratio);
  793. let rglj = gljKeyMap[rIndex];
  794. let ts = scMathUtil.roundForObj(parseFloat(ratio.consumption) * rglj.priceInfo.tenderPrice, decimalObj.glj.unitPrice);
  795. if (FixedCostMap[ratio.name]) {
  796. FixedCostItems.push(new FixedCostItem(ratio));
  797. fcsum = scMathUtil.roundForObj(fcsum + ts, decimalObj.glj.unitPrice);
  798. } else {
  799. VariableCostItems.push(new VariableCostItem(ratio));
  800. vcsum = scMathUtil.roundForObj(vcsum + ts, decimalObj.glj.unitPrice);
  801. }
  802. }
  803. }
  804. if (FixedCostItems.length > 0) {
  805. let fc = new FixedCost(fcsum);
  806. fc.children = FixedCostItems;
  807. this.children.push(fc);
  808. }
  809. if (VariableCostItems.length > 0) {
  810. let vc = new VariableCost(vcsum);
  811. vc.children = VariableCostItems;
  812. this.children.push(vc);
  813. }
  814. function VariableCost(sum) {
  815. const attrs = [{
  816. name: "VariableCostSum",
  817. value: sum,
  818. }];
  819. Element.call(this, "VariableCost", attrs);
  820. }
  821. function VariableCostItem(item) {
  822. const attrs = [{
  823. name: "VariableCostNo",
  824. value: item.code,
  825. }, {
  826. name: "Consumption",
  827. value: item.consumption,
  828. }]
  829. Element.call(this, "VariableCostItem", attrs);
  830. }
  831. function FixedCost(sum) {
  832. const attrs = [{
  833. name: "FixedCostSum",
  834. value: sum,
  835. }, {
  836. name: "FixedRate",
  837. value: 1,
  838. }];
  839. Element.call(this, "FixedCost", attrs);
  840. }
  841. function FixedCostItem(item) {
  842. const attrs = [{
  843. name: "FixedCostNo",
  844. value: ratioCodeMap[item.code],
  845. }, {
  846. name: "Sum",
  847. value: item.consumption,
  848. }]
  849. Element.call(this, "FixedCostItem", attrs);
  850. }
  851. }
  852. let Mps = new emptyElement("Mps");
  853. let Materials = new emptyElement("Materials");
  854. let Mechs = new emptyElement("Mechs");
  855. let gljKeyMap = {};
  856. let temMechs = [];
  857. if (isBidSubmission || isControl) { //导出到招标文件中,不输出这一部分。
  858. for (let g of pgljData.gljList) {
  859. if (!g.quantity) {
  860. continue;
  861. }
  862. let type = g.type + "";
  863. gljKeyMap[gljUtil.getIndex(g)] = g;
  864. type = type.charAt(0);
  865. if (type == "1") {
  866. Mps.children.push(new Mp(g));
  867. } else if (type == "2" || type == 5) {
  868. Materials.children.push(new Material(g));
  869. } else if (type == "3") {
  870. temMechs.push(g);
  871. }
  872. }
  873. for (let t of temMechs) {
  874. Mechs.children.push(new Mech(t, gljKeyMap));
  875. }
  876. }
  877. this.children.push(Mps);
  878. this.children.push(Materials);
  879. this.children.push(Mechs);
  880. }
  881. function EprjInfo(tenderProject) {
  882. let bills = tenderProject.Bills.datas;
  883. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  884. let totalItem = null;
  885. let proItem = null; //暂列金额项
  886. let safeItem = null;
  887. let oneToSevenItem = null;
  888. for (let b of bills) {
  889. if (b.flagsIndex && b.flagsIndex.fixed && b.flagsIndex.fixed.flag == fixedFlag.TOTAL_COST) totalItem = b;
  890. if (b.flagsIndex && b.flagsIndex.fixed && b.flagsIndex.fixed.flag == fixedFlag.PROVISIONAL) proItem = b;
  891. if (b.flagsIndex && b.flagsIndex.fixed && b.flagsIndex.fixed.flag == fixedFlag.ONE_SEVEN_BILLS) oneToSevenItem = b;
  892. if (b.code == "102-3" && b.name == "安全生产费") safeItem = b;
  893. }
  894. const attrs = [{
  895. name: "Name",
  896. value: tenderProject.projectInfo.name,
  897. },
  898. {
  899. name: "Sums",
  900. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  901. },
  902. ];
  903. //输出控制价、投标文件时,取调价后的标段总造价。
  904. //输出招标文件时,取0
  905. if (isBidInvitation) attrs[1].value = 0;
  906. Element.call(this, "EprjInfo", attrs);
  907. this.children.push(new SummaryOfCost(totalItem, proItem, safeItem, oneToSevenItem, feature));
  908. this.children.push(new MakeInfo(tenderProject));
  909. this.children.push(new Params(tenderProject));
  910. const cacheForFormula = _preCodeingForBills(tenderProject);
  911. this.children.push(new getBillsItems(tenderProject, cacheForFormula));
  912. this.children.push(new getIndexs(tenderProject));
  913. let bidEvaluationMainMaterials = getBidEvaluationMainMaterial(tenderProject);
  914. if (bidEvaluationMainMaterials.length > 0) this.children.push(...bidEvaluationMainMaterials);
  915. //山东接口还需要增加几个表的数据(就是把原报表的显示数据转到投标文件里)
  916. // 1. 投标报价汇总表
  917. this.children.push(new quoteSummary(tenderProject));
  918. // 2. 计日工表
  919. let spdw = sporadicWork(tenderProject);
  920. if (spdw) {
  921. this.children.push(spdw);
  922. }
  923. // 3. 材料暂估价表
  924. let estMaterialRpt = materialEstimate(tenderProject);
  925. if (estMaterialRpt) {
  926. this.children.push(estMaterialRpt);
  927. }
  928. // 4. 工程设备暂估价表
  929. let estMachineRpt = getMachineTempEst(tenderProject);
  930. if (estMachineRpt) {
  931. this.children.push(estMachineRpt);
  932. }
  933. // 5. 专业工程暂估价表
  934. let estSpecPrjRpt = getSpecPrjEst(tenderProject);
  935. if (estSpecPrjRpt) {
  936. this.children.push(estSpecPrjRpt);
  937. }
  938. // 6. 工程量清单单价分析表
  939. let billAnalyzeRpt = getBillsAnalyze(tenderProject);
  940. if (billAnalyzeRpt) {
  941. this.children.push(billAnalyzeRpt);
  942. }
  943. }
  944. function _getBidGljCode(tenderProject, orgGlj) {
  945. let rst = orgGlj.code;
  946. if (tenderProject.bid_evaluation_list && tenderProject.bid_evaluation_list.datas) {
  947. for (let bGlj of tenderProject.bid_evaluation_list.datas) {
  948. if (bGlj.projectGLJID === orgGlj.id) {
  949. rst = bGlj.seq;
  950. break;
  951. }
  952. }
  953. }
  954. return rst;
  955. }
  956. function _getFee(bill, key = 'common', valueKey = 'tenderTotalFee') {
  957. let rstSum = 0;
  958. if (bill) {
  959. let dtlB = (bill.data) ? bill.data : bill;
  960. if (dtlB.fees) {
  961. for (let fee of dtlB.fees) {
  962. if (fee.fieldName === key) {
  963. rstSum = fee[valueKey];
  964. break;
  965. }
  966. }
  967. }
  968. }
  969. return rstSum;
  970. };
  971. function _getNumValueByExportKind(orgSum) {
  972. let rst = orgSum;
  973. // const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  974. // const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  975. // const isControl = exportKind === CONTROL; // 是否是控制价
  976. //根据导出类型(上面3个),输出实际合计或price
  977. if (isBidInvitation) {
  978. rst = 0;
  979. }
  980. return rst;
  981. }
  982. function _getStrValueByExportKind(orgStr) {
  983. let rst = orgStr;
  984. // const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  985. // const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  986. // const isControl = exportKind === CONTROL; // 是否是控制价
  987. //根据导出类型(上面3个),输出实际合计或price
  988. if (isBidInvitation) {
  989. rst = '';
  990. }
  991. return rst;
  992. }
  993. function _getFixedSum(tenderProject) {
  994. let rst = 0;
  995. tenderProject.Bills.datas.forEach((bill) => {
  996. if (bill.specialProvisional == "固定费用") {
  997. let bVal = _getFee(bill);
  998. rst += bVal;
  999. }
  1000. });
  1001. return rst;
  1002. }
  1003. function quoteSummary(tenderProject) {
  1004. let quoteSummaryItem = new emptyElement('QuoteSummary');
  1005. // let attrs = [];
  1006. //1. 取固定清单,
  1007. // 1.1 100~700章总清单(flags有属性为19的那个) -> topNode100To700
  1008. // 1.2 已包含在清单合计中的材料、工程设备、专业工程暂估价合计 标记:20
  1009. // 1.3 清单合计减去材料、工程设备、专业工程暂估价|合计 标记:21
  1010. // 1.4 计日工合计 标记:22
  1011. // 1.5 暂列金额(不含计日工总额) 标记:26
  1012. // 1.6 投标报价 标记:9
  1013. let topNode100To700, nodeZXZDJ, nodeQDKCZXZDJ, nodeJRG, nodeZLJE, nodeTBBJ, newAddedBill;
  1014. let chapterNodes = [];
  1015. let fixedSum = _getFixedSum(tenderProject); //山东有固定费用,此费用不参与到此项中去
  1016. let nextBillID = '';
  1017. tenderProject.Bills.datas.forEach((bill) => {
  1018. if (bill.flags && bill.flags.length > 0) {
  1019. for (let flag of bill.flags) {
  1020. switch (flag.flag) {
  1021. case 19:
  1022. topNode100To700 = bill;
  1023. break;
  1024. case 20:
  1025. nodeZXZDJ = bill;
  1026. break;
  1027. case 21:
  1028. nodeQDKCZXZDJ = bill;
  1029. break;
  1030. case 22:
  1031. nodeJRG = bill;
  1032. break;
  1033. case 26:
  1034. nodeZLJE = bill;
  1035. nextBillID = bill.NextSiblingID
  1036. break;
  1037. case 9:
  1038. nodeTBBJ = bill;
  1039. break;
  1040. case 44:
  1041. newAddedBill = bill;
  1042. break;
  1043. default:
  1044. break;
  1045. }
  1046. }
  1047. }
  1048. });
  1049. tenderProject.Bills.datas.forEach((bill) => {
  1050. if (bill.type === 1 && bill.ID === nextBillID && nodeTBBJ && nodeTBBJ.ID !== nextBillID) {
  1051. newAddedBill = bill;
  1052. }
  1053. });
  1054. //2. 然后获取topNode100To700下的所有次一级清单(100章...700章)
  1055. if (topNode100To700) {
  1056. for (let rootBill of tenderProject.Bills.tree.roots) {
  1057. // 100~700章总清单在top级别(山东养护)
  1058. if (rootBill.data.ID === topNode100To700.ID) {
  1059. rootBill.children.forEach((subBill) => {
  1060. if (subBill.data.name.includes('00章')) {
  1061. chapterNodes.push(subBill);
  1062. }
  1063. });
  1064. break;
  1065. }
  1066. }
  1067. }
  1068. //3. 拼凑数据
  1069. let nodeAttrs = [];
  1070. if (topNode100To700) {
  1071. let order = 1;
  1072. //读取投标报价汇总表信息。1.ItemNo 序号。2.ChapterNo 章次。 3.Name 科目名称。 4.Sum 金额。
  1073. chapterNodes.forEach((cnode) => {
  1074. if (_chkIfValid100(cnode)) {
  1075. let chapterIdx = cnode.data.name.indexOf("00章");
  1076. let chpNoStr = '';
  1077. const ch = cnode.data.name.substr(chapterIdx - 2, 2);
  1078. if (isNaN(parseFloat(ch))) {
  1079. chpNoStr = cnode.data.name.substr(chapterIdx - 1, 3);
  1080. } else {
  1081. chpNoStr = cnode.data.name.substr(chapterIdx - 2, 4);
  1082. }
  1083. // nodeAttrs.push({ ItemNo: order, ChapterNo: cnode.data.name.substr(chapterIdx - 1, 3), Name: cnode.data.name, Sum: _getFee(cnode) });
  1084. nodeAttrs.push({ ItemNo: order, ChapterNo: chpNoStr, Name: cnode.data.name, Sum: _getFee(cnode) });
  1085. order++;
  1086. }
  1087. });
  1088. // nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: '第100章至700章清单合计', Sum: _getFee(topNode100To700) });
  1089. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: topNode100To700.name, Sum: _getFee(topNode100To700) });
  1090. order++;
  1091. if (nodeZXZDJ) {
  1092. // nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: '已包含在清单合计中的材料、工程设备、专业工程暂估价合计', Sum: _getFee(nodeZXZDJ) - fixedSum});
  1093. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: '已包含在清单合计中的材料、工程设备、专业工程暂估价合计', Sum: _getFee(nodeZXZDJ) }); // 又不需要fixedSum了
  1094. order++;
  1095. }
  1096. if (nodeQDKCZXZDJ) {
  1097. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: `清单合计减去材料、工程设备、专业工程暂估价合计(即${order - 2}-${order - 1})=${order}`, Sum: _getFee(nodeQDKCZXZDJ) });
  1098. order++;
  1099. }
  1100. if (nodeJRG) {
  1101. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: `计日工合计`, Sum: _getFee(nodeJRG) });
  1102. order++;
  1103. }
  1104. if (nodeZLJE) {
  1105. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: `暂列金额(不含计日工总额)`, Sum: _getFee(nodeZLJE) });
  1106. order++;
  1107. }
  1108. if (newAddedBill) {
  1109. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: newAddedBill.name, Sum: _getFee(newAddedBill) });
  1110. order++;
  1111. }
  1112. if (nodeTBBJ) {
  1113. let nameStr = `投标报价(${chapterNodes.length + 1}+${order - 2}+${order - 1})=${order}`;
  1114. if (newAddedBill && nodeTBBJ.calcBase && nodeTBBJ.calcBase.includes(newAddedBill.ID)) {
  1115. nameStr = `投标报价(${chapterNodes.length + 1}+${order - 3}+${order - 2}+${order - 1})=${order}`;
  1116. }
  1117. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: nameStr, Sum: _getFee(nodeTBBJ) });
  1118. order++;
  1119. }
  1120. }
  1121. function _Item(item) {
  1122. const attrs = [
  1123. {
  1124. name: 'ItemNo',
  1125. value: item.ItemNo
  1126. },
  1127. {
  1128. name: 'ChapterNo',
  1129. value: item.ChapterNo
  1130. },
  1131. {
  1132. name: 'Name',
  1133. value: getXMLTransitCharacters(item.Name || '')
  1134. },
  1135. {
  1136. name: 'Sum',
  1137. value: scMathUtil.roundForObj(_getNumValueByExportKind(item.Sum), tenderProject.property.decimal.bills.totalPrice)
  1138. // value: 0 // 所有清单的金额都是0
  1139. }
  1140. ];
  1141. let rst = new emptyElement('Item');
  1142. rst.attrs.push(...attrs);
  1143. return rst;
  1144. }
  1145. for (let attr of nodeAttrs) {
  1146. quoteSummaryItem.children.push(_Item(attr));
  1147. }
  1148. return quoteSummaryItem;
  1149. }
  1150. function sporadicWork(tenderProject) {
  1151. //计日工表,含:劳务、材料、施工机械、计日工汇总
  1152. let hasSporadicWork = false;
  1153. let sporadicWorkItem = new Element('SporadicWork');
  1154. let nodeLabour, nodeMaterial, nodeMachine;
  1155. //首先收集过滤计日工相关清单
  1156. tenderProject.Bills.datas.forEach((bill) => {
  1157. if (bill.flags && bill.flags.length > 0) {
  1158. for (let flag of bill.flags) {
  1159. switch (flag.flag) {
  1160. case 23:
  1161. nodeLabour = bill;
  1162. break;
  1163. case 24:
  1164. nodeMaterial = bill;
  1165. break;
  1166. case 25:
  1167. nodeMachine = bill;
  1168. break;
  1169. default:
  1170. break;
  1171. }
  1172. }
  1173. }
  1174. });
  1175. const _buildWorkNodeItem = function (orgNode, subNodes, parentKey, childKey) {
  1176. let parentNode = new Element(parentKey);
  1177. sporadicWorkItem.children.push(parentNode);
  1178. const pSumAttrs = [
  1179. {
  1180. name: 'Sum',
  1181. value: _getNumValueByExportKind(_getFee(orgNode))
  1182. // value: 0
  1183. }
  1184. ];
  1185. // Element.call(this, parentKey, pSumAttrs);
  1186. parentNode.attrs.push(...pSumAttrs);
  1187. subNodes.forEach((node, index) => {
  1188. let childNode = new Element(childKey);
  1189. parentNode.children.push(childNode);
  1190. const attrs = [
  1191. {
  1192. name: 'ItemNo',
  1193. value: (node.code) ? node.code : `${index + 1}`
  1194. }, {
  1195. name: 'Name',
  1196. value: node.name
  1197. }, {
  1198. name: 'Unit',
  1199. value: node.unit
  1200. }, {
  1201. name: 'Num',
  1202. value: node.quantity
  1203. }, {
  1204. name: 'Price',
  1205. value: _getNumValueByExportKind(_getFee(node, 'common', 'tenderUnitFee'))
  1206. // value: 0
  1207. }, {
  1208. name: 'Sum',
  1209. value: _getNumValueByExportKind(_getFee(node))
  1210. // value: 0
  1211. }
  1212. ];
  1213. childNode.attrs.push(...attrs);
  1214. });
  1215. };
  1216. //1. 判断劳务
  1217. if (nodeLabour) {
  1218. let subNodes = [];
  1219. tenderProject.Bills.datas.forEach((bill) => {
  1220. if (bill.ParentID === nodeLabour.ID) {
  1221. subNodes.push(bill);
  1222. }
  1223. });
  1224. if (subNodes.length > 0) {
  1225. hasSporadicWork = true;
  1226. //创建劳务Mps节点及劳务Mps下Mp子节点
  1227. _buildWorkNodeItem(nodeLabour, subNodes, 'Mps', 'Mp');
  1228. }
  1229. }
  1230. //2. 判断材料
  1231. if (nodeMaterial) {
  1232. let subNodes = [];
  1233. tenderProject.Bills.datas.forEach((bill) => {
  1234. if (bill.ParentID === nodeMaterial.ID) {
  1235. subNodes.push(bill);
  1236. }
  1237. });
  1238. if (subNodes.length > 0) {
  1239. hasSporadicWork = true;
  1240. //创建材料Materials节点及劳务Materials下Material子节点
  1241. _buildWorkNodeItem(nodeMaterial, subNodes, 'Materials', 'Material');
  1242. }
  1243. }
  1244. //3. 判断施工机械
  1245. if (nodeMachine) {
  1246. let subNodes = [];
  1247. tenderProject.Bills.datas.forEach((bill) => {
  1248. if (bill.ParentID === nodeMachine.ID) {
  1249. subNodes.push(bill);
  1250. }
  1251. });
  1252. if (subNodes.length > 0) {
  1253. hasSporadicWork = true;
  1254. //创建施工机械Meehs节点及劳务Meehs下Meeh子节点
  1255. _buildWorkNodeItem(nodeMachine, subNodes, 'Mechs', 'Mech');
  1256. }
  1257. }
  1258. //4. 判断计日工汇总
  1259. if (hasSporadicWork) {
  1260. let summaryNode = new Element('Summary');
  1261. sporadicWorkItem.children.push(summaryNode);
  1262. const pSumAttrs = [
  1263. {
  1264. name: 'Sum',
  1265. // value: _getFee(nodeLabour) + _getFee(nodeMaterial) + _getFee(nodeMachine)
  1266. value: _getNumValueByExportKind(_getFee(nodeLabour) + _getFee(nodeMaterial) + _getFee(nodeMachine))
  1267. }
  1268. ];
  1269. summaryNode.attrs = pSumAttrs;
  1270. //把劳务、材料、施工机械
  1271. function _workItem(node, name, remark = '') {
  1272. let childNode = new Element('Item');
  1273. summaryNode.children.push(childNode);
  1274. const attrs = [
  1275. {
  1276. name: "Name",
  1277. value: getXMLTransitCharacters(name || ''),
  1278. },
  1279. {
  1280. name: "Sum",
  1281. value: _getNumValueByExportKind(_getFee(node)),
  1282. },
  1283. {
  1284. name: "Remark",
  1285. value: remark,
  1286. }
  1287. ]
  1288. childNode.attrs.push(...attrs);
  1289. }
  1290. _workItem(nodeLabour, '劳务');
  1291. _workItem(nodeMaterial, '材料');
  1292. _workItem(nodeMachine, '机械');
  1293. }
  1294. //返回
  1295. if (hasSporadicWork) {
  1296. return sporadicWorkItem;
  1297. } else {
  1298. return null;
  1299. }
  1300. }
  1301. function materialEstimate(tenderProject) {
  1302. let mEstNode = new emptyElement('MaterialEstimate');
  1303. let items = [];
  1304. let billItems = [];
  1305. let itemNo = 1;
  1306. //材料暂估价明细
  1307. tenderProject.Bills.datas.forEach((bill) => {
  1308. if (bill.specialProvisional === '材料暂估') {
  1309. billItems.push(bill);
  1310. }
  1311. });
  1312. if (billItems.length > 0) {
  1313. billItems.forEach((bill) => {
  1314. let mEstItemNode = new emptyElement('Item');
  1315. mEstNode.children.push(mEstItemNode);
  1316. let attrs = [
  1317. { name: 'ItemNo', value: itemNo },
  1318. { name: 'Code', value: bill.code },
  1319. { name: 'Number', value: bill.code },
  1320. { name: 'Name', value: getXMLTransitCharacters(bill.name || '') },
  1321. { name: 'Unit', value: bill.unit },
  1322. { name: 'Num', value: bill.quantity },
  1323. { name: 'Price', value: _getNumValueByExportKind(_getFee(bill, 'common', 'tenderUnitFee')) },
  1324. { name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), 0)), type: TYPE.DECIMAL },
  1325. // {name: 'Price', value: 0},
  1326. // {name: 'Sum', value: 0},
  1327. { name: 'Remark', value: (bill.remark) ? bill.remark : '' }
  1328. ];
  1329. itemNo++;
  1330. mEstItemNode.attrs.push(...attrs);
  1331. });
  1332. }
  1333. tenderProject.projectGLJ.datas.gljList.forEach((glj) => {
  1334. if (glj.is_evaluate && glj.type !== 5 && glj.type !== 301) {
  1335. items.push(glj);
  1336. }
  1337. });
  1338. if (items.length > 0) {
  1339. items.forEach((glj) => {
  1340. let mEstItemNode = new emptyElement('Item');
  1341. mEstNode.children.push(mEstItemNode);
  1342. let gljName = glj.name;
  1343. if (tenderProject.evaluate_list.datas && tenderProject.evaluate_list.datas.length > 0) {
  1344. for (let relGlj of tenderProject.evaluate_list.datas) {
  1345. if (relGlj.projectGLJID == glj.id) {
  1346. gljName = relGlj.name;
  1347. break;
  1348. }
  1349. }
  1350. }
  1351. let attrs = [
  1352. { name: 'ItemNo', value: itemNo },
  1353. { name: 'Code', value: _getBidGljCode(tenderProject, glj) },
  1354. { name: 'Number', value: glj.code },
  1355. { name: 'Name', value: getXMLTransitCharacters(gljName || '') },
  1356. { name: 'Unit', value: glj.unit },
  1357. { name: 'Num', value: glj.tenderQuantity },
  1358. // {name: 'Price', value: _getNumValueByExportKind(glj.unit_price.market_price)},
  1359. { name: 'Price', value: glj.unit_price.market_price }, //暂估材料输出price,不需判断导出类型
  1360. { name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(glj.tenderQuantity * glj.unit_price.market_price, 0)), type: TYPE.DECIMAL },
  1361. // {name: 'Price', value: 0},
  1362. // {name: 'Sum', value: 0},
  1363. { name: 'Remark', value: (glj.remark) ? glj.remark : '' }
  1364. ];
  1365. itemNo++;
  1366. mEstItemNode.attrs.push(...attrs);
  1367. });
  1368. }
  1369. if (billItems.length > 0 || items.length > 0) {
  1370. return mEstNode;
  1371. } else {
  1372. return null;
  1373. }
  1374. }
  1375. function getMachineTempEst(tenderProject) {
  1376. let mEstNode = new emptyElement('PrjDeviceEstimate');
  1377. let items = [];
  1378. let billItems = [];
  1379. let itemNo = 1;
  1380. //工程设备明细
  1381. tenderProject.Bills.datas.forEach((bill) => {
  1382. console.log(`bill.specialProvisional: ${bill.specialProvisional}`);
  1383. if (bill.specialProvisional === '工程设备') {
  1384. billItems.push(bill);
  1385. }
  1386. });
  1387. if (billItems.length > 0) {
  1388. billItems.forEach((bill) => {
  1389. let mEstItemNode = new emptyElement('Item');
  1390. mEstNode.children.push(mEstItemNode);
  1391. let attrs = [
  1392. { name: 'ItemNo', value: itemNo },
  1393. { name: 'Code', value: bill.code },
  1394. { name: 'Number', value: bill.code },
  1395. { name: 'Name', value: getXMLTransitCharacters(bill.name || '') },
  1396. { name: 'Unit', value: bill.unit },
  1397. { name: 'Num', value: bill.quantity },
  1398. { name: 'Price', value: _getNumValueByExportKind(_getFee(bill, 'common', 'tenderUnitFee')) },
  1399. { name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), 0)), type: TYPE.DECIMAL },
  1400. // {name: 'Price', value: 0},
  1401. // {name: 'Sum', value: 0},
  1402. { name: 'Remark', value: (bill.remark) ? glj.remark : '' }
  1403. ];
  1404. itemNo++;
  1405. mEstItemNode.attrs.push(...attrs);
  1406. });
  1407. }
  1408. tenderProject.projectGLJ.datas.gljList.forEach((glj) => {
  1409. if (glj.is_evaluate && glj.type === 5) {
  1410. items.push(glj);
  1411. }
  1412. });
  1413. if (items.length > 0) {
  1414. items.forEach((glj, sno) => {
  1415. let mEstItemNode = new emptyElement('Item');
  1416. mEstNode.children.push(mEstItemNode);
  1417. let attrs = [
  1418. { name: 'ItemNo', value: itemNo },
  1419. { name: 'Code', value: _getBidGljCode(tenderProject, glj) },
  1420. { name: 'Number', value: glj.code },
  1421. { name: 'Name', value: getXMLTransitCharacters(glj.name || '') },
  1422. { name: 'Unit', value: glj.unit },
  1423. { name: 'Num', value: glj.tenderQuantity },
  1424. // {name: 'Price', value: _getNumValueByExportKind(glj.unit_price.market_price)},
  1425. { name: 'Price', value: glj.unit_price.market_price }, // 暂估设备直接输出price
  1426. { name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(glj.tenderQuantity * glj.unit_price.market_price, 0)), type: TYPE.DECIMAL },
  1427. // {name: 'Price', value: 0},
  1428. // {name: 'Sum', value: 0},
  1429. { name: 'Remark', value: (glj.remark) ? glj.remark : '' }
  1430. ];
  1431. itemNo++;
  1432. mEstItemNode.attrs.push(...attrs);
  1433. });
  1434. }
  1435. if (billItems.length > 0 || items.length > 0) {
  1436. return mEstNode;
  1437. } else {
  1438. return null;
  1439. }
  1440. }
  1441. function getSpecPrjEst(tenderProject) {
  1442. let mEstNode = new emptyElement('SpecPrjEstimate');
  1443. let sum = 0;
  1444. let items = [];
  1445. //专业工程暂估明细
  1446. tenderProject.Bills.datas.forEach((bill) => {
  1447. if (bill.specialProvisional === '专业工程') {
  1448. items.push(bill);
  1449. }
  1450. });
  1451. if (items.length > 0) {
  1452. items.forEach((bill, sno) => {
  1453. let mEstItemNode = new emptyElement('Item');
  1454. mEstNode.children.push(mEstItemNode);
  1455. let ttl = _getFee(bill);
  1456. sum += ttl;
  1457. let jobContent = '';
  1458. if (bill.jobContent && bill.jobContent.length > 0) {
  1459. jobContent = bill.jobContent.toString();
  1460. } else {
  1461. jobContent = (bill.jobContentText) ? bill.jobContentText : '';
  1462. }
  1463. jobContent = jobContent.replace(regRt1, '&#xA;').replace(regRt2, '&#xA;').replace(reg1, '&#xA;').replace(reg2, '&#xA;'); // 转成XML的换行转义符
  1464. let attrs = [
  1465. { name: 'ItemNo', value: sno + 1 },
  1466. { name: 'Code', value: bill.code },
  1467. { name: 'Number', value: bill.code },
  1468. { name: 'Name', value: getXMLTransitCharacters(bill.name || '') },
  1469. { name: 'Content', value: jobContent },
  1470. // {name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(ttl, 0)), type:TYPE.DECIMAL},
  1471. { name: 'Sum', value: ttl, type: TYPE.DECIMAL },
  1472. // {name: 'Sum', value: 0, type:TYPE.DECIMAL},
  1473. ];
  1474. mEstItemNode.attrs.push(...attrs);
  1475. });
  1476. mEstNode.attrs.push({ name: 'Sum', value: sum });
  1477. return mEstNode;
  1478. } else {
  1479. return null;
  1480. }
  1481. }
  1482. function getBillsAnalyze(tenderProject) {
  1483. if (isBidInvitation) return null; // 招标不输出此部分
  1484. // 本函数是尽量复刻【5.5表】工程量清单单价分析表的‘综合’计算式脚本的相关逻辑,具体细节根据实际环境有所调整(前端环境已有不少现成的结构及数据,能少跑不少逻辑)
  1485. let djfxbNode = new emptyElement('ListUnitPriceAnalysis');
  1486. let decimalObj = tenderProject.property.decimal;
  1487. // 工程量清单单价分析(100~700章 清单下所有定额工料机的综合)
  1488. let topNode100To700;
  1489. let sno = 1;
  1490. const prefix = '_';
  1491. let filterMtlTypes = [202, 203, 204, 301];
  1492. for (let bill of tenderProject.Bills.datas) {
  1493. if (bill.flags && bill.flags.length > 0) {
  1494. for (let flag of bill.flags) {
  1495. if (flag.flag === 19) {
  1496. for (let rootBill of tenderProject.Bills.tree.roots) {
  1497. if (rootBill.data.ID === bill.ID) {
  1498. topNode100To700 = rootBill;
  1499. break;
  1500. }
  1501. }
  1502. break;
  1503. }
  1504. }
  1505. }
  1506. }
  1507. const cacheObj = {};
  1508. const proKeysArr = [];
  1509. const addedGljCodeCache = {};
  1510. //说明:根据实际情况,用户会直接在清单下加工料机,此工料机属于定额层次,那么算工程量的时候要加上这个(沟通后这种几率很小,暂时返回0,如有再补上)
  1511. const _getAdhocGljQty = function (billsId, rationCode, rstType = 1) {
  1512. let rst = 0;
  1513. // for (let nbidx = 0; nbidx < newRBillsIdArr.length; nbidx++) {
  1514. // if (newRBillsIdArr[nbidx] === billsId && newRCodeArr[nbidx] === rationCode) {
  1515. // rst = (rstType === 1) ? newRQtyArr[nbidx] : newTtlArr[nbidx];
  1516. // break;
  1517. // }
  1518. // }
  1519. return rst;
  1520. };
  1521. const _getCacheObjInitialedItem = function (bill = null, glj = null) {
  1522. let rst = {
  1523. code: (bill) ? bill.code : ((glj) ? glj.code : ''),
  1524. name: (bill) ? bill.name : ((glj) ? glj.name : ''),
  1525. quantity: (bill) ? bill.quantity : 1,
  1526. labourConsume: 0,
  1527. labourUnitPrice: 0,
  1528. labourTotalPrice: 0,
  1529. mainMaterialFee: 0,
  1530. auxiliaryMaterialFee: 0,
  1531. materialUnitFee: (bill) ? _getFee(bill, 'marketMaterial', 'unitFee') : 0,
  1532. machineFee: (bill) ? _getFee(bill, 'marketMachine') : 0,
  1533. otherFee: (bill) ? _getFee(bill, 'measure') : 0, //措施费
  1534. managementFee: (bill) ? (_getFee(bill, 'manage') + _getFee(bill, 'force')) : 0, //管理+规费
  1535. taxFee: (bill) ? _getFee(bill, 'tax') : 0,
  1536. profitFee: (bill) ? _getFee(bill, 'profit') : 0,
  1537. unitPrice: (bill) ? _getFee(bill, 'common', 'unitFee') : 0,
  1538. items: []
  1539. };
  1540. return rst;
  1541. };
  1542. const _getPrjGLJ = function (gljID) {
  1543. let rst = null;
  1544. for (let glj of tenderProject.projectGLJ.datas.gljList) {
  1545. if (glj.id === gljID) {
  1546. rst = glj;
  1547. break;
  1548. }
  1549. }
  1550. return rst;
  1551. };
  1552. const _getRation = function (rationId) {
  1553. let rst = null;
  1554. for (let ration of tenderProject.Ration.datas) {
  1555. if (ration.ID === rationId) {
  1556. rst = ration;
  1557. break;
  1558. }
  1559. }
  1560. return rst;
  1561. };
  1562. const _createNode = function (billIdKey, bill) {
  1563. if (cacheObj[billIdKey]) {
  1564. //1. 叶子清单,先创建清单Item
  1565. let bQtn = 1;
  1566. if (bill.data.hasOwnProperty('quantity')) {
  1567. bQtn = parseFloat(bill.data.quantity);
  1568. if (isNaN(bQtn)) bQtn = 1;
  1569. }
  1570. let billMainMaterialTtl = cacheObj[billIdKey].mainMaterialFee / bQtn;
  1571. let billAuxiliaryMaterialTtl = cacheObj[billIdKey].auxiliaryMaterialFee / bQtn;
  1572. // scMathUtil.roundForObj(cacheObj[billIdKey].labourConsume / bQtn, decimalObj.glj.unitPrice)
  1573. let leafBillAttrs = [
  1574. { name: 'ItemNo', value: sno },
  1575. { name: 'Code', value: cacheObj[billIdKey].code },
  1576. { name: 'Name', value: getXMLTransitCharacters(cacheObj[billIdKey].name) },
  1577. { name: 'LaborWorkDays', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourConsume / bQtn, decimalObj.glj.quantity)) },
  1578. { name: 'LaborUnitPrice', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourUnitPrice, decimalObj.glj.unitPrice)) },
  1579. { name: 'LaborUnitTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourTotalPrice / bQtn, decimalObj.glj.unitPrice)) },
  1580. { name: 'MainMaterialConsume', value: 0 },
  1581. { name: 'MainMaterialUnit', value: '' },
  1582. { name: 'MainMaterialUnitPrice', value: 0 },
  1583. { name: 'MainMaterialTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(billMainMaterialTtl, decimalObj.glj.unitPrice)) },
  1584. { name: 'AuxiliaryMaterialFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(billAuxiliaryMaterialTtl, decimalObj.glj.unitPrice)) },
  1585. { name: 'MaterialSum', value: _getNumValueByExportKind(scMathUtil.roundForObj(billMainMaterialTtl + billAuxiliaryMaterialTtl, decimalObj.glj.unitPrice)) },
  1586. { name: 'MachUsageFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].machineFee / bQtn, decimalObj.glj.unitPrice)) },
  1587. { name: 'OtherFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].otherFee / bQtn, decimalObj.glj.unitPrice)) },
  1588. { name: 'ManageFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].managementFee / bQtn, decimalObj.glj.unitPrice)) },
  1589. { name: 'Tax', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].taxFee / bQtn, decimalObj.glj.unitPrice)) },
  1590. { name: 'Profit', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].profitFee / bQtn, decimalObj.glj.unitPrice)) },
  1591. { name: 'Price', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill, 'common', 'tenderUnitFee'), decimalObj.glj.unitPrice)) },
  1592. ];
  1593. sno++;
  1594. let leafItemNode = new emptyElement('Item');
  1595. djfxbNode.children.push(leafItemNode);
  1596. // leafItemNode.attrs.push(...leafBillAttrs);
  1597. leafItemNode.attrs = leafBillAttrs;
  1598. //2. 清单下工料机
  1599. cacheObj[billIdKey].items.forEach((gljItem) => {
  1600. let showQty = gljItem.mainMaterialConsume / bQtn;
  1601. showQty = Math.round(showQty * 1000000) / 1000000;
  1602. let gljAttrs = [
  1603. { name: 'ItemNo', value: sno },
  1604. { name: 'Code', value: gljItem.code },
  1605. { name: 'Name', value: getXMLTransitCharacters(gljItem.name || '') },
  1606. { name: 'LaborWorkDays', value: 0 },
  1607. { name: 'LaborUnitPrice', value: 0 },
  1608. { name: 'LaborUnitTotal', value: 0 },
  1609. // {name: 'MainMaterialConsume', value: scMathUtil.roundForObj(showQty, decimalObj.glj.quantity)},
  1610. { name: 'MainMaterialConsume', value: _getNumValueByExportKind(scMathUtil.roundForObj(showQty, decimalObj.glj.quantity)) },
  1611. // {name: 'MainMaterialUnit', value: gljItem.mainMaterialUnit},
  1612. { name: 'MainMaterialUnit', value: _getStrValueByExportKind(gljItem.mainMaterialUnit) },
  1613. { name: 'MainMaterialUnitPrice', value: _getNumValueByExportKind(scMathUtil.roundForObj(gljItem.mainMaterialUnitPrice, decimalObj.glj.unitPrice)) },
  1614. { name: 'MainMaterialTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(showQty * gljItem.mainMaterialUnitPrice, decimalObj.glj.unitPrice)) },
  1615. { name: 'AuxiliaryMaterialFee', value: 0 },
  1616. { name: 'MaterialSum', value: 0 },
  1617. { name: 'MachUsageFee', value: 0 },
  1618. { name: 'OtherFee', value: 0 },
  1619. { name: 'ManageFee', value: 0 },
  1620. { name: 'Tax', value: 0 },
  1621. { name: 'Profit', value: 0 },
  1622. // {name: 'Price', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), decimalObj.glj.unitPrice))},
  1623. { name: 'Price', value: 0 },
  1624. ];
  1625. sno++;
  1626. let gljItemNode = new emptyElement('Item');
  1627. djfxbNode.children.push(gljItemNode);
  1628. // gljItemNode.attrs.push(...gljAttrs);
  1629. gljItemNode.attrs = gljAttrs;
  1630. });
  1631. }
  1632. };
  1633. const _getAllGlj = function (parentBill) {
  1634. if (parentBill.data.name === '挖除水泥混凝土路面(平面交叉)') {
  1635. debugger;
  1636. }
  1637. if (parentBill.children.length > 0) {
  1638. parentBill.children.forEach((subBill) => {
  1639. _getAllGlj(subBill);
  1640. });
  1641. } else {
  1642. let billIdKey = prefix + parentBill.data.ID;
  1643. if (!cacheObj.hasOwnProperty(billIdKey)) {
  1644. cacheObj[billIdKey] = _getCacheObjInitialedItem(parentBill.data);
  1645. addedGljCodeCache[billIdKey] = [];
  1646. proKeysArr.push(billIdKey);
  1647. }
  1648. tenderProject.ration_glj.datas.forEach((rglj) => {
  1649. if (rglj.billsItemID === parentBill.data.ID) {
  1650. let ration = _getRation(rglj.rationID);
  1651. if (ration) {
  1652. // 计算消耗量,否则定额人材机消耗量取值会不正确
  1653. gljOprObj.getTotalQuantity(rglj, ration);
  1654. }
  1655. let gljQty = parseFloat(rglj.tenderQuantity || rglj.quantity);
  1656. if (isNaN(gljQty)) gljQty = 0;
  1657. let gljRationQty = 0;
  1658. if (ration) gljRationQty = parseFloat(ration.tenderQuantity || ration.quantity);
  1659. if (isNaN(gljRationQty)) gljRationQty = 0;
  1660. let gljCns = gljQty * gljRationQty;
  1661. let prjGlj = _getPrjGLJ(rglj.projectGLJID);
  1662. let gljUnitPrice = parseFloat(prjGlj.unit_price.market_price);
  1663. let gljTotalPrice = gljCns * gljUnitPrice;
  1664. let gljCode = rglj.code;
  1665. if (rglj.type === 1) {
  1666. //人工
  1667. cacheObj[billIdKey].labourConsume = cacheObj[billIdKey].labourConsume + gljCns;
  1668. cacheObj[billIdKey].labourUnitPrice = gljUnitPrice;
  1669. cacheObj[billIdKey].labourTotalPrice = cacheObj[billIdKey].labourTotalPrice + gljTotalPrice;
  1670. } else if (filterMtlTypes.indexOf(rglj.type) < 0) {
  1671. if (!addedGljCodeCache[billIdKey].includes(gljCode)) {
  1672. addedGljCodeCache[billIdKey].push(gljCode);
  1673. }
  1674. if (prjGlj.is_main_material) {
  1675. let dtlObj = {};
  1676. dtlObj.code = gljCode;
  1677. dtlObj.name = rglj.name;
  1678. dtlObj.specs = rglj.specs;
  1679. //
  1680. let adhocGljQty = _getAdhocGljQty(parentBill.data.ID, dtlObj.code);
  1681. let adhocGljTtl = adhocGljQty * gljUnitPrice;
  1682. dtlObj.mainMaterialConsume = gljCns + adhocGljQty; //考虑清单单独加工料机的情况,需要补上消耗量
  1683. dtlObj.mainMaterialUnitPrice = gljUnitPrice;
  1684. dtlObj.mainMaterialTotalPrice = gljTotalPrice;
  1685. dtlObj.mainMaterialUnit = rglj.unit;
  1686. let isAdd = 0;
  1687. for (let i = 0; i < cacheObj[billIdKey].items.length; i++) {
  1688. //先比较对象中是否已存在同一条工料机,存在,则累加汇总消耗量和金额;否则添加。
  1689. if (dtlObj.code === cacheObj[billIdKey].items[i].code && dtlObj.name === cacheObj[billIdKey].items[i].name && dtlObj.mainMaterialUnit === cacheObj[billIdKey].items[i].mainMaterialUnit && dtlObj.specs === cacheObj[billIdKey].items[i].specs) {
  1690. cacheObj[billIdKey].items[i].mainMaterialConsume = cacheObj[billIdKey].items[i].mainMaterialConsume + gljCns;
  1691. cacheObj[billIdKey].items[i].mainMaterialTotalPrice = cacheObj[billIdKey].items[i].mainMaterialTotalPrice + gljTotalPrice;
  1692. isAdd = 1;
  1693. break;
  1694. }
  1695. }
  1696. if (isAdd === 0) {
  1697. cacheObj[billIdKey].items.push(dtlObj);
  1698. }
  1699. cacheObj[billIdKey].mainMaterialFee = cacheObj[billIdKey].mainMaterialFee + gljTotalPrice + adhocGljTtl;
  1700. } else {
  1701. cacheObj[billIdKey].auxiliaryMaterialFee = cacheObj[billIdKey].auxiliaryMaterialFee + gljTotalPrice;
  1702. }
  1703. }
  1704. }
  1705. });
  1706. // 整理完后,开始创建XML节点(这里与参考脚本逻辑不一样了,直接开始创建)
  1707. _createNode(billIdKey, parentBill);
  1708. }
  1709. };
  1710. if (topNode100To700) {
  1711. topNode100To700.children.forEach((topChapterBill) => {
  1712. _getAllGlj(topChapterBill);
  1713. });
  1714. }
  1715. //...
  1716. return djfxbNode;
  1717. }
  1718. function getBidEvaluationMainMaterial(tenderProject) {
  1719. let bidMaterials = [];
  1720. let i = 1;
  1721. for (let b of tenderProject.bidMaterialData) {
  1722. bidMaterials.push(new BidEvaluationMainMaterial(b, i));
  1723. i++
  1724. }
  1725. return bidMaterials;
  1726. function BidEvaluationMainMaterial(b, index) {
  1727. const attrs = [{
  1728. name: "Code",
  1729. value: b.seq,
  1730. },
  1731. {
  1732. name: "Number",
  1733. value: b.code
  1734. },
  1735. {
  1736. name: "Name",
  1737. value: b.name
  1738. },
  1739. {
  1740. name: "Specification",
  1741. value: b.specs
  1742. },
  1743. {
  1744. name: "Unit",
  1745. value: b.unit
  1746. },
  1747. {
  1748. name: "Price",
  1749. value: _getNumValueByExportKind(b.marketPrice || '0'),
  1750. type: TYPE.DECIMAL
  1751. },
  1752. {
  1753. name: "LimitedPrice",
  1754. value: _getNumValueByExportKind(b.marketPrice || '0'),
  1755. type: TYPE.DECIMAL
  1756. },
  1757. {
  1758. name: "Quantity",
  1759. value: b.quantity,
  1760. type: TYPE.DECIMAL
  1761. },
  1762. {
  1763. name: "Total",
  1764. value: 0
  1765. },
  1766. {
  1767. name: "Remark",
  1768. value: b.remark
  1769. }
  1770. ];
  1771. if (isBidSubmission || isControl) {
  1772. attrs[7].value = b.quantity;
  1773. attrs[8].value = b.totalPrice;
  1774. }
  1775. Element.call(this, "BidEvaluationMainMaterial", attrs);
  1776. }
  1777. }
  1778. function getIndexs(tenderProject) {
  1779. let Indexs = new emptyElement('Indexs');
  1780. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  1781. for (let f of feature) {
  1782. if (f.code) Indexs.children.push(new IndexItem(f))
  1783. }
  1784. return Indexs;
  1785. function IndexItem(fea) {
  1786. const attrs = [{
  1787. name: "Code",
  1788. value: fea.code,
  1789. },
  1790. {
  1791. name: "Name",
  1792. value: fea.dispName,
  1793. },
  1794. {
  1795. name: "Unit",
  1796. value: fea.unit,
  1797. },
  1798. {
  1799. name: "Value",
  1800. value: fea.value,
  1801. },
  1802. {
  1803. name: "Remark",
  1804. value: fea.remark,
  1805. }
  1806. ]
  1807. Element.call(this, "IndexItem", attrs);
  1808. }
  1809. }
  1810. function _chkIfValid100(node) {
  1811. let rst = true;
  1812. if (node.data.name?.indexOf('第100章') >= 0 && node.data.name?.indexOf('总则') >= 0) {
  1813. let bVal = _getFee(node);
  1814. rst = node.children.length > 0 || bVal !== 0;
  1815. }
  1816. return rst;
  1817. }
  1818. function getBillsItems(tenderProject, cacheForFormula) {
  1819. let items = new emptyElement("Items");
  1820. let rootNodes = tenderProject.mainTree.roots;
  1821. for (let r of rootNodes) {
  1822. setItem(r, -1, items.children);
  1823. }
  1824. return items;
  1825. function setItem(bNode, level, list, dftListCodeSeq = -1) {
  1826. const specialChkBillFlag = [fixedFlag.DAYWORK_LABOR, fixedFlag.LABOUR_SERVICE, fixedFlag.MATERIAL, fixedFlag.CONSTRUCTION_MACHINE];
  1827. if (bNode.sourceType == ModuleNames.ration) return;
  1828. // 判断: 1. 招标清单 2. 是否量价,都是的话,return
  1829. if (isBidInvitation && (bNode.data.specialProvisional == "材料暂估" || bNode.data.specialProvisional == "工程设备")) {
  1830. return;
  1831. }
  1832. // 判断: 100章下无子清单,且金额为0时,return
  1833. if (!_chkIfValid100(bNode)) {
  1834. return;
  1835. }
  1836. let item = new bill(bNode, level, dftListCodeSeq);
  1837. if (bNode.children && bNode.children.length > 0) {
  1838. level += 1;
  1839. let dftLCStartSeq = -1;
  1840. if (isFlag(bNode.data) && specialChkBillFlag.includes(bNode.data.flagsIndex.fixed.flag)) {
  1841. dftLCStartSeq = 1;
  1842. }
  1843. for (let c of bNode.children) {
  1844. setItem(c, level, item.children, dftLCStartSeq);
  1845. if (dftLCStartSeq > 0) dftLCStartSeq++;
  1846. }
  1847. }
  1848. list.push(item);
  1849. function getCalcType(node) {
  1850. /*
  1851. 判断是否父项:
  1852. 是父项,则取1;
  1853. 是叶子项,则判断其下有无套定额/量价/工料机:
  1854. 有则取1;
  1855. 无则判断有无基数计算:
  1856. 有则取2;
  1857. 无则取3 */
  1858. if (node.children && node.children.length > 0) {
  1859. return 1; //是父项,则取1, 有套定额/量价/工料机,也取1
  1860. } else {
  1861. return node.data.calcBase && node.data.calcBase != "" ? 2 : 3
  1862. }
  1863. }
  1864. function getItemType(node) {
  1865. let Bills = projectObj.project.Bills;
  1866. //是100~900章部分、或是计日工部分,叶子清单输出1,父项输出0;
  1867. if (Bills.isBelongOneToSeven(node) || Bills.isBelongDayWork(node)) {
  1868. if (node.children && node.children.length > 0) {
  1869. return node.children[0].sourceType == ModuleNames.ration ? 1 : 0
  1870. }
  1871. //山东新需求:清单 第XXX章、计日工、劳务、材料、机械 输出0
  1872. const bNodeName = _billStrFilter(node.data.name);
  1873. if (bNodeName.indexOf('清单第') >= 0 && bNodeName.indexOf('00章') > 0) {
  1874. return 0;
  1875. } else if (isFlag(node.data) && specialChkBillFlag.includes(node.data.flagsIndex.fixed.flag)) {
  1876. return 0;
  1877. }
  1878. return 1 //叶子清单输出1
  1879. } else {
  1880. return 0;
  1881. /* //非100~900章部分,
  1882. // 是暂列金额,判断暂列金额的金额等于0,则输出为0;暂列金额的金额不等于0,则输出为1;
  1883. if (node.data.name && node.data.name.indexOf("暂列金额") != -1) {
  1884. let sum = node.data.feesIndex && node.data.feesIndex.common ? node.data.feesIndex.common.tenderTotalFee : "";
  1885. return gljUtil.isNotEmpty(sum) ? 1 : 0
  1886. } else { //非暂列金额,则判断清单的工程量是否等于0,等于0,则输出0;不等于0,则输出1
  1887. return gljUtil.isNotEmpty(node.data.quantity) ? 1 : 0
  1888. } */
  1889. }
  1890. }
  1891. function bill(bNode, level, dftListCodeSeq = -1) {
  1892. let data = bNode.data;
  1893. let CostKind = 3;
  1894. if (data.name === undefined || data.name === null) data.name = '';
  1895. if (data.name && data.name.indexOf("安全生产费") != -1) CostKind = 1;
  1896. if (data.name && data.name.indexOf("暂列金额") != -1) CostKind = 2;
  1897. //1 = 工程量×综合单价;2 = 计算基数×费率;3 = 工程量×单价。
  1898. let CalcType = getCalcType(bNode);
  1899. //取暂估价类型。读取造价书界面的专项暂定列。0=材料暂估价,1=工程设备暂估价,2=专业工程暂估价,没有选的输出为空。
  1900. let ProvisionalType = "";
  1901. if (data.specialProvisional == "材料暂估") ProvisionalType = 0;
  1902. if (data.specialProvisional == "工程设备") ProvisionalType = 1;
  1903. if (data.specialProvisional == "专业工程") ProvisionalType = 2;
  1904. if (data.specialProvisional == "固定费用") ProvisionalType = 3;
  1905. //MpRatio
  1906. let MpRatio = "";
  1907. let MaterialRatio = "";
  1908. let MechRatio = "";
  1909. if (data.quantityCoe) {
  1910. if (data.quantityCoe["labour"]) MpRatio = data.quantityCoe["labour"];
  1911. if (data.quantityCoe["material"]) MaterialRatio = data.quantityCoe["material"];
  1912. if (data.quantityCoe["machine"]) MechRatio = data.quantityCoe["machine"];
  1913. }
  1914. let fail = billNameChecking(bNode, tenderProject.projectInfo.name, fixedFlag)
  1915. //fail: { hint: '错误提示', type: '提示所属(基本就是单位工程名称)' }
  1916. let ListCode = "";
  1917. // if (ListCodeMap[data.name]) ListCode = ListCodeMap[data.name];
  1918. if (ListCodeMap[_billStrFilter(data.name)]) {
  1919. ListCode = ListCodeMap[_billStrFilter(data.name)];
  1920. } else if (_chkAdhocChapterBillCode(data.name)) {
  1921. ListCode = _extractAdhocChapter(data.name);
  1922. } else if (data.code && data.code != "") {
  1923. ListCode = data.code;
  1924. } else if (dftListCodeSeq > 0) {
  1925. ListCode = `${dftListCodeSeq}`;
  1926. }
  1927. let qtyFormula = data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "";
  1928. //data.calcBase //data.calcBase ? cbParser.toFExpr(data.calcBase, tenderProject.mainTree.items) : "",
  1929. if (!data.name.includes('暂列金额') && isBidInvitation) {
  1930. if (data.hasOwnProperty('calcBase')) {
  1931. let chkNaN = parseFloat(data.calcBase);
  1932. if (isNaN(chkNaN)) {
  1933. qtyFormula = data.calcBase;
  1934. } else {
  1935. qtyFormula = '';
  1936. }
  1937. } else {
  1938. qtyFormula = '';
  1939. }
  1940. //判断公式(calcBase)是否为正常的计算公式(即非直接输入数量),
  1941. }
  1942. let formulaCode = '';
  1943. if (cacheForFormula['_' + data.ID] && cacheForFormula['_' + data.ID].formulaCode) {
  1944. formulaCode = cacheForFormula['_' + data.ID].formulaCode;
  1945. }
  1946. const attrs = [{
  1947. name: "ListCode",
  1948. value: ListCode,
  1949. },
  1950. {
  1951. name: "ListName",
  1952. value: data.name,
  1953. fail: fail
  1954. },
  1955. {
  1956. name: "Unit",
  1957. value: data.unit,
  1958. },
  1959. {
  1960. name: "Num",
  1961. value: data.quantity,
  1962. type: TYPE.DECIMAL,
  1963. toFix: 3
  1964. },
  1965. {
  1966. name: "QtyFormula",
  1967. value: qtyFormula,
  1968. type: TYPE.DECIMAL,
  1969. toFix: 2
  1970. },
  1971. {
  1972. name: "Price",
  1973. value: 0,//data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderUnitFee : "",
  1974. type: TYPE.DECIMAL,
  1975. toFix: 2
  1976. },
  1977. {
  1978. name: "Rate",
  1979. value: 100,
  1980. },
  1981. {
  1982. name: "Sum",
  1983. value: 0,//data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "",
  1984. type: TYPE.DECIMAL,
  1985. toFix: 2
  1986. },
  1987. {
  1988. name: "ChapterKind",
  1989. value: level > 3 ? 3 : level,
  1990. },
  1991. {
  1992. name: "CostKind",
  1993. value: CostKind,
  1994. },
  1995. {
  1996. name: "CalcType",
  1997. value: CalcType,
  1998. },
  1999. {
  2000. name: "ProvisionalType",
  2001. value: ProvisionalType,
  2002. mustHasValue: true
  2003. },
  2004. {
  2005. name: "MeterRules",
  2006. value: "",
  2007. },
  2008. {
  2009. name: "Content",
  2010. value: data.jobContentText,
  2011. },
  2012. {
  2013. name: "Remarks",
  2014. value: data.remark,
  2015. },
  2016. /* {
  2017. name: "MpRatio",
  2018. value: MpRatio,
  2019. },
  2020. {
  2021. name: "MaterialRatio",
  2022. value: MaterialRatio,
  2023. },
  2024. {
  2025. name: "MechRatio",
  2026. value: MechRatio,
  2027. },
  2028. {
  2029. name: "AdjustedPrice",
  2030. value: data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderUnitFee : "",
  2031. },
  2032. {
  2033. name: "AdjustedSums",
  2034. value: data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "",
  2035. }, */
  2036. {
  2037. name: "ItemType",
  2038. value: getItemType(bNode),
  2039. },
  2040. /* {
  2041. name: "FomulaCode",
  2042. value: ""
  2043. }, */
  2044. {
  2045. name: "FormulaCode",
  2046. value: formulaCode,
  2047. },
  2048. ];
  2049. //投标、招标控制价时。取单价。
  2050. //招标时,如果是“安全生产费”或“暂列金额”,取单价,否则取0。
  2051. // 新需求:安全生产费在招标时也不输出(CostKind === 1)
  2052. // if (isBidSubmission || isControl || CostKind == 1 || CostKind == 2 || ProvisionalType === 2 || ProvisionalType === 3) {
  2053. if (isBidSubmission || isControl || CostKind == 2 || ProvisionalType === 2 || ProvisionalType === 3) {
  2054. attrs[5].value = data.feesIndex && data.feesIndex.common ? scMathUtil.roundForObj(data.feesIndex.common.tenderUnitFee, tenderProject.property.decimal.bills.unitPrice) : "";
  2055. attrs[7].value = data.feesIndex && data.feesIndex.common ? scMathUtil.roundForObj(data.feesIndex.common.tenderTotalFee, tenderProject.property.decimal.bills.totalPrice) : "";
  2056. //暂列金额 数量为0的时候,单价输出0
  2057. if (CostKind == 2 && !gljUtil.isNotEmpty(data.quantity)) attrs[5].value = 0
  2058. }
  2059. let fixedSumVal = _getFixedSum(tenderProject); // 固定费用
  2060. Element.call(this, "Item", attrs);
  2061. let cc = CostComposition(bNode);
  2062. if (cc) this.children.push(cc);
  2063. this.children.push(CostStructure(data, tenderProject.property.decimal.bills.totalPrice))
  2064. function CostComposition(bNode) {
  2065. // 山东逻辑:如果清单下有计算基数,则需要输出(废弃)
  2066. // 新逻辑:
  2067. // 标准接口文档里,写了只有招标清单,才是完全不输出定额相关数据的
  2068. // 当清单有清单基数和费率,那么应该就是没有定额,不输出定额;
  2069. // 清单没有基数和费率,也没有下挂定额,那么也不输出定额相关字段;
  2070. // 清单有下挂定额、量价,那么输出定额相关数据。
  2071. // if (isBidInvitation) return null; // 山东接口又要这个了
  2072. let CostComposition = new emptyElement('CostComposition');
  2073. let Norms = [];
  2074. let Costs = [];
  2075. if (bNode.children && bNode.children.length > 0 && bNode.children[0].sourceType == ModuleNames.ration) {
  2076. for (let r of bNode.children) {
  2077. if (r.data.type == rationType.ration) {
  2078. if (isEmptyRation(r.data) || isBidInvitation) continue; // 招标 或者 定额空行不输出到接口文件中。
  2079. Norms.push(new Ration(r.data));
  2080. } else if (!isBidInvitation) {
  2081. Costs.push(new Cost(r.data));
  2082. }
  2083. }
  2084. }
  2085. if (Norms.length > 0) CostComposition.children.push(...Norms);
  2086. if (Costs.length > 0) CostComposition.children.push(...Costs);
  2087. if (bNode.data.calcBase) CostComposition.children.push(new Formula(bNode.data));
  2088. return CostComposition.children.length > 0 ? CostComposition : null;
  2089. //定额空行不输出到接口文件中。 //定额空行的判断是:定额编码、定额名称、定额单位、定额单位、定额工程量为零或为空时
  2090. function isEmptyRation(ration) {
  2091. return !gljUtil.isNotEmpty(ration.code) && !gljUtil.isNotEmpty(ration.name) && !gljUtil.isNotEmpty(ration.unit) && (!gljUtil.isNotEmpty(ration.quantity) || ration.quantity == 0)
  2092. }
  2093. function Formula(bills) {
  2094. let sumFix = (bills.name === '已包含在清单合计中的材料、工程设备、专业工程暂估价合计') ? fixedSumVal : 0;
  2095. const attrs = [{
  2096. name: "Name",
  2097. value: bills.name
  2098. },
  2099. {
  2100. name: "Formulas",
  2101. value: _getFormulaDispName(cacheForFormula, bills)
  2102. },
  2103. {
  2104. name: "Ratio",
  2105. value: 1
  2106. },
  2107. {
  2108. name: "Sum",
  2109. // value: bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : "",
  2110. // value: _getNumValueByExportKind(bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : "") - sumFix,
  2111. value: _getNumValueByExportKind(bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : ""), // 不用再减一次sumFix
  2112. type: TYPE.DECIMAL
  2113. },
  2114. {
  2115. name: "Remarks",
  2116. value: bills.remark
  2117. }
  2118. ]
  2119. Element.call(this, "Formula", attrs);
  2120. // 1.Name
  2121. // 名称/描述。取清单的名称。
  2122. // 2.Formulas
  2123. // 计算式。读取计算基数的文本。
  2124. // 取基数计算窗口内容,基数直接转换为金额?参考标准文档的 7.11 及 7.12 节。
  2125. // 7.11是定额的费用,7.12是清单累进基数,主要是估概预算中用到,清单里的不同,所以中山的接口直接输出基数文本。
  2126. // 3.Ratio
  2127. // 系数。输出为1,非必填。
  2128. // 4.Sum
  2129. // 取金额。
  2130. // 5.Remarks
  2131. }
  2132. function Cost(item) {
  2133. let BasePrice = 0;
  2134. if (item.type == rationType.volumePrice) { // 当插入的是量价时,基价读取单价列。
  2135. BasePrice = item.feesIndex && item.feesIndex.common ? item.feesIndex.common.tenderUnitFee : 0
  2136. } else {
  2137. BasePrice = getBasePrice(item.projectGLJID, tenderProject)
  2138. }
  2139. let calcMap = tenderProject.calcProgram.compiledTemplateMaps
  2140. let CostTypeNo = '';
  2141. if (feeRateMap[calcMap[item.programID]]) CostTypeNo = feeRateMap[calcMap[item.programID]];
  2142. const attrs = [{
  2143. name: "Code",
  2144. value: item.code,
  2145. }, {
  2146. name: 'Name',
  2147. value: item.name
  2148. }, {
  2149. name: 'Spec',
  2150. value: item.specs
  2151. }, {
  2152. name: 'Unit',
  2153. value: item.unit
  2154. }, {
  2155. name: 'Num',
  2156. value: item.tenderQuantity
  2157. }, {
  2158. name: 'BasePrice',
  2159. value: BasePrice
  2160. }, {
  2161. name: 'Price',
  2162. value: item.feesIndex && item.feesIndex.common ? item.feesIndex.common.tenderUnitFee : 0
  2163. }, {
  2164. name: 'IsEquipment',
  2165. value: item.subType == gljType.EQUIPMENT ? 1 : 0
  2166. }, {
  2167. name: 'CostTypeNo',
  2168. value: CostTypeNo
  2169. }, {
  2170. name: 'ProfitRate',
  2171. value: getFeeRate(item.programID, 'profit', tenderProject)
  2172. },
  2173. {
  2174. name: 'TaxRate',
  2175. value: getFeeRate(item.programID, 'tax', tenderProject)
  2176. },
  2177. {
  2178. name: 'MpRatio',
  2179. value: item.subType == gljType.LABOUR ? 100 : 0
  2180. },
  2181. {
  2182. name: 'MaterialRatio',
  2183. value: item.subType == gljType.GENERAL_MATERIAL ? 100 : 0
  2184. },
  2185. {
  2186. name: 'MechRatio',
  2187. value: item.subType == gljType.GENERAL_MACHINE ? 100 : 0
  2188. }
  2189. ]
  2190. Element.call(this, "Cost", attrs);
  2191. this.children.push(CostStructure(item, tenderProject.property.decimal.ration.totalPrice));
  2192. }
  2193. function Ration(ration) {
  2194. let calcMap = tenderProject.calcProgram.compiledTemplateMaps
  2195. let CostTypeNo = '';
  2196. if (feeRateMap[calcMap[ration.programID]]) CostTypeNo = feeRateMap[calcMap[ration.programID]];
  2197. const attrs = [{
  2198. name: "NormLibNo",
  2199. value: 'YSDE-000000-2018-86',
  2200. }, {
  2201. name: 'DisplayCode',
  2202. value: ration.code
  2203. }, {
  2204. name: 'Name',
  2205. value: ration.name
  2206. }, {
  2207. name: 'Unit',
  2208. value: ration.unit
  2209. }, {
  2210. name: 'Num',
  2211. value: ration.tenderQuantity
  2212. },
  2213. {
  2214. name: 'CostTypeNo',
  2215. value: CostTypeNo
  2216. },
  2217. {
  2218. name: 'ProfitRate',
  2219. value: getFeeRate(ration.programID, 'profit', tenderProject) //tenderProject.ProfitRate
  2220. },
  2221. {
  2222. name: 'TaxRate',
  2223. value: getFeeRate(ration.programID, 'tax', tenderProject) //tenderProject.TaxRate
  2224. },
  2225. {
  2226. name: 'FabricationCost',
  2227. value: ration.feesIndex && ration.feesIndex.common ? ration.feesIndex.common.tenderTotalFee : 0
  2228. },
  2229. {
  2230. name: 'AdjustStatus',
  2231. value: ration.adjustState
  2232. }
  2233. ]
  2234. Element.call(this, "Norm", attrs);
  2235. this.children.push(CostStructure(ration, tenderProject.property.decimal.ration.totalPrice));
  2236. this.children.push(Consume(ration));
  2237. }
  2238. }
  2239. function Consume(ration) {
  2240. let consume = new emptyElement('Consume');
  2241. for (let rg of ration.rationGLJList) {
  2242. consume.children.push(new ConsumeItem(rg));
  2243. }
  2244. return consume;
  2245. function ConsumeItem(rg) {
  2246. const attrs = [{
  2247. name: "Code",
  2248. value: rg.code,
  2249. }, {
  2250. name: "Consumption",
  2251. value: rg.tenderQuantity
  2252. }];
  2253. Element.call(this, "ConsumeItem", attrs);
  2254. }
  2255. }
  2256. function CostStructure(item, decimalNum) {
  2257. let CostStructure = new emptyElement('CostStructure');
  2258. for (let f of cpFeeTypes) {
  2259. if (itemFeeMap[f.type]) CostStructure.children.push(new CostItem(item, f.type))
  2260. }
  2261. if (CostStructure.children.length == 0) CostStructure.children.push(new CostItem({}, ""))
  2262. function CostItem(item, type) {
  2263. const attrs = [{
  2264. name: "ItemNo",
  2265. value: itemFeeMap[type],
  2266. }, {
  2267. name: 'Sum',
  2268. value: 0 //fee.tenderTotalFee
  2269. }]
  2270. if ((isBidSubmission || isControl) && item.feesIndex && item.feesIndex[type]) {
  2271. attrs[1].value = scMathUtil.roundForObj(item.feesIndex[type].tenderTotalFee, decimalNum);
  2272. if ((item.name === '已包含在清单合计中的材料、工程设备、专业工程暂估价合计') && (itemFeeMap[type] === 'JAF')) {
  2273. attrs[1].value = scMathUtil.roundForObj(attrs[1].value - fixedSumVal, decimalNum);
  2274. }
  2275. }
  2276. Element.call(this, "CostItem", attrs);
  2277. }
  2278. return CostStructure;
  2279. }
  2280. }
  2281. }
  2282. }
  2283. function Params(tenderProject) {
  2284. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  2285. let featrueMap = {};
  2286. let baseMap = {};
  2287. for (let f of feature) {
  2288. featrueMap[f.key] = f;
  2289. }
  2290. let baseInfo = _.find(tenderProject.property.basicInformation, {
  2291. dispName: "基本信息",
  2292. });
  2293. for (let i of baseInfo.items) {
  2294. let key = i.key;
  2295. //if (i.dispName == "编制日期") key = "编制时间";
  2296. baseMap[key] = i;
  2297. }
  2298. let BuildType = "";
  2299. const natureConstruction = baseMap["natureConstruction"] || {};
  2300. if (natureConstruction.value == "新建") BuildType = 0;
  2301. if (natureConstruction.value == "改扩建") BuildType = 1;
  2302. let Terrain = "";
  2303. const terrainCategory = baseMap["terrainCategory"] || {};
  2304. if (terrainCategory.value == "平原微丘") Terrain = 0;
  2305. if (terrainCategory.value == "山岭重丘") Terrain = 1;
  2306. let DesignSpeed = (featrueMap["designSpeed"] || {}).value;
  2307. let Structure = "";
  2308. const pavementStructure = featrueMap["pavementStructure"] || {};
  2309. if (pavementStructure.value == "沥青路面") Structure = 0;
  2310. if (pavementStructure.value == "水泥混凝土路面") Structure = 1;
  2311. if (pavementStructure.value == "其他类型路面") Structure = 2;
  2312. let RoadGrade = "";
  2313. if (RoadGradeMap[(baseMap["roadGrade"] || {value: ''}).value]) RoadGrade = RoadGradeMap[baseMap["roadGrade"].value];
  2314. const attrs = [{
  2315. name: "PrjArea",
  2316. value: baseMap["location"] ? baseMap["location"].value : ""
  2317. },
  2318. {
  2319. name: "StartPileNo",
  2320. value: baseMap["startChainages"] ? baseMap["startChainages"].value : "",
  2321. mustHasValue: true
  2322. },
  2323. {
  2324. name: "EndPileNo",
  2325. value: baseMap["endChainages"] ? baseMap["endChainages"].value : "",
  2326. mustHasValue: true
  2327. },
  2328. {
  2329. name: "BuildType",
  2330. value: BuildType,
  2331. },
  2332. {
  2333. name: "Terrain",
  2334. value: Terrain,
  2335. mustHasValue: true
  2336. },
  2337. {
  2338. name: "RoadGrade",
  2339. value: RoadGrade,
  2340. mustHasValue: true
  2341. },
  2342. {
  2343. name: "DesignSpeed",
  2344. value: DesignSpeed,
  2345. mustHasValue: true
  2346. },
  2347. {
  2348. name: "Structure",
  2349. value: Structure,
  2350. mustHasValue: true
  2351. },
  2352. {
  2353. name: "SubgradeWidth",
  2354. value: featrueMap["subgradeWidth"] ? featrueMap["subgradeWidth"].value : "",
  2355. mustHasValue: true
  2356. },
  2357. {
  2358. name: "RoadLength",
  2359. value: featrueMap["roadLength"] ? featrueMap["roadLength"].value : "",
  2360. mustHasValue: true
  2361. },
  2362. {
  2363. name: "BridgeLength",
  2364. value: featrueMap["bridgeLength"] ? featrueMap["bridgeLength"].value : "",
  2365. mustHasValue: true
  2366. },
  2367. {
  2368. name: "TunnelLength",
  2369. value: featrueMap["tunnelLength"] ? featrueMap["tunnelLength"].value : "",
  2370. mustHasValue: true
  2371. },
  2372. {
  2373. name: "BriTunRate",
  2374. value: featrueMap["briTunRate"] ? featrueMap["briTunRate"].value : "",
  2375. mustHasValue: true
  2376. },
  2377. {
  2378. name: "InterchangeNum",
  2379. value: featrueMap["interchangeNum"] ? featrueMap["interchangeNum"].value : "",
  2380. mustHasValue: true
  2381. },
  2382. {
  2383. name: "StubLengths",
  2384. value: featrueMap["stubLengths"] ? featrueMap["stubLengths"].value : "",
  2385. mustHasValue: true
  2386. },
  2387. {
  2388. name: "LaneLength",
  2389. value: featrueMap["laneLength"] ? featrueMap["laneLength"].value : "",
  2390. mustHasValue: true
  2391. },
  2392. ];
  2393. Element.call(this, "Params", attrs);
  2394. }
  2395. function SummaryOfCost(totalItem, proItem, safeItem, oneToSevenItem, feature) {
  2396. let attrs = [{
  2397. name: "TenderSumLimit",
  2398. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  2399. type: TYPE.DECIMAL,
  2400. toFix: 2,
  2401. },
  2402. {
  2403. name: "BidTotal",
  2404. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  2405. type: TYPE.DECIMAL,
  2406. toFix: 2,
  2407. },
  2408. {
  2409. name: "BillTotal",
  2410. value: oneToSevenItem.feesIndex && oneToSevenItem.feesIndex.common && oneToSevenItem.feesIndex.common.tenderTotalFee ? oneToSevenItem.feesIndex.common.tenderTotalFee : 0,
  2411. type: TYPE.DECIMAL,
  2412. toFix: 2,
  2413. },
  2414. {
  2415. name: "CostForHSE",
  2416. value: safeItem && safeItem.feesIndex && safeItem.feesIndex.common && safeItem.feesIndex.common.tenderTotalFee ? safeItem.feesIndex.common.tenderTotalFee : 0,
  2417. type: TYPE.DECIMAL,
  2418. toFix: 2,
  2419. },
  2420. {
  2421. name: "ProvisionalSums",
  2422. value: proItem.feesIndex && proItem.feesIndex.common && proItem.feesIndex.common.tenderTotalFee ? proItem.feesIndex.common.tenderTotalFee : 0,
  2423. type: TYPE.DECIMAL,
  2424. toFix: 2,
  2425. },
  2426. {
  2427. name: "Appraisal",
  2428. // value: totalItem.feesIndex && totalItem.feesIndex.estimate && totalItem.feesIndex.estimate.tenderTotalFee ? totalItem.feesIndex.estimate.tenderTotalFee : 0,
  2429. value: 0,
  2430. type: TYPE.DECIMAL,
  2431. toFix: 2,
  2432. },
  2433. ];
  2434. if (isBidInvitation) {
  2435. attrs.splice(0, 3) //招标
  2436. }
  2437. //if (isControl) attrs.splice(1, 5); //控制价
  2438. if (isBidSubmission) { //投标文件时,读工程特征中的 招标控制价 值
  2439. let tenderSumLimit = _.find(feature, { "key": "tenderSumLimit" });
  2440. if (tenderSumLimit) attrs[0].value = tenderSumLimit.value
  2441. }
  2442. Element.call(this, "SummaryOfCost", attrs);
  2443. }
  2444. function MakeInfo(tenderProject) {
  2445. let property = tenderProject.property;
  2446. let baseMap = {};
  2447. let baseInfo = _.find(property.basicInformation, {
  2448. dispName: "基本信息",
  2449. });
  2450. for (let i of baseInfo.items) {
  2451. let key = i.key;
  2452. //if (i.dispName == "编制日期") key = "编制时间";
  2453. baseMap[key] = i;
  2454. }
  2455. //mustHasValue
  2456. const attrs = [{
  2457. name: "ValuationModel",
  2458. value: property.taxType,
  2459. },
  2460. {
  2461. name: "Manage",
  2462. value: baseMap["constructingUnit"] ? baseMap["constructingUnit"].value : "",
  2463. },
  2464. {
  2465. name: "Designer",
  2466. value: baseMap["designUnit"] ? baseMap["designUnit"].value : "",
  2467. mustHasValue: true
  2468. },
  2469. {
  2470. name: "Compile",
  2471. value: baseMap["compileUnit"] ? baseMap["compileUnit"].value : "",
  2472. },
  2473. {
  2474. name: "CompileApprover",
  2475. value: baseMap["compileApprover"] ? baseMap["compileApprover"].value : "",
  2476. },
  2477. {
  2478. name: "CompileCertNo",
  2479. value: baseMap["compileCertNo"] ? baseMap["compileCertNo"].value : "",
  2480. mustHasValue: true
  2481. },
  2482. {
  2483. name: "CompileDate",
  2484. value: baseMap["compileDate"] && baseMap["compileDate"].value != "" ? baseMap["compileDate"].value + "T00:00:00" : "",
  2485. mustHasValue: true
  2486. },
  2487. {
  2488. name: "Review",
  2489. value: baseMap["reviewUnit"] ? baseMap["reviewUnit"].value : "",
  2490. mustHasValue: true
  2491. },
  2492. {
  2493. name: "ReviewApprover",
  2494. value: baseMap["reviewApprover"] ? baseMap["reviewApprover"].value : "",
  2495. mustHasValue: true
  2496. },
  2497. {
  2498. name: "ReviewCertNo",
  2499. value: baseMap["reviewCertNo"] ? baseMap["reviewCertNo"].value : "",
  2500. mustHasValue: true
  2501. },
  2502. {
  2503. name: "ReviewDate",
  2504. value: baseMap["reviewDate"] && baseMap["reviewDate"].value != "" ? baseMap["reviewDate"].value + "T00:00:00" : "",
  2505. mustHasValue: true
  2506. },
  2507. {
  2508. name: "Examine",
  2509. value: baseMap["examineUnit"] ? baseMap["examineUnit"].value : "",
  2510. mustHasValue: true
  2511. },
  2512. {
  2513. name: "ExamineApprover",
  2514. value: baseMap["examineApprover"] ? baseMap["examineApprover"].value : "",
  2515. mustHasValue: true
  2516. },
  2517. {
  2518. name: "ExamineCertNo",
  2519. value: baseMap["examineCertNo"] ? baseMap["examineCertNo"].value : "",
  2520. mustHasValue: true
  2521. },
  2522. {
  2523. name: "ExamineDate",
  2524. value: baseMap["examineDate"] && baseMap["examineDate"].value != "" ? baseMap["examineDate"].value + "T00:00:00" : "",
  2525. mustHasValue: true
  2526. },
  2527. {
  2528. name: "CompileExplain",
  2529. value: baseMap["compileExplain"] ? baseMap["compileExplain"].value : "",
  2530. mustHasValue: true
  2531. },
  2532. {
  2533. name: "ExamineExplain",
  2534. value: baseMap["examineExplain"] ? baseMap["examineExplain"].value : "",
  2535. mustHasValue: true
  2536. },
  2537. {
  2538. name: "ProjectExplain",
  2539. value: baseMap["projectExplain"] ? baseMap["projectExplain"].value : "",
  2540. mustHasValue: true
  2541. },
  2542. {
  2543. name: "Bidder",
  2544. // value: baseMap["bidderCompany"] ? baseMap["bidderCompany"].value : "",
  2545. value: baseMap["bidderName"] ? baseMap["bidderName"].value : "",
  2546. mustHasValue: true
  2547. },
  2548. ];
  2549. if (isBidInvitation) { //招标文件,则以下的8、12~18则不输出
  2550. attrs.splice(11, 7);
  2551. attrs.splice(7, 1);
  2552. }
  2553. Element.call(this, "MakeInfo", attrs);
  2554. }
  2555. let data = new CprjInfo(projectData.name);
  2556. data.children.push(new SystemInfo(projectData));
  2557. data.children.push(new CostBasis());
  2558. let seriNo = 1;
  2559. let Rates = [];
  2560. let Practs = [];
  2561. let EprjInfos = [];
  2562. for (let c of projectData.children) {
  2563. let tenderProject = tenderDetailMap[c.ID];
  2564. let feeRataDatas = tenderProject.FeeRate.datas;
  2565. Rates.push(new Rate(tenderProject, feeRataDatas, seriNo));
  2566. Practs.push(new Pract(tenderProject, seriNo));
  2567. EprjInfos.push(new EprjInfo(tenderProject));
  2568. seriNo++;
  2569. }
  2570. data.children.push(...Rates, ...Practs, ...EprjInfos);
  2571. return [{
  2572. data: data,
  2573. exportKind: exportKind,
  2574. fileName: projectData.name + INTERFACE_CONFIG[areaKey]["fileSuffix"][exportKind],
  2575. },];
  2576. }
  2577. // 山东需求,要有密文校验信息(SM3算法,在界面上已导入sm3对象)
  2578. /**
  2579. * SM3加密主函数
  2580. * @param msg
  2581. * @returns
  2582. */
  2583. function sm3Digest(msg) {
  2584. let hashHex = sm3(msg);
  2585. // return hashHex;
  2586. return hashHex.toUpperCase();
  2587. }
  2588. function _extractBillCalcRefs(currentBill) {
  2589. const rst = [];
  2590. function _extract(spliter, excluded = true, nextGap) {
  2591. let currentBillCalcBase = currentBill.calcBase;
  2592. let currentIdx = currentBillCalcBase.indexOf(spliter);
  2593. let exCnt = 0;
  2594. if (excluded) exCnt = spliter.length;
  2595. while (currentIdx >= 0) {
  2596. let bId = currentBillCalcBase.substr(currentIdx + excluded, nextGap);
  2597. if (!rst.includes(bId)) {
  2598. rst.push(bId);
  2599. }
  2600. currentBillCalcBase = currentBillCalcBase.substr(currentIdx + excluded + nextGap);
  2601. currentIdx = currentBillCalcBase.indexOf(spliter);
  2602. }
  2603. }
  2604. if (typeof currentBill.calcBase === 'string') {
  2605. //1. 抽取@引用
  2606. _extract('@', true, 36);
  2607. //2. 抽取特殊引用
  2608. // 2.1 {各章清单合计}
  2609. _extract('{各章清单合计}', false, '{各章清单合计}'.length);
  2610. // 2.2 {100章以外清单合计}
  2611. _extract('{100章以外清单合计}', false, '{100章以外清单合计}'.length);
  2612. }
  2613. return rst;
  2614. }
  2615. function _preCodeingForBills(tenderProject) {
  2616. const cacheObj = {};
  2617. function _chkAdhocChapterBill(bill) {
  2618. let rst = false;
  2619. if (typeof bill.name === 'string' && bill.name.includes('00章') && bill.name.includes('清单')) {
  2620. rst = true;
  2621. }
  2622. return rst;
  2623. }
  2624. function _setCache(bNode) {
  2625. cacheObj['_' + bNode.data.ID] = bNode.data;
  2626. if (bNode.children && bNode.children.length > 0) {
  2627. for (let subNode of bNode.children) {
  2628. _setCache(subNode);
  2629. }
  2630. }
  2631. }
  2632. let rootNodes = tenderProject.mainTree.roots;
  2633. for (let rootNode of rootNodes) {
  2634. _setCache(rootNode);
  2635. }
  2636. let cnt = 1;
  2637. let billsForAcc = [];
  2638. for (let bill of tenderProject.Bills.datas) {
  2639. //这一步设置特殊清单(各章清单合计, 100章~1200章)
  2640. cacheObj['_{100章以外清单合计}'] = {};
  2641. if (_billStrFilter(bill.name).includes('第100章至700章清单') || sectionNameMap[_billStrFilter(bill.name)] || _chkAdhocChapterBill(bill)) {
  2642. if (cacheObj['_' + bill.ID]) {
  2643. if (!cacheObj['_' + bill.ID].hasOwnProperty('formulaCode')) {
  2644. cacheObj['_' + bill.ID].formulaCode = `F${cnt}`;
  2645. cnt++;
  2646. }
  2647. }
  2648. // if (_billStrFilter(bill.name).includes('第100章至700章清单')) {
  2649. if (_billStrFilter(bill.name).includes('第100章至') && _billStrFilter(bill.name).includes('00章清单')) {
  2650. cacheObj['_{各章清单合计}'] = {};
  2651. cacheObj['_{各章清单合计}'].formulaCode = `{F${cnt - 1}}`;
  2652. } else if (!_billStrFilter(bill.name).includes('清单第100章')) {
  2653. billsForAcc.push(`F${cnt - 1}`);
  2654. }
  2655. }
  2656. }
  2657. let tmpStr = ''
  2658. for (let idx = 0; idx < billsForAcc.length; idx++) {
  2659. if (idx === 0) {
  2660. tmpStr = '( ' + `{${billsForAcc[idx]}}`;
  2661. } else {
  2662. tmpStr = tmpStr + ` + {${billsForAcc[idx]}}`;
  2663. }
  2664. if (idx === billsForAcc.length - 1) tmpStr = tmpStr + ' )';
  2665. }
  2666. cacheObj['_{100章以外清单合计}'].formulaCode = tmpStr;
  2667. for (let bill of tenderProject.Bills.datas) {
  2668. let billRefs = _extractBillCalcRefs(bill);
  2669. for (let refBillId of billRefs) {
  2670. if (cacheObj['_' + refBillId]) {
  2671. if (!cacheObj['_' + refBillId].hasOwnProperty('formulaCode')) {
  2672. cacheObj['_' + refBillId].formulaCode = `F${cnt}`;
  2673. cnt++;
  2674. }
  2675. }
  2676. }
  2677. }
  2678. return cacheObj;
  2679. }
  2680. function _getFormulaDispName(cacheForFormula, currentBill) {
  2681. let rst = currentBill.calcBase;
  2682. if (typeof currentBill.calcBase === 'string') {
  2683. //1. @引用
  2684. let currentBillCalcBase = currentBill.calcBase;
  2685. let currentIdx = currentBillCalcBase.indexOf('@');
  2686. let bIdArr = [], replaceArr = [];
  2687. while (currentIdx >= 0) {
  2688. let bId = currentBillCalcBase.substr(currentIdx + 1, 36);
  2689. bIdArr.push(bId);
  2690. if (cacheForFormula['_' + bId]) {
  2691. if (cacheForFormula['_' + bId].hasOwnProperty('formulaCode')) {
  2692. replaceArr.push(`{${cacheForFormula['_' + bId].formulaCode}}`);
  2693. } else {
  2694. replaceArr.push(`{无formulaCode错误:${bId}}`);
  2695. }
  2696. } else {
  2697. replaceArr.push(`{引用错误:${bId}}`);
  2698. }
  2699. currentBillCalcBase = currentBillCalcBase.substr(currentIdx + 37);
  2700. currentIdx = currentBillCalcBase.indexOf('@');
  2701. }
  2702. let tempBillCalcBase = currentBill.calcBase;
  2703. for (let idx = 0; idx < bIdArr.length; idx++) {
  2704. tempBillCalcBase = tempBillCalcBase.replace('@' + bIdArr[idx], replaceArr[idx]);
  2705. }
  2706. //2. 特殊引用
  2707. //{各章清单合计} {100章以外清单合计}
  2708. if (tempBillCalcBase.includes('{各章清单合计}')) {
  2709. console.log(`特殊引用清单{各章清单合计}:${currentBill.name}(${currentBill.code} - ${tempBillCalcBase})`);
  2710. tempBillCalcBase = tempBillCalcBase.replace('{各章清单合计}', cacheForFormula['_{各章清单合计}'].formulaCode);
  2711. }
  2712. if (tempBillCalcBase.includes('{100章以外清单合计}')) {
  2713. console.log(`特殊引用清单{100章以外清单合计}:${currentBill.name}(${currentBill.code} - ${tempBillCalcBase})`);
  2714. tempBillCalcBase = tempBillCalcBase.replace('{100章以外清单合计}', cacheForFormula['_{100章以外清单合计}'].formulaCode);
  2715. }
  2716. //
  2717. rst = tempBillCalcBase;
  2718. }
  2719. return rst;
  2720. }
  2721. return {
  2722. entry,
  2723. };
  2724. })();