// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
|
|
package models
|
|
|
|
import (
|
|
"leit.com/LAPP_GAAS_GFrame/db"
|
|
"errors"
|
|
"xorm.io/core"
|
|
)
|
|
|
|
type Workshiftefflst struct {
|
|
Plantnr int `json:"PlantNr" xorm:"not null pk INT(4)"`
|
|
Workshiftnr int `json:"WorkShiftNr" xorm:"not null pk INT(4)"`
|
|
Levelid string `json:"LevelId" xorm:"not null pk NVARCHAR(80)"`
|
|
Descr string `json:"Descr" xorm:"NVARCHAR(200)"`
|
|
Planpersonuclqty int `json:"PlanPersonUclQty" xorm:"INT(4)"`
|
|
Planpersonlclqty int `json:"PlanPersonLclQty" xorm:"INT(4)"`
|
|
Planefficiency float32 `json:"PlanEfficiency" xorm:"not null FLOAT(8)"`
|
|
}
|
|
|
|
/******数据表名******/
|
|
func (t *Workshiftefflst) TableName() string {
|
|
return "Workshiftefflst"
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name :
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 数据添加
|
|
*
|
|
* @Function Parameters:
|
|
*
|
|
* @Return Value :
|
|
*
|
|
* @Author : Lou Wenzhi
|
|
*
|
|
* @Date : 2021/3/6 8:47
|
|
*
|
|
******************************************************************************/
|
|
func (t *Workshiftefflst) Add() error {
|
|
e := db.Eloquent.Master()
|
|
count := new(Workshiftefflst)
|
|
affw, err := e.Table(t.TableName()).ID(core.PK{t.Plantnr, t.Workshiftnr, t.Levelid}).Count(count)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if affw > 0 {
|
|
return errors.New("数据已经存在!")
|
|
}
|
|
_, err = e.Table(t.TableName()).Insert(t)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name :
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 数据删除
|
|
*
|
|
* @Function Parameters:
|
|
*
|
|
* @Return Value :
|
|
*
|
|
* @Author : Lou Wenzhi
|
|
*
|
|
* @Date : 2021/3/6 8:47
|
|
*
|
|
******************************************************************************/
|
|
func (t *Workshiftefflst) Del() bool {
|
|
e := db.Eloquent.Master()
|
|
_, err := e.ID(core.PK{t.Plantnr, t.Workshiftnr, t.Levelid}).Delete(&Workshiftefflst{})
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name :
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 数据修改
|
|
*
|
|
* @Function Parameters:
|
|
*
|
|
* @Return Value :
|
|
*
|
|
* @Author : Lou Wenzhi
|
|
*
|
|
* @Date : 2021/3/6 8:47
|
|
*
|
|
******************************************************************************/
|
|
func (t *Workshiftefflst) Update() error {
|
|
e := db.Eloquent.Master()
|
|
_, err := e.ID(core.PK{t.Plantnr, t.Workshiftnr, t.Levelid}).Update(t)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name :
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 数据查找
|
|
*
|
|
* @Function Parameters:
|
|
*
|
|
* @Return Value :
|
|
*
|
|
* @Author : Lou Wenzhi
|
|
*
|
|
* @Date : 2021/3/6 8:47
|
|
*
|
|
******************************************************************************/
|
|
func (t *Workshiftefflst) SelectOne() (Workshiftefflst, error) {
|
|
e := db.Eloquent.Master()
|
|
var data Workshiftefflst
|
|
_, err := e.ID(core.PK{t.Plantnr, t.Workshiftnr, t.Levelid}).Get(&data)
|
|
if err != nil {
|
|
return data, err
|
|
}
|
|
return data, nil
|
|
}
|