| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- /*
- * @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对象
- * @param {Object} template - 单位工程的一些模板数据,例如清单模板、标准费率数据等。
- */
- async function entry(areaKey, xmlObj, template) {
- const {
- UTIL: {
- getValue,
- arrayValue,
- }
- } = INTERFACE_EXPORT_BASE;
- const subArea = areaKey.split('@')[1];
- // 提取基本信息,xml中提取出来的基本信息,最终会与模板基本信息进行合并处理。(接口内不需要处理合并)
- function setupInformation(projectSrc) {
- // key:基本信息模板中的key,作为合并时的匹配字段
- const info = [
- { key: 'projNum', value: getValue(projectSrc, ['_Xmbh']) },
- { key: 'projType', value: getValue(projectSrc, ['_Bzlx']) },
- { key: 'startAndChainages', value: getValue(projectSrc, ['_Xmqzzh']) },
- { key: 'constructingUnits', value: getValue(projectSrc, ['_Jsdw']) },
- { key: 'taxMode', value: getValue(projectSrc, ['_Jsfs']) },
- { key: 'tendereeName', value: getValue(projectSrc, ['ZhaoBiaoXx', '_Zbr']) },
- { key: 'costConsultant', value: getValue(projectSrc, ['ZhaoBiaoXx', '_Zxr']) },
- { key: 'tenderAuthorizer', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZbrDb']) },
- { key: 'consultantAuthorizer', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZxrDb']) },
- { key: 'tenderCompiler', value: getValue(projectSrc, ['ZhaoBiaoXx', '_Bzr']) },
- { key: 'tenderExaminer', value: getValue(projectSrc, ['ZhaoBiaoXx', '_Fhr']) },
- { key: 'compilationTime', value: getValue(projectSrc, ['ZhaoBiaoXx', '_BzTime']) },
- { key: 'reviewTime', value: getValue(projectSrc, ['ZhaoBiaoXx', '_FhTime']) },
- ];
- if (['淮北', '铜陵'].includes(subArea)) {
- const extraInfo = [
- { key: 'tendereeTaxpayerIdentificationNo', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZbrNssbh']) },
- { key: 'costConsultantTaxpayerIdentificationNo', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZxrNssbh']) },
- { key: 'tenderAuthorizerIDNo', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZbrDbSfzh']) },
- { key: 'consultantAuthorizerTaxpayerIdentificationNo', value: getValue(projectSrc, ['ZhaoBiaoXx', '_ZxrDbSfzh']) },
- ];
- info.push(...extraInfo);
- }
- return info;
- }
- // 提取工程特征信息,xml中提取出来的工程特征,最终会与模板工程特征进行合并处理。(接口内不需要处理合并)
- function setupFeature(projectSrc, tenderSrc) {
- return [
- { key: 'singleProjNo', value: getValue(projectSrc, ['Dxgcxx', '_Dxgcbh']) },
- { key: 'singleProjName', value: getValue(projectSrc, ['Dxgcxx', '_Dxgcmc']) },
- { key: 'unitProjNo', value: getValue(tenderSrc, ['_Dwgcbh']) },
- ];
- }
- // 提取单位工程数据
- function setupTender(projectSrc, tenderSrc) {
- return {
- name: getValue(tenderSrc, ['_Dwgcmc']),
- feature: setupFeature(projectSrc, tenderSrc),
- }
- }
- // 从xml对象提取需要的数据
- function setupProject(projectSrc) {
- const tenders = arrayValue(projectSrc, ['Dxgcxx', 'Dwgcxx'])
- .map(tenderSrc => setupTender(projectSrc, tenderSrc))
- return {
- name: getValue(projectSrc, ['_Xmmc']),
- info: setupInformation(projectSrc),
- tenders,
- };
- }
- const test = setupProject(getValue(xmlObj, ['JingJiBiao']));
- console.log(test);
- return test;
- }
- return {
- entry
- };
- })();
|