anhui_maanshan.js 9.7 KB

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