// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
|
|
package models
|
|
|
|
import (
|
|
"errors"
|
|
"leit.com/aps_engine/db"
|
|
"leit.com/aps_engine/grmi"
|
|
"xorm.io/core"
|
|
)
|
|
|
|
type WorkShiftEffLst struct {
|
|
PlantNr int `xorm:"pk int 'PlantNr'" json:"WorkShiftEffLst-PlantNr"`
|
|
WorkShiftNr int `xorm:"pk int 'WorkShiftNr'" json:"WorkShiftEffLst-WorkShiftNr"`
|
|
LevelId string `xorm:"pk nvarchar(40) 'LevelId'" json:"WorkShiftEffLst-LevelId"`
|
|
Descr string `xorm:"nvarchar(100) 'Descr'" json:"WorkShiftEffLst-Descr"`
|
|
PlanPersonUclQty int `xorm:"int 'PlanPersonUclQty'" json:"WorkShiftEffLst-PlanPersonUclQty"`
|
|
PlanPersonLclQty int `xorm:"int 'PlanPersonLclQty'" json:"WorkShiftEffLst-PlanPersonLclQty"`
|
|
PlanEfficiency float64 `xorm:"float 'PlanEfficiency' not null" json:"WorkShiftEffLst-PlanEfficiency"`
|
|
LastModify grmi.DateTime `xorm:"datetime 'LastModify' not null updated" json:"WorkShiftEffLst-LastModify"`
|
|
LastUser string `xorm:"nvarchar(20) 'LastUser' not null" json:"WorkShiftEffLst-LastUser"`
|
|
CreateTime grmi.DateTime `xorm:"datetime 'CreateTime' not null created" json:"WorkShiftEffLst-CreateTime"`
|
|
}
|
|
|
|
/******数据表名******/
|
|
func (t *WorkShiftEffLst) TableName() string {
|
|
return "Workshiftefflst"
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : GetKey
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 获取实体的主键
|
|
*
|
|
* @Return Value : 实体的主键
|
|
*
|
|
* @Author : 代码生成器创建
|
|
*
|
|
* @Date : 2021-03-23 17:06:57
|
|
*
|
|
******************************************************************************/
|
|
func (self *WorkShiftEffLst) GetKey() core.PK {
|
|
return core.PK{self.PlantNr, self.WorkShiftNr, self.LevelId}
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @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(t.GetKey()).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(t.GetKey()).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(t.GetKey()).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(t.GetKey()).Get(&data)
|
|
if err != nil {
|
|
return data, err
|
|
}
|
|
return data, nil
|
|
}
|