shandong_common.js 100 KB

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