anhui_maanshan.js 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. * @param {Object} template - 单位工程的一些模板数据,例如清单模板、标准费率数据等。
  14. */
  15. async function entry(areaKey, xmlObj, template) {
  16. const {
  17. UTIL: {
  18. getValue,
  19. arrayValue,
  20. }
  21. } = INTERFACE_EXPORT_BASE;
  22. const subArea = areaKey.split('@')[1];
  23. // 提取基本信息,xml中提取出来的基本信息,最终会与模板基本信息进行合并处理。(接口内不需要处理合并)
  24. function setupInformation(projectSrc) {
  25. // key:基本信息模板中的key,作为合并时的匹配字段
  26. const info = [
  27. { key: 'projNum', value: getValue(projectSrc, ['_Xmbh']) },
  28. { key: 'projType', value: getValue(projectSrc, ['_Bzlx']) },
  29. { key: 'startAndChainages', value: getValue(projectSrc, ['_Xmqzzh']) },
  30. { key: 'constructingUnits', value: getValue(projectSrc, ['_Jsdw']) },
  31. { key: 'taxMode', value: getValue(projectSrc, ['_Jsfs']) },
  32. { key: 'tendereeName', value: getValue(projectSrc, ['ZhaoBiaoXx', '_Zbr']) },
  33. { key: 'costConsultant', value: getValue(projectSrc, ['ZhaoBiaoXx', '_Zxr']) },
  34. { key: 'tenderAuthorizer', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZbrDb']) },
  35. { key: 'consultantAuthorizer', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZxrDb']) },
  36. { key: 'tenderCompiler', value: getValue(projectSrc, ['ZhaoBiaoXx', '_Bzr']) },
  37. { key: 'tenderExaminer', value: getValue(projectSrc, ['ZhaoBiaoXx', '_Fhr']) },
  38. { key: 'compilationTime', value: getValue(projectSrc, ['ZhaoBiaoXx', '_BzTime']) },
  39. { key: 'reviewTime', value: getValue(projectSrc, ['ZhaoBiaoXx', '_FhTime']) },
  40. ];
  41. if (['淮北', '铜陵'].includes(subArea)) {
  42. const extraInfo = [
  43. { key: 'tendereeTaxpayerIdentificationNo', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZbrNssbh']) },
  44. { key: 'costConsultantTaxpayerIdentificationNo', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZxrNssbh']) },
  45. { key: 'tenderAuthorizerIDNo', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZbrDbSfzh']) },
  46. { key: 'consultantAuthorizerTaxpayerIdentificationNo', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZxrDbSfzh']) },
  47. ];
  48. info.push(...extraInfo);
  49. }
  50. return info;
  51. }
  52. // 提取工程特征信息,xml中提取出来的工程特征,最终会与模板工程特征进行合并处理。(接口内不需要处理合并)
  53. function setupFeature(projectSrc, tenderSrc) {
  54. return [
  55. { key: 'singleProjNo', value: getValue(projectSrc, ['Dxgcxx', '_Dxgcbh']) },
  56. { key: 'singleProjName', value: getValue(projectSrc, ['Dxgcxx', '_Dxgcmc']) },
  57. { key: 'unitProjNo', value: getValue(tenderSrc, ['_Dwgcbh']) },
  58. ];
  59. }
  60. // 提取单位工程数据
  61. function setupTender(projectSrc, tenderSrc) {
  62. return {
  63. name: getValue(tenderSrc, ['_Dwgcmc']),
  64. feature: setupFeature(projectSrc, tenderSrc),
  65. }
  66. }
  67. // 从xml对象提取需要的数据
  68. function setupProject(projectSrc) {
  69. const tenders = arrayValue(projectSrc, ['Dxgcxx', 'Dwgcxx'])
  70. .map(tenderSrc => setupTender(projectSrc, tenderSrc))
  71. return {
  72. name: getValue(projectSrc, ['_Xmmc']),
  73. info: setupInformation(projectSrc),
  74. tenders,
  75. };
  76. }
  77. const test = setupProject(getValue(xmlObj, ['JingJiBiao']));
  78. console.log(test);
  79. return test;
  80. }
  81. return {
  82. entry
  83. };
  84. })();