package db
|
|
|
|
import (
|
|
"github.com/go-xorm/xorm"
|
|
"leit.com/leit_seat_aps/common"
|
|
)
|
|
|
|
//CALLOFF信息错误日志表
|
|
type Pln_calloff_errorlst struct {
|
|
Finr int `xorm:"pk"`
|
|
Calloffnr int `xorm:"pk"`
|
|
Consumeplant int `xorm:"pk"`
|
|
Partfamilyid string `xorm:"pk"`
|
|
Pos int `xorm:"pk"`
|
|
Oemordernr string
|
|
Errortype int
|
|
Errorinfo string
|
|
Errorstatus string
|
|
Lastmodif string
|
|
Lastuser string
|
|
Credatuz string
|
|
}
|
|
|
|
func (t *Pln_calloff_errorlst) Clipped() {
|
|
common.TrimStruct(t, *t)
|
|
}
|
|
|
|
func (t *Pln_calloff_errorlst) TableName() string {
|
|
return "pln_calloff_errorlst"
|
|
}
|
|
|
|
//增
|
|
func (t *Pln_calloff_errorlst) Add() error {
|
|
e := G_DbEngine
|
|
var pos int
|
|
cfdatatab := new(Pln_calloff_errorlst)
|
|
//查询上一条pos
|
|
ok, err := e.Table("pln_calloff_errorlst").Where("finr = ?", G_FINR).Desc("pos").Limit(1).Get(cfdatatab)
|
|
if !ok {
|
|
pos = 1
|
|
} else {
|
|
pos = cfdatatab.Pos + 1
|
|
}
|
|
t.Pos = pos
|
|
_, err = e.Table("pln_calloff_errorlst").Insert(t)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
//增
|
|
func (t *Pln_calloff_errorlst) Insert(session *xorm.Session) error {
|
|
var pos int
|
|
|
|
cfdatatab := new(Pln_calloff_errorlst)
|
|
//查询上一条pos
|
|
ok, err := session.Table("pln_calloff_errorlst").Where("finr = ?", G_FINR).Desc("pos").Limit(1).Get(cfdatatab)
|
|
if !ok {
|
|
pos = 1
|
|
} else {
|
|
pos = cfdatatab.Pos + 1
|
|
}
|
|
t.Pos = pos
|
|
_, err = session.Table("pln_calloff_errorlst").Insert(t)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
//增
|
|
func (t *Pln_calloff_errorlst) InsertList(session *xorm.Session, errlst []Pln_calloff_errorlst) error {
|
|
var i, pos int
|
|
|
|
cfdatatab := new(Pln_calloff_errorlst)
|
|
//查询上一条pos
|
|
ok, err := session.Table("pln_calloff_errorlst").Where("finr = ?", G_FINR).Desc("pos").Limit(1).Get(cfdatatab)
|
|
if !ok {
|
|
pos = 1
|
|
} else {
|
|
pos = cfdatatab.Pos + 1
|
|
}
|
|
for i = 0; i < len(errlst); i++ {
|
|
errlst[i].Pos = pos + i
|
|
_, err = session.Table("pln_calloff_errorlst").Insert(errlst[i])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|