coeList.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Created by CSL on 2017/5/3.
  3. * 系数表。
  4. */
  5. var mongoose = require("mongoose");
  6. var dbm = require("../../../config/db/db_manager");
  7. var db = dbm.getCfgConnection("rationRepository")
  8. var coeSchema = mongoose.Schema({
  9. coeType: String, // 系数类型,指作用范围:
  10. // 0 针对单个工料机。如:111量0.001
  11. // 1 人工类。 2 材料类。 3 机械类。
  12. // 9 针对本定额所有工料机。如:定额×0.925 (可以用123代替,但9的好处是前端不用做多余的过滤判断,提高效率)
  13. gljID: Number, // 要调整的工料机ID(当coeType=0时有效)
  14. operator: String, // 运算符(*、+、-、=)
  15. amount: String, // 调整的量
  16. _id: false
  17. });
  18. var coeListSchema = mongoose.Schema({
  19. libID: Number, // 所属定额定ID
  20. ID: Number, // 系数ID(流水号ID)
  21. name: String, // 名称
  22. content: String, // 说明
  23. coes: [coeSchema]
  24. });
  25. var coeListModel = db.model("coeLists",coeListSchema, "coeLists")
  26. var coeListDAO = function(){};
  27. coeListDAO.prototype.getCoe = function (data, callback) {
  28. coeListModel.findOne({
  29. "libID": data.libID,
  30. "ID": data.ID,
  31. "$or": [{"isDeleted": null}, {"isDeleted": false}]
  32. },
  33. function (err, doc) {
  34. if (err) callback(true, "获取系数明细错误!", "")
  35. else callback(false, "获取系数明细成功", doc);
  36. })
  37. };
  38. module.exports = new coeListDAO();