std_glj_lib_map_model.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * 工料机库业务逻辑
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/8/16
  6. * @version
  7. */
  8. import BaseModel from "../../common/base/base_model";
  9. import mongoose from "mongoose";
  10. const STDGLJLibMapSchema = mongoose.model("std_glj_lib_map");
  11. class STDGLJLibMapModel extends BaseModel {
  12. /**
  13. * 构造函数
  14. *
  15. * @return {void}
  16. */
  17. constructor() {
  18. let parent = super();
  19. parent.model = STDGLJLibMapSchema;
  20. parent.init();
  21. }
  22. /**
  23. * 获取对应的工料机库
  24. *
  25. * @param {String} compilationId
  26. * @return {Promise}
  27. */
  28. async getGLJLibList(compilationId) {
  29. let result = [];
  30. let gliLib = await this.findDataByCondition(
  31. { deleted: false, compilationId: compilationId.toString() },
  32. null,
  33. false
  34. );
  35. if (gliLib.length <= 0) {
  36. return result;
  37. }
  38. // 整理数据
  39. let gljList = [];
  40. for (let tmp of gliLib) {
  41. let tmpRation = { id: tmp.ID, name: tmp.dispName };
  42. if (gljList.length <= 0) {
  43. gljList = [tmpRation];
  44. } else {
  45. gljList.push(tmpRation);
  46. }
  47. }
  48. result = gljList;
  49. return result;
  50. }
  51. /**
  52. * 获取所有未删除的的工料机库
  53. *
  54. * @param {String} compilationId
  55. * @return {Promise}
  56. */
  57. async getAllGLJLibList() {
  58. let result = [];
  59. let gliLib = await this.findDataByCondition(
  60. { deleted: false },
  61. null,
  62. false
  63. );
  64. if (gliLib.length <= 0) {
  65. return result;
  66. }
  67. // 整理数据
  68. let gljList = [];
  69. for (let tmp of gliLib) {
  70. let tmpRation = { id: tmp.ID, name: tmp.dispName };
  71. if (gljList.length <= 0) {
  72. gljList = [tmpRation];
  73. } else {
  74. gljList.push(tmpRation);
  75. }
  76. }
  77. result = gljList;
  78. return result;
  79. }
  80. }
  81. export default STDGLJLibMapModel;