shandong_common.js 103 KB

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