guangxi_common.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /*
  2. * @Descripttion: 广西导入接口(参考广东-中山)
  3. * @Author: Tony
  4. * @Date: 2022-09-23
  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. // { key: 'keyId', value: getValue(CprjInfo, ['SystemInfo','KeyId']) },
  76. ]
  77. for (let t of EprjInfos) {
  78. tenders.push(setupTender(t))
  79. }
  80. }
  81. // 获取需要存的KeyId(建设项目内只有一个的,可以存到一个字段。清单的无法这么处理,清单的keyId数据要存到清单本身)
  82. function getConstructionKeyIDData() {
  83. const cprjInfo = getValue(xmlObj, ['CprjInfo', '_KeyId']);
  84. const systemInfo = getValue(xmlObj, ['CprjInfo', 'SystemInfo', '_KeyId']);
  85. const costBasis = getValue(xmlObj, ['CprjInfo', 'CostBasis', '_KeyId']);
  86. const rate = getValue(xmlObj, ['CprjInfo', 'Rate', '_KeyId']);
  87. const pract = getValue(xmlObj, ['CprjInfo', 'Pract', '_KeyId']);
  88. const eprjInfo = getValue(xmlObj, ['CprjInfo', 'EprjInfo', '_KeyId']);
  89. const indexs = getValue(xmlObj, ['CprjInfo', 'Indexs', '_KeyId']);
  90. const rateParams = getValue(xmlObj, ['CprjInfo', 'Rate', 'RateParams', '_KeyId']);
  91. const rateValues = getValue(xmlObj, ['CprjInfo', 'Rate', 'RateValues', '_KeyId']);
  92. const mps = getValue(xmlObj, ['CprjInfo', 'Pract', 'Mps', '_KeyId']);
  93. const materials = getValue(xmlObj, ['CprjInfo', 'Pract', 'Materials', '_KeyId']);
  94. const mechs = getValue(xmlObj, ['CprjInfo', 'Pract', 'Mechs', '_KeyId']);
  95. const makeInfo = getValue(xmlObj, ['CprjInfo', 'EprjInfo', 'MakeInfo', '_KeyId']);
  96. const params = getValue(xmlObj, ['CprjInfo', 'EprjInfo', 'Params', '_KeyId']);
  97. const items = getValue(xmlObj, ['CprjInfo', 'EprjInfo', 'Items', '_KeyId']);
  98. return {
  99. cprjInfo,
  100. systemInfo,
  101. costBasis,
  102. rate,
  103. pract,
  104. eprjInfo,
  105. indexs,
  106. rateParams,
  107. rateValues,
  108. mps,
  109. materials,
  110. mechs,
  111. makeInfo,
  112. params,
  113. items,
  114. }
  115. }
  116. function setupTender(EprjInfo) {
  117. let tender = {};
  118. let Params = EprjInfo.Params;
  119. // let SummaryOfCost = EprjInfo.SummaryOfCost;
  120. tender.name = EprjInfo._Name;
  121. tender.bills = [];
  122. tender.bidEvaluationList = [];
  123. tender.evaluationList = [];
  124. // let ProvisionalSums = getValue(SummaryOfCost, ['_ProvisionalSums']);
  125. let Structure = getValue(Params, ['_Structure']);
  126. let pavementStructure = "";
  127. if (Structure == "0") pavementStructure = "沥青路面";
  128. if (Structure == "1") pavementStructure = "水泥混凝土路面";
  129. if (Structure == "2") pavementStructure = "其他类型路面";
  130. tender.feature = [
  131. // { key: 'tenderSumLimit', value: getValue(SummaryOfCost, ['_TenderSumLimit'])},//招标控制价
  132. { key: 'designSpeed', value: getValue(Params, ['_DesignSpeed']) },// --todo
  133. { key: 'pavementStructure', value: pavementStructure },// --todo
  134. { key: 'subgradeWidth', value: getValue(Params, ['_SubgradeWidth']) },
  135. { key: 'roadLength', value: getValue(Params, ['_RoadLength']) },// --todo
  136. { key: 'bridgeLength', value: getValue(Params, ['_BridgeLength']) },
  137. { key: 'tunnelLength', value: getValue(Params, ['_TunnelLength']) },// --todo
  138. { key: 'briTunRate', value: getValue(Params, ['_BriTunRate']) },// --todo
  139. { key: 'interchangeNum', value: getValue(Params, ['_InterchangeNum']) },// --todo
  140. { key: 'stubLengths', value: getValue(Params, ['_StubLengths']) },// --todo
  141. { key: 'laneLength', value: getValue(Params, ['_LaneLength']) },// --todo
  142. ]
  143. const items = arrayValue(EprjInfo, ['Items', 'Item']);
  144. for (let i of items) {
  145. let bill = setupBills(i);
  146. // if (bill.name == "暂列金额(不含计日工总额)") {
  147. // bill.fees = [{ fieldName: "common",tenderTotalFee:ProvisionalSums, tenderUnitFee: "0", totalFee: ProvisionalSums, unitFee: "0" }];
  148. // bill.calcBase = ProvisionalSums;
  149. // bill.calcFlag = 1;
  150. // }
  151. tender.bills.push(bill);
  152. }
  153. const BidEvaluationMainMaterial = arrayValue(EprjInfo, ['BidEvaluationMainMaterial']);
  154. for (let b of BidEvaluationMainMaterial) {
  155. tender.bidEvaluationList.push(setUpBidEvaluation(b))
  156. }
  157. return tender;
  158. }
  159. // 获取清单相关的KeyId数据
  160. function getBillKeyIDData(billItem) {
  161. const item = getValue(billItem, ['_KeyId']);
  162. const costComposition = getValue(billItem, ['CostComposition', '_KeyId']);
  163. const formula = getValue(billItem, ['Formula', '_KeyId']);
  164. const costStructure = getValue(billItem, ['CostStructure', '_KeyId']) || getValue(billItem, ['CostComposition', 'Cost', 'CostStructure', '_KeyId']);
  165. return {
  166. item,
  167. costComposition,
  168. formula,
  169. costStructure
  170. }
  171. }
  172. function setupBills(item) {
  173. let bill = {
  174. code: item._ListCode,
  175. name: item._ListName,
  176. unit: item._Unit,
  177. quantity: item._Num,
  178. remark: item._Remarks,
  179. jobContentText: item._Content,
  180. specialProvisional: '',
  181. keyIDData: getBillKeyIDData(item),
  182. children: []
  183. }
  184. if (item._ProvisionalType == '0') bill.specialProvisional = '材料暂估';
  185. if (item._ProvisionalType == '1') bill.specialProvisional = '工程设备';
  186. if (item._ProvisionalType == '2') bill.specialProvisional = '专业工程';
  187. let subItems = arrayValue(item, ['Item']);
  188. if (subItems && subItems.length > 0) {
  189. for (let i of subItems) {
  190. bill.children.push(setupBills(i))
  191. }
  192. }
  193. return bill;
  194. }
  195. function setUpBidEvaluation(b) {
  196. return {
  197. seq: b._Code,
  198. code: b._Number,
  199. name: b._Name,
  200. specs: b._Specification,
  201. unit: b._Unit,
  202. market_price: b._Price,
  203. quantity: b._Quantity,
  204. remark: b._Remark
  205. }
  206. }
  207. return {
  208. name: CprjInfo._CprjName,
  209. info,
  210. tenders,
  211. keyIDData: getConstructionKeyIDData()
  212. };
  213. }
  214. return {
  215. entry
  216. };
  217. })();