// 浙江-杭州(copy from 宁海) INTERFACE_EXPORT = (() => { 'use strict'; /** * * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理 * @param {Number} exportKind - 导出类型,招标、投标、控制价 * @param {Object} projectData - 项目表数据:{ 建设项目Data, children: [单位工程...] } * @param {Object} tenderDetailMap - 单位工程ID与getData接口数据(projectObj.project的结构)的映射。 * @return {Promise} - 返回的数据结构必须按照规定:[{ data, exportKind, fileName }],参考web\building_saas\standard_interface\index.js中的注释说明 */ async function entry(areaKey, exportKind, projectData, tenderDetailMap) { const { CONFIG: { TYPE, WHITE_SPACE }, UTIL: { getValueByKey, getHan, getFee, getUnitFee, getNodeByFlag, generateHardwareId, }, Element, } = INTERFACE_EXPORT_BASE; const { EXPORT_KIND: { BID_INVITATION, BID_SUBMISSION, CONTROL }, fixedFlag, RationType, } = window.commonConstants const GljType = gljUtil.gljType; const { isGLYun } = window.commonUtil; const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标 const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标 const isControl = exportKind === CONTROL; // 是否是控制价 const subArea = areaKey.split('@')[1]; const info = projectData.property && projectData.property.basicInformation || []; const { summaryInfo } = projectData; const constructionSummary = summaryInfo[projectData.ID]; let curTender; // 小数位数(按照需求固定) const qD = 4; // 消耗量 const fD = 2; // 费用 const pD = 6; // 中间过程 // 值映射表 const valueMap = { '施工': '1', '养护': '2', // '养护': '3', // '养护(年度经费)': '4', // '养护(年度经费)': '4', '高速公路': '1', '一级公路': '2', '二级公路': '3', '三级公路': '4', '四级公路': '5', '桥梁工程': '6', '独立桥梁': '6', '隧道工程': '7', '独立隧道': '7', '其他工程': '8', '等外工程': '8', '一般计税': '1', '简易计税': '2', } // 是否是材料 const isMaterial = (type) => { return /^2/.test(type); } // 是否是机械 const isMachine = (type) => { return /^3/.test(type); } // 获取预算价 const getMarketPrice = (glj) => { const tenderCoe = gljUtil.getTenderPriceCoe(glj, curTender.property); return gljUtil.getMarketPrice(glj, curTender.projectGLJ.datas, curTender.property.calcOptions, curTender.labourCoe.datas, curTender.property.decimal, false, _, scMathUtil, tenderCoe); } // 获取人工单价 const getLabourPrice = () => { if (isBidInvitation) { return 0; } const glj = curTender.projectGLJ.datas.gljList.find(glj => glj.type === 1); if (!glj) { return 0; } return getMarketPrice(glj); } const subTypeKeyArr = ['code', 'name', 'specs', 'unit', 'subType'] // 获取人工消耗量 const getLabourQuantity = (node) => { if (isBidInvitation) { return 0; } const quantity = +node.data.quantity || 1; let total = 0; const posterity = node.getPosterity(); const rations = posterity.filter(item => calcTools.isRationItem(item)); rations.forEach(ration => { const labours = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID && glj.type === 1); labours.forEach(labour => { total = scMathUtil.roundForObj(total + labour.tenderQuantity * ration.data.tenderQuantity, qD); }); }); const labourRations = posterity.filter(item => (calcTools.isVolumePrice(item) || calcTools.isGljRation(item)) && item.data.subType === 1); labourRations.forEach(labour => { total = scMathUtil.roundForObj(total + +labour.data.tenderQuantity, qD); }); return total / quantity; } // 获取主材费、辅材费 const getMaterialFee = (node) => { const rst = { mainFee: 0, assFee: 0, }; if (isBidInvitation) { return rst; } let quantity = calcTools.isBill(node) ? node.data.quantity : node.data.tenderQuantity; quantity = +quantity || 1; const posterity = calcTools.isBill(node) ? node.getPosterity() : [node]; // 计算定额下的费用(限定材料) const rations = posterity.filter(item => calcTools.isRationItem(item)); rations.forEach(ration => { const rationGljData = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID && isMaterial(glj.type)); rationGljData.forEach(rGlj => { const key = gljUtil.getIndex(rGlj); const projectGlj = curTender.projectGLJ.datas.gljMap[key]; if (projectGlj) { const gljUnitFee = scMathUtil.roundForObj(rGlj.tenderQuantity * getMarketPrice(projectGlj), pD); const gljTotalFee = scMathUtil.roundForObj(gljUnitFee * ration.data.tenderQuantity, fD); if (projectGlj.is_main_material) { rst.mainFee = scMathUtil.roundForObj(rst.mainFee + gljTotalFee, fD); } else { rst.assFee = scMathUtil.roundForObj( rst.assFee + gljTotalFee, fD); } } }); }); // 计算工料机类型定额、量价(限定材料) const materialRations = posterity.filter(item => calcTools.isGljRation(item) && isMaterial(item.data.subType)); materialRations.forEach(ration => { const key = gljUtil.getIndex(ration.data, subTypeKeyArr); const projectGlj = curTender.projectGLJ.datas.gljMap[key]; if (projectGlj) { if (projectGlj.is_main_material) { rst.mainFee = scMathUtil.roundForObj(rst.mainFee + getFee(ration.data.fees, 'common.tenderTotalFee'), fD); } else { rst.assFee = scMathUtil.roundForObj(rst.assFee + getFee(ration.data.fees, 'common.tenderTotalFee'), fD); } } }); const volumes = posterity.filter(item => calcTools.isVolumePrice(item) && isMaterial(item.data.subType)); volumes.forEach(vol => { rst.mainFee = scMathUtil.roundForObj(rst.mainFee + getFee(vol.data.fees, 'common.tenderTotalFee'), fD); }); rst.mainFee = scMathUtil.roundForObj(rst.mainFee / quantity, fD); rst.assFee = scMathUtil.roundForObj(rst.assFee / quantity, fD); return rst; } // 节点定义-------------------------------- /* 工程信息 */ function GongCXX(md5Str) { const xmlxStr = isGLYun() ? '施工' : '养护'; const attrs = [ { name: '项目编号', value: getValueByKey(info, 'projNum'), minLen: 1 }, { name: '项目名称', value: projectData.name, minLen: 1 }, { name: '建设单位', value: getValueByKey(info, 'constructingUnits'), minLen: 1 }, { name: '起始桩号', value: getValueByKey(info, 'startChainages') }, { name: '终点桩号', value: getValueByKey(info, 'endChainages') }, { name: '建设地址', value: getValueByKey(info, 'constructionAddress') }, { name: '项目概况', value: getValueByKey(info, 'projOverview') }, // { name: '项目类型', value: valueMap[getValueByKey(info, 'natureConstruction')] }, { name: '项目类型', value: valueMap[xmlxStr] }, { name: '专业划分', value: valueMap[getValueByKey(info, 'roadGrade')] }, { name: '道路里程-公里', value: getValueByKey(info, 'roadDistance') }, { name: '设计单位', value: getValueByKey(info, 'designUnit') }, { name: '计税方式', value: valueMap[getValueByKey(info, 'taxMode')] }, {name: '文件类型', value: isBidInvitation ? 1 : (isControl ? 2 : 3)}, // 1=工程量清单;2=招标控制价;3=投标报价; { name: '数据校验码', value: md5Str }, { name: '标准版本号', value: '1.0' }, { name: 'GUID', value: projectData.GUID } ]; Element.call(this, '工程信息', attrs); } /* 招标信息 */ function ZhaoBiaoXX() { const attrs = [ { name: '招标人', value: getValueByKey(info, 'tendereeName'), minLen: 1 }, { name: '招标法定代表人或其授权人', value: getValueByKey(info, 'tenderAuthorizer') }, { name: '编制人', value: getValueByKey(info, 'compileApprover') }, { name: '编制人资格证号', value: getValueByKey(info, 'compileCertNo') }, { name: '编制日期', value: getValueByKey(info, 'compileDate'), type: TYPE.DATE}, { name: '招标代理机构', value: getValueByKey(info, 'proxy'), minLen: 1}, { name: '招标范围', value: getValueByKey(info, 'scopeofBidding')}, { name: '总工期日历天', value: getValueByKey(info, 'timeLimit'), minLen: 1}, ]; Element.call(this, '招标信息', attrs); } /* 招标控制价 */ function ZhaoBiaoKZJ() { const attrs = [ { name: '招标人', value: getValueByKey(info, 'tendereeName'), minLen: 1 }, { name: '招标法定代表人或其授权人', value: getValueByKey(info, 'tenderAuthorizer') }, { name: '编制人', value: getValueByKey(info, 'compileApprover') }, { name: '编制人资格证号', value: getValueByKey(info, 'compileCertNo') }, { name: '编制日期', value: getValueByKey(info, 'compileDate'), type: TYPE.DATE}, { name: '编制说明', value: getValueByKey(info, 'preparationDescription') }, { name: '复核人', value: getValueByKey(info, 'reviewApprover') }, { name: '复核人资格证号', value: getValueByKey(info, 'reviewCertNo') }, { name: '复核日期', value: getValueByKey(info, 'reviewDate'), type: TYPE.DATE }, { name: '审核人', value: getValueByKey(info, 'examineApprover') }, { name: '审核人资格证号', value: getValueByKey(info, 'examineCertNo') }, { name: '审核日期', value: getValueByKey(info, 'examineDate'), type: TYPE.DATE }, { name: '控制价总价', value: constructionSummary.totalCost, type: TYPE.DECIMAL }, { name: '备注', value: getValueByKey(info, '') }, ]; Element.call(this, '招标控制价', attrs); } /* 投标信息 */ function TouBiaoXX() { let hardID = generateHardwareId(); let [cpuId, diskId, macId] = hardID.split(";"); const attrs = [ { name: '投标人', value: getValueByKey(info, 'bidderName'), minLen: 1 }, { name: '投标人法人或其授权人', value: getValueByKey(info, 'bidderAuthorizer') }, { name: '投标人资质证号', value: getValueByKey(info, 'bidderCertNo') }, { name: '总工期日历天', value: getValueByKey(info, 'timeLimit')}, //{ name: '投标总价', value: constructionSummary.totalCost, type: TYPE.DECIMAL }, { name: '投标总价', value: (constructionSummary.totalCost).toFixed(2) }, // 根据需求,固定写死2位小数,所以不设定Decimal,当string来看 { name: '投标下浮率', value: getValueByKey(info, 'downwardFloatingRateOfBid') }, { name: '投标报价说明', value: getValueByKey(info, 'descriptionOfTenderOffer') }, { name: '质量承诺', value: getValueByKey(info, 'qualityCommitment') }, { name: '投标保证金', value: getValueByKey(info, 'bidBond') }, { name: '项目经理或项目负责人', value: getValueByKey(info, 'projectManagers') }, { name: '项目经理或项目负责人资格证号', value: getValueByKey(info, 'projectmanagersCertNo') }, { name: '造价软件品牌', value: '纵横公路云造价', minLen: 1 }, { name: '造价软件版本', value: 'Ver' + VERSION, minLen: 1 }, { name: '造价软件加密锁编号', value: userID, minLen: 1 }, { name: '计算机硬件信息', value: cpuId + diskId + macId, minLen: 1 }, { name: '备注', value: getValueByKey(info, '') }, ]; Element.call(this, '投标信息', attrs); } /* 工程量清单明细 */ let billSeq = 1; // 获取数据类型 function getBillDataType(node) { // 目录 if (!calcTools.isLeafBill(node)) { return '1'; } // 备注:增加判断,有些目录下无子项,原则上属于叶子,但应该还是要设置成目录 if ( (node.data.name.indexOf('第') >= 0) && (node.data.name.indexOf('00章') >= 0) ) { return '1'; } // 专项暂定 if (node.data.specialProvisional == '专业工程') { return '21'; } // 安全生产费 const safeCode = projectObj.getSaveProductionCostCode(); if (node.data.code == safeCode) { return '22' } // 工程一切险 if ((node.data.code == '-a' || node.data.code == '101-1-1') && (node.parent && (node.parent.data.code == '101-1'))) { return '23' } // 第三者责任险 if ((node.data.code == '-b' || node.data.code == '101-1-2') && (node.parent && (node.parent.data.code == '101-1'))) { return '24' } return '20'; } // 获取清单章节 const getBillSection = (node) => { const parentFlag = node.parent ? node.parent.getFlag() : null; if (parentFlag !== fixedFlag.ONE_SEVEN_BILLS) { let cur = node; while (cur) { if (cur.data.sectionCode) { return cur.data.sectionCode; } cur = cur.parent; } return (cur?.data?.name || '').replace(/[^0-9]/g, ''); } else { const sectionCode = (node.data.name || '').replace(/[^0-9]/g, ''); node.data.sectionCode = sectionCode; return sectionCode } } // 获取子目号 const getBillCode = (node) => { if (node.data.code) { return node.data.code; } const parentFlag = node.parent ? node.parent.getFlag() : null; if (parentFlag === fixedFlag.ONE_SEVEN_BILLS) { return getBillSection(node); } return node.data.code; } function GongCLQDMX(node, lnStr) { const { mainFee, assFee } = getMaterialFee(node); const billDataType = getBillDataType(node); let unitFee = 0; let totalFee = 0; if (!isBidInvitation || billDataType === '21') { unitFee = getFee(node.data.fees, 'common.tenderUnitFee'); totalFee = getFee(node.data.fees, 'common.tenderTotalFee'); } const attrs = [ {name: '序号', value: billSeq ++ }, {name: 'GUID', value: node.data.GUID || node.data.ID }, {name: '清单章节', value: getBillSection(node), minLen: 1, enumeration: [ '100', '200', '300', '400', '500', '600', '700', '800', '900', '1000', '1100', '1200', '1300', '1400', '1500', '1600', '1700', '1800', '1900', '2000', ]}, // {name: '子目长编号', value: divideObj.getExeBillCode(node.data.ID, node. tree)}, {name: '子目长编号', value: lnStr}, {name: '子目号', value: getBillCode(node), minLen: 1}, {name: '子目名称', value: node.data.name, minLen: 1}, {name: '单位', value: node.data.unit}, {name: '数量', value: node.data.quantity, type: TYPE.DECIMAL}, {name: '单价', value: unitFee, type: TYPE.DECIMAL}, {name: '合价', value: totalFee, type: TYPE.DECIMAL}, {name: '备注', value: node.data.remark }, {name: '数据类型', value: billDataType }, {name: '人工费', value: getUnitFee(getFee(node.data.fees, 'marketLabour.tenderTotalFee', exportKind), node.data.quantity, 2), type: TYPE.DECIMAL}, {name: '人工单价', value: getLabourPrice(), type: TYPE.DECIMAL}, {name: '人工消耗量', value: getLabourQuantity(node), type: TYPE.DECIMAL}, {name: '主材费', value: mainFee, type: TYPE.DECIMAL}, {name: '辅材费', value: assFee, type: TYPE.DECIMAL}, {name: '设备费', value: getUnitFee(getFee(node.data.fees, 'equipment.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL}, {name: '机械使用费', value: getUnitFee(getFee(node.data.fees, 'machine.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL}, {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}, {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}, {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}, {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}, {name: '利润', value: getUnitFee(getFee(node.data.fees, 'profit.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL}, {name: '税金', value: getUnitFee(getFee(node.data.fees, 'tax.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL}, {name: '评审清单', value: isNaN(+node.data.appraisalBills) ? 0 : +node.data.appraisalBills}, ]; Element.call(this, '工程量清单明细', attrs); } /* 清单主材表明细 */ let mainMaterialSeq = 1; function QDZCBMX(material) { const attrs = [ { name: '序号', value: mainMaterialSeq++, minLen: 1 }, { name: '材料编码', value: material.code, minLen: 1 }, { name: '主材名称', value: material.name, minLen: 1 }, { name: '单位', value: material.unit, minLen: 1 }, { name: '主材消耗量', value: material.quantity, type: TYPE.DECIMAL }, { name: '单价', value: material.unitPrice, type: TYPE.DECIMAL }, { name: '合价', value: material.totalPrice , type: TYPE.DECIMAL}, { name: '备注', value: material.remark }, ]; Element.call(this, '清单主材明细', attrs); } /* 定额信息表 */ let rationSeq = 1; // 获取数据类型 const getRationDataType = (node) => { const programText = curTender.calcProgram.compiledTemplateMaps[node.data.programID]; return programText === '费率为0' ? '4' : '3'; } function DEXXB(node) { const { mainFee, assFee } = getMaterialFee(node); const attrs = [ {name: '序号', value: rationSeq ++ }, {name: 'GUID', value: node.data.GUID || node.data.ID }, {name: '定额编号', value: node.data.code}, {name: '定额名称', value: node.data.name, minLen: 1 }, {name: '单位', value: node.data.unit, minLen: 1 }, {name: '数量', value: node.data.tenderQuantity, type: TYPE.DECIMAL}, {name: '单价', value: getFee(node.data.fees, 'common.tenderUnitFee', exportKind), type: TYPE.DECIMAL}, {name: '合价', value: getFee(node.data.fees, 'common.tenderTotalFee', exportKind), type: TYPE.DECIMAL}, {name: '备注', value: node.data.remark }, {name: '数据类型', value: getRationDataType(node) }, // {name: '人工费', value: getUnitFee(getFee(node.data.fees, 'marketLabour.tenderTotalFee', exportKind), node.data.tenderQuantity, 2), type: TYPE.DECIMAL}, {name: '人工费', value: getFee(node.data.fees, 'marketLabour.tenderUnitFee', exportKind), type: TYPE.DECIMAL}, {name: '主材费', value: mainFee, type: TYPE.DECIMAL}, {name: '辅材费', value: assFee, type: TYPE.DECIMAL}, // {name: '设备费', value: getUnitFee(getFee(node.data.fees, 'equipment.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL}, {name: '设备费', value: getFee(node.data.fees, 'equipment.tenderUnitFee', exportKind), type: TYPE.DECIMAL}, // {name: '机械使用费', value: getUnitFee(getFee(node.data.fees, 'machine.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL}, {name: '机械使用费', value: getFee(node.data.fees, 'machine.tenderUnitFee', exportKind), type: TYPE.DECIMAL}, {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}, {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}, {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}, {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}, // {name: '利润', value: getUnitFee(getFee(node.data.fees, 'profit.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL}, {name: '利润', value: getFee(node.data.fees, 'profit.tenderUnitFee', exportKind), type: TYPE.DECIMAL}, // {name: '税金', value: getUnitFee(getFee(node.data.fees, 'tax.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL}, {name: '税金', value: getFee(node.data.fees, 'tax.tenderUnitFee', exportKind), type: TYPE.DECIMAL}, ]; Element.call(this, '定额信息表', attrs); } /* 造价汇总明细 */ let hzSeq = 1; // 获取章次 const getSection = (node) => { const parentFlag = node.parent ? node.parent.getFlag() : null; if (parentFlag !== fixedFlag.ONE_SEVEN_BILLS) { return ''; } return (node.data.name || '').replace(/[^0-9]/g, '') } let curLB = 8; // 获取类别 const getLB = (node) => { const flag = node.getFlag(); const parentFlag = node.parent ? node.parent.getFlag() : null; if (parentFlag === fixedFlag.ONE_SEVEN_BILLS) { return getSection(node); } switch (flag) { case fixedFlag.ONE_SEVEN_BILLS: return '1'; case fixedFlag.PROVISIONAL_TOTAL: return '2'; case fixedFlag.BILLS_TOTAL_WT_PROV: return '3'; case fixedFlag.DAYWORK_LABOR: // 根据费用定额判断,用全国2018导出的,就输出4; 用浙江养护2005导出的,就输出7 if (isGLYun()) { return '4'; } else { return '7'; } case fixedFlag.PROVISIONAL: return '5'; case fixedFlag.TOTAL_COST: return '6'; default: return curLB++; } } function ZJHZMX(node, index = 0, isOneSeven) { let chaptNo = getSection(node); let lb = getLB(node); if (isOneSeven) { chaptNo = `${(index + 1) * 100}`; lb = chaptNo; } const attrs = [ {name: '序号', value: hzSeq++ }, {name: '章次', value: chaptNo }, {name: '名称', value: node.data.name, minLen: 1 }, {name: '金额', value: getFee(node.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL }, {name: '类别', value: lb }, {name: '备注', value: node.data.remark }, ]; Element.call(this, '造价汇总明细', attrs); } /* 人材机汇总明细表 */ // 获取人材机类别 const getGljLB = (glj) => { if (glj.type === 1) { return '1'; } if (!glj.is_main_material && isMaterial(glj.type) && ![202, 203, 204 ].includes(glj.type)) { return '2'; } if (isMachine(glj.type) && glj.type !== 301) { return '3'; } if (glj.type === 5) { return '4'; } if ([202, 203, 204].includes(glj.type)) { return '5'; } if (glj.type === 301) { return '6'; } if (glj.is_main_material && isMaterial(glj.type) && ![202, 203, 204 ].includes(glj.type)) { return '7'; } return '2'; } function RCJHZMXB(glj) { const attrs = [ {name: '人材机编号', value: glj.code, minLen: 1 }, {name: '人材机名称', value: glj.name, minLen: 1 }, {name: '规格型号', value: glj.specs }, {name: '单位', value: glj.unit, minLen: 1 }, {name: '数量', value: glj.tenderQuantity }, {name: '单价', value: glj.priceInfo.tenderPrice, type: TYPE.DECIMAL }, {name: '人材机类别', value: getGljLB(glj) }, {name: '是否主要材料', value: +glj.is_main_material }, {name: '是否甲供', value: 0 }, {name: '备注', value: glj.remark }, ]; Element.call(this, '人材机汇总明细表', attrs); } // 组装数据 ------------------------------------------------------------ /* 生成清单主材表 */ function createQDZCB(node) { const qdzcb = new Element('清单主材表'); // 获取主材 const mainMaterials = []; const materialMap = {}; node.children.forEach(ration => { const materials = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID && isMaterial(glj.type)); materials.forEach(material => { const key = gljUtil.getIndex(material); const projectGlj = curTender.projectGLJ.datas.gljMap[key]; if (projectGlj && projectGlj.is_main_material) { if (!materialMap[key]) { materialMap[key] = { code: projectGlj.code, name: projectGlj.name, unit: projectGlj.unit, quantity: +material.tenderQuantity, unitPrice: getMarketPrice(projectGlj), totalPrice: 0, remark: projectGlj.remark, }; mainMaterials.push(materialMap[key]); } else { materialMap[key].quantity = scMathUtil.roundForObj(materialMap[key].quantity + +material.tenderQuantity, qD); } } }); }); mainMaterials.forEach(material => { material.totalPrice = scMathUtil.roundForObj(material.quantity * material.unitPrice, fD); qdzcb.children.push(new QDZCBMX(material)); }); return qdzcb.children.length ? qdzcb : null; } /* 生成定额信息表 */ function createDEXXB(node) { const rst = []; if(isBidInvitation) return rst; //招标工程量清单不导出定额数据 node.children.forEach(ration => { const dexxb = new DEXXB(ration); rst.push(dexxb); // 生成定额人材机含量明细 const rGljData = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID); rGljData.forEach(rGlj => { const projectGlj = curTender.projectGLJ.datas.gljMap[gljUtil.getIndex(rGlj)]; if (!projectGlj) { return; } const attrs = [ { name: '人材机编号', value: projectGlj.code }, { name: '人材机含量', value: rGlj.tenderQuantity, type: TYPE.DECIMAL }, ] const dercjhlmx = new Element('定额人材机含量明细', attrs); dexxb.children.push(dercjhlmx); }) }); return rst; } /* 生成工程量清单表 */ function createGCLQD() { // 设置工程量清单明细 function setupGCLQDMX(nodes, longNoStr = '') { const rst = []; nodes.forEach((node, index) => { let lnStr = longNoStr; if (longNoStr === '') { lnStr = `${(index + 1) * 100}`; } const glcqdmx = new GongCLQDMX(node, lnStr); rst.push(glcqdmx); if (!node.source.children.length && node.children.length) { // 清单主材表 const qdzcb = createQDZCB(node); if (qdzcb) { glcqdmx.children.push(qdzcb); } // 定额 glcqdmx.children.push(...createDEXXB(node)); } else { // 子清单 glcqdmx.children.push(...setupGCLQDMX(node.children, lnStr)); } }); return rst; } const gclqd = new Element('工程量清单表'); // 工程量清单明细为固定清单(第100章至700章清单)下所有清单 const fixedNode = getNodeByFlag(curTender.mainTree, fixedFlag.ONE_SEVEN_BILLS) gclqd.children.push(...setupGCLQDMX(fixedNode.children)); return gclqd; } /* 生成计日工信息表 */ let jrgSeq = 1; // 获取数据类型 const getJRGDataType = (node) => { const flag = node.getFlag(); const parentFlag = node.parent ? node.parent.getFlag() : null; if (flag === fixedFlag.DAYWORK_LABOR) { return '0'; } if (flag === fixedFlag.LABOUR_SERVICE) { return '1'; } if (flag === fixedFlag.MATERIAL) { return '2'; } if (flag === fixedFlag.CONSTRUCTION_MACHINE) { return '3'; } if (parentFlag === fixedFlag.LABOUR_SERVICE) { return '4'; } if (parentFlag === fixedFlag.MATERIAL) { return '5'; } if (parentFlag === fixedFlag.CONSTRUCTION_MACHINE) { return '6'; } } function createJRGXXB() { const jrgxxb = new Element('计日工信息表'); const fixedNode = getNodeByFlag(curTender.mainTree, fixedFlag.DAYWORK_LABOR); function createJRG(node) { // 计日工信息标题 const jrgAttrs = [ { name: '序号', value: jrgSeq++ }, { name: '名称', value: node.data.name }, { name: '数据类型', value: getJRGDataType(node) }, { name: '合价', value: getFee(node.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL}, ]; if (typeof node.data.remark === 'string' && node.data.remark.length > 0) { jrgAttrs.push({ name: '备注', value: node.data.remark }); } const jrgxxbt = new Element('计日工信息标题', jrgAttrs); if (node === fixedNode) { return jrgxxbt; } jrgxxbt.children = node.children.map(child => new Element('计日工信息明细', [ { name: '编号', value: child.data.code, minLen: 1 }, { name: '名称', value: child.data.name, minLen: 1 }, { name: '数据类型', value: getJRGDataType(child) }, { name: '单位', value: child.data.unit, minLen: 1 }, { name: '暂定数量', value: child.data.quantity, type: TYPE.DECIMAL }, { name: '单价', value: getFee(child.data.fees, 'common.tenderUnitFee'), type: TYPE.DECIMAL }, { name: '合价', value: getFee(child.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL }, ])); return jrgxxbt; } jrgxxb.children = [fixedNode, ...fixedNode.children].map(node => createJRG(node)); return jrgxxb; } /* 生成造价汇总表 */ function createZJHZB() { const zjhzb = new Element('造价汇总表'); // 提取需要显示的数据 const nodes = []; let oneSevenMin = -1, oneSevenMax = -1; curTender.mainTree.roots.forEach(node => { nodes.push(node); if (node.getFlag() === fixedFlag.ONE_SEVEN_BILLS) { oneSevenMin = nodes.length; nodes.push(...node.children); oneSevenMax = nodes.length - 1; } }); // zjhzb.children = nodes.map(node => new ZJHZMX(node)); let startIdx = 0; nodes.forEach((node, index) => { const isOneSeven = index >= oneSevenMin && index <= oneSevenMax zjhzb.children.push(new ZJHZMX(node, startIdx, isOneSeven)); if (isOneSeven) startIdx++; }); return zjhzb; } /* 生成人材机汇总 */ function createRCJHZ() { const rcjhz = new Element('人材机汇总'); rcjhz.children = curTender.projectGLJ.datas.gljList.map(glj => new RCJHZMXB(glj)); return rcjhz; } /* 生成标段工程 */ function createGLBDGC(rawTender, seq){ // 标段属性 const tenderAttrs = [ { name: '序号', value: seq, minLen: 1 }, { name: '标段名称', value: rawTender.name, minLen: 1 }, { name: '金额', value: isBidInvitation ? 0 : projectData.summaryInfo[rawTender.ID].totalCost }, { name: '唯一标识-Guid', value: rawTender.GUID } ]; const gongLBDGC = new Element('公路标段工程', tenderAttrs) // 工程量清单表 const gclqd = createGCLQD(); // 计日工信息表 const jrgxxb = createJRGXXB(); // 造价汇总表 const zjhzb = createZJHZB(); // 人材机汇总 const rcjhz = createRCJHZ(); gongLBDGC.children = [gclqd, jrgxxb, zjhzb, rcjhz]; // 公路工程汇总明细属性 const hzAttrs = [ ...tenderAttrs, { name: '备注', value: '' } ]; return { gongLBDGC, hzAttrs, } } /* 组装建设项目数据 */ async function setupConstruction() { const rootNode = new Element('浙江交通建设工程'); const zhaoTBXX = new Element('招投标信息'); const gongLGCSJ = new Element('公路工程数据'); const newCRCvals = []; if (isBidInvitation) { zhaoTBXX.children.push(new ZhaoBiaoXX()); } else if (isControl) { zhaoTBXX.children.push(new ZhaoBiaoKZJ()); } else { const TBInfo = new TouBiaoXX(); newCRCvals.push(_toXMLStr([TBInfo])); zhaoTBXX.children.push(TBInfo); } const gongLGCHZ = new Element('公路工程汇总'); const gongLGCHZBT = new Element('公路工程汇总标题'); gongLGCHZ.children.push(gongLGCHZBT); // 组装标段数据 projectData.children.forEach( (tender, index) => { billSeq = 1; mainMaterialSeq = 1; rationSeq = 1; jrgSeq = 1; hzSeq = 1; curTender = tenderDetailMap[tender.ID]; const { gongLBDGC, hzAttrs, } = createGLBDGC(tender, index + 1); gongLGCSJ.children.push(gongLBDGC); const gongLGCHZMX = new Element('公路工程汇总明细', hzAttrs); gongLGCHZBT.children.push(gongLGCHZMX); }); gongLGCSJ.children.push(gongLGCHZ); newCRCvals.push(_toXMLStr([gongLGCHZ])); for (let crcIdx = 0; crcIdx < newCRCvals.length; crcIdx++) { newCRCvals[crcIdx] = newCRCvals[crcIdx].replace(/ /g, '').replace(/\r/g, '').replace(/\n/g, ''); } const md5Str = md5Ex(newCRCvals.join('')); const binaryStr = hexToBinary(md5Str); // 转成二进制string const finalMd5Str = window.btoa(binaryStr); // 还要做一次BASE64转换 const gongCXX = new GongCXX(finalMd5Str); rootNode.children = [gongCXX, zhaoTBXX, gongLGCSJ]; const suffix = INTERFACE_CONFIG[areaKey]['fileSuffix'][exportKind]; return [{ data: rootNode, exportKind, fileName: `${projectData.name}${suffix}` }]; } return await setupConstruction(projectData); } async function md5(message) { const msgUint8 = new TextEncoder().encode(message); // 将字符串转换为UTF-8编码的字节 // const hashBuffer = await crypto.subtle.digest('MD5', msgUint8); // 计算MD5哈希 const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8); // 计算MD5哈希 // const hashBuffer = await crypto.subtle.digest('md5', msgUint8); // 计算MD5哈希 const hashArray = Array.from(new Uint8Array(hashBuffer)); // 转换成数组 const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // 转换成16进制字符串 return hashHex; } function md5Ex(string) { function md5_RotateLeft(lValue, iShiftBits) { return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits)); } function md5_AddUnsigned(lX, lY) { var lX4, lY4, lX8, lY8, lResult; lX8 = (lX & 0x80000000);//2147483648 lY8 = (lY & 0x80000000);//2147483648 lX4 = (lX & 0x40000000);//1073741824 lY4 = (lY & 0x40000000);//1073741824 lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF); if (lX4 & lY4) { return (lResult ^ 0x80000000 ^ lX8 ^ lY8); } if (lX4 | lY4) { if (lResult & 0x40000000) { return (lResult ^ 0xC0000000 ^ lX8 ^ lY8); } else { return (lResult ^ 0x40000000 ^ lX8 ^ lY8); } } else { return (lResult ^ lX8 ^ lY8); } } function md5_F(x, y, z) { return (x & y) | ((~x) & z); } function md5_G(x, y, z) { return (x & z) | (y & (~z)); } function md5_H(x, y, z) { return (x ^ y ^ z); } function md5_I(x, y, z) { return (y ^ (x | (~z))); } function md5_FF(a, b, c, d, x, s, ac) { a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_F(b, c, d), x), ac)); return md5_AddUnsigned(md5_RotateLeft(a, s), b); }; function md5_GG(a, b, c, d, x, s, ac) { a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_G(b, c, d), x), ac)); return md5_AddUnsigned(md5_RotateLeft(a, s), b); }; function md5_HH(a, b, c, d, x, s, ac) { a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_H(b, c, d), x), ac)); return md5_AddUnsigned(md5_RotateLeft(a, s), b); }; function md5_II(a, b, c, d, x, s, ac) { a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_I(b, c, d), x), ac)); return md5_AddUnsigned(md5_RotateLeft(a, s), b); }; function md5_ConvertToWordArray(string) { var lWordCount; var lMessageLength = string.length; var lNumberOfWords_temp1 = lMessageLength + 8; var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64; var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16; var lWordArray = Array(lNumberOfWords - 1); var lBytePosition = 0; var lByteCount = 0; while (lByteCount < lMessageLength) { lWordCount = (lByteCount - (lByteCount % 4)) / 4; lBytePosition = (lByteCount % 4) * 8; lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition)); lByteCount++; } lWordCount = (lByteCount - (lByteCount % 4)) / 4; lBytePosition = (lByteCount % 4) * 8; lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition); lWordArray[lNumberOfWords - 2] = lMessageLength << 3; lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29; return lWordArray; }; function md5_WordToHex(lValue) { var WordToHexValue = "", WordToHexValue_temp = "", lByte, lCount; for (lCount = 0; lCount <= 3; lCount++) { lByte = (lValue >>> (lCount * 8)) & 255; WordToHexValue_temp = "0" + lByte.toString(16); WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length - 2, 2); } return WordToHexValue; }; function md5_Utf8Encode(string) { string = string.replace(/\r\n/g, "\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if ((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }; var x = Array(); var k, AA, BB, CC, DD, a, b, c, d; var S11 = 7, S12 = 12, S13 = 17, S14 = 22; var S21 = 5, S22 = 9, S23 = 14, S24 = 20; var S31 = 4, S32 = 11, S33 = 16, S34 = 23; var S41 = 6, S42 = 10, S43 = 15, S44 = 21; string = md5_Utf8Encode(string); x = md5_ConvertToWordArray(string); a = 0x67452301;//1732584193 b = 0xEFCDAB89;//4023233417 c = 0x98BADCFE;//2562383102 d = 0x10325476;//271733878 for (k = 0; k < x.length; k += 16) { AA = a; BB = b; CC = c; DD = d; a = md5_FF(a, b, c, d, x[k + 0], S11, 0xD76AA478); d = md5_FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756); c = md5_FF(c, d, a, b, x[k + 2], S13, 0x242070DB); b = md5_FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE); a = md5_FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF); d = md5_FF(d, a, b, c, x[k + 5], S12, 0x4787C62A); c = md5_FF(c, d, a, b, x[k + 6], S13, 0xA8304613); b = md5_FF(b, c, d, a, x[k + 7], S14, 0xFD469501); a = md5_FF(a, b, c, d, x[k + 8], S11, 0x698098D8); d = md5_FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF); c = md5_FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1); b = md5_FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE); a = md5_FF(a, b, c, d, x[k + 12], S11, 0x6B901122); d = md5_FF(d, a, b, c, x[k + 13], S12, 0xFD987193); c = md5_FF(c, d, a, b, x[k + 14], S13, 0xA679438E); b = md5_FF(b, c, d, a, x[k + 15], S14, 0x49B40821); a = md5_GG(a, b, c, d, x[k + 1], S21, 0xF61E2562); d = md5_GG(d, a, b, c, x[k + 6], S22, 0xC040B340); c = md5_GG(c, d, a, b, x[k + 11], S23, 0x265E5A51); b = md5_GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA); a = md5_GG(a, b, c, d, x[k + 5], S21, 0xD62F105D); d = md5_GG(d, a, b, c, x[k + 10], S22, 0x2441453); c = md5_GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681); b = md5_GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8); a = md5_GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6); d = md5_GG(d, a, b, c, x[k + 14], S22, 0xC33707D6); c = md5_GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87); b = md5_GG(b, c, d, a, x[k + 8], S24, 0x455A14ED); a = md5_GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905); d = md5_GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8); c = md5_GG(c, d, a, b, x[k + 7], S23, 0x676F02D9); b = md5_GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A); a = md5_HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942); d = md5_HH(d, a, b, c, x[k + 8], S32, 0x8771F681); c = md5_HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122); b = md5_HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C); a = md5_HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44); d = md5_HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9); c = md5_HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60); b = md5_HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70); a = md5_HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6); d = md5_HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA); c = md5_HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085); b = md5_HH(b, c, d, a, x[k + 6], S34, 0x4881D05); a = md5_HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039); d = md5_HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5); c = md5_HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8); b = md5_HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665); a = md5_II(a, b, c, d, x[k + 0], S41, 0xF4292244); d = md5_II(d, a, b, c, x[k + 7], S42, 0x432AFF97); c = md5_II(c, d, a, b, x[k + 14], S43, 0xAB9423A7); b = md5_II(b, c, d, a, x[k + 5], S44, 0xFC93A039); a = md5_II(a, b, c, d, x[k + 12], S41, 0x655B59C3); d = md5_II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92); c = md5_II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D); b = md5_II(b, c, d, a, x[k + 1], S44, 0x85845DD1); a = md5_II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F); d = md5_II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0); c = md5_II(c, d, a, b, x[k + 6], S43, 0xA3014314); b = md5_II(b, c, d, a, x[k + 13], S44, 0x4E0811A1); a = md5_II(a, b, c, d, x[k + 4], S41, 0xF7537E82); d = md5_II(d, a, b, c, x[k + 11], S42, 0xBD3AF235); c = md5_II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB); b = md5_II(b, c, d, a, x[k + 9], S44, 0xEB86D391); a = md5_AddUnsigned(a, AA); b = md5_AddUnsigned(b, BB); c = md5_AddUnsigned(c, CC); d = md5_AddUnsigned(d, DD); } return (md5_WordToHex(a) + md5_WordToHex(b) + md5_WordToHex(c) + md5_WordToHex(d)).toLowerCase(); } function hexToBinary(hex) { return hex.replace(/^(.{2})(.*)$/g, function(_, $1, $2) { return String.fromCharCode(parseInt($1, 16)) + hexToBinary($2); }); } // 开始标签 function _startTag(ele) { let rst = `<${ele.name}`; for (const attr of ele.attrs) { rst += ` ${attr.name}="${attr.value}"`; } rst += ele.children.length > 0 ? '>' : '/>'; return rst; } // 结束标签 function _endTag(ele) { return ``; } // 拼接成xml字符串 function _toXMLStr(eles) { let rst = ''; for (const ele of eles) { rst += _startTag(ele); if (ele.children.length > 0) { rst += _toXMLStr(ele.children); rst += _endTag(ele); } } return rst; } return { entry, }; })();