|
@@ -67,37 +67,38 @@ const gatherUtils = {
|
|
|
gatherNode[prefix + "c_dgn_qty1"] = helper.add(gatherNode[prefix + "c_dgn_qty1"], sourceNode.c_dgn_qty1);
|
|
|
gatherNode[prefix + "c_dgn_qty2"] = helper.add(gatherNode[prefix + "c_dgn_qty2"], sourceNode.c_dgn_qty2);
|
|
|
|
|
|
- gatherNode['s_' + "qty"] = helper.add(gatherNode['s_' + "qty"], sourceNode.quantity);
|
|
|
- gatherNode['s_' + "tp"] = helper.add(gatherNode['s_' + "tp"], sourceNode.total_price);
|
|
|
-
|
|
|
- gatherNode['s_' + "dgn_qty1"] = helper.add(gatherNode['s_' + "dgn_qty1"], sourceNode.dgn_qty1);
|
|
|
- gatherNode['s_' + "dgn_qty2"] = helper.add(gatherNode['s_' + "dgn_qty2"], sourceNode.dgn_qty2);
|
|
|
-
|
|
|
- gatherNode['s_' + "contract_qty"] = helper.add(gatherNode['s_' + "contract_qty"], sourceNode.contract_qty);
|
|
|
- gatherNode['s_' + "contract_tp"] = helper.add(gatherNode['s_' + "contract_tp"], sourceNode.contract_tp);
|
|
|
- gatherNode['s_' + "qc_qty"] = helper.add(gatherNode['s_' + "qc_qty"], sourceNode.qc_qty);
|
|
|
- gatherNode['s_' + "qc_tp"] = helper.add(gatherNode['s_' + "qc_tp"], sourceNode.qc_tp);
|
|
|
- gatherNode['s_' + "gather_qty"] = helper.add(gatherNode['s_' + "gather_qty"], sourceNode.gather_qty);
|
|
|
- gatherNode['s_' + "gather_tp"] = helper.add(gatherNode['s_' + "gather_tp"], sourceNode.gather_tp);
|
|
|
-
|
|
|
- gatherNode['s_' + "pre_contract_qty"] = helper.add(gatherNode['s_' + "pre_contract_qty"], sourceNode.pre_contract_qty);
|
|
|
- gatherNode['s_' + "pre_contract_tp"] = helper.add(gatherNode['s_' + "pre_contract_tp"], sourceNode.pre_contract_tp);
|
|
|
- gatherNode['s_' + "pre_qc_qty"] = helper.add(gatherNode['s_' + "pre_qc_qty"], sourceNode.pre_qc_qty);
|
|
|
- gatherNode['s_' + "pre_qc_tp"] = helper.add(gatherNode['s_' + "pre_qc_tp"], sourceNode.pre_qc_tp);
|
|
|
- gatherNode['s_' + "pre_gather_qty"] = helper.add(gatherNode['s_' + "pre_gather_qty"], sourceNode.pre_gather_qty);
|
|
|
- gatherNode['s_' + "pre_gather_tp"] = helper.add(gatherNode['s_' + "pre_gather_tp"], sourceNode.pre_gather_tp);
|
|
|
-
|
|
|
- gatherNode['s_' + "end_contract_qty"] = helper.add(gatherNode['s_' + "end_contract_qty"], sourceNode.end_contract_qty);
|
|
|
- gatherNode['s_' + "end_contract_tp"] = helper.add(gatherNode['s_' + "end_contract_tp"], sourceNode.end_contract_tp);
|
|
|
- gatherNode['s_' + "end_qc_qty"] = helper.add(gatherNode['s_' + "end_qc_qty"], sourceNode.end_qc_qty);
|
|
|
- gatherNode['s_' + "end_qc_tp"] = helper.add(gatherNode['s_' + "end_qc_tp"], sourceNode.end_qc_tp);
|
|
|
- gatherNode['s_' + "end_gather_qty"] = helper.add(gatherNode['s_' + "end_gather_qty"], sourceNode.end_gather_qty);
|
|
|
- gatherNode['s_' + "end_gather_tp"] = helper.add(gatherNode['s_' + "end_gather_tp"], sourceNode.end_gather_tp);
|
|
|
-
|
|
|
- gatherNode['s_' + "deal_dgn_qty1"] = helper.add(gatherNode['s_' + "deal_dgn_qty1"], sourceNode.deal_dgn_qty1);
|
|
|
- gatherNode['s_' + "deal_dgn_qty2"] = helper.add(gatherNode['s_' + "deal_dgn_qty2"], sourceNode.deal_dgn_qty2);
|
|
|
- gatherNode['s_' + "c_dgn_qty1"] = helper.add(gatherNode['s_' + "c_dgn_qty1"], sourceNode.c_dgn_qty1);
|
|
|
- gatherNode['s_' + "c_dgn_qty2"] = helper.add(gatherNode['s_' + "c_dgn_qty2"], sourceNode.c_dgn_qty2);
|
|
|
+ gatherNode.s_qty = helper.add(gatherNode.s_qty, sourceNode.quantity);
|
|
|
+ gatherNode.s_tp = helper.add(gatherNode.s_tp, sourceNode.total_price);
|
|
|
+
|
|
|
+ gatherNode.s_dgn_qty1 = helper.add(gatherNode.s_dgn_qty1, sourceNode.dgn_qty1);
|
|
|
+ gatherNode.s_dgn_qty2 = helper.add(gatherNode.s_dgn_qty2, sourceNode.dgn_qty2);
|
|
|
+
|
|
|
+ gatherNode.s_contract_qty = helper.add(gatherNode.s_contract_qty, sourceNode.contract_qty);
|
|
|
+ gatherNode.s_contract_tp = helper.add(gatherNode.s_contract_tp, sourceNode.contract_tp);
|
|
|
+ gatherNode.s_qc_qty = helper.add(gatherNode.s_qc_qty, sourceNode.qc_qty);
|
|
|
+ gatherNode.s_qc_tp = helper.add(gatherNode.s_qc_tp, sourceNode.qc_tp);
|
|
|
+ gatherNode.s_gather_qty = helper.add(gatherNode.s_gather_qty, sourceNode.gather_qty);
|
|
|
+ gatherNode.s_gather_tp = helper.add(gatherNode.s_gather_tp, sourceNode.gather_tp);
|
|
|
+ gatherNode.s_pc_tp = helper.add(gatherNode.s_pc_tp, sourceNode.pc_tp);
|
|
|
+
|
|
|
+ gatherNode.s_pre_contract_qty = helper.add(gatherNode.s_pre_contract_qty, sourceNode.pre_contract_qty);
|
|
|
+ gatherNode.s_pre_contract_tp = helper.add(gatherNode.s_pre_contract_tp, sourceNode.pre_contract_tp);
|
|
|
+ gatherNode.s_pre_qc_qty = helper.add(gatherNode.s_pre_qc_qty, sourceNode.pre_qc_qty);
|
|
|
+ gatherNode.s_pre_qc_tp = helper.add(gatherNode.s_pre_qc_tp, sourceNode.pre_qc_tp);
|
|
|
+ gatherNode.s_pre_gather_qty = helper.add(gatherNode.s_pre_gather_qty, sourceNode.pre_gather_qty);
|
|
|
+ gatherNode.s_pre_gather_tp = helper.add(gatherNode.s_pre_gather_tp, sourceNode.pre_gather_tp);
|
|
|
+
|
|
|
+ gatherNode.s_end_contract_qty = helper.add(gatherNode.s_end_contract_qty, sourceNode.end_contract_qty);
|
|
|
+ gatherNode.s_end_contract_tp = helper.add(gatherNode.s_end_contract_tp, sourceNode.end_contract_tp);
|
|
|
+ gatherNode.s_end_qc_qty = helper.add(gatherNode.s_end_qc_qty, sourceNode.end_qc_qty);
|
|
|
+ gatherNode.s_end_qc_tp = helper.add(gatherNode.s_end_qc_tp, sourceNode.end_qc_tp);
|
|
|
+ gatherNode.s_end_gather_qty = helper.add(gatherNode.s_end_gather_qty, sourceNode.end_gather_qty);
|
|
|
+ gatherNode.s_end_gather_tp = helper.add(gatherNode.s_end_gather_tp, sourceNode.end_gather_tp);
|
|
|
+
|
|
|
+ gatherNode.s_deal_dgn_qty1 = helper.add(gatherNode.s_deal_dgn_qty1, sourceNode.deal_dgn_qty1);
|
|
|
+ gatherNode.s_deal_dgn_qty2 = helper.add(gatherNode.s_deal_dgn_qty2, sourceNode.deal_dgn_qty2);
|
|
|
+ gatherNode.s_c_dgn_qty1 = helper.add(gatherNode.s_c_dgn_qty1, sourceNode.c_dgn_qty1);
|
|
|
+ gatherNode.s_c_dgn_qty2 = helper.add(gatherNode.s_c_dgn_qty2, sourceNode.c_dgn_qty2);
|
|
|
},
|
|
|
gatherZone: function (tender, gatherNode, sourceNode, prefix, helper) {
|
|
|
gatherNode[prefix + 'id'] = tender.id;
|
|
@@ -123,15 +124,16 @@ const gatherUtils = {
|
|
|
gatherNode[prefix + "c_dgn_qty1"] = helper.add(gatherNode[prefix + "c_dgn_qty1"], sourceNode.c_dgn_qty1);
|
|
|
gatherNode[prefix + "c_dgn_qty2"] = helper.add(gatherNode[prefix + "c_dgn_qty2"], sourceNode.c_dgn_qty2);
|
|
|
|
|
|
- gatherNode['s_' + "qty"] = helper.add(gatherNode['s_' + "qty"], sourceNode.quantity);
|
|
|
- gatherNode['s_' + "tp"] = helper.add(gatherNode['s_' + "tp"], sourceNode.total_price);
|
|
|
+ gatherNode.s_qty = helper.add(gatherNode.s_qty, sourceNode.quantity);
|
|
|
+ gatherNode.s_tp = helper.add(gatherNode.s_tp, sourceNode.total_price);
|
|
|
|
|
|
- gatherNode['s_' + "contract_qty"] = helper.add(gatherNode['s_' + "contract_qty"], sourceNode.contract_qty);
|
|
|
- gatherNode['s_' + "contract_tp"] = helper.add(gatherNode['s_' + "contract_tp"], sourceNode.contract_tp);
|
|
|
- gatherNode['s_' + "qc_qty"] = helper.add(gatherNode['s_' + "qc_qty"], sourceNode.qc_qty);
|
|
|
- gatherNode['s_' + "qc_tp"] = helper.add(gatherNode['s_' + "qc_tp"], sourceNode.qc_tp);
|
|
|
- gatherNode['s_' + "gather_qty"] = helper.add(gatherNode['s_' + "gather_qty"], sourceNode.gather_qty);
|
|
|
- gatherNode['s_' + "gather_tp"] = helper.add(gatherNode['s_' + "gather_tp"], sourceNode.gather_tp);
|
|
|
+ gatherNode.s_contract_qty = helper.add(gatherNode.s_contract_qty, sourceNode.contract_qty);
|
|
|
+ gatherNode.s_contract_tp = helper.add(gatherNode.s_contract_tp, sourceNode.contract_tp);
|
|
|
+ gatherNode.s_qc_qty = helper.add(gatherNode.s_qc_qty, sourceNode.qc_qty);
|
|
|
+ gatherNode.s_qc_tp = helper.add(gatherNode.s_qc_tp, sourceNode.qc_tp);
|
|
|
+ gatherNode.s_gather_qty = helper.add(gatherNode.s_gather_qty, sourceNode.gather_qty);
|
|
|
+ gatherNode.s_gather_tp = helper.add(gatherNode.s_gather_tp, sourceNode.gather_tp);
|
|
|
+ gatherNode.s_pc_tp = helper.add(gatherNode.s_pc_tp, sourceNode.pc_tp);
|
|
|
},
|
|
|
gatherLedger: function (tender, gatherNode, sourceNode, prefix, helper) {
|
|
|
gatherNode[prefix + 'id'] = tender.id;
|
|
@@ -144,8 +146,8 @@ const gatherUtils = {
|
|
|
gatherNode[prefix + "dgn_qty1"] = helper.add(gatherNode[prefix + "dgn_qty1"], sourceNode.dgn_qty1);
|
|
|
gatherNode[prefix + "dgn_qty2"] = helper.add(gatherNode[prefix + "dgn_qty2"], sourceNode.dgn_qty2);
|
|
|
|
|
|
- gatherNode['s_' + "qty"] = helper.add(gatherNode['s_' + "qty"], sourceNode.quantity);
|
|
|
- gatherNode['s_' + "tp"] = helper.add(gatherNode['s_' + "tp"], sourceNode.total_price);
|
|
|
+ gatherNode.s_qty = helper.add(gatherNode.s_qty, sourceNode.quantity);
|
|
|
+ gatherNode.s_tp = helper.add(gatherNode.s_tp, sourceNode.total_price);
|
|
|
},
|
|
|
gatherSpecial: function (gatherNode, sourceNode, prefix, helper) {
|
|
|
gatherNode[prefix + "qty"] = helper.add(gatherNode[prefix + "qty"], sourceNode.quantity);
|
|
@@ -154,6 +156,68 @@ const gatherUtils = {
|
|
|
gatherNode[prefix + "dgn_qty1"] = helper.add(gatherNode[prefix + "dgn_qty1"], sourceNode.dgn_qty1);
|
|
|
gatherNode[prefix + "dgn_qty2"] = helper.add(gatherNode[prefix + "dgn_qty2"], sourceNode.dgn_qty2);
|
|
|
},
|
|
|
+ gatherStagePos: function (tender, gatherNode, sourceNode, prefix, helper) {
|
|
|
+ gatherNode[prefix + 'id'] = tender.id;
|
|
|
+ gatherNode[prefix + 'name'] = tender.name;
|
|
|
+ gatherNode[prefix + 'category'] = tender.category;
|
|
|
+
|
|
|
+ gatherNode[prefix + "qty"] = helper.add(gatherNode[prefix + "qty"], sourceNode.quantity);
|
|
|
+
|
|
|
+ gatherNode[prefix + "contract_qty"] = helper.add(gatherNode[prefix + "contract_qty"], sourceNode.contract_qty);
|
|
|
+ gatherNode[prefix + "qc_qty"] = helper.add(gatherNode[prefix + "qc_qty"], sourceNode.qc_qty);
|
|
|
+ gatherNode[prefix + "gather_qty"] = helper.add(gatherNode[prefix + "gather_qty"], sourceNode.gather_qty);
|
|
|
+
|
|
|
+ gatherNode[prefix + "pre_contract_qty"] = helper.add(gatherNode[prefix + "pre_contract_qty"], sourceNode.pre_contract_qty);
|
|
|
+ gatherNode[prefix + "pre_qc_qty"] = helper.add(gatherNode[prefix + "pre_qc_qty"], sourceNode.pre_qc_qty);
|
|
|
+ gatherNode[prefix + "pre_gather_qty"] = helper.add(gatherNode[prefix + "pre_gather_qty"], sourceNode.pre_gather_qty);
|
|
|
+
|
|
|
+ gatherNode[prefix + "end_contract_qty"] = helper.add(gatherNode[prefix + "end_contract_qty"], sourceNode.end_contract_qty);
|
|
|
+ gatherNode[prefix + "end_qc_qty"] = helper.add(gatherNode[prefix + "end_qc_qty"], sourceNode.end_qc_qty);
|
|
|
+ gatherNode[prefix + "end_gather_qty"] = helper.add(gatherNode[prefix + "end_gather_qty"], sourceNode.end_gather_qty);
|
|
|
+
|
|
|
+ gatherNode.s_qty = helper.add(gatherNode.s_qty, sourceNode.quantity);
|
|
|
+
|
|
|
+ gatherNode.s_contract_qty = helper.add(gatherNode.s_contract_qty, sourceNode.contract_qty);
|
|
|
+ gatherNode.s_qc_qty = helper.add(gatherNode.s_qc_qty, sourceNode.qc_qty);
|
|
|
+ gatherNode.s_gather_qty = helper.add(gatherNode.s_gather_qty, sourceNode.gather_qty);
|
|
|
+
|
|
|
+ gatherNode.s_pre_contract_qty = helper.add(gatherNode.s_pre_contract_qty, sourceNode.pre_contract_qty);
|
|
|
+ gatherNode.s_pre_qc_qty = helper.add(gatherNode.s_pre_qc_qty, sourceNode.pre_qc_qty);
|
|
|
+ gatherNode.s_pre_gather_qty = helper.add(gatherNode.s_pre_gather_qty, sourceNode.pre_gather_qty);
|
|
|
+
|
|
|
+ gatherNode.s_end_contract_qty = helper.add(gatherNode.s_end_contract_qty, sourceNode.end_contract_qty);
|
|
|
+ gatherNode.s_end_qc_qty = helper.add(gatherNode.s_end_qc_qty, sourceNode.end_qc_qty);
|
|
|
+ gatherNode.s_end_gather_qty = helper.add(gatherNode.s_end_gather_qty, sourceNode.end_gather_qty);
|
|
|
+ },
|
|
|
+ gatherZonePos: function (tender, gatherNode, sourceNode, prefix, helper) {
|
|
|
+ gatherNode[prefix + 'id'] = tender.id;
|
|
|
+ gatherNode[prefix + 'name'] = tender.name;
|
|
|
+ gatherNode[prefix + 'category'] = tender.category;
|
|
|
+
|
|
|
+ gatherNode[prefix + "qty"] = helper.add(gatherNode[prefix + "qty"], sourceNode.quantity);
|
|
|
+
|
|
|
+ gatherNode[prefix + "contract_qty"] = helper.add(gatherNode[prefix + "contract_qty"], sourceNode.contract_qty);
|
|
|
+ gatherNode[prefix + "qc_qty"] = helper.add(gatherNode[prefix + "qc_qty"], sourceNode.qc_qty);
|
|
|
+ gatherNode[prefix + "gather_qty"] = helper.add(gatherNode[prefix + "gather_qty"], sourceNode.gather_qty);
|
|
|
+
|
|
|
+ gatherNode.s_qty = helper.add(gatherNode.s_qty, sourceNode.quantity);
|
|
|
+
|
|
|
+ gatherNode.s_contract_qty = helper.add(gatherNode.s_contract_qty, sourceNode.contract_qty);
|
|
|
+ gatherNode.s_qc_qty = helper.add(gatherNode.s_qc_qty, sourceNode.qc_qty);
|
|
|
+ gatherNode.s_gather_qty = helper.add(gatherNode.s_gather_qty, sourceNode.gather_qty);
|
|
|
+ },
|
|
|
+ gatherPos: function (tender, gatherNode, sourceNode, prefix, helper) {
|
|
|
+ gatherNode[prefix + 'id'] = tender.id;
|
|
|
+ gatherNode[prefix + 'name'] = tender.name;
|
|
|
+ gatherNode[prefix + 'category'] = tender.category;
|
|
|
+
|
|
|
+ gatherNode[prefix + "qty"] = helper.add(gatherNode[prefix + "qty"], sourceNode.quantity);
|
|
|
+
|
|
|
+ gatherNode.s_qty = helper.add(gatherNode.s_qty, sourceNode.quantity);
|
|
|
+ },
|
|
|
+ gatherSpecialPos: function (gatherNode, sourceNode, prefix, helper) {
|
|
|
+ gatherNode[prefix + "qty"] = helper.add(gatherNode[prefix + "qty"], sourceNode.quantity);
|
|
|
+ },
|
|
|
};
|
|
|
|
|
|
module.exports = app => {
|
|
@@ -167,22 +231,17 @@ module.exports = app => {
|
|
|
*/
|
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
- this.resultTree = new Ledger.gatherTree(ctx, {
|
|
|
- id: 'id',
|
|
|
- pid: 'pid',
|
|
|
- order: 'order',
|
|
|
- level: 'level',
|
|
|
- rootId: -1
|
|
|
- });
|
|
|
+ this.resultTree = null;
|
|
|
+ this.resultPos = null;
|
|
|
this.resultTenderInfo = [];
|
|
|
this.resultDealPay = [];
|
|
|
this.resultDealBills = [];
|
|
|
}
|
|
|
|
|
|
- async _getValidStages(tenderId) {
|
|
|
+ async _getValidStages(tenderId, sort = 'desc') {
|
|
|
const stages = await this.db.select(this.ctx.service.stage.tableName, {
|
|
|
where: { tid: tenderId },
|
|
|
- orders: [['order', 'desc']],
|
|
|
+ orders: [['order', sort]],
|
|
|
});
|
|
|
if (stages.length !== 0) {
|
|
|
const lastStage = stages[0];
|
|
@@ -222,36 +281,97 @@ module.exports = app => {
|
|
|
const beginTime = moment(times[0], 'YYYY-MM');
|
|
|
const endTime = moment(times[1], 'YYYY-MM');
|
|
|
|
|
|
- const stages = await this._getValidStages(tender.id), validStages = [];
|
|
|
+ const stages = await this._getValidStages(tender.id, 'asc'), validStages = [];
|
|
|
+ let preStage, endStage;
|
|
|
for (const stage of stages) {
|
|
|
const sTime = moment(stage.s_time, 'YYYY-MM');
|
|
|
if (sTime.isBetween(beginTime, endTime, null, '[]')) {
|
|
|
validStages.push(stage);
|
|
|
+ } else if (sTime.isBefore(beginTime)) {
|
|
|
+ if (!preStage || moment(preStage.s_time, 'YYYY-MM').isBefore(sTime)) preStage = stage;
|
|
|
+ } else if (sTime.isAfter(endTime)) {
|
|
|
+ if (!endStage || moment(endStage.s_time, 'YYYY-MM').isAfter(sTime)) endStage = stage;
|
|
|
}
|
|
|
}
|
|
|
- return validStages;
|
|
|
+ return [validStages, preStage, endStage];
|
|
|
}
|
|
|
-
|
|
|
async _getOrderZoneStages (tender, zone) {
|
|
|
let [iBegin, iEnd] = zone.split(':');
|
|
|
iBegin = this.ctx.helper._.toInteger(iBegin) || 0;
|
|
|
iEnd = this.ctx.helper._.toInteger(iEnd) || 0;
|
|
|
- const stages = await this._getValidStages(tender.id), validStages = [];
|
|
|
+ const stages = await this._getValidStages(tender.id, 'asc'), validStages = [];
|
|
|
+ let preStage, endStage;
|
|
|
for (const stage of stages) {
|
|
|
- if (stage.order < iBegin || stage.order > iEnd) continue;
|
|
|
+ if (stage.order < iBegin) {
|
|
|
+ if (!preStage || preStage.order < stage.order) preStage = stage;
|
|
|
+ } else if (stage.order > iEnd) {
|
|
|
+ if (!endStage || endStage.order > stage.order) endStage = stage;
|
|
|
+ } else {
|
|
|
+ validStages.push(stage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return [validStages, preStage, endStage];
|
|
|
+ }
|
|
|
+ async _getCheckedZoneStages(tender, zone) {
|
|
|
+ const times = zone.split(' - ');
|
|
|
+ if (times.length !== 2) throw '选择的汇总周期无效';
|
|
|
+ const beginTime = moment(times[0], 'YYYY-MM-DD');
|
|
|
+ const endTime = moment(times[1], 'YYYY-MM-DD');
|
|
|
+
|
|
|
+ const stages = await this._getValidStages(tender.id, 'asc'), validStages = [];
|
|
|
+ let preStage, endStage;
|
|
|
+ for (const stage of stages) {
|
|
|
+ if (stage.status !== auditConst.stage.status.checked) continue;
|
|
|
+
|
|
|
+ const finalAudit = await this.ctx.service.stageAudit.getLastestAuditor(stage.id, stage.times, stage.status);
|
|
|
+ if (!finalAudit) continue;
|
|
|
|
|
|
- validStages.push(stage);
|
|
|
+ const sTime = moment(moment(finalAudit.end_time).format('YYYY-MM-DD'), 'YYYY-MM-DD');
|
|
|
+ stage.checked_day = sTime;
|
|
|
+ stage.checked_time = moment(finalAudit.end_time);
|
|
|
+ if (sTime.isBetween(beginTime, endTime, null, '[]')) {
|
|
|
+ validStages.push(stage);
|
|
|
+ } else if (sTime.isBefore(beginTime)) {
|
|
|
+ if (!preStage || preStage.checked_time.isBefore(stage.checked_time)) preStage = stage;
|
|
|
+ } else if (sTime.isAfter(endTime)) {
|
|
|
+ if (!endStage || endStage.checked_time.isAfter(stage.checked_time)) endStage = stage;
|
|
|
+ }
|
|
|
}
|
|
|
- return validStages;
|
|
|
+ return [validStages, preStage, endStage];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 台账数据
|
|
|
*/
|
|
|
- async _gatherStageData(completeData, tender, stage, hasPre) {
|
|
|
+
|
|
|
+ async _gatherStagesData(completeData, tender, stages, preStage) {
|
|
|
+ const resultPos = this.resultPos;
|
|
|
const helper = this.ctx.helper;
|
|
|
completeData.id = tender.id;
|
|
|
completeData.name = tender.name;
|
|
|
+ /**
|
|
|
+ * 汇总并合并 相关数据
|
|
|
+ * @param {Array} index - 主数据
|
|
|
+ * @param {Array[]}rela - 相关数据 {data, fields, prefix, relaId}
|
|
|
+ */
|
|
|
+ const sumAssignRelaData = function (index, rela) {
|
|
|
+ const loadFields = function (datas, fields, prefix, relaId) {
|
|
|
+ for (const d of datas) {
|
|
|
+ const key = indexPre + d[relaId];
|
|
|
+ const m = index[key];
|
|
|
+ if (m) {
|
|
|
+ for (const f of fields) {
|
|
|
+ if (d[f] !== undefined) {
|
|
|
+ m[prefix + f] = helper.add(m[prefix + f], d[f]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ for (const r of rela) {
|
|
|
+ loadFields(r.data, r.fields, r.prefix, r.relaId);
|
|
|
+ }
|
|
|
+ };
|
|
|
const billsTree = new Ledger.billsTree(this.ctx, {
|
|
|
id: 'ledger_id',
|
|
|
pid: 'ledger_pid',
|
|
@@ -260,7 +380,7 @@ module.exports = app => {
|
|
|
rootId: -1,
|
|
|
keys: ['id', 'tender_id', 'ledger_id'],
|
|
|
stageId: 'id',
|
|
|
- calcFields: ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'contract_pc_tp', 'qc_pc_tp', 'pc_tp', 'gather_tp', 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp'],
|
|
|
+ calcFields: ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp', 'contract_pc_tp', 'qc_pc_tp', 'pc_tp', 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp'],
|
|
|
calc: function (node) {
|
|
|
if (node.children && node.children.length === 0) {
|
|
|
node.pre_gather_qty = helper.add(node.pre_contract_qty, node.pre_qc_qty);
|
|
@@ -270,67 +390,101 @@ module.exports = app => {
|
|
|
node.end_gather_qty = helper.add(node.pre_gather_qty, node.gather_qty);
|
|
|
}
|
|
|
node.pre_gather_tp = helper.add(node.pre_contract_tp, node.pre_qc_tp);
|
|
|
- node.gather_tp = helper.sum([node.contract_tp, node.qc_tp, node.pc_tp]);
|
|
|
- node.end_contract_tp = helper.sum([node.pre_contract_tp, node.contract_tp, node.contract_pc_tp]);
|
|
|
- node.end_qc_tp = helper.sum([node.pre_qc_tp, node.qc_tp, node.qc_pc_tp]);
|
|
|
+ node.gather_tp = helper.add(node.contract_tp, node.qc_tp);
|
|
|
+ node.end_contract_tp = helper.add(node.pre_contract_tp, node.contract_tp);
|
|
|
+ node.end_qc_tp = helper.add(node.pre_qc_tp, node.qc_tp);
|
|
|
node.end_gather_tp = helper.add(node.pre_gather_tp, node.gather_tp);
|
|
|
}
|
|
|
});
|
|
|
const billsData = await this.ctx.service.ledger.getData(tender.id);
|
|
|
-
|
|
|
const dgnData = await this.ctx.service.stageBillsDgn.getDgnData(tender.id);
|
|
|
for (const d of dgnData) {
|
|
|
const l = this.ctx.helper._.find(billsData, {id: d.id});
|
|
|
this.ctx.helper._.assignIn(l, d);
|
|
|
}
|
|
|
+ const pos = new Ledger.pos({
|
|
|
+ id: 'id', ledgerId: 'lid',
|
|
|
+ calc: function (node) {
|
|
|
+ node.pre_gather_qty = helper.add(node.pre_contract_qty, node.pre_qc_qty);
|
|
|
+ node.gather_tp = helper.sum([node.contract_tp, node.qc_tp, node.pc_tp]);
|
|
|
+ node.end_contract_tp = helper.sum([node.pre_contract_tp, node.contract_tp, node.contract_pc_tp]);
|
|
|
+ node.end_qc_tp = helper.sum([node.pre_qc_tp, node.qc_tp, node.qc_pc_tp]);
|
|
|
+ node.end_gather_qty = helper.add(node.pre_gather_qty, node.gather_qty);
|
|
|
+ },
|
|
|
+ });
|
|
|
+ const posData = await this.ctx.service.pos.getAllDataByCondition({ where: { tid: tender.id} });
|
|
|
+ let billsIndexData = {};
|
|
|
+ for (const bd of billsData) {
|
|
|
+ billsIndexData[indexPre + bd.id] = bd;
|
|
|
+ }
|
|
|
+ let posIndexData = {};
|
|
|
+ for (const p of posData) {
|
|
|
+ posIndexData[indexPre + p.id] = p;
|
|
|
+ }
|
|
|
|
|
|
- if (stage) {
|
|
|
+ if (preStage) {
|
|
|
+ await this.ctx.service.stage.doCheckStage(preStage);
|
|
|
+ const endStage = await this.ctx.service.stageBillsFinal.getFinalData(tender, preStage.order);
|
|
|
+ sumAssignRelaData(billsIndexData, [
|
|
|
+ { data: endStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'pre_', relaId: 'lid' },
|
|
|
+ ]);
|
|
|
+ const endStagePos = await this.ctx.service.stagePosFinal.getFinalData(tender, preStage.order);
|
|
|
+ sumAssignRelaData(posIndexData, [
|
|
|
+ {data: endStagePos, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'lid'},
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (const stage of stages) {
|
|
|
await this.ctx.service.stage.doCheckStage(stage);
|
|
|
const curStage = stage.readOnly
|
|
|
? await this.ctx.service.stageBills.getAuditorStageData2(tender.id, stage.id, stage.curTimes, stage.curOrder)
|
|
|
: await this.ctx.service.stageBills.getLastestStageData2(tender.id, stage.id);
|
|
|
- const preStage = hasPre && stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(tender, stage.order - 1) : [];
|
|
|
const bpcStage = await this.ctx.service.stageBillsPc.getAllDataByCondition({ where: { sid: stage.id } });
|
|
|
- this.ctx.helper.assignRelaData(billsData, [
|
|
|
- { data: curStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid' },
|
|
|
- { data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'pre_', relaId: 'lid' },
|
|
|
+ sumAssignRelaData(billsIndexData, [
|
|
|
+ {data: curStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid'},
|
|
|
{ data: bpcStage, fields: ['contract_pc_tp', 'qc_pc_tp', 'pc_tp'], prefix: '', relaId: 'lid' },
|
|
|
]);
|
|
|
+ const curStagePos = stage.readOnly
|
|
|
+ ? await this.ctx.service.stagePos.getAuditorStageData2(tender.id, stage.id, stage.curTimes, stage.curOrder)
|
|
|
+ : await this.ctx.service.stagePos.getLastestStageData2(tender.id, stage.id);
|
|
|
+ sumAssignRelaData(posIndexData, [
|
|
|
+ {data: curStagePos, fields: ['contract_qty', 'qc_qty'], prefix: '', relaId: 'pid'},
|
|
|
+ ]);
|
|
|
}
|
|
|
+
|
|
|
billsTree.loadDatas(billsData);
|
|
|
billsTree.calculateAll();
|
|
|
+ pos.loadDatas(posData);
|
|
|
+ pos.calculateAll();
|
|
|
this.resultTree.loadGatherTree(billsTree, function (gatherNode, sourceNode) {
|
|
|
gatherUtils.gatherStage(tender, gatherNode, sourceNode, completeData.prefix, helper);
|
|
|
+ }, function (gatherNode, sourceNode) {
|
|
|
+ const posRange = pos.getLedgerPos(sourceNode.id);
|
|
|
+ if (!posRange || posRange.length === 0) return;
|
|
|
+ resultPos.loadGatherPos(gatherNode.id, posRange, (gatherPos, sourcePos) => {
|
|
|
+ gatherUtils.gatherStagePos(tender, gatherPos, sourcePos, completeData.prefix, helper);
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
+ async _gatherZoneData(tender, completeData, zone) {
|
|
|
+ const [stages, preStage, endStage] = await this._getTimeZoneStages(tender, zone);
|
|
|
+ await this._gatherStagesData(completeData, tender, stages, preStage);
|
|
|
+ }
|
|
|
+ async _gatherIndexZoneData(tender, completeData, stageZone) {
|
|
|
+ const [stages, preStage, endStage] = await this._getOrderZoneStages(tender, stageZone);
|
|
|
+ await this._gatherStagesData(completeData, tender, stages, preStage);
|
|
|
+ }
|
|
|
+ async _gatherCheckedZoneData(tender, completeData, zone) {
|
|
|
+ const [stages, preStage, endStage] = await this._getCheckedZoneStages(tender, zone);
|
|
|
+ await this._gatherStagesData(completeData, tender, stages, preStage);
|
|
|
+ }
|
|
|
|
|
|
- async _gatherStagesData(completeData, tender, stages) {
|
|
|
+ async _gatherStageData(completeData, tender, stage, hasPre) {
|
|
|
const helper = this.ctx.helper;
|
|
|
+ const resultPos = this.resultPos;
|
|
|
completeData.id = tender.id;
|
|
|
completeData.name = tender.name;
|
|
|
- /**
|
|
|
- * 汇总并合并 相关数据
|
|
|
- * @param {Array} index - 主数据
|
|
|
- * @param {Array[]}rela - 相关数据 {data, fields, prefix, relaId}
|
|
|
- */
|
|
|
- const sumAssignRelaData = function (index, rela) {
|
|
|
- const loadFields = function (datas, fields, prefix, relaId) {
|
|
|
- for (const d of datas) {
|
|
|
- const key = indexPre + d[relaId];
|
|
|
- const m = index[key];
|
|
|
- if (m) {
|
|
|
- for (const f of fields) {
|
|
|
- if (d[f] !== undefined) {
|
|
|
- m[prefix + f] = helper.add(m[prefix + f], d[f]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- for (const r of rela) {
|
|
|
- loadFields(r.data, r.fields, r.prefix, r.relaId);
|
|
|
- }
|
|
|
- };
|
|
|
+
|
|
|
const billsTree = new Ledger.billsTree(this.ctx, {
|
|
|
id: 'ledger_id',
|
|
|
pid: 'ledger_pid',
|
|
@@ -339,80 +493,96 @@ module.exports = app => {
|
|
|
rootId: -1,
|
|
|
keys: ['id', 'tender_id', 'ledger_id'],
|
|
|
stageId: 'id',
|
|
|
- calcFields: ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp'],
|
|
|
+ calcFields: ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'contract_pc_tp', 'qc_pc_tp', 'pc_tp', 'gather_tp', 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp'],
|
|
|
calc: function (node) {
|
|
|
if (node.children && node.children.length === 0) {
|
|
|
+ node.pre_gather_qty = helper.add(node.pre_contract_qty, node.pre_qc_qty);
|
|
|
node.gather_qty = helper.add(node.contract_qty, node.qc_qty);
|
|
|
+ node.end_contract_qty = helper.add(node.pre_contract_qty, node.contract_qty);
|
|
|
+ node.end_qc_qty = helper.add(node.pre_qc_qty, node.qc_qty);
|
|
|
+ node.end_gather_qty = helper.add(node.pre_gather_qty, node.gather_qty);
|
|
|
}
|
|
|
- node.gather_tp = helper.add(node.contract_tp, node.qc_tp);
|
|
|
+ node.pre_gather_tp = helper.add(node.pre_contract_tp, node.pre_qc_tp);
|
|
|
+ node.gather_tp = helper.sum([node.contract_tp, node.qc_tp, node.pc_tp]);
|
|
|
+ node.end_contract_tp = helper.sum([node.pre_contract_tp, node.contract_tp, node.contract_pc_tp]);
|
|
|
+ node.end_qc_tp = helper.sum([node.pre_qc_tp, node.qc_tp, node.qc_pc_tp]);
|
|
|
+ node.end_gather_tp = helper.add(node.pre_gather_tp, node.gather_tp);
|
|
|
}
|
|
|
});
|
|
|
const billsData = await this.ctx.service.ledger.getData(tender.id);
|
|
|
-
|
|
|
const dgnData = await this.ctx.service.stageBillsDgn.getDgnData(tender.id);
|
|
|
for (const d of dgnData) {
|
|
|
const l = this.ctx.helper._.find(billsData, {id: d.id});
|
|
|
this.ctx.helper._.assignIn(l, d);
|
|
|
}
|
|
|
-
|
|
|
- let billsIndexData = {};
|
|
|
- for (const bd of billsData) {
|
|
|
- billsIndexData[indexPre + bd.id] = bd;
|
|
|
- }
|
|
|
-
|
|
|
- for (const stage of stages) {
|
|
|
+ const pos = new Ledger.pos({
|
|
|
+ id: 'id', ledgerId: 'lid',
|
|
|
+ calc: function (node) {
|
|
|
+ node.pre_gather_qty = helper.add(node.pre_contract_qty, node.pre_qc_qty);
|
|
|
+ node.gather_qty = helper.add(node.contract_qty, node.qc_qty);
|
|
|
+ node.end_contract_qty = helper.add(node.pre_contract_qty, node.contract_qty);
|
|
|
+ node.end_qc_qty = helper.add(node.pre_qc_qty, node.qc_qty);
|
|
|
+ node.end_gather_qty = helper.add(node.pre_gather_qty, node.gather_qty);
|
|
|
+ },
|
|
|
+ });
|
|
|
+ const posData = await this.ctx.service.pos.getPosData({ tid: tender.id });
|
|
|
+ if (stage) {
|
|
|
await this.ctx.service.stage.doCheckStage(stage);
|
|
|
const curStage = stage.readOnly
|
|
|
? await this.ctx.service.stageBills.getAuditorStageData2(tender.id, stage.id, stage.curTimes, stage.curOrder)
|
|
|
: await this.ctx.service.stageBills.getLastestStageData2(tender.id, stage.id);
|
|
|
- const bpcStage = await this.ctx.service.stageBillsPc.getAllDataByCondition({ where: { sid: this.ctx.stage.id } });
|
|
|
- sumAssignRelaData(billsIndexData, [
|
|
|
- {data: curStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid'},
|
|
|
+ const preStage = hasPre && stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(tender, stage.order - 1) : [];
|
|
|
+ const bpcStage = await this.ctx.service.stageBillsPc.getAllDataByCondition({ where: { sid: stage.id } });
|
|
|
+ this.ctx.helper.assignRelaData(billsData, [
|
|
|
+ { data: curStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid' },
|
|
|
+ { data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'pre_', relaId: 'lid' },
|
|
|
{ data: bpcStage, fields: ['contract_pc_tp', 'qc_pc_tp', 'pc_tp'], prefix: '', relaId: 'lid' },
|
|
|
]);
|
|
|
- }
|
|
|
|
|
|
+ const curStagePos = stage.readOnly
|
|
|
+ ? await this.ctx.service.stagePos.getAuditorStageData2(tender.id, stage.id, stage.curTimes, stage.curOrder)
|
|
|
+ : await this.ctx.service.stagePos.getLastestStageData2(tender.id, stage.id);
|
|
|
+ const preStagePos = hasPre && stage.order > 1 ? await this.ctx.service.stagePosFinal.getFinalData(tender, stage.order - 1) : [];
|
|
|
+ this.ctx.helper.assignRelaData(posData, [
|
|
|
+ { data: curStagePos, fields: ['contract_qty', 'qc_qty'], prefix: '', relaId: 'pid' },
|
|
|
+ { data: preStagePos, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid' },
|
|
|
+ ]);
|
|
|
+ }
|
|
|
billsTree.loadDatas(billsData);
|
|
|
billsTree.calculateAll();
|
|
|
+ pos.loadDatas(posData);
|
|
|
+ pos.calculateAll();
|
|
|
+
|
|
|
this.resultTree.loadGatherTree(billsTree, function (gatherNode, sourceNode) {
|
|
|
- gatherUtils.gatherZone(tender, gatherNode, sourceNode, completeData.prefix, helper);
|
|
|
+ gatherUtils.gatherStage(tender, gatherNode, sourceNode, completeData.prefix, helper);
|
|
|
+ }, function (gatherNode, sourceNode) {
|
|
|
+ const posRange = pos.getLedgerPos(sourceNode.id);
|
|
|
+ if (!posRange || posRange.length === 0) return;
|
|
|
+ resultPos.loadGatherPos(gatherNode.id, posRange, (gatherPos, sourcePos) => {
|
|
|
+ gatherUtils.gatherStagePos(tender, gatherPos, sourcePos, completeData.prefix, helper);
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
async _gatherMonthData(tender, completeData, month, hasPre) {
|
|
|
const stages = await this._getValidStages(tender.id);
|
|
|
const stage = this.ctx.helper._.find(stages, {s_time: month});
|
|
|
await this._gatherStageData(completeData, tender, stage, hasPre);
|
|
|
}
|
|
|
-
|
|
|
async _gatherIndexData(tender, completeData, index, hasPre) {
|
|
|
const stages = await this._getValidStages(tender.id);
|
|
|
const stage = this.ctx.helper._.find(stages, {order: index});
|
|
|
await this._gatherStageData(completeData, tender, stage, hasPre);
|
|
|
}
|
|
|
-
|
|
|
- async _gatherZoneData(tender, completeData, zone) {
|
|
|
- const stages = await this._getTimeZoneStages(tender, zone);
|
|
|
- await this._gatherStagesData(completeData, tender, stages);
|
|
|
- }
|
|
|
-
|
|
|
- async _gatherIndexZoneData(tender, completeData, stageZone) {
|
|
|
- const stages = await this._getOrderZoneStages(tender, stageZone);
|
|
|
- await this._gatherStagesData(completeData, tender, stages);
|
|
|
- }
|
|
|
-
|
|
|
async _gatherFinalData(tender, completeData, hasPre) {
|
|
|
const stages = await this._getValidStages(tender.id);
|
|
|
await this._gatherStageData(completeData, tender, stages[0], hasPre);
|
|
|
}
|
|
|
-
|
|
|
async _gatherCheckedFinalData(tender, completeData, hasPre) {
|
|
|
const stages = await this._getCheckedStages(tender.id);
|
|
|
await this._gatherStageData(completeData, tender, stages[0], hasPre);
|
|
|
}
|
|
|
|
|
|
- async _gatherLedgerData(tender, completeData) {
|
|
|
- const helper = this.ctx.helper;
|
|
|
+ async _loadGatherLedger(tender) {
|
|
|
const billsTree = new Ledger.billsTree(this.ctx, {
|
|
|
id: 'ledger_id',
|
|
|
pid: 'ledger_pid',
|
|
@@ -426,36 +596,59 @@ module.exports = app => {
|
|
|
const billsData = await this.ctx.service.ledger.getData(tender.id);
|
|
|
billsTree.loadDatas(billsData);
|
|
|
billsTree.calculateAll();
|
|
|
+ return billsTree;
|
|
|
+ }
|
|
|
+ async _loadGatherPos(tender) {
|
|
|
+ const pos = new Ledger.pos({ id: 'id', ledgerId: 'lid' });
|
|
|
+ const posData = await this.ctx.service.pos.getAllDataByCondition({ where: { tid: tender.id } });
|
|
|
+ pos.loadDatas(posData);
|
|
|
+ return pos;
|
|
|
+ }
|
|
|
+ async _gatherLedgerData(tender, completeData) {
|
|
|
+ const resultPos = this.resultPos;
|
|
|
+ const helper = this.ctx.helper;
|
|
|
+ const billsTree = await this._loadGatherLedger(tender);
|
|
|
+ const pos = await this._loadGatherPos(tender);
|
|
|
this.resultTree.loadGatherTree(billsTree, function (gatherNode, sourceNode) {
|
|
|
gatherUtils.gatherLedger(tender, gatherNode, sourceNode, completeData.prefix, helper);
|
|
|
+ }, function (gatherNode, sourceNode) {
|
|
|
+ const posRange = pos.getLedgerPos(sourceNode.id);
|
|
|
+ if (!posRange || posRange.length === 0) return;
|
|
|
+ resultPos.loadGatherPos(posRange, (gatherPos, sourcePos) => {
|
|
|
+ gatherUtils.gatherPos(gatherPos, sourcePos, completeData.prefix, helper);
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
async _gatherSpecialData(tender, sKey) {
|
|
|
+ const resultPos = this.resultPos;
|
|
|
const helper = this.ctx.helper;
|
|
|
- const billsTree = new Ledger.billsTree(this.ctx, {
|
|
|
- id: 'ledger_id',
|
|
|
- pid: 'ledger_pid',
|
|
|
- order: 'order',
|
|
|
- level: 'level',
|
|
|
- rootId: -1,
|
|
|
- keys: ['id', 'tender_id', 'ledger_id'],
|
|
|
- stageId: 'id',
|
|
|
- calcFields: ['deal_tp', 'total_price'],
|
|
|
- });
|
|
|
- const billsData = await this.ctx.service.ledger.getData(tender.id);
|
|
|
- billsTree.loadDatas(billsData);
|
|
|
- billsTree.calculateAll();
|
|
|
+ const billsTree = await this._loadGatherLedger(tender);
|
|
|
+ const pos = await this._loadGatherPos(tender);
|
|
|
this.resultTree.loadGatherTree(billsTree, function (gatherNode, sourceNode) {
|
|
|
gatherUtils.gatherSpecial(gatherNode, sourceNode, 'ts_' + sKey + '_', helper);
|
|
|
+ }, function (gatherNode, sourceNode) {
|
|
|
+ const posRange = pos.getLedgerPos(sourceNode.id);
|
|
|
+ if (!posRange || posRange.length === 0) return;
|
|
|
+ resultPos.loadGatherPos(gatherNode.id, posRange, (gatherPos, sourcePos) => {
|
|
|
+ gatherUtils.gatherSpecialPos(gatherPos, sourcePos, 'ts_' + sKey + '_', helper);
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- async getGatherStageBills(memFieldKeys, gsDefine, gsCustom) {
|
|
|
- if (!gsDefine || !gsDefine.enable) return [];
|
|
|
- if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
|
|
|
+ async _doGatherStageData(memFieldKeys, gsDefine, gsCustom) {
|
|
|
+ if (this.resultTree || this.resultPos) return;
|
|
|
+ if (!gsDefine || !gsDefine.enable) return;
|
|
|
+ if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return;
|
|
|
+
|
|
|
+ this.resultTree = new Ledger.gatherTree(this.ctx, {
|
|
|
+ id: 'id',
|
|
|
+ pid: 'pid',
|
|
|
+ order: 'order',
|
|
|
+ level: 'level',
|
|
|
+ rootId: -1
|
|
|
+ });
|
|
|
+ this.resultPos = new Ledger.gatherPos({ id: 'id', ledgerId: 'lid' });
|
|
|
|
|
|
- this.resultTree.clear();
|
|
|
const gsSetting = JSON.parse(gsDefine.setting);
|
|
|
let commonIndex = 0;
|
|
|
const completeDatas = [];
|
|
@@ -489,6 +682,9 @@ module.exports = app => {
|
|
|
case 'stage-zone':
|
|
|
await this._gatherIndexZoneData(tender, completeData, gsCustom.stage_zone);
|
|
|
break;
|
|
|
+ case 'checked-zone':
|
|
|
+ await this._gatherCheckedZoneData(tender, completeData, gsCustom.checked_zone);
|
|
|
+ break;
|
|
|
}
|
|
|
commonIndex++;
|
|
|
} else {
|
|
@@ -498,7 +694,16 @@ module.exports = app => {
|
|
|
|
|
|
this.resultTree.resortChildrenDefault();
|
|
|
gatherUtils.completeGatherData(this.resultTree.nodes, completeDatas);
|
|
|
- return this.resultTree.getDefaultDatas();
|
|
|
+ gatherUtils.completeGatherData(this.resultPos.datas, completeDatas);
|
|
|
+ }
|
|
|
+
|
|
|
+ async getGatherStageBills(memFieldKeys, gsDefine, gsCustom) {
|
|
|
+ await this._doGatherStageData(memFieldKeys, gsDefine, gsCustom);
|
|
|
+ return this.resultTree ? this.resultTree.getDefaultDatas() : [];
|
|
|
+ }
|
|
|
+ async getGatherStagePos(memFieldKeys, gsDefine, gsCustom) {
|
|
|
+ await this._doGatherStageData(memFieldKeys, gsDefine, gsCustom);
|
|
|
+ return this.resultPos ? this.resultPos.getDatas() : [];
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -556,19 +761,49 @@ module.exports = app => {
|
|
|
info.end_sf_tp = helper.add(stage.sf_tp, stage.pre_sf_tp);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- async _getStagesTenderInfo(stages, info) {
|
|
|
+ async _getStagesTenderInfo(stages, info, preStage) {
|
|
|
const helper = this.ctx.helper;
|
|
|
+ if (preStage) {
|
|
|
+ info.pre_contract_tp = helper.add(preStage.contract_tp, preStage.pre_contract_tp);
|
|
|
+ info.pre_qc_tp = helper.add(preStage.qc_tp, preStage.pre_qc_tp);
|
|
|
+ info.pre_gather_tp = helper.add(info.pre_contract_tp, info.pre_qc_tp);
|
|
|
+ info.pre_yf_tp = helper.add(preStage.yf_tp, preStage.pre_yf_tp);
|
|
|
+ }
|
|
|
+
|
|
|
for (const stage of stages) {
|
|
|
await this.ctx.service.stage.doCheckStage(stage);
|
|
|
await this.ctx.service.stage.checkStageGatherData(stage, this.ctx.session.sessionUser.is_admin);
|
|
|
|
|
|
+
|
|
|
info.contract_tp = helper.add(info.contract_tp, stage.contract_tp);
|
|
|
info.qc_tp = helper.add(info.qc_tp, stage.qc_tp);
|
|
|
|
|
|
info.yf_tp = helper.add(info.yf_tp, stage.yf_tp);
|
|
|
}
|
|
|
info.gather_tp = helper.add(info.contract_tp, info.qc_tp);
|
|
|
+ info.end_contract_tp = helper.add(info.pre_contract_tp, info.contract_tp);
|
|
|
+ info.end_qc_tp = helper.add(info.pre_qc_tp, info.qc_tp);
|
|
|
+ info.end_gather_tp = helper.add(info.pre_gather_tp, info.gather_tp);
|
|
|
+ info.end_yf_tp = helper.add(info.pre_yf_tp, info.yf_tp);
|
|
|
+ }
|
|
|
+
|
|
|
+ async _gatherZoneTenderInfo(tender, index, zone) {
|
|
|
+ const info = await this._getBaseTenderInfo(tender);
|
|
|
+ const [stages, preStage, endStage] = await this._getTimeZoneStages(tender, zone);
|
|
|
+ await this._getStagesTenderInfo(stages, info, preStage);
|
|
|
+ this.resultTenderInfo.push(info);
|
|
|
+ }
|
|
|
+ async _gatherOrderZoneTenderInfo(tender, index, stageZone) {
|
|
|
+ const info = await this._getBaseTenderInfo(tender);
|
|
|
+ const [stages, preStage, endStage] = await this._getOrderZoneStages(tender, stageZone);
|
|
|
+ await this._getStagesTenderInfo(stages, info, preStage);
|
|
|
+ this.resultTenderInfo.push(info);
|
|
|
+ }
|
|
|
+ async _gatherCheckedZoneTenderInfo(tender, index, zone) {
|
|
|
+ const info = await this._getBaseTenderInfo(tender);
|
|
|
+ const [stages, preStage, endStage] = await this._getCheckedZoneStages(tender, zone);
|
|
|
+ await this._getStagesTenderInfo(stages, info, preStage);
|
|
|
+ this.resultTenderInfo.push(info);
|
|
|
}
|
|
|
|
|
|
async _gatherMonthTenderInfo(tender, index, month, hasPre) {
|
|
@@ -578,7 +813,6 @@ module.exports = app => {
|
|
|
await this._getStageTenderInfo(stage, info);
|
|
|
this.resultTenderInfo.push(info);
|
|
|
}
|
|
|
-
|
|
|
async _gatherOrderTenderInfo(tender, index, order, hasPre) {
|
|
|
const info = await this._getBaseTenderInfo(tender);
|
|
|
const stages = await this._getValidStages(tender.id);
|
|
@@ -586,28 +820,12 @@ module.exports = app => {
|
|
|
await this._getStageTenderInfo(stage, info);
|
|
|
this.resultTenderInfo.push(info);
|
|
|
}
|
|
|
-
|
|
|
- async _gatherZoneTenderInfo(tender, index, zone) {
|
|
|
- const info = await this._getBaseTenderInfo(tender);
|
|
|
- const stages = await this._getTimeZoneStages(tender, zone);
|
|
|
- await this._getStagesTenderInfo(stages, info);
|
|
|
- this.resultTenderInfo.push(info);
|
|
|
- }
|
|
|
-
|
|
|
- async _gatherOrderZoneTenderInfo(tender, index, stageZone) {
|
|
|
- const info = await this._getBaseTenderInfo(tender);
|
|
|
- const stages = await this._getOrderZoneStages(tender, stageZone);
|
|
|
- await this._getStagesTenderInfo(stages, info);
|
|
|
- this.resultTenderInfo.push(info);
|
|
|
- }
|
|
|
-
|
|
|
async _gatherFinalTenderInfo(tender, index, hasPre) {
|
|
|
const info = await this._getBaseTenderInfo(tender);
|
|
|
const stages = await this._getValidStages(tender.id);
|
|
|
await this._getStageTenderInfo(stages[0], info);
|
|
|
this.resultTenderInfo.push(info);
|
|
|
}
|
|
|
-
|
|
|
async _gatherCheckedFinalTenderInfo(tender, index, hasPre) {
|
|
|
const info = await this._getBaseTenderInfo(tender);
|
|
|
const stages = await this._getCheckedStages(tender.id);
|
|
@@ -619,7 +837,6 @@ module.exports = app => {
|
|
|
const info = await this._getBaseTenderInfo(tender);
|
|
|
this.resultTenderInfo.push(info);
|
|
|
}
|
|
|
-
|
|
|
async _gatherSpecialTenderInfo(tender, sKey) {
|
|
|
const info = await this._getBaseTenderInfo(tender);
|
|
|
info.spec = sKey;
|
|
@@ -659,6 +876,9 @@ module.exports = app => {
|
|
|
case 'stage-zone':
|
|
|
await this._gatherOrderZoneTenderInfo(tender, commonIndex, gsCustom.stage_zone);
|
|
|
break;
|
|
|
+ case 'checked-zone':
|
|
|
+ await this._gatherCheckedZoneTenderInfo(tender, commonIndex, gsCustom.checked_zone);
|
|
|
+ break;
|
|
|
}
|
|
|
commonIndex++;
|
|
|
} else {
|
|
@@ -728,12 +948,27 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- async _gatherStagesPay(completeData, tender, stages) {
|
|
|
+ async _gatherStagesPay(completeData, tender, stages, preStage) {
|
|
|
const helper = this.ctx.helper;
|
|
|
completeData.id = tender.id;
|
|
|
completeData.name = tender.name;
|
|
|
|
|
|
+ if (preStage) await this.ctx.service.stage.doCheckStage(preStage);
|
|
|
+ const preDealPay = preStage ? await this.ctx.service.stagePay.getStagePays(preStage) : [];
|
|
|
+ for (const dp of preDealPay) {
|
|
|
+ dp.end_tp = helper.add(dp.pre_tp, dp.tp);
|
|
|
+ this._gatherPayRecord(dp, function (gatherData, sourceData) {
|
|
|
+ gatherData[completeData.prefix + 'id'] = tender.id;
|
|
|
+ gatherData[completeData.prefix + 'name'] = tender.name;
|
|
|
+
|
|
|
+ gatherData[completeData.prefix + 'pre_tp'] = sourceData.end_tp;
|
|
|
+ gatherData.s_pre_tp = helper.add(gatherData.s_pre_tp, sourceData.end_tp);
|
|
|
+
|
|
|
+ gatherData[completeData.prefix + 'end_tp'] = sourceData.end_tp;
|
|
|
+ gatherData.s_end_tp = helper.add(gatherData.s_end_tp, sourceData.end_tp);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
for (const stage of stages) {
|
|
|
await this.ctx.service.stage.doCheckStage(stage);
|
|
|
|
|
@@ -747,43 +982,47 @@ module.exports = app => {
|
|
|
|
|
|
gatherData[completeData.prefix + 'tp'] = helper.add(gatherData[completeData.prefix + 'tp'], sourceData.tp);
|
|
|
gatherData['s_' + 'tp'] = helper.add(gatherData['s_' + 'tp'], sourceData.tp);
|
|
|
+
|
|
|
+ gatherData[completeData.prefix + 'end_tp'] = helper.add(gatherData[completeData.prefix + 'end_tp'], sourceData.tp);
|
|
|
+ gatherData['s_' + 'end_tp'] = helper.add(gatherData['s_' + 'end_tp'], sourceData.tp);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ async _gatherZoneStagePay(sTender, completeData, zone) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const [stages, preStage, endStage] = await this._getTimeZoneStages(tender, zone);
|
|
|
+ await this._gatherStagesPay(completeData, tender, stages, preStage);
|
|
|
+ }
|
|
|
+ async _gatherOrderZoneStagePay(sTender, completeData, stageZone) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const [stages, preStage, endStage] = await this._getOrderZoneStages(tender, stageZone);
|
|
|
+ await this._gatherStagesPay(completeData, tender, stages, preStage);
|
|
|
+ }
|
|
|
+ async _gatherCheckedZoneStagePay(sTender, completeData, zone) {
|
|
|
+ const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
+ const [stages, preStage, endStage] = await this._getCheckedZoneStages(tender, zone);
|
|
|
+ await this._gatherStagesPay(completeData, tender, stages, preStage);
|
|
|
+ }
|
|
|
+
|
|
|
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(completeData, tender, stage, hasPre);
|
|
|
}
|
|
|
-
|
|
|
async _gatherOrderStagePay(sTender, completeData, order, 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, {order: order});
|
|
|
await this._gatherStagePay(completeData, tender, stage, hasPre);
|
|
|
}
|
|
|
-
|
|
|
- async _gatherZoneStagePay(sTender, completeData, zone) {
|
|
|
- const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
- const stages = await this._getTimeZoneStages(tender, zone);
|
|
|
- await this._gatherStagesPay(completeData, tender, stages);
|
|
|
- }
|
|
|
-
|
|
|
- async _gatherOrderZoneStagePay(sTender, completeData, stageZone) {
|
|
|
- const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
- const stages = await this._getOrderZoneStages(tender, stageZone)
|
|
|
- await this._gatherStagesPay(completeData, tender, stages);
|
|
|
- }
|
|
|
-
|
|
|
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(completeData, tender, stages[0], hasPre);
|
|
|
}
|
|
|
-
|
|
|
async _gatherCheckedFinalStagePay(sTender, completeData, hasPre) {
|
|
|
const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
|
|
|
const stages = await this._getCheckedStages(tender.id);
|
|
@@ -824,6 +1063,9 @@ module.exports = app => {
|
|
|
case 'stage-zone':
|
|
|
await this._gatherOrderZoneStagePay(tender, completeData, gsCustom.stage_zone);
|
|
|
break;
|
|
|
+ case 'checked-zone':
|
|
|
+ await this._gatherCheckedZoneStagePay(tender, completeData, gsCustom.checked_zone);
|
|
|
+ break;
|
|
|
}
|
|
|
commonIndex++;
|
|
|
}
|