anhui_maanshan.js 10 KB

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