Selaa lähdekoodia

报表数据源,汇总,变更调用明细

MaiXinRong 11 kuukautta sitten
vanhempi
commit
378e7d40bf

+ 83 - 1
app/service/rpt_gather_memory.js

@@ -1213,7 +1213,7 @@ module.exports = app => {
             if (!gsDefine || !gsDefine.enable) return [];
             if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
 
-            this.resultTenderInfo = [];
+            this.resultDealBills = [];
             const gsSetting = JSON.parse(gsDefine.setting);
             let commonIndex = 0;
             const completeDatas = [];
@@ -1343,6 +1343,88 @@ module.exports = app => {
             return result;
         }
 
+        async _gatherStageChange(completeData, tender, stage, hasPre, gatherType = 'flow'){
+            if (!stage) return [];
+            const helper = this.ctx.helper;
+            await this.ctx.service.stage.doCheckStage(stage);
+
+            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) : [];
+            if (gatherType === 'flow') return [...curStageChange, ...preStageChange];
+
+            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;
+            };
+            curStageChange.forEach(sc => {
+                const r = findR(sc);
+                r.qty = helper.add(r.qty, sc.qty);
+            });
+            preStageChange.forEach(sc => {
+                const r = findR(sc);
+                r.pre_qty = helper.add(r.pre_qty, sc.qty);
+            });
+            result.forEach(r => { r.end_qty = helper.add(r.pre_qty, r.qty); });
+            return result;
+        }
+        async _gatherMonthStageChange(sTender, completeData, month, hasPre, gatherType) {
+            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._gatherStageChange(completeData, tender, stage, hasPre, gatherType);
+        }
+        async _gatherOrderStageChange(sTender, completeData, order, hasPre, gatherType) {
+            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._gatherStageChange(completeData, tender, stage, hasPre, gatherType);
+        }
+        async _gatherFinalStageChange(sTender, completeData, hasPre, gatherType) {
+            const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
+            const stages = await this._getValidStages(tender.id);
+            await this._gatherStageChange(completeData, tender, stages[0], hasPre, gatherType);
+        }
+        async _gatherCheckedFinalStageChange(sTender, completeData, hasPre, gatherType) {
+            const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
+            const stages = await this._getCheckedStages(tender.id);
+            await this._gatherStageChange(completeData, tender, stages[0], hasPre, gatherType);
+        }
+        async getGatherStageChange(memFieldKeys, gsDefine, gsCustom) {
+            if (!gsDefine || !gsDefine.enable) return [];
+            if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
+            const gsSetting = JSON.parse(gsDefine.setting);
+            if (gsSetting.type !== 'stage') return [];
+
+            this.resultStageChange = [];
+            let commonIndex = 0;
+            const completeDatas = [];
+            for (const tender of gsCustom.tenders) {
+                const completeData = { prefix: 't_' + commonIndex + '_' };
+                completeDatas.push(completeData);
+                switch (gsSetting.type) {
+                    case 'month':
+                        await this._gatherMonthStageChange(tender, completeData, gsCustom.month, gsSetting.hasPre, gsSetting.gather);
+                        break;
+                    case 'final':
+                        await this._gatherFinalStageChange(tender, completeData, gsSetting.hasPre, gsSetting.gather);
+                        break;
+                    case 'checked-final':
+                        await this._gatherCheckedFinalStageChange(tender, completeData, gsSetting.hasPre, gsSetting.gather);
+                        break;
+                    case 'stage':
+                        await this._gatherOrderStageChange(tender, completeData, gsCustom.stage, gsSetting.hasPre, gsSetting.gather);
+                        break;
+                }
+                commonIndex++;
+            }
+            return this.resultStageChange;
+        }
+
         async getGatherAdvancePay(memFieldKeys, gsDefine, gsCustom) {
             if (!gsDefine || !gsDefine.enable) return [];
             if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];

+ 6 - 0
app/service/stage_change.js

@@ -649,6 +649,12 @@ module.exports = app => {
             return this._.map(this._.filter(cur, 'qty'), 'cid');
         }
 
+        async getCurStageData(tid, sid, stimes, sorder) {
+            const sql = `SELECT * From ${this.tableName} WHERE tid = ? AND sid = ? AND (stimes < ? OR (stimes = ? AND sorder < ?))`;
+            const data = await this.db.query(sql, [tid, sid, stimes, stimes, sorder]);
+            return this.ctx.helper.filterLastestData(data, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder');
+        }
+
         async getFinalStageData(tid, sid) {
             const data = await this.getAllDataByCondition({ where: { tid, sid } });
             return this.ctx.helper.filterLastestData(data, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder');

+ 1 - 1
app/view/revise/history.ejs

@@ -94,7 +94,7 @@
                 <li class="nav-item">
                     <a class="nav-link" content="#search" href="javascript: void(0);">查找定位</a>
                 </li>
-                <li class="nav-item" style="display: none">
+                <li class="nav-item">
                     <a class="nav-link" content="#fujian" href="javascript: void(0);">附件</a>
                 </li>
             </ul>

+ 1 - 1
app/view/revise/info.ejs

@@ -222,7 +222,7 @@
                     <a class="nav-link" content="#bills-tag" href="javascript: void(0);">书签</a>
                 </li>
                 <li class="nav-item">
-                    <a class="nav-link" content="#fujian" href="javascript: void(0);" style="display: none">附件</a>
+                    <a class="nav-link" content="#fujian" href="javascript: void(0);">附件</a>
                 </li>
                 <li class="nav-item">
                     <a class="nav-link" content="#error-list" id="error-list-tab" href="javascript: void(0);" style="display: none;">错误列表</a>