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.

154 lines
4.4 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 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/LAPP_GAAS_GFrame/db"
  6. "time"
  7. "xorm.io/core"
  8. )
  9. type OmWorkorderqty struct {
  10. Plantnr int `json:"PlantNr" xorm:"not null pk INT(4)"`
  11. Workorderid string `json:"WorkOrderId" xorm:"not null pk NVARCHAR(40)"`
  12. Planqty float32 `json:"PlanQty" xorm:"not null FLOAT(8)"`
  13. Releasedqty float32 `json:"ReleasedQty" xorm:"not null FLOAT(8)"`
  14. Actqty float32 `json:"ActQty" xorm:"not null FLOAT(8)"`
  15. Actgoodqty float32 `json:"ActGoodQty" xorm:"not null FLOAT(8)"`
  16. Actscrapqty float32 `json:"ActScrapQty" xorm:"not null FLOAT(8)"`
  17. Actreworkqty float32 `json:"ActReworkQty" xorm:"not null FLOAT(8)"`
  18. Actqty1 float32 `json:"ActQty1" xorm:"not null FLOAT(8)"`
  19. Actqty2 float32 `json:"ActQty2" xorm:"not null FLOAT(8)"`
  20. Actqty3 float32 `json:"ActQty3" xorm:"not null FLOAT(8)"`
  21. Actqty4 float32 `json:"ActQty4" xorm:"not null FLOAT(8)"`
  22. Lastmodify time.Time `json:"LastModify" xorm:"DATETIME(8)"`
  23. Lastuser string `json:"LastUser" xorm:"not null NVARCHAR(40)"`
  24. Createtime time.Time `json:"CreateTime" xorm:"DATETIME(8)"`
  25. Itemlst []OMWorkorderqtyreclst `json:"itemlst" xorm:"-"`
  26. }
  27. /******数据表名******/
  28. func (t *OmWorkorderqty) TableName() string {
  29. return "OmWorkOrderQty"
  30. }
  31. /******************************************************************************
  32. *
  33. * @Function Name :
  34. *-----------------------------------------------------------------------------
  35. *
  36. * @Description : 数据添加
  37. *
  38. * @Function Parameters:
  39. *
  40. * @Return Value :
  41. *
  42. * @Author : Lou Wenzhi
  43. *
  44. * @Date : 2021/3/6 8:47
  45. *
  46. ******************************************************************************/
  47. func (t *OmWorkorderqty) Add() error {
  48. e := db.Eloquent.Master()
  49. woqtytab := new(OmWorkorderqty)
  50. /**主键:****/
  51. affw, err := e.Table(t.TableName()).ID(core.PK{t.Plantnr, t.Workorderid}).Count(woqtytab)
  52. if err != nil {
  53. return err
  54. }
  55. if affw > 0 {
  56. return errors.New("数据已经存在!")
  57. }
  58. _, err = e.Table(t.TableName()).Insert(t)
  59. if err != nil {
  60. return err
  61. }
  62. return nil
  63. }
  64. /******************************************************************************
  65. *
  66. * @Function Name :
  67. *-----------------------------------------------------------------------------
  68. *
  69. * @Description : 数据删除
  70. *
  71. * @Function Parameters:
  72. *
  73. * @Return Value :
  74. *
  75. * @Author : Lou Wenzhi
  76. *
  77. * @Date : 2021/3/6 8:47
  78. *
  79. ******************************************************************************/
  80. func (t *OmWorkorderqty) Del() error {
  81. e := db.Eloquent.Master()
  82. /**主键:****/
  83. _, err := e.ID(core.PK{t.Plantnr, t.Workorderid}).Delete(&OmWorkorderqty{})
  84. if err != nil {
  85. return errors.New("删除失败!")
  86. }
  87. // 删除该订单所有的状态记录
  88. return nil
  89. }
  90. /******************************************************************************
  91. *
  92. * @Function Name :
  93. *-----------------------------------------------------------------------------
  94. *
  95. * @Description : 数据修改
  96. *
  97. * @Function Parameters:
  98. *
  99. * @Return Value :
  100. *
  101. * @Author : Lou Wenzhi
  102. *
  103. * @Date : 2021/3/6 8:47
  104. *
  105. ******************************************************************************/
  106. func (t *OmWorkorderqty) Update() error {
  107. e := db.Eloquent.Master()
  108. /**主键:****/
  109. _, err := e.ID(core.PK{t.Plantnr, t.Workorderid}).Update(t)
  110. if err != nil {
  111. return err
  112. }
  113. return nil
  114. }
  115. /******************************************************************************
  116. *
  117. * @Function Name :
  118. *-----------------------------------------------------------------------------
  119. *
  120. * @Description : 数据查找
  121. *
  122. * @Function Parameters:
  123. *
  124. * @Return Value :
  125. *
  126. * @Author : Lou Wenzhi
  127. *
  128. * @Date : 2021/3/6 8:47
  129. *
  130. ******************************************************************************/
  131. func (t *OmWorkorderqty) SelectOne() (data OmWorkorderqty, err error) {
  132. e := db.Eloquent.Master()
  133. /**主键:****/
  134. _, err = e.ID(core.PK{t.Plantnr, t.Workorderid}).Get(&data)
  135. if err != nil {
  136. return
  137. }
  138. // 获取值列表
  139. if err = e.Where("Plantnr = ? and ProdOrderId = ? ",
  140. t.Plantnr, t.Workorderid).OrderBy("pos").Find(&data.Itemlst); err != nil {
  141. return
  142. }
  143. return
  144. }