|
@@ -1052,7 +1052,7 @@ module.exports = app => {
|
|
|
if (!gsDefine || !gsDefine.enable) return [];
|
|
|
if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
|
|
|
|
|
|
- this.resultTenderInfo = [];
|
|
|
+ this.resultDealPay = [];
|
|
|
const gsSetting = JSON.parse(gsDefine.setting);
|
|
|
let commonIndex = 0;
|
|
|
const completeDatas = [];
|
|
@@ -1250,7 +1250,6 @@ module.exports = app => {
|
|
|
return [[], []];
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
async getGatherChange(memFieldKeys, gsDefine, gsCustom) {
|
|
|
if (!gsDefine || !gsDefine.enable) return [];
|
|
|
if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
|
|
@@ -1264,6 +1263,345 @@ module.exports = app => {
|
|
|
}
|
|
|
return result
|
|
|
}
|
|
|
+
|
|
|
+ async _gatherStageJgcl(tender, stage) {
|
|
|
+ const data = await this.ctx.service.stageJgcl.getStageData(stage);
|
|
|
+ const preData = stage.order > 1 ? await this.ctx.service.stageJgcl.getPreStageData(stage.order) : 0;
|
|
|
+ for (const d of data) {
|
|
|
+ const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
|
|
|
+ if (pd) {
|
|
|
+ d.pre_arrive_qty = pd.arrive_qty;
|
|
|
+ d.pre_arrive_tp = pd.arrive_tp;
|
|
|
+ d.pre_deduct_qty = pd.deduct_qty;
|
|
|
+ d.pre_deduct_tp = pd.deduct_tp;
|
|
|
+ }
|
|
|
+ d.end_arrive_qty = this.ctx.helper.add(d.pre_arrive_qty, d.arrive_qty);
|
|
|
+ d.end_arrive_tp = this.ctx.helper.add(d.pre_arrive_tp, d.arrive_tp);
|
|
|
+ d.end_deduct_qty = this.ctx.helper.add(d.pre_deduct_qty, d.deduct_qty);
|
|
|
+ d.end_deduct_tp = this.ctx.helper.add(d.pre_deduct_tp, d.deduct_tp);
|
|
|
+ }
|
|
|
+ this.resultStageJgcl.push(...data);
|
|
|
+ }
|
|
|
+ async _gatherMonthStageJgcl(sTender, month) {
|
|
|
+ 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._gatherStageJgcl(tender, stage);
|
|
|
+ }
|
|
|
+ async _gatherOrderStageJgcl(sTender, order) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getValidStages(tender.id);
|
|
|
+ const stage = this.ctx.helper._.find(stages, {order: order});
|
|
|
+ await this._gatherStageJgcl(tender, stage);
|
|
|
+ }
|
|
|
+ async _gatherFinalStageJgcl(sTender) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getValidStages(tender.id);
|
|
|
+ await this._gatherStageJgcl(tender, stages[0]);
|
|
|
+ }
|
|
|
+ async _gatherCheckedFinalStageJgcl(sTender) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getCheckedStages(tender.id);
|
|
|
+ await this._gatherStageJgcl(tender, stages[0]);
|
|
|
+ }
|
|
|
+ async getGatherStageJgcl(memFieldKeys, gsDefine, gsCustom) {
|
|
|
+ if (!gsDefine || !gsDefine.enable) return [];
|
|
|
+ if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
|
|
|
+
|
|
|
+ this.resultStageJgcl = [];
|
|
|
+ const gsSetting = JSON.parse(gsDefine.setting);
|
|
|
+ for (const tender of gsCustom.tenders) {
|
|
|
+ switch (gsSetting.type) {
|
|
|
+ case 'month':
|
|
|
+ await this._gatherMonthStageJgcl(tender, gsCustom.month);
|
|
|
+ break;
|
|
|
+ case 'final':
|
|
|
+ await this._gatherFinalStageJgcl(tender);
|
|
|
+ break;
|
|
|
+ case 'checked-final':
|
|
|
+ await this._gatherCheckedFinalStageJgcl(tender);
|
|
|
+ break;
|
|
|
+ case 'stage':
|
|
|
+ await this._gatherOrderStageJgcl(tender, gsCustom.stage);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.resultStageJgcl;
|
|
|
+ }
|
|
|
+
|
|
|
+ async _gatherStageBonus(tender, stage) {
|
|
|
+ const data = await this.ctx.service.stageBonus.getEndStageData(stage.order);
|
|
|
+ for (const d of data) {
|
|
|
+ const names = this.ctx.helper._.map(d.proof_file, function (x) {
|
|
|
+ return x.filename + x.fileext;
|
|
|
+ });
|
|
|
+ d.proof = names.join('\n');
|
|
|
+ }
|
|
|
+ this.resultStageBonus.push(...data);
|
|
|
+ }
|
|
|
+ async _gatherMonthStageBonus(sTender, month) {
|
|
|
+ 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._gatherStageBonus(tender, stage);
|
|
|
+ }
|
|
|
+ async _gatherOrderStageBonus(sTender, order) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getValidStages(tender.id);
|
|
|
+ const stage = this.ctx.helper._.find(stages, {order: order});
|
|
|
+ await this._gatherStageBonus(tender, stage);
|
|
|
+ }
|
|
|
+ async _gatherFinalStageBonus(sTender) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getValidStages(tender.id);
|
|
|
+ await this._gatherStageBonus(tender, stages[0]);
|
|
|
+ }
|
|
|
+ async _gatherCheckedFinalStageBonus(sTender) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getCheckedStages(tender.id);
|
|
|
+ await this._gatherStageBonus(tender, stages[0]);
|
|
|
+ }
|
|
|
+ async getGatherStageBonus(memFieldKeys, gsDefine, gsCustom) {
|
|
|
+ if (!gsDefine || !gsDefine.enable) return [];
|
|
|
+ if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
|
|
|
+
|
|
|
+ this.resultStageBonus = [];
|
|
|
+ const gsSetting = JSON.parse(gsDefine.setting);
|
|
|
+ for (const tender of gsCustom.tenders) {
|
|
|
+ switch (gsSetting.type) {
|
|
|
+ case 'month':
|
|
|
+ await this._gatherMonthStageBonus(tender, gsCustom.month);
|
|
|
+ break;
|
|
|
+ case 'final':
|
|
|
+ await this._gatherFinalStageBonus(tender);
|
|
|
+ break;
|
|
|
+ case 'checked-final':
|
|
|
+ await this._gatherCheckedFinalStageBonus(tender);
|
|
|
+ break;
|
|
|
+ case 'stage':
|
|
|
+ await this._gatherOrderStageBonus(tender, gsCustom.stage);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return this.resultStageBonus;
|
|
|
+ }
|
|
|
+
|
|
|
+ async _gatherStageOther(tender, stage) {
|
|
|
+ const data = await this.ctx.service.stageOther.getStageData(stage);
|
|
|
+ const preData = stage.order > 1 ? await this.ctx.service.stageOther.getPreStageData(stage.order) : [];
|
|
|
+ for (const d of data) {
|
|
|
+ const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
|
|
|
+ if (pd) {
|
|
|
+ d.pre_tp = pd.tp;
|
|
|
+ }
|
|
|
+ d.end_tp = this.ctx.helper.add(d.pre_tp, d.tp);
|
|
|
+ }
|
|
|
+ this.resultStageOther.push(...data);
|
|
|
+ }
|
|
|
+ async _gatherMonthStageOther(sTender, month) {
|
|
|
+ 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._gatherStageOther(tender, stage);
|
|
|
+ }
|
|
|
+ async _gatherOrderStageOther(sTender, order) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getValidStages(tender.id);
|
|
|
+ const stage = this.ctx.helper._.find(stages, {order: order});
|
|
|
+ await this._gatherStageOther(tender, stage);
|
|
|
+ }
|
|
|
+ async _gatherFinalStageOther(sTender) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getValidStages(tender.id);
|
|
|
+ await this._gatherStageOther(tender, stages[0]);
|
|
|
+ }
|
|
|
+ async _gatherCheckedFinalStageOther(sTender) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getCheckedStages(tender.id);
|
|
|
+ await this._gatherStageOther(tender, stages[0]);
|
|
|
+ }
|
|
|
+ async getGatherStageOther(memFieldKeys, gsDefine, gsCustom) {
|
|
|
+ if (!gsDefine || !gsDefine.enable) return [];
|
|
|
+ if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
|
|
|
+
|
|
|
+ this.resultStageOther = [];
|
|
|
+ const gsSetting = JSON.parse(gsDefine.setting);
|
|
|
+ for (const tender of gsCustom.tenders) {
|
|
|
+ switch (gsSetting.type) {
|
|
|
+ case 'month':
|
|
|
+ await this._gatherMonthStageOther(tender, gsCustom.month);
|
|
|
+ break;
|
|
|
+ case 'final':
|
|
|
+ await this._gatherFinalStageOther(tender);
|
|
|
+ break;
|
|
|
+ case 'checked-final':
|
|
|
+ await this._gatherCheckedFinalStageOther(tender);
|
|
|
+ break;
|
|
|
+ case 'stage':
|
|
|
+ await this._gatherOrderStageOther(tender, gsCustom.stage);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return this.resultStageOther;
|
|
|
+ }
|
|
|
+
|
|
|
+ async _gatherStageSafeProd(tender, stage) {
|
|
|
+ const data = await this.ctx.service.stageSafeProd.getStageData(stage);
|
|
|
+ const preData = stage.order > 1 ? await this.ctx.service.stageSafeProd.getPreStageData(stage.order) : [];
|
|
|
+ for (const d of data) {
|
|
|
+ const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
|
|
|
+ if (pd) {
|
|
|
+ d.pre_qty = pd.qty;
|
|
|
+ d.pre_tp = pd.tp;
|
|
|
+ }
|
|
|
+ d.end_qty = this.ctx.helper.add(d.pre_qty, d.qty);
|
|
|
+ d.end_tp = this.ctx.helper.add(d.pre_tp, d.tp);
|
|
|
+ }
|
|
|
+ const helper = this.ctx.helper;
|
|
|
+ for (const d of data) {
|
|
|
+ let gd = this.resultStageSafeProd.find(x => {
|
|
|
+ return x.name === d.name && x.unit === d.unit && helper.checkNumEqual(x.unit_price, d.unit_price);
|
|
|
+ });
|
|
|
+ if (!gd) {
|
|
|
+ gd = { name: d.name, unit: d.unit, unit_price: d.unit_price };
|
|
|
+ this.resultStageSafeProd.push(d);
|
|
|
+ }
|
|
|
+ gd.s_quantity = helper.add(gd.s_quantity, d.quantity);
|
|
|
+ gd.s_total_price = helper.add(gd.s_total_price, d.total_price);
|
|
|
+ gd.s_qty = helper.add(gd.s_qty, d.qty);
|
|
|
+ gd.s_tp = helper.add(gd.s_tp, d.tp);
|
|
|
+ gd.s_pre_qty = helper.add(gd.s_pre_qty, d.pre_qty);
|
|
|
+ gd.s_pre_tp = helper.add(gd.s_pre_tp, d.pre_tp);
|
|
|
+ gd.s_end_qty = helper.add(gd.s_end_qty, d.end_qty);
|
|
|
+ gd.s_end_tp = helper.add(gd.s_end_tp, d.end_tp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ async _gatherMonthStageSafeProd(sTender, month) {
|
|
|
+ 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._gatherStageSafeProd(tender, stage);
|
|
|
+ }
|
|
|
+ async _gatherOrderStageSafeProd(sTender, order) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getValidStages(tender.id);
|
|
|
+ const stage = this.ctx.helper._.find(stages, {order: order});
|
|
|
+ await this._gatherStageSafeProd(tender, stage);
|
|
|
+ }
|
|
|
+ async _gatherFinalStageSafeProd(sTender) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getValidStages(tender.id);
|
|
|
+ await this._gatherStageSafeProd(tender, stages[0]);
|
|
|
+ }
|
|
|
+ async _gatherCheckedFinalStageSafeProd(sTender) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getCheckedStages(tender.id);
|
|
|
+ await this._gatherStageSafeProd(tender, stages[0]);
|
|
|
+ }
|
|
|
+ async getGatherStageSafeProd(memFieldKeys, gsDefine, gsCustom) {
|
|
|
+ if (!gsDefine || !gsDefine.enable) return [];
|
|
|
+ if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
|
|
|
+
|
|
|
+ this.resultStageSafeProd = [];
|
|
|
+ const gsSetting = JSON.parse(gsDefine.setting);
|
|
|
+ for (const tender of gsCustom.tenders) {
|
|
|
+ switch (gsSetting.type) {
|
|
|
+ case 'month':
|
|
|
+ await this._gatherMonthStageSafeProd(tender, gsCustom.month);
|
|
|
+ break;
|
|
|
+ case 'final':
|
|
|
+ await this._gatherFinalStageSafeProd(tender);
|
|
|
+ break;
|
|
|
+ case 'checked-final':
|
|
|
+ await this._gatherCheckedFinalStageSafeProd(tender);
|
|
|
+ break;
|
|
|
+ case 'stage':
|
|
|
+ await this._gatherOrderStageSafeProd(tender, gsCustom.stage);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.resultStageSafeProd;
|
|
|
+ }
|
|
|
+
|
|
|
+ async _gatherStageTempLand(tender, stage) {
|
|
|
+ const data = await this.ctx.service.stageTempLand.getStageData(stage);
|
|
|
+ const preData = stage.order > 1 ? await this.ctx.service.stageTempLand.getPreStageData(stage.order) : [];
|
|
|
+ for (const d of data) {
|
|
|
+ const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
|
|
|
+ if (pd) {
|
|
|
+ d.pre_qty = pd.qty;
|
|
|
+ d.pre_tp = pd.tp;
|
|
|
+ }
|
|
|
+ d.end_qty = this.ctx.helper.add(d.pre_qty, d.qty);
|
|
|
+ d.end_tp = this.ctx.helper.add(d.pre_tp, d.tp);
|
|
|
+ }
|
|
|
+
|
|
|
+ const helper = this.ctx.helper;
|
|
|
+ for (const d of data) {
|
|
|
+ let gd = this.resultStageTempLand.find(x => {
|
|
|
+ return x.name === d.name && x.unit === d.unit && helper.checkNumEqual(x.unit_price, d.unit_price);
|
|
|
+ });
|
|
|
+ if (!gd) {
|
|
|
+ gd = { name: d.name, unit: d.unit, unit_price: d.unit_price };
|
|
|
+ this.resultStageTempLand.push(d);
|
|
|
+ }
|
|
|
+ gd.s_qty = helper.add(gd.s_qty, d.qty);
|
|
|
+ gd.s_tp = helper.add(gd.s_tp, d.tp);
|
|
|
+ gd.s_pre_qty = helper.add(gd.s_pre_qty, d.pre_qty);
|
|
|
+ gd.s_pre_tp = helper.add(gd.s_pre_tp, d.pre_tp);
|
|
|
+ gd.s_end_qty = helper.add(gd.s_end_qty, d.end_qty);
|
|
|
+ gd.s_end_tp = helper.add(gd.s_end_tp, d.end_tp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ async _gatherMonthStageTempLand(sTender, month) {
|
|
|
+ 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._gatherStageTempLand(tender, stage);
|
|
|
+ }
|
|
|
+ async _gatherOrderStageTempLand(sTender, order) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getValidStages(tender.id);
|
|
|
+ const stage = this.ctx.helper._.find(stages, {order: order});
|
|
|
+ await this._gatherStageTempLand(tender, stage);
|
|
|
+ }
|
|
|
+ async _gatherFinalStageTempLand(sTender) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getValidStages(tender.id);
|
|
|
+ await this._gatherStageTempLand(tender, stages[0]);
|
|
|
+ }
|
|
|
+ async _gatherCheckedFinalStageTempLand(sTender) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const stages = await this._getCheckedStages(tender.id);
|
|
|
+ await this._gatherStageTempLand(tender, stages[0]);
|
|
|
+ }
|
|
|
+ async getGatherStageTempLand(memFieldKeys, gsDefine, gsCustom) {
|
|
|
+ if (!gsDefine || !gsDefine.enable) return [];
|
|
|
+ if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
|
|
|
+
|
|
|
+ this.resultStageTempLand = [];
|
|
|
+ const gsSetting = JSON.parse(gsDefine.setting);
|
|
|
+ for (const tender of gsCustom.tenders) {
|
|
|
+ switch (gsSetting.type) {
|
|
|
+ case 'month':
|
|
|
+ await this._gatherMonthStageTempLand(tender, gsCustom.month);
|
|
|
+ break;
|
|
|
+ case 'final':
|
|
|
+ await this._gatherFinalStageTempLand(tender);
|
|
|
+ break;
|
|
|
+ case 'checked-final':
|
|
|
+ await this._gatherCheckedFinalStageTempLand(tender);
|
|
|
+ break;
|
|
|
+ case 'stage':
|
|
|
+ await this._gatherOrderStageTempLand(tender, gsCustom.stage);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.resultStageTempLand;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return RptGatherMemory;
|