Преглед изворни кода

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

Tony Kang пре 2 година
родитељ
комит
117f79d929

+ 5 - 5
app/controller/stage_extra_controller.js

@@ -50,7 +50,7 @@ module.exports = app => {
         async loadJgcl (ctx) {
             try {
                 const data = await ctx.service.stageJgcl.getStageData(ctx.stage);
-                const preData = await ctx.service.stageJgcl.getPreStageData(ctx.stage.order);
+                const preData = await ctx.service.stageJgcl.getPreStageData(ctx.stage.tid, ctx.stage.order);
                 for (const d of data) {
                     const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
                     if (pd) {
@@ -115,7 +115,7 @@ module.exports = app => {
                         pf.username = (await ctx.service.projectAccount.getAccountInfoById(pf.uid)).name;
                     }
                 }
-                const preData = await ctx.service.stageBonus.getPreStageData(ctx.stage.order);
+                const preData = await ctx.service.stageBonus.getPreStageData(ctx.stage.tid, ctx.stage.order);
                 for (const d of preData) {
                     for (const pf of d.proof_file) {
                         delete pf.filepath;
@@ -168,7 +168,7 @@ module.exports = app => {
         async loadOther (ctx) {
             try {
                 const data = await ctx.service.stageOther.getStageData(ctx.stage);
-                const preData = await ctx.service.stageOther.getPreStageData(ctx.stage.order);
+                const preData = await ctx.service.stageOther.getPreStageData(ctx.stage.tid, ctx.stage.order);
                 for (const d of data) {
                     const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
                     if (pd) {
@@ -222,7 +222,7 @@ module.exports = app => {
         async loadSafeProd (ctx) {
             try {
                 const data = await ctx.service.stageSafeProd.getStageData(ctx.stage);
-                const preData = await ctx.service.stageSafeProd.getPreStageData(ctx.stage.order);
+                const preData = await ctx.service.stageSafeProd.getPreStageData(ctx.stage.tid, ctx.stage.order);
                 for (const d of data) {
                     const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
                     if (pd) {
@@ -278,7 +278,7 @@ module.exports = app => {
         async loadTempLand (ctx) {
             try {
                 const data = await ctx.service.stageTempLand.getStageData(ctx.stage);
-                const preData = await ctx.service.stageTempLand.getPreStageData(ctx.stage.order);
+                const preData = await ctx.service.stageTempLand.getPreStageData(ctx.stage.tid, ctx.stage.order);
                 for (const d of data) {
                     const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
                     if (pd) {

+ 1 - 1
app/public/js/path_tree.js

@@ -1104,7 +1104,7 @@ const createNewPathTree = function (type, setting) {
 
                 if (node.code.indexOf('-') >= 0) {
                     return '07';
-                } else if (node.code.length > 5) {
+                } else if (node.code.length >= 5) {
                     const num = _.toNumber(node.code);
                     if (num && num > 10000) return '18';
                 }

+ 4 - 0
app/service/project_account.js

@@ -601,6 +601,10 @@ module.exports = app => {
                     const sqlParam = [this.tableName, account, encryptPassword, accountId, 'SSO password'];
                     const operate = await this.transaction.query(sql, sqlParam);
                     result = operate.affectedRows > 0;
+                    // 判断账号是否为管理员,则同步更新到项目表里
+                    if (accountData.is_admin) {
+                        await this.transaction.update(this.ctx.service.project.tableName, { id: accountData.project_id, user_account: account });
+                    }
                 } else {
                     const sql = 'UPDATE ?? SET password=? WHERE id=? AND password != ?;';
                     const sqlParam = [this.tableName, encryptPassword, accountId, 'SSO password'];

+ 5 - 5
app/service/report_memory.js

@@ -1213,7 +1213,7 @@ module.exports = app => {
                 await this.ctx.service.stage.checkStage(sid);
 
                 const data = await this.ctx.service.stageJgcl.getStageData(this.ctx.stage);
-                const preData = await this.ctx.service.stageJgcl.getPreStageData(this.ctx.stage.order);
+                const preData = await this.ctx.service.stageJgcl.getPreStageData(tid, this.ctx.stage.order);
                 for (const d of data) {
                     const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
                     if (pd) {
@@ -1238,7 +1238,7 @@ module.exports = app => {
                 await this.ctx.service.tender.checkTender(tid);
                 await this.ctx.service.stage.checkStage(sid);
 
-                const data = await this.ctx.service.stageBonus.getEndStageData(this.ctx.stage.order);
+                const data = await this.ctx.service.stageBonus.getEndStageData(tid, this.ctx.stage.order);
                 for (const d of data) {
                     const names = this.ctx.helper._.map(d.proof_file, function (x) {
                         return x.filename + x.fileext;
@@ -1257,7 +1257,7 @@ module.exports = app => {
                 await this.ctx.service.stage.checkStage(sid);
 
                 const data = await this.ctx.service.stageOther.getStageData(this.ctx.stage);
-                const preData = await this.ctx.service.stageOther.getPreStageData(this.ctx.stage.order);
+                const preData = await this.ctx.service.stageOther.getPreStageData(tid, this.ctx.stage.order);
                 for (const d of data) {
                     const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
                     if (pd) {
@@ -1277,7 +1277,7 @@ module.exports = app => {
                 await this.ctx.service.stage.checkStage(sid);
 
                 const data = await this.ctx.service.stageSafeProd.getStageData(this.ctx.stage);
-                const preData = await this.ctx.service.stageSafeProd.getPreStageData(this.ctx.stage.order);
+                const preData = await this.ctx.service.stageSafeProd.getPreStageData(tid, this.ctx.stage.order);
                 for (const d of data) {
                     const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
                     if (pd) {
@@ -1299,7 +1299,7 @@ module.exports = app => {
                 await this.ctx.service.stage.checkStage(sid);
 
                 const data = await this.ctx.service.stageTempLand.getStageData(this.ctx.stage);
-                const preData = await this.ctx.service.stageTempLand.getPreStageData(this.ctx.stage.order);
+                const preData = await this.ctx.service.stageTempLand.getPreStageData(tid, this.ctx.stage.order);
                 for (const d of data) {
                     const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
                     if (pd) {

+ 10 - 9
app/service/rpt_gather_memory.js

@@ -1266,7 +1266,7 @@ module.exports = app => {
 
         async _gatherStageJgcl(tender, stage) {
             const data = await this.ctx.service.stageJgcl.getStageData(stage);
-            const preData = stage.order > 1 ? await this.ctx.service.stageJgcl.getPreStageData(stage.order) : 0;
+            const preData = stage.order > 1 ? await this.ctx.service.stageJgcl.getPreStageData(stage.tid, stage.order) : 0;
             for (const d of data) {
                 const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
                 if (pd) {
@@ -1331,7 +1331,7 @@ module.exports = app => {
         }
 
         async _gatherStageBonus(tender, stage) {
-            const data = await this.ctx.service.stageBonus.getEndStageData(stage.order);
+            const data = await this.ctx.service.stageBonus.getEndStageData(tender.id, stage.order);
             for (const d of data) {
                 const names = this.ctx.helper._.map(d.proof_file, function (x) {
                     return x.filename + x.fileext;
@@ -1369,6 +1369,7 @@ module.exports = app => {
             this.resultStageBonus = [];
             const gsSetting = JSON.parse(gsDefine.setting);
             for (const tender of gsCustom.tenders) {
+                console.log(tender, gsSetting.type);
                 switch (gsSetting.type) {
                     case 'month':
                         await this._gatherMonthStageBonus(tender, gsCustom.month);
@@ -1389,7 +1390,7 @@ module.exports = app => {
 
         async _gatherStageOther(tender, stage) {
             const data = await this.ctx.service.stageOther.getStageData(stage);
-            const preData = stage.order > 1 ? await this.ctx.service.stageOther.getPreStageData(stage.order) : [];
+            const preData = stage.order > 1 ? await this.ctx.service.stageOther.getPreStageData(stage.tid, stage.order) : [];
             for (const d of data) {
                 const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
                 if (pd) {
@@ -1448,7 +1449,7 @@ module.exports = app => {
 
         async _gatherStageSafeProd(tender, stage) {
             const data = await this.ctx.service.stageSafeProd.getStageData(stage);
-            const preData = stage.order > 1 ? await this.ctx.service.stageSafeProd.getPreStageData(stage.order) : [];
+            const preData = stage.order > 1 ? await this.ctx.service.stageSafeProd.getPreStageData(stage.tid, stage.order) : [];
             for (const d of data) {
                 const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
                 if (pd) {
@@ -1461,11 +1462,11 @@ module.exports = app => {
             const helper = this.ctx.helper;
             for (const d of data) {
                 let gd = this.resultStageSafeProd.find(x => {
-                    return x.name === d.name && x.unit === d.unit && helper.checkNumEqual(x.unit_price, d.unit_price);
+                    return x.name === d.name && x.unit === d.unit && helper.numEqual(x.unit_price, d.unit_price);
                 });
                 if (!gd) {
                     gd = { name: d.name, unit: d.unit, unit_price: d.unit_price };
-                    this.resultStageSafeProd.push(d);
+                    this.resultStageSafeProd.push(gd);
                 }
                 gd.s_quantity = helper.add(gd.s_quantity, d.quantity);
                 gd.s_total_price = helper.add(gd.s_total_price, d.total_price);
@@ -1527,7 +1528,7 @@ module.exports = app => {
 
         async _gatherStageTempLand(tender, stage) {
             const data = await this.ctx.service.stageTempLand.getStageData(stage);
-            const preData = stage.order > 1 ? await this.ctx.service.stageTempLand.getPreStageData(stage.order) : [];
+            const preData = stage.order > 1 ? await this.ctx.service.stageTempLand.getPreStageData(stage.tid, stage.order) : [];
             for (const d of data) {
                 const pd = this.ctx.helper._.find(preData, {uuid: d.uuid});
                 if (pd) {
@@ -1541,11 +1542,11 @@ module.exports = app => {
             const helper = this.ctx.helper;
             for (const d of data) {
                 let gd = this.resultStageTempLand.find(x => {
-                    return x.name === d.name && x.unit === d.unit && helper.checkNumEqual(x.unit_price, d.unit_price);
+                    return x.name === d.name && x.unit === d.unit && helper.numEqual(x.unit_price, d.unit_price);
                 });
                 if (!gd) {
                     gd = { name: d.name, unit: d.unit, unit_price: d.unit_price };
-                    this.resultStageTempLand.push(d);
+                    this.resultStageTempLand.push(gd);
                 }
                 gd.s_qty = helper.add(gd.s_qty, d.qty);
                 gd.s_tp = helper.add(gd.s_tp, d.tp);

+ 4 - 4
app/service/stage_bonus.js

@@ -49,17 +49,17 @@ module.exports = app => {
             return data;
         }
 
-        async getPreStageData(sorder) {
+        async getPreStageData(tid, sorder) {
             const sql = 'SELECT * From ' + this.tableName + ' WHERE sorder < ? And tid = ?';
-            const sqlParam = [sorder, this.ctx.tender.id];
+            const sqlParam = [sorder, tid];
             const data = await this.db.query(sql, sqlParam);
             this._parseData(data);
             return data;
         }
 
-        async getEndStageData(sorder) {
+        async getEndStageData(tid, sorder) {
             const sql = 'SELECT * From ' + this.tableName + ' WHERE sorder <= ? And tid = ? ORDER BY `sorder`, `order`';
-            const sqlParam = [sorder, this.ctx.tender.id];
+            const sqlParam = [sorder, tid];
             const data = await this.db.query(sql, sqlParam);
             this._parseData(data);
             return data;

+ 4 - 4
app/service/stage_jgcl.js

@@ -46,26 +46,26 @@ module.exports = app => {
             return data;
         }
 
-        async getPreStageData(sorder) {
+        async getPreStageData(tid, sorder) {
             const sql = 'SELECT c.uuid, Sum(c.arrive_qty) as arrive_qty, Sum(c.arrive_tp) as arrive_tp,' +
                 '    Sum(c.deduct_qty) as deduct_qty, Sum(c.deduct_tp) as deduct_tp' +
                 '  From ' + this.tableName + ' c' +
                 '  LEFT JOIN ' + this.ctx.service.stage.tableName + ' s ON s.id = c.sid' +
                 '  WHERE s.`order` < ? And s.`tid` = ?' +
                 '  GROUP By uuid';
-            const sqlParam = [sorder, this.ctx.tender.id];
+            const sqlParam = [sorder, tid];
             const data = await this.db.query(sql, sqlParam);
             return data;
         }
 
-        async getEndStageData(sorder) {
+        async getEndStageData(tid, sorder) {
             const sql = 'SELECT c.uuid, Sum(c.arrive_qty) as arrive_qty, Sum(c.arrive_tp) as arrive_tp,' +
                 '    Sum(c.deduct_qty) as deduct_qty, Sum(c.deduct_tp) as deduct_tp' +
                 '  From ' + this.tableName + ' c' +
                 '  LEFT JOIN ' + this.ctx.service.stage.tableName + ' s ON s.id = c.sid' +
                 '  WHERE s.`order` <= ? And s.`tid` = ?' +
                 '  GROUP By uuid';
-            const sqlParam = [sorder, this.ctx.tender.id];
+            const sqlParam = [sorder, tid];
             const data = await this.db.query(sql, sqlParam);
             return data;
         }

+ 4 - 4
app/service/stage_other.js

@@ -36,24 +36,24 @@ module.exports = app => {
             return data;
         }
 
-        async getPreStageData(sorder) {
+        async getPreStageData(tid, sorder) {
             const sql = 'SELECT o.uuid, Sum(o.tp) as tp ' +
                 '  From ' + this.tableName + ' o ' +
                 '  LEFT JOIN ' + this.ctx.service.stage.tableName + ' s ON s.id = o.sid' +
                 '  WHERE s.order < ? And o.tid = ?' +
                 '  GROUP By uuid';
-            const sqlParam = [sorder, this.ctx.tender.id];
+            const sqlParam = [sorder, tid];
             const data = await this.db.query(sql, sqlParam);
             return data;
         }
 
-        async getEndStageData(sorder) {
+        async getEndStageData(tid, sorder) {
             const sql = 'SELECT o.uuid, Sum(o.tp) as tp ' +
                 '  From ' + this.tableName + ' o ' +
                 '  LEFT JOIN ' + this.ctx.service.stage.tableName + ' s ON s.id = o.sid' +
                 '  WHERE s.order <= ? And o.tid = ?' +
                 '  GROUP By uuid';
-            const sqlParam = [sorder, this.ctx.tender.id];
+            const sqlParam = [sorder, tid];
             const data = await this.db.query(sql, sqlParam);
             return data;
         }

+ 4 - 4
app/service/stage_safe_prod.js

@@ -39,24 +39,24 @@ module.exports = app => {
             return data;
         }
 
-        async getPreStageData(sorder) {
+        async getPreStageData(tid, sorder) {
             const sql = 'SELECT o.uuid, Sum(o.qty) as qty, Sum(o.tp) as tp ' +
                 '  From ' + this.tableName + ' o ' +
                 '  LEFT JOIN ' + this.ctx.service.stage.tableName + ' s ON s.id = o.sid' +
                 '  WHERE s.order < ? And o.tid = ?' +
                 '  GROUP By uuid';
-            const sqlParam = [sorder, this.ctx.tender.id];
+            const sqlParam = [sorder, tid];
             const data = await this.db.query(sql, sqlParam);
             return data;
         }
 
-        async getEndStageData(sorder) {
+        async getEndStageData(tid, sorder) {
             const sql = 'SELECT o.uuid, Sum(o.qty) as qty, Sum(o.tp) as tp ' +
                 '  From ' + this.tableName + ' o ' +
                 '  LEFT JOIN ' + this.ctx.service.stage.tableName + ' s ON s.id = o.sid' +
                 '  WHERE s.order <= ? And o.tid = ?' +
                 '  GROUP By uuid';
-            const sqlParam = [sorder, this.ctx.tender.id];
+            const sqlParam = [sorder, tid];
             const data = await this.db.query(sql, sqlParam);
             return data;
         }

+ 4 - 4
app/service/stage_temp_land.js

@@ -39,24 +39,24 @@ module.exports = app => {
             return data;
         }
 
-        async getPreStageData(sorder) {
+        async getPreStageData(tid, sorder) {
             const sql = 'SELECT o.uuid, Sum(o.qty) as qty, Sum(o.tp) as tp ' +
                 '  From ' + this.tableName + ' o ' +
                 '  LEFT JOIN ' + this.ctx.service.stage.tableName + ' s ON s.id = o.sid' +
                 '  WHERE s.order < ? And o.tid = ?' +
                 '  GROUP By uuid';
-            const sqlParam = [sorder, this.ctx.tender.id];
+            const sqlParam = [sorder, tid];
             const data = await this.db.query(sql, sqlParam);
             return data;
         }
 
-        async getEndStageData(sorder) {
+        async getEndStageData(tid, sorder) {
             const sql = 'SELECT o.uuid, Sum(o.qty) as qty, Sum(o.tp) as tp ' +
                 '  From ' + this.tableName + ' o ' +
                 '  LEFT JOIN ' + this.ctx.service.stage.tableName + ' s ON s.id = o.sid' +
                 '  WHERE s.order <= ? And o.tid = ?' +
                 '  GROUP By uuid';
-            const sqlParam = [sorder, this.ctx.tender.id];
+            const sqlParam = [sorder, tid];
             const data = await this.db.query(sql, sqlParam);
             return data;
         }