|
|
@@ -0,0 +1,138 @@
|
|
|
+/*
|
|
|
+ * @Descripttion: 安徽马鞍山导入接口
|
|
|
+ * @Author: vian
|
|
|
+ * @Date: 2020-09-09 11:51:15
|
|
|
+ */
|
|
|
+
|
|
|
+// INTERFACE_EXPORT =,必须这么写,这样才能在导入时动态加载脚本后,覆盖前端代码
|
|
|
+INTERFACE_IMPORT = (() => {
|
|
|
+ 'use strict';
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
|
|
|
+ * @param {Object} xmlObj - xml经过x2js转换后的xml对象
|
|
|
+ * @return {Object} - 返回的格式需要统一,具体参考函数内返回的内容。返回的内容会经过一系列的统一处理形成可入库的数据。
|
|
|
+ */
|
|
|
+ async function entry(areaKey, xmlObj) {
|
|
|
+ const {
|
|
|
+ UTIL: {
|
|
|
+ getValue,
|
|
|
+ arrayValue,
|
|
|
+ getBool,
|
|
|
+ extractItemsRecur,
|
|
|
+ }
|
|
|
+ } = INTERFACE_EXPORT_BASE;
|
|
|
+ let info = [];
|
|
|
+ let tenders = [];
|
|
|
+ let CprjInfo = getValue(xmlObj, ['CprjInfo']);
|
|
|
+ let EprjInfos = arrayValue(CprjInfo, ["EprjInfo"]);
|
|
|
+ if (EprjInfos.length > 0) {
|
|
|
+ let MakeInfo = EprjInfos[0].MakeInfo;
|
|
|
+ let Params = EprjInfos[0].Params;
|
|
|
+ info = [
|
|
|
+ { key: 'constructingUnits', value: getValue(MakeInfo, ['_Manage']) },
|
|
|
+ { key: 'designUnits', value: getValue(MakeInfo, ['_Designer']) },
|
|
|
+ { key: 'establishUnit', value: getValue(MakeInfo, ['_Compile']) },
|
|
|
+ { key: 'tenderCompiler', value: getValue(MakeInfo, ['_CompileApprover']) },
|
|
|
+ { key: 'authorNo', value: getValue(MakeInfo, ['_CompileCertNo']) },
|
|
|
+ { key: 'establishDate', value: getValue(MakeInfo, ['_CompileDate']) },
|
|
|
+ { key: 'tenderExaminer', value: getValue(MakeInfo, ['_ReviewApprover']) },
|
|
|
+ { key: 'certificateReviewer', value: getValue(MakeInfo, ['_ReviewCertNo']) },
|
|
|
+ { key: 'reviewTime', value: getValue(MakeInfo, ['_ReviewDate']) },
|
|
|
+ { key: 'startAndChainages', value: getValue(Params, ['_StartPileNo'])},
|
|
|
+ { key: 'endChainages', value: getValue(Params, ['_EndPileNo']) },
|
|
|
+ ]
|
|
|
+ for (let t of EprjInfos) {
|
|
|
+ tenders.push(setupTender(t))
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function setupTender(EprjInfo) {
|
|
|
+ let tender = {};
|
|
|
+ let Params = EprjInfo.Params;
|
|
|
+ tender.name = EprjInfo._Name;
|
|
|
+ tender.bills = [];
|
|
|
+ tender.bidEvaluationList = [];
|
|
|
+ tender.evaluationList = [];
|
|
|
+ let terrainCategory = "";
|
|
|
+ if (getValue(Params, ['_Terrain']) == '平原微丘陵区') terrainCategory = 0;
|
|
|
+ if (getValue(Params, ['_Terrain']) == '山岭重丘陵区') terrainCategory = 0;
|
|
|
+ tender.feature = [
|
|
|
+ { key: 'projLocation', value: getValue(Params, ['_PrjArea']) },
|
|
|
+ { key: 'buildType', value: getValue(Params, ['_BuildType']) },// --todo
|
|
|
+ { key: 'terrainCategory', value: terrainCategory },
|
|
|
+ { key: 'establishDate', value: getValue(Params, ['_RoadGrade']) },// --todo
|
|
|
+ { key: 'tenderExaminer', value: getValue(Params, ['_DesignSpeed']) },// --todo
|
|
|
+ { key: 'pavementStructure', value: getValue(Params, ['_Structure']) },// --todo
|
|
|
+ { key: 'subgradeWidth', value: getValue(Params, ['_SubgradeWidth']) },
|
|
|
+ { key: 'routeLength', value: getValue(Params, ['_RoadLength']) },// --todo
|
|
|
+ { key: 'bridgeLength', value: getValue(Params, ['_BridgeLength']) },
|
|
|
+ { key: 'tunnelLength', value: getValue(Params, ['_TunnelLength']) },// --todo
|
|
|
+ { key: 'bridgeTunnelProportion', value: getValue(Params, ['_BriTunRate']) },// --todo
|
|
|
+ { key: 'interchangeNo', value: getValue(Params, ['_InterchangeNum']) },// --todo
|
|
|
+ { key: 'lineContactLineLength', value: getValue(Params, ['_StubLengths']) },// --todo
|
|
|
+ { key: 'auxiliaryContactLineLength', value: getValue(Params, ['_LaneLength']) },// --todo
|
|
|
+ ]
|
|
|
+ const items = arrayValue(EprjInfo, ['Items', 'Item']);
|
|
|
+ for (let i of items) {
|
|
|
+ tender.bills.push(setupBills(i));
|
|
|
+ }
|
|
|
+ const BidEvaluationMainMaterial = arrayValue(EprjInfo, ['BidEvaluationMainMaterial']);
|
|
|
+ for (let b of BidEvaluationMainMaterial) {
|
|
|
+ tender.bidEvaluationList.push(setUpBidEvaluation(b))
|
|
|
+ }
|
|
|
+
|
|
|
+ return tender;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ function setupBills(item) {
|
|
|
+ let bill = {
|
|
|
+ code: item._ListCode,
|
|
|
+ name: item._ListName,
|
|
|
+ unit: item._Unit,
|
|
|
+ quantity: item._Num,
|
|
|
+ remark: item._Remarks,
|
|
|
+ jobContentText: item._Content,
|
|
|
+ specialProvisional: '',
|
|
|
+ children: []
|
|
|
+ }
|
|
|
+ if (item._ProvisionalType == '0') bill.specialProvisional = '材料';
|
|
|
+ if (item._ProvisionalType == '1') bill.specialProvisional = '工程设备';
|
|
|
+ if (item._ProvisionalType == '2') bill.specialProvisional = '工程设备';
|
|
|
+ if (item.Item && item.Item.length > 0) {
|
|
|
+ for (let i of item.Item) {
|
|
|
+ bill.children.push(setupBills(i))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return bill;
|
|
|
+ }
|
|
|
+
|
|
|
+ function setUpBidEvaluation(b) {
|
|
|
+ return {
|
|
|
+ code: b._Code,
|
|
|
+ name: b._Name,
|
|
|
+ specs: b.Specification,
|
|
|
+ unit: b._Unit,
|
|
|
+ market_price: b._Price,
|
|
|
+ quantity: b._Quantity,
|
|
|
+ remark:b._Remark
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return {
|
|
|
+ name: CprjInfo._CprjName,
|
|
|
+ info,
|
|
|
+ tenders,
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ entry
|
|
|
+ };
|
|
|
+
|
|
|
+})();
|