|
@@ -19,6 +19,15 @@ const moment = require('moment');
|
|
|
const indexPre = 'id_';
|
|
|
|
|
|
const gatherUtils = {
|
|
|
+ completeGatherData: function (datas, completeDatas) {
|
|
|
+ console.log(completeDatas);
|
|
|
+ for (const data of datas) {
|
|
|
+ for (const cd of completeDatas) {
|
|
|
+ data[cd.prefix + 'id'] = cd.id;
|
|
|
+ data[cd.prefix + 'name'] = cd.name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
gatherStage: function (tender, gatherNode, sourceNode, prefix, helper) {
|
|
|
gatherNode[prefix + 'id'] = tender.id;
|
|
|
gatherNode[prefix + 'name'] = tender.name;
|
|
@@ -130,7 +139,7 @@ module.exports = app => {
|
|
|
rootId: -1
|
|
|
});
|
|
|
this.resultTenderInfo = [];
|
|
|
- this.resultDealpPay = [];
|
|
|
+ this.resultDealPay = [];
|
|
|
this.resultDealBills = [];
|
|
|
}
|
|
|
|
|
@@ -174,8 +183,10 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 台账数据
|
|
|
*/
|
|
|
- async _gatherStageData(index, tender, stage, hasPre) {
|
|
|
+ async _gatherStageData(completeData, tender, stage, hasPre) {
|
|
|
const helper = this.ctx.helper;
|
|
|
+ completeData.id = tender.id;
|
|
|
+ completeData.name = tender.name;
|
|
|
const billsTree = new Ledger.billsTree(this.ctx, {
|
|
|
id: 'ledger_id',
|
|
|
pid: 'ledger_pid',
|
|
@@ -225,18 +236,19 @@ module.exports = app => {
|
|
|
billsTree.loadDatas(billsData);
|
|
|
billsTree.calculateAll();
|
|
|
this.resultTree.loadGatherTree(billsTree, function (gatherNode, sourceNode) {
|
|
|
- gatherUtils.gatherStage(tender, gatherNode, sourceNode, 't_' + index + '_', helper);
|
|
|
+ gatherUtils.gatherStage(tender, gatherNode, sourceNode, completeData.prefix, helper);
|
|
|
});
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- async _gatherMonthData(sTender, index, month, hasPre) {
|
|
|
+ async _gatherMonthData(sTender, completeData, month, hasPre) {
|
|
|
const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
const stages = await this._getValidStages(tender.id);
|
|
|
const stage = this.ctx.helper._.find(stages, {s_time: month});
|
|
|
- await this._gatherStageData(index, tender, stage, hasPre);
|
|
|
+ await this._gatherStageData(completeData, tender, stage, hasPre);
|
|
|
}
|
|
|
|
|
|
- async _gatherZoneData(sTender, index, zone) {
|
|
|
+ async _gatherZoneData(sTender, completeData, zone) {
|
|
|
const helper = this.ctx.helper;
|
|
|
/**
|
|
|
* 汇总并合并 相关数据
|
|
@@ -279,6 +291,8 @@ module.exports = app => {
|
|
|
}
|
|
|
});
|
|
|
const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ completeData.id = tender.id;
|
|
|
+ completeData.name = tender.name;
|
|
|
const billsData = await this.ctx.service.ledger.getData(tender.id);
|
|
|
|
|
|
let billsIndexData = {};
|
|
@@ -313,23 +327,23 @@ module.exports = app => {
|
|
|
billsTree.loadDatas(billsData);
|
|
|
billsTree.calculateAll();
|
|
|
this.resultTree.loadGatherTree(billsTree, function (gatherNode, sourceNode) {
|
|
|
- gatherUtils.gatherZone(gatherNode, sourceNode, 't_' + index + '_', helper);
|
|
|
+ gatherUtils.gatherZone(gatherNode, sourceNode, completeData.prefix, helper);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- async _gatherFinalData(sTender, index, hasPre) {
|
|
|
+ async _gatherFinalData(sTender, completeData, hasPre) {
|
|
|
const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
const stages = await this._getValidStages(tender.id);
|
|
|
- await this._gatherStageData(index, tender, stages[0], hasPre);
|
|
|
+ await this._gatherStageData(completeData, tender, stages[0], hasPre);
|
|
|
}
|
|
|
|
|
|
- async _gatherCheckedFinalData(sTender, index, hasPre) {
|
|
|
+ async _gatherCheckedFinalData(sTender, completeData, hasPre) {
|
|
|
const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
const stages = await this._getCheckedStages(tender.id);
|
|
|
- await this._gatherStageData(index, tender, stages[0], hasPre);
|
|
|
+ await this._gatherStageData(completeData, tender, stages[0], hasPre);
|
|
|
}
|
|
|
|
|
|
- async _gatherLedgerData(sTender, index) {
|
|
|
+ async _gatherLedgerData(sTender, completeData) {
|
|
|
const helper = this.ctx.helper;
|
|
|
const billsTree = new Ledger.billsTree(this.ctx, {
|
|
|
id: 'ledger_id',
|
|
@@ -346,7 +360,7 @@ module.exports = app => {
|
|
|
billsTree.loadDatas(billsData);
|
|
|
billsTree.calculateAll();
|
|
|
this.resultTree.loadGatherTree(billsTree, function (gatherNode, sourceNode) {
|
|
|
- gatherUtils.gatherLedger(tender, gatherNode, sourceNode, 't_' + index + '_', helper);
|
|
|
+ gatherUtils.gatherLedger(tender, gatherNode, sourceNode, completeData.prefix, helper);
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -377,24 +391,29 @@ module.exports = app => {
|
|
|
|
|
|
const gsSetting = JSON.parse(gsDefine.setting);
|
|
|
let commonIndex = 0;
|
|
|
+ const completeDatas = [];
|
|
|
for (const tender of gsCustom.tenders) {
|
|
|
const specialKey = this._checkSpecialTender(tender, gsSetting.special);
|
|
|
if (specialKey === '') {
|
|
|
+ const completeData = {
|
|
|
+ prefix: 't_' + commonIndex + '_',
|
|
|
+ };
|
|
|
+ completeDatas.push(completeData);
|
|
|
switch (gsSetting.type) {
|
|
|
case 'month':
|
|
|
- await this._gatherMonthData(tender, commonIndex, gsCustom.month, gsSetting.hasPre);
|
|
|
+ await this._gatherMonthData(tender, completeData, gsCustom.month, gsSetting.hasPre);
|
|
|
break;
|
|
|
case 'zone':
|
|
|
- await this._gatherZoneData(tender, commonIndex, gsCustom.zone);
|
|
|
+ await this._gatherZoneData(tender, completeData, gsCustom.zone);
|
|
|
break;
|
|
|
case 'final':
|
|
|
- await this._gatherFinalData(tender, commonIndex, gsSetting.hasPre);
|
|
|
+ await this._gatherFinalData(tender, completeData, gsSetting.hasPre);
|
|
|
break;
|
|
|
case 'checked-final':
|
|
|
- await this._gatherCheckedFinalData(tender, commonIndex, gsSetting.hasPre);
|
|
|
+ await this._gatherCheckedFinalData(tender, completeData, gsSetting.hasPre);
|
|
|
break;
|
|
|
case 'ledger':
|
|
|
- await this._gatherLedgerData(tender, commonIndex);
|
|
|
+ await this._gatherLedgerData(tender, completeData);
|
|
|
break;
|
|
|
}
|
|
|
commonIndex++;
|
|
@@ -404,6 +423,7 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
this.resultTree.generateSortNodes();
|
|
|
+ gatherUtils.completeGatherData(this.resultTree.nodes, completeDatas);
|
|
|
return this.resultTree.getDefaultDatas();
|
|
|
}
|
|
|
|
|
@@ -559,9 +579,9 @@ module.exports = app => {
|
|
|
_gatherPayRecord(dealPay, fun) {
|
|
|
let rdp;
|
|
|
if (dealPay.ptype !== payConst.payType.normal) {
|
|
|
- rdp = this.ctx.helper._.find(this.resultDealpPay, {ptype: dealPay.ptype});
|
|
|
+ rdp = this.ctx.helper._.find(this.resultDealPay, {ptype: dealPay.ptype});
|
|
|
} else {
|
|
|
- rdp = this.ctx.helper._.find(this.resultDealpPay, {
|
|
|
+ rdp = this.ctx.helper._.find(this.resultDealPay, {
|
|
|
name: dealPay.name,
|
|
|
minus: dealPay.minus ? true : false,
|
|
|
is_yf: dealPay.is_yf ? true : false,
|
|
@@ -574,7 +594,7 @@ module.exports = app => {
|
|
|
minus: dealPay.minus ? true : false,
|
|
|
is_yf: dealPay.is_yf ? true : false,
|
|
|
};
|
|
|
- this.resultDealpPay.push(rdp);
|
|
|
+ this.resultDealPay.push(rdp);
|
|
|
}
|
|
|
if (fun) fun(rdp, dealPay);
|
|
|
}
|
|
@@ -587,8 +607,10 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async _gatherStagePay(index, tender, stage, hasPre) {
|
|
|
+ async _gatherStagePay(completeData, tender, stage, hasPre) {
|
|
|
if (stage) {
|
|
|
+ completeData.id = tender.id;
|
|
|
+ completeData.name = tender.name;
|
|
|
const helper = this.ctx.helper;
|
|
|
await this.ctx.service.stage.doCheckStage(stage);
|
|
|
|
|
@@ -597,13 +619,12 @@ module.exports = app => {
|
|
|
for (const dp of dealPay) {
|
|
|
dp.end_tp = helper.add(dp.pre_tp, dp.tp);
|
|
|
this._gatherPayRecord(dp, function (gatherData, sourceData) {
|
|
|
- const preFix = 't_' + index + '_';
|
|
|
- gatherData[preFix + 'id'] = tender.id;
|
|
|
- gatherData[preFix + 'name'] = tender.name;
|
|
|
+ gatherData[completeData.prefix + 'id'] = tender.id;
|
|
|
+ gatherData[completeData.prefix + 'name'] = tender.name;
|
|
|
|
|
|
- gatherData[preFix + 'tp'] = helper.add(gatherData[preFix + 'tp'], sourceData.tp);
|
|
|
- gatherData[preFix + 'pre_tp'] = helper.add(gatherData[preFix + 'pre_tp'], sourceData.pre_tp);
|
|
|
- gatherData[preFix + 'end_tp'] = helper.add(gatherData[preFix + 'end_tp'], sourceData.end_tp);
|
|
|
+ gatherData[completeData.prefix + 'tp'] = helper.add(gatherData[completeData.prefix + 'tp'], sourceData.tp);
|
|
|
+ gatherData[completeData.prefix + 'pre_tp'] = helper.add(gatherData[completeData.prefix + 'pre_tp'], sourceData.pre_tp);
|
|
|
+ gatherData[completeData.prefix + 'end_tp'] = helper.add(gatherData[completeData.prefix + 'end_tp'], sourceData.end_tp);
|
|
|
|
|
|
gatherData['s_' + 'tp'] = helper.add(gatherData['s_' + 'tp'], sourceData.tp);
|
|
|
gatherData['s_' + 'pre_tp'] = helper.add(gatherData['s_' + 'pre_tp'], sourceData.pre_tp);
|
|
@@ -613,17 +634,19 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async _gatherMonthStagePay(sTender, index, month, hasPre) {
|
|
|
+ async _gatherMonthStagePay(sTender, completeData, month, hasPre) {
|
|
|
const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
const stages = await this._getValidStages(tender.id);
|
|
|
const stage = this.ctx.helper._.find(stages, {s_time: month});
|
|
|
- await this._gatherStagePay(index, tender, stage, hasPre);
|
|
|
+ await this._gatherStagePay(completeData, tender, stage, hasPre);
|
|
|
}
|
|
|
|
|
|
- async _gatherZoneStagePay(sTender, index, zone) {
|
|
|
+ async _gatherZoneStagePay(sTender, completeData, zone) {
|
|
|
const helper = this.ctx.helper;
|
|
|
|
|
|
const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ completeData.id = tender.id;
|
|
|
+ completeData.name = tender.name;
|
|
|
const stages = await this._getValidStages(tender.id);
|
|
|
|
|
|
const times = zone.split(' - ');
|
|
@@ -641,11 +664,10 @@ module.exports = app => {
|
|
|
for (const dp of dealPay) {
|
|
|
dp.end_tp = helper.add(dp.pre_tp, dp.tp);
|
|
|
this._gatherPayRecord(dp, function (gatherData, sourceData) {
|
|
|
- const preFix = 't_' + index + '_';
|
|
|
- gatherData[preFix + 'id'] = tender.id;
|
|
|
- gatherData[preFix + 'name'] = tender.name;
|
|
|
+ gatherData[completeData.prefix + 'id'] = tender.id;
|
|
|
+ gatherData[completeData.prefix + 'name'] = tender.name;
|
|
|
|
|
|
- gatherData[preFix + 'tp'] = helper.add(gatherData[preFix + 'tp'], sourceData.tp);
|
|
|
+ gatherData[completeData.prefix + 'tp'] = helper.add(gatherData[completeData.prefix + 'tp'], sourceData.tp);
|
|
|
gatherData['s_' + 'tp'] = helper.add(gatherData['s_' + 'tp'], sourceData.tp);
|
|
|
});
|
|
|
}
|
|
@@ -653,16 +675,16 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async _gatherFinalStagePay(sTender, index, hasPre) {
|
|
|
+ async _gatherFinalStagePay(sTender, completeData, hasPre) {
|
|
|
const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
const stages = await this._getValidStages(tender.id);
|
|
|
- await this._gatherStagePay(index, tender, stages[0], hasPre);
|
|
|
+ await this._gatherStagePay(completeData, tender, stages[0], hasPre);
|
|
|
}
|
|
|
|
|
|
- async _gatherCheckedFinalStagePay(sTender, index, hasPre) {
|
|
|
+ async _gatherCheckedFinalStagePay(sTender, completeData, hasPre) {
|
|
|
const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
const stages = await this._getCheckedStages(tender.id);
|
|
|
- await this._gatherStagePay(index, tender, stages[0], hasPre);
|
|
|
+ await this._gatherStagePay(completeData, tender, stages[0], hasPre);
|
|
|
}
|
|
|
|
|
|
async getGatherStagePay(memFieldKeys, gsDefine, gsCustom) {
|
|
@@ -672,28 +694,34 @@ module.exports = app => {
|
|
|
this.resultTenderInfo = [];
|
|
|
const gsSetting = JSON.parse(gsDefine.setting);
|
|
|
let commonIndex = 0;
|
|
|
+ const completeDatas = [];
|
|
|
for (const tender of gsCustom.tenders) {
|
|
|
const specialKey = this._checkSpecialTender(tender, gsSetting.special);
|
|
|
if (specialKey === '') {
|
|
|
+ const completeData = {
|
|
|
+ prefix: 't_' + commonIndex + '_',
|
|
|
+ };
|
|
|
+ completeDatas.push(completeData);
|
|
|
switch (gsSetting.type) {
|
|
|
case 'month':
|
|
|
- await this._gatherMonthStagePay(tender, commonIndex, gsCustom.month, gsSetting.hasPre);
|
|
|
+ await this._gatherMonthStagePay(tender, completeData, gsCustom.month, gsSetting.hasPre);
|
|
|
break;
|
|
|
case 'zone':
|
|
|
- await this._gatherZoneStagePay(tender, commonIndex, gsCustom.zone);
|
|
|
+ await this._gatherZoneStagePay(tender, completeData, gsCustom.zone);
|
|
|
break;
|
|
|
case 'final':
|
|
|
- await this._gatherFinalStagePay(tender, commonIndex, gsSetting.hasPre);
|
|
|
+ await this._gatherFinalStagePay(tender, completeData, gsSetting.hasPre);
|
|
|
break;
|
|
|
case 'checked-final':
|
|
|
- await this._gatherCheckedFinalStagePay(tender, commonIndex, gsSetting.hasPre);
|
|
|
+ await this._gatherCheckedFinalStagePay(tender, completeData, gsSetting.hasPre);
|
|
|
break;
|
|
|
}
|
|
|
commonIndex++;
|
|
|
}
|
|
|
// 合同支付,只有在每一期中有数据,故特殊标段直接不汇总合同支付
|
|
|
}
|
|
|
- return this.resultDealpPay;
|
|
|
+ gatherUtils.completeGatherData(this.resultDealPay, completeDatas);
|
|
|
+ return this.resultDealPay;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -723,15 +751,16 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async _gatherCommonDealBills(sTender, index) {
|
|
|
+ async _gatherCommonDealBills(sTender, completeData) {
|
|
|
const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ completeData.id = tender.id;
|
|
|
+ completeData.name = tender.name;
|
|
|
await this._gatherDealBills(tender, function (gatherData, sourceData) {
|
|
|
- const prefix = 't_' + index + '_';
|
|
|
- gatherData[prefix + 'id'] = tender.id;
|
|
|
- gatherData[prefix + 'name'] = tender.name;
|
|
|
+ gatherData[completeData.prefix + 'id'] = tender.id;
|
|
|
+ gatherData[completeData.prefix + 'name'] = tender.name;
|
|
|
|
|
|
- gatherData[prefix + 'qty'] = sourceData.quantity;
|
|
|
- gatherData[prefix + 'tp'] = sourceData.total_price;
|
|
|
+ gatherData[completeData.prefix + 'qty'] = sourceData.quantity;
|
|
|
+ gatherData[completeData.prefix + 'tp'] = sourceData.total_price;
|
|
|
|
|
|
gatherData['s_' + 'qty'] = sourceData.quantity;
|
|
|
gatherData['s_' + 'tp'] = sourceData.total_price;
|
|
@@ -755,15 +784,21 @@ module.exports = app => {
|
|
|
this.resultTenderInfo = [];
|
|
|
const gsSetting = JSON.parse(gsDefine.setting);
|
|
|
let commonIndex = 0;
|
|
|
+ const completeDatas = [];
|
|
|
for (const tender of gsCustom.tenders) {
|
|
|
const specialKey = this._checkSpecialTender(tender, gsSetting.special);
|
|
|
if (specialKey === '') {
|
|
|
- await this._gatherCommonDealBills(tender, commonIndex);
|
|
|
+ const completeData = {
|
|
|
+ prefix: 't_' + commonIndex + '_',
|
|
|
+ };
|
|
|
+ completeDatas.push(completeData);
|
|
|
+ await this._gatherCommonDealBills(tender, completeData);
|
|
|
commonIndex++;
|
|
|
} else {
|
|
|
await this._gatherSpecialDealBills(tender, specialKey);
|
|
|
}
|
|
|
}
|
|
|
+ gatherUtils.completeGatherData(this.resultDealBills, completeDatas);
|
|
|
return this.resultDealBills;
|
|
|
}
|
|
|
}
|