|
@@ -187,6 +187,54 @@ module.exports = app => {
|
|
|
}
|
|
|
return this.stageImData.main;
|
|
|
}
|
|
|
+
|
|
|
+ async getMonthProgress(tid) {
|
|
|
+ const helper = this.ctx.helper;
|
|
|
+ await this.ctx.service.tender.checkTender(tid);
|
|
|
+ const tender = this.ctx.tender;
|
|
|
+
|
|
|
+ const stages = await this.ctx.service.stage.getValidStages(tender.id);
|
|
|
+ const lastStage = stages.length > 0 ? stages[0] : null;
|
|
|
+ if (lastStage) {
|
|
|
+ await this.ctx.service.stage.checkStageGatherData(lastStage);
|
|
|
+ tender.gather_tp = helper.add(lastStage.contract_tp, lastStage.qc_tp);
|
|
|
+ tender.end_contract_tp = helper.add(lastStage.contract_tp, lastStage.pre_contract_tp);
|
|
|
+ tender.end_qc_tp = helper.add(lastStage.qc_tp, lastStage.pre_qc_tp);
|
|
|
+ tender.end_gather_tp = helper.add(tender.end_contract_tp, tender.end_qc_tp);
|
|
|
+ tender.pre_gather_tp = helper.add(lastStage.pre_contract_tp, lastStage.pre_qc_tp);
|
|
|
+ tender.yf_tp = lastStage.yf_tp;
|
|
|
+ tender.qc_ratio = helper.mul(helper.div(tender.end_qc_tp, tender.info.deal_param.contractPrice, 2), 100);
|
|
|
+ tender.sum = helper.add(tender.total_price, tender.end_qc_tp);
|
|
|
+ tender.pre_ratio = helper.mul(helper.div(tender.pre_gather_tp, tender.sum, 2), 100);
|
|
|
+ tender.cur_ratio = helper.mul(helper.div(tender.gather_tp, tender.sum, 2), 100);
|
|
|
+ tender.other_tp = helper.sub(helper.sub(tender.sum, tender.pre_gather_tp), tender.gather_tp);
|
|
|
+ tender.other_ratio = Math.max(0, 100 - tender.pre_ratio - tender.cur_ratio);
|
|
|
+ }
|
|
|
+ const monthProgress = [];
|
|
|
+ for (const s of stages) {
|
|
|
+ if (s.s_time) {
|
|
|
+ let progress = monthProgress.find(function (x) {
|
|
|
+ return x.month === s.s_time;
|
|
|
+ });
|
|
|
+ if (!progress) {
|
|
|
+ progress = {month: s.s_time};
|
|
|
+ monthProgress.push(progress);
|
|
|
+ }
|
|
|
+ progress.tp = helper.add(helper.add(progress.tp, s.contract_tp), s.qc_tp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ monthProgress.sort(function (x, y) {
|
|
|
+ return Date.parse(x.month) - Date.parse(y.month);
|
|
|
+ });
|
|
|
+ let sum = 0;
|
|
|
+ for (const p of monthProgress) {
|
|
|
+ p.ratio = helper.mul(helper.div(p.tp, tender.sum, 4), 100);
|
|
|
+ sum = helper.add(sum, p.tp);
|
|
|
+ p.end_tp = sum;
|
|
|
+ p.end_ratio = helper.mul(helper.div(p.end_tp, tender.sum, 4), 100);
|
|
|
+ }
|
|
|
+ return monthProgress;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return ReportMemory;
|