zhejiang_hangzhou.js 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028
  1. // 浙江-杭州(copy from 宁海)
  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. getNodeByFlag,
  24. generateHardwareId,
  25. },
  26. Element,
  27. } = INTERFACE_EXPORT_BASE;
  28. const {
  29. EXPORT_KIND: { BID_INVITATION, BID_SUBMISSION, CONTROL },
  30. fixedFlag,
  31. RationType,
  32. } = window.commonConstants
  33. const GljType = gljUtil.gljType;
  34. const { isGLYun } = window.commonUtil;
  35. const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  36. const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  37. const isControl = exportKind === CONTROL; // 是否是控制价
  38. const subArea = areaKey.split('@')[1];
  39. const info = projectData.property && projectData.property.basicInformation || [];
  40. const { summaryInfo } = projectData;
  41. const constructionSummary = summaryInfo[projectData.ID];
  42. let curTender;
  43. // 小数位数(按照需求固定)
  44. const qD = 4; // 消耗量
  45. const fD = 2; // 费用
  46. const pD = 6; // 中间过程
  47. // 值映射表
  48. const valueMap = {
  49. '施工': '1',
  50. '养护': '2',
  51. // '养护': '3',
  52. // '养护(年度经费)': '4',
  53. // '养护(年度经费)': '4',
  54. '高速公路': '1',
  55. '一级公路': '2',
  56. '二级公路': '3',
  57. '三级公路': '4',
  58. '四级公路': '5',
  59. '桥梁工程': '6',
  60. '独立桥梁': '6',
  61. '隧道工程': '7',
  62. '独立隧道': '7',
  63. '其他工程': '8',
  64. '等外工程': '8',
  65. '一般计税': '1',
  66. '简易计税': '2',
  67. }
  68. // 是否是材料
  69. const isMaterial = (type) => {
  70. return /^2/.test(type);
  71. }
  72. // 是否是机械
  73. const isMachine = (type) => {
  74. return /^3/.test(type);
  75. }
  76. // 获取预算价
  77. const getMarketPrice = (glj) => {
  78. const tenderCoe = gljUtil.getTenderPriceCoe(glj, curTender.property);
  79. return gljUtil.getMarketPrice(glj, curTender.projectGLJ.datas, curTender.property.calcOptions, curTender.labourCoe.datas, curTender.property.decimal, false, _, scMathUtil, tenderCoe);
  80. }
  81. // 获取人工单价
  82. const getLabourPrice = () => {
  83. if (isBidInvitation) {
  84. return 0;
  85. }
  86. const glj = curTender.projectGLJ.datas.gljList.find(glj => glj.type === 1);
  87. if (!glj) {
  88. return 0;
  89. }
  90. return getMarketPrice(glj);
  91. }
  92. const subTypeKeyArr = ['code', 'name', 'specs', 'unit', 'subType']
  93. // 获取人工消耗量
  94. const getLabourQuantity = (node) => {
  95. if (isBidInvitation) {
  96. return 0;
  97. }
  98. const quantity = +node.data.quantity || 1;
  99. let total = 0;
  100. const posterity = node.getPosterity();
  101. const rations = posterity.filter(item => calcTools.isRationItem(item));
  102. rations.forEach(ration => {
  103. const labours = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID && glj.type === 1);
  104. labours.forEach(labour => {
  105. total = scMathUtil.roundForObj(total + labour.tenderQuantity * ration.data.tenderQuantity, qD);
  106. });
  107. });
  108. const labourRations = posterity.filter(item => (calcTools.isVolumePrice(item) || calcTools.isGljRation(item)) && item.data.subType === 1);
  109. labourRations.forEach(labour => {
  110. total = scMathUtil.roundForObj(total + +labour.data.tenderQuantity, qD);
  111. });
  112. return total / quantity;
  113. }
  114. // 获取主材费、辅材费
  115. const getMaterialFee = (node) => {
  116. const rst = {
  117. mainFee: 0,
  118. assFee: 0,
  119. };
  120. if (isBidInvitation) {
  121. return rst;
  122. }
  123. let quantity = calcTools.isBill(node) ? node.data.quantity : node.data.tenderQuantity;
  124. quantity = +quantity || 1;
  125. const posterity = calcTools.isBill(node) ? node.getPosterity() : [node];
  126. // 计算定额下的费用(限定材料)
  127. const rations = posterity.filter(item => calcTools.isRationItem(item));
  128. rations.forEach(ration => {
  129. const rationGljData = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID && isMaterial(glj.type));
  130. rationGljData.forEach(rGlj => {
  131. const key = gljUtil.getIndex(rGlj);
  132. const projectGlj = curTender.projectGLJ.datas.gljMap[key];
  133. if (projectGlj) {
  134. const gljUnitFee = scMathUtil.roundForObj(rGlj.tenderQuantity * getMarketPrice(projectGlj), pD);
  135. const gljTotalFee = scMathUtil.roundForObj(gljUnitFee * ration.data.tenderQuantity, fD);
  136. if (projectGlj.is_main_material) {
  137. rst.mainFee = scMathUtil.roundForObj(rst.mainFee + gljTotalFee, fD);
  138. } else {
  139. rst.assFee = scMathUtil.roundForObj( rst.assFee + gljTotalFee, fD);
  140. }
  141. }
  142. });
  143. });
  144. // 计算工料机类型定额、量价(限定材料)
  145. const materialRations = posterity.filter(item => calcTools.isGljRation(item) && isMaterial(item.data.subType));
  146. materialRations.forEach(ration => {
  147. const key = gljUtil.getIndex(ration.data, subTypeKeyArr);
  148. const projectGlj = curTender.projectGLJ.datas.gljMap[key];
  149. if (projectGlj) {
  150. if (projectGlj.is_main_material) {
  151. rst.mainFee = scMathUtil.roundForObj(rst.mainFee + getFee(ration.data.fees, 'common.tenderTotalFee'), fD);
  152. } else {
  153. rst.assFee = scMathUtil.roundForObj(rst.assFee + getFee(ration.data.fees, 'common.tenderTotalFee'), fD);
  154. }
  155. }
  156. });
  157. const volumes = posterity.filter(item => calcTools.isVolumePrice(item) && isMaterial(item.data.subType));
  158. volumes.forEach(vol => {
  159. rst.mainFee = scMathUtil.roundForObj(rst.mainFee + getFee(vol.data.fees, 'common.tenderTotalFee'), fD);
  160. });
  161. rst.mainFee = scMathUtil.roundForObj(rst.mainFee / quantity, fD);
  162. rst.assFee = scMathUtil.roundForObj(rst.assFee / quantity, fD);
  163. return rst;
  164. }
  165. // 节点定义--------------------------------
  166. /* 工程信息 */
  167. function GongCXX(md5Str) {
  168. const xmlxStr = isGLYun() ? '施工' : '养护';
  169. const attrs = [
  170. { name: '项目编号', value: getValueByKey(info, 'projNum'), minLen: 1 },
  171. { name: '项目名称', value: projectData.name, minLen: 1 },
  172. { name: '建设单位', value: getValueByKey(info, 'constructingUnits'), minLen: 1 },
  173. { name: '起始桩号', value: getValueByKey(info, 'startChainages') },
  174. { name: '终点桩号', value: getValueByKey(info, 'endChainages') },
  175. { name: '建设地址', value: getValueByKey(info, 'constructionAddress') },
  176. { name: '项目概况', value: getValueByKey(info, 'projOverview') },
  177. // { name: '项目类型', value: valueMap[getValueByKey(info, 'natureConstruction')] },
  178. { name: '项目类型', value: valueMap[xmlxStr] },
  179. { name: '专业划分', value: valueMap[getValueByKey(info, 'roadGrade')] },
  180. { name: '道路里程-公里', value: getValueByKey(info, 'roadDistance') },
  181. { name: '设计单位', value: getValueByKey(info, 'designUnit') },
  182. { name: '计税方式', value: valueMap[getValueByKey(info, 'taxMode')] },
  183. {name: '文件类型', value: isBidInvitation ? 1 : (isControl ? 2 : 3)}, // 1=工程量清单;2=招标控制价;3=投标报价;
  184. { name: '数据校验码', value: md5Str },
  185. { name: '标准版本号', value: '1.0' },
  186. { name: 'GUID', value: projectData.GUID }
  187. ];
  188. Element.call(this, '工程信息', attrs);
  189. }
  190. /* 招标信息 */
  191. function ZhaoBiaoXX() {
  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, 'proxy'), minLen: 1},
  199. { name: '招标范围', value: getValueByKey(info, 'scopeofBidding')},
  200. { name: '总工期日历天', value: getValueByKey(info, 'timeLimit'), minLen: 1},
  201. ];
  202. Element.call(this, '招标信息', attrs);
  203. }
  204. /* 招标控制价 */
  205. function ZhaoBiaoKZJ() {
  206. const attrs = [
  207. { name: '招标人', value: getValueByKey(info, 'tendereeName'), minLen: 1 },
  208. { name: '招标法定代表人或其授权人', value: getValueByKey(info, 'tenderAuthorizer') },
  209. { name: '编制人', value: getValueByKey(info, 'compileApprover') },
  210. { name: '编制人资格证号', value: getValueByKey(info, 'compileCertNo') },
  211. { name: '编制日期', value: getValueByKey(info, 'compileDate'), type: TYPE.DATE},
  212. { name: '编制说明', value: getValueByKey(info, 'preparationDescription') },
  213. { name: '复核人', value: getValueByKey(info, 'reviewApprover') },
  214. { name: '复核人资格证号', value: getValueByKey(info, 'reviewCertNo') },
  215. { name: '复核日期', value: getValueByKey(info, 'reviewDate'), type: TYPE.DATE },
  216. { name: '审核人', value: getValueByKey(info, 'examineApprover') },
  217. { name: '审核人资格证号', value: getValueByKey(info, 'examineCertNo') },
  218. { name: '审核日期', value: getValueByKey(info, 'examineDate'), type: TYPE.DATE },
  219. { name: '控制价总价', value: constructionSummary.totalCost, type: TYPE.DECIMAL },
  220. { name: '备注', value: getValueByKey(info, '') },
  221. ];
  222. Element.call(this, '招标控制价', attrs);
  223. }
  224. /* 投标信息 */
  225. function TouBiaoXX(CRCvals) {
  226. let hardID = generateHardwareId();
  227. let [cpuId, diskId, macId] = hardID.split(";");
  228. const attrs = [
  229. { name: '投标人', value: getValueByKey(info, 'bidderName'), minLen: 1 },
  230. { name: '投标人法人或其授权人', value: getValueByKey(info, 'bidderAuthorizer') },
  231. { name: '投标人资质证号', value: getValueByKey(info, 'bidderCertNo') },
  232. { name: '总工期日历天', value: getValueByKey(info, 'timeLimit')},
  233. //{ name: '投标总价', value: constructionSummary.totalCost, type: TYPE.DECIMAL },
  234. { name: '投标总价', value: (constructionSummary.totalCost).toFixed(2) }, // 根据需求,固定写死2位小数,所以不设定Decimal,当string来看
  235. { name: '投标下浮率', value: getValueByKey(info, 'downwardFloatingRateOfBid') },
  236. { name: '投标报价说明', value: getValueByKey(info, 'descriptionOfTenderOffer') },
  237. { name: '质量承诺', value: getValueByKey(info, 'qualityCommitment') },
  238. { name: '投标保证金', value: getValueByKey(info, 'bidBond') },
  239. { name: '项目经理或项目负责人', value: getValueByKey(info, 'projectManagers') },
  240. { name: '项目经理或项目负责人资格证号', value: getValueByKey(info, 'projectmanagersCertNo') },
  241. { name: '造价软件品牌', value: '纵横公路云造价', minLen: 1 },
  242. { name: '造价软件版本', value: 'Ver' + VERSION, minLen: 1 },
  243. { name: '造价软件加密锁编号', value: userID, minLen: 1 },
  244. { name: '计算机硬件信息', value: cpuId + diskId + macId, minLen: 1 },
  245. { name: '备注', value: getValueByKey(info, '') },
  246. ];
  247. attrs.forEach(attr => {
  248. CRCvals.push(attr.value || '');
  249. });
  250. Element.call(this, '投标信息', attrs);
  251. }
  252. /* 工程量清单明细 */
  253. let billSeq = 1;
  254. // 获取数据类型
  255. function getBillDataType(node) {
  256. // 目录
  257. if (!calcTools.isLeafBill(node)) {
  258. return '1';
  259. }
  260. // 备注:增加判断,有些目录下无子项,原则上属于叶子,但应该还是要设置成目录
  261. if ( (node.data.name.indexOf('第') >= 0) && (node.data.name.indexOf('00章') >= 0) ) {
  262. return '1';
  263. }
  264. // 专项暂定
  265. if (node.data.specialProvisional == '专业工程') {
  266. return '21';
  267. }
  268. // 安全生产费
  269. const safeCode = projectObj.getSaveProductionCostCode();
  270. if (node.data.code == safeCode) {
  271. return '22'
  272. }
  273. // 工程一切险
  274. if ((node.data.code == '-a' || node.data.code == '101-1-1') && (node.parent && (node.parent.data.code == '101-1'))) {
  275. return '23'
  276. }
  277. // 第三者责任险
  278. if ((node.data.code == '-b' || node.data.code == '101-1-2') && (node.parent && (node.parent.data.code == '101-1'))) {
  279. return '24'
  280. }
  281. return '20';
  282. }
  283. // 获取清单章节
  284. const getBillSection = (node) => {
  285. const parentFlag = node.parent ? node.parent.getFlag() : null;
  286. if (parentFlag !== fixedFlag.ONE_SEVEN_BILLS) {
  287. let cur = node;
  288. while (cur) {
  289. if (cur.data.sectionCode) {
  290. return cur.data.sectionCode;
  291. }
  292. cur = cur.parent;
  293. }
  294. return (cur.data.name || '').replace(/[^0-9]/g, '');
  295. } else {
  296. const sectionCode = (node.data.name || '').replace(/[^0-9]/g, '');
  297. node.data.sectionCode = sectionCode;
  298. return sectionCode
  299. }
  300. }
  301. // 获取子目号
  302. const getBillCode = (node) => {
  303. if (node.data.code) {
  304. return node.data.code;
  305. }
  306. const parentFlag = node.parent ? node.parent.getFlag() : null;
  307. if (parentFlag === fixedFlag.ONE_SEVEN_BILLS) {
  308. return getBillSection(node);
  309. }
  310. return node.data.code;
  311. }
  312. function GongCLQDMX(node) {
  313. const { mainFee, assFee } = getMaterialFee(node);
  314. const billDataType = getBillDataType(node);
  315. let unitFee = 0;
  316. let totalFee = 0;
  317. if (!isBidInvitation || billDataType === '21') {
  318. unitFee = getFee(node.data.fees, 'common.tenderUnitFee');
  319. totalFee = getFee(node.data.fees, 'common.tenderTotalFee');
  320. }
  321. const attrs = [
  322. {name: '序号', value: billSeq ++ },
  323. {name: 'GUID', value: node.data.GUID || node.data.ID },
  324. {name: '清单章节', value: getBillSection(node), minLen: 1, enumeration: [
  325. '100', '200', '300', '400', '500', '600', '700', '800', '900', '1000', '1100',
  326. '1200', '1300', '1400', '1500', '1600', '1700', '1800', '1900', '2000',
  327. ]},
  328. {name: '子目长编号', value: divideObj.getExeBillCode(node.data.ID, node. tree)},
  329. {name: '子目号', value: getBillCode(node), minLen: 1},
  330. {name: '子目名称', value: node.data.name, minLen: 1},
  331. {name: '单位', value: node.data.unit},
  332. {name: '数量', value: node.data.quantity, type: TYPE.DECIMAL},
  333. {name: '单价', value: unitFee, type: TYPE.DECIMAL},
  334. {name: '合价', value: totalFee, type: TYPE.DECIMAL},
  335. {name: '备注', value: node.data.remark },
  336. {name: '数据类型', value: billDataType },
  337. {name: '人工费', value: getUnitFee(getFee(node.data.fees, 'marketLabour.tenderTotalFee', exportKind), node.data.quantity, 2), type: TYPE.DECIMAL},
  338. {name: '人工单价', value: getLabourPrice(), type: TYPE.DECIMAL},
  339. {name: '人工消耗量', value: getLabourQuantity(node), type: TYPE.DECIMAL},
  340. {name: '主材费', value: mainFee, type: TYPE.DECIMAL},
  341. {name: '辅材费', value: assFee, type: TYPE.DECIMAL},
  342. {name: '设备费', value: getUnitFee(getFee(node.data.fees, 'equipment.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
  343. {name: '机械使用费', value: getUnitFee(getFee(node.data.fees, 'machine.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
  344. {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},
  345. {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},
  346. {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},
  347. {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},
  348. {name: '利润', value: getUnitFee(getFee(node.data.fees, 'profit.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
  349. {name: '税金', value: getUnitFee(getFee(node.data.fees, 'tax.tenderTotalFee', exportKind), node.data.quantity, fD), type: TYPE.DECIMAL},
  350. {name: '评审清单', value: isNaN(+node.data.appraisalBills) ? 0 : +node.data.appraisalBills},
  351. ];
  352. Element.call(this, '工程量清单明细', attrs);
  353. }
  354. /* 清单主材表明细 */
  355. let mainMaterialSeq = 1;
  356. function QDZCBMX(material) {
  357. const attrs = [
  358. { name: '序号', value: mainMaterialSeq++, minLen: 1 },
  359. { name: '材料编码', value: material.code, minLen: 1 },
  360. { name: '主材名称', value: material.name, minLen: 1 },
  361. { name: '单位', value: material.unit, minLen: 1 },
  362. { name: '主材消耗量', value: material.quantity, type: TYPE.DECIMAL },
  363. { name: '单价', value: material.unitPrice, type: TYPE.DECIMAL },
  364. { name: '合价', value: material.totalPrice , type: TYPE.DECIMAL},
  365. { name: '备注', value: material.remark },
  366. ];
  367. Element.call(this, '清单主材明细', attrs);
  368. }
  369. /* 定额信息表 */
  370. let rationSeq = 1;
  371. // 获取数据类型
  372. const getRationDataType = (node) => {
  373. const programText = curTender.calcProgram.compiledTemplateMaps[node.data.programID];
  374. return programText === '费率为0' ? '4' : '3';
  375. }
  376. function DEXXB(node) {
  377. const { mainFee, assFee } = getMaterialFee(node);
  378. const attrs = [
  379. {name: '序号', value: rationSeq ++ },
  380. {name: 'GUID', value: node.data.GUID || node.data.ID },
  381. {name: '定额编号', value: node.data.code},
  382. {name: '定额名称', value: node.data.name, minLen: 1 },
  383. {name: '单位', value: node.data.unit, minLen: 1 },
  384. {name: '数量', value: node.data.tenderQuantity, type: TYPE.DECIMAL},
  385. {name: '单价', value: getFee(node.data.fees, 'common.tenderUnitFee', exportKind), type: TYPE.DECIMAL},
  386. {name: '合价', value: getFee(node.data.fees, 'common.tenderTotalFee', exportKind), type: TYPE.DECIMAL},
  387. {name: '备注', value: node.data.remark },
  388. {name: '数据类型', value: getRationDataType(node) },
  389. // {name: '人工费', value: getUnitFee(getFee(node.data.fees, 'marketLabour.tenderTotalFee', exportKind), node.data.tenderQuantity, 2), type: TYPE.DECIMAL},
  390. {name: '人工费', value: getFee(node.data.fees, 'marketLabour.tenderUnitFee', exportKind), type: TYPE.DECIMAL},
  391. {name: '主材费', value: mainFee, type: TYPE.DECIMAL},
  392. {name: '辅材费', value: assFee, type: TYPE.DECIMAL},
  393. // {name: '设备费', value: getUnitFee(getFee(node.data.fees, 'equipment.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
  394. {name: '设备费', value: getFee(node.data.fees, 'equipment.tenderUnitFee', exportKind), type: TYPE.DECIMAL},
  395. // {name: '机械使用费', value: getUnitFee(getFee(node.data.fees, 'machine.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
  396. {name: '机械使用费', value: getFee(node.data.fees, 'machine.tenderUnitFee', exportKind), type: TYPE.DECIMAL},
  397. {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},
  398. {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},
  399. {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},
  400. {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},
  401. // {name: '利润', value: getUnitFee(getFee(node.data.fees, 'profit.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
  402. {name: '利润', value: getFee(node.data.fees, 'profit.tenderUnitFee', exportKind), type: TYPE.DECIMAL},
  403. // {name: '税金', value: getUnitFee(getFee(node.data.fees, 'tax.tenderTotalFee', exportKind), node.data.tenderQuantity, fD), type: TYPE.DECIMAL},
  404. {name: '税金', value: getFee(node.data.fees, 'tax.tenderUnitFee', exportKind), type: TYPE.DECIMAL},
  405. ];
  406. Element.call(this, '定额信息表', attrs);
  407. }
  408. /* 造价汇总明细 */
  409. let hzSeq = 1;
  410. // 获取章次
  411. const getSection = (node) => {
  412. const parentFlag = node.parent ? node.parent.getFlag() : null;
  413. if (parentFlag !== fixedFlag.ONE_SEVEN_BILLS) {
  414. return '';
  415. }
  416. return (node.data.name || '').replace(/[^0-9]/g, '')
  417. }
  418. let curLB = 8;
  419. // 获取类别
  420. const getLB = (node) => {
  421. const flag = node.getFlag();
  422. const parentFlag = node.parent ? node.parent.getFlag() : null;
  423. if (parentFlag === fixedFlag.ONE_SEVEN_BILLS) {
  424. return getSection(node);
  425. }
  426. switch (flag) {
  427. case fixedFlag.ONE_SEVEN_BILLS:
  428. return '1';
  429. case fixedFlag.PROVISIONAL_TOTAL:
  430. return '2';
  431. case fixedFlag.BILLS_TOTAL_WT_PROV:
  432. return '3';
  433. case fixedFlag.DAYWORK_LABOR:
  434. // 根据费用定额判断,用全国2018导出的,就输出4; 用浙江养护2005导出的,就输出7
  435. if (isGLYun()) {
  436. return '4';
  437. } else {
  438. return '7';
  439. }
  440. case fixedFlag.PROVISIONAL:
  441. return '5';
  442. case fixedFlag.TOTAL_COST:
  443. return '6';
  444. default:
  445. return curLB++;
  446. }
  447. }
  448. function ZJHZMX(node) {
  449. const attrs = [
  450. {name: '序号', value: hzSeq++ },
  451. {name: '章次', value: getSection(node) },
  452. {name: '名称', value: node.data.name, minLen: 1 },
  453. {name: '金额', value: getFee(node.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL },
  454. {name: '类别', value: getLB(node) },
  455. {name: '备注', value: node.data.remark },
  456. ];
  457. Element.call(this, '造价汇总明细', attrs);
  458. }
  459. /* 人材机汇总明细表 */
  460. // 获取人材机类别
  461. const getGljLB = (glj) => {
  462. if (glj.type === 1) {
  463. return '1';
  464. }
  465. if (!glj.is_main_material && isMaterial(glj.type) && ![202, 203, 204 ].includes(glj.type)) {
  466. return '2';
  467. }
  468. if (isMachine(glj.type) && glj.type !== 301) {
  469. return '3';
  470. }
  471. if (glj.type === 5) {
  472. return '4';
  473. }
  474. if ([202, 203, 204].includes(glj.type)) {
  475. return '5';
  476. }
  477. if (glj.type === 301) {
  478. return '6';
  479. }
  480. if (glj.is_main_material && isMaterial(glj.type) && ![202, 203, 204 ].includes(glj.type)) {
  481. return '7';
  482. }
  483. return '2';
  484. }
  485. function RCJHZMXB(glj) {
  486. const attrs = [
  487. {name: '人材机编号', value: glj.code, minLen: 1 },
  488. {name: '人材机名称', value: glj.name, minLen: 1 },
  489. {name: '规格型号', value: glj.specs },
  490. {name: '单位', value: glj.unit, minLen: 1 },
  491. {name: '数量', value: glj.tenderQuantity },
  492. {name: '单价', value: glj.priceInfo.tenderPrice, type: TYPE.DECIMAL },
  493. {name: '人材机类别', value: getGljLB(glj) },
  494. {name: '是否主要材料', value: +glj.is_main_material },
  495. {name: '是否甲供', value: 0 },
  496. {name: '备注', value: glj.remark },
  497. ];
  498. Element.call(this, '人材机汇总明细表', attrs);
  499. }
  500. // 组装数据 ------------------------------------------------------------
  501. /* 生成清单主材表 */
  502. function createQDZCB(node) {
  503. const qdzcb = new Element('清单主材表');
  504. // 获取主材
  505. const mainMaterials = [];
  506. const materialMap = {};
  507. node.children.forEach(ration => {
  508. const materials = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID && isMaterial(glj.type));
  509. materials.forEach(material => {
  510. const key = gljUtil.getIndex(material);
  511. const projectGlj = curTender.projectGLJ.datas.gljMap[key];
  512. if (projectGlj && projectGlj.is_main_material) {
  513. if (!materialMap[key]) {
  514. materialMap[key] = {
  515. code: projectGlj.code,
  516. name: projectGlj.name,
  517. unit: projectGlj.unit,
  518. quantity: +material.tenderQuantity,
  519. unitPrice: getMarketPrice(projectGlj),
  520. totalPrice: 0,
  521. remark: projectGlj.remark,
  522. };
  523. mainMaterials.push(materialMap[key]);
  524. } else {
  525. materialMap[key].quantity = scMathUtil.roundForObj(materialMap[key].quantity + +material.tenderQuantity, qD);
  526. }
  527. }
  528. });
  529. });
  530. mainMaterials.forEach(material => {
  531. material.totalPrice = scMathUtil.roundForObj(material.quantity * material.unitPrice, fD);
  532. qdzcb.children.push(new QDZCBMX(material));
  533. });
  534. return qdzcb.children.length ? qdzcb : null;
  535. }
  536. /* 生成定额信息表 */
  537. function createDEXXB(node) {
  538. const rst = [];
  539. if(isBidInvitation) return rst; //招标工程量清单不导出定额数据
  540. node.children.forEach(ration => {
  541. const dexxb = new DEXXB(ration);
  542. rst.push(dexxb);
  543. // 生成定额人材机含量明细
  544. const rGljData = curTender.ration_glj.datas.filter(glj => glj.rationID === ration.data.ID);
  545. rGljData.forEach(rGlj => {
  546. const projectGlj = curTender.projectGLJ.datas.gljMap[gljUtil.getIndex(rGlj)];
  547. if (!projectGlj) {
  548. return;
  549. }
  550. const attrs = [
  551. { name: '人材机编号', value: projectGlj.code },
  552. { name: '人材机含量', value: rGlj.tenderQuantity, type: TYPE.DECIMAL },
  553. ]
  554. const dercjhlmx = new Element('定额人材机含量明细', attrs);
  555. dexxb.children.push(dercjhlmx);
  556. })
  557. });
  558. return rst;
  559. }
  560. /* 生成工程量清单表 */
  561. function createGCLQD() {
  562. // 设置工程量清单明细
  563. function setupGCLQDMX(nodes) {
  564. const rst = [];
  565. nodes.forEach(node => {
  566. const glcqdmx = new GongCLQDMX(node);
  567. rst.push(glcqdmx);
  568. if (!node.source.children.length && node.children.length) {
  569. // 清单主材表
  570. const qdzcb = createQDZCB(node);
  571. if (qdzcb) {
  572. glcqdmx.children.push(qdzcb);
  573. }
  574. // 定额
  575. glcqdmx.children.push(...createDEXXB(node));
  576. } else {
  577. // 子清单
  578. glcqdmx.children.push(...setupGCLQDMX(node.children));
  579. }
  580. });
  581. return rst;
  582. }
  583. const gclqd = new Element('工程量清单表');
  584. // 工程量清单明细为固定清单(第100章至700章清单)下所有清单
  585. const fixedNode = getNodeByFlag(curTender.mainTree, fixedFlag.ONE_SEVEN_BILLS)
  586. gclqd.children.push(...setupGCLQDMX(fixedNode.children));
  587. return gclqd;
  588. }
  589. /* 生成计日工信息表 */
  590. let jrgSeq = 1;
  591. // 获取数据类型
  592. const getJRGDataType = (node) => {
  593. const flag = node.getFlag();
  594. const parentFlag = node.parent ? node.parent.getFlag() : null;
  595. if (flag === fixedFlag.DAYWORK_LABOR) {
  596. return '0';
  597. }
  598. if (flag === fixedFlag.LABOUR_SERVICE) {
  599. return '1';
  600. }
  601. if (flag === fixedFlag.MATERIAL) {
  602. return '2';
  603. }
  604. if (flag === fixedFlag.CONSTRUCTION_MACHINE) {
  605. return '3';
  606. }
  607. if (parentFlag === fixedFlag.LABOUR_SERVICE) {
  608. return '4';
  609. }
  610. if (parentFlag === fixedFlag.MATERIAL) {
  611. return '5';
  612. }
  613. if (parentFlag === fixedFlag.CONSTRUCTION_MACHINE) {
  614. return '6';
  615. }
  616. }
  617. function createJRGXXB() {
  618. const jrgxxb = new Element('计日工信息表');
  619. const fixedNode = getNodeByFlag(curTender.mainTree, fixedFlag.DAYWORK_LABOR);
  620. function createJRG(node) {
  621. // 计日工信息标题
  622. const jrgAttrs = [
  623. { name: '序号', value: jrgSeq++ },
  624. { name: '名称', value: node.data.name },
  625. { name: '数据类型', value: getJRGDataType(node) },
  626. { name: '合价', value: getFee(node.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL},
  627. ];
  628. if (typeof node.data.remark === 'string' && node.data.remark.length > 0) {
  629. jrgAttrs.push({ name: '备注', value: node.data.remark });
  630. }
  631. const jrgxxbt = new Element('计日工信息标题', jrgAttrs);
  632. if (node === fixedNode) {
  633. return jrgxxbt;
  634. }
  635. jrgxxbt.children = node.children.map(child => new Element('计日工信息明细', [
  636. { name: '编号', value: child.data.code, minLen: 1 },
  637. { name: '名称', value: child.data.name, minLen: 1 },
  638. { name: '数据类型', value: getJRGDataType(child) },
  639. { name: '单位', value: child.data.unit, minLen: 1 },
  640. { name: '暂定数量', value: child.data.quantity, type: TYPE.DECIMAL },
  641. { name: '单价', value: getFee(child.data.fees, 'common.tenderUnitFee'), type: TYPE.DECIMAL },
  642. { name: '合价', value: getFee(child.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL },
  643. ]));
  644. return jrgxxbt;
  645. }
  646. jrgxxb.children = [fixedNode, ...fixedNode.children].map(node => createJRG(node));
  647. return jrgxxb;
  648. }
  649. /* 生成造价汇总表 */
  650. function createZJHZB() {
  651. const zjhzb = new Element('造价汇总表');
  652. // 提取需要显示的数据
  653. const nodes = [];
  654. curTender.mainTree.roots.forEach(node => {
  655. nodes.push(node);
  656. if (node.getFlag() === fixedFlag.ONE_SEVEN_BILLS) {
  657. nodes.push(...node.children);
  658. }
  659. });
  660. zjhzb.children = nodes.map(node => new ZJHZMX(node));
  661. return zjhzb;
  662. }
  663. /* 生成人材机汇总 */
  664. function createRCJHZ() {
  665. const rcjhz = new Element('人材机汇总');
  666. rcjhz.children = curTender.projectGLJ.datas.gljList.map(glj => new RCJHZMXB(glj));
  667. return rcjhz;
  668. }
  669. /* 生成标段工程 */
  670. function createGLBDGC(rawTender, seq){
  671. // 标段属性
  672. const tenderAttrs = [
  673. { name: '序号', value: seq, minLen: 1 },
  674. { name: '标段名称', value: rawTender.name, minLen: 1 },
  675. { name: '金额', value: isBidInvitation ? 0 : projectData.summaryInfo[rawTender.ID].totalCost },
  676. { name: '唯一标识-Guid', value: rawTender.GUID }
  677. ];
  678. const gongLBDGC = new Element('公路标段工程', tenderAttrs)
  679. // 工程量清单表
  680. const gclqd = createGCLQD();
  681. // 计日工信息表
  682. const jrgxxb = createJRGXXB();
  683. // 造价汇总表
  684. const zjhzb = createZJHZB();
  685. // 人材机汇总
  686. const rcjhz = createRCJHZ();
  687. gongLBDGC.children = [gclqd, jrgxxb, zjhzb, rcjhz];
  688. // 公路工程汇总明细属性
  689. const hzAttrs = [
  690. ...tenderAttrs,
  691. { name: '备注', value: '' }
  692. ];
  693. return {
  694. gongLBDGC,
  695. hzAttrs,
  696. }
  697. }
  698. /* 组装建设项目数据 */
  699. async function setupConstruction() {
  700. const rootNode = new Element('浙江交通建设工程');
  701. const zhaoTBXX = new Element('招投标信息');
  702. const gongLGCSJ = new Element('公路工程数据');
  703. const CRCvals = []; // 数据校验码 用
  704. if (isBidInvitation) {
  705. zhaoTBXX.children.push(new ZhaoBiaoXX());
  706. } else if (isControl) {
  707. zhaoTBXX.children.push(new ZhaoBiaoKZJ());
  708. } else {
  709. zhaoTBXX.children.push(new TouBiaoXX(CRCvals));
  710. }
  711. const gongLGCHZ = new Element('公路工程汇总');
  712. const gongLGCHZBT = new Element('公路工程汇总标题');
  713. gongLGCHZ.children.push(gongLGCHZBT);
  714. // 组装标段数据
  715. projectData.children.forEach( (tender, index) => {
  716. billSeq = 1;
  717. mainMaterialSeq = 1;
  718. rationSeq = 1;
  719. jrgSeq = 1;
  720. hzSeq = 1;
  721. curTender = tenderDetailMap[tender.ID];
  722. const {
  723. gongLBDGC,
  724. hzAttrs,
  725. } = createGLBDGC(tender, index + 1);
  726. hzAttrs.forEach(hzAttr => {
  727. CRCvals.push(hzAttr.value || '');
  728. });
  729. gongLGCSJ.children.push(gongLBDGC);
  730. const gongLGCHZMX = new Element('公路工程汇总明细', hzAttrs);
  731. gongLGCHZBT.children.push(gongLGCHZMX);
  732. });
  733. gongLGCSJ.children.push(gongLGCHZ);
  734. // const md5Str = await md5(CRCvals.join(''));
  735. const md5Str = md5Ex(CRCvals.join(''));
  736. const gongCXX = new GongCXX(md5Str);
  737. rootNode.children = [gongCXX, zhaoTBXX, gongLGCSJ];
  738. const suffix = INTERFACE_CONFIG[areaKey]['fileSuffix'][exportKind];
  739. return [{
  740. data: rootNode,
  741. exportKind,
  742. fileName: `${projectData.name}${suffix}`
  743. }];
  744. }
  745. return await setupConstruction(projectData);
  746. }
  747. async function md5(message) {
  748. const msgUint8 = new TextEncoder().encode(message); // 将字符串转换为UTF-8编码的字节
  749. // const hashBuffer = await crypto.subtle.digest('MD5', msgUint8); // 计算MD5哈希
  750. const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8); // 计算MD5哈希
  751. // const hashBuffer = await crypto.subtle.digest('md5', msgUint8); // 计算MD5哈希
  752. const hashArray = Array.from(new Uint8Array(hashBuffer)); // 转换成数组
  753. const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // 转换成16进制字符串
  754. return hashHex;
  755. }
  756. function md5Ex(string) {
  757. function md5_RotateLeft(lValue, iShiftBits) {
  758. return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
  759. }
  760. function md5_AddUnsigned(lX, lY) {
  761. var lX4, lY4, lX8, lY8, lResult;
  762. lX8 = (lX & 0x80000000);//2147483648
  763. lY8 = (lY & 0x80000000);//2147483648
  764. lX4 = (lX & 0x40000000);//1073741824
  765. lY4 = (lY & 0x40000000);//1073741824
  766. lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
  767. if (lX4 & lY4) {
  768. return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
  769. }
  770. if (lX4 | lY4) {
  771. if (lResult & 0x40000000) {
  772. return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
  773. } else {
  774. return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
  775. }
  776. } else {
  777. return (lResult ^ lX8 ^ lY8);
  778. }
  779. }
  780. function md5_F(x, y, z) {
  781. return (x & y) | ((~x) & z);
  782. }
  783. function md5_G(x, y, z) {
  784. return (x & z) | (y & (~z));
  785. }
  786. function md5_H(x, y, z) {
  787. return (x ^ y ^ z);
  788. }
  789. function md5_I(x, y, z) {
  790. return (y ^ (x | (~z)));
  791. }
  792. function md5_FF(a, b, c, d, x, s, ac) {
  793. a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_F(b, c, d), x), ac));
  794. return md5_AddUnsigned(md5_RotateLeft(a, s), b);
  795. };
  796. function md5_GG(a, b, c, d, x, s, ac) {
  797. a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_G(b, c, d), x), ac));
  798. return md5_AddUnsigned(md5_RotateLeft(a, s), b);
  799. };
  800. function md5_HH(a, b, c, d, x, s, ac) {
  801. a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_H(b, c, d), x), ac));
  802. return md5_AddUnsigned(md5_RotateLeft(a, s), b);
  803. };
  804. function md5_II(a, b, c, d, x, s, ac) {
  805. a = md5_AddUnsigned(a, md5_AddUnsigned(md5_AddUnsigned(md5_I(b, c, d), x), ac));
  806. return md5_AddUnsigned(md5_RotateLeft(a, s), b);
  807. };
  808. function md5_ConvertToWordArray(string) {
  809. var lWordCount;
  810. var lMessageLength = string.length;
  811. var lNumberOfWords_temp1 = lMessageLength + 8;
  812. var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64;
  813. var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16;
  814. var lWordArray = Array(lNumberOfWords - 1);
  815. var lBytePosition = 0;
  816. var lByteCount = 0;
  817. while (lByteCount < lMessageLength) {
  818. lWordCount = (lByteCount - (lByteCount % 4)) / 4;
  819. lBytePosition = (lByteCount % 4) * 8;
  820. lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition));
  821. lByteCount++;
  822. }
  823. lWordCount = (lByteCount - (lByteCount % 4)) / 4;
  824. lBytePosition = (lByteCount % 4) * 8;
  825. lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
  826. lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
  827. lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
  828. return lWordArray;
  829. };
  830. function md5_WordToHex(lValue) {
  831. var WordToHexValue = "",
  832. WordToHexValue_temp = "",
  833. lByte, lCount;
  834. for (lCount = 0; lCount <= 3; lCount++) {
  835. lByte = (lValue >>> (lCount * 8)) & 255;
  836. WordToHexValue_temp = "0" + lByte.toString(16);
  837. WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length - 2, 2);
  838. }
  839. return WordToHexValue;
  840. };
  841. function md5_Utf8Encode(string) {
  842. string = string.replace(/\r\n/g, "\n");
  843. var utftext = "";
  844. for (var n = 0; n < string.length; n++) {
  845. var c = string.charCodeAt(n);
  846. if (c < 128) {
  847. utftext += String.fromCharCode(c);
  848. } else if ((c > 127) && (c < 2048)) {
  849. utftext += String.fromCharCode((c >> 6) | 192);
  850. utftext += String.fromCharCode((c & 63) | 128);
  851. } else {
  852. utftext += String.fromCharCode((c >> 12) | 224);
  853. utftext += String.fromCharCode(((c >> 6) & 63) | 128);
  854. utftext += String.fromCharCode((c & 63) | 128);
  855. }
  856. }
  857. return utftext;
  858. };
  859. var x = Array();
  860. var k, AA, BB, CC, DD, a, b, c, d;
  861. var S11 = 7,
  862. S12 = 12,
  863. S13 = 17,
  864. S14 = 22;
  865. var S21 = 5,
  866. S22 = 9,
  867. S23 = 14,
  868. S24 = 20;
  869. var S31 = 4,
  870. S32 = 11,
  871. S33 = 16,
  872. S34 = 23;
  873. var S41 = 6,
  874. S42 = 10,
  875. S43 = 15,
  876. S44 = 21;
  877. string = md5_Utf8Encode(string);
  878. x = md5_ConvertToWordArray(string);
  879. a = 0x67452301;//1732584193
  880. b = 0xEFCDAB89;//4023233417
  881. c = 0x98BADCFE;//2562383102
  882. d = 0x10325476;//271733878
  883. for (k = 0; k < x.length; k += 16) {
  884. AA = a;
  885. BB = b;
  886. CC = c;
  887. DD = d;
  888. a = md5_FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
  889. d = md5_FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
  890. c = md5_FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
  891. b = md5_FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
  892. a = md5_FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
  893. d = md5_FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
  894. c = md5_FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
  895. b = md5_FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
  896. a = md5_FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
  897. d = md5_FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
  898. c = md5_FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
  899. b = md5_FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
  900. a = md5_FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
  901. d = md5_FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
  902. c = md5_FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
  903. b = md5_FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
  904. a = md5_GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
  905. d = md5_GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
  906. c = md5_GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
  907. b = md5_GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
  908. a = md5_GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
  909. d = md5_GG(d, a, b, c, x[k + 10], S22, 0x2441453);
  910. c = md5_GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
  911. b = md5_GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8);
  912. a = md5_GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6);
  913. d = md5_GG(d, a, b, c, x[k + 14], S22, 0xC33707D6);
  914. c = md5_GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87);
  915. b = md5_GG(b, c, d, a, x[k + 8], S24, 0x455A14ED);
  916. a = md5_GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905);
  917. d = md5_GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8);
  918. c = md5_GG(c, d, a, b, x[k + 7], S23, 0x676F02D9);
  919. b = md5_GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A);
  920. a = md5_HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942);
  921. d = md5_HH(d, a, b, c, x[k + 8], S32, 0x8771F681);
  922. c = md5_HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122);
  923. b = md5_HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C);
  924. a = md5_HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44);
  925. d = md5_HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9);
  926. c = md5_HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60);
  927. b = md5_HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70);
  928. a = md5_HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6);
  929. d = md5_HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA);
  930. c = md5_HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085);
  931. b = md5_HH(b, c, d, a, x[k + 6], S34, 0x4881D05);
  932. a = md5_HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039);
  933. d = md5_HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5);
  934. c = md5_HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8);
  935. b = md5_HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665);
  936. a = md5_II(a, b, c, d, x[k + 0], S41, 0xF4292244);
  937. d = md5_II(d, a, b, c, x[k + 7], S42, 0x432AFF97);
  938. c = md5_II(c, d, a, b, x[k + 14], S43, 0xAB9423A7);
  939. b = md5_II(b, c, d, a, x[k + 5], S44, 0xFC93A039);
  940. a = md5_II(a, b, c, d, x[k + 12], S41, 0x655B59C3);
  941. d = md5_II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92);
  942. c = md5_II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D);
  943. b = md5_II(b, c, d, a, x[k + 1], S44, 0x85845DD1);
  944. a = md5_II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F);
  945. d = md5_II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0);
  946. c = md5_II(c, d, a, b, x[k + 6], S43, 0xA3014314);
  947. b = md5_II(b, c, d, a, x[k + 13], S44, 0x4E0811A1);
  948. a = md5_II(a, b, c, d, x[k + 4], S41, 0xF7537E82);
  949. d = md5_II(d, a, b, c, x[k + 11], S42, 0xBD3AF235);
  950. c = md5_II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB);
  951. b = md5_II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
  952. a = md5_AddUnsigned(a, AA);
  953. b = md5_AddUnsigned(b, BB);
  954. c = md5_AddUnsigned(c, CC);
  955. d = md5_AddUnsigned(d, DD);
  956. }
  957. return (md5_WordToHex(a) + md5_WordToHex(b) + md5_WordToHex(c) + md5_WordToHex(d)).toLowerCase();
  958. }
  959. return {
  960. entry,
  961. };
  962. })();