shandong_common.js 101 KB

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