|
|
@@ -9,6 +9,7 @@
|
|
|
};
|
|
|
//先导出后require可以解决循环引用问题
|
|
|
module.exports={
|
|
|
+ getExtendData,
|
|
|
getBasicInfo,
|
|
|
getImportTemplateData,
|
|
|
getProjectByGranularity,
|
|
|
@@ -54,7 +55,7 @@ module.exports={
|
|
|
importInterface,
|
|
|
copyConstructionProject,
|
|
|
isTenderOverrun,
|
|
|
- getWelcomeInfo:getWelcomeInfo
|
|
|
+ getWelcomeInfo:getWelcomeInfo,
|
|
|
};
|
|
|
|
|
|
|
|
|
@@ -138,6 +139,29 @@ let path = require("path");
|
|
|
let request = require("request");
|
|
|
const systemSettingModel = mongoose.model('system_setting');
|
|
|
|
|
|
+function getExtendData(property, compilation) {
|
|
|
+ let ext = {};
|
|
|
+ if (property) {
|
|
|
+ let region = property.region;
|
|
|
+ let taxType = property.taxType;
|
|
|
+ if (compilation.priceProperties && compilation.priceProperties.length > 0) {//如果是具有多单价的编办,取单价对应的字段
|
|
|
+ let priceProperty = _.find(compilation.priceProperties, { region: region, taxModel: parseInt(taxType) });
|
|
|
+ if (priceProperty) {
|
|
|
+ ext['priceField'] = priceProperty.price.dataCode;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (compilation.consumeAmtProperties && compilation.consumeAmtProperties.length > 0) {
|
|
|
+ let consumeAmt = _.find(compilation.consumeAmtProperties, { region: region, taxModel: parseInt(taxType) });
|
|
|
+ if (consumeAmt) {
|
|
|
+ ext['quantityField'] = consumeAmt.consumeAmt.dataCode;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return _.isEmpty(ext) ? null : ext;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
let qiniu_config = {
|
|
|
"AccessKey": "_gR1ed4vi1vT2G2YITGSf4_H0fJu_nRS9Tzk3T4z",
|
|
|
"SecretKey": "ty4zd0FHqgEDaiVzSLC8DfHlai99aS7bspLkw6s6",
|
|
|
@@ -1819,14 +1843,14 @@ async function handleImportInterface(key, session) {
|
|
|
throw '无有效数据';
|
|
|
}
|
|
|
const userID = session.sessionUser.id;
|
|
|
- const compilationID = session.sessionCompilation._id;
|
|
|
+ const compilation = session.sessionCompilation;
|
|
|
const importData = JSON.parse(srcData);
|
|
|
const tenderCount = importData.tenders.length;
|
|
|
if (await isTenderOverrun(tenderCount, session)) {
|
|
|
throw '您创建的项目个数超限,请联系我们的客服人员,或者导出建设项目保存到本地备份,删除云上数据。';
|
|
|
}
|
|
|
const overWriteUrl = session.sessionCompilation.overWriteUrl;
|
|
|
- const projectID = await importInterfaceProject(importData, userID, compilationID, overWriteUrl);
|
|
|
+ const projectID = await importInterfaceProject(importData, userID, compilation, overWriteUrl);
|
|
|
doc.projectID = projectID;
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
@@ -1841,7 +1865,8 @@ async function handleImportInterface(key, session) {
|
|
|
/*
|
|
|
* 接口导入 项目详细数据都导入完成了,再生成项目数据(项目管理界面数据)
|
|
|
* */
|
|
|
-async function importInterfaceProject(importObj, userID, compilationID, overWriteUrl) {
|
|
|
+async function importInterfaceProject(importObj, userID, compilation, overWriteUrl) {
|
|
|
+ const compilationID = compilation._id;
|
|
|
const toInsertProjects = [importObj]; //待新增项目数据
|
|
|
let defaultCalcMode;
|
|
|
if (overWriteUrl) {
|
|
|
@@ -1855,7 +1880,7 @@ async function importInterfaceProject(importObj, userID, compilationID, overWrit
|
|
|
for (const curTender of importObj.tenders) {
|
|
|
await setupProject(curTender);
|
|
|
// 插入单位工程的详细数据
|
|
|
- await importTenderDetail(curTender);
|
|
|
+ await importTenderDetail(curTender, compilation);
|
|
|
delete curTender.bills;
|
|
|
toInsertProjects.push(curTender);
|
|
|
}
|
|
|
@@ -1916,7 +1941,7 @@ async function importInterfaceProject(importObj, userID, compilationID, overWrit
|
|
|
}
|
|
|
|
|
|
//插入单位工程内部详细数据
|
|
|
-async function importTenderDetail(tenderData) {
|
|
|
+async function importTenderDetail(tenderData, compilation) {
|
|
|
// 单价文件
|
|
|
const upFile = {
|
|
|
id: tenderData.property.unitPriceFile.id,
|
|
|
@@ -1926,6 +1951,8 @@ async function importTenderDetail(tenderData) {
|
|
|
root_project_id: tenderData.property.rootProjectID
|
|
|
};
|
|
|
await unitPriceFileModel.create(upFile);
|
|
|
+ // 新增单价文件的同时,在项目工料机和空白的单价文件中先插入机械组成物等信息
|
|
|
+ await glj_facade.addMixRatioForNew(tenderData.ID, upFile.id, tenderData.property.engineering_id, getExtendData(tenderData.property, compilation))
|
|
|
// 费率文件
|
|
|
const feeRateFileID = await feeRate_facade.newFeeRateFile(tenderData.userID, tenderData);
|
|
|
tenderData.property.feeFile = feeRateFileID ? feeRateFileID : -1;
|