zhongzewei 7 anni fa
parent
commit
943d01e101
2 ha cambiato i file con 56 aggiunte e 4 eliminazioni
  1. 50 0
      modules/all_models/mix_ratio.js
  2. 6 4
      modules/sys_tools/models/sys_model.js

+ 50 - 0
modules/all_models/mix_ratio.js

@@ -0,0 +1,50 @@
+/**
+ * 配合比数据结构
+ *
+ * @author CaiAoLin
+ * @date 2017/7/12
+ * @version
+ */
+import mongoose from "mongoose";
+
+let Schema = mongoose.Schema;
+let collectionName = 'mix_ratio';
+let modelSchema = {
+    // 自增id
+    id: Number,
+    // 消耗量(有别于总消耗,此字段记录配合比的消耗量)
+    consumption: {
+        type: String,
+        default: 0
+    },
+    // 工料机总库对应id (关联用)
+    glj_id: {
+        type: Number,
+        index: true
+    },
+    // 单价文件表id (因为选择单价文件后配合比数据也需要同步,所以记录单价文件id)
+    unit_price_file_id: Number,
+    // 关联项目工料机的key 不能关联id,因为单价文件导入别的项目后项目工料机id不同
+    connect_key: {
+        type: String,
+        index: true
+    },
+    // 规格型号
+    specs: {
+        type: String,
+        default: ''
+    },
+    // 单位
+    unit: String,
+    // 名称
+    name: {
+        type: String,
+        index: true,
+        default: ''
+    },
+    // 对应工料机code
+    code: String,
+    // 工料机类型
+    type: Number
+};
+mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));

+ 6 - 4
modules/sys_tools/models/sys_model.js

@@ -25,6 +25,7 @@ const rationInstallationModel = mongoose.model('ration_installation');
 const quantityDetailModel = mongoose.model('quantity_detail');
 const unitPriceFileModel = mongoose.model('unit_price_file');
 const unitPriceModel = mongoose.model('unit_price');
+const mixRatioModel = mongoose.model('mix_ratio');
 const feeRateFileModel = mongoose.model('fee_rate_file');
 const feeRateModel = mongoose.model('fee_rates');
 
@@ -94,7 +95,7 @@ async function clearJunkData(callback){
             unitPriceModel.remove({unit_price_file_id: {$in: junkUFIds}}, cb);
         });
         functions.push(function(cb){
-            unitPriceFileModel.remove({id: {$in: junkUFIds}}, cb);
+            mixRatioModel.remove({unit_price_file_id: {$in: junkUFIds}}, cb);
         });
     }
     //彻底删除了的费率文件
@@ -107,9 +108,6 @@ async function clearJunkData(callback){
         functions.push(function(cb){
             feeRateModel.remove({ID: {$in: junkFFIds}}, cb);
         });
-        functions.push(function(cb){
-            feeRateFileModel.remove({feeRateID: {$in: junkFFIds}}, cb);
-        });
     }
     //清除
     if(functions.length > 0){
@@ -117,6 +115,10 @@ async function clearJunkData(callback){
             if(!err){
                 //清除项目
                 await projectModel.remove({ID: {$in: junkProjIds}});
+                //清除单价文件
+                await unitPriceFileModel.remove({id: {$in: junkUFIds}});
+                //清除费率文件
+                await feeRateFileModel.remove({feeRateID: {$in: junkFFIds}});
             }
             if(callback){
                 callback(err);