فهرست منبع

计量台账,总分包,导入覆盖数据

MaiXinRong 3 سال پیش
والد
کامیت
d271731b85

+ 1 - 1
app/controller/tender_controller.js

@@ -1265,7 +1265,7 @@ module.exports = app => {
                         ctx.body = {err: 0, msg: '', data: reviseData};
                         break;
                     case 'stage':
-                        const stageData = await this.ctx.service.stageBills.sumLoad(data.lid, data.tenders);
+                        const stageData = await this.ctx.service.stageBills.sumLoad(data.lid, data.tenders, data.cover);
                         ctx.body = {err: 0, msg: '', data: stageData};
                         break;
                     default:

+ 13 - 4
app/lib/sum_load.js

@@ -314,6 +314,10 @@ class updateReviseGclTree extends loadGclBaseTree {
 }
 
 class gatherStageGclTree extends loadGclBaseTree {
+    constructor (ctx, setting) {
+        super(ctx, setting);
+        this.cover = setting.cover;
+    }
     loadBase(datas, pos) {
         datas.sort((x, y) => { return x.level === y.level ? x.order - y.order : x.level - y.level; });
         const Index = {};
@@ -334,8 +338,8 @@ class gatherStageGclTree extends loadGclBaseTree {
                 name: d.name,
                 unit: d.unit,
                 unit_price: d.unit_price,
-                org_contract_qty: d.contract_qty || 0,
-                org_contract_tp: d.contract_tp || 0,
+                org_contract_qty: this.cover ? d.contract_qty || 0 : 0,
+                org_contract_tp: this.cover ? d.contract_tp || 0 : 0,
                 org_order: d.order,
                 contract_qty: 0,
                 contract_tp: 0,
@@ -392,6 +396,7 @@ class gatherStageGclTree extends loadGclBaseTree {
                 }
             }
         }
+        console.log(result.update.length);
         for (const i of this.items) {
             result.errors.push({ b_code: i.b_code, name: i.name, unit: i.unit, qty: i.contract_qty, type: 'miss' });
             if (i.change_detail && i.change_detail.length > 0) {
@@ -505,12 +510,16 @@ class sumLoad {
         }
     }
 
-    async stageGatherGcl(select, maxId, tenders, defaultData) {
+    async stageGatherGcl(select, maxId, tenders, defaultData, cover) {
         const ignoreParent = this.ctx.tender.info.fun_rela.sum_load.ignoreParent;
         this.loadTree = new gatherStageGclTree(this.ctx, {
-            parent: select, maxId, type: 'ledger', defaultData, ignoreParent,
+            parent: select, maxId, type: 'ledger', defaultData, ignoreParent, cover,
         });
         const posterity = await this.ctx.service.ledger.getPosterityByParentId(this.ctx.tender.id, select.ledger_id);
+        const stageBills = await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id);
+        this.ctx.helper.assignRelaData(posterity, [
+            { data: stageBills, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp' ], prefix: '', relaId: 'lid' },
+        ]);
         const pos = await this.ctx.service.revisePos.getData(this.ctx.tender.id);
         this.loadTree.loadBase(posterity, pos);
 

+ 5 - 1
app/public/js/shares/tender_select.js

@@ -171,10 +171,14 @@ const TenderSelect = function (setting) {
             this.tenderSpread.bind(spreadNS.Events.ButtonClicked, tsObj.tsButtonClicked);
             if (this.setting.type === 'stage') {
                 this.resultSpread.bind(spreadNS.Events.EditEnded, tsObj.trEditEnded);
+                $('#tender-select-option').show();
+            } else {
+                $('#tender-select-option').hide();
             }
 
             $('#tender-select-ok').click(() => {
-                const updateData = {lid: tsObj.select.id, type: tsObj.setting.type, tenders: tsObj.trArray};
+                const updateData = { lid: tsObj.select.id, type: tsObj.setting.type, tenders: tsObj.trArray };
+                if (tsObj.setting.type === 'stage') updateData.cover = $('#ts-cover')[0].checked;
                 if (updateData.tenders.length > 0) {
                     postData(window.location.pathname + '/sumLoad', updateData, result => {
                         tsObj.setting.afterLoad(result);

+ 3 - 3
app/service/stage_bills.js

@@ -445,13 +445,13 @@ module.exports = app => {
             return { contract_tp, qc_tp };
         }
 
-        async sumLoad(lid, tenders) {
+        async sumLoad(lid, tenders, cover) {
             const conn = await this.db.beginTransaction();
             try {
                 const maxId = await this.ctx.service.ledger._getMaxLid(this.ctx.tender.id);
                 const select = await this.ctx.service.ledger.getDataById(lid);
                 const sumLoad = new SumLoad(this.ctx);
-                const loadTree = await sumLoad.stageGatherGcl(select, maxId, tenders);
+                const loadTree = await sumLoad.stageGatherGcl(select, maxId, tenders, null, cover);
                 const result = loadTree.getUpdateData();
                 if (result.errors.length > 100) throw '您导入的数据存在大量数据错误,请您仔细检查';
 
@@ -475,7 +475,7 @@ module.exports = app => {
                     }
                 }
 
-                const his = await this.ctx.service.sumLoadHistory.saveStageHistory(this.ctx.tender.id, this.ctx.stage.id, lid, tenders, result.errors);
+                const his = await this.ctx.service.sumLoadHistory.saveStageHistory(this.ctx.tender.id, this.ctx.stage.id, lid, tenders, result.errors, cover);
                 if (updateStageBills.length > 0) await conn.updateRows(this.tableName, updateStageBills);
                 if (insertStageBills.length > 0) await conn.insert(this.tableName, insertStageBills);
                 await conn.commit();

+ 3 - 2
app/service/sum_load_history.js

@@ -72,11 +72,12 @@ module.exports = app => {
             return data;
         }
 
-        async saveStageHistory(tid, sid, lid, tenders, errors) {
+        async saveStageHistory(tid, sid, lid, tenders, errors, cover) {
             const data = {
-                tid, lid, type: 'revise', sid,
+                tid, lid, type: 'stage', sid,
                 load_time: new Date(), uid: this.ctx.session.sessionUser.accountId,
                 tenders: JSON.stringify(tenders), errors: errors ? JSON.stringify(errors) : '',
+                cover: cover,
             };
             await this.db.insert(this.tableName, data);
             data.tenders = tenders;

+ 6 - 0
app/view/shares/tender_select_modal.ejs

@@ -18,6 +18,12 @@
                         <h5>已选标段 </h5>
                         <div class="modal-height-300" id="ts-result-spread">
                         </div>
+                        <div id="tender-select-option">
+                            <div class="form-check form-check-inline">
+                                <input class="form-check-input" type="checkbox" id="ts-cover">
+                                <label class="form-check-label" for="ts-cover">覆盖数据</label>
+                            </div>
+                        </div>
                     </div>
                     <div id="tender-select-hint">
                         <div class="text-danger text-center ml-3 d-inline-block" id="ts-hint-text">我是提示呀</div>

+ 2 - 65
sql/update.sql

@@ -1,68 +1,3 @@
-
-ALTER TABLE `zh_stage`
-ADD COLUMN `im_start_num`  int(11) NOT NULL DEFAULT 1 AFTER `im_gather_node`;
-
-CREATE TABLE `zh_stage_safe_prod` (
-  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `tid` int(11) unsigned NOT NULL COMMENT '标段id',
-  `sid` int(11) unsigned NOT NULL COMMENT '期id',
-  `sorder` tinyint(4) unsigned NOT NULL COMMENT '期序号',
-  `uuid` varchar(36) CHARACTER SET ascii NOT NULL COMMENT '安全生产标识id',
-  `add_sid` int(11) unsigned NOT NULL COMMENT '新增期id',
-  `add_uid` int(11) NOT NULL COMMENT '新增人id',
-  `add_time` datetime NOT NULL COMMENT '新增时间',
-  `order` int(11) unsigned NOT NULL COMMENT '排序',
-  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '名称',
-  `unit` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '单位',
-  `unit_price` decimal(24,8) DEFAULT NULL COMMENT '单价',
-  `quantity` decimal(24,8) DEFAULT NULL COMMENT '计划-数量',
-  `total_price` decimal(24,8) DEFAULT NULL COMMENT '计划-金额',
-  `qty` decimal(24,8) DEFAULT NULL COMMENT '本期-数量',
-  `tp` decimal(24,8) DEFAULT NULL COMMENT '本期-金额',
-  `shistory` text CHARACTER SET utf8 COMMENT '本期历史数据',
-  `pre_used` tinyint(4) DEFAULT '0' COMMENT '往期是否使用',
-  `memo` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '备注',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
-CREATE TABLE `zh_stage_temp_land` (
-  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `tid` int(11) unsigned NOT NULL COMMENT '标段id',
-  `sid` int(11) unsigned NOT NULL COMMENT '期id',
-  `sorder` tinyint(4) unsigned NOT NULL COMMENT '期序号',
-  `uuid` varchar(36) CHARACTER SET ascii NOT NULL COMMENT '安全生产标识id',
-  `add_sid` int(11) unsigned NOT NULL COMMENT '新增期id',
-  `add_uid` int(11) NOT NULL COMMENT '新增人id',
-  `add_time` datetime NOT NULL COMMENT '新增时间',
-  `order` int(11) unsigned NOT NULL COMMENT '排序',
-  `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '名称',
-  `unit` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '单位',
-  `unit_price` decimal(24,8) DEFAULT NULL COMMENT '单价',
-  `qty` decimal(24,8) DEFAULT NULL COMMENT '本期-数量',
-  `tp` decimal(24,8) DEFAULT NULL COMMENT '本期-金额',
-  `shistory` text CHARACTER SET utf8 COMMENT '本期历史数据',
-  `pre_used` tinyint(4) DEFAULT '0' COMMENT '往期是否使用',
-  `memo` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '备注',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
-CREATE TABLE `zh_stage_detail_attachment` (
-  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `tid` int(11) unsigned NOT NULL COMMENT '标段id',
-  `sid` int(11) unsigned NOT NULL COMMENT '标段id',
-  `sorder` tinyint(4) unsigned NOT NULL COMMENT '期序号',
-  `uuid` varchar(50) CHARACTER SET ascii NOT NULL COMMENT '中间计量附件标识uuid',
-  `lid` varchar(50) CHARACTER SET ascii NOT NULL COMMENT '台账id(标识)',
-  `pid` varchar(50) CHARACTER SET ascii NOT NULL COMMENT '计量单元id(标识)',
-  `code` varchar(50) CHARACTER SET utf8 DEFAULT NULL COMMENT '编号(标识)',
-  `name` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '名称(标识)',
-  `unit` varchar(20) CHARACTER SET utf8 DEFAULT NULL COMMENT '单位(标识)',
-  `unit_price` decimal(24,8) DEFAULT NULL COMMENT '单价(标识)',
-  `pos_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '计量单元名称(标识)',
-  `im_type` tinyint(1) NOT NULL COMMENT '中间计量类型(标识)',
-  `attachment` text CHARACTER SET utf8 COMMENT '附件',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+ALTER TABLE `zh_sum_load_history`
+ADD COLUMN `cover`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '覆盖数据' AFTER `load_time`;
 

+ 67 - 0
sql/update20211103.sql

@@ -0,0 +1,67 @@
+
+ALTER TABLE `zh_stage`
+ADD COLUMN `im_start_num`  int(11) NOT NULL DEFAULT 1 AFTER `im_gather_node`;
+
+-- 安全生产
+CREATE TABLE `zh_stage_safe_prod` (
+    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+    `tid` int(11) unsigned NOT NULL COMMENT '标段id',
+    `sid` int(11) unsigned NOT NULL COMMENT '期id',
+    `sorder` tinyint(4) unsigned NOT NULL COMMENT '期序号',
+    `uuid` varchar(36) CHARACTER SET ascii NOT NULL COMMENT '安全生产标识id',
+    `add_sid` int(11) unsigned NOT NULL COMMENT '新增期id',
+    `add_uid` int(11) NOT NULL COMMENT '新增人id',
+    `add_time` datetime NOT NULL COMMENT '新增时间',
+    `order` int(11) unsigned NOT NULL COMMENT '排序',
+    `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '名称',
+    `unit` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '单位',
+    `unit_price` decimal(24,8) DEFAULT NULL COMMENT '单价',
+    `quantity` decimal(24,8) DEFAULT NULL COMMENT '计划-数量',
+    `total_price` decimal(24,8) DEFAULT NULL COMMENT '计划-金额',
+    `qty` decimal(24,8) DEFAULT NULL COMMENT '本期-数量',
+    `tp` decimal(24,8) DEFAULT NULL COMMENT '本期-金额',
+    `shistory` text CHARACTER SET utf8 COMMENT '本期历史数据',
+    `pre_used` tinyint(4) DEFAULT '0' COMMENT '往期是否使用',
+    `memo` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '备注',
+    PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+-- 临时占地
+CREATE TABLE `zh_stage_temp_land` (
+    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+    `tid` int(11) unsigned NOT NULL COMMENT '标段id',
+    `sid` int(11) unsigned NOT NULL COMMENT '期id',
+    `sorder` tinyint(4) unsigned NOT NULL COMMENT '期序号',
+    `uuid` varchar(36) CHARACTER SET ascii NOT NULL COMMENT '安全生产标识id',
+    `add_sid` int(11) unsigned NOT NULL COMMENT '新增期id',
+    `add_uid` int(11) NOT NULL COMMENT '新增人id',
+    `add_time` datetime NOT NULL COMMENT '新增时间',
+    `order` int(11) unsigned NOT NULL COMMENT '排序',
+    `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '名称',
+    `unit` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '单位',
+    `unit_price` decimal(24,8) DEFAULT NULL COMMENT '单价',
+    `qty` decimal(24,8) DEFAULT NULL COMMENT '本期-数量',
+    `tp` decimal(24,8) DEFAULT NULL COMMENT '本期-金额',
+    `shistory` text CHARACTER SET utf8 COMMENT '本期历史数据',
+    `pre_used` tinyint(4) DEFAULT '0' COMMENT '往期是否使用',
+    `memo` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '备注',
+    PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+CREATE TABLE `zh_stage_detail_attachment` (
+    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+    `tid` int(11) unsigned NOT NULL COMMENT '标段id',
+    `sid` int(11) unsigned NOT NULL COMMENT '标段id',
+    `sorder` tinyint(4) unsigned NOT NULL COMMENT '期序号',
+    `uuid` varchar(50) CHARACTER SET ascii NOT NULL COMMENT '中间计量附件标识uuid',
+    `lid` varchar(50) CHARACTER SET ascii NOT NULL COMMENT '台账id(标识)',
+    `pid` varchar(50) CHARACTER SET ascii NOT NULL COMMENT '计量单元id(标识)',
+    `code` varchar(50) CHARACTER SET utf8 DEFAULT NULL COMMENT '编号(标识)',
+    `name` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '名称(标识)',
+    `unit` varchar(20) CHARACTER SET utf8 DEFAULT NULL COMMENT '单位(标识)',
+    `unit_price` decimal(24,8) DEFAULT NULL COMMENT '单价(标识)',
+    `pos_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '计量单元名称(标识)',
+    `im_type` tinyint(1) NOT NULL COMMENT '中间计量类型(标识)',
+    `attachment` text CHARACTER SET utf8 COMMENT '附件',
+    PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;