|
|
- // 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 Secondaryresource struct {
- Plantnr int `json:"PlantNr" xorm:"not null pk INT(4)"`
- Resourcenr int `json:"ResourceNr" xorm:"not null pk INT(4)"`
- Resourceid string `json:"ResourceId" xorm:"not null NVARCHAR(40)"`
- Descr string `json:"Descr" xorm:"not null NVARCHAR(200)"`
- Resourcetype string `json:"ResourceType" xorm:"not null NVARCHAR(40)"`
- Capacitytype string `json:"CapacityType" xorm:"not null NVARCHAR(40)"`
- 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 *Secondaryresource) TableName() string {
- return "SecondaryResource"
- }
-
- /******************************************************************************
- *
- * @Function Name :
- *-----------------------------------------------------------------------------
- *
- * @Description : 数据添加
- *
- * @Function Parameters:
- *
- * @Return Value :
- *
- * @Author : Lou Wenzhi
- *
- * @Date : 2021/3/6 8:47
- *
- ******************************************************************************/
- func (t *Secondaryresource) Add() error {
- e := db.Eloquent.Master()
- count := new(Secondaryresource)
- /**主键:****/
-
- /******/
- affw, err := e.Table(t.TableName()).ID(core.PK{t.Plantnr, t.Resourcenr}).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 *Secondaryresource) Del() (err error) {
- e := db.Eloquent.Master()
- /**主键:****/
-
- /******/
- _, err = e.ID(core.PK{t.Plantnr, t.Resourcenr}).Delete(&Secondaryresource{})
- if err != nil {
- return
- }
- return nil
- }
-
- /******************************************************************************
- *
- * @Function Name :
- *-----------------------------------------------------------------------------
- *
- * @Description : 数据修改
- *
- * @Function Parameters:
- *
- * @Return Value :
- *
- * @Author : Lou Wenzhi
- *
- * @Date : 2021/3/6 8:47
- *
- ******************************************************************************/
- func (t *Secondaryresource) Update() error {
- e := db.Eloquent.Master()
- /**主键:****/
-
- /******/
- _, err := e.ID(core.PK{t.Plantnr, t.Resourcenr}).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 *Secondaryresource) SelectOne() (Secondaryresource, error) {
- e := db.Eloquent.Master()
- var data Secondaryresource
- /**主键:****/
-
- /******/
- _, err := e.ID(core.PK{t.Plantnr, t.Resourcenr}).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 *Secondaryresource) SelectAll() (datalst []Secondaryresource, err error) {
- e := db.Eloquent.Master()
- if err = e.Table(t.TableName()).Where("PlantNr = ?",t.Plantnr).OrderBy("ResourceNr").Find(&datalst); err != nil{
- return
- }
- return
- }
-
|