Ver código fonte

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

Tony Kang 3 anos atrás
pai
commit
13614ebc51

+ 11 - 2
app/controller/material_controller.js

@@ -496,7 +496,7 @@ module.exports = app => {
                     const materialListData = await ctx.service.materialList.getMaterialData(ctx.tender.id, lastMaterial.id);
                     const hadBillsList = [];
                     for (const ml of materialListData) {
-                        const hb = _.find(hadBillsList, { gcl_id: ml.gcl_id, mb_id: ml.mb_id });
+                        const hb = _.find(hadBillsList, {gcl_id: ml.gcl_id, mb_id: ml.mb_id});
                         if (!hb) {
                             hadBillsList.push({
                                 gcl_id: ml.gcl_id,
@@ -509,9 +509,18 @@ module.exports = app => {
                     }
                     // 批量插入并修改is_new值
                     await ctx.service.materialListGcl.setData(lastMaterial.id, hadBillsList);
+                    // responseData.data.gclList = hadBillsList;
+                }
+                // } else {
+                // 判断是否是最新期,不是则获取的gclList是由materialList拼接而成,
+                if (lastMaterial.id === ctx.material.id) {
+                    const hadBillsList = await ctx.service.materialListGcl.getAllDataByCondition({ where: { tid: ctx.tender.id } });
                     responseData.data.gclList = hadBillsList;
                 } else {
-                    const hadBillsList = await ctx.service.materialListGcl.getAllDataByCondition({ where: { tid: ctx.tender.id } });
+                    const materialList = await this.ctx.service.materialList.getAllDataByCondition({ where: { mid: ctx.material.id, is_self: 0 } });
+                    const hadBillsList = ctx.app._.unionWith(materialList, function(item1, item2) {
+                        return item1.gcl_id === item2.gcl_id && item1.mb_id === item2.mb_id;
+                    });
                     responseData.data.gclList = hadBillsList;
                 }
                 ctx.body = responseData;

+ 7 - 3
app/lib/rm/material.js

@@ -245,6 +245,10 @@ class ReportMemoryMaterial {
         try {
 
             const billsData = await this.ctx.service.ledger.getData(tender_id);
+            const curStageBills = await this.ctx.service.stageBills.getStagesData(tender_id, material.stage_id);
+            this.ctx.helper.assignRelaData(billsData, [
+                { data: curStageBills, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid' },
+            ]);
             const billsTree = this._getNewBillsTree();
             billsTree.loadDatas(billsData);
             billsTree.calculateAll();
@@ -252,7 +256,7 @@ class ReportMemoryMaterial {
             const posData = await this.ctx.service.pos.getPosData({ tid: tender_id });
             const curStage = await this.ctx.service.stagePos.getStagesData(tender_id, material.stage_id);
             this.ctx.helper.assignRelaData(posData, [
-                { data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'pid' },
+                { data: curStage, fields: ['contract_qty', 'qc_qty'], prefix: '', relaId: 'pid' },
             ]);
             const pos = this._getNewPos();
             pos.loadDatas(posData);
@@ -272,11 +276,11 @@ class ReportMemoryMaterial {
                 for (const x of g.leafXmjs) {
                     x.jiacha = 0;
                     const mnj = materialNotJoin.find(m => {
-                        return m.gcl_id === x.org_gcl_id && m.xmj_id === x.id && (x.mx_id ? x.mx_id === m.mx_id : true);
+                        return m.gcl_id === x.org_gcl_id && m.xmj_id === x.id && (x.mx_id && x.mx_id !== x.id  ? x.mx_id === m.mx_id : true);
                     });
                     if (mnj) continue;
                     const list = materialGl.filter(g => {
-                        return g.gcl_id === x.org_gcl_id && g.xmj_id === x.id && (x.mx_id ? x.mx_id === g.mx_id : true);
+                        return g.gcl_id === x.org_gcl_id && g.xmj_id === x.id && (x.mx_id && x.mx_id !== x.id ? x.mx_id === g.mx_id : true);
                     });
                     for (const l of list) {
                         x.jiacha = helper.add(x.jiacha, helper.mul(helper.mul(x.gather_qty, l.quantity), l.m_spread));

+ 9 - 9
app/public/js/material_list.js

@@ -41,10 +41,10 @@ function getMpSpreadByMBData(id) {
     return info ? info.m_spread : 0;
 }
 
-function getMaterialListByLeafXmj(gcl_id, xmj_id, mx_id = null) {
+function getMaterialListByLeafXmj(gcl_id, xmj_id, mx_id = '') {
     const list = [];
     for (const ml of materialListData) {
-        if (gcl_id === ml.gcl_id && xmj_id === ml.xmj_id && (mx_id === null || mx_id === ml.mx_id)) {
+        if (gcl_id === ml.gcl_id && xmj_id === ml.xmj_id && (mx_id === '' || mx_id === ml.mx_id)) {
             list.push(ml);
         }
     }
@@ -224,7 +224,7 @@ $(document).ready(() => {
                     indent: 16,
                     getColor: function (index, data) {
                         if (!data) return;
-                        if (_.findIndex(selfList, { gcl_id: data.gcl_id, xmj_id: data.id, mx_id: (data.mx_id ? data.mx_id : null) }) !== -1) {
+                        if (_.findIndex(selfList, { gcl_id: data.gcl_id, xmj_id: data.id, mx_id: (data.mx_id ? data.mx_id : '') }) !== -1) {
                             return '#dc3545';
                         }
                     }
@@ -484,7 +484,7 @@ $(document).ready(() => {
             const xmj = leafXmjs[iLXmjRow];
             console.log(xmj, iLXmjRow);
             materialListSelf = [];
-            if (_.findIndex(selfList, { gcl_id: xmj.gcl_id, xmj_id: xmj.id, mx_id: (xmj.mx_id ? xmj.mx_id : null) }) != -1) {
+            if (_.findIndex(selfList, { gcl_id: xmj.gcl_id, xmj_id: xmj.id, mx_id: (xmj.mx_id ? xmj.mx_id : '') }) != -1) {
                 for (const m of materialListData) {
                     if (m.gcl_id === xmj.gcl_id && m.xmj_id === xmj.id && ((xmj.mx_id !==undefined && m.mx_id === xmj.mx_id) || xmj.mx_id === undefined)) {
                         materialListSelf.push(m);
@@ -582,7 +582,7 @@ $(document).ready(() => {
                 const data = {
                     xmj_id: xmj.id,
                     gcl_id: xmj.gcl_id,
-                    mx_id: xmj.mx_id ? xmj.mx_id : null,
+                    mx_id: xmj.mx_id ? xmj.mx_id : '',
                     gather_qty: xmj.gather_qty,
                     is_join: notx === undefined ? 1 : 0,
                 };
@@ -617,7 +617,7 @@ $(document).ready(() => {
             const data = {
                 xmj_id: xmj.id,
                 gcl_id: xmj.gcl_id,
-                mx_id: xmj.mx_id ? xmj.mx_id : null,
+                mx_id: xmj.mx_id ? xmj.mx_id : '',
                 mb_id: mb_id,
                 gather_qty: xmj.gather_qty,
                 is_join: notx === undefined ? 1 : 0,
@@ -809,7 +809,7 @@ $(document).ready(() => {
                     const data = {
                         xmj_id: xmj.id,
                         gcl_id: xmj.gcl_id,
-                        mx_id: xmj.mx_id ? xmj.mx_id : null,
+                        mx_id: xmj.mx_id ? xmj.mx_id : '',
                     };
                     datas.push(data);
                 }
@@ -911,7 +911,7 @@ $(document).ready(() => {
                         const data = {
                             xmj_id: xmj.id,
                             gcl_id: xmj.gcl_id,
-                            mx_id: xmj.mx_id ? xmj.mx_id : null,
+                            mx_id: xmj.mx_id ? xmj.mx_id : '',
                         };
                         datas.push(data);
                     }
@@ -1040,7 +1040,7 @@ $(document).ready(() => {
                     const data2 = {
                         xmj_id: xmj.id,
                         gcl_id: xmj.gcl_id,
-                        mx_id: xmj.mx_id ? xmj.mx_id : null,
+                        mx_id: xmj.mx_id ? xmj.mx_id : '',
                     };
                     datas.push(data2);
                 }

+ 3 - 2
app/service/material_list.js

@@ -153,7 +153,7 @@ module.exports = app => {
                             mid: this.ctx.material.id,
                             gcl_id: xmj.gcl_id,
                             xmj_id: xmj.id,
-                            mx_id: xmj.mx_id ? xmj.mx_id : [null, ''],
+                            mx_id: xmj.mx_id,
                         },
                     });
                     const mbIdList = this._.map(mlList, 'mb_id');
@@ -167,7 +167,7 @@ module.exports = app => {
                             mb_id: mb.mb_id,
                             gcl_id: xmj.gcl_id,
                             xmj_id: xmj.id,
-                            mx_id: xmj.mx_id ? xmj.mx_id : '',
+                            mx_id: xmj.mx_id,
                             gather_qty: xmj.gather_qty ? xmj.gather_qty : null,
                             quantity: mb.quantity,
                             expr: mb.expr,
@@ -548,6 +548,7 @@ module.exports = app => {
                         });
                     }
                 }
+                console.log(updateDatas);
                 if (updateDatas.length > 0) await transaction.updateRows(this.tableName, updateDatas);
                 if (updateListGcl.length > 0) await transaction.updateRows(this.service.materialListGcl.tableName, updateListGcl);
                 await this.calcQuantityByML(transaction, mb_id);

+ 1 - 1
app/service/material_list_gcl.js

@@ -80,7 +80,7 @@ module.exports = app => {
             if (order >= 1) {
                 // 获取上一期的list值
                 const materialInfo = await this.ctx.service.material.getDataByCondition({ tid, order });
-                const materialList = await this.ctx.service.materialList.getAllDataByCondition({ where: { mid: materialInfo.id } });
+                const materialList = await this.ctx.service.materialList.getAllDataByCondition({ where: { mid: materialInfo.id, is_self: 0 } });
                 const lastMaterialGclList = this._.unionWith(materialList, function(item1, item2) {
                     return item1.gcl_id === item2.gcl_id && item1.mb_id === item2.mb_id;
                 });

+ 6 - 5
app/service/material_list_notjoin.js

@@ -37,11 +37,11 @@ module.exports = app => {
                     mid: this.ctx.material.id,
                     gcl_id: data.gcl_id,
                     xmj_id: data.id,
-                    mx_id: data.mx_id !== undefined ? data.mx_id : null,
+                    mx_id: data.mx_id ? data.mx_id : '',
                     in_time: new Date(),
                 };
                 data.xmj_id = data.id;
-                data.mx_id = data.mx_id !== undefined ? data.mx_id : null;
+                data.mx_id = data.mx_id ? data.mx_id : '';
                 await this.updateAllMaterials(transaction, data, 'add');
                 // 新增不参与调差清单
                 const result = await transaction.insert(this.tableName, newListNotJoin);
@@ -90,10 +90,11 @@ module.exports = app => {
                 mid: this.ctx.material.id,
                 gcl_id: data.gcl_id,
                 xmj_id: data.xmj_id,
+                mx_id: data.mx_id,
             };
-            if (data.mx_id !== null) {
-                searchSql.mx_id = data.mx_id;
-            }
+            // if (data.mx_id !== '') {
+            //     searchSql.mx_id = data.mx_id;
+            // }
             const materialListData = await this.ctx.service.materialList.getAllDataByCondition({
                 where: searchSql,
             });

+ 7 - 6
app/service/material_list_self.js

@@ -37,7 +37,7 @@ module.exports = app => {
                     mid: this.ctx.material.id,
                     gcl_id: data.gcl_id,
                     xmj_id: data.id,
-                    mx_id: data.mx_id !== undefined ? data.mx_id : null,
+                    mx_id: data.mx_id ? data.mx_id : '',
                     in_time: new Date(),
                 };
                 // 更新list表为is_self为1
@@ -47,7 +47,7 @@ module.exports = app => {
                         mid: this.ctx.material.id,
                         gcl_id: data.gcl_id,
                         xmj_id: data.id,
-                        mx_id: data.mx_id ? data.mx_id : null,
+                        mx_id: data.mx_id ? data.mx_id : '',
                     },
                 });
                 // data.xmj_id = data.id;
@@ -100,10 +100,11 @@ module.exports = app => {
                 mid: this.ctx.material.id,
                 gcl_id: data.gcl_id,
                 xmj_id: data.xmj_id,
+                mx_id: data.mx_id,
             };
-            if (data.mx_id !== null) {
-                searchSql.mx_id = data.mx_id;
-            }
+            // if (data.mx_id !== null) {
+            //     searchSql.mx_id = data.mx_id;
+            // }
             const materialListData = await this.ctx.service.materialList.getAllDataByCondition({
                 where: searchSql,
             });
@@ -121,7 +122,7 @@ module.exports = app => {
                     mid: this.ctx.material.id,
                     gcl_id: data.gcl_id,
                     xmj_id: data.xmj_id,
-                    mx_id: data.mx_id ? data.mx_id : null,
+                    mx_id: data.mx_id ? data.mx_id : '',
                 });
                 const materialListGclData = await this.ctx.service.materialListGcl.getAllDataByCondition({
                     where: { tid: this.ctx.tender.id, gcl_id: data.gcl_id },

+ 1 - 1
app/service/stage_change_final.js

@@ -61,7 +61,7 @@ module.exports = app => {
                 if (!c.qty) continue;
 
                 data.push({
-                    tid: c.tid, sid: c.sid,
+                    tid: c.tid, sid: c.sid, sorder: stage.order,
                     lid: c.lid, pid: c.pid, cid: c.cid, cbid: c.cbid,
                     qty: c.qty,
                 });

+ 14 - 2
sql/update.sql

@@ -71,7 +71,11 @@ UPDATE `zh_material` SET `exponent_rate`=`rate`;
 
 ALTER TABLE `zh_material_list` ADD `is_self` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '是否为单独添加的工料清单关联' AFTER `is_join`;
 
-UPDATE `zh_material_list` SET `mx_id`= null WHERE `mx_id` = '';
+UPDATE `zh_material_list` SET `mx_id`= '' WHERE `mx_id` is null;
+
+ALTER TABLE `zh_material_list_notjoin` CHANGE `mx_id` `mx_id` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT '' COMMENT '部位明细id';
+
+UPDATE `zh_material_list_notjoin` SET `mx_id`= '' WHERE `mx_id` is null;
 
 CREATE TABLE `zh_material_list_self`  (
   `id` int(11) NOT NULL AUTO_INCREMENT,
@@ -79,7 +83,7 @@ CREATE TABLE `zh_material_list_self`  (
   `mid` int(11) NOT NULL COMMENT '调差期id',
   `gcl_id` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '清单id',
   `xmj_id` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '项目节id',
-  `mx_id` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '部位明细id',
+  `mx_id` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT '' COMMENT '部位明细id',
   `in_time` datetime NOT NULL COMMENT '添加时间',
   PRIMARY KEY (`id`) USING BTREE
 ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '单独调差的清单表';
@@ -87,3 +91,11 @@ CREATE TABLE `zh_material_list_self`  (
 ALTER TABLE `zh_advance_pay`
 ADD COLUMN `selected`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '报表用,是否选择' AFTER `id`;
 
+ALTER TABLE `zh_stage_change_final`
+ADD COLUMN `sorder`  int(11) UNSIGNED NOT NULL AFTER `sid`;
+
+Update zh_stage_change_final scf Join zh_stage s on scf.sid = s.id Set scf.sorder = s.`order`;
+
+ALTER TABLE `zh_change` ADD `order_by` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '清单排序规则,默认按清单编号排(0),自定义排序(1)' AFTER `is_revise`;
+ALTER TABLE `zh_change_audit_list` ADD `order` INT NULL DEFAULT NULL COMMENT '排序序号(自定义规则时使用)' AFTER `spamount`;
+