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.

171 lines
6.4 KiB

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/LAPP_GAAS_GFrame/db"
  6. "time"
  7. "xorm.io/core"
  8. )
  9. type Article struct {
  10. Plantnr int `json:"PlantNr" xorm:"not null pk INT(4)"`
  11. Artid string `json:"ArtId" xorm:"not null pk NVARCHAR(80)"`
  12. Descr1 string `json:"Descr1" xorm:"not null NVARCHAR(200)"`
  13. Descr2 string `json:"Descr2" xorm:"not null NVARCHAR(200)"`
  14. Arttypeid string `json:"ArtTypeId" xorm:"not null NVARCHAR(80)"`
  15. Projectid string `json:"ProjectId" xorm:"not null NVARCHAR(80)"`
  16. Custartid string `json:"CustArtId" xorm:"not null NVARCHAR(80)"`
  17. Alternativeartid string `json:"AlternativeArtId" xorm:"not null NVARCHAR(80)"`
  18. Planresourcegroupid string `json:"PlanResourceGroupId" xorm:"not null NVARCHAR(80)"`
  19. Planresourceid string `json:"PlanResourceId" xorm:"not null NVARCHAR(80)"`
  20. Usedresourceid string `json:"UsedResourceId" xorm:"not null NVARCHAR(80)"`
  21. Uomid string `json:"UomId" xorm:"not null NVARCHAR(80)"`
  22. Planscraprate float32 `json:"PlanScrapRate" xorm:"not null FLOAT(8)"`
  23. Rateperhourtoggle int `json:"RatePerHourToggle" xorm:"not null BIT(1)"`
  24. Timeperitemtoggle int `json:"TimePerItemToggle" xorm:"not null BIT(1)"`
  25. Timeperbatchtoggle int `json:"TimePerBatchToggle" xorm:"not null BIT(1)"`
  26. Batchtimefieldtoggle int `json:"BatchTimeFieldToggle" xorm:"not null BIT(1)"`
  27. Optimeperitem float32 `json:"OpTimePerItem" xorm:"FLOAT(8)"`
  28. Batchtime float32 `json:"BatchTime" xorm:"FLOAT(8)"`
  29. Quantityperhour float32 `json:"QuantityPerHour" xorm:"not null FLOAT(8)"`
  30. Midbatchquantity int `json:"MidBatchQuantity" xorm:"not null INT(4)"`
  31. Midbatchtime time.Time `json:"MidBatchTime" xorm:"DATETIME(8)"`
  32. Effectiveoptime float32 `json:"EffectiveOpTime" xorm:"FLOAT(8)"`
  33. Batchingmethod int `json:"BatchingMethod" xorm:"not null INT(4)"`
  34. Deliverybuffer float32 `json:"DeliveryBuffer" xorm:"FLOAT(8)"`
  35. Icon string `json:"Icon" xorm:"not null NVARCHAR(200)"`
  36. Displaycolor string `json:"DisplayColor" xorm:"not null NVARCHAR(40)"`
  37. Document string `json:"Document" xorm:"not null NVARCHAR(200)"`
  38. Defaultroute string `json:"DefaultRoute" xorm:"not null NVARCHAR(80)"`
  39. Defaultinspectplanid string `json:"DefaultInspectPlanId" xorm:"not null NVARCHAR(80)"`
  40. Lotsize float32 `json:"LotSize" xorm:"FLOAT(8)"`
  41. Abcclass string `json:"ABCClass" xorm:"not null NVARCHAR(2)"`
  42. Artsize1 string `json:"ArtSize1" xorm:"not null NVARCHAR(200)"`
  43. Artsize2 string `json:"ArtSize2" xorm:"not null NVARCHAR(200)"`
  44. Artsize3 string `json:"ArtSize3" xorm:"not null NVARCHAR(200)"`
  45. Artsize4 string `json:"ArtSize4" xorm:"not null NVARCHAR(200)"`
  46. Artsize5 string `json:"ArtSize5" xorm:"not null NVARCHAR(200)"`
  47. Artspec1 string `json:"ArtSpec1" xorm:"not null NVARCHAR(200)"`
  48. Artspec2 string `json:"ArtSpec2" xorm:"not null NVARCHAR(200)"`
  49. Artspec3 string `json:"ArtSpec3" xorm:"not null NVARCHAR(200)"`
  50. Artspec4 string `json:"ArtSpec4" xorm:"not null NVARCHAR(200)"`
  51. Artspec5 string `json:"ArtSpec5" xorm:"not null NVARCHAR(200)"`
  52. Lastmodify time.Time `json:"LastModify" xorm:"DATETIME(8)"`
  53. Lastuser string `json:"LastUser" xorm:"not null NVARCHAR(40)"`
  54. Createtime time.Time `json:"CreateTime" xorm:"DATETIME(8)"`
  55. }
  56. /******数据表名******/
  57. func (t *Article) TableName() string {
  58. return "Article"
  59. }
  60. /******************************************************************************
  61. *
  62. * @Function Name :
  63. *-----------------------------------------------------------------------------
  64. *
  65. * @Description : 数据添加
  66. *
  67. * @Function Parameters:
  68. *
  69. * @Return Value :
  70. *
  71. * @Author : Lou Wenzhi
  72. *
  73. * @Date : 2021/3/6 8:47
  74. *
  75. ******************************************************************************/
  76. func (t *Article) Add() error {
  77. e := db.Eloquent.Master()
  78. arttab := new(Article)
  79. /**主键:****/
  80. affw, err := e.Table(t.TableName()).ID(core.PK{t.Plantnr, t.Artid}).Count(arttab)
  81. if err != nil {
  82. return err
  83. }
  84. if affw > 0 {
  85. return errors.New("数据已经存在!")
  86. }
  87. _, err = e.Table(t.TableName()).Insert(t)
  88. if err != nil {
  89. return err
  90. }
  91. return nil
  92. }
  93. /******************************************************************************
  94. *
  95. * @Function Name :
  96. *-----------------------------------------------------------------------------
  97. *
  98. * @Description : 数据删除
  99. *
  100. * @Function Parameters:
  101. *
  102. * @Return Value :
  103. *
  104. * @Author : Lou Wenzhi
  105. *
  106. * @Date : 2021/3/6 8:47
  107. *
  108. ******************************************************************************/
  109. func (t *Article) Del() (err error) {
  110. e := db.Eloquent.Master()
  111. if _, err := e.ID(core.PK{t.Plantnr, t.Artid}).Delete(&Article{}); err != nil {
  112. return
  113. }
  114. return
  115. }
  116. /******************************************************************************
  117. *
  118. * @Function Name :
  119. *-----------------------------------------------------------------------------
  120. *
  121. * @Description : 数据修改
  122. *
  123. * @Function Parameters:
  124. *
  125. * @Return Value :
  126. *
  127. * @Author : Lou Wenzhi
  128. *
  129. * @Date : 2021/3/6 8:47
  130. *
  131. ******************************************************************************/
  132. func (t *Article) Update() (err error) {
  133. e := db.Eloquent.Master()
  134. /**主键:****/
  135. if _, err := e.ID(core.PK{t.Plantnr, t.Artid}).Update(t);err != nil {
  136. return
  137. }
  138. return
  139. }
  140. /******************************************************************************
  141. *
  142. * @Function Name :
  143. *-----------------------------------------------------------------------------
  144. *
  145. * @Description : 数据查找
  146. *
  147. * @Function Parameters:
  148. *
  149. * @Return Value :
  150. *
  151. * @Author : Lou Wenzhi
  152. *
  153. * @Date : 2021/3/6 8:47
  154. *
  155. ******************************************************************************/
  156. func (t *Article) SelectOne() (data Article,err error) {
  157. e := db.Eloquent.Master()
  158. /******/
  159. if _, err := e.ID(core.PK{t.Plantnr, t.Artid}).Get(&data);err != nil {
  160. return
  161. }
  162. return
  163. }