shandong_common.js 93 KB

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