|
@@ -223,6 +223,35 @@ module.exports = app => {
|
|
|
await transaction.updateRows(this.tableName, updateDatas);
|
|
|
}
|
|
|
|
|
|
+ async updateHistory4CheckAgain(stage, transaction) {
|
|
|
+ const datas = await this.getStageData(stage);
|
|
|
+ if (datas.length === 0) return;
|
|
|
+
|
|
|
+ const updateDatas = [];
|
|
|
+ const times = this.ctx.stage.curTimes, order = this.ctx.stage.curOrder + 1;
|
|
|
+ for (const d of datas) {
|
|
|
+ const history = d.shistory && d.shistory !== '' ? JSON.parse(d.shistory) : [];
|
|
|
+ const his = history.find(function (x) {
|
|
|
+ return x.stimes && x.stimes === times
|
|
|
+ && x.sorder && x.sorder === order;
|
|
|
+ });
|
|
|
+ if (his) {
|
|
|
+ his.arrive_qty = d.arrive_qty;
|
|
|
+ his.arrive_tp = d.arrive_tp;
|
|
|
+ his.deduct_qty = d.deduct_qty;
|
|
|
+ his.deduct_tp = d.deduct_tp;
|
|
|
+ } else {
|
|
|
+ history.push({
|
|
|
+ stimes: times, sorder: order,
|
|
|
+ arrive_qty: d.arrive_qty, arrive_tp: d.arrive_tp,
|
|
|
+ deduct_qty: d.deduct_qty, deduct_tp: d.deduct_tp
|
|
|
+ });
|
|
|
+ }
|
|
|
+ updateDatas.push({ id: d.id, shistory: JSON.stringify(history) });
|
|
|
+ }
|
|
|
+ await transaction.updateRows(this.tableName, updateDatas);
|
|
|
+ }
|
|
|
+
|
|
|
async addInitialStageData(stage, preStage, transaction) {
|
|
|
if (!stage || !preStage) {
|
|
|
throw '标段数据有误';
|