|
|
@@ -58,15 +58,24 @@ module.exports = app => {
|
|
|
return ctx.app._.indexOf(noTids, item.id) === -1;
|
|
|
});
|
|
|
const tenderidList = ctx.helper._.map(tenderList, 'id');
|
|
|
- const noticeList = await ctx.service.noticePush.getNoticeByDataCollect(ctx.session.sessionProject.id, tenderidList);
|
|
|
// 获取分类
|
|
|
const categoryData = await this.ctx.service.category.getListByCategoryLevel(ctx.subProject.id);
|
|
|
// 默认坐标,否则则取办事处坐标
|
|
|
const projectData = await ctx.service.project.getDataById(ctx.session.sessionProject.id);
|
|
|
ctx.subProject.data_collect_pages = ctx.subProject.data_collect_pages ? ctx.subProject.data_collect_pages.split(',') : [];
|
|
|
+ // 判断是否只有'7',如果只有7,则不用获取其它数据
|
|
|
+ let only_cost = false;
|
|
|
+ if (ctx.subProject.data_collect_pages.length === 1 && ctx.subProject.data_collect_pages[0] === '7') {
|
|
|
+ only_cost = true;
|
|
|
+ }
|
|
|
+ let noticeList = [];
|
|
|
+ if (!only_cost) {
|
|
|
+ noticeList = await ctx.service.noticePush.getNoticeByDataCollect(ctx.session.sessionProject.id, tenderidList);
|
|
|
+ }
|
|
|
if (ctx.params.index) {
|
|
|
ctx.subProject.data_collect = parseInt(ctx.params.index);
|
|
|
}
|
|
|
+ const is_cost = ctx.subProject.data_collect_pages.includes('7') && ctx.subProject.data_collect === 7;
|
|
|
const is_dz2 = ['P0505', 'P0506', 'P1201', 'P1202', 'GY18Y', 'GYJJ1', 'P1103', 'KLG25', 'I2U5B', 'SEN48'].indexOf(ctx.session.sessionProject.code) !== -1
|
|
|
&& ctx.subProject.data_collect_pages.includes('6') && ctx.subProject.data_collect === 6;
|
|
|
const renderData = {
|
|
|
@@ -83,7 +92,9 @@ module.exports = app => {
|
|
|
pushType: auditConst.pushType,
|
|
|
jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.datacollect.index),
|
|
|
};
|
|
|
- if (is_dz2) {
|
|
|
+ if (is_cost) {
|
|
|
+ await this.layout('datacollect/index_cost.ejs', renderData);
|
|
|
+ } else if (is_dz2) {
|
|
|
// 判断并更新common_json
|
|
|
if (!ctx.subProject.common_json) {
|
|
|
ctx.subProject.common_json = await ctx.service.subProject.updateCommonJsonDaping06(ctx.subProject, projectData);
|
|
|
@@ -119,62 +130,77 @@ module.exports = app => {
|
|
|
tenderList = ctx.app._.filter(tenderList, function(item) {
|
|
|
return ctx.app._.indexOf(noTids, item.id) === -1;
|
|
|
});
|
|
|
+ // 判断是否只有'7',如果只有7,则不用获取其它数据
|
|
|
+ let only_cost = false;
|
|
|
+ if (ctx.subProject.data_collect_pages.length === 1 && ctx.subProject.data_collect_pages[0] === '7') {
|
|
|
+ only_cost = true;
|
|
|
+ }
|
|
|
+ const have_cost = ctx.subProject.data_collect_pages.includes('7');
|
|
|
const thisMonth = new Date();
|
|
|
const [startMonth, endMonth] = ctx.helper.getStartEndMonth(thisMonth);
|
|
|
// 统计方法总时长
|
|
|
// let sumStageByDataCollectTime = 0;
|
|
|
for (const t of tenderList) {
|
|
|
- // const tenderInfo = await ctx.service.tenderInfo.getTenderInfo(t.id);
|
|
|
- // t.contract_price = tenderInfo.deal_param.contractPrice;
|
|
|
- // let bCalcTp = t.ledger_status === auditConst.ledger.status.checkNo || t.ledger_status === auditConst.ledger.status.uncheck;
|
|
|
- // t.advance_tp = await ctx.service.advance.getSumAdvance(t.id);
|
|
|
- //
|
|
|
- // if (t.ledger_status === auditConst.ledger.status.checked) {
|
|
|
- // t.lastStage = await ctx.service.stage.getLastestStage(t.id);
|
|
|
- // if (t.lastStage) await ctx.service.stage.checkStageGatherDataByDataCollect(t.lastStage, true);
|
|
|
- // t.completeStage = await ctx.service.stage.getLastestCompleteStage(t.id);
|
|
|
- // if ((!bCalcTp) && t.measure_type === measureType.gcl.value) {
|
|
|
- // bCalcTp = t.lastStage && t.lastStage.status !== auditConst.stage.status.checked && !t.lastStage.readOnly;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (bCalcTp) {
|
|
|
- // const sum = await this.ctx.service.ledger.addUp({ tender_id: t.id/* , is_leaf: true*/ });
|
|
|
- // t.total_price = sum.total_price;
|
|
|
- // t.deal_tp = sum.deal_tp;
|
|
|
- // }
|
|
|
// 用标段管理的方法获取t数据
|
|
|
- await this.ctx.service.tenderCache.loadTenderCache(t, '');
|
|
|
- t.total_price = t.ledger_tp && t.ledger_tp.total_price ? t.ledger_tp.total_price : 0;
|
|
|
- [t.change_tp, t.change_p_tp, t.change_n_tp, t.change_valuation_tp, t.change_unvaluation_tp] = await ctx.service.change.getChangeTp(t.id);
|
|
|
- // t.material_tp = await ctx.service.material.getSumMaterial(t.id);
|
|
|
- // 获取本标段 本月计量期审批通过数目,变更令审批通过数目,台账修订通过数目,材料调差通过数目
|
|
|
- t.month_stage_num = await ctx.service.stageAudit.getNumByMonth(t.id, startMonth, endMonth);
|
|
|
- t.month_change_num = await ctx.service.changeAudit.getNumByMonth(t.id, startMonth, endMonth);
|
|
|
- t.month_revise_num = await ctx.service.reviseAudit.getNumByMonth(t.id, startMonth, endMonth);
|
|
|
- t.month_material_num = await ctx.service.materialAudit.getNumByMonth(t.id, startMonth, endMonth);
|
|
|
- // 获取标段计量月统计及截止月累计计量
|
|
|
- // 这个慢,统计下面这个方法时长
|
|
|
- const stageList = await ctx.service.stage.getStageByDataCollect(t.id, t.stage_tp);
|
|
|
- // const stageList = [];
|
|
|
- const month_stage = [];
|
|
|
- for (const s of stageList) {
|
|
|
- const monthOneStage = ctx.app._.find(month_stage, { yearmonth: s.s_time });
|
|
|
- if (monthOneStage) {
|
|
|
- monthOneStage.tp = ctx.helper.add(monthOneStage.tp, s.tp);
|
|
|
- monthOneStage.end_yf_tp = ctx.helper.add(monthOneStage.end_yf_tp, s.yf_tp);
|
|
|
- monthOneStage.end_sf_tp = ctx.helper.add(monthOneStage.end_sf_tp, s.sf_tp);
|
|
|
- } else {
|
|
|
- const data = {
|
|
|
- yearmonth: s.s_time,
|
|
|
- tp: s.tp,
|
|
|
- end_tp: s.end_tp,
|
|
|
- end_yf_tp: s.yf_tp,
|
|
|
- end_sf_tp: s.sf_tp,
|
|
|
- };
|
|
|
- month_stage.push(data);
|
|
|
+ if (!only_cost) {
|
|
|
+ await this.ctx.service.tenderCache.loadTenderCache(t, '');
|
|
|
+ t.total_price = t.ledger_tp && t.ledger_tp.total_price ? t.ledger_tp.total_price : 0;
|
|
|
+ [t.change_tp, t.change_p_tp, t.change_n_tp, t.change_valuation_tp, t.change_unvaluation_tp] = await ctx.service.change.getChangeTp(t.id);
|
|
|
+ // t.material_tp = await ctx.service.material.getSumMaterial(t.id);
|
|
|
+ // 获取本标段 本月计量期审批通过数目,变更令审批通过数目,台账修订通过数目,材料调差通过数目
|
|
|
+ t.month_stage_num = await ctx.service.stageAudit.getNumByMonth(t.id, startMonth, endMonth);
|
|
|
+ t.month_change_num = await ctx.service.changeAudit.getNumByMonth(t.id, startMonth, endMonth);
|
|
|
+ t.month_revise_num = await ctx.service.reviseAudit.getNumByMonth(t.id, startMonth, endMonth);
|
|
|
+ t.month_material_num = await ctx.service.materialAudit.getNumByMonth(t.id, startMonth, endMonth);
|
|
|
+ // 获取标段计量月统计及截止月累计计量
|
|
|
+ // 这个慢,统计下面这个方法时长
|
|
|
+ const stageList = await ctx.service.stage.getStageByDataCollect(t.id, t.stage_tp);
|
|
|
+ // const stageList = [];
|
|
|
+ const month_stage = [];
|
|
|
+ for (const s of stageList) {
|
|
|
+ const monthOneStage = ctx.app._.find(month_stage, { yearmonth: s.s_time });
|
|
|
+ if (monthOneStage) {
|
|
|
+ monthOneStage.tp = ctx.helper.add(monthOneStage.tp, s.tp);
|
|
|
+ monthOneStage.end_yf_tp = ctx.helper.add(monthOneStage.end_yf_tp, s.yf_tp);
|
|
|
+ monthOneStage.end_sf_tp = ctx.helper.add(monthOneStage.end_sf_tp, s.sf_tp);
|
|
|
+ } else {
|
|
|
+ const data = {
|
|
|
+ yearmonth: s.s_time,
|
|
|
+ tp: s.tp,
|
|
|
+ end_tp: s.end_tp,
|
|
|
+ end_yf_tp: s.yf_tp,
|
|
|
+ end_sf_tp: s.sf_tp,
|
|
|
+ };
|
|
|
+ month_stage.push(data);
|
|
|
+ }
|
|
|
}
|
|
|
+ t.month_stage = month_stage;
|
|
|
+ }
|
|
|
+ if (have_cost) {
|
|
|
+ // 取最新已审批完成的成本管理-成本分析期数据
|
|
|
+ t.cost_analysis = await ctx.service.costStage.getLastCheckedStage(t.id, 'analysis');
|
|
|
+ t.stage_num = await ctx.service.stage.getNumByChecked(t.id);
|
|
|
+ t.cost_ledger_num = await ctx.service.costStage.getNumByChecked(t.id, 'ledger');
|
|
|
+ t.cost_analysis_num = await ctx.service.costStage.getNumByChecked(t.id, 'analysis');
|
|
|
+ t.cost_book_num = await ctx.service.costStage.getNumByChecked(t.id, 'book');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (have_cost) {
|
|
|
+ const data = {};
|
|
|
+ const budget = await ctx.service.budget.getCurBudget(ctx.subProject.budget_id);
|
|
|
+ budget.name = ctx.subProject.name || '';
|
|
|
+ if (!budget) throw '未设置概预算标准';
|
|
|
+ if (budget.final_id) {
|
|
|
+ data.final = await ctx.service.budgetFinal.getAllDataByCondition({ where: { final_id: budget.final_id } });
|
|
|
+ data.finalInfo = await ctx.service.budgetFinalList.getFinal(budget.final_id);
|
|
|
+ } else {
|
|
|
+ data.gu = await ctx.service.budgetGu.getData(budget.id);
|
|
|
+ data.gai = await ctx.service.budgetGai.getData(budget.id);
|
|
|
+ data.yu = await ctx.service.budgetYu.getData(budget.id);
|
|
|
+ data.zb = await ctx.service.budgetZb.getData(budget.id);
|
|
|
+ data.ctrl = await ctx.service.budgetCtrl.getData(budget.id);
|
|
|
}
|
|
|
- t.month_stage = month_stage;
|
|
|
+ responseData.data.budget = data;
|
|
|
}
|
|
|
// const tenderMapList = await ctx.service.tenderMap.getAllDataByCondition({ where: { tid: tender.id } });
|
|
|
responseData.data.tenderList = tenderList;
|