Ver código fonte

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

laiguoran 3 anos atrás
pai
commit
98db8584a0

+ 8 - 0
app/controller/tender_controller.js

@@ -1396,6 +1396,14 @@ module.exports = app => {
                                 orders: [['in_time', 'desc']],
                             });
                             break;
+                        case 'change_plan':
+                            if (ctx.session.sessionProject.page_show.isOnlyChecked) where.status = auditConst.changeApply.status.checked;
+                            responseData.data[f] = await ctx.service.changePlan.getAllDataByCondition({
+                                columns: [ 'id', 'code', 'name', 'selected' ],
+                                where,
+                                orders: [['in_time', 'desc']],
+                            });
+                            break;
                         default:
                             throw '未知数据类型';
                     }

+ 1 - 0
app/public/report/js/rpt_change_rela.js

@@ -3,6 +3,7 @@ const rptChangeRela = (function (){
         change: { title: '请选择变更令', colHeader: ['选择', '变更令号', '工程名称'] },
         change_project: { title: '请选择变更立项', colHeader: ['选择', '变更立项编号', '工程名称'] },
         change_apply: { title: '请选择变更申请', colHeader: ['选择', '变更申请编号', '工程名称'] },
+        change_plan: { title: '请选择变更方案', colHeader: ['选择', '变更方案编号', '工程名称'] },
     };
     const data = {};
     let curType = '';

+ 17 - 0
app/service/change_apply_list.js

@@ -196,6 +196,23 @@ module.exports = app => {
             };
             await transaction.update(this.ctx.service.changeApply.tableName, updateData, options);
         }
+
+        /**
+         * 报表用
+         * Tony Kang
+         * @param {tid} tid - 标段id
+         * @return {void}
+         */
+        async getChangeBills(tid, onlyChecked) {
+            const sql = 'SELECT cb.*' +
+                '  FROM ' + this.tableName + ' cb' +
+                '  LEFT JOIN ' + this.ctx.service.change.tableName + ' c ON cb.caid = c.id' +
+                '  WHERE c.tid = ? ' + (onlyChecked ? `and c.status = ${audit.changeApply.status.checked}` : '') +
+                '  ORDER BY cb.cid, cb.code';
+            const param = [tid];
+            const result = await this.db.query(sql, param);
+            return result;
+        }
     }
 
     return ChangeApplyList;

+ 12 - 0
app/service/report.js

@@ -281,9 +281,21 @@ module.exports = app => {
                     case 'mem_change_apply':
                         rst[filter] = await service.reportMemory.getChangeApplyData(params.tender_id);
                         break;
+                    case 'mem_change_apply_bills':
+                        rst[filter] = await service.reportMemory.getChangeApplyBillsData(params.tender_id);
+                        break;
                     case 'mem_change_apply_audit':
                         rst[filter] = await service.reportMemory.getChangeApplyAuditData(params.tender_id);
                         break;
+                    case 'mem_change_plan':
+                        rst[filter] = await service.reportMemory.getChangePlanData(params.tender_id);
+                        break;
+                    case 'mem_change_plan_bills':
+                        rst[filter] = await service.reportMemory.getChangePlanBillsData(params.tender_id);
+                        break;
+                    case 'mem_change_plan_audit':
+                        rst[filter] = await service.reportMemory.getChangePlanAuditData(params.tender_id);
+                        break;
                     case 'mem_change_project':
                         rst[filter] = await service.reportMemory.getChangeProjectData(params.tender_id);
                         break;

+ 83 - 1
app/service/report_memory.js

@@ -845,7 +845,20 @@ module.exports = app => {
             this.changeApplyData = {};
             const where = { tid };
             if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeApply.status.checked;
-            this.changeApplyData = { data: await this.ctx.service.changeApply.getAllDataByCondition({ where }) };
+            const data = await this.ctx.service.changeApply.getAllDataByCondition({ where });
+            const bills = await this.ctx.service.changeApplyList.getChangeBills(tid, this.ctx.session.sessionProject.page_show.isOnlyChecked);
+            bills.sort(function(a, b ) {
+                const aCIndex = data.findIndex(function (c) {
+                    return c.cid === a.cid;
+                });
+                const bCIndex = data.findIndex(function (c) {
+                    return c.cid === b.cid;
+                });
+                return aCIndex === bCIndex
+                    ? ctx.helper.compareCode(a.code, b.code)
+                    : aCIndex - bCIndex;
+            });
+            this.changeApplyData = { data, bills };
         }
 
         async _generateChangeApplyAudit() {
@@ -868,6 +881,14 @@ module.exports = app => {
             }
         }
 
+        async getChangeApplyBillsData(tid, sid, fields) {
+            try {
+                await this._generateChangeApply(tid);
+                return this.changeApplyData.bills;
+            } catch (err) {
+                return [];
+            }
+        }
 
         async getChangeApplyAuditData(tid, sid, fields) {
             try {
@@ -880,6 +901,67 @@ module.exports = app => {
             }
         }
 
+        async _generateChangePlan(tid) {
+            if (!!this.changePlanData) return;
+            this.changePlanData = {};
+            const where = { tid };
+            if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeApply.status.checked;
+            const data = await this.ctx.service.changePlan.getAllDataByCondition({ where });
+            const bills = await this.ctx.service.changePlanList.getChangeBills(tid, this.ctx.session.sessionProject.page_show.isOnlyChecked);
+            bills.sort(function(a, b ) {
+                const aCIndex = data.findIndex(function (c) {
+                    return c.cid === a.cid;
+                });
+                const bCIndex = data.findIndex(function (c) {
+                    return c.cid === b.cid;
+                });
+                return aCIndex === bCIndex
+                    ? ctx.helper.compareCode(a.code, b.code)
+                    : aCIndex - bCIndex;
+            });
+            this.changePlanData = { data, bills };
+        }
+
+        async _generateChangePlanAudit() {
+            if (!!this.changePlanData.audit) return;
+
+            this.changePlanData.audit = [];
+            for (const c of this.changePlanData.data) {
+                const changeAudit = await this.ctx.service.changePlanAudit.getAllDataByCondition({ where: { caid: c.id, times: c.times }});
+                const changeAuditFilter = this.ctx.helper.filterLastestData(changeAudit, ['aid']);
+                this.changePlanData.audit.push(...changeAuditFilter);
+            }
+        }
+
+        async getChangePlanData(tid, sid, fields) {
+            try {
+                await this._generateChangePlan(tid);
+                return this.changePlanData.data;
+            } catch (err) {
+                return [];
+            }
+        }
+
+        async getChangePlanBillsData(tid, sid, fields) {
+            try {
+                await this._generateChangePlan(tid);
+                return this.changePlanData.bills;
+            } catch (err) {
+                return [];
+            }
+        }
+
+        async getChangePlanAuditData(tid, sid, fields) {
+            try {
+                await this._generateChangePlan(tid);
+                await this._generateChangePlanAudit();
+                return this.changePlanData.audit;
+            } catch (err) {
+                this.ctx.log(err);
+                return [];
+            }
+        }
+
         async _generateChangeProject(tid) {
             if (!!this.changeProjectData) return;
             const where = { tid };

+ 1 - 0
app/view/report/index.ejs

@@ -34,6 +34,7 @@
                             <a class="dropdown-item" href="javascript: void(0)" onclick="rptChangeRela.showChangeRela('change_project');">变更立项</a>
                             <a class="dropdown-item" href="javascript: void(0)" onclick="rptChangeRela.showChangeRela('change_apply');">变更申请</a>
                             <a class="dropdown-item" href="javascript: void(0)" onclick="rptChangeRela.showChangeRela('change');">变更令</a>
+                            <a class="dropdown-item" href="javascript: void(0)" onclick="rptChangeRela.showChangeRela('change_plan');">变更方案</a>
                         </div>
                     </div>
                 </div>

+ 93 - 1
builder_report_index_define.js

@@ -431,6 +431,96 @@ const change_apply_audit = {
         { name: '审批意见', field: 'opinion', type: dataType.str },
     ],
 };
+const change_apply_bills = {
+    name: '变更申请 清单(mem_change_apply_bills)',
+    remark: '',
+    id: 79,
+    key: 'mem_change_apply_bills',
+    prefix: '变更申请 清单',
+    cols: [
+        { name: 'id', field: 'id', type: dataType.int },
+        { name: '标段id', field: 'tid', type: dataType.int },
+        { name: '变更申请id', field: 'cpid', type: dataType.int },
+        { name: '清单编号', field: 'code', type: dataType.str },
+        { name: '名称', field: 'name', type: dataType.str },
+        { name: '单位', field: 'unit', type: dataType.str },
+        { name: '单价', field: 'unit_price', type: dataType.currency },
+        { name: '原数量', field: 'oamount', type: dataType.currency },
+        { name: '变更数量', field: 'camount', type: dataType.currency },
+    ]
+};
+
+const change_plan = {
+    name: '变更方案(mem_change_plan)',
+    remark: '',
+    id: 80,
+    key: 'mem_change_plan',
+    prefix: '变更方案',
+    cols: [
+        { name: 'id', field: 'id', type: dataType.int },
+        { name: '标段id', field: 'tid', type: dataType.int },
+        { name: '报表用,是否选择', field: 'selected', type: dataType.int },
+        { name: '发起人', field: 'uid', type: dataType.int },
+        { name: '变更方案编号', field: 'code', type: dataType.str },
+        { name: '变更工程名称', field: 'name', type: dataType.str },
+        { name: '发起时间', field: 'in_time', type: dataType.time },
+        { name: '方案状态', field: 'status', type: dataType.int },
+        { name: '审批次数', field: 'times', type: dataType.int },
+        { name: '变更申请编号', field: 'apply_code', type: dataType.str },
+        { name: '原设计图名称', field: 'org_name', type: dataType.str },
+        { name: '桩号', field: 'peg', type: dataType.str },
+        { name: '图号', field: 'new_code', type: dataType.str },
+        { name: '变更图号', field: 'c_new_code', type: dataType.str },
+        { name: '变更设计名称', field: 'design_name', type: dataType.str },
+        { name: '工程变更类别', field: 'class', type: dataType.str },
+        { name: '工程变更性质', field: 'quality', type: dataType.str },
+        { name: '变更原因', field: 'reason', type: dataType.str },
+        { name: '变更内容', field: 'content', type: dataType.str },
+        { name: '方案描述', field: 'memo', type: dataType.str },
+        { name: '金额', field: 'total_price', type: dataType.currency },
+        { name: '小数位数设置JSON', field: 'decimal', type: dataType.int },
+    ],
+};
+const change_plan_audit = {
+    name: '变更方案 审批(mem_change_plan_audit)',
+    remark: '',
+    id: 81,
+    key: 'mem_change_plan_audit',
+    prefix: '变更方案 审批',
+    cols: [
+        { name: 'id', field: 'id', type: dataType.int },
+        { name: '标段id', field: 'tid', type: dataType.int },
+        { name: '方案id', field: 'cpid', type: dataType.int },
+        { name: '审批人id', field: 'aid', type: dataType.int },
+        { name: '审批顺序', field: 'order', type: dataType.int },
+        { name: '审批次数', field: 'times', type: dataType.int },
+        { name: '审批状态', field: 'status', type: dataType.int },
+        { name: '开始审批时间', field: 'begin_time', type: dataType.time },
+        { name: '结束审批时间', field: 'end_time', type: dataType.time },
+        { name: '审批意见', field: 'opinion', type: dataType.str },
+    ],
+};
+const change_plan_bills = {
+    name: '变更方案 清单(mem_change_plan_bills)',
+    remark: '',
+    id: 82,
+    key: 'mem_change_plan_bills',
+    prefix: '变更方案 清单',
+    cols: [
+        { name: 'id', field: 'id', type: dataType.int },
+        { name: '标段id', field: 'tid', type: dataType.int },
+        { name: '变更申请id', field: 'cpid', type: dataType.int },
+        { name: '清单编号', field: 'code', type: dataType.str },
+        { name: '名称', field: 'name', type: dataType.str },
+        { name: '单位', field: 'unit', type: dataType.str },
+        { name: '单价', field: 'unit_price', type: dataType.currency },
+        { name: '原数量', field: 'oamount', type: dataType.currency },
+        { name: '变更数量', field: 'camount', type: dataType.currency },
+        { name: '审批完成后变更数量', field: 'samount', type: dataType.currency },
+        { name: '用户填的数目, json', field: 'audit_amount', type: dataType.str },
+        { name: '审批流程中读取数量', field: 'spamount', type: dataType.currency },
+    ]
+};
 
 // 期 - 清单
 const stage_bills = {
@@ -2384,7 +2474,9 @@ const defines = [
     stage_bills, stage_bills_compare,
     stage_jgcl, stage_bonus, stage_other, stage_safe_prod, stage_temp_land,
     change, change_bills, change_audit,
-    change_apply, change_apply_audit, change_project, change_project_audit,
+    change_apply, change_apply_audit, change_apply_bills,
+    change_plan, change_plan_audit, change_plan_bills,
+    change_project, change_project_audit,
     stage_pos, stage_pos_compare,
     stage_pay,
     stage_im_zl, stage_im_tz, stage_im_tz_bills,

+ 1 - 0
sql/update.sql

@@ -150,6 +150,7 @@ DROP TABLE IF EXISTS `zh_change_plan`;
 CREATE TABLE `zh_change_plan`  (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `tid` int(11) NOT NULL COMMENT '标段id',
+  `selected` tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '报表用,是否选择',
   `uid` int(11) NOT NULL COMMENT '发起人',
   `code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '变更方案编号',
   `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '变更工程名称',