第二代基于事件的高级计划排程引擎
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.
 

179 lines
5.0 KiB

// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
package models
import (
"errors"
"leit.com/aps_engine/db"
"time"
"xorm.io/core"
)
type Workplacegrp struct {
Plantnr int `json:"PlantNr" xorm:"not null pk INT(4)"`
Workplacegrpnr int `json:"WorkPlaceGrpNr" xorm:"not null pk INT(4)"`
Workplacegrpid string `json:"WorkPlaceGrpId" xorm:"not null NVARCHAR(80)"`
Descr string `json:"Descr" xorm:"not null NVARCHAR(200)"`
Workplacetype string `json:"WorkPlaceType" xorm:"not null NVARCHAR(80)"`
Capacitytype string `json:"CapacityType" xorm:"not null NVARCHAR(80)"`
Capacityfactor float32 `json:"CapacityFactor" xorm:"not null FLOAT(8)"`
Planefficiency float32 `json:"PlanEfficiency" xorm:"not null FLOAT(8)"`
Costrate float32 `json:"CostRate" xorm:"not null FLOAT(8)"`
Weekmodelnr int `json:"WeekModelNr" xorm:"not null INT(4)"`
Workcalendarnr int `json:"WorkCalendarNr" xorm:"not null INT(4)"`
Costcenterid string `json:"CostCenterId" xorm:"not null NVARCHAR(80)"`
Locationid string `json:"LocationId" xorm:"not null NVARCHAR(80)"`
Lastmodify time.Time `json:"LastModify" xorm:"DATETIME(8)"`
Lastuser string `json:"LastUser" xorm:"not null NVARCHAR(40)"`
Createtime time.Time `json:"CreateTime" xorm:"DATETIME(8)"`
}
/******数据表名******/
func (t *Workplacegrp) TableName() string {
return "Workplacegrp"
}
/******************************************************************************
*
* @Function Name :
*-----------------------------------------------------------------------------
*
* @Description : 数据添加
*
* @Function Parameters:
*
* @Return Value :
*
* @Author : Lou Wenzhi
*
* @Date : 2021/3/6 8:47
*
******************************************************************************/
func (t *Workplacegrp) Add() error {
e := db.Eloquent.Master()
count := new(Workplacegrp)
/**主键:****/
/******/
affw, err := e.Table(t.TableName()).ID(core.PK{t.Plantnr, t.Workplacegrpnr}).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 *Workplacegrp) Del() (err error) {
e := db.Eloquent.Master()
/**主键:****/
/******/
_, err = e.ID(core.PK{t.Plantnr, t.Workplacegrpnr}).Delete(&Workplacegrp{})
if err != nil {
return
}
return nil
}
/******************************************************************************
*
* @Function Name :
*-----------------------------------------------------------------------------
*
* @Description : 数据修改
*
* @Function Parameters:
*
* @Return Value :
*
* @Author : Lou Wenzhi
*
* @Date : 2021/3/6 8:47
*
******************************************************************************/
func (t *Workplacegrp) Update() error {
e := db.Eloquent.Master()
/**主键:****/
/******/
_, err := e.ID(core.PK{t.Plantnr, t.Workplacegrpnr}).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 *Workplacegrp) SelectOne() (Workplacegrp, error) {
e := db.Eloquent.Master()
var data Workplacegrp
/**主键:****/
/******/
_, err := e.ID(core.PK{t.Plantnr, t.Workplacegrpnr}).Get(&data)
if err != nil {
return data, err
}
return data, nil
}
/******************************************************************************
*
* @Function Name :
*-----------------------------------------------------------------------------
*
* @Description : 查找所有的工位组
*
* @Function Parameters:
*
* @Return Value :
*
* @Author : LEO XUE
*
* @Date : 2021/3/6 8:47
*
******************************************************************************/
func (t *Workplacegrp) SelectAll() (datalst []Workplacegrp, err error) {
e := db.Eloquent.Master()
if err = e.Table(t.TableName()).Where("PlantNr = ?",t.Plantnr).OrderBy("WorkPlaceGrpNr").Find(&datalst); err != nil{
return
}
return
}