zhejiang_ninghai.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. // 浙江宁海导入接口
  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. '3': '养护',
  24. '4': '养护(年度经费)',
  25. };
  26. const roadGradeMap = {
  27. '1': '高速公路',
  28. '2': '一级公路',
  29. '3': '二级公路',
  30. '4': '三级公路',
  31. '5': '四级公路',
  32. '6': '桥梁工程',
  33. '7': '隧道工程',
  34. '8': '其他工程',
  35. };
  36. const taxModeMap = {
  37. '1': '一般计税',
  38. '2': '简易计税',
  39. };
  40. // 提取基本信息,xml中提取出来的基本信息,最终会与模板基本信息进行合并处理。(接口内不需要处理合并)
  41. function setupInformation(projectSrc) {
  42. const gcxx = getValue(projectSrc, ['工程信息']);
  43. const ztbxx = getValue(projectSrc, ['招投标信息', '招标控制价']) || getValue(projectSrc, ['招投标信息', '投标信息']) || getValue(projectSrc, ['招投标信息', '招标信息']);
  44. // key:基本信息模板中的key,作为合并时的匹配字段
  45. const info = [
  46. { key: 'projNum', value: getValue(gcxx, ['_项目编号']) },
  47. { key: 'constructingUnits', value: getValue(gcxx, ['_建设单位']) },
  48. { key: 'startChainages', value: getValue(gcxx, ['_起始桩号']) },
  49. { key: 'endChainages', value: getValue(gcxx, ['_终点桩号']) },
  50. { key: 'constructionAddress', value: getValue(gcxx, ['_建设地址']) },
  51. { key: 'projOverview', value: getValue(gcxx, ['_项目概况']) },
  52. { key: 'natureConstruction', value: natureConstructionMap[getValue(gcxx, ['_项目类型'])] || '' },
  53. { key: 'roadGrade', value: roadGradeMap[getValue(gcxx, ['_专业划分'])] || '' },
  54. { key: 'roadDistance', value: getValue(gcxx, ['_道路里程-公里']) },
  55. { key: 'designUnit', value: getValue(gcxx, ['_设计单位']) },
  56. { key: 'taxMode', value: taxModeMap[getValue(gcxx, ['_计税方式'])] },
  57. { key: 'tendereeName', value: getValue(ztbxx, ['_招标人']) },
  58. { key: 'tenderAuthorizer', value: getValue(ztbxx, ['_招标法定代表人或其授权人']) },
  59. { key: 'compileApprover', value: getValue(ztbxx, ['_编制人']) },
  60. { key: 'compileCertNo', value: getValue(ztbxx, ['_编制人资格证号']) },
  61. { key: 'compileDate', value: getValue(ztbxx, ['_编制日期']) },
  62. { key: 'proxy', value: getValue(ztbxx, ['_招标代理机构']) },
  63. { key: 'scopeofBidding', value: getValue(ztbxx, ['_招标范围']) },
  64. { key: 'timeLimit', value: getValue(ztbxx, ['_总工期日历天']) },
  65. { key: 'compileDate', value: getValue(ztbxx, ['_编制日期']) },
  66. { key: 'preparationDescription', value: getValue(ztbxx, ['_编制说明']) },
  67. { key: 'reviewApprover', value: getValue(ztbxx, ['_复核人']) },
  68. { key: 'reviewCertNo', value: getValue(ztbxx, ['_复核人资格证号']) },
  69. { key: 'reviewDate', value: getValue(ztbxx, ['_复核日期']) },
  70. { key: 'examineApprover', value: getValue(ztbxx, ['_审核人']) },
  71. { key: 'examineCertNo', value: getValue(ztbxx, ['_审核人资格证号']) },
  72. { key: 'examineDate', value: getValue(ztbxx, ['_审核日期']) },
  73. { key: 'bidderName', value: getValue(ztbxx, ['_投标人']) },
  74. { key: 'bidderAuthorizer', value: getValue(ztbxx, ['_投标人法人或其授权人']) },
  75. { key: 'bidderCertNo', value: getValue(ztbxx, ['_投标人资质证号']) },
  76. { key: 'downwardFloatingRateOfBid', value: getValue(ztbxx, ['_投标下浮率']) },
  77. { key: 'descriptionOfTenderOffer', value: getValue(ztbxx, ['_投标报价说明']) },
  78. { key: 'qualityCommitment', value: getValue(ztbxx, ['_质量承诺']) },
  79. { key: 'bidBond', value: getValue(ztbxx, ['_投标保证金']) },
  80. { key: 'projectManagers', value: getValue(ztbxx, ['_项目经理或项目负责人']) },
  81. { key: 'projectmanagersCertNo', value: getValue(ztbxx, ['_项目经理或项目负责人资格证号']) },
  82. ];
  83. return info;
  84. }
  85. // 提取清单数据
  86. function setupBills(rootSrc, oneSevenSrc, dayWorkSrc) {
  87. // 章次为空的造价汇总表数据,为大项费用数据
  88. const roots = arrayValue(rootSrc, ['造价汇总明细'])
  89. .filter(item => !getValue(item, ['_章次']))
  90. .map(item => ({
  91. name: getValue(item, ['_名称']),
  92. remark: getValue(item, ['_备注']),
  93. titleType: getValue(item, ['_类别'])
  94. }));
  95. let oneSevenBills;
  96. let dayWorkBills;
  97. roots.forEach(item => {
  98. const simpleName = item.name ? item.name.replace(/\s/g, '') : '';
  99. if (item.titleType === '1' || /100章至第700章|100章至700章/.test(simpleName)) {
  100. oneSevenBills = item;
  101. } else if (/计日工合计/.test(simpleName)) {
  102. dayWorkBills = item;
  103. }
  104. });
  105. // 第100-700章的数据
  106. if (oneSevenBills) {
  107. oneSevenBills.children = extractItemsRecur(oneSevenSrc, [['工程量清单明细']], (src) => ({
  108. GUID: getValue(src, ['_GUID']),
  109. sectionCode: getValue(src, ['_清单章节号']),
  110. code: getValue(src, ['_子目号']),
  111. name: getValue(src, ['_子目名称']),
  112. unit: getValue(src, ['_单位']),
  113. quantity: getValue(src, ['_数量']),
  114. remark: getValue(src, ['_备注']),
  115. appraisalBills: +getValue(src, ['_评审清单']),
  116. }));
  117. }
  118. // 计日工数据
  119. if (dayWorkBills) {
  120. const title = '计日工信息标题';
  121. const detail = '计日工信息明细';
  122. dayWorkBills.children = extractItemsRecur(dayWorkSrc, [[title], [detail]], (src, curField) => {
  123. const name = getValue(src, ['_名称']);
  124. const simpleName = name ? name.replace(/\s/g, '') : ''
  125. if (curField === title && /计日工合计/.test(simpleName)) { // 计日工标题在根节点中已经提取了,不重复提取
  126. return null;
  127. }
  128. const item = { name };
  129. if (curField === detail) {
  130. item.code = getValue(src, ['_编号']);
  131. item.unit = getValue(src, ['_单位']);
  132. item.quantity = getValue(src, ['_暂定数量']);
  133. }
  134. return item;
  135. });
  136. }
  137. return roots;
  138. }
  139. // 提取单位工程数据
  140. function setupTender(tenderSrc) {
  141. const oneSevenSrc = getValue(tenderSrc, ['工程量清单表']);
  142. const dayWorkSrc = getValue(tenderSrc, ['计日工信息表']);
  143. const rootSrc = getValue(tenderSrc, ['造价汇总表']);
  144. return {
  145. name: getValue(tenderSrc, ['_标段名称']),
  146. GUID: getValue(tenderSrc, ['_唯一标识-Guid']),
  147. bills: setupBills(rootSrc, oneSevenSrc, dayWorkSrc)
  148. };
  149. }
  150. // 从xml对象提取需要的数据
  151. function setupProject(projectSrc) {
  152. const tenders = arrayValue(projectSrc, ['公路工程数据', '公路标段工程'])
  153. .map(tenderSrc => setupTender(tenderSrc));
  154. return {
  155. name: getValue(projectSrc, ['工程信息', '_项目名称']),
  156. GUID: getValue(projectSrc, ['工程信息', '_GUID']),
  157. info: setupInformation(projectSrc),
  158. tenders,
  159. };
  160. }
  161. return setupProject(getValue(xmlObj, ['浙江公路工程']));
  162. }
  163. return {
  164. entry
  165. };
  166. })();