Browse Source

1.单价文件数据以及组成物数据表新增字段
2.修复组成物接口返回的bug

olym 7 years ago
parent
commit
4b2909aaf5

+ 9 - 8
modules/glj/controllers/glj_controller.js

@@ -458,24 +458,25 @@ class GLJController extends BaseController {
             compositionData = JSON.parse(JSON.stringify(compositionData));
             // 查找对应的单价数据
             let unitPriceModel = new UnitPriceModel();
-            let unitPriceData = await unitPriceModel.findDataByCondition({unit_price_file_id: currentUnitPriceId}, null, false, 'code');
+            let unitPriceData = await unitPriceModel.findDataByCondition({unit_price_file_id: currentUnitPriceId}, null, false, 'glj_id');
 
             // 整理数据
             let result = {};
             for(let composition of compositionData) {
+                let tmpId = composition.glj_id !== undefined ? composition.glj_id : -1;
                 let tmpData = {
-                    market_price: unitPriceData[composition.connect_code] !== undefined ?
-                        unitPriceData[composition.connect_code].market_price : 0,
-                    base_price: unitPriceData[composition.connect_code] !== undefined ?
-                        unitPriceData[composition.connect_code].base_price : 0,
+                    market_price: unitPriceData[tmpId] !== undefined ?
+                        unitPriceData[tmpId].market_price : 0,
+                    base_price: unitPriceData[tmpId] !== undefined ?
+                        unitPriceData[tmpId].base_price : 0,
                     consumption: composition.consumption,
                     glj_type: composition.glj_type,
                     connect_code: composition.connect_code
                 };
-                if (result[composition.connect_code] === undefined) {
-                    result[composition.connect_code] = [];
+                if (result[tmpId] === undefined) {
+                    result[tmpId] = [];
                 }
-                result[composition.connect_code].push(tmpData);
+                result[tmpId].push(tmpData);
             }
             responseData.data = result;
         } catch (error) {

+ 3 - 1
modules/glj/models/glj_list_model.js

@@ -439,7 +439,8 @@ class GLJListModel extends BaseModel {
                 glj_id: tmp.ID,
                 unit_price_file_id: unitPriceFileId,
                 connect_code: tmp.connectCode,
-                glj_type: tmp.gljType
+                glj_type: tmp.gljType,
+                code: tmp.code,
             };
             mixRatioInsertData.push(mixRatioData);
         }
@@ -484,6 +485,7 @@ class GLJListModel extends BaseModel {
                 unit_price_file_id: unitPriceFileId,
                 type: tmp.gljType,
                 short_name: tmp.shortName === undefined ? '' : tmp.shortName,
+                glj_id: tmp.ID,
             };
             unitPriceInsertData.push(unitPriceData);
         }

+ 3 - 0
modules/glj/models/schemas/mix_ratio.js

@@ -29,6 +29,9 @@ let modelSchema = {
         type: String,
         index: true
     },
+    // 对应工料机code
+    code: String,
+    // 工料机类型
     glj_type: Number
 };
 let model = mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));

+ 2 - 0
modules/glj/models/schemas/unit_price.js

@@ -32,6 +32,8 @@ let modelSchema = {
     short_name: String,
     // 单价文件表id
     unit_price_file_id: Number,
+    // 对应标准库工料机id
+    glj_id: Number
 };
 let model = mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
 export {model as default, collectionName as collectionName};

+ 2 - 2
modules/glj/models/unit_price_model.js

@@ -107,7 +107,6 @@ class UnitPriceModel extends BaseModel {
             data.name = regular.test(data.name) ? data.name.replace(regular, changeString) :
                 data.name + changeString;
         }
-
         let insertData = {
             code: data.code,
             base_price: data.base_price,
@@ -115,7 +114,8 @@ class UnitPriceModel extends BaseModel {
             unit_price_file_id: unitPriceFileId,
             name: data.name,
             type: data.type,
-            short_name: data.shortName !== undefined ? data.shortName : ''
+            short_name: data.shortName !== undefined ? data.shortName : '',
+            glj_id: data.glj_id
         };
 
         let addPriceResult = await this.add(insertData);