zhejiang_hangzhou.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. // 浙江杭州导入接口(copy from 宁海)
  2. // INTERFACE_EXPORT =,必须这么写,这样才能在导入时动态加载脚本后,覆盖前端代码
  3. INTERFACE_IMPORT = (() => {
  4. 'use strict';
  5. /**
  6. *
  7. * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
  8. * @param {Object} xmlObj - xml经过x2js转换后的xml对象
  9. * @return {Object} - 返回的格式需要统一,具体参考函数内返回的内容。返回的内容会经过一系列的统一处理形成可入库的数据。
  10. */
  11. async function entry(areaKey, xmlObj) {
  12. const {
  13. UTIL: {
  14. getValue,
  15. arrayValue,
  16. extractItemsRecur,
  17. }
  18. } = INTERFACE_EXPORT_BASE;
  19. const subArea = areaKey.split('@')[1];
  20. const natureConstructionMap = {
  21. '1': '施工',
  22. '2': '养护',
  23. };
  24. const roadGradeMap = {
  25. '1': '高速公路',
  26. '2': '一级公路',
  27. '3': '二级公路',
  28. '4': '三级公路',
  29. '5': '四级公路',
  30. '6': '桥梁工程',
  31. '7': '隧道工程',
  32. '8': '其他工程',
  33. };
  34. const taxModeMap = {
  35. '1': '一般计税',
  36. '2': '简易计税',
  37. };
  38. // 工程专业
  39. let engineeringName = '小修保养、大中修';
  40. // 费用标准
  41. let feeName = '高速公路';
  42. // 提取基本信息,xml中提取出来的基本信息,最终会与模板基本信息进行合并处理。(接口内不需要处理合并)
  43. function setupInformation(projectSrc) {
  44. const gcxx = getValue(projectSrc, ['工程信息']);
  45. const ztbxx = getValue(projectSrc, ['招投标信息', '招标控制价']) || getValue(projectSrc, ['招投标信息', '投标信息']) || getValue(projectSrc, ['招投标信息', '招标信息']);
  46. // key:基本信息模板中的key,作为合并时的匹配字段
  47. const natureConstruction = natureConstructionMap[getValue(gcxx, ['_项目类型'])] || '';
  48. if (natureConstruction === '养护(年度经费)') {
  49. engineeringName = '小修保养年度经费';
  50. }
  51. const roadGrade = roadGradeMap[getValue(gcxx, ['_专业划分'])] || '';
  52. feeName = roadGrade;
  53. const info = [
  54. { key: 'projNum', value: getValue(gcxx, ['_项目编号']) },
  55. { key: 'constructingUnits', value: getValue(gcxx, ['_建设单位']) },
  56. { key: 'startChainages', value: getValue(gcxx, ['_起始桩号']) },
  57. { key: 'endChainages', value: getValue(gcxx, ['_终点桩号']) },
  58. { key: 'constructionAddress', value: getValue(gcxx, ['_建设地址']) },
  59. { key: 'projOverview', value: getValue(gcxx, ['_项目概况']) },
  60. { key: 'natureConstruction', value: natureConstruction },
  61. { key: 'roadGrade', value: roadGrade },
  62. { key: 'roadDistance', value: getValue(gcxx, ['_道路里程-公里']) },
  63. { key: 'designUnit', value: getValue(gcxx, ['_设计单位']) },
  64. { key: 'taxMode', value: taxModeMap[getValue(gcxx, ['_计税方式'])] },
  65. { key: 'tendereeName', value: getValue(ztbxx, ['_招标人']) },
  66. { key: 'tenderAuthorizer', value: getValue(ztbxx, ['_招标法定代表人或其授权人']) },
  67. { key: 'compileApprover', value: getValue(ztbxx, ['_编制人']) },
  68. { key: 'compileCertNo', value: getValue(ztbxx, ['_编制人资格证号']) },
  69. { key: 'compileDate', value: getValue(ztbxx, ['_编制日期']) },
  70. { key: 'proxy', value: getValue(ztbxx, ['_招标代理机构']) },
  71. { key: 'scopeofBidding', value: getValue(ztbxx, ['_招标范围']) },
  72. { key: 'timeLimit', value: getValue(ztbxx, ['_总工期日历天']) },
  73. { key: 'compileDate', value: getValue(ztbxx, ['_编制日期']) },
  74. { key: 'preparationDescription', value: getValue(ztbxx, ['_编制说明']) },
  75. { key: 'reviewApprover', value: getValue(ztbxx, ['_复核人']) },
  76. { key: 'reviewCertNo', value: getValue(ztbxx, ['_复核人资格证号']) },
  77. { key: 'reviewDate', value: getValue(ztbxx, ['_复核日期']) },
  78. { key: 'examineApprover', value: getValue(ztbxx, ['_审核人']) },
  79. { key: 'examineCertNo', value: getValue(ztbxx, ['_审核人资格证号']) },
  80. { key: 'examineDate', value: getValue(ztbxx, ['_审核日期']) },
  81. { key: 'bidderName', value: getValue(ztbxx, ['_投标人']) },
  82. { key: 'bidderAuthorizer', value: getValue(ztbxx, ['_投标人法人或其授权人']) },
  83. { key: 'bidderCertNo', value: getValue(ztbxx, ['_投标人资质证号']) },
  84. { key: 'downwardFloatingRateOfBid', value: getValue(ztbxx, ['_投标下浮率']) },
  85. { key: 'descriptionOfTenderOffer', value: getValue(ztbxx, ['_投标报价说明']) },
  86. { key: 'qualityCommitment', value: getValue(ztbxx, ['_质量承诺']) },
  87. { key: 'bidBond', value: getValue(ztbxx, ['_投标保证金']) },
  88. { key: 'projectManagers', value: getValue(ztbxx, ['_项目经理或项目负责人']) },
  89. { key: 'projectmanagersCertNo', value: getValue(ztbxx, ['_项目经理或项目负责人资格证号']) },
  90. ];
  91. return info;
  92. }
  93. // 提取清单数据
  94. function setupBills(rootSrc, oneSevenSrc, dayWorkSrc) {
  95. // 章次为空的造价汇总表数据,为大项费用数据
  96. const roots = arrayValue(rootSrc, ['造价汇总明细'])
  97. .filter(item => !getValue(item, ['_章次']))
  98. .map(item => ({
  99. name: getValue(item, ['_名称']),
  100. remark: getValue(item, ['_备注']),
  101. titleType: getValue(item, ['_类别'])
  102. }));
  103. let oneSevenBills;
  104. let dayWorkBills;
  105. roots.forEach(item => {
  106. // const simpleName = item.name ? item.name.replace(/\s/g, '') : '';
  107. const simpleName = item.name ? item.name : ''; // 根据需求,保留所有类型的空格(空格、换行、tab缩进)
  108. if (item.titleType === '1' || /100章至第700章|100章至700章/.test(simpleName)) {
  109. oneSevenBills = item;
  110. } else if (item.titleType === '4' || (/计日工合计|计日工/.test(simpleName) && !(/不含计日工/.test(simpleName)))) {
  111. dayWorkBills = item;
  112. }
  113. });
  114. // 第100-700章的数据
  115. if (oneSevenBills) {
  116. oneSevenBills.children = extractItemsRecur(oneSevenSrc, [['工程量清单明细']], (src) => ({
  117. GUID: getValue(src, ['_GUID']),
  118. sectionCode: getValue(src, ['_清单章节号']),
  119. code: getValue(src, ['_子目号']),
  120. name: getValue(src, ['_子目名称']),
  121. unit: getValue(src, ['_单位']),
  122. quantity: getValue(src, ['_数量']),
  123. remark: getValue(src, ['_备注']),
  124. appraisalBills: +getValue(src, ['_评审清单']),
  125. specialProvisional: getValue(src, ['_数据类型']) === '21' ? '专业工程' : ''
  126. }));
  127. }
  128. // 计日工数据
  129. if (dayWorkBills) {
  130. const title = '计日工信息标题';
  131. const detail = '计日工信息明细';
  132. let jrgBillExName = '计日工合计';
  133. dayWorkBills.children = extractItemsRecur(dayWorkSrc, [[title], [detail]], (src, curField) => {
  134. const name = getValue(src, ['_名称']);
  135. const dataType = getValue(src, ['_数据类型']);
  136. // const simpleName = name ? name.replace(/\s/g, '') : ''
  137. const simpleName = name ? name : ''; // 根据需求,保留所有类型的空格(空格、换行、tab缩进)
  138. if (curField === title && (dataType === '0' || /计日工合计|计日工/.test(simpleName))) { // 计日工标题在根节点中已经提取了,不重复提取
  139. jrgBillExName = simpleName;
  140. return null;
  141. }
  142. const item = { name };
  143. if (curField === detail) {
  144. item.code = getValue(src, ['_编号']);
  145. item.unit = getValue(src, ['_单位']);
  146. item.quantity = getValue(src, ['_暂定数量']);
  147. }
  148. const remark = getValue(src, ['_备注']) || '';
  149. if (remark !== '') {
  150. item.remark = remark;
  151. }
  152. return item;
  153. });
  154. const jrgBill = roots.find(rBill => rBill.titleType === '4');
  155. if (jrgBill) {
  156. // jrgBill.specialName = jrgBillExName;
  157. jrgBill.name = jrgBillExName;
  158. }
  159. }
  160. return roots;
  161. }
  162. // 提取单位工程数据
  163. function setupTender(tenderSrc) {
  164. const oneSevenSrc = getValue(tenderSrc, ['工程量清单表']);
  165. const dayWorkSrc = getValue(tenderSrc, ['计日工信息表']);
  166. const rootSrc = getValue(tenderSrc, ['造价汇总表']);
  167. return {
  168. name: getValue(tenderSrc, ['_标段名称']),
  169. GUID: getValue(tenderSrc, ['_唯一标识-Guid']),
  170. bills: setupBills(rootSrc, oneSevenSrc, dayWorkSrc)
  171. };
  172. }
  173. // 从xml对象提取需要的数据
  174. function setupProject(projectSrc) {
  175. const tenders = arrayValue(projectSrc, ['公路工程数据', '公路标段工程'])
  176. .map(tenderSrc => setupTender(tenderSrc));
  177. return {
  178. name: getValue(projectSrc, ['工程信息', '_项目名称']),
  179. GUID: getValue(projectSrc, ['工程信息', '_GUID']),
  180. info: setupInformation(projectSrc),
  181. tenders,
  182. engineeringName,
  183. feeName,
  184. };
  185. }
  186. return setupProject(getValue(xmlObj, ['浙江交通建设工程']));
  187. }
  188. return {
  189. entry
  190. };
  191. })();