|
|
- // Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
- package models
-
- import (
- "errors"
- "leit.com/LAPP_GAAS_GFrame/db"
- "time"
- "xorm.io/core"
- )
-
- type Article struct {
- Plantnr int `json:"PlantNr" xorm:"not null pk INT(4)"`
- Artid string `json:"ArtId" xorm:"not null pk NVARCHAR(80)"`
- Descr1 string `json:"Descr1" xorm:"not null NVARCHAR(200)"`
- Descr2 string `json:"Descr2" xorm:"not null NVARCHAR(200)"`
- Arttypeid string `json:"ArtTypeId" xorm:"not null NVARCHAR(80)"`
- Projectid string `json:"ProjectId" xorm:"not null NVARCHAR(80)"`
- Custartid string `json:"CustArtId" xorm:"not null NVARCHAR(80)"`
- Alternativeartid string `json:"AlternativeArtId" xorm:"not null NVARCHAR(80)"`
- Planresourcegroupid string `json:"PlanResourceGroupId" xorm:"not null NVARCHAR(80)"`
- Planresourceid string `json:"PlanResourceId" xorm:"not null NVARCHAR(80)"`
- Usedresourceid string `json:"UsedResourceId" xorm:"not null NVARCHAR(80)"`
- Uomid string `json:"UomId" xorm:"not null NVARCHAR(80)"`
- Planscraprate float32 `json:"PlanScrapRate" xorm:"not null FLOAT(8)"`
- Rateperhourtoggle int `json:"RatePerHourToggle" xorm:"not null BIT(1)"`
- Timeperitemtoggle int `json:"TimePerItemToggle" xorm:"not null BIT(1)"`
- Timeperbatchtoggle int `json:"TimePerBatchToggle" xorm:"not null BIT(1)"`
- Batchtimefieldtoggle int `json:"BatchTimeFieldToggle" xorm:"not null BIT(1)"`
- Optimeperitem float32 `json:"OpTimePerItem" xorm:"FLOAT(8)"`
- Batchtime float32 `json:"BatchTime" xorm:"FLOAT(8)"`
- Quantityperhour float32 `json:"QuantityPerHour" xorm:"not null FLOAT(8)"`
- Midbatchquantity int `json:"MidBatchQuantity" xorm:"not null INT(4)"`
- Midbatchtime time.Time `json:"MidBatchTime" xorm:"DATETIME(8)"`
- Effectiveoptime float32 `json:"EffectiveOpTime" xorm:"FLOAT(8)"`
- Batchingmethod int `json:"BatchingMethod" xorm:"not null INT(4)"`
- Deliverybuffer float32 `json:"DeliveryBuffer" xorm:"FLOAT(8)"`
- Icon string `json:"Icon" xorm:"not null NVARCHAR(200)"`
- Displaycolor string `json:"DisplayColor" xorm:"not null NVARCHAR(40)"`
- Document string `json:"Document" xorm:"not null NVARCHAR(200)"`
- Defaultroute string `json:"DefaultRoute" xorm:"not null NVARCHAR(80)"`
- Defaultinspectplanid string `json:"DefaultInspectPlanId" xorm:"not null NVARCHAR(80)"`
- Lotsize float32 `json:"LotSize" xorm:"FLOAT(8)"`
- Abcclass string `json:"ABCClass" xorm:"not null NVARCHAR(2)"`
- Artsize1 string `json:"ArtSize1" xorm:"not null NVARCHAR(200)"`
- Artsize2 string `json:"ArtSize2" xorm:"not null NVARCHAR(200)"`
- Artsize3 string `json:"ArtSize3" xorm:"not null NVARCHAR(200)"`
- Artsize4 string `json:"ArtSize4" xorm:"not null NVARCHAR(200)"`
- Artsize5 string `json:"ArtSize5" xorm:"not null NVARCHAR(200)"`
- Artspec1 string `json:"ArtSpec1" xorm:"not null NVARCHAR(200)"`
- Artspec2 string `json:"ArtSpec2" xorm:"not null NVARCHAR(200)"`
- Artspec3 string `json:"ArtSpec3" xorm:"not null NVARCHAR(200)"`
- Artspec4 string `json:"ArtSpec4" xorm:"not null NVARCHAR(200)"`
- Artspec5 string `json:"ArtSpec5" 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 *Article) TableName() string {
- return "Article"
- }
-
- /******************************************************************************
- *
- * @Function Name :
- *-----------------------------------------------------------------------------
- *
- * @Description : 数据添加
- *
- * @Function Parameters:
- *
- * @Return Value :
- *
- * @Author : Lou Wenzhi
- *
- * @Date : 2021/3/6 8:47
- *
- ******************************************************************************/
- func (t *Article) Add() error {
- e := db.Eloquent.Master()
- arttab := new(Article)
- /**主键:****/
- affw, err := e.Table(t.TableName()).ID(core.PK{t.Plantnr, t.Artid}).Count(arttab)
- 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 *Article) Del() (err error) {
- e := db.Eloquent.Master()
- if _, err := e.ID(core.PK{t.Plantnr, t.Artid}).Delete(&Article{}); err != nil {
- return
- }
- return
- }
-
- /******************************************************************************
- *
- * @Function Name :
- *-----------------------------------------------------------------------------
- *
- * @Description : 数据修改
- *
- * @Function Parameters:
- *
- * @Return Value :
- *
- * @Author : Lou Wenzhi
- *
- * @Date : 2021/3/6 8:47
- *
- ******************************************************************************/
- func (t *Article) Update() (err error) {
- e := db.Eloquent.Master()
- /**主键:****/
- if _, err := e.ID(core.PK{t.Plantnr, t.Artid}).Update(t);err != nil {
- return
- }
- return
- }
-
- /******************************************************************************
- *
- * @Function Name :
- *-----------------------------------------------------------------------------
- *
- * @Description : 数据查找
- *
- * @Function Parameters:
- *
- * @Return Value :
- *
- * @Author : Lou Wenzhi
- *
- * @Date : 2021/3/6 8:47
- *
- ******************************************************************************/
- func (t *Article) SelectOne() (data Article,err error) {
- e := db.Eloquent.Master()
- /******/
- if _, err := e.ID(core.PK{t.Plantnr, t.Artid}).Get(&data);err != nil {
- return
- }
- return
- }
|