shandong_common.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * @Descripttion: 山东导入接口(原始内容参考中山)
  3. * @Author: Tony
  4. * @Date: 2022-10-09
  5. */
  6. INTERFACE_IMPORT = (() => {
  7. 'use strict';
  8. /**
  9. *
  10. * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
  11. * @param {Object} xmlObj - xml经过x2js转换后的xml对象
  12. * @return {Object} - 返回的格式需要统一,具体参考函数内返回的内容。返回的内容会经过一系列的统一处理形成可入库的数据。
  13. */
  14. const RoadGradeMap = {
  15. "0": "高速公路",
  16. "1": "一级公路",
  17. "2": "二级公路",
  18. "3": "三级公路",
  19. "4": "四级公路",
  20. "5": "等外公路",
  21. "6": "独立桥梁",
  22. "7":"独立隧道"
  23. }
  24. function formateDataString(dstring) {
  25. if (!dstring || dstring == "") return "";
  26. const strArr = dstring.split("T");
  27. return strArr[0]
  28. }
  29. async function entry(areaKey, xmlObj) {
  30. const {
  31. UTIL: {
  32. getValue,
  33. arrayValue,
  34. getBool,
  35. extractItemsRecur,
  36. }
  37. } = INTERFACE_EXPORT_BASE;
  38. let info = [];
  39. let tenders = [];
  40. let CprjInfo = getValue(xmlObj, ['CprjInfo']);
  41. let EprjInfos = arrayValue(CprjInfo, ["EprjInfo"]);
  42. if (EprjInfos.length > 0) {
  43. let MakeInfo = EprjInfos[0].MakeInfo;
  44. let Params = EprjInfos[0].Params;
  45. let BuildType = getValue(Params, ['_BuildType']);
  46. let natureConstruction = "";
  47. if (BuildType == "0") natureConstruction = "新建";
  48. if (BuildType == "1") natureConstruction = "改扩建";
  49. let terrainCategory = "";
  50. let Terrain = getValue(Params, ['_Terrain']);
  51. if (Terrain == "0") terrainCategory = "平原微丘";
  52. if (Terrain == "1") terrainCategory = "山岭重丘";
  53. let RoadGrade = getValue(Params, ['_RoadGrade']);
  54. let roadGrade = "";
  55. if (RoadGradeMap[RoadGrade]) roadGrade = RoadGradeMap[RoadGrade];
  56. info = [
  57. { key: 'constructingUnit', value: getValue(MakeInfo, ['_Manage']) },
  58. { key: 'designUnit', value: getValue(MakeInfo, ['_Designer']) },
  59. { key: 'compileUnit', value: getValue(MakeInfo, ['_Compile']) },
  60. { key: 'compileApprover', value: getValue(MakeInfo, ['_CompileApprover']) },
  61. { key: 'compileCertNo', value: getValue(MakeInfo, ['_CompileCertNo']) },
  62. { key: 'compileDate', value: formateDataString(getValue(MakeInfo, ['_CompileDate'])) },
  63. { key: 'reviewUnit', value: getValue(MakeInfo, ['_Review']) },
  64. { key: 'reviewApprover', value: getValue(MakeInfo, ['_ReviewApprover']) },
  65. { key: 'reviewCertNo', value: getValue(MakeInfo, ['_ReviewCertNo']) },
  66. { key: 'reviewDate', value: formateDataString(getValue(MakeInfo, ['_ReviewDate'])) },
  67. { key: 'startChainages', value: getValue(Params, ['_StartPileNo'])},
  68. { key: 'endChainages', value: getValue(Params, ['_EndPileNo']) },
  69. { key: 'location', value: getValue(Params, ['_PrjArea']) },
  70. { key: 'natureConstruction', value: natureConstruction },
  71. { key: 'terrainCategory', value: terrainCategory },
  72. { key: 'roadGrade', value: roadGrade },
  73. { key: 'makeDate', value: getValue(CprjInfo, ['SystemInfo','_MakeDate']) },
  74. ]
  75. for (let t of EprjInfos) {
  76. tenders.push(setupTender(t))
  77. }
  78. }
  79. function setupTender(EprjInfo) {
  80. let tender = {};
  81. let Params = EprjInfo.Params;
  82. let SummaryOfCost = EprjInfo.SummaryOfCost;
  83. tender.name = EprjInfo._Name;
  84. tender.bills = [];
  85. tender.bidEvaluationList = [];
  86. tender.evaluationList = [];
  87. let ProvisionalSums = getValue(SummaryOfCost, ['_ProvisionalSums']);
  88. let Structure = getValue(Params, ['_Structure']);
  89. let pavementStructure = "";
  90. if (Structure == "0") pavementStructure = "沥青路面";
  91. if (Structure == "1") pavementStructure = "水泥混凝土路面";
  92. if (Structure == "2") pavementStructure = "其他类型路面";
  93. tender.feature = [
  94. { key: 'tenderSumLimit', value: getValue(SummaryOfCost, ['_TenderSumLimit'])},//招标控制价
  95. { key: 'designSpeed', value: getValue(Params, ['_DesignSpeed']) },// --todo
  96. { key: 'pavementStructure', value: pavementStructure},// --todo
  97. { key: 'subgradeWidth', value: getValue(Params, ['_SubgradeWidth']) },
  98. { key: 'roadLength', value: getValue(Params, ['_RoadLength']) },// --todo
  99. { key: 'bridgeLength', value: getValue(Params, ['_BridgeLength']) },
  100. { key: 'tunnelLength', value: getValue(Params, ['_TunnelLength']) },// --todo
  101. { key: 'briTunRate', value: getValue(Params, ['_BriTunRate']) },// --todo
  102. { key: 'interchangeNum', value: getValue(Params, ['_InterchangeNum']) },// --todo
  103. { key: 'stubLengths', value: getValue(Params, ['_StubLengths']) },// --todo
  104. { key: 'laneLength', value: getValue(Params, ['_LaneLength']) },// --todo
  105. ]
  106. const items = arrayValue(EprjInfo, ['Items', 'Item']);
  107. for (let i of items) {
  108. let bill = setupBills(i);
  109. if (bill.name == "暂列金额(不含计日工总额)") {
  110. bill.fees = [{ fieldName: "common",tenderTotalFee:ProvisionalSums, tenderUnitFee: "0", totalFee: ProvisionalSums, unitFee: "0" }];
  111. bill.calcBase = ProvisionalSums;
  112. bill.calcFlag = 1;
  113. }
  114. tender.bills.push(bill);
  115. }
  116. const BidEvaluationMainMaterial = arrayValue(EprjInfo, ['BidEvaluationMainMaterial']);
  117. for (let b of BidEvaluationMainMaterial) {
  118. tender.bidEvaluationList.push(setUpBidEvaluation(b))
  119. }
  120. return tender;
  121. }
  122. function setupBills(item) {
  123. let bill = {
  124. code: item._ListCode,
  125. name: item._ListName,
  126. unit: item._Unit,
  127. quantity: item._Num,
  128. remark: item._Remarks,
  129. jobContentText: item._Content,
  130. specialProvisional: '',
  131. children: []
  132. }
  133. if (item._ProvisionalType == '0') bill.specialProvisional = '材料暂估';
  134. if (item._ProvisionalType == '1') bill.specialProvisional = '工程设备';
  135. if (item._ProvisionalType == '2') bill.specialProvisional = '专业工程';
  136. let subItems = arrayValue(item, ['Item']);
  137. if (subItems && subItems.length > 0) {
  138. for (let i of subItems) {
  139. bill.children.push(setupBills(i))
  140. }
  141. }
  142. return bill;
  143. }
  144. function setUpBidEvaluation(b) {
  145. return {
  146. seq: b._Code,
  147. code: b._Number,
  148. name: b._Name,
  149. specs: b._Specification,
  150. unit: b._Unit,
  151. market_price: b._Price,
  152. quantity: b._Quantity,
  153. remark:b._Remark
  154. }
  155. }
  156. return {
  157. name: CprjInfo._CprjName,
  158. info,
  159. tenders,
  160. };
  161. }
  162. return {
  163. entry
  164. };
  165. })();