zhejiang_ninghai.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. // 浙江-宁海
  2. INTERFACE_EXPORT = (() => {
  3. 'use strict';
  4. /**
  5. *
  6. * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
  7. * @param {Number} exportKind - 导出类型,招标、投标、控制价
  8. * @param {Object} projectData - 项目表数据:{ 建设项目Data, children: [单位工程...] }
  9. * @param {Object} tenderDetailMap - 单位工程ID与getData接口数据(projectObj.project的结构)的映射。
  10. * @return {Promise<Array>} - 返回的数据结构必须按照规定:[{ data, exportKind, fileName }],参考web\building_saas\standard_interface\index.js中的注释说明
  11. */
  12. async function entry(areaKey, exportKind, projectData, tenderDetailMap) {
  13. const {
  14. CONFIG: {
  15. TYPE,
  16. WHITE_SPACE
  17. },
  18. UTIL: {
  19. getValueByKey,
  20. getHan,
  21. getFee,
  22. getUnitFee,
  23. generateHardwareId,
  24. },
  25. Element,
  26. } = INTERFACE_EXPORT_BASE;
  27. const {
  28. EXPORT_KIND: { BID_INVITATION, BID_SUBMISSION, CONTROL },
  29. fixedFlag,
  30. RationType,
  31. } = window.commonConstants
  32. const GljType = gljUtil.gljType;
  33. const { isEmptyVal, isDef } = window.commonUtil;
  34. const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  35. const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  36. const isControl = exportKind === CONTROL; // 是否是控制价
  37. const subArea = areaKey.split('@')[1];
  38. const info = projectData.property && projectData.property.basicInformation || [];
  39. const { summaryInfo } = projectData;
  40. const constructionSummary = summaryInfo[projectData.ID];
  41. let curTender;
  42. // 小数位数(按照需求固定)
  43. const qD = 4; // 消耗量
  44. const fD = 2; // 费用
  45. const pD = 6; // 中间过程
  46. // 值映射表
  47. const valueMap = {
  48. '新建': '1',
  49. '改扩建': '2',
  50. '养护': '3',
  51. '养护(年度经费)': '4',
  52. '养护(年度经费)': '4',
  53. '高速公路': '1',
  54. '一级公路': '2',
  55. '二级公路': '3',
  56. '三级公路': '4',
  57. '四级公路': '5',
  58. '桥梁工程': '6',
  59. '独立桥梁': '6',
  60. '隧道工程': '7',
  61. '独立隧道': '7',
  62. '其他工程': '8',
  63. '等外工程': '8',
  64. '一般计税': '1',
  65. '简易计税': '2',
  66. }
  67. // 是否是材料
  68. const isMaterial = (type) => {
  69. return /^2/.test(type);
  70. }
  71. // 获取预算价
  72. const getMarketPrice = (glj) => {
  73. const tenderCoe = gljUtil.getTenderPriceCoe(glj, curTender.property);
  74. return gljUtil.getMarketPrice(glj, curTender.projectGLJ.datas, curTender.property.calcOptions, curTender.labourCoe.datas, curTender.property.decimal, false, _, scMathUtil, tenderCoe);
  75. }
  76. // 获取人工单价
  77. const getLabourPrice = () => {
  78. const glj = curTender.projectGLJ.datas.gljList.find(glj => glj.type === 1);
  79. if (!glj) {
  80. return 0;
  81. }
  82. return getMarketPrice(glj);
  83. }
  84. // 获取人工消耗量
  85. const getLabourQuantity = (node) => {
  86. if (!+node.data.quantity) {
  87. return 0;
  88. }
  89. let total = 0;
  90. const posterity = node.getPosterity();
  91. const rations = posterity.filter(item => calcTools.isRationItem(item));
  92. rations.forEach(ration => {
  93. const labours = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID && glj.type === 1);
  94. labours.forEach(labour => {
  95. total = scMathUtil.roundForObj(total + labour.tenderQuantity * ration.data.tenderQuantity, qD);
  96. });
  97. });
  98. const labourRations = posterity.filter(item => (calcTools.isVolumePrice(item) || calcTools.isGljRation(item)) && item.data.subType === 1);
  99. labourRations.forEach(labour => {
  100. total = scMathUtil.roundForObj(total + +labour.data.tenderQuantity, qD);
  101. });
  102. return total / +node.data.quantity;
  103. }
  104. // 获取主材费、辅材费
  105. const getMaterialFee = (node) => {
  106. const rst = {
  107. mainFee: 0,
  108. assFee: 0,
  109. };
  110. const quantity = calcTools.isBill(node) ? node.data.quantity : node.data.tenderQuantity;
  111. if (!+quantity) {
  112. return rst;
  113. }
  114. const posterity = calcTools.isBill(node) ? node.getPosterity() : [node];
  115. // 计算定额下的费用(限定材料)
  116. const rations = posterity.filter(item => calcTools.isRationItem(item));
  117. rations.forEach(ration => {
  118. const rationGljData = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID && isMaterial(glj.type));
  119. rationGljData.forEach(rGlj => {
  120. const key = gljUtil.getIndex(rGlj);
  121. const projectGlj = curTender.projectGLJ.datas.gljMap[key];
  122. if (projectGlj) {
  123. const gljUnitFee = scMathUtil.roundForObj(rGlj.tenderQuantity * getMarketPrice(projectGlj), pD);
  124. const gljTotalFee = scMathUtil.roundForObj(gljUnitFee * ration.data.tenderQuantity, fD);
  125. if (projectGlj.is_main_material) {
  126. rst.mainFee = scMathUtil.roundForObj(rst.mainFee + gljTotalFee, fD);
  127. } else {
  128. rst.assFee = scMathUtil.roundForObj( rst.assFee + gljTotalFee, fD);
  129. }
  130. }
  131. });
  132. });
  133. // 计算工料机类型定额、量价(限定材料)
  134. const materialRations = posterity.filter(item => calcTools.isGljRation(item) && isMaterial(item.data.subType));
  135. materialRations.forEach(ration => {
  136. const key = gljUtil.getIndex(ration.data);
  137. const projectGlj = curTender.projectGLJ.datas.gljMap[key];
  138. if (projectGlj) {
  139. if (projectGlj.is_main_material) {
  140. rst.mainFee = scMathUtil.roundForObj(rst.mainFee + getFee(ration.data.fees, 'common.tenderTotalFee'), fD);
  141. } else {
  142. rst.assFee = scMathUtil.roundForObj(rst.assFee + getFee(ration.data.fees, 'common.tenderTotalFee'), fD);
  143. }
  144. }
  145. });
  146. const volumes = posterity.filter(item => calcTools.isVolumePrice(item) && isMaterial(item.data.subType));
  147. volumes.forEach(vol => {
  148. rst.mainFee = scMathUtil.roundForObj(rst.mainFee + getFee(vol.data.fees, 'common.tenderTotalFee'), fD);
  149. });
  150. rst.mainFee = scMathUtil.roundForObj(rst.mainFee / quantity, fD);
  151. rst.assFee = scMathUtil.roundForObj(rst.assFee / quantity, fD);
  152. return rst;
  153. }
  154. // 节点定义--------------------------------
  155. /* 工程信息 */
  156. function GongCXX() {
  157. const attrs = [
  158. { name: '项目编号', value: getValueByKey(info, 'projNum'), minLen: 1 },
  159. { name: '项目名称', value: projectData.name, minLen: 1 },
  160. { name: '建设单位', value: getValueByKey(info, 'constructingUnits'), minLen: 1 },
  161. { name: '起始桩号', value: getValueByKey(info, 'startChainages') },
  162. { name: '终点桩号', value: getValueByKey(info, 'endChainages') },
  163. { name: '建设地址', value: getValueByKey(info, 'constructionAddress') },
  164. { name: '项目概况', value: getValueByKey(info, 'projOverview') },
  165. { name: '项目类型', value: valueMap[getValueByKey(info, 'natureConstruction')] },
  166. { name: '专业划分', value: valueMap[getValueByKey(info, 'roadGrade')] },
  167. { name: '道路里程-公里', value: getValueByKey(info, 'roadDistance') },
  168. { name: '设计单位', value: getValueByKey(info, 'designUnit') },
  169. { name: '计税方式', value: valueMap[getValueByKey(info, 'taxMode')] },
  170. {name: '文件类型', value: isBidInvitation ? 1 : (isControl ? 2 : 3)}, // 1=工程量清单;2=招标控制价;3=投标报价;
  171. { name: '标准版本号', value: '1.0' },
  172. { name: 'GUID', value: uuid.v1() }
  173. ];
  174. Element.call(this, '工程信息', attrs);
  175. }
  176. /* 招标信息 */
  177. function ZhaoBiaoXX() {
  178. const attrs = [
  179. { name: '招标人', value: getValueByKey(info, 'tendereeName'), minLen: 1 },
  180. { name: '招标法定代表人或其授权人', value: getValueByKey(info, 'tenderAuthorizer') },
  181. { name: '编制人', value: getValueByKey(info, 'compileApprover') },
  182. { name: '编制人资格证号', value: getValueByKey(info, 'compileCertNo') },
  183. { name: '编制日期', value: getValueByKey(info, 'compileDate'), type: TYPE.DATE},
  184. { name: '招标代理机构', value: getValueByKey(info, 'proxy'), minLen: 1},
  185. { name: '招标范围', value: getValueByKey(info, 'scopeofBidding')},
  186. { name: '总工期日历天', value: getValueByKey(info, 'timeLimit'), minLen: 1},
  187. ];
  188. Element.call(this, '招标信息', attrs);
  189. }
  190. /* 招标控制价 */
  191. function ZhaoBiaoKZJ() {
  192. const attrs = [
  193. { name: '招标人', value: getValueByKey(info, 'tendereeName'), minLen: 1 },
  194. { name: '招标法定代表人或其授权人', value: getValueByKey(info, 'tenderAuthorizer') },
  195. { name: '编制人', value: getValueByKey(info, 'compileApprover') },
  196. { name: '编制人资格证号', value: getValueByKey(info, 'compileCertNo') },
  197. { name: '编制日期', value: getValueByKey(info, 'compileDate'), type: TYPE.DATE},
  198. { name: '编制说明', value: getValueByKey(info, 'preparationDescription') },
  199. { name: '复核人', value: getValueByKey(info, 'reviewApprover') },
  200. { name: '复核人资格证号', value: getValueByKey(info, 'reviewCertNo') },
  201. { name: '复核日期', value: getValueByKey(info, 'reviewDate'), type: TYPE.DATE },
  202. { name: '审核人', value: getValueByKey(info, 'examineApprover') },
  203. { name: '审核人资格证号', value: getValueByKey(info, 'examineCertNo') },
  204. { name: '审核日期', value: getValueByKey(info, 'examineDate'), type: TYPE.DATE },
  205. { name: '控制价总价', value: constructionSummary.totalCost, type: TYPE.DECIMAL },
  206. { name: '备注', value: getValueByKey(info, '') },
  207. ];
  208. Element.call(this, '招标控制价', attrs);
  209. }
  210. /* 投标信息 */
  211. function TouBiaoXX() {
  212. let hardID = generateHardwareId();
  213. let [cpuId, diskId, macId] = hardID.split(";");
  214. const attrs = [
  215. { name: '投标人', value: getValueByKey(info, 'bidderName'), minLen: 1 },
  216. { name: '投标人法人或其授权人', value: getValueByKey(info, 'bidderAuthorizer') },
  217. { name: '投标人资质证号', value: getValueByKey(info, 'bidderCertNo') },
  218. { name: '总工期日历天', value: getValueByKey(info, 'timeLimit')},
  219. { name: '投标总价', value: constructionSummary.totalCost, type: TYPE.DECIMAL },
  220. { name: '投标下浮率', value: getValueByKey(info, 'downwardFloatingRateOfBid') },
  221. { name: '投标报价说明', value: getValueByKey(info, 'downwardFloatingRateOfBid') },
  222. { name: '质量承诺', value: getValueByKey(info, 'qualityCommitment') },
  223. { name: '投标保证金', value: getValueByKey(info, 'bidBond') },
  224. { name: '项目经理或项目负责人', value: getValueByKey(info, 'projectManagers') },
  225. { name: '项目经理或项目负责人资格证号', value: getValueByKey(info, 'projectmanagersCertNo') },
  226. { name: '造价软件品牌', value: '纵横公路云造价', minLen: 1 },
  227. { name: '造价软件版本', value: 'Ver' + VERSION, minLen: 1 },
  228. { name: '造价软件加密锁编号', value: userID, minLen: 1 },
  229. { name: '计算机硬件信息', value: cpuId + diskId + macId, minLen: 1 },
  230. { name: '备注', value: getValueByKey(info, '') },
  231. ];
  232. Element.call(this, '投标信息', attrs);
  233. }
  234. /* 工程量清单明细 */
  235. let billSeq = 1;
  236. // 获取数据类型
  237. function getBillDataType(node) {
  238. // 目录
  239. if (!calcTools.isLeafBill(node)) {
  240. return '1';
  241. }
  242. // 专项暂定
  243. if (node.data.specialProvisional == '专业工程') {
  244. return '21';
  245. }
  246. // 安全生产费
  247. if (node.data.code == '102-3') {
  248. return '22'
  249. }
  250. // 工程一切险
  251. if ((node.data.code == '-a') && (node.parent && (node.parent.data.code == '101-1'))) {
  252. return '23'
  253. }
  254. // 第三者责任险
  255. if ((node.data.code == '-b') && (node.parent && (node.parent.data.code == '101-1'))) {
  256. return '24'
  257. }
  258. return '20';
  259. }
  260. // 获取清单章节
  261. const getBillSection = (node) => {
  262. debugger;
  263. let cur = node;
  264. while (cur) {
  265. const sectionCode = (cur.data.name || '').replace(/[^0-9]/g, '');
  266. if (sectionCode) {
  267. return sectionCode;
  268. }
  269. cur = cur.parent;
  270. }
  271. return '';
  272. }
  273. function GongCLQDMX(node) {
  274. const { mainFee, assFee } = getMaterialFee(node);
  275. const attrs = [
  276. {name: '序号', value: billSeq ++ },
  277. {name: 'GUID', value: node.data.ID },
  278. {name: '清单章节', value: getBillSection(node)},
  279. {name: '子目长编号', value: divideObj.getExeBillCode(node.data.ID, node. tree)},
  280. {name: '子目号', value: node.data.code},
  281. {name: '子目名称', value: node.data.name},
  282. {name: '单位', value: node.data.unit},
  283. {name: '数量', value: node.data.quantity, type: TYPE.DECIMAL},
  284. {name: '单价', value: getFee(node.data.fees, 'common.tenderUnitFee', exportKind), type: TYPE.DECIMAL},
  285. {name: '合价', value: getFee(node.data.fees, 'common.tenderTotalFee', exportKind), type: TYPE.DECIMAL},
  286. {name: '备注', value: node.data.remark },
  287. {name: '数据类型', value: getBillDataType(node) },
  288. {name: '人工费', value: getUnitFee(getFee(node.data.fees, 'marketLabour.tenderTotalFee', exportKind), node.data.quantity, 2), type: TYPE.DECIMAL},
  289. {name: '人工单价', value: getLabourPrice(), type: TYPE.DECIMAL},
  290. {name: '人工消耗量', value: getLabourQuantity(node), type: TYPE.DECIMAL},
  291. {name: '主材费', value: mainFee, type: TYPE.DECIMAL},
  292. {name: '辅材费', value: assFee, type: TYPE.DECIMAL},
  293. {name: '设备费', value: getUnitFee(getFee(node.data.fees, 'equipment.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
  294. {name: '机械使用费', value: getFee(node.data.fees, 'machine.tenderTotalFee', exportKind), type: TYPE.DECIMAL},
  295. {name: '措施费1', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'measure1.tenderTotalFee', exportKind) : getFee(node.data.fees, 'otherDirect.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
  296. {name: '措施费2', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'measure2.tenderTotalFee', exportKind) : getFee(node.data.fees, 'composite.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
  297. {name: '企业管理费', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'manage.tenderTotalFee', exportKind) : getFee(node.data.fees, 'local.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
  298. {name: '规费', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'force.tenderTotalFee', exportKind) : getFee(node.data.fees, 'indirect.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
  299. {name: '利润', value: getUnitFee(getFee(node.data.fees, 'profit.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
  300. {name: '税金', value: getUnitFee(getFee(node.data.fees, 'tax.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
  301. // TODO
  302. {name: '评审清单', value: '0'},
  303. ];
  304. Element.call(this, '工程量清单明细', attrs);
  305. }
  306. /* 清单主材表明细 */
  307. let mainMaterialSeq = 1;
  308. function QDZCBMX(material) {
  309. const attrs = [
  310. { name: '序号', value: mainMaterialSeq++ },
  311. { name: '材料编码', value: material.code },
  312. { name: '主材名称', value: material.name },
  313. { name: '单位', value: material.unit },
  314. { name: '主材消耗量', value: material.quantity, type: TYPE.DECIMAL },
  315. { name: '单价', value: material.unitPrice, type: TYPE.DECIMAL },
  316. { name: '合价', value: material.totalPrice , type: TYPE.DECIMAL},
  317. { name: '备注', value: material.remark },
  318. ];
  319. Element.call(this, '清单主材明细', attrs);
  320. }
  321. /* 定额信息表 */
  322. let rationSeq = 1;
  323. // 获取数据类型
  324. const getRationDataType = (node) => {
  325. const programText = curTender.calcProgram.compiledTemplateMaps[node.data.programID];
  326. return programText === '费率为0' ? '4' : '3';
  327. }
  328. function DEXXB(node) {
  329. const { mainFee, assFee } = getMaterialFee(node);
  330. const attrs = [
  331. {name: '序号', value: rationSeq ++ },
  332. {name: 'GUID', value: node.data.ID },
  333. {name: '定额编号', value: node.data.code},
  334. {name: '定额名称', value: node.data.name},
  335. {name: '单位', value: node.data.unit},
  336. {name: '数量', value: node.data.tenderQuantity, type: TYPE.DECIMAL},
  337. {name: '单价', value: getFee(node.data.fees, 'common.tenderUnitFee', exportKind), type: TYPE.DECIMAL},
  338. {name: '合价', value: getFee(node.data.fees, 'common.tenderTotalFee', exportKind), type: TYPE.DECIMAL},
  339. {name: '备注', value: node.data.remark },
  340. {name: '数据类型', value: getRationDataType(node) },
  341. {name: '人工费', value: getUnitFee(getFee(node.data.fees, 'marketLabour.tenderTotalFee', exportKind), node.data.tenderQuantity, 2), type: TYPE.DECIMAL},
  342. {name: '主材费', value: mainFee, type: TYPE.DECIMAL},
  343. {name: '辅材费', value: assFee, type: TYPE.DECIMAL},
  344. {name: '设备费', value: getUnitFee(getFee(node.data.fees, 'equipment.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
  345. {name: '机械使用费', value: getFee(node.data.fees, 'machine.tenderTotalFee', exportKind), type: TYPE.DECIMAL},
  346. {name: '措施费1', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'measure1.tenderTotalFee', exportKind) : getFee(node.data.fees, 'otherDirect.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
  347. {name: '措施费2', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'measure2.tenderTotalFee', exportKind) : getFee(node.data.fees, 'composite.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
  348. {name: '企业管理费', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'manage.tenderTotalFee', exportKind) : getFee(node.data.fees, 'local.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
  349. {name: '规费', value: getUnitFee(COMPILATION_NAME.includes('公路造价') ? getFee(node.data.fees, 'force.tenderTotalFee', exportKind) : getFee(node.data.fees, 'indirect.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
  350. {name: '利润', value: getUnitFee(getFee(node.data.fees, 'profit.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
  351. {name: '税金', value: getUnitFee(getFee(node.data.fees, 'tax.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
  352. ];
  353. Element.call(this, '定额信息表', attrs);
  354. }
  355. /* 造价汇总明细 */
  356. let hzSeq = 1;
  357. // 获取章次
  358. const getSection = (node) => {
  359. const parentFlag = node.parent ? node.parent.getFlag() : null;
  360. if (parentFlag !== fixedFlag.ONE_SEVEN_BILLS) {
  361. return '';
  362. }
  363. return (node.data.name || '').replace(/[^0-9]/g, '')
  364. }
  365. let curLB = 7;
  366. // 获取类别
  367. const getLB = (node) => {
  368. const flag = node.getFlag();
  369. const parentFlag = node.parent ? node.parent.getFlag() : null;
  370. if (parentFlag === fixedFlag.ONE_SEVEN_BILLS) {
  371. return getSection(node);
  372. }
  373. switch (flag) {
  374. case fixedFlag.ONE_SEVEN_BILLS:
  375. return '1';
  376. case fixedFlag.PROVISIONAL_TOTAL:
  377. return '2';
  378. case fixedFlag.BILLS_TOTAL_WT_PROV:
  379. return '3';
  380. case fixedFlag.DAYWORK_LABOR:
  381. return '4';
  382. case fixedFlag.PROVISIONAL:
  383. return '5';
  384. case fixedFlag.TOTAL_COST:
  385. return '6';
  386. default:
  387. return curLB++;
  388. }
  389. }
  390. function ZJHZMX(node) {
  391. const attrs = [
  392. {name: '序号', value: hzSeq++ },
  393. {name: '章次', value: getSection(node) },
  394. {name: '名称', value: node.data.name },
  395. {name: '金额', value: getFee(node.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL },
  396. {name: '类别', value: getLB(node) },
  397. {name: '备注', value: node.data.remark },
  398. ];
  399. Element.call(this, '造价汇总明细', attrs);
  400. }
  401. /* 人材机汇总明细表 */
  402. // 获取人材机类别
  403. const getGljLB = (glj) => {
  404. if (glj.type === 1) {
  405. return '1';
  406. }
  407. if (glj.type === 201) {
  408. return '2';
  409. }
  410. if (glj.type === 302) {
  411. return '3';
  412. }
  413. if (glj.type === 5) {
  414. return '4';
  415. }
  416. if (glj.type === 204) {
  417. return '5';
  418. }
  419. if (glj.type === 301) {
  420. return '6';
  421. }
  422. if (glj.type === 4) {
  423. return '7';
  424. }
  425. if (glj.is_main_material) {
  426. return '8';
  427. }
  428. }
  429. function RCJHZMXB(glj) {
  430. const attrs = [
  431. {name: '人材机编号', value: glj.code },
  432. {name: '人材机名称', value: glj.name },
  433. {name: '规格型号', value: glj.specs },
  434. {name: '单位', value: glj.unit },
  435. {name: '数量', value: glj.tenderQuantity },
  436. {name: '单价', value: glj.priceInfo.tenderPrice, type: TYPE.DECIMAL },
  437. {name: '人材机类别', value: getGljLB(glj) },
  438. {name: '是否主要材料', value: +glj.is_main_material },
  439. {name: '是否甲供', value: 0 },
  440. {name: '备注', value: glj.remark },
  441. ];
  442. Element.call(this, '人材机汇总明细表', attrs);
  443. }
  444. // 组装数据 ------------------------------------------------------------
  445. /* 生成清单主材表 */
  446. function createQDZCB(node) {
  447. const qdzcb = new Element('清单主材表');
  448. // 获取主材
  449. const mainMaterials = [];
  450. const materialMap = {};
  451. node.children.forEach(ration => {
  452. const materials = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID && isMaterial(glj.type));
  453. materials.forEach(material => {
  454. const key = gljUtil.getIndex(material);
  455. const projectGlj = curTender.projectGLJ.datas.gljMap[key];
  456. if (projectGlj && projectGlj.is_main_material) {
  457. if (!materialMap[key]) {
  458. materialMap[key] = {
  459. code: projectGlj.code,
  460. name: projectGlj.name,
  461. unit: projectGlj.unit,
  462. quantity: +material.tenderQuantity,
  463. unitPrice: getMarketPrice(projectGlj),
  464. totalPrice: 0,
  465. remark: projectGlj.remark,
  466. };
  467. mainMaterials.push(materialMap[key]);
  468. } else {
  469. materialMap[key].quantity = scMathUtil.roundForObj(materialMap[key].quantity + +material.tenderQuantity, qD);
  470. }
  471. }
  472. });
  473. });
  474. mainMaterials.forEach(material => {
  475. material.totalPrice = scMathUtil.roundForObj(material.quantity * material.unitPrice, fD);
  476. qdzcb.children.push(new QDZCBMX(material));
  477. });
  478. return qdzcb.children.length ? qdzcb : null;
  479. }
  480. /* 生成定额信息表 */
  481. function createDEXXB(node) {
  482. const rst = [];
  483. node.children.forEach(ration => {
  484. const dexxb = new DEXXB(ration);
  485. rst.push(dexxb);
  486. // 生成定额人材机含量明细
  487. const rGljData = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID);
  488. rGljData.forEach(rGlj => {
  489. const projectGlj = curTender.projectGLJ.datas.gljMap[gljUtil.getIndex(rGlj)];
  490. if (!projectGlj) {
  491. return;
  492. }
  493. const attrs = [
  494. { name: '人材机编号', value: projectGlj.code },
  495. { name: '人材机含量', value: rGlj.tenderQuantity, type: TYPE.DECIMAL },
  496. ]
  497. const dercjhlmx = new Element('定额人材机含量明细', attrs);
  498. dexxb.children.push(dercjhlmx);
  499. })
  500. });
  501. return rst;
  502. }
  503. /* 生成工程量清单表 */
  504. function createGCLQD() {
  505. // 设置工程量清单明细
  506. function setupGCLQDMX(nodes) {
  507. const rst = [];
  508. nodes.forEach(node => {
  509. const glcqdmx = new GongCLQDMX(node);
  510. rst.push(glcqdmx);
  511. if (!node.source.children.length && node.children.length) {
  512. // 清单主材表
  513. const qdzcb = createQDZCB(node);
  514. if (qdzcb) {
  515. glcqdmx.children.push(qdzcb);
  516. }
  517. // 定额
  518. glcqdmx.children.push(...createDEXXB(node));
  519. } else {
  520. // 子清单
  521. glcqdmx.children.push(...setupGCLQDMX(node.children));
  522. }
  523. });
  524. return rst;
  525. }
  526. const gclqd = new Element('工程量清单表');
  527. // 工程量清单明细为固定清单(第100章至700章清单)下所有清单
  528. const fixedNode = calcTools.getNodeByFlag(fixedFlag.ONE_SEVEN_BILLS)
  529. gclqd.children.push(...setupGCLQDMX(fixedNode.children));
  530. return gclqd;
  531. }
  532. /* 生成计日工信息表 */
  533. let jrgSeq = 1;
  534. // 获取数据类型
  535. const getJRGDataType = (node) => {
  536. const flag = node.getFlag();
  537. const parentFlag = node.parent ? node.parent.getFlag() : null;
  538. if (flag === fixedFlag.DAYWORK_LABOR) {
  539. return '0';
  540. }
  541. if (flag === fixedFlag.LABOUR_SERVICE) {
  542. return '1';
  543. }
  544. if (flag === fixedFlag.MATERIAL) {
  545. return '2';
  546. }
  547. if (flag === fixedFlag.CONSTRUCTION_MACHINE) {
  548. return '3';
  549. }
  550. if (parentFlag === fixedFlag.LABOUR_SERVICE) {
  551. return '4';
  552. }
  553. if (parentFlag === fixedFlag.MATERIAL) {
  554. return '5';
  555. }
  556. if (parentFlag === fixedFlag.CONSTRUCTION_MACHINE) {
  557. return '6';
  558. }
  559. }
  560. function createJRGXXB() {
  561. const jrgxxb = new Element('计日工信息表');
  562. const fixedNode = calcTools.getNodeByFlag(fixedFlag.DAYWORK_LABOR);
  563. function createJRG(node) {
  564. // 计日工信息标题
  565. const jrgxxbt = new Element('计日工信息标题', [
  566. { name: '序号', value: jrgSeq++ },
  567. { name: '名称', value: node.data.name },
  568. { name: '数据类型', value: getJRGDataType(node) },
  569. { name: '合价', value: getFee(node.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL},
  570. ]);
  571. if (node === fixedNode) {
  572. return jrgxxbt;
  573. }
  574. jrgxxbt.children = node.children.map(child => new Element('计日工信息明细', [
  575. { name: '编号', value: child.data.code },
  576. { name: '名称', value: child.data.name },
  577. { name: '数据类型', value: getJRGDataType(child) },
  578. { name: '单位', value: child.data.unit },
  579. { name: '暂定数量', value: child.data.quantity, type: TYPE.DECIMAL },
  580. { name: '单价', value: getFee(child.data.fees, 'common.tenderUnitFee'), type: TYPE.DECIMAL },
  581. { name: '合价', value: getFee(child.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL },
  582. ]));
  583. return jrgxxbt;
  584. }
  585. jrgxxb.children = [fixedNode, ...fixedNode.children].map(node => createJRG(node));
  586. return jrgxxb;
  587. }
  588. /* 生成造价汇总表 */
  589. function createZJHZB() {
  590. const zjhzb = new Element('造价汇总表');
  591. // 提取需要显示的数据
  592. const nodes = [];
  593. curTender.mainTree.roots.forEach(node => {
  594. nodes.push(node);
  595. if (node.getFlag() === fixedFlag.ONE_SEVEN_BILLS) {
  596. nodes.push(...node.children);
  597. }
  598. });
  599. zjhzb.children = nodes.map(node => new ZJHZMX(node));
  600. return zjhzb;
  601. }
  602. /* 生成人材机汇总 */
  603. function createRCJHZ() {
  604. const rcjhz = new Element('人材机汇总');
  605. rcjhz.children = curTender.projectGLJ.datas.gljList.map(glj => new RCJHZMXB(glj));
  606. return rcjhz;
  607. }
  608. /* 生成标段工程 */
  609. function createGLBDGC(rawTender, seq){
  610. // 标段属性
  611. const tenderAttrs = [
  612. { name: '序号', value: seq },
  613. { name: '标段名称', value: rawTender.name },
  614. { name: '金额', value: isBidInvitation ? 0 : projectData.summaryInfo[rawTender.ID].totalCost },
  615. { name: '唯一标识-Guid', value: uuid.v1() }
  616. ];
  617. const gongLBDGC = new Element('公路标段工程', tenderAttrs)
  618. // 工程量清单表
  619. const gclqd = createGCLQD();
  620. // 计日工信息表
  621. const jrgxxb = createJRGXXB();
  622. // 造价汇总表
  623. const zjhzb = createZJHZB();
  624. // 人材机汇总
  625. const rcjhz = createRCJHZ();
  626. gongLBDGC.children = [gclqd, jrgxxb, zjhzb, rcjhz];
  627. // 公路工程汇总明细属性
  628. const hzAttrs = [
  629. ...tenderAttrs,
  630. { name: '备注', value: '' }
  631. ];
  632. return {
  633. gongLBDGC,
  634. hzAttrs,
  635. }
  636. }
  637. /* 组装建设项目数据 */
  638. function setupConstruction() {
  639. const rootNode = new Element('浙江公路工程');
  640. const gongCXX = new GongCXX();
  641. const zhaoTBXX = new Element('招投标信息');
  642. const gongLGCSJ = new Element('公路工程数据');
  643. rootNode.children = [gongCXX, zhaoTBXX, gongLGCSJ];
  644. if (isBidInvitation) {
  645. zhaoTBXX.children.push(new ZhaoBiaoXX());
  646. } else if (isControl) {
  647. zhaoTBXX.children.push(new ZhaoBiaoKZJ());
  648. } else {
  649. zhaoTBXX.children.push(new TouBiaoXX());
  650. }
  651. const gongLGCHZ = new Element('公路工程汇总');
  652. const gongLGCHZBT = new Element('公路工程汇总标题');
  653. gongLGCHZ.children.push(gongLGCHZBT);
  654. // 组装标段数据
  655. projectData.children.forEach((tender, index) => {
  656. billSeq = 1;
  657. mainMaterialSeq = 1;
  658. rationSeq = 1;
  659. jrgSeq = 1;
  660. hzSeq = 1;
  661. curTender = tenderDetailMap[tender.ID];
  662. const {
  663. gongLBDGC,
  664. hzAttrs,
  665. } = createGLBDGC(tender, index + 1);
  666. gongLGCSJ.children.push(gongLBDGC);
  667. const gongLGCHZMX = new Element('公路工程汇总明细', hzAttrs);
  668. gongLGCHZBT.children.push(gongLGCHZMX);
  669. });
  670. gongLGCSJ.children.push(gongLGCHZ);
  671. const suffix = INTERFACE_CONFIG[areaKey]['fileSuffix'][exportKind];
  672. return [{
  673. data: rootNode,
  674. exportKind,
  675. fileName: `${projectData.name}${suffix}`
  676. }];
  677. }
  678. return setupConstruction(projectData);
  679. }
  680. return {
  681. entry,
  682. };
  683. })();