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.
 

204 lines
7.0 KiB

// 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"
"time"
)
type Daymodel struct {
Plantnr int `json:"PlantNr" xorm:"not null pk INT(4)"`
Daymodelnr int `json:"DayModelNr" xorm:"not null pk INT(4)"`
Descr string `json:"Descr" xorm:"NVARCHAR(200)"`
Abrev string `json:"Abrev" xorm:"not null NVARCHAR(20)"`
Hexcolor string `json:"HexColor" xorm:"NVARCHAR(20)"`
S1toggle int `json:"S1Toggle" xorm:"not null BIT(1)"`
S2toggle int `json:"S2Toggle" xorm:"not null BIT(1)"`
S3toggle int `json:"S3Toggle" xorm:"not null BIT(1)"`
Workshifttoggle int `json:"WorkShiftToggle" xorm:"not null BIT(1)"`
S1Workshiftnr int `json:"S1_WorkShiftNr" xorm:"not null INT(4)"`
S2Workshiftnr int `json:"S2_WorkShiftNr" xorm:"not null INT(4)"`
S3Workshiftnr int `json:"S3_WorkShiftNr" xorm:"not null INT(4)"`
S1Beg int `json:"S1_Beg" xorm:"INT(4)"`
S1End int `json:"S1_End" xorm:"INT(4)"`
S1Len int `json:"S1_Len" xorm:"INT(4)"`
S2Beg int `json:"S2_Beg" xorm:"INT(4)"`
S2End int `json:"S2_End" xorm:"INT(4)"`
S2Len int `json:"S2_Len" xorm:"INT(4)"`
S3Beg int `json:"S3_Beg" xorm:"INT(4)"`
S3End int `json:"S3_End" xorm:"INT(4)"`
S3Len int `json:"S3_Len" xorm:"INT(4)"`
DmLen int `json:"Dm_Len" xorm:"INT(4)"`
S1B1Beg int `json:"S1_B1_Beg" xorm:"INT(4)"`
S1B1End int `json:"S1_B1_End" xorm:"INT(4)"`
S1B2Beg int `json:"S1_B2_Beg" xorm:"INT(4)"`
S1B2End int `json:"S1_B2_End" xorm:"INT(4)"`
S1B3Beg int `json:"S1_B3_Beg" xorm:"INT(4)"`
S1B3End int `json:"S1_B3_End" xorm:"INT(4)"`
S1B4Beg int `json:"S1_B4_Beg" xorm:"INT(4)"`
S1B4End int `json:"S1_B4_End" xorm:"INT(4)"`
S1B5Beg int `json:"S1_B5_Beg" xorm:"INT(4)"`
S1B5End int `json:"S1_B5_End" xorm:"INT(4)"`
S2B1Beg int `json:"S2_B1_Beg" xorm:"INT(4)"`
S2B1End int `json:"S2_B1_End" xorm:"INT(4)"`
S2B2Beg int `json:"S2_B2_Beg" xorm:"INT(4)"`
S2B2End int `json:"S2_B2_End" xorm:"INT(4)"`
S2B3Beg int `json:"S2_B3_Beg" xorm:"INT(4)"`
S2B3End int `json:"S2_B3_End" xorm:"INT(4)"`
S2B4Beg int `json:"S2_B4_Beg" xorm:"INT(4)"`
S2B4End int `json:"S2_B4_End" xorm:"INT(4)"`
S2B5Beg int `json:"S2_B5_Beg" xorm:"INT(4)"`
S2B5End int `json:"S2_B5_End" xorm:"INT(4)"`
S3B1Beg int `json:"S3_B1_Beg" xorm:"INT(4)"`
S3B1End int `json:"S3_B1_End" xorm:"INT(4)"`
S3B2Beg int `json:"S3_B2_Beg" xorm:"INT(4)"`
S3B2End int `json:"S3_B2_End" xorm:"INT(4)"`
S3B3Beg int `json:"S3_B3_Beg" xorm:"INT(4)"`
S3B3End int `json:"S3_B3_End" xorm:"INT(4)"`
S3B4Beg int `json:"S3_B4_Beg" xorm:"INT(4)"`
S3B4End int `json:"S3_B4_End" xorm:"INT(4)"`
S3B5Beg int `json:"S3_B5_Beg" xorm:"INT(4)"`
S3B5End int `json:"S3_B5_End" xorm:"INT(4)"`
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 *Daymodel) TableName() string {
return "Daymodel"
}
/******************************************************************************
*
* @Function Name :
*-----------------------------------------------------------------------------
*
* @Description : 数据添加
*
* @Function Parameters:
*
* @Return Value :
*
* @Author : Lou Wenzhi
*
* @Date : 2021/3/6 8:47
*
******************************************************************************/
func (t *Daymodel) Add() error {
e := db.Eloquent.Master()
count := new(Daymodel)
affw, err := e.Table(t.TableName()).ID(core.PK{t.Plantnr, t.Daymodelnr}).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 *Daymodel) Del() bool {
e := db.Eloquent.Master()
_, err := e.ID(core.PK{t.Plantnr, t.Daymodelnr}).Delete(&Daymodel{})
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 *Daymodel) Update() error {
e := db.Eloquent.Master()
_, err := e.ID(core.PK{t.Plantnr, t.Daymodelnr}).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 *Daymodel) SelectOne() (data Daymodel, err error) {
e := db.Eloquent.Master()
if _, err = e.ID(core.PK{t.Plantnr, t.Daymodelnr}).Get(&data); 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 *Daymodel) SelectAll() (datalst []Daymodel, err error) {
e := db.Eloquent.Master()
if err := e.Table(t.TableName()).Where("PlantNr = ?",t.Plantnr).OrderBy("DayModelNr").Find(&datalst); err != nil{
return
}
return
}