// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
|
|
package db
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/go-xorm/xorm"
|
|
"leit.com/leit_seat_aps/common"
|
|
"xorm.io/core"
|
|
)
|
|
|
|
type Pln_workorder_intstatus struct {
|
|
Finr int `xorm:"not null pk comment('车间编号') INT(0)" json:"finr"`
|
|
Workordernr string `xorm:"not null pk comment('工单号') VARCHAR(18)" json:"workordernr"`
|
|
Releaseflag int `xorm:"not null comment('标记状态') INT(0)" json:"releaseflag"`
|
|
Runningflag int `xorm:"not null comment('启动状态') INT(0)" json:"runningflag"`
|
|
Finishflag int `xorm:"not null comment('结束状态') INT(0)" json:"finishflag"`
|
|
Lastmodif string `xorm:"not null comment('上一次更改日期') VARCHAR(14)" json:"lastmodif"`
|
|
Lastuser string `xorm:"not null comment('最后编辑人员') VARCHAR(20)" json:"lastuser"`
|
|
Credatuz string `xorm:"not null comment('创建时间') VARCHAR(14)" json:"credatuz"`
|
|
}
|
|
|
|
func (t *Pln_workorder_intstatus) TableName() string {
|
|
return "pln_workorder_intstatus"
|
|
}
|
|
|
|
// 清除string字段的右侧空格
|
|
func (t *Pln_workorder_intstatus) Clipped() {
|
|
common.TrimStruct(t, *t)
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name :
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description :
|
|
*
|
|
* @Function Parameters:
|
|
*
|
|
* @Return Value :
|
|
*
|
|
* @Author : Lou Wenzhi
|
|
*
|
|
* @Date : 2021/3/10 11:18
|
|
*
|
|
******************************************************************************/
|
|
func (t *Pln_workorder_intstatus) Add() error {
|
|
e := G_DbEngine
|
|
countrole := new(Pln_workorder_intstatus)
|
|
affw, err := e.Table("pln_workorder_intstatus").ID(core.PK{G_FINR, t.Workordernr}).Count(countrole)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if affw > 0 {
|
|
return nil
|
|
}
|
|
_, err = e.Table("pln_workorder_intstatus").Insert(t)
|
|
if err != nil {
|
|
fmt.Printf("err is :%v",err)
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
//更新指定字段
|
|
func (t *Pln_workorder_intstatus) Insert(session *xorm.Session) (err error) {
|
|
countrole := new(Pln_workorder_intstatus)
|
|
affw, err := session.Table("pln_workorder_intstatus").ID(core.PK{G_FINR, t.Workordernr}).Count(countrole)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if affw > 0 {
|
|
return nil
|
|
}
|
|
_, err = session.Table("pln_workorder_intstatus").Insert(t)
|
|
if err != nil {
|
|
fmt.Printf("err is :%v",err)
|
|
return err
|
|
}
|
|
return
|
|
}
|
|
|
|
func (t *Pln_workorder_intstatus) Del() bool {
|
|
e := G_DbEngine
|
|
_, err := e.ID(core.PK{G_FINR, t.Workordernr}).Delete(&Pln_workorder_intstatus{})
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (t *Pln_workorder_intstatus) Update() bool {
|
|
e := G_DbEngine
|
|
_, err := e.ID(core.PK{G_FINR, t.Workordernr}).Cols("releaseflag","runningflag","finishflag","lastmodif","lastuser").Update(t)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (t *Pln_workorder_intstatus) SelectOne() (Pln_workorder_intstatus, error) {
|
|
e := G_DbEngine
|
|
var data Pln_workorder_intstatus
|
|
_, err := e.ID(core.PK{G_FINR, t.Workordernr}).Get(&data)
|
|
if err != nil {
|
|
return data, err
|
|
}
|
|
return data, nil
|
|
}
|
|
|