shandong_common.js 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857
  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: getXMLTransitCharacters(g.name || ''),
  568. },
  569. {
  570. name: "Spec",
  571. value: getXMLTransitCharacters(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: getXMLTransitCharacters(g.name || ''),
  600. },
  601. {
  602. name: "Spec",
  603. value: getXMLTransitCharacters(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: getXMLTransitCharacters(g.name || ''),
  763. },
  764. {
  765. name: "Spec",
  766. value: getXMLTransitCharacters(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. if (orgSum === Infinity) rst = 0; // 无穷大得给0
  974. // const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  975. // const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  976. // const isControl = exportKind === CONTROL; // 是否是控制价
  977. //根据导出类型(上面3个),输出实际合计或price
  978. if (isBidInvitation) {
  979. rst = 0;
  980. }
  981. return rst;
  982. }
  983. function _getStrValueByExportKind(orgStr) {
  984. let rst = orgStr;
  985. // const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  986. // const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  987. // const isControl = exportKind === CONTROL; // 是否是控制价
  988. //根据导出类型(上面3个),输出实际合计或price
  989. if (isBidInvitation) {
  990. rst = '';
  991. }
  992. return rst;
  993. }
  994. function _getFixedSum(tenderProject) {
  995. let rst = 0;
  996. tenderProject.Bills.datas.forEach((bill) => {
  997. if (bill.specialProvisional == "固定费用") {
  998. let bVal = _getFee(bill);
  999. rst += bVal;
  1000. }
  1001. });
  1002. return rst;
  1003. }
  1004. function quoteSummary(tenderProject) {
  1005. let quoteSummaryItem = new emptyElement('QuoteSummary');
  1006. // let attrs = [];
  1007. //1. 取固定清单,
  1008. // 1.1 100~700章总清单(flags有属性为19的那个) -> topNode100To700
  1009. // 1.2 已包含在清单合计中的材料、工程设备、专业工程暂估价合计 标记:20
  1010. // 1.3 清单合计减去材料、工程设备、专业工程暂估价|合计 标记:21
  1011. // 1.4 计日工合计 标记:22
  1012. // 1.5 暂列金额(不含计日工总额) 标记:26
  1013. // 1.6 投标报价 标记:9
  1014. let topNode100To700, nodeZXZDJ, nodeQDKCZXZDJ, nodeJRG, nodeZLJE, nodeTBBJ, newAddedBill;
  1015. let chapterNodes = [];
  1016. let fixedSum = _getFixedSum(tenderProject); //山东有固定费用,此费用不参与到此项中去
  1017. let nextBillID = '';
  1018. tenderProject.Bills.datas.forEach((bill) => {
  1019. if (bill.flags && bill.flags.length > 0) {
  1020. for (let flag of bill.flags) {
  1021. switch (flag.flag) {
  1022. case 19:
  1023. topNode100To700 = bill;
  1024. break;
  1025. case 20:
  1026. nodeZXZDJ = bill;
  1027. break;
  1028. case 21:
  1029. nodeQDKCZXZDJ = bill;
  1030. break;
  1031. case 22:
  1032. nodeJRG = bill;
  1033. break;
  1034. case 26:
  1035. nodeZLJE = bill;
  1036. nextBillID = bill.NextSiblingID
  1037. break;
  1038. case 9:
  1039. nodeTBBJ = bill;
  1040. break;
  1041. case 44:
  1042. newAddedBill = bill;
  1043. break;
  1044. default:
  1045. break;
  1046. }
  1047. }
  1048. }
  1049. });
  1050. tenderProject.Bills.datas.forEach((bill) => {
  1051. if (bill.type === 1 && bill.ID === nextBillID && nodeTBBJ && nodeTBBJ.ID !== nextBillID) {
  1052. newAddedBill = bill;
  1053. }
  1054. });
  1055. //2. 然后获取topNode100To700下的所有次一级清单(100章...700章)
  1056. if (topNode100To700) {
  1057. for (let rootBill of tenderProject.Bills.tree.roots) {
  1058. // 100~700章总清单在top级别(山东养护)
  1059. if (rootBill.data.ID === topNode100To700.ID) {
  1060. rootBill.children.forEach((subBill) => {
  1061. if (subBill.data.name.includes('00章')) {
  1062. chapterNodes.push(subBill);
  1063. }
  1064. });
  1065. break;
  1066. }
  1067. }
  1068. }
  1069. //3. 拼凑数据
  1070. let nodeAttrs = [];
  1071. if (topNode100To700) {
  1072. let order = 1;
  1073. //读取投标报价汇总表信息。1.ItemNo 序号。2.ChapterNo 章次。 3.Name 科目名称。 4.Sum 金额。
  1074. chapterNodes.forEach((cnode) => {
  1075. if (_chkIfValid100(cnode)) {
  1076. let chapterIdx = cnode.data.name.indexOf("00章");
  1077. let chpNoStr = '';
  1078. const ch = cnode.data.name.substr(chapterIdx - 2, 2);
  1079. if (isNaN(parseFloat(ch))) {
  1080. chpNoStr = cnode.data.name.substr(chapterIdx - 1, 3);
  1081. } else {
  1082. chpNoStr = cnode.data.name.substr(chapterIdx - 2, 4);
  1083. }
  1084. // nodeAttrs.push({ ItemNo: order, ChapterNo: cnode.data.name.substr(chapterIdx - 1, 3), Name: cnode.data.name, Sum: _getFee(cnode) });
  1085. nodeAttrs.push({ ItemNo: order, ChapterNo: chpNoStr, Name: cnode.data.name, Sum: _getFee(cnode) });
  1086. order++;
  1087. }
  1088. });
  1089. // nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: '第100章至700章清单合计', Sum: _getFee(topNode100To700) });
  1090. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: topNode100To700.name, Sum: _getFee(topNode100To700) });
  1091. order++;
  1092. if (nodeZXZDJ) {
  1093. // nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: '已包含在清单合计中的材料、工程设备、专业工程暂估价合计', Sum: _getFee(nodeZXZDJ) - fixedSum});
  1094. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: '已包含在清单合计中的材料、工程设备、专业工程暂估价合计', Sum: _getFee(nodeZXZDJ) }); // 又不需要fixedSum了
  1095. order++;
  1096. }
  1097. if (nodeQDKCZXZDJ) {
  1098. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: `清单合计减去材料、工程设备、专业工程暂估价合计(即${order - 2}-${order - 1})=${order}`, Sum: _getFee(nodeQDKCZXZDJ) });
  1099. order++;
  1100. }
  1101. if (nodeJRG) {
  1102. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: `计日工合计`, Sum: _getFee(nodeJRG) });
  1103. order++;
  1104. }
  1105. if (nodeZLJE) {
  1106. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: `暂列金额(不含计日工总额)`, Sum: _getFee(nodeZLJE) });
  1107. order++;
  1108. }
  1109. if (newAddedBill) {
  1110. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: newAddedBill.name, Sum: _getFee(newAddedBill) });
  1111. order++;
  1112. }
  1113. if (nodeTBBJ) {
  1114. let nameStr = `投标报价(${chapterNodes.length + 1}+${order - 2}+${order - 1})=${order}`;
  1115. if (newAddedBill && nodeTBBJ.calcBase && nodeTBBJ.calcBase.includes(newAddedBill.ID)) {
  1116. nameStr = `投标报价(${chapterNodes.length + 1}+${order - 3}+${order - 2}+${order - 1})=${order}`;
  1117. }
  1118. nodeAttrs.push({ ItemNo: order, ChapterNo: '', Name: nameStr, Sum: _getFee(nodeTBBJ) });
  1119. order++;
  1120. }
  1121. }
  1122. function _Item(item) {
  1123. const attrs = [
  1124. {
  1125. name: 'ItemNo',
  1126. value: item.ItemNo
  1127. },
  1128. {
  1129. name: 'ChapterNo',
  1130. value: item.ChapterNo
  1131. },
  1132. {
  1133. name: 'Name',
  1134. value: getXMLTransitCharacters(item.Name || '')
  1135. },
  1136. {
  1137. name: 'Sum',
  1138. value: scMathUtil.roundForObj(_getNumValueByExportKind(item.Sum), tenderProject.property.decimal.bills.totalPrice)
  1139. // value: 0 // 所有清单的金额都是0
  1140. }
  1141. ];
  1142. let rst = new emptyElement('Item');
  1143. rst.attrs.push(...attrs);
  1144. return rst;
  1145. }
  1146. for (let attr of nodeAttrs) {
  1147. quoteSummaryItem.children.push(_Item(attr));
  1148. }
  1149. return quoteSummaryItem;
  1150. }
  1151. function sporadicWork(tenderProject) {
  1152. //计日工表,含:劳务、材料、施工机械、计日工汇总
  1153. let hasSporadicWork = false;
  1154. let sporadicWorkItem = new Element('SporadicWork');
  1155. let nodeLabour, nodeMaterial, nodeMachine;
  1156. //首先收集过滤计日工相关清单
  1157. tenderProject.Bills.datas.forEach((bill) => {
  1158. if (bill.flags && bill.flags.length > 0) {
  1159. for (let flag of bill.flags) {
  1160. switch (flag.flag) {
  1161. case 23:
  1162. nodeLabour = bill;
  1163. break;
  1164. case 24:
  1165. nodeMaterial = bill;
  1166. break;
  1167. case 25:
  1168. nodeMachine = bill;
  1169. break;
  1170. default:
  1171. break;
  1172. }
  1173. }
  1174. }
  1175. });
  1176. const _buildWorkNodeItem = function (orgNode, subNodes, parentKey, childKey) {
  1177. let parentNode = new Element(parentKey);
  1178. sporadicWorkItem.children.push(parentNode);
  1179. const pSumAttrs = [
  1180. {
  1181. name: 'Sum',
  1182. value: _getNumValueByExportKind(_getFee(orgNode))
  1183. // value: 0
  1184. }
  1185. ];
  1186. // Element.call(this, parentKey, pSumAttrs);
  1187. parentNode.attrs.push(...pSumAttrs);
  1188. subNodes.forEach((node, index) => {
  1189. let childNode = new Element(childKey);
  1190. parentNode.children.push(childNode);
  1191. const attrs = [
  1192. {
  1193. name: 'ItemNo',
  1194. value: (node.code) ? node.code : `${index + 1}`
  1195. }, {
  1196. name: 'Name',
  1197. value: node.name
  1198. }, {
  1199. name: 'Unit',
  1200. value: node.unit
  1201. }, {
  1202. name: 'Num',
  1203. value: node.quantity
  1204. }, {
  1205. name: 'Price',
  1206. value: _getNumValueByExportKind(_getFee(node, 'common', 'tenderUnitFee'))
  1207. // value: 0
  1208. }, {
  1209. name: 'Sum',
  1210. value: _getNumValueByExportKind(_getFee(node))
  1211. // value: 0
  1212. }
  1213. ];
  1214. childNode.attrs.push(...attrs);
  1215. });
  1216. };
  1217. //1. 判断劳务
  1218. if (nodeLabour) {
  1219. let subNodes = [];
  1220. tenderProject.Bills.datas.forEach((bill) => {
  1221. if (bill.ParentID === nodeLabour.ID) {
  1222. subNodes.push(bill);
  1223. }
  1224. });
  1225. if (subNodes.length > 0) {
  1226. hasSporadicWork = true;
  1227. //创建劳务Mps节点及劳务Mps下Mp子节点
  1228. _buildWorkNodeItem(nodeLabour, subNodes, 'Mps', 'Mp');
  1229. }
  1230. }
  1231. //2. 判断材料
  1232. if (nodeMaterial) {
  1233. let subNodes = [];
  1234. tenderProject.Bills.datas.forEach((bill) => {
  1235. if (bill.ParentID === nodeMaterial.ID) {
  1236. subNodes.push(bill);
  1237. }
  1238. });
  1239. if (subNodes.length > 0) {
  1240. hasSporadicWork = true;
  1241. //创建材料Materials节点及劳务Materials下Material子节点
  1242. _buildWorkNodeItem(nodeMaterial, subNodes, 'Materials', 'Material');
  1243. }
  1244. }
  1245. //3. 判断施工机械
  1246. if (nodeMachine) {
  1247. let subNodes = [];
  1248. tenderProject.Bills.datas.forEach((bill) => {
  1249. if (bill.ParentID === nodeMachine.ID) {
  1250. subNodes.push(bill);
  1251. }
  1252. });
  1253. if (subNodes.length > 0) {
  1254. hasSporadicWork = true;
  1255. //创建施工机械Meehs节点及劳务Meehs下Meeh子节点
  1256. _buildWorkNodeItem(nodeMachine, subNodes, 'Mechs', 'Mech');
  1257. }
  1258. }
  1259. //4. 判断计日工汇总
  1260. if (hasSporadicWork) {
  1261. let summaryNode = new Element('Summary');
  1262. sporadicWorkItem.children.push(summaryNode);
  1263. const pSumAttrs = [
  1264. {
  1265. name: 'Sum',
  1266. // value: _getFee(nodeLabour) + _getFee(nodeMaterial) + _getFee(nodeMachine)
  1267. value: _getNumValueByExportKind(_getFee(nodeLabour) + _getFee(nodeMaterial) + _getFee(nodeMachine))
  1268. }
  1269. ];
  1270. summaryNode.attrs = pSumAttrs;
  1271. //把劳务、材料、施工机械
  1272. function _workItem(node, name, remark = '') {
  1273. let childNode = new Element('Item');
  1274. summaryNode.children.push(childNode);
  1275. const attrs = [
  1276. {
  1277. name: "Name",
  1278. value: getXMLTransitCharacters(name || ''),
  1279. },
  1280. {
  1281. name: "Sum",
  1282. value: _getNumValueByExportKind(_getFee(node)),
  1283. },
  1284. {
  1285. name: "Remark",
  1286. value: remark,
  1287. }
  1288. ]
  1289. childNode.attrs.push(...attrs);
  1290. }
  1291. _workItem(nodeLabour, '劳务');
  1292. _workItem(nodeMaterial, '材料');
  1293. _workItem(nodeMachine, '机械');
  1294. }
  1295. //返回
  1296. if (hasSporadicWork) {
  1297. return sporadicWorkItem;
  1298. } else {
  1299. return null;
  1300. }
  1301. }
  1302. function materialEstimate(tenderProject) {
  1303. let mEstNode = new emptyElement('MaterialEstimate');
  1304. let items = [];
  1305. let billItems = [];
  1306. let itemNo = 1;
  1307. //材料暂估价明细
  1308. tenderProject.Bills.datas.forEach((bill) => {
  1309. if (bill.specialProvisional === '材料暂估') {
  1310. billItems.push(bill);
  1311. }
  1312. });
  1313. if (billItems.length > 0) {
  1314. billItems.forEach((bill) => {
  1315. let mEstItemNode = new emptyElement('Item');
  1316. mEstNode.children.push(mEstItemNode);
  1317. let attrs = [
  1318. { name: 'ItemNo', value: itemNo },
  1319. { name: 'Code', value: bill.code },
  1320. { name: 'Number', value: bill.code },
  1321. { name: 'Name', value: getXMLTransitCharacters(bill.name || '') },
  1322. { name: 'Unit', value: bill.unit },
  1323. { name: 'Num', value: bill.quantity },
  1324. { name: 'Price', value: _getNumValueByExportKind(_getFee(bill, 'common', 'tenderUnitFee')) },
  1325. { name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), 0)), type: TYPE.DECIMAL },
  1326. // {name: 'Price', value: 0},
  1327. // {name: 'Sum', value: 0},
  1328. { name: 'Remark', value: (bill.remark) ? bill.remark : '' }
  1329. ];
  1330. itemNo++;
  1331. mEstItemNode.attrs.push(...attrs);
  1332. });
  1333. }
  1334. tenderProject.projectGLJ.datas.gljList.forEach((glj) => {
  1335. if (glj.is_evaluate && glj.type !== 5 && glj.type !== 301) {
  1336. items.push(glj);
  1337. }
  1338. });
  1339. if (items.length > 0) {
  1340. items.forEach((glj) => {
  1341. let mEstItemNode = new emptyElement('Item');
  1342. mEstNode.children.push(mEstItemNode);
  1343. let gljName = glj.name;
  1344. if (tenderProject.evaluate_list.datas && tenderProject.evaluate_list.datas.length > 0) {
  1345. for (let relGlj of tenderProject.evaluate_list.datas) {
  1346. if (relGlj.projectGLJID == glj.id) {
  1347. gljName = relGlj.name;
  1348. break;
  1349. }
  1350. }
  1351. }
  1352. let attrs = [
  1353. { name: 'ItemNo', value: itemNo },
  1354. { name: 'Code', value: _getBidGljCode(tenderProject, glj) },
  1355. { name: 'Number', value: glj.code },
  1356. { name: 'Name', value: getXMLTransitCharacters(gljName || '') },
  1357. { name: 'Unit', value: glj.unit },
  1358. { name: 'Num', value: glj.tenderQuantity },
  1359. // {name: 'Price', value: _getNumValueByExportKind(glj.unit_price.market_price)},
  1360. { name: 'Price', value: glj.unit_price.market_price }, //暂估材料输出price,不需判断导出类型
  1361. { name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(glj.tenderQuantity * glj.unit_price.market_price, 0)), type: TYPE.DECIMAL },
  1362. // {name: 'Price', value: 0},
  1363. // {name: 'Sum', value: 0},
  1364. { name: 'Remark', value: (glj.remark) ? glj.remark : '' }
  1365. ];
  1366. itemNo++;
  1367. mEstItemNode.attrs.push(...attrs);
  1368. });
  1369. }
  1370. if (billItems.length > 0 || items.length > 0) {
  1371. return mEstNode;
  1372. } else {
  1373. return null;
  1374. }
  1375. }
  1376. function getMachineTempEst(tenderProject) {
  1377. let mEstNode = new emptyElement('PrjDeviceEstimate');
  1378. let items = [];
  1379. let billItems = [];
  1380. let itemNo = 1;
  1381. //工程设备明细
  1382. tenderProject.Bills.datas.forEach((bill) => {
  1383. console.log(`bill.specialProvisional: ${bill.specialProvisional}`);
  1384. if (bill.specialProvisional === '工程设备') {
  1385. billItems.push(bill);
  1386. }
  1387. });
  1388. if (billItems.length > 0) {
  1389. billItems.forEach((bill) => {
  1390. let mEstItemNode = new emptyElement('Item');
  1391. mEstNode.children.push(mEstItemNode);
  1392. let attrs = [
  1393. { name: 'ItemNo', value: itemNo },
  1394. { name: 'Code', value: bill.code },
  1395. { name: 'Number', value: bill.code },
  1396. { name: 'Name', value: getXMLTransitCharacters(bill.name || '') },
  1397. { name: 'Unit', value: bill.unit },
  1398. { name: 'Num', value: bill.quantity },
  1399. { name: 'Price', value: _getNumValueByExportKind(_getFee(bill, 'common', 'tenderUnitFee')) },
  1400. { name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), 0)), type: TYPE.DECIMAL },
  1401. // {name: 'Price', value: 0},
  1402. // {name: 'Sum', value: 0},
  1403. { name: 'Remark', value: (bill.remark) ? glj.remark : '' }
  1404. ];
  1405. itemNo++;
  1406. mEstItemNode.attrs.push(...attrs);
  1407. });
  1408. }
  1409. tenderProject.projectGLJ.datas.gljList.forEach((glj) => {
  1410. if (glj.is_evaluate && glj.type === 5) {
  1411. items.push(glj);
  1412. }
  1413. });
  1414. if (items.length > 0) {
  1415. items.forEach((glj, sno) => {
  1416. let mEstItemNode = new emptyElement('Item');
  1417. mEstNode.children.push(mEstItemNode);
  1418. let attrs = [
  1419. { name: 'ItemNo', value: itemNo },
  1420. { name: 'Code', value: _getBidGljCode(tenderProject, glj) },
  1421. { name: 'Number', value: glj.code },
  1422. { name: 'Name', value: getXMLTransitCharacters(glj.name || '') },
  1423. { name: 'Unit', value: glj.unit },
  1424. { name: 'Num', value: glj.tenderQuantity },
  1425. // {name: 'Price', value: _getNumValueByExportKind(glj.unit_price.market_price)},
  1426. { name: 'Price', value: glj.unit_price.market_price }, // 暂估设备直接输出price
  1427. { name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(glj.tenderQuantity * glj.unit_price.market_price, 0)), type: TYPE.DECIMAL },
  1428. // {name: 'Price', value: 0},
  1429. // {name: 'Sum', value: 0},
  1430. { name: 'Remark', value: (glj.remark) ? glj.remark : '' }
  1431. ];
  1432. itemNo++;
  1433. mEstItemNode.attrs.push(...attrs);
  1434. });
  1435. }
  1436. if (billItems.length > 0 || items.length > 0) {
  1437. return mEstNode;
  1438. } else {
  1439. return null;
  1440. }
  1441. }
  1442. function getSpecPrjEst(tenderProject) {
  1443. let mEstNode = new emptyElement('SpecPrjEstimate');
  1444. let sum = 0;
  1445. let items = [];
  1446. //专业工程暂估明细
  1447. tenderProject.Bills.datas.forEach((bill) => {
  1448. if (bill.specialProvisional === '专业工程') {
  1449. items.push(bill);
  1450. }
  1451. });
  1452. if (items.length > 0) {
  1453. items.forEach((bill, sno) => {
  1454. let mEstItemNode = new emptyElement('Item');
  1455. mEstNode.children.push(mEstItemNode);
  1456. let ttl = _getFee(bill);
  1457. sum += ttl;
  1458. let jobContent = '';
  1459. if (bill.jobContent && bill.jobContent.length > 0) {
  1460. jobContent = bill.jobContent.toString();
  1461. } else {
  1462. jobContent = (bill.jobContentText) ? bill.jobContentText : '';
  1463. }
  1464. jobContent = jobContent.replace(regRt1, '&#xA;').replace(regRt2, '&#xA;').replace(reg1, '&#xA;').replace(reg2, '&#xA;'); // 转成XML的换行转义符
  1465. let attrs = [
  1466. { name: 'ItemNo', value: sno + 1 },
  1467. { name: 'Code', value: bill.code },
  1468. { name: 'Number', value: bill.code },
  1469. { name: 'Name', value: getXMLTransitCharacters(bill.name || '') },
  1470. { name: 'Content', value: jobContent },
  1471. // {name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(ttl, 0)), type:TYPE.DECIMAL},
  1472. { name: 'Sum', value: ttl, type: TYPE.DECIMAL },
  1473. // {name: 'Sum', value: 0, type:TYPE.DECIMAL},
  1474. ];
  1475. mEstItemNode.attrs.push(...attrs);
  1476. });
  1477. mEstNode.attrs.push({ name: 'Sum', value: sum });
  1478. return mEstNode;
  1479. } else {
  1480. return null;
  1481. }
  1482. }
  1483. function getBillsAnalyze(tenderProject) {
  1484. if (isBidInvitation) return null; // 招标不输出此部分
  1485. // 本函数是尽量复刻【5.5表】工程量清单单价分析表的‘综合’计算式脚本的相关逻辑,具体细节根据实际环境有所调整(前端环境已有不少现成的结构及数据,能少跑不少逻辑)
  1486. let djfxbNode = new emptyElement('ListUnitPriceAnalysis');
  1487. let decimalObj = tenderProject.property.decimal;
  1488. // 工程量清单单价分析(100~700章 清单下所有定额工料机的综合)
  1489. let topNode100To700;
  1490. let sno = 1;
  1491. const prefix = '_';
  1492. let filterMtlTypes = [202, 203, 204, 301];
  1493. for (let bill of tenderProject.Bills.datas) {
  1494. if (bill.flags && bill.flags.length > 0) {
  1495. for (let flag of bill.flags) {
  1496. if (flag.flag === 19) {
  1497. for (let rootBill of tenderProject.Bills.tree.roots) {
  1498. if (rootBill.data.ID === bill.ID) {
  1499. topNode100To700 = rootBill;
  1500. break;
  1501. }
  1502. }
  1503. break;
  1504. }
  1505. }
  1506. }
  1507. }
  1508. const cacheObj = {};
  1509. const proKeysArr = [];
  1510. const addedGljCodeCache = {};
  1511. //说明:根据实际情况,用户会直接在清单下加工料机,此工料机属于定额层次,那么算工程量的时候要加上这个(沟通后这种几率很小,暂时返回0,如有再补上)
  1512. const _getAdhocGljQty = function (billsId, rationCode, rstType = 1) {
  1513. let rst = 0;
  1514. // for (let nbidx = 0; nbidx < newRBillsIdArr.length; nbidx++) {
  1515. // if (newRBillsIdArr[nbidx] === billsId && newRCodeArr[nbidx] === rationCode) {
  1516. // rst = (rstType === 1) ? newRQtyArr[nbidx] : newTtlArr[nbidx];
  1517. // break;
  1518. // }
  1519. // }
  1520. return rst;
  1521. };
  1522. const _getCacheObjInitialedItem = function (bill = null, glj = null) {
  1523. let rst = {
  1524. code: (bill) ? bill.code : ((glj) ? glj.code : ''),
  1525. name: (bill) ? bill.name : ((glj) ? glj.name : ''),
  1526. quantity: (bill) ? bill.quantity : 1,
  1527. labourConsume: 0,
  1528. labourUnitPrice: 0,
  1529. labourTotalPrice: 0,
  1530. mainMaterialFee: 0,
  1531. auxiliaryMaterialFee: 0,
  1532. materialUnitFee: (bill) ? _getFee(bill, 'marketMaterial', 'unitFee') : 0,
  1533. machineFee: (bill) ? _getFee(bill, 'marketMachine') : 0,
  1534. otherFee: (bill) ? _getFee(bill, 'measure') : 0, //措施费
  1535. managementFee: (bill) ? (_getFee(bill, 'manage') + _getFee(bill, 'force')) : 0, //管理+规费
  1536. taxFee: (bill) ? _getFee(bill, 'tax') : 0,
  1537. profitFee: (bill) ? _getFee(bill, 'profit') : 0,
  1538. unitPrice: (bill) ? _getFee(bill, 'common', 'unitFee') : 0,
  1539. items: []
  1540. };
  1541. return rst;
  1542. };
  1543. const _getPrjGLJ = function (gljID) {
  1544. let rst = null;
  1545. for (let glj of tenderProject.projectGLJ.datas.gljList) {
  1546. if (glj.id === gljID) {
  1547. rst = glj;
  1548. break;
  1549. }
  1550. }
  1551. return rst;
  1552. };
  1553. const _getRation = function (rationId) {
  1554. let rst = null;
  1555. for (let ration of tenderProject.Ration.datas) {
  1556. if (ration.ID === rationId) {
  1557. rst = ration;
  1558. break;
  1559. }
  1560. }
  1561. return rst;
  1562. };
  1563. const _createNode = function (billIdKey, bill) {
  1564. if (cacheObj[billIdKey]) {
  1565. //1. 叶子清单,先创建清单Item
  1566. let bQtn = 1;
  1567. if (bill.data.hasOwnProperty('quantity')) {
  1568. bQtn = parseFloat(bill.data.quantity);
  1569. if (isNaN(bQtn)) bQtn = 1;
  1570. // if (bQtn)
  1571. }
  1572. let billMainMaterialTtl = cacheObj[billIdKey].mainMaterialFee / bQtn;
  1573. let billAuxiliaryMaterialTtl = cacheObj[billIdKey].auxiliaryMaterialFee / bQtn;
  1574. // scMathUtil.roundForObj(cacheObj[billIdKey].labourConsume / bQtn, decimalObj.glj.unitPrice)
  1575. let leafBillAttrs = [
  1576. { name: 'ItemNo', value: sno },
  1577. { name: 'Code', value: cacheObj[billIdKey].code },
  1578. { name: 'Name', value: getXMLTransitCharacters(cacheObj[billIdKey].name) },
  1579. { name: 'LaborWorkDays', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourConsume / bQtn, decimalObj.glj.quantity)) },
  1580. { name: 'LaborUnitPrice', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourUnitPrice, decimalObj.glj.unitPrice)) },
  1581. { name: 'LaborUnitTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourTotalPrice / bQtn, decimalObj.glj.unitPrice)) },
  1582. { name: 'MainMaterialConsume', value: 0 },
  1583. { name: 'MainMaterialUnit', value: '' },
  1584. { name: 'MainMaterialUnitPrice', value: 0 },
  1585. { name: 'MainMaterialTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(billMainMaterialTtl, decimalObj.glj.unitPrice)) },
  1586. { name: 'AuxiliaryMaterialFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(billAuxiliaryMaterialTtl, decimalObj.glj.unitPrice)) },
  1587. { name: 'MaterialSum', value: _getNumValueByExportKind(scMathUtil.roundForObj(billMainMaterialTtl + billAuxiliaryMaterialTtl, decimalObj.glj.unitPrice)) },
  1588. { name: 'MachUsageFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].machineFee / bQtn, decimalObj.glj.unitPrice)) },
  1589. { name: 'OtherFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].otherFee / bQtn, decimalObj.glj.unitPrice)) },
  1590. { name: 'ManageFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].managementFee / bQtn, decimalObj.glj.unitPrice)) },
  1591. { name: 'Tax', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].taxFee / bQtn, decimalObj.glj.unitPrice)) },
  1592. { name: 'Profit', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].profitFee / bQtn, decimalObj.glj.unitPrice)) },
  1593. { name: 'Price', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill, 'common', 'tenderUnitFee'), decimalObj.glj.unitPrice)) },
  1594. ];
  1595. sno++;
  1596. let leafItemNode = new emptyElement('Item');
  1597. djfxbNode.children.push(leafItemNode);
  1598. // leafItemNode.attrs.push(...leafBillAttrs);
  1599. leafItemNode.attrs = leafBillAttrs;
  1600. //2. 清单下工料机
  1601. cacheObj[billIdKey].items.forEach((gljItem) => {
  1602. let showQty = gljItem.mainMaterialConsume / bQtn;
  1603. showQty = Math.round(showQty * 1000000) / 1000000;
  1604. let gljAttrs = [
  1605. { name: 'ItemNo', value: sno },
  1606. { name: 'Code', value: gljItem.code },
  1607. { name: 'Name', value: getXMLTransitCharacters(gljItem.name || '') },
  1608. { name: 'LaborWorkDays', value: 0 },
  1609. { name: 'LaborUnitPrice', value: 0 },
  1610. { name: 'LaborUnitTotal', value: 0 },
  1611. // {name: 'MainMaterialConsume', value: scMathUtil.roundForObj(showQty, decimalObj.glj.quantity)},
  1612. { name: 'MainMaterialConsume', value: _getNumValueByExportKind(scMathUtil.roundForObj(showQty, decimalObj.glj.quantity)) },
  1613. // {name: 'MainMaterialUnit', value: gljItem.mainMaterialUnit},
  1614. { name: 'MainMaterialUnit', value: _getStrValueByExportKind(gljItem.mainMaterialUnit) },
  1615. { name: 'MainMaterialUnitPrice', value: _getNumValueByExportKind(scMathUtil.roundForObj(gljItem.mainMaterialUnitPrice, decimalObj.glj.unitPrice)) },
  1616. { name: 'MainMaterialTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(showQty * gljItem.mainMaterialUnitPrice, decimalObj.glj.unitPrice)) },
  1617. { name: 'AuxiliaryMaterialFee', value: 0 },
  1618. { name: 'MaterialSum', value: 0 },
  1619. { name: 'MachUsageFee', value: 0 },
  1620. { name: 'OtherFee', value: 0 },
  1621. { name: 'ManageFee', value: 0 },
  1622. { name: 'Tax', value: 0 },
  1623. { name: 'Profit', value: 0 },
  1624. // {name: 'Price', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), decimalObj.glj.unitPrice))},
  1625. { name: 'Price', value: 0 },
  1626. ];
  1627. sno++;
  1628. let gljItemNode = new emptyElement('Item');
  1629. djfxbNode.children.push(gljItemNode);
  1630. // gljItemNode.attrs.push(...gljAttrs);
  1631. gljItemNode.attrs = gljAttrs;
  1632. });
  1633. }
  1634. };
  1635. const _getAllGlj = function (parentBill) {
  1636. if (parentBill.data.name === '挖除水泥混凝土路面(平面交叉)') {
  1637. debugger;
  1638. }
  1639. if (parentBill.children.length > 0) {
  1640. parentBill.children.forEach((subBill) => {
  1641. _getAllGlj(subBill);
  1642. });
  1643. } else {
  1644. let billIdKey = prefix + parentBill.data.ID;
  1645. if (!cacheObj.hasOwnProperty(billIdKey)) {
  1646. cacheObj[billIdKey] = _getCacheObjInitialedItem(parentBill.data);
  1647. addedGljCodeCache[billIdKey] = [];
  1648. proKeysArr.push(billIdKey);
  1649. }
  1650. tenderProject.ration_glj.datas.forEach((rglj) => {
  1651. if (rglj.billsItemID === parentBill.data.ID) {
  1652. let ration = _getRation(rglj.rationID);
  1653. if (ration) {
  1654. // 计算消耗量,否则定额人材机消耗量取值会不正确
  1655. gljOprObj.getTotalQuantity(rglj, ration);
  1656. }
  1657. let gljQty = parseFloat(rglj.tenderQuantity || rglj.quantity);
  1658. if (isNaN(gljQty)) gljQty = 0;
  1659. let gljRationQty = 0;
  1660. if (ration) gljRationQty = parseFloat(ration.tenderQuantity || ration.quantity);
  1661. if (isNaN(gljRationQty)) gljRationQty = 0;
  1662. let gljCns = gljQty * gljRationQty;
  1663. let prjGlj = _getPrjGLJ(rglj.projectGLJID);
  1664. let gljUnitPrice = parseFloat(prjGlj.unit_price.market_price);
  1665. let gljTotalPrice = gljCns * gljUnitPrice;
  1666. let gljCode = rglj.code;
  1667. if (rglj.type === 1) {
  1668. //人工
  1669. cacheObj[billIdKey].labourConsume = cacheObj[billIdKey].labourConsume + gljCns;
  1670. cacheObj[billIdKey].labourUnitPrice = gljUnitPrice;
  1671. cacheObj[billIdKey].labourTotalPrice = cacheObj[billIdKey].labourTotalPrice + gljTotalPrice;
  1672. } else if (filterMtlTypes.indexOf(rglj.type) < 0) {
  1673. if (!addedGljCodeCache[billIdKey].includes(gljCode)) {
  1674. addedGljCodeCache[billIdKey].push(gljCode);
  1675. }
  1676. if (prjGlj.is_main_material) {
  1677. let dtlObj = {};
  1678. dtlObj.code = gljCode;
  1679. dtlObj.name = rglj.name;
  1680. dtlObj.specs = rglj.specs;
  1681. //
  1682. let adhocGljQty = _getAdhocGljQty(parentBill.data.ID, dtlObj.code);
  1683. let adhocGljTtl = adhocGljQty * gljUnitPrice;
  1684. dtlObj.mainMaterialConsume = gljCns + adhocGljQty; //考虑清单单独加工料机的情况,需要补上消耗量
  1685. dtlObj.mainMaterialUnitPrice = gljUnitPrice;
  1686. dtlObj.mainMaterialTotalPrice = gljTotalPrice;
  1687. dtlObj.mainMaterialUnit = rglj.unit;
  1688. let isAdd = 0;
  1689. for (let i = 0; i < cacheObj[billIdKey].items.length; i++) {
  1690. //先比较对象中是否已存在同一条工料机,存在,则累加汇总消耗量和金额;否则添加。
  1691. 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) {
  1692. cacheObj[billIdKey].items[i].mainMaterialConsume = cacheObj[billIdKey].items[i].mainMaterialConsume + gljCns;
  1693. cacheObj[billIdKey].items[i].mainMaterialTotalPrice = cacheObj[billIdKey].items[i].mainMaterialTotalPrice + gljTotalPrice;
  1694. isAdd = 1;
  1695. break;
  1696. }
  1697. }
  1698. if (isAdd === 0) {
  1699. cacheObj[billIdKey].items.push(dtlObj);
  1700. }
  1701. cacheObj[billIdKey].mainMaterialFee = cacheObj[billIdKey].mainMaterialFee + gljTotalPrice + adhocGljTtl;
  1702. } else {
  1703. cacheObj[billIdKey].auxiliaryMaterialFee = cacheObj[billIdKey].auxiliaryMaterialFee + gljTotalPrice;
  1704. }
  1705. }
  1706. }
  1707. });
  1708. // 整理完后,开始创建XML节点(这里与参考脚本逻辑不一样了,直接开始创建)
  1709. _createNode(billIdKey, parentBill);
  1710. }
  1711. };
  1712. if (topNode100To700) {
  1713. topNode100To700.children.forEach((topChapterBill) => {
  1714. _getAllGlj(topChapterBill);
  1715. });
  1716. }
  1717. //...
  1718. return djfxbNode;
  1719. }
  1720. function getBidEvaluationMainMaterial(tenderProject) {
  1721. let bidMaterials = [];
  1722. let i = 1;
  1723. for (let b of tenderProject.bidMaterialData) {
  1724. bidMaterials.push(new BidEvaluationMainMaterial(b, i));
  1725. i++
  1726. }
  1727. return bidMaterials;
  1728. function BidEvaluationMainMaterial(b, index) {
  1729. const attrs = [{
  1730. name: "Code",
  1731. value: b.seq,
  1732. },
  1733. {
  1734. name: "Number",
  1735. value: b.code
  1736. },
  1737. {
  1738. name: "Name",
  1739. value: b.name
  1740. },
  1741. {
  1742. name: "Specification",
  1743. value: b.specs
  1744. },
  1745. {
  1746. name: "Unit",
  1747. value: b.unit
  1748. },
  1749. {
  1750. name: "Price",
  1751. value: _getNumValueByExportKind(b.marketPrice || '0'),
  1752. type: TYPE.DECIMAL
  1753. },
  1754. {
  1755. name: "LimitedPrice",
  1756. value: _getNumValueByExportKind(b.marketPrice || '0'),
  1757. type: TYPE.DECIMAL
  1758. },
  1759. {
  1760. name: "Quantity",
  1761. value: b.quantity,
  1762. type: TYPE.DECIMAL
  1763. },
  1764. {
  1765. name: "Total",
  1766. value: 0
  1767. },
  1768. {
  1769. name: "Remark",
  1770. value: b.remark
  1771. }
  1772. ];
  1773. if (isBidSubmission || isControl) {
  1774. attrs[7].value = b.quantity;
  1775. attrs[8].value = b.totalPrice;
  1776. }
  1777. Element.call(this, "BidEvaluationMainMaterial", attrs);
  1778. }
  1779. }
  1780. function getIndexs(tenderProject) {
  1781. let Indexs = new emptyElement('Indexs');
  1782. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  1783. for (let f of feature) {
  1784. if (f.code) Indexs.children.push(new IndexItem(f))
  1785. }
  1786. return Indexs;
  1787. function IndexItem(fea) {
  1788. const attrs = [{
  1789. name: "Code",
  1790. value: fea.code,
  1791. },
  1792. {
  1793. name: "Name",
  1794. value: fea.dispName,
  1795. },
  1796. {
  1797. name: "Unit",
  1798. value: fea.unit,
  1799. },
  1800. {
  1801. name: "Value",
  1802. value: fea.value,
  1803. },
  1804. {
  1805. name: "Remark",
  1806. value: fea.remark,
  1807. }
  1808. ]
  1809. Element.call(this, "IndexItem", attrs);
  1810. }
  1811. }
  1812. function _chkIfValid100(node) {
  1813. let rst = true;
  1814. if (node.data.name?.indexOf('第100章') >= 0 && node.data.name?.indexOf('总则') >= 0) {
  1815. let bVal = _getFee(node);
  1816. rst = node.children.length > 0 || bVal !== 0;
  1817. }
  1818. return rst;
  1819. }
  1820. function getBillsItems(tenderProject, cacheForFormula) {
  1821. let items = new emptyElement("Items");
  1822. let rootNodes = tenderProject.mainTree.roots;
  1823. for (let r of rootNodes) {
  1824. setItem(r, -1, items.children);
  1825. }
  1826. return items;
  1827. function setItem(bNode, level, list, dftListCodeSeq = -1) {
  1828. const specialChkBillFlag = [fixedFlag.DAYWORK_LABOR, fixedFlag.LABOUR_SERVICE, fixedFlag.MATERIAL, fixedFlag.CONSTRUCTION_MACHINE];
  1829. if (bNode.sourceType == ModuleNames.ration) return;
  1830. // 判断: 1. 招标清单 2. 是否量价,都是的话,return
  1831. if (isBidInvitation && (bNode.data.specialProvisional == "材料暂估" || bNode.data.specialProvisional == "工程设备")) {
  1832. return;
  1833. }
  1834. // 判断: 100章下无子清单,且金额为0时,return
  1835. if (!_chkIfValid100(bNode)) {
  1836. return;
  1837. }
  1838. let item = new bill(bNode, level, dftListCodeSeq);
  1839. if (bNode.children && bNode.children.length > 0) {
  1840. level += 1;
  1841. let dftLCStartSeq = -1;
  1842. if (isFlag(bNode.data) && specialChkBillFlag.includes(bNode.data.flagsIndex.fixed.flag)) {
  1843. dftLCStartSeq = 1;
  1844. }
  1845. for (let c of bNode.children) {
  1846. setItem(c, level, item.children, dftLCStartSeq);
  1847. if (dftLCStartSeq > 0) dftLCStartSeq++;
  1848. }
  1849. }
  1850. list.push(item);
  1851. function getCalcType(node) {
  1852. /*
  1853. 判断是否父项:
  1854. 是父项,则取1;
  1855. 是叶子项,则判断其下有无套定额/量价/工料机:
  1856. 有则取1;
  1857. 无则判断有无基数计算:
  1858. 有则取2;
  1859. 无则取3 */
  1860. if (node.children && node.children.length > 0) {
  1861. return 1; //是父项,则取1, 有套定额/量价/工料机,也取1
  1862. } else {
  1863. return node.data.calcBase && node.data.calcBase != "" ? 2 : 3
  1864. }
  1865. }
  1866. function getItemType(node) {
  1867. let Bills = projectObj.project.Bills;
  1868. //是100~900章部分、或是计日工部分,叶子清单输出1,父项输出0;
  1869. if (Bills.isBelongOneToSeven(node) || Bills.isBelongDayWork(node)) {
  1870. if (node.children && node.children.length > 0) {
  1871. return node.children[0].sourceType == ModuleNames.ration ? 1 : 0
  1872. }
  1873. //山东新需求:清单 第XXX章、计日工、劳务、材料、机械 输出0
  1874. const bNodeName = _billStrFilter(node.data.name);
  1875. if (bNodeName.indexOf('清单第') >= 0 && bNodeName.indexOf('00章') > 0) {
  1876. return 0;
  1877. } else if (isFlag(node.data) && specialChkBillFlag.includes(node.data.flagsIndex.fixed.flag)) {
  1878. return 0;
  1879. }
  1880. return 1 //叶子清单输出1
  1881. } else {
  1882. return 0;
  1883. /* //非100~900章部分,
  1884. // 是暂列金额,判断暂列金额的金额等于0,则输出为0;暂列金额的金额不等于0,则输出为1;
  1885. if (node.data.name && node.data.name.indexOf("暂列金额") != -1) {
  1886. let sum = node.data.feesIndex && node.data.feesIndex.common ? node.data.feesIndex.common.tenderTotalFee : "";
  1887. return gljUtil.isNotEmpty(sum) ? 1 : 0
  1888. } else { //非暂列金额,则判断清单的工程量是否等于0,等于0,则输出0;不等于0,则输出1
  1889. return gljUtil.isNotEmpty(node.data.quantity) ? 1 : 0
  1890. } */
  1891. }
  1892. }
  1893. function bill(bNode, level, dftListCodeSeq = -1) {
  1894. let data = bNode.data;
  1895. let CostKind = 3;
  1896. if (data.name === undefined || data.name === null) data.name = '';
  1897. if (data.name && data.name.indexOf("安全生产费") != -1) CostKind = 1;
  1898. if (data.name && data.name.indexOf("暂列金额") != -1) CostKind = 2;
  1899. //1 = 工程量×综合单价;2 = 计算基数×费率;3 = 工程量×单价。
  1900. let CalcType = getCalcType(bNode);
  1901. //取暂估价类型。读取造价书界面的专项暂定列。0=材料暂估价,1=工程设备暂估价,2=专业工程暂估价,没有选的输出为空。
  1902. let ProvisionalType = "";
  1903. if (data.specialProvisional == "材料暂估") ProvisionalType = 0;
  1904. if (data.specialProvisional == "工程设备") ProvisionalType = 1;
  1905. if (data.specialProvisional == "专业工程") ProvisionalType = 2;
  1906. if (data.specialProvisional == "固定费用") ProvisionalType = 3;
  1907. //MpRatio
  1908. let MpRatio = "";
  1909. let MaterialRatio = "";
  1910. let MechRatio = "";
  1911. if (data.quantityCoe) {
  1912. if (data.quantityCoe["labour"]) MpRatio = data.quantityCoe["labour"];
  1913. if (data.quantityCoe["material"]) MaterialRatio = data.quantityCoe["material"];
  1914. if (data.quantityCoe["machine"]) MechRatio = data.quantityCoe["machine"];
  1915. }
  1916. let fail = billNameChecking(bNode, tenderProject.projectInfo.name, fixedFlag)
  1917. //fail: { hint: '错误提示', type: '提示所属(基本就是单位工程名称)' }
  1918. let ListCode = "";
  1919. // if (ListCodeMap[data.name]) ListCode = ListCodeMap[data.name];
  1920. if (ListCodeMap[_billStrFilter(data.name)]) {
  1921. ListCode = ListCodeMap[_billStrFilter(data.name)];
  1922. } else if (_chkAdhocChapterBillCode(data.name)) {
  1923. ListCode = _extractAdhocChapter(data.name);
  1924. } else if (data.code && data.code != "") {
  1925. ListCode = data.code;
  1926. } else if (dftListCodeSeq > 0) {
  1927. ListCode = `${dftListCodeSeq}`;
  1928. }
  1929. let qtyFormula = data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "";
  1930. //data.calcBase //data.calcBase ? cbParser.toFExpr(data.calcBase, tenderProject.mainTree.items) : "",
  1931. if (!data.name.includes('暂列金额') && isBidInvitation) {
  1932. if (data.hasOwnProperty('calcBase')) {
  1933. let chkNaN = parseFloat(data.calcBase);
  1934. if (isNaN(chkNaN)) {
  1935. qtyFormula = data.calcBase;
  1936. } else {
  1937. qtyFormula = '';
  1938. }
  1939. } else {
  1940. qtyFormula = '';
  1941. }
  1942. //判断公式(calcBase)是否为正常的计算公式(即非直接输入数量),
  1943. }
  1944. let formulaCode = '';
  1945. if (cacheForFormula['_' + data.ID] && cacheForFormula['_' + data.ID].formulaCode) {
  1946. formulaCode = cacheForFormula['_' + data.ID].formulaCode;
  1947. }
  1948. const attrs = [{
  1949. name: "ListCode",
  1950. value: ListCode,
  1951. },
  1952. {
  1953. name: "ListName",
  1954. value: data.name,
  1955. fail: fail
  1956. },
  1957. {
  1958. name: "Unit",
  1959. value: data.unit,
  1960. },
  1961. {
  1962. name: "Num",
  1963. value: data.quantity,
  1964. type: TYPE.DECIMAL,
  1965. toFix: 3
  1966. },
  1967. {
  1968. name: "QtyFormula",
  1969. value: qtyFormula,
  1970. type: TYPE.DECIMAL,
  1971. toFix: 2
  1972. },
  1973. {
  1974. name: "Price",
  1975. value: 0,//data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderUnitFee : "",
  1976. type: TYPE.DECIMAL,
  1977. toFix: 2
  1978. },
  1979. {
  1980. name: "Rate",
  1981. value: 100,
  1982. },
  1983. {
  1984. name: "Sum",
  1985. value: 0,//data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "",
  1986. type: TYPE.DECIMAL,
  1987. toFix: 2
  1988. },
  1989. {
  1990. name: "ChapterKind",
  1991. value: level > 3 ? 3 : level,
  1992. },
  1993. {
  1994. name: "CostKind",
  1995. value: CostKind,
  1996. },
  1997. {
  1998. name: "CalcType",
  1999. value: CalcType,
  2000. },
  2001. {
  2002. name: "ProvisionalType",
  2003. value: ProvisionalType,
  2004. mustHasValue: true
  2005. },
  2006. {
  2007. name: "MeterRules",
  2008. value: "",
  2009. },
  2010. {
  2011. name: "Content",
  2012. value: data.jobContentText,
  2013. },
  2014. {
  2015. name: "Remarks",
  2016. value: data.remark,
  2017. },
  2018. /* {
  2019. name: "MpRatio",
  2020. value: MpRatio,
  2021. },
  2022. {
  2023. name: "MaterialRatio",
  2024. value: MaterialRatio,
  2025. },
  2026. {
  2027. name: "MechRatio",
  2028. value: MechRatio,
  2029. },
  2030. {
  2031. name: "AdjustedPrice",
  2032. value: data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderUnitFee : "",
  2033. },
  2034. {
  2035. name: "AdjustedSums",
  2036. value: data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "",
  2037. }, */
  2038. {
  2039. name: "ItemType",
  2040. value: getItemType(bNode),
  2041. },
  2042. /* {
  2043. name: "FomulaCode",
  2044. value: ""
  2045. }, */
  2046. {
  2047. name: "FormulaCode",
  2048. value: formulaCode,
  2049. },
  2050. ];
  2051. //投标、招标控制价时。取单价。
  2052. //招标时,如果是“安全生产费”或“暂列金额”,取单价,否则取0。
  2053. // 新需求:安全生产费在招标时也不输出(CostKind === 1)
  2054. // if (isBidSubmission || isControl || CostKind == 1 || CostKind == 2 || ProvisionalType === 2 || ProvisionalType === 3) {
  2055. if (isBidSubmission || isControl || CostKind == 2 || ProvisionalType === 2 || ProvisionalType === 3) {
  2056. attrs[5].value = data.feesIndex && data.feesIndex.common ? scMathUtil.roundForObj(data.feesIndex.common.tenderUnitFee, tenderProject.property.decimal.bills.unitPrice) : "";
  2057. attrs[7].value = data.feesIndex && data.feesIndex.common ? scMathUtil.roundForObj(data.feesIndex.common.tenderTotalFee, tenderProject.property.decimal.bills.totalPrice) : "";
  2058. //暂列金额 数量为0的时候,单价输出0
  2059. if (CostKind == 2 && !gljUtil.isNotEmpty(data.quantity)) attrs[5].value = 0
  2060. }
  2061. let fixedSumVal = _getFixedSum(tenderProject); // 固定费用
  2062. Element.call(this, "Item", attrs);
  2063. let cc = CostComposition(bNode);
  2064. if (cc) this.children.push(cc);
  2065. this.children.push(CostStructure(data, tenderProject.property.decimal.bills.totalPrice))
  2066. function CostComposition(bNode) {
  2067. // 山东逻辑:如果清单下有计算基数,则需要输出(废弃)
  2068. // 新逻辑:
  2069. // 标准接口文档里,写了只有招标清单,才是完全不输出定额相关数据的
  2070. // 当清单有清单基数和费率,那么应该就是没有定额,不输出定额;
  2071. // 清单没有基数和费率,也没有下挂定额,那么也不输出定额相关字段;
  2072. // 清单有下挂定额、量价,那么输出定额相关数据。
  2073. // if (isBidInvitation) return null; // 山东接口又要这个了
  2074. let CostComposition = new emptyElement('CostComposition');
  2075. let Norms = [];
  2076. let Costs = [];
  2077. if (bNode.children && bNode.children.length > 0 && bNode.children[0].sourceType == ModuleNames.ration) {
  2078. for (let r of bNode.children) {
  2079. if (r.data.type == rationType.ration) {
  2080. if (isEmptyRation(r.data) || isBidInvitation) continue; // 招标 或者 定额空行不输出到接口文件中。
  2081. Norms.push(new Ration(r.data));
  2082. } else if (!isBidInvitation) {
  2083. Costs.push(new Cost(r.data));
  2084. }
  2085. }
  2086. }
  2087. if (Norms.length > 0) CostComposition.children.push(...Norms);
  2088. if (Costs.length > 0) CostComposition.children.push(...Costs);
  2089. if (bNode.data.calcBase) CostComposition.children.push(new Formula(bNode.data));
  2090. return CostComposition.children.length > 0 ? CostComposition : null;
  2091. //定额空行不输出到接口文件中。 //定额空行的判断是:定额编码、定额名称、定额单位、定额单位、定额工程量为零或为空时
  2092. function isEmptyRation(ration) {
  2093. return !gljUtil.isNotEmpty(ration.code) && !gljUtil.isNotEmpty(ration.name) && !gljUtil.isNotEmpty(ration.unit) && (!gljUtil.isNotEmpty(ration.quantity) || ration.quantity == 0)
  2094. }
  2095. function Formula(bills) {
  2096. let sumFix = (bills.name === '已包含在清单合计中的材料、工程设备、专业工程暂估价合计') ? fixedSumVal : 0;
  2097. const attrs = [{
  2098. name: "Name",
  2099. value: bills.name
  2100. },
  2101. {
  2102. name: "Formulas",
  2103. value: _getFormulaDispName(cacheForFormula, bills)
  2104. },
  2105. {
  2106. name: "Ratio",
  2107. value: 1
  2108. },
  2109. {
  2110. name: "Sum",
  2111. // value: bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : "",
  2112. // value: _getNumValueByExportKind(bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : "") - sumFix,
  2113. value: _getNumValueByExportKind(bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : ""), // 不用再减一次sumFix
  2114. type: TYPE.DECIMAL
  2115. },
  2116. {
  2117. name: "Remarks",
  2118. value: bills.remark
  2119. }
  2120. ]
  2121. Element.call(this, "Formula", attrs);
  2122. // 1.Name
  2123. // 名称/描述。取清单的名称。
  2124. // 2.Formulas
  2125. // 计算式。读取计算基数的文本。
  2126. // 取基数计算窗口内容,基数直接转换为金额?参考标准文档的 7.11 及 7.12 节。
  2127. // 7.11是定额的费用,7.12是清单累进基数,主要是估概预算中用到,清单里的不同,所以中山的接口直接输出基数文本。
  2128. // 3.Ratio
  2129. // 系数。输出为1,非必填。
  2130. // 4.Sum
  2131. // 取金额。
  2132. // 5.Remarks
  2133. }
  2134. function Cost(item) {
  2135. let BasePrice = 0;
  2136. if (item.type == rationType.volumePrice) { // 当插入的是量价时,基价读取单价列。
  2137. BasePrice = item.feesIndex && item.feesIndex.common ? item.feesIndex.common.tenderUnitFee : 0
  2138. } else {
  2139. BasePrice = getBasePrice(item.projectGLJID, tenderProject)
  2140. }
  2141. let calcMap = tenderProject.calcProgram.compiledTemplateMaps
  2142. let CostTypeNo = '';
  2143. if (feeRateMap[calcMap[item.programID]]) CostTypeNo = feeRateMap[calcMap[item.programID]];
  2144. const attrs = [{
  2145. name: "Code",
  2146. value: item.code,
  2147. }, {
  2148. name: 'Name',
  2149. value: item.name
  2150. }, {
  2151. name: 'Spec',
  2152. value: item.specs
  2153. }, {
  2154. name: 'Unit',
  2155. value: item.unit
  2156. }, {
  2157. name: 'Num',
  2158. value: item.tenderQuantity
  2159. }, {
  2160. name: 'BasePrice',
  2161. value: BasePrice
  2162. }, {
  2163. name: 'Price',
  2164. value: item.feesIndex && item.feesIndex.common ? item.feesIndex.common.tenderUnitFee : 0
  2165. }, {
  2166. name: 'IsEquipment',
  2167. value: item.subType == gljType.EQUIPMENT ? 1 : 0
  2168. }, {
  2169. name: 'CostTypeNo',
  2170. value: CostTypeNo
  2171. }, {
  2172. name: 'ProfitRate',
  2173. value: getFeeRate(item.programID, 'profit', tenderProject)
  2174. },
  2175. {
  2176. name: 'TaxRate',
  2177. value: getFeeRate(item.programID, 'tax', tenderProject)
  2178. },
  2179. {
  2180. name: 'MpRatio',
  2181. value: item.subType == gljType.LABOUR ? 100 : 0
  2182. },
  2183. {
  2184. name: 'MaterialRatio',
  2185. value: item.subType == gljType.GENERAL_MATERIAL ? 100 : 0
  2186. },
  2187. {
  2188. name: 'MechRatio',
  2189. value: item.subType == gljType.GENERAL_MACHINE ? 100 : 0
  2190. }
  2191. ]
  2192. Element.call(this, "Cost", attrs);
  2193. this.children.push(CostStructure(item, tenderProject.property.decimal.ration.totalPrice));
  2194. }
  2195. function Ration(ration) {
  2196. let calcMap = tenderProject.calcProgram.compiledTemplateMaps
  2197. let CostTypeNo = '';
  2198. if (feeRateMap[calcMap[ration.programID]]) CostTypeNo = feeRateMap[calcMap[ration.programID]];
  2199. const attrs = [{
  2200. name: "NormLibNo",
  2201. value: 'YSDE-000000-2018-86',
  2202. }, {
  2203. name: 'DisplayCode',
  2204. value: ration.code
  2205. }, {
  2206. name: 'Name',
  2207. value: ration.name
  2208. }, {
  2209. name: 'Unit',
  2210. value: ration.unit
  2211. }, {
  2212. name: 'Num',
  2213. value: ration.tenderQuantity
  2214. },
  2215. {
  2216. name: 'CostTypeNo',
  2217. value: CostTypeNo
  2218. },
  2219. {
  2220. name: 'ProfitRate',
  2221. value: getFeeRate(ration.programID, 'profit', tenderProject) //tenderProject.ProfitRate
  2222. },
  2223. {
  2224. name: 'TaxRate',
  2225. value: getFeeRate(ration.programID, 'tax', tenderProject) //tenderProject.TaxRate
  2226. },
  2227. {
  2228. name: 'FabricationCost',
  2229. value: ration.feesIndex && ration.feesIndex.common ? ration.feesIndex.common.tenderTotalFee : 0
  2230. },
  2231. {
  2232. name: 'AdjustStatus',
  2233. value: ration.adjustState
  2234. }
  2235. ]
  2236. Element.call(this, "Norm", attrs);
  2237. this.children.push(CostStructure(ration, tenderProject.property.decimal.ration.totalPrice));
  2238. this.children.push(Consume(ration));
  2239. }
  2240. }
  2241. function Consume(ration) {
  2242. let consume = new emptyElement('Consume');
  2243. for (let rg of ration.rationGLJList) {
  2244. consume.children.push(new ConsumeItem(rg));
  2245. }
  2246. return consume;
  2247. function ConsumeItem(rg) {
  2248. const attrs = [{
  2249. name: "Code",
  2250. value: rg.code,
  2251. }, {
  2252. name: "Consumption",
  2253. value: rg.tenderQuantity
  2254. }];
  2255. Element.call(this, "ConsumeItem", attrs);
  2256. }
  2257. }
  2258. function CostStructure(item, decimalNum) {
  2259. let CostStructure = new emptyElement('CostStructure');
  2260. for (let f of cpFeeTypes) {
  2261. if (itemFeeMap[f.type]) CostStructure.children.push(new CostItem(item, f.type))
  2262. }
  2263. if (CostStructure.children.length == 0) CostStructure.children.push(new CostItem({}, ""))
  2264. function CostItem(item, type) {
  2265. const attrs = [{
  2266. name: "ItemNo",
  2267. value: itemFeeMap[type],
  2268. }, {
  2269. name: 'Sum',
  2270. value: 0 //fee.tenderTotalFee
  2271. }]
  2272. if ((isBidSubmission || isControl) && item.feesIndex && item.feesIndex[type]) {
  2273. attrs[1].value = scMathUtil.roundForObj(item.feesIndex[type].tenderTotalFee, decimalNum);
  2274. if ((item.name === '已包含在清单合计中的材料、工程设备、专业工程暂估价合计') && (itemFeeMap[type] === 'JAF')) {
  2275. attrs[1].value = scMathUtil.roundForObj(attrs[1].value - fixedSumVal, decimalNum);
  2276. }
  2277. }
  2278. Element.call(this, "CostItem", attrs);
  2279. }
  2280. return CostStructure;
  2281. }
  2282. }
  2283. }
  2284. }
  2285. function Params(tenderProject) {
  2286. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  2287. let featrueMap = {};
  2288. let baseMap = {};
  2289. for (let f of feature) {
  2290. featrueMap[f.key] = f;
  2291. }
  2292. let baseInfo = _.find(tenderProject.property.basicInformation, {
  2293. dispName: "基本信息",
  2294. });
  2295. for (let i of baseInfo.items) {
  2296. let key = i.key;
  2297. //if (i.dispName == "编制日期") key = "编制时间";
  2298. baseMap[key] = i;
  2299. }
  2300. let BuildType = "";
  2301. const natureConstruction = baseMap["natureConstruction"] || {};
  2302. if (natureConstruction.value == "新建") BuildType = 0;
  2303. if (natureConstruction.value == "改扩建") BuildType = 1;
  2304. let Terrain = "";
  2305. const terrainCategory = baseMap["terrainCategory"] || {};
  2306. if (terrainCategory.value == "平原微丘") Terrain = 0;
  2307. if (terrainCategory.value == "山岭重丘") Terrain = 1;
  2308. let DesignSpeed = (featrueMap["designSpeed"] || {}).value;
  2309. let Structure = "";
  2310. const pavementStructure = featrueMap["pavementStructure"] || {};
  2311. if (pavementStructure.value == "沥青路面") Structure = 0;
  2312. if (pavementStructure.value == "水泥混凝土路面") Structure = 1;
  2313. if (pavementStructure.value == "其他类型路面") Structure = 2;
  2314. let RoadGrade = "";
  2315. if (RoadGradeMap[(baseMap["roadGrade"] || {value: ''}).value]) RoadGrade = RoadGradeMap[baseMap["roadGrade"].value];
  2316. const attrs = [{
  2317. name: "PrjArea",
  2318. value: baseMap["location"] ? baseMap["location"].value : ""
  2319. },
  2320. {
  2321. name: "StartPileNo",
  2322. value: baseMap["startChainages"] ? baseMap["startChainages"].value : "",
  2323. mustHasValue: true
  2324. },
  2325. {
  2326. name: "EndPileNo",
  2327. value: baseMap["endChainages"] ? baseMap["endChainages"].value : "",
  2328. mustHasValue: true
  2329. },
  2330. {
  2331. name: "BuildType",
  2332. value: BuildType,
  2333. },
  2334. {
  2335. name: "Terrain",
  2336. value: Terrain,
  2337. mustHasValue: true
  2338. },
  2339. {
  2340. name: "RoadGrade",
  2341. value: RoadGrade,
  2342. mustHasValue: true
  2343. },
  2344. {
  2345. name: "DesignSpeed",
  2346. value: DesignSpeed,
  2347. mustHasValue: true
  2348. },
  2349. {
  2350. name: "Structure",
  2351. value: Structure,
  2352. mustHasValue: true
  2353. },
  2354. {
  2355. name: "SubgradeWidth",
  2356. value: featrueMap["subgradeWidth"] ? featrueMap["subgradeWidth"].value : "",
  2357. mustHasValue: true
  2358. },
  2359. {
  2360. name: "RoadLength",
  2361. value: featrueMap["roadLength"] ? featrueMap["roadLength"].value : "",
  2362. mustHasValue: true
  2363. },
  2364. {
  2365. name: "BridgeLength",
  2366. value: featrueMap["bridgeLength"] ? featrueMap["bridgeLength"].value : "",
  2367. mustHasValue: true
  2368. },
  2369. {
  2370. name: "TunnelLength",
  2371. value: featrueMap["tunnelLength"] ? featrueMap["tunnelLength"].value : "",
  2372. mustHasValue: true
  2373. },
  2374. {
  2375. name: "BriTunRate",
  2376. value: featrueMap["briTunRate"] ? featrueMap["briTunRate"].value : "",
  2377. mustHasValue: true
  2378. },
  2379. {
  2380. name: "InterchangeNum",
  2381. value: featrueMap["interchangeNum"] ? featrueMap["interchangeNum"].value : "",
  2382. mustHasValue: true
  2383. },
  2384. {
  2385. name: "StubLengths",
  2386. value: featrueMap["stubLengths"] ? featrueMap["stubLengths"].value : "",
  2387. mustHasValue: true
  2388. },
  2389. {
  2390. name: "LaneLength",
  2391. value: featrueMap["laneLength"] ? featrueMap["laneLength"].value : "",
  2392. mustHasValue: true
  2393. },
  2394. ];
  2395. Element.call(this, "Params", attrs);
  2396. }
  2397. function SummaryOfCost(totalItem, proItem, safeItem, oneToSevenItem, feature) {
  2398. let attrs = [{
  2399. name: "TenderSumLimit",
  2400. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  2401. type: TYPE.DECIMAL,
  2402. toFix: 2,
  2403. },
  2404. {
  2405. name: "BidTotal",
  2406. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  2407. type: TYPE.DECIMAL,
  2408. toFix: 2,
  2409. },
  2410. {
  2411. name: "BillTotal",
  2412. value: oneToSevenItem.feesIndex && oneToSevenItem.feesIndex.common && oneToSevenItem.feesIndex.common.tenderTotalFee ? oneToSevenItem.feesIndex.common.tenderTotalFee : 0,
  2413. type: TYPE.DECIMAL,
  2414. toFix: 2,
  2415. },
  2416. {
  2417. name: "CostForHSE",
  2418. value: safeItem && safeItem.feesIndex && safeItem.feesIndex.common && safeItem.feesIndex.common.tenderTotalFee ? safeItem.feesIndex.common.tenderTotalFee : 0,
  2419. type: TYPE.DECIMAL,
  2420. toFix: 2,
  2421. },
  2422. {
  2423. name: "ProvisionalSums",
  2424. value: proItem.feesIndex && proItem.feesIndex.common && proItem.feesIndex.common.tenderTotalFee ? proItem.feesIndex.common.tenderTotalFee : 0,
  2425. type: TYPE.DECIMAL,
  2426. toFix: 2,
  2427. },
  2428. {
  2429. name: "Appraisal",
  2430. // value: totalItem.feesIndex && totalItem.feesIndex.estimate && totalItem.feesIndex.estimate.tenderTotalFee ? totalItem.feesIndex.estimate.tenderTotalFee : 0,
  2431. value: 0,
  2432. type: TYPE.DECIMAL,
  2433. toFix: 2,
  2434. },
  2435. ];
  2436. if (isBidInvitation) {
  2437. attrs.splice(0, 3) //招标
  2438. }
  2439. //if (isControl) attrs.splice(1, 5); //控制价
  2440. if (isBidSubmission) { //投标文件时,读工程特征中的 招标控制价 值
  2441. let tenderSumLimit = _.find(feature, { "key": "tenderSumLimit" });
  2442. if (tenderSumLimit) attrs[0].value = tenderSumLimit.value
  2443. }
  2444. Element.call(this, "SummaryOfCost", attrs);
  2445. }
  2446. function MakeInfo(tenderProject) {
  2447. let property = tenderProject.property;
  2448. let baseMap = {};
  2449. let baseInfo = _.find(property.basicInformation, {
  2450. dispName: "基本信息",
  2451. });
  2452. for (let i of baseInfo.items) {
  2453. let key = i.key;
  2454. //if (i.dispName == "编制日期") key = "编制时间";
  2455. baseMap[key] = i;
  2456. }
  2457. //mustHasValue
  2458. const attrs = [{
  2459. name: "ValuationModel",
  2460. value: property.taxType,
  2461. },
  2462. {
  2463. name: "Manage",
  2464. value: baseMap["constructingUnit"] ? baseMap["constructingUnit"].value : "",
  2465. },
  2466. {
  2467. name: "Designer",
  2468. value: baseMap["designUnit"] ? baseMap["designUnit"].value : "",
  2469. mustHasValue: true
  2470. },
  2471. {
  2472. name: "Compile",
  2473. value: baseMap["compileUnit"] ? baseMap["compileUnit"].value : "",
  2474. },
  2475. {
  2476. name: "CompileApprover",
  2477. value: baseMap["compileApprover"] ? baseMap["compileApprover"].value : "",
  2478. },
  2479. {
  2480. name: "CompileCertNo",
  2481. value: baseMap["compileCertNo"] ? baseMap["compileCertNo"].value : "",
  2482. mustHasValue: true
  2483. },
  2484. {
  2485. name: "CompileDate",
  2486. value: baseMap["compileDate"] && baseMap["compileDate"].value != "" ? baseMap["compileDate"].value + "T00:00:00" : "",
  2487. mustHasValue: true
  2488. },
  2489. {
  2490. name: "Review",
  2491. value: baseMap["reviewUnit"] ? baseMap["reviewUnit"].value : "",
  2492. mustHasValue: true
  2493. },
  2494. {
  2495. name: "ReviewApprover",
  2496. value: baseMap["reviewApprover"] ? baseMap["reviewApprover"].value : "",
  2497. mustHasValue: true
  2498. },
  2499. {
  2500. name: "ReviewCertNo",
  2501. value: baseMap["reviewCertNo"] ? baseMap["reviewCertNo"].value : "",
  2502. mustHasValue: true
  2503. },
  2504. {
  2505. name: "ReviewDate",
  2506. value: baseMap["reviewDate"] && baseMap["reviewDate"].value != "" ? baseMap["reviewDate"].value + "T00:00:00" : "",
  2507. mustHasValue: true
  2508. },
  2509. {
  2510. name: "Examine",
  2511. value: baseMap["examineUnit"] ? baseMap["examineUnit"].value : "",
  2512. mustHasValue: true
  2513. },
  2514. {
  2515. name: "ExamineApprover",
  2516. value: baseMap["examineApprover"] ? baseMap["examineApprover"].value : "",
  2517. mustHasValue: true
  2518. },
  2519. {
  2520. name: "ExamineCertNo",
  2521. value: baseMap["examineCertNo"] ? baseMap["examineCertNo"].value : "",
  2522. mustHasValue: true
  2523. },
  2524. {
  2525. name: "ExamineDate",
  2526. value: baseMap["examineDate"] && baseMap["examineDate"].value != "" ? baseMap["examineDate"].value + "T00:00:00" : "",
  2527. mustHasValue: true
  2528. },
  2529. {
  2530. name: "CompileExplain",
  2531. value: baseMap["compileExplain"] ? baseMap["compileExplain"].value : "",
  2532. mustHasValue: true
  2533. },
  2534. {
  2535. name: "ExamineExplain",
  2536. value: baseMap["examineExplain"] ? baseMap["examineExplain"].value : "",
  2537. mustHasValue: true
  2538. },
  2539. {
  2540. name: "ProjectExplain",
  2541. value: baseMap["projectExplain"] ? baseMap["projectExplain"].value : "",
  2542. mustHasValue: true
  2543. },
  2544. {
  2545. name: "Bidder",
  2546. // value: baseMap["bidderCompany"] ? baseMap["bidderCompany"].value : "",
  2547. value: baseMap["bidderName"] ? baseMap["bidderName"].value : "",
  2548. mustHasValue: true
  2549. },
  2550. ];
  2551. if (isBidInvitation) { //招标文件,则以下的8、12~18则不输出
  2552. attrs.splice(11, 7);
  2553. attrs.splice(7, 1);
  2554. }
  2555. Element.call(this, "MakeInfo", attrs);
  2556. }
  2557. let data = new CprjInfo(projectData.name);
  2558. data.children.push(new SystemInfo(projectData));
  2559. data.children.push(new CostBasis());
  2560. let seriNo = 1;
  2561. let Rates = [];
  2562. let Practs = [];
  2563. let EprjInfos = [];
  2564. for (let c of projectData.children) {
  2565. let tenderProject = tenderDetailMap[c.ID];
  2566. let feeRataDatas = tenderProject.FeeRate.datas;
  2567. Rates.push(new Rate(tenderProject, feeRataDatas, seriNo));
  2568. Practs.push(new Pract(tenderProject, seriNo));
  2569. EprjInfos.push(new EprjInfo(tenderProject));
  2570. seriNo++;
  2571. }
  2572. data.children.push(...Rates, ...Practs, ...EprjInfos);
  2573. return [{
  2574. data: data,
  2575. exportKind: exportKind,
  2576. fileName: projectData.name + INTERFACE_CONFIG[areaKey]["fileSuffix"][exportKind],
  2577. },];
  2578. }
  2579. // 山东需求,要有密文校验信息(SM3算法,在界面上已导入sm3对象)
  2580. /**
  2581. * SM3加密主函数
  2582. * @param msg
  2583. * @returns
  2584. */
  2585. function sm3Digest(msg) {
  2586. let hashHex = sm3(msg);
  2587. // return hashHex;
  2588. return hashHex.toUpperCase();
  2589. }
  2590. function _extractBillCalcRefs(currentBill) {
  2591. const rst = [];
  2592. function _extract(spliter, excluded = true, nextGap) {
  2593. let currentBillCalcBase = currentBill.calcBase;
  2594. let currentIdx = currentBillCalcBase.indexOf(spliter);
  2595. let exCnt = 0;
  2596. if (excluded) exCnt = spliter.length;
  2597. while (currentIdx >= 0) {
  2598. let bId = currentBillCalcBase.substr(currentIdx + excluded, nextGap);
  2599. if (!rst.includes(bId)) {
  2600. rst.push(bId);
  2601. }
  2602. currentBillCalcBase = currentBillCalcBase.substr(currentIdx + excluded + nextGap);
  2603. currentIdx = currentBillCalcBase.indexOf(spliter);
  2604. }
  2605. }
  2606. if (typeof currentBill.calcBase === 'string') {
  2607. //1. 抽取@引用
  2608. _extract('@', true, 36);
  2609. //2. 抽取特殊引用
  2610. // 2.1 {各章清单合计}
  2611. _extract('{各章清单合计}', false, '{各章清单合计}'.length);
  2612. // 2.2 {100章以外清单合计}
  2613. _extract('{100章以外清单合计}', false, '{100章以外清单合计}'.length);
  2614. }
  2615. return rst;
  2616. }
  2617. function _preCodeingForBills(tenderProject) {
  2618. const cacheObj = {};
  2619. function _chkAdhocChapterBill(bill) {
  2620. let rst = false;
  2621. if (typeof bill.name === 'string' && bill.name.includes('00章') && bill.name.includes('清单')) {
  2622. rst = true;
  2623. }
  2624. return rst;
  2625. }
  2626. function _setCache(bNode) {
  2627. cacheObj['_' + bNode.data.ID] = bNode.data;
  2628. if (bNode.children && bNode.children.length > 0) {
  2629. for (let subNode of bNode.children) {
  2630. _setCache(subNode);
  2631. }
  2632. }
  2633. }
  2634. let rootNodes = tenderProject.mainTree.roots;
  2635. for (let rootNode of rootNodes) {
  2636. _setCache(rootNode);
  2637. }
  2638. let cnt = 1;
  2639. let billsForAcc = [];
  2640. for (let bill of tenderProject.Bills.datas) {
  2641. //这一步设置特殊清单(各章清单合计, 100章~1200章)
  2642. cacheObj['_{100章以外清单合计}'] = {};
  2643. if (_billStrFilter(bill.name).includes('第100章至700章清单') || sectionNameMap[_billStrFilter(bill.name)] || _chkAdhocChapterBill(bill)) {
  2644. if (cacheObj['_' + bill.ID]) {
  2645. if (!cacheObj['_' + bill.ID].hasOwnProperty('formulaCode')) {
  2646. cacheObj['_' + bill.ID].formulaCode = `F${cnt}`;
  2647. cnt++;
  2648. }
  2649. }
  2650. // if (_billStrFilter(bill.name).includes('第100章至700章清单')) {
  2651. if (_billStrFilter(bill.name).includes('第100章至') && _billStrFilter(bill.name).includes('00章清单')) {
  2652. cacheObj['_{各章清单合计}'] = {};
  2653. cacheObj['_{各章清单合计}'].formulaCode = `{F${cnt - 1}}`;
  2654. } else if (!_billStrFilter(bill.name).includes('清单第100章')) {
  2655. billsForAcc.push(`F${cnt - 1}`);
  2656. }
  2657. }
  2658. }
  2659. let tmpStr = ''
  2660. for (let idx = 0; idx < billsForAcc.length; idx++) {
  2661. if (idx === 0) {
  2662. tmpStr = '( ' + `{${billsForAcc[idx]}}`;
  2663. } else {
  2664. tmpStr = tmpStr + ` + {${billsForAcc[idx]}}`;
  2665. }
  2666. if (idx === billsForAcc.length - 1) tmpStr = tmpStr + ' )';
  2667. }
  2668. cacheObj['_{100章以外清单合计}'].formulaCode = tmpStr;
  2669. for (let bill of tenderProject.Bills.datas) {
  2670. let billRefs = _extractBillCalcRefs(bill);
  2671. for (let refBillId of billRefs) {
  2672. if (cacheObj['_' + refBillId]) {
  2673. if (!cacheObj['_' + refBillId].hasOwnProperty('formulaCode')) {
  2674. cacheObj['_' + refBillId].formulaCode = `F${cnt}`;
  2675. cnt++;
  2676. }
  2677. }
  2678. }
  2679. }
  2680. return cacheObj;
  2681. }
  2682. function _getFormulaDispName(cacheForFormula, currentBill) {
  2683. let rst = currentBill.calcBase;
  2684. if (typeof currentBill.calcBase === 'string') {
  2685. //1. @引用
  2686. let currentBillCalcBase = currentBill.calcBase;
  2687. let currentIdx = currentBillCalcBase.indexOf('@');
  2688. let bIdArr = [], replaceArr = [];
  2689. while (currentIdx >= 0) {
  2690. let bId = currentBillCalcBase.substr(currentIdx + 1, 36);
  2691. bIdArr.push(bId);
  2692. if (cacheForFormula['_' + bId]) {
  2693. if (cacheForFormula['_' + bId].hasOwnProperty('formulaCode')) {
  2694. replaceArr.push(`{${cacheForFormula['_' + bId].formulaCode}}`);
  2695. } else {
  2696. replaceArr.push(`{无formulaCode错误:${bId}}`);
  2697. }
  2698. } else {
  2699. replaceArr.push(`{引用错误:${bId}}`);
  2700. }
  2701. currentBillCalcBase = currentBillCalcBase.substr(currentIdx + 37);
  2702. currentIdx = currentBillCalcBase.indexOf('@');
  2703. }
  2704. let tempBillCalcBase = currentBill.calcBase;
  2705. for (let idx = 0; idx < bIdArr.length; idx++) {
  2706. tempBillCalcBase = tempBillCalcBase.replace('@' + bIdArr[idx], replaceArr[idx]);
  2707. }
  2708. //2. 特殊引用
  2709. //{各章清单合计} {100章以外清单合计}
  2710. if (tempBillCalcBase.includes('{各章清单合计}')) {
  2711. console.log(`特殊引用清单{各章清单合计}:${currentBill.name}(${currentBill.code} - ${tempBillCalcBase})`);
  2712. tempBillCalcBase = tempBillCalcBase.replace('{各章清单合计}', cacheForFormula['_{各章清单合计}'].formulaCode);
  2713. }
  2714. if (tempBillCalcBase.includes('{100章以外清单合计}')) {
  2715. console.log(`特殊引用清单{100章以外清单合计}:${currentBill.name}(${currentBill.code} - ${tempBillCalcBase})`);
  2716. tempBillCalcBase = tempBillCalcBase.replace('{100章以外清单合计}', cacheForFormula['_{100章以外清单合计}'].formulaCode);
  2717. }
  2718. //
  2719. rst = tempBillCalcBase;
  2720. }
  2721. return rst;
  2722. }
  2723. return {
  2724. entry,
  2725. };
  2726. })();