guangdong_zhongshan.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. const RoadGradeMap = {
  16. "0": "高速公路",
  17. "1": "一级公路",
  18. "2": "二级公路",
  19. "3": "三级公路",
  20. "4": "四级公路",
  21. "5": "等外公路",
  22. "6": "独立桥梁",
  23. "7":"独立隧道"
  24. }
  25. function formateDataString(dstring) {
  26. if (!dstring || dstring == "") return "";
  27. const strArr = dstring.split("T");
  28. return strArr[0]
  29. }
  30. async function entry(areaKey, xmlObj) {
  31. const {
  32. UTIL: {
  33. getValue,
  34. arrayValue,
  35. getBool,
  36. extractItemsRecur,
  37. }
  38. } = INTERFACE_EXPORT_BASE;
  39. let info = [];
  40. let tenders = [];
  41. let CprjInfo = getValue(xmlObj, ['CprjInfo']);
  42. let EprjInfos = arrayValue(CprjInfo, ["EprjInfo"]);
  43. if (EprjInfos.length > 0) {
  44. let MakeInfo = EprjInfos[0].MakeInfo;
  45. let Params = EprjInfos[0].Params;
  46. let BuildType = getValue(Params, ['_BuildType']);
  47. let natureConstruction = "";
  48. if (BuildType == "0") natureConstruction = "新建";
  49. if (BuildType == "1") natureConstruction = "改扩建";
  50. let terrainCategory = "";
  51. let Terrain = getValue(Params, ['_Terrain']);
  52. if (Terrain == "0") terrainCategory = "平原微丘";
  53. if (Terrain == "1") terrainCategory = "山岭重丘";
  54. let RoadGrade = getValue(Params, ['_RoadGrade']);
  55. let roadGrade = "";
  56. if (RoadGradeMap[RoadGrade]) roadGrade = RoadGradeMap[RoadGrade];
  57. info = [
  58. { key: 'constructingUnit', value: getValue(MakeInfo, ['_Manage']) },
  59. { key: 'designUnit', value: getValue(MakeInfo, ['_Designer']) },
  60. { key: 'compileUnit', value: getValue(MakeInfo, ['_Compile']) },
  61. { key: 'compileApprover', value: getValue(MakeInfo, ['_CompileApprover']) },
  62. { key: 'compileCertNo', value: getValue(MakeInfo, ['_CompileCertNo']) },
  63. { key: 'compileDate', value: formateDataString(getValue(MakeInfo, ['_CompileDate'])) },
  64. { key: 'reviewUnit', value: getValue(MakeInfo, ['_Review']) },
  65. { key: 'reviewApprover', value: getValue(MakeInfo, ['_ReviewApprover']) },
  66. { key: 'reviewCertNo', value: getValue(MakeInfo, ['_ReviewCertNo']) },
  67. { key: 'reviewDate', value: formateDataString(getValue(MakeInfo, ['_ReviewDate'])) },
  68. { key: 'startChainages', value: getValue(Params, ['_StartPileNo'])},
  69. { key: 'endChainages', value: getValue(Params, ['_EndPileNo']) },
  70. { key: 'location', value: getValue(Params, ['_PrjArea']) },
  71. { key: 'natureConstruction', value: natureConstruction },
  72. { key: 'terrainCategory', value: terrainCategory },
  73. { key: 'roadGrade', value: roadGrade },
  74. { key: 'makeDate', value: getValue(CprjInfo, ['SystemInfo','_MakeDate']) },
  75. ]
  76. for (let t of EprjInfos) {
  77. tenders.push(setupTender(t))
  78. }
  79. }
  80. function setupTender(EprjInfo) {
  81. let tender = {};
  82. let Params = EprjInfo.Params;
  83. let SummaryOfCost = EprjInfo.SummaryOfCost;
  84. tender.name = EprjInfo._Name;
  85. tender.bills = [];
  86. tender.bidEvaluationList = [];
  87. tender.evaluationList = [];
  88. let ProvisionalSums = getValue(SummaryOfCost, ['_ProvisionalSums']);
  89. let Structure = getValue(Params, ['_Structure']);
  90. let pavementStructure = "";
  91. if (Structure == "0") pavementStructure = "沥青路面";
  92. if (Structure == "1") pavementStructure = "水泥混凝土路面";
  93. if (Structure == "2") pavementStructure = "其他类型路面";
  94. tender.feature = [
  95. { key: 'tenderSumLimit', value: getValue(SummaryOfCost, ['_TenderSumLimit'])},//招标控制价
  96. { key: 'designSpeed', value: getValue(Params, ['_DesignSpeed']) },// --todo
  97. { key: 'pavementStructure', value: pavementStructure},// --todo
  98. { key: 'subgradeWidth', value: getValue(Params, ['_SubgradeWidth']) },
  99. { key: 'roadLength', value: getValue(Params, ['_RoadLength']) },// --todo
  100. { key: 'bridgeLength', value: getValue(Params, ['_BridgeLength']) },
  101. { key: 'tunnelLength', value: getValue(Params, ['_TunnelLength']) },// --todo
  102. { key: 'briTunRate', value: getValue(Params, ['_BriTunRate']) },// --todo
  103. { key: 'interchangeNum', value: getValue(Params, ['_InterchangeNum']) },// --todo
  104. { key: 'stubLengths', value: getValue(Params, ['_StubLengths']) },// --todo
  105. { key: 'laneLength', value: getValue(Params, ['_LaneLength']) },// --todo
  106. ]
  107. const items = arrayValue(EprjInfo, ['Items', 'Item']);
  108. for (let i of items) {
  109. let bill = setupBills(i);
  110. if (bill.name == "暂列金额(不含计日工总额)") {
  111. bill.fees = [{ fieldName: "common",tenderTotalFee:ProvisionalSums, tenderUnitFee: "0", totalFee: ProvisionalSums, unitFee: "0" }];
  112. bill.calcBase = ProvisionalSums;
  113. bill.calcFlag = 1;
  114. }
  115. tender.bills.push(bill);
  116. }
  117. const BidEvaluationMainMaterial = arrayValue(EprjInfo, ['BidEvaluationMainMaterial']);
  118. for (let b of BidEvaluationMainMaterial) {
  119. tender.bidEvaluationList.push(setUpBidEvaluation(b))
  120. }
  121. return tender;
  122. }
  123. function setupBills(item) {
  124. let bill = {
  125. code: item._ListCode,
  126. name: item._ListName,
  127. unit: item._Unit,
  128. quantity: item._Num,
  129. remark: item._Remarks,
  130. jobContentText: item._Content,
  131. specialProvisional: '',
  132. children: []
  133. }
  134. if (item._ProvisionalType == '0') bill.specialProvisional = '材料';
  135. if (item._ProvisionalType == '1') bill.specialProvisional = '工程设备';
  136. if (item._ProvisionalType == '2') bill.specialProvisional = '工程设备';
  137. let subItems = arrayValue(item, ['Item']);
  138. if (subItems && subItems.length > 0) {
  139. for (let i of subItems) {
  140. bill.children.push(setupBills(i))
  141. }
  142. }
  143. return bill;
  144. }
  145. function setUpBidEvaluation(b) {
  146. return {
  147. seq: b._Code,
  148. code: b._Number,
  149. name: b._Name,
  150. specs: b._Specification,
  151. unit: b._Unit,
  152. market_price: b._Price,
  153. quantity: b._Quantity,
  154. remark:b._Remark
  155. }
  156. }
  157. return {
  158. name: CprjInfo._CprjName,
  159. info,
  160. tenders,
  161. };
  162. }
  163. return {
  164. entry
  165. };
  166. })();