第二代基于事件的高级计划排程引擎
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
4.6 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. // Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
  2. package models
  3. import (
  4. "errors"
  5. "leit.com/aps_engine/db"
  6. "leit.com/aps_engine/grmi"
  7. "xorm.io/core"
  8. )
  9. type WorkShiftEffLst struct {
  10. PlantNr int `xorm:"pk int 'PlantNr'" json:"WorkShiftEffLst-PlantNr"`
  11. WorkShiftNr int `xorm:"pk int 'WorkShiftNr'" json:"WorkShiftEffLst-WorkShiftNr"`
  12. LevelId string `xorm:"pk nvarchar(40) 'LevelId'" json:"WorkShiftEffLst-LevelId"`
  13. Descr string `xorm:"nvarchar(100) 'Descr'" json:"WorkShiftEffLst-Descr"`
  14. PlanPersonUclQty int `xorm:"int 'PlanPersonUclQty'" json:"WorkShiftEffLst-PlanPersonUclQty"`
  15. PlanPersonLclQty int `xorm:"int 'PlanPersonLclQty'" json:"WorkShiftEffLst-PlanPersonLclQty"`
  16. PlanEfficiency float64 `xorm:"float 'PlanEfficiency' not null" json:"WorkShiftEffLst-PlanEfficiency"`
  17. LastModify grmi.DateTime `xorm:"datetime 'LastModify' not null updated" json:"WorkShiftEffLst-LastModify"`
  18. LastUser string `xorm:"nvarchar(20) 'LastUser' not null" json:"WorkShiftEffLst-LastUser"`
  19. CreateTime grmi.DateTime `xorm:"datetime 'CreateTime' not null created" json:"WorkShiftEffLst-CreateTime"`
  20. }
  21. /******数据表名******/
  22. func (t *WorkShiftEffLst) TableName() string {
  23. return "Workshiftefflst"
  24. }
  25. /******************************************************************************
  26. *
  27. * @Function Name : GetKey
  28. *-----------------------------------------------------------------------------
  29. *
  30. * @Description : 获取实体的主键
  31. *
  32. * @Return Value : 实体的主键
  33. *
  34. * @Author : 代码生成器创建
  35. *
  36. * @Date : 2021-03-23 17:06:57
  37. *
  38. ******************************************************************************/
  39. func (self *WorkShiftEffLst) GetKey() core.PK {
  40. return core.PK{self.PlantNr, self.WorkShiftNr, self.LevelId}
  41. }
  42. /******************************************************************************
  43. *
  44. * @Function Name :
  45. *-----------------------------------------------------------------------------
  46. *
  47. * @Description : 数据添加
  48. *
  49. * @Function Parameters:
  50. *
  51. * @Return Value :
  52. *
  53. * @Author : Lou Wenzhi
  54. *
  55. * @Date : 2021/3/6 8:47
  56. *
  57. ******************************************************************************/
  58. func (t *WorkShiftEffLst) Add() error {
  59. e := db.Eloquent.Master()
  60. count := new(WorkShiftEffLst)
  61. affw, err := e.Table(t.TableName()).ID(t.GetKey()).Count(count)
  62. if err != nil {
  63. return err
  64. }
  65. if affw > 0 {
  66. return errors.New("数据已经存在!")
  67. }
  68. _, err = e.Table(t.TableName()).Insert(t)
  69. if err != nil {
  70. return err
  71. }
  72. return nil
  73. }
  74. /******************************************************************************
  75. *
  76. * @Function Name :
  77. *-----------------------------------------------------------------------------
  78. *
  79. * @Description : 数据删除
  80. *
  81. * @Function Parameters:
  82. *
  83. * @Return Value :
  84. *
  85. * @Author : Lou Wenzhi
  86. *
  87. * @Date : 2021/3/6 8:47
  88. *
  89. ******************************************************************************/
  90. func (t *WorkShiftEffLst) Del() bool {
  91. e := db.Eloquent.Master()
  92. _, err := e.ID(t.GetKey()).Delete(&WorkShiftEffLst{})
  93. if err != nil {
  94. return false
  95. }
  96. return true
  97. }
  98. /******************************************************************************
  99. *
  100. * @Function Name :
  101. *-----------------------------------------------------------------------------
  102. *
  103. * @Description : 数据修改
  104. *
  105. * @Function Parameters:
  106. *
  107. * @Return Value :
  108. *
  109. * @Author : Lou Wenzhi
  110. *
  111. * @Date : 2021/3/6 8:47
  112. *
  113. ******************************************************************************/
  114. func (t *WorkShiftEffLst) Update() error {
  115. e := db.Eloquent.Master()
  116. _, err := e.ID(t.GetKey()).Update(t)
  117. if err != nil {
  118. return err
  119. }
  120. return nil
  121. }
  122. /******************************************************************************
  123. *
  124. * @Function Name :
  125. *-----------------------------------------------------------------------------
  126. *
  127. * @Description : 数据查找
  128. *
  129. * @Function Parameters:
  130. *
  131. * @Return Value :
  132. *
  133. * @Author : Lou Wenzhi
  134. *
  135. * @Date : 2021/3/6 8:47
  136. *
  137. ******************************************************************************/
  138. func (t *WorkShiftEffLst) SelectOne() (WorkShiftEffLst, error) {
  139. e := db.Eloquent.Master()
  140. var data WorkShiftEffLst
  141. _, err := e.ID(t.GetKey()).Get(&data)
  142. if err != nil {
  143. return data, err
  144. }
  145. return data, nil
  146. }