shandong_common.js 101 KB

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