shandong_common.js 100 KB

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