SJA APS后端代码
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.

110 lines
3.1 KiB

  1. // Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
  2. package db
  3. import (
  4. "fmt"
  5. "github.com/go-xorm/xorm"
  6. "leit.com/leit_seat_aps/common"
  7. "xorm.io/core"
  8. )
  9. type Pln_workorder_intstatus struct {
  10. Finr int `xorm:"not null pk comment('车间编号') INT(0)" json:"finr"`
  11. Workordernr string `xorm:"not null pk comment('工单号') VARCHAR(18)" json:"workordernr"`
  12. Releaseflag int `xorm:"not null comment('标记状态') INT(0)" json:"releaseflag"`
  13. Runningflag int `xorm:"not null comment('启动状态') INT(0)" json:"runningflag"`
  14. Finishflag int `xorm:"not null comment('结束状态') INT(0)" json:"finishflag"`
  15. Lastmodif string `xorm:"not null comment('上一次更改日期') VARCHAR(14)" json:"lastmodif"`
  16. Lastuser string `xorm:"not null comment('最后编辑人员') VARCHAR(20)" json:"lastuser"`
  17. Credatuz string `xorm:"not null comment('创建时间') VARCHAR(14)" json:"credatuz"`
  18. }
  19. func (t *Pln_workorder_intstatus) TableName() string {
  20. return "pln_workorder_intstatus"
  21. }
  22. // 清除string字段的右侧空格
  23. func (t *Pln_workorder_intstatus) Clipped() {
  24. common.TrimStruct(t, *t)
  25. }
  26. /******************************************************************************
  27. *
  28. * @Function Name :
  29. *-----------------------------------------------------------------------------
  30. *
  31. * @Description :
  32. *
  33. * @Function Parameters:
  34. *
  35. * @Return Value :
  36. *
  37. * @Author : Lou Wenzhi
  38. *
  39. * @Date : 2021/3/10 11:18
  40. *
  41. ******************************************************************************/
  42. func (t *Pln_workorder_intstatus) Add() error {
  43. e := G_DbEngine
  44. countrole := new(Pln_workorder_intstatus)
  45. affw, err := e.Table("pln_workorder_intstatus").ID(core.PK{G_FINR, t.Workordernr}).Count(countrole)
  46. if err != nil {
  47. return err
  48. }
  49. if affw > 0 {
  50. return nil
  51. }
  52. _, err = e.Table("pln_workorder_intstatus").Insert(t)
  53. if err != nil {
  54. fmt.Printf("err is :%v",err)
  55. return err
  56. }
  57. return nil
  58. }
  59. //更新指定字段
  60. func (t *Pln_workorder_intstatus) Insert(session *xorm.Session) (err error) {
  61. countrole := new(Pln_workorder_intstatus)
  62. affw, err := session.Table("pln_workorder_intstatus").ID(core.PK{G_FINR, t.Workordernr}).Count(countrole)
  63. if err != nil {
  64. return err
  65. }
  66. if affw > 0 {
  67. return nil
  68. }
  69. _, err = session.Table("pln_workorder_intstatus").Insert(t)
  70. if err != nil {
  71. fmt.Printf("err is :%v",err)
  72. return err
  73. }
  74. return
  75. }
  76. func (t *Pln_workorder_intstatus) Del() bool {
  77. e := G_DbEngine
  78. _, err := e.ID(core.PK{G_FINR, t.Workordernr}).Delete(&Pln_workorder_intstatus{})
  79. if err != nil {
  80. return false
  81. }
  82. return true
  83. }
  84. func (t *Pln_workorder_intstatus) Update() bool {
  85. e := G_DbEngine
  86. _, err := e.ID(core.PK{G_FINR, t.Workordernr}).Cols("releaseflag","runningflag","finishflag","lastmodif","lastuser").Update(t)
  87. if err != nil {
  88. return false
  89. }
  90. return true
  91. }
  92. func (t *Pln_workorder_intstatus) SelectOne() (Pln_workorder_intstatus, error) {
  93. e := G_DbEngine
  94. var data Pln_workorder_intstatus
  95. _, err := e.ID(core.PK{G_FINR, t.Workordernr}).Get(&data)
  96. if err != nil {
  97. return data, err
  98. }
  99. return data, nil
  100. }