guangxi_common.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. const {
  40. fixedFlag,
  41. } = window.commonConstants;
  42. let info = [];
  43. let tenders = [];
  44. let CprjInfo = getValue(xmlObj, ['CprjInfo']);
  45. let EprjInfos = arrayValue(CprjInfo, ["EprjInfo"]);
  46. if (EprjInfos.length > 0) {
  47. let MakeInfo = EprjInfos[0].MakeInfo;
  48. let Params = EprjInfos[0].Params;
  49. let BuildType = getValue(Params, ['_BuildType']);
  50. let natureConstruction = "";
  51. if (BuildType == "0") natureConstruction = "新建";
  52. if (BuildType == "1") natureConstruction = "改扩建";
  53. let terrainCategory = "";
  54. let Terrain = getValue(Params, ['_Terrain']);
  55. if (Terrain == "0") terrainCategory = "平原微丘";
  56. if (Terrain == "1") terrainCategory = "山岭重丘";
  57. let RoadGrade = getValue(Params, ['_RoadGrade']);
  58. let roadGrade = "";
  59. if (RoadGradeMap[RoadGrade]) roadGrade = RoadGradeMap[RoadGrade];
  60. info = [
  61. { key: 'constructingUnit', value: getValue(MakeInfo, ['_Manage']) },
  62. { key: 'designUnit', value: getValue(MakeInfo, ['_Designer']) },
  63. { key: 'compileUnit', value: getValue(MakeInfo, ['_Compile']) },
  64. { key: 'compileApprover', value: getValue(MakeInfo, ['_CompileApprover']) },
  65. { key: 'compileCertNo', value: getValue(MakeInfo, ['_CompileCertNo']) },
  66. { key: 'compileDate', value: formateDataString(getValue(MakeInfo, ['_CompileDate'])) },
  67. { key: 'reviewUnit', value: getValue(MakeInfo, ['_Review']) },
  68. { key: 'reviewApprover', value: getValue(MakeInfo, ['_ReviewApprover']) },
  69. { key: 'reviewCertNo', value: getValue(MakeInfo, ['_ReviewCertNo']) },
  70. { key: 'reviewDate', value: formateDataString(getValue(MakeInfo, ['_ReviewDate'])) },
  71. { key: 'startChainages', value: getValue(Params, ['_StartPileNo']) },
  72. { key: 'endChainages', value: getValue(Params, ['_EndPileNo']) },
  73. { key: 'location', value: getValue(Params, ['_PrjArea']) },
  74. { key: 'natureConstruction', value: natureConstruction },
  75. { key: 'terrainCategory', value: terrainCategory },
  76. { key: 'roadGrade', value: roadGrade },
  77. { key: 'makeDate', value: getValue(CprjInfo, ['SystemInfo', '_MakeDate']) },
  78. // { key: 'keyId', value: getValue(CprjInfo, ['SystemInfo','KeyId']) },
  79. ]
  80. for (let t of EprjInfos) {
  81. tenders.push(setupTender(t))
  82. }
  83. }
  84. // 获取需要存的KeyId(建设项目内只有一个的,可以存到一个字段。清单的无法这么处理,清单的keyId数据要存到清单本身)
  85. function getConstructionKeyIDData() {
  86. const cprjInfo = getValue(xmlObj, ['CprjInfo', '_KeyId']);
  87. const systemInfo = getValue(xmlObj, ['CprjInfo', 'SystemInfo', '_KeyId']);
  88. const costBasis = getValue(xmlObj, ['CprjInfo', 'CostBasis', '_KeyId']);
  89. const rate = getValue(xmlObj, ['CprjInfo', 'Rate', '_KeyId']);
  90. const pract = getValue(xmlObj, ['CprjInfo', 'Pract', '_KeyId']);
  91. const eprjInfo = getValue(xmlObj, ['CprjInfo', 'EprjInfo', '_KeyId']);
  92. const indexs = getValue(xmlObj, ['CprjInfo', 'Indexs', '_KeyId']);
  93. const rateParams = getValue(xmlObj, ['CprjInfo', 'Rate', 'RateParams', '_KeyId']);
  94. const rateValues = getValue(xmlObj, ['CprjInfo', 'Rate', 'RateValues', '_KeyId']);
  95. const mps = getValue(xmlObj, ['CprjInfo', 'Pract', 'Mps', '_KeyId']);
  96. const materials = getValue(xmlObj, ['CprjInfo', 'Pract', 'Materials', '_KeyId']);
  97. const mechs = getValue(xmlObj, ['CprjInfo', 'Pract', 'Mechs', '_KeyId']);
  98. const makeInfo = getValue(xmlObj, ['CprjInfo', 'EprjInfo', 'MakeInfo', '_KeyId']);
  99. const params = getValue(xmlObj, ['CprjInfo', 'EprjInfo', 'Params', '_KeyId']);
  100. const items = getValue(xmlObj, ['CprjInfo', 'EprjInfo', 'Items', '_KeyId']);
  101. return {
  102. cprjInfo,
  103. systemInfo,
  104. costBasis,
  105. rate,
  106. pract,
  107. eprjInfo,
  108. indexs,
  109. rateParams,
  110. rateValues,
  111. mps,
  112. materials,
  113. mechs,
  114. makeInfo,
  115. params,
  116. items,
  117. }
  118. }
  119. function setupTender(EprjInfo) {
  120. let tender = {};
  121. let Params = EprjInfo.Params;
  122. // let SummaryOfCost = EprjInfo.SummaryOfCost;
  123. tender.name = EprjInfo._Name;
  124. tender.bills = [];
  125. tender.bidEvaluationList = [];
  126. tender.evaluationList = [];
  127. // let ProvisionalSums = getValue(SummaryOfCost, ['_ProvisionalSums']);
  128. let Structure = getValue(Params, ['_Structure']);
  129. let pavementStructure = "";
  130. if (Structure == "0") pavementStructure = "沥青路面";
  131. if (Structure == "1") pavementStructure = "水泥混凝土路面";
  132. if (Structure == "2") pavementStructure = "其他类型路面";
  133. tender.feature = [
  134. // { key: 'tenderSumLimit', value: getValue(SummaryOfCost, ['_TenderSumLimit'])},//招标控制价
  135. { key: 'designSpeed', value: getValue(Params, ['_DesignSpeed']) },// --todo
  136. { key: 'pavementStructure', value: pavementStructure },// --todo
  137. { key: 'subgradeWidth', value: getValue(Params, ['_SubgradeWidth']) },
  138. { key: 'roadLength', value: getValue(Params, ['_RoadLength']) },// --todo
  139. { key: 'bridgeLength', value: getValue(Params, ['_BridgeLength']) },
  140. { key: 'tunnelLength', value: getValue(Params, ['_TunnelLength']) },// --todo
  141. { key: 'briTunRate', value: getValue(Params, ['_BriTunRate']) },// --todo
  142. { key: 'interchangeNum', value: getValue(Params, ['_InterchangeNum']) },// --todo
  143. { key: 'stubLengths', value: getValue(Params, ['_StubLengths']) },// --todo
  144. { key: 'laneLength', value: getValue(Params, ['_LaneLength']) },// --todo
  145. ]
  146. const items = arrayValue(EprjInfo, ['Items', 'Item']);
  147. for (let i of items) {
  148. let bill = setupBills(i);
  149. // if (bill.name == "暂列金额(不含计日工总额)") {
  150. // bill.fees = [{ fieldName: "common",tenderTotalFee:ProvisionalSums, tenderUnitFee: "0", totalFee: ProvisionalSums, unitFee: "0" }];
  151. // bill.calcBase = ProvisionalSums;
  152. // bill.calcFlag = 1;
  153. // }
  154. tender.bills.push(bill);
  155. }
  156. const BidEvaluationMainMaterial = arrayValue(EprjInfo, ['BidEvaluationMainMaterial']);
  157. for (let b of BidEvaluationMainMaterial) {
  158. tender.bidEvaluationList.push(setUpBidEvaluation(b))
  159. }
  160. return tender;
  161. }
  162. // 获取清单相关的KeyId数据
  163. function getBillKeyIDData(billItem) {
  164. const item = getValue(billItem, ['_KeyId']);
  165. const costComposition = getValue(billItem, ['CostComposition', '_KeyId']);
  166. const formula = getValue(billItem, ['Formula', '_KeyId']);
  167. const costStructure = getValue(billItem, ['CostStructure', '_KeyId']) || getValue(billItem, ['CostComposition', 'Cost', 'CostStructure', '_KeyId']);
  168. return {
  169. item,
  170. costComposition,
  171. formula,
  172. costStructure
  173. }
  174. }
  175. function setupBills(item) {
  176. let bill = {
  177. code: item._ListCode,
  178. name: item._ListName,
  179. unit: item._Unit,
  180. quantity: item._Num,
  181. remark: item._Remarks,
  182. jobContentText: item._Content,
  183. specialProvisional: '',
  184. keyIDData: getBillKeyIDData(item),
  185. children: []
  186. }
  187. if (item._ProvisionalType == '0') bill.specialProvisional = '材料暂估';
  188. if (item._ProvisionalType == '1') bill.specialProvisional = '工程设备';
  189. if (item._ProvisionalType == '2') bill.specialProvisional = '专业工程';
  190. if (item._FormulaCode === 'E') {
  191. // 这是一个暂列金额
  192. bill.titleType = 5; // 这个会在同目录下base.js中的 titleTypeToFlag 对象中判断,5对应的就是:fixedFlag.PROVISIONAL
  193. }
  194. let subItems = arrayValue(item, ['Item']);
  195. if (subItems && subItems.length > 0) {
  196. for (let i of subItems) {
  197. bill.children.push(setupBills(i))
  198. }
  199. }
  200. return bill;
  201. }
  202. function setUpBidEvaluation(b) {
  203. return {
  204. seq: b._Code,
  205. code: b._Number,
  206. name: b._Name,
  207. specs: b._Specification,
  208. unit: b._Unit,
  209. market_price: b._Price,
  210. quantity: b._Quantity,
  211. remark: b._Remark
  212. }
  213. }
  214. return {
  215. name: CprjInfo._CprjName,
  216. info,
  217. tenders,
  218. keyIDData: getConstructionKeyIDData()
  219. };
  220. }
  221. return {
  222. entry
  223. };
  224. })();