第二代基于事件的高级计划排程引擎
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.

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