|
@@ -1343,6 +1343,55 @@ module.exports = app => {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ async _gatherStagesChange(completeData, tender, stages, preStage, gatherType = 'flow'){
|
|
|
|
+ const result = [];
|
|
|
|
+ const findR = function(source) {
|
|
|
|
+ let r = result.find(x => { return x.cbid === source.cbid});
|
|
|
|
+ if (!r) {
|
|
|
|
+ r = { cid: source.cid, cbid: source.cbid, qty: 0, pre_qty: 0 };
|
|
|
|
+ result.push(r);
|
|
|
|
+ }
|
|
|
|
+ return r;
|
|
|
|
+ };
|
|
|
|
+ const helper = this.ctx.helper;
|
|
|
|
+
|
|
|
|
+ if (preStage) {
|
|
|
|
+ const preStageChange = await this.ctx.service.stageChangeFinal.getEndStageData(stage.tid, preStage.order);
|
|
|
|
+ if (gatherType === 'flow') {
|
|
|
|
+ result.push(...preStageChange);
|
|
|
|
+ } else {
|
|
|
|
+ preStageChange.forEach(sc => {
|
|
|
|
+ const r = findR(sc);
|
|
|
|
+ r.pre_qty = helper.add(r.pre_qty, sc.qty);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (const stage of stages) {
|
|
|
|
+ let curStageChange;
|
|
|
|
+ if (stage.status === auditConst.stage.status.checked) {
|
|
|
|
+ curStageChange = await this.ctx.service.stageChangeFinal.getAllDataByCondition({ where: { tid: stage.tid, sid: stage.id } });
|
|
|
|
+ } else {
|
|
|
|
+ await this.ctx.service.stage.doCheckStage(stage);
|
|
|
|
+ curStageChange = await this.ctx.service.stageChange.getCurStageData(stage.tid, stage.id, stage.curTimes, stage.curOrder);
|
|
|
|
+ }
|
|
|
|
+ if (gatherType === 'flow') {
|
|
|
|
+ result.push(...curStageChange);
|
|
|
|
+ } else {
|
|
|
|
+ curStageChange.forEach(sc => {
|
|
|
|
+ const r = findR(sc);
|
|
|
|
+ r.qty = helper.add(r.qty, sc.qty);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ result.forEach(r => { r.end_qty = helper.add(r.pre_qty, r.qty); });
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ async _gatherCustomZoneStageChange(sTender, completeData, timeType, gatherType) {
|
|
|
|
+ const [stages, preStage, endStage] = await this._getCustomZoneStages(tender, zone, timeType);
|
|
|
|
+ await this._gatherStagesChange(completeData, tender, stages, preStage, gatherType);
|
|
|
|
+ }
|
|
async _gatherStageChange(completeData, tender, stage, hasPre, gatherType = 'flow'){
|
|
async _gatherStageChange(completeData, tender, stage, hasPre, gatherType = 'flow'){
|
|
if (!stage) return [];
|
|
if (!stage) return [];
|
|
const helper = this.ctx.helper;
|
|
const helper = this.ctx.helper;
|
|
@@ -1350,7 +1399,7 @@ module.exports = app => {
|
|
|
|
|
|
const curStageChange = await this.ctx.service.stageChange.getCurStageData(stage.tid, stage.id, stage.curTimes, stage.curOrder);
|
|
const curStageChange = await this.ctx.service.stageChange.getCurStageData(stage.tid, stage.id, stage.curTimes, stage.curOrder);
|
|
const preStageChange = hasPre && stage.preCheckedStage ? await this.ctx.service.stageChangeFinal.getEndStageData(stage.tid, stage.preCheckedStage.order) : [];
|
|
const preStageChange = hasPre && stage.preCheckedStage ? await this.ctx.service.stageChangeFinal.getEndStageData(stage.tid, stage.preCheckedStage.order) : [];
|
|
- if (gatherType === 'flow') return [...curStageChange, ...preStageChange];
|
|
|
|
|
|
+ if (gatherType === 'flow') return [...preStageChange, ...curStageChange];
|
|
|
|
|
|
const result = [];
|
|
const result = [];
|
|
const findR = function(source) {
|
|
const findR = function(source) {
|
|
@@ -1419,6 +1468,9 @@ module.exports = app => {
|
|
case 'stage':
|
|
case 'stage':
|
|
await this._gatherOrderStageChange(tender, completeData, gsCustom.stage, gsSetting.hasPre, gsSetting.gather);
|
|
await this._gatherOrderStageChange(tender, completeData, gsCustom.stage, gsSetting.hasPre, gsSetting.gather);
|
|
break;
|
|
break;
|
|
|
|
+ case 'custom-zone':
|
|
|
|
+ await this._gatherCustomZoneStageChange(tender, completeData, gsCustom.custom_zone, gsSetting.timeType, gsSetting.gather);
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
commonIndex++;
|
|
commonIndex++;
|
|
}
|
|
}
|