// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
|
|
package models
|
|
|
|
import (
|
|
"leit.com/LAPP_GAAS_GFrame/db"
|
|
"time"
|
|
"errors"
|
|
"xorm.io/core"
|
|
)
|
|
|
|
type Workline struct {
|
|
Plantnr int `json:"PlantNr" xorm:"not null pk INT(4)"`
|
|
Worklineid string `json:"WorkLineId" xorm:"not null pk NVARCHAR(80)"`
|
|
Descr string `json:"Descr" xorm:"not null NVARCHAR(200)"`
|
|
Linetype string `json:"LineType" xorm:"not null NVARCHAR(2)"`
|
|
Lineplanmode string `json:"LinePlanMode" xorm:"not null NVARCHAR(6)"`
|
|
Weekmodelnr int `json:"WeekModelNr" xorm:"not null INT(4)"`
|
|
Workcalendarnr int `json:"WorkCalendarNr" xorm:"not null INT(4)"`
|
|
Location string `json:"Location" xorm:"not null NVARCHAR(80)"`
|
|
Costcenterid string `json:"CostCenterId" xorm:"not null NVARCHAR(80)"`
|
|
Costrate float32 `json:"CostRate" xorm:"not null FLOAT(8)"`
|
|
Prodeff float32 `json:"ProdEff" xorm:"not null FLOAT(8)"`
|
|
Reqworkers int `json:"ReqWorkers" xorm:"not null INT(4)"`
|
|
Pos int `json:"Pos" xorm:"not null INT(4)"`
|
|
Taskqueuesortway string `json:"TaskQueueSortWay" xorm:"not null NVARCHAR(20)"`
|
|
Multiqueuemixsorttoggle int `json:"MultiQueueMixSortToggle" xorm:"not null BIT(1)"`
|
|
Taskqueuemixsortway string `json:"TaskQueueMixSortWay" xorm:"not null NVARCHAR(20)"`
|
|
Mixsortlogic string `json:"MixSortLogic" xorm:"not null NVARCHAR(200)"`
|
|
Taskreleaseway string `json:"TaskReleaseWay" xorm:"not null NVARCHAR(20)"`
|
|
Releaseqtyparameter int `json:"ReleaseQtyParameter" xorm:"not null INT(4)"`
|
|
Releasetimeparameter time.Time `json:"ReleaseTimeParameter" xorm:"DATETIME(8)"`
|
|
Releasectrlparameter string `json:"ReleaseCtrlParameter" xorm:"not null NVARCHAR(200)"`
|
|
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 *Workline) TableName() string {
|
|
return "Workline"
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name :
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 数据添加
|
|
*
|
|
* @Function Parameters:
|
|
*
|
|
* @Return Value :
|
|
*
|
|
* @Author : Lou Wenzhi
|
|
*
|
|
* @Date : 2021/3/6 8:47
|
|
*
|
|
******************************************************************************/
|
|
func (t *Workline) Add() error {
|
|
e := db.Eloquent.Master()
|
|
count := new(Workline)
|
|
affw, err := e.Table(t.TableName()).ID(core.PK{t.Plantnr, t.Worklineid}).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 *Workline) Del() bool {
|
|
e := db.Eloquent.Master()
|
|
_, err := e.ID(core.PK{t.Plantnr, t.Worklineid}).Delete(&Workline{})
|
|
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 *Workline) Update() error {
|
|
e := db.Eloquent.Master()
|
|
_, err := e.ID(core.PK{t.Plantnr, t.Worklineid}).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 *Workline) SelectOne() (Workline, error) {
|
|
e := db.Eloquent.Master()
|
|
var data Workline
|
|
_, err := e.ID(core.PK{t.Plantnr, t.Worklineid}).Get(&data)
|
|
if err != nil {
|
|
return data, err
|
|
}
|
|
return data, nil
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name :
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : 查找所有指定类型的馋相
|
|
*
|
|
* @Function Parameters:
|
|
*
|
|
* @Return Value :
|
|
*
|
|
* @Author : Lou Wenzhi
|
|
*
|
|
* @Date : 2021/3/6 8:47
|
|
*
|
|
******************************************************************************/
|
|
func (t *Workline) SelectByType(wltype string) (datalst []Workline, err error) {
|
|
e := db.Eloquent.Master()
|
|
if err := e.Where("Plantnr = ? and Linetype = ?", t.Plantnr, wltype).OrderBy("WorkLineId").Find(&datalst); err != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|