shandong_common.js 99 KB

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