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.

95 lines
2.0 KiB

  1. package db
  2. import (
  3. "github.com/go-xorm/xorm"
  4. "leit.com/leit_seat_aps/common"
  5. )
  6. //CALLOFF信息错误日志表
  7. type Pln_calloff_errorlst struct {
  8. Finr int `xorm:"pk"`
  9. Calloffnr int `xorm:"pk"`
  10. Consumeplant int `xorm:"pk"`
  11. Partfamilyid string `xorm:"pk"`
  12. Pos int `xorm:"pk"`
  13. Oemordernr string
  14. Errortype int
  15. Errorinfo string
  16. Errorstatus string
  17. Lastmodif string
  18. Lastuser string
  19. Credatuz string
  20. }
  21. func (t *Pln_calloff_errorlst) Clipped() {
  22. common.TrimStruct(t, *t)
  23. }
  24. func (t *Pln_calloff_errorlst) TableName() string {
  25. return "pln_calloff_errorlst"
  26. }
  27. //增
  28. func (t *Pln_calloff_errorlst) Add() error {
  29. e := G_DbEngine
  30. var pos int
  31. cfdatatab := new(Pln_calloff_errorlst)
  32. //查询上一条pos
  33. ok, err := e.Table("pln_calloff_errorlst").Where("finr = ?", G_FINR).Desc("pos").Limit(1).Get(cfdatatab)
  34. if !ok {
  35. pos = 1
  36. } else {
  37. pos = cfdatatab.Pos + 1
  38. }
  39. t.Pos = pos
  40. _, err = e.Table("pln_calloff_errorlst").Insert(t)
  41. if err != nil {
  42. return err
  43. }
  44. return nil
  45. }
  46. //增
  47. func (t *Pln_calloff_errorlst) Insert(session *xorm.Session) error {
  48. var pos int
  49. cfdatatab := new(Pln_calloff_errorlst)
  50. //查询上一条pos
  51. ok, err := session.Table("pln_calloff_errorlst").Where("finr = ?", G_FINR).Desc("pos").Limit(1).Get(cfdatatab)
  52. if !ok {
  53. pos = 1
  54. } else {
  55. pos = cfdatatab.Pos + 1
  56. }
  57. t.Pos = pos
  58. _, err = session.Table("pln_calloff_errorlst").Insert(t)
  59. if err != nil {
  60. return err
  61. }
  62. return nil
  63. }
  64. //增
  65. func (t *Pln_calloff_errorlst) InsertList(session *xorm.Session, errlst []Pln_calloff_errorlst) error {
  66. var i, pos int
  67. cfdatatab := new(Pln_calloff_errorlst)
  68. //查询上一条pos
  69. ok, err := session.Table("pln_calloff_errorlst").Where("finr = ?", G_FINR).Desc("pos").Limit(1).Get(cfdatatab)
  70. if !ok {
  71. pos = 1
  72. } else {
  73. pos = cfdatatab.Pos + 1
  74. }
  75. for i = 0; i < len(errlst); i++ {
  76. errlst[i].Pos = pos + i
  77. _, err = session.Table("pln_calloff_errorlst").Insert(errlst[i])
  78. if err != nil {
  79. return err
  80. }
  81. }
  82. return nil
  83. }