anhui_maanshan.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * @Descripttion: 安徽马鞍山导入接口
  3. * @Author: vian
  4. * @Date: 2020-09-09 11:51:15
  5. */
  6. // INTERFACE_EXPORT =,必须这么写,这样才能在导入时动态加载脚本后,覆盖前端代码
  7. INTERFACE_IMPORT = (() => {
  8. 'use strict';
  9. /**
  10. *
  11. * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
  12. * @param {Object} xmlObj - xml经过x2js转换后的xml对象
  13. */
  14. async function entry(areaKey, xmlObj) {
  15. const {
  16. UTIL: {
  17. getValue,
  18. arrayValue,
  19. getBool,
  20. extractItemsRecur,
  21. }
  22. } = INTERFACE_EXPORT_BASE;
  23. const subArea = areaKey.split('@')[1];
  24. // 提取基本信息,xml中提取出来的基本信息,最终会与模板基本信息进行合并处理。(接口内不需要处理合并)
  25. function setupInformation(projectSrc) {
  26. // key:基本信息模板中的key,作为合并时的匹配字段
  27. const info = [
  28. { key: 'projNum', value: getValue(projectSrc, ['_Xmbh']) },
  29. { key: 'projType', value: getValue(projectSrc, ['_Bzlx']) },
  30. { key: 'startAndChainages', value: getValue(projectSrc, ['_Xmqzzh']) },
  31. { key: 'constructingUnits', value: getValue(projectSrc, ['_Jsdw']) },
  32. { key: 'taxMode', value: getValue(projectSrc, ['_Jsfs']) },
  33. { key: 'tendereeName', value: getValue(projectSrc, ['ZhaoBiaoXx', '_Zbr']) },
  34. { key: 'costConsultant', value: getValue(projectSrc, ['ZhaoBiaoXx', '_Zxr']) },
  35. { key: 'tenderAuthorizer', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZbrDb']) },
  36. { key: 'consultantAuthorizer', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZxrDb']) },
  37. { key: 'tenderCompiler', value: getValue(projectSrc, ['ZhaoBiaoXx', '_Bzr']) },
  38. { key: 'tenderExaminer', value: getValue(projectSrc, ['ZhaoBiaoXx', '_Fhr']) },
  39. { key: 'compilationTime', value: getValue(projectSrc, ['ZhaoBiaoXx', '_BzTime']) },
  40. { key: 'reviewTime', value: getValue(projectSrc, ['ZhaoBiaoXx', '_FhTime']) },
  41. ];
  42. if (['淮北', '铜陵'].includes(subArea)) {
  43. const extraInfo = [
  44. { key: 'tendereeTaxpayerIdentificationNo', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZbrNssbh']) },
  45. { key: 'costConsultantTaxpayerIdentificationNo', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZxrNssbh']) },
  46. { key: 'tenderAuthorizerIDNo', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZbrDbSfzh']) },
  47. { key: 'consultantAuthorizerTaxpayerIdentificationNo', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZxrDbSfzh']) },
  48. ];
  49. info.push(...extraInfo);
  50. }
  51. return info;
  52. }
  53. // 提取工程特征信息,xml中提取出来的工程特征,最终会与模板工程特征进行合并处理。(接口内不需要处理合并)
  54. function setupFeature(midSrc, tenderSrc) {
  55. const feature = [
  56. { key: 'singleProjNo', value: getValue(midSrc, ['_Dxgcbh']) }, // 单项工程编号
  57. { key: 'singleProjName', value: getValue(midSrc, ['_Dxgcmc']) }, // 单项工程名称
  58. { key: 'unitProjNo', value: getValue(tenderSrc, ['_Dwgcbh']) },
  59. ];
  60. // 工程所在地在费率项中
  61. const feeRateItems = arrayValue(tenderSrc, ['Qfxx', 'JjFlx', 'JjFlxMx']);
  62. const locationItem = feeRateItems.find(item => getValue(item, ['_Mc']) === '工程所在地');
  63. if (locationItem) {
  64. feature.push(locationItem);
  65. }
  66. return feature;
  67. }
  68. // 费率值映射表,“接口中可有效识别的费率值类型值,此接口是Bm”与“软件中对应费率标准的名称”映射。
  69. const feeRateValueMap = {
  70. 'DJF': '冬季施工增加费',
  71. 'YJF': '雨季施工增加费',
  72. 'YEF': '夜间施工增加费',
  73. 'GYF': '高原地区施工增加费',
  74. 'FSF': '风沙地区施工增加费',
  75. 'YHF': '沿海地区施工增加费',
  76. 'XCF': '行车干扰施工增加费',
  77. 'ZYF': '工地转移费',
  78. 'SFF': '施工辅助费',
  79. 'JBF': '基本费用',
  80. 'YFF': '主副食运费补贴',
  81. 'TQF': '职工探亲路费',
  82. 'QNF': '职工取暖补贴',
  83. 'CWF': '财务费用',
  84. 'YLF': '养老保险费',
  85. 'SYF': '失业保险费',
  86. 'YBF': '医疗保险费',
  87. 'GSF': '工伤保险费',
  88. 'ZFF': '住房公积金',
  89. 'LR': '利润',
  90. 'SJ': '税金',
  91. };
  92. // 费率工程类型映射表, “接口中可有效识别的工程类型值,此接口是Qflb”与“袁建中对应费率标准的工程类型名称”映射
  93. const feeRateParentTypeMap = {
  94. 1: '土方',
  95. 2: '运输',
  96. 3: '石方',
  97. 4: '路面',
  98. 4: '路面(不计雨)',
  99. 5: '构造物Ⅰ',
  100. 6: '构造物Ⅱ',
  101. 8: '构造物Ⅲ(除桥以外)',
  102. 8: '构造物Ⅲ(除桥以外不计雨夜)',
  103. 9: '构造物Ⅲ(桥梁)',
  104. 10: '技术复杂大桥',
  105. 11: '隧道',
  106. 12: '钢材及钢结构(桥梁)',
  107. 13: '钢材及钢结构(除桥以外)',
  108. 13: '钢材及钢结构(除桥以外不计夜)',
  109. 14: '量价',
  110. 15: '设备',
  111. 16: '构造物Ⅰ(不计冬)',
  112. 16: '构造物Ⅰ(不计雨)',
  113. 17: '费率为0',
  114. };
  115. const feeRateParamMap = {
  116. djsg: '冬季施工',
  117. yjsg: '雨季施工',
  118. yjsg: '夜间施工',
  119. gysg: '高原施工',
  120. fssg: '风沙施工',
  121. yhsg: '沿海施工',
  122. hcgr: '行车干扰',
  123. gdzy: '工地转移(km)',
  124. sgfz: '施工辅助',
  125. jbfy: '基本费用',
  126. zhlc: '综合里程(km)',
  127. zgtq: '职工探亲',
  128. zgqn: '职工取暖',
  129. cwfy: '财务费用',
  130. ylbx: '养老保险(%)',
  131. sybx: '失业保险(%)',
  132. ylbx: '医疗保险(%)',
  133. gsbx: '工伤保险(%)',
  134. zfgj: '住房公积金(%)',
  135. lr: '利润(%)',
  136. sj: '税金(%)',
  137. };
  138. // 提取费率数据(费率值、费率参数),最终会与标准费率数据进行合并。(接口内不需要处理合并)
  139. function setupFeeRate(feeRateSrc) {
  140. // 提取费率值数据
  141. const valueItems = arrayValue(feeRateSrc, ['JjFlb', 'JjFlbMx'])
  142. .map(item => ({
  143. parentType: feeRateParentTypeMap[getValue(item, ['_Qflb'])] || '',
  144. type: feeRateValueMap[getValue(item, ['_Bm'])] || '',
  145. value: getValue(item, ['_Fl'])
  146. }));
  147. // 提取费率参数数据
  148. const paramItems = arrayValue(feeRateSrc, ['JjFlx', '_JjFlxMx'])
  149. .map(item => ({
  150. type: feeRateParamMap[getValue(item, ['_Bm'])] || '',
  151. value: getValue(item, ['_ShuZhi'])
  152. }));
  153. return { valueItems, paramItems };
  154. }
  155. // 提取清单数据
  156. function setupBills(billsSrc) {
  157. const qdbt = 'QdBt';
  158. const qdmx = 'QdMx';
  159. const jrg = 'Jrg';
  160. const jrgbt = 'JrgBt';
  161. const fields = [[qdbt], [qdmx], [jrg, jrgbt]];
  162. return extractItemsRecur(billsSrc, fields, (src, curField) => {
  163. let item = {
  164. name: getValue(src, ['_Name']),
  165. remark: getValue(src, ['_Bz']),
  166. }
  167. if (curField === qdbt) {
  168. item.code = getValue(src, ['_Bm']);
  169. item.rowCode = getValue(src, ['_Code']); // 注意:行号标记,用于后续(通用处理)清单基数进行转换(行引用转换为ID引用)
  170. item.calcBase = getValue(src, ['_Jsgs']);
  171. } else if (curField === qdmx) {
  172. item.code = getValue(src, ['_Qdbm']);
  173. item.unit = getValue(src, ['_Dw']);
  174. item.quantity = getValue(src, ['_Sl']);
  175. item.calcBase = getValue(src, ['_Jsgs']);
  176. item.specialProvisional = getBool(src, ['_Iszg']) ? '专业工程' : ''; // 是否暂定
  177. item.unitPriceAnalysis = +getBool(src, ['_Djfx']); // 单价分析
  178. }
  179. return item;
  180. });
  181. }
  182. // 提取单位工程数据
  183. function setupTender(midSrc, tenderSrc) {
  184. //const feeRateSrc = getValue(tenderSrc, ['Qfxx']);
  185. const billsSrc = getValue(tenderSrc, ['QdXm']);
  186. return {
  187. name: getValue(tenderSrc, ['_Dwgcmc']),
  188. feature: setupFeature(midSrc, tenderSrc),
  189. //feeRate: setupFeeRate(feeRateSrc),
  190. bills: setupBills(billsSrc)
  191. };
  192. }
  193. // 从xml对象提取需要的数据
  194. function setupProject(projectSrc) {
  195. const tenders = [];
  196. arrayValue(projectSrc, ['Dxgcxx'])
  197. .forEach(midSrc => {
  198. arrayValue(midSrc, ['Dwgcxx'])
  199. .forEach(tenderSrc => tenders.push(setupTender(midSrc, tenderSrc)))
  200. });
  201. return {
  202. name: getValue(projectSrc, ['_Xmmc']),
  203. info: setupInformation(projectSrc),
  204. tenders,
  205. };
  206. }
  207. const test = setupProject(getValue(xmlObj, ['JingJiBiao']));
  208. console.log(test);
  209. return test;
  210. }
  211. return {
  212. entry
  213. };
  214. })();