zhejiang_ninghai.js 8.9 KB

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