From b9e669c2442f3f36f9f697f620f0b83c24acfe96 Mon Sep 17 00:00:00 2001 From: louwenzhi Date: Fri, 21 May 2021 15:33:02 +0800 Subject: [PATCH] =?UTF-8?q?portal=20=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yaml | 69 +++++ dao/log/ArtDemandHead.dao.go | 53 +++- dao/log/ArtDemandLst.dao.go | 51 ++-- dao/log/implments/ArtDemandHead.dao.impl.go | 46 +++ dao/log/implments/ArtDemandLst.dao.impl.go | 45 +-- models/log/log.go | 93 ++++++ services/log/ArtDemandHead.service.go | 19 ++ services/log/ArtDemandLst.service.go | 19 -- .../implments/ArtDemandHead.service.impl.go | 20 ++ .../implments/ArtDemandLst.service.impl.go | 270 ++++++++++-------- web/controllers/log/ArtDemandHead.rest.go | 33 +++ web/controllers/log/ArtDemandLst.rest.go | 33 --- web/controllers/log/log.go | 4 +- 13 files changed, 554 insertions(+), 201 deletions(-) create mode 100644 config.yaml diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..eac2eab --- /dev/null +++ b/config.yaml @@ -0,0 +1,69 @@ +# 配置输出 支持三种输出 db file 和console +# db为数据库输出 目前支持输出到mongo 配置为map +db: + mongo1: + dbtype: mongo + host: 127.0.0.1 + port: 27017 + database: GAAS_MOM + # mongo的collection + Table: LOG + mongo2: + dbtype: mongo + host: 127.0.0.1 + port: 27017 + database: GAAS_MOM + # mongo的collection + Table: LOG2 + +# file为输出到文件 配置为map 按天分割 +file: + common: + # 文件location + filename: ./log/common.log + # 支持文件的最大个数 + MaxAge: 30 + user: + # 文件location + filename: ./log/user.log + # 支持文件的最大个数 + MaxAge: 7 + +# console 为输出到控制台 +console: + enable: true # bool 是否输出到控制台 + + +# module配置输出源 配置为map +config: + # root为根配置 默认配置 module未配置则使用root配置 + + + root: + # 此处的file、db、console名称可以随意起 见文知意即可 + file: + # drivertype 为驱动类型 file-文件 db-数据库 console-控制台 + drivertype: file + level: debug + # drivername 需要和output的map 键值相同 + drivername: common +# db: +# drivertype: db +# level: debug +# drivername: mongo1 + console: + drivertype: console + level: debug + drivername: console + user: + file: + # drivertype 为驱动类型 file-文件 db-数据库 console-控制台 + drivertype: file + level: info + # drivername 需要和output的map 键值相同 + drivername: user + db: + drivertype: db + level: debug + drivername: mongo2 + diff --git a/dao/log/ArtDemandHead.dao.go b/dao/log/ArtDemandHead.dao.go index 46a22a3..e7d1487 100644 --- a/dao/log/ArtDemandHead.dao.go +++ b/dao/log/ArtDemandHead.dao.go @@ -39,6 +39,23 @@ type ArtDemandHeadDAO interface { * ******************************************************************************/ InsertOne(*model.ArtDemandHead) error + /****************************************************************************** + * + * @Function Name : SyncInsertOne + *----------------------------------------------------------------------------- + * + * @Description : 插入一条ArtDemandHead + * + * @Function Parameters : 需要插入的ArtDemandHead + * + * @Return Value : 执行时发生的错误 + * + * @Author : 代码生成器创建 + * + * @Date : 2021-03-24 09:53:49 + * + ******************************************************************************/ + SyncInsertOne(*model.SyncArtDemandHead) error /****************************************************************************** * * @Function Name : DeleteOne @@ -95,7 +112,24 @@ type ArtDemandHeadDAO interface { * @Date : 2021-03-24 09:53:49 * ******************************************************************************/ - UpdateOne(*model.ArtDemandHead) error + UpdateOne(head *model.ArtDemandHead) error + /****************************************************************************** + * + * @Function Name : UpdateOne + *----------------------------------------------------------------------------- + * + * @Description : 修改ArtDemandHead + * + * @Function Parameters : 需要修改的ArtDemandHead + * + * @Return Value : 执行时发生的错误 + * + * @Author : 娄文智 + * + * @Date : 2021-03-24 09:53:49 + * + ******************************************************************************/ + SyncUpdateOne(head *model.SyncArtDemandHead) error /****************************************************************************** * * @Function Name : Insert @@ -299,6 +333,23 @@ type ArtDemandHeadDAO interface { * ******************************************************************************/ SelectWithoutAuthority([]grmi.Predicate, []grmi.Field) ([]model.ArtDemandHead, error) + /****************************************************************************** + * + * @Function Name : SelectLastModify + *----------------------------------------------------------------------------- + * + * @Description : 按条件查询最后一条ArtDemandHead + * + * @Return Value : 查询结果 + * + * @Return Value : 执行时发生的错误 + * + * @Author : 娄文智 + * + * @Date : 2021-05-07 + * + ******************************************************************************/ + SelectLastModify() (model.ArtDemandHead, error) } /****************************************************************************** diff --git a/dao/log/ArtDemandLst.dao.go b/dao/log/ArtDemandLst.dao.go index 2d8a5e6..49e450a 100644 --- a/dao/log/ArtDemandLst.dao.go +++ b/dao/log/ArtDemandLst.dao.go @@ -39,6 +39,23 @@ type ArtDemandLstDAO interface { * ******************************************************************************/ InsertOne(*model.ArtDemandLst) error + /****************************************************************************** + * + * @Function Name : SyncInsertOne + *----------------------------------------------------------------------------- + * + * @Description : 插入一条ArtDemandLst + * + * @Function Parameters : 需要插入的ArtDemandLst + * + * @Return Value : 执行时发生的错误 + * + * @Author : 代码生成器创建 + * + * @Date : 2021-04-22 11:27:55 + * + ******************************************************************************/ + SyncInsertOne(*model.SyncArtDemandLst) error /****************************************************************************** * * @Function Name : DeleteOne @@ -96,6 +113,23 @@ type ArtDemandLstDAO interface { * ******************************************************************************/ UpdateOne(*model.ArtDemandLst) error + /****************************************************************************** + * + * @Function Name : SyncUpdateOne + *----------------------------------------------------------------------------- + * + * @Description : 修改ArtDemandLst + * + * @Function Parameters : 需要修改的ArtDemandLst + * + * @Return Value : 执行时发生的错误 + * + * @Author : 代码生成器创建 + * + * @Date : 2021-04-22 11:27:55 + * + ******************************************************************************/ + SyncUpdateOne(lst *model.SyncArtDemandLst) error /****************************************************************************** * * @Function Name : Insert @@ -276,23 +310,6 @@ type ArtDemandLstDAO interface { * ******************************************************************************/ SelectWithoutAuthority([]grmi.Predicate, []grmi.Field) ([]model.ArtDemandLst, error) - /****************************************************************************** - * - * @Function Name : SelectLastModify - *----------------------------------------------------------------------------- - * - * @Description : 按条件查询最后一条WorkOrder - * - * @Return Value : 查询结果 - * - * @Return Value : 执行时发生的错误 - * - * @Author : 娄文智 - * - * @Date : 2021-05-07 - * - ******************************************************************************/ - SelectLastModify() (model.ArtDemandLst, error) } /****************************************************************************** diff --git a/dao/log/implments/ArtDemandHead.dao.impl.go b/dao/log/implments/ArtDemandHead.dao.impl.go index 416cda7..8cd528b 100644 --- a/dao/log/implments/ArtDemandHead.dao.impl.go +++ b/dao/log/implments/ArtDemandHead.dao.impl.go @@ -70,6 +70,21 @@ func (impl *ArtDemandHeadDAOImplement) InsertOne(entity *model.ArtDemandHead) er return nil } +/****************************************************************************** + * + * @Reference LAPP_GAAS_GFrame_BACKEND/dao/log/ArtDemandHeadDAO.InsertOne + * + ******************************************************************************/ +func (impl *ArtDemandHeadDAOImplement) SyncInsertOne(entity *model.SyncArtDemandHead) error { + entity.PlantNr = impl.plantNr + entity.LastUser = impl.userid + _, err := impl.session.Table(impl.meta.TableName).Insert(entity) + if err != nil { + return grmi.NewDataBaseError(err) + } + return nil +} + /****************************************************************************** * * @Reference LAPP_GAAS_GFrame_BACKEND/dao/log/ArtDemandHeadDAO.DeleteOne @@ -119,6 +134,22 @@ func (impl *ArtDemandHeadDAOImplement) UpdateOne(entity *model.ArtDemandHead) er return nil } +/****************************************************************************** + * + * @Reference LAPP_GAAS_GFrame_BACKEND/dao/log/ArtDemandHeadDAO.SyncUpdateOne + * + ******************************************************************************/ +func (impl *ArtDemandHeadDAOImplement) SyncUpdateOne(entity *model.SyncArtDemandHead) error { + entity.PlantNr = impl.plantNr + entity.LastUser = impl.userid + _, err := impl.session.Table(impl.meta.TableName).Cols(impl.meta.UpdatingMembers...).ID(core.PK{entity.PlantNr,entity.ArtId,entity.DemandId}).Update(entity) + if err != nil { + return grmi.NewDataBaseError(err) + } + return nil +} + + /****************************************************************************** * * @Reference LAPP_GAAS_GFrame_BACKEND/dao/log/ArtDemandHeadDAO.Insert @@ -413,3 +444,18 @@ func (impl *ArtDemandHeadDAOImplement) SelectWithoutAuthority (predicates []grmi } return data, nil } +/****************************************************************************** + * + * @Reference LAPP_GAAS_GFrame_BACKEND/dao/log/ArtDemandHeadDAO.SelectLastModify + * + ******************************************************************************/ +func (impl *ArtDemandHeadDAOImplement) SelectLastModify() (data model.ArtDemandHead, err error) { + ok, err := impl.session.Table(impl.meta.TableName).Where("PlantNr = ? ", impl.plantNr).Desc("LastModify").Limit(1).Get(&data) + if err != nil { + return data, grmi.NewDataBaseError(err) + } + if !ok { + return data, grmi.NewBusinessError("数据不存在!") + } + return data, nil +} \ No newline at end of file diff --git a/dao/log/implments/ArtDemandLst.dao.impl.go b/dao/log/implments/ArtDemandLst.dao.impl.go index e7a57f8..7214770 100644 --- a/dao/log/implments/ArtDemandLst.dao.impl.go +++ b/dao/log/implments/ArtDemandLst.dao.impl.go @@ -69,7 +69,20 @@ func (impl *ArtDemandLstDAOImplement) InsertOne(entity *model.ArtDemandLst) erro } return nil } - +/****************************************************************************** + * + * @Reference LAPP_GAAS_GFrame_BACKEND/dao/log/ArtDemandLstDAO.SyncInsertOne + * + ******************************************************************************/ +func (impl *ArtDemandLstDAOImplement) SyncInsertOne(entity *model.SyncArtDemandLst) error { + entity.PlantNr = impl.plantNr + entity.LastUser = impl.userid + _, err := impl.session.Table(impl.meta.TableName).Insert(entity) + if err != nil { + return grmi.NewDataBaseError(err) + } + return nil +} /****************************************************************************** * * @Reference LAPP_GAAS_GFrame_BACKEND/dao/log/ArtDemandLstDAO.DeleteOne @@ -119,6 +132,21 @@ func (impl *ArtDemandLstDAOImplement) UpdateOne(entity *model.ArtDemandLst) erro return nil } +/****************************************************************************** + * + * @Reference LAPP_GAAS_GFrame_BACKEND/dao/log/ArtDemandLstDAO.UpdateOne + * + ******************************************************************************/ +func (impl *ArtDemandLstDAOImplement) SyncUpdateOne(entity *model.SyncArtDemandLst) error { + entity.PlantNr = impl.plantNr + entity.LastUser = impl.userid + _, err := impl.session.Table(impl.meta.TableName).Cols(impl.meta.UpdatingMembers...).ID(core.PK{entity.PlantNr,entity.DemandId,entity.Pos}).Update(entity) + if err != nil { + return grmi.NewDataBaseError(err) + } + return nil +} + /****************************************************************************** * * @Reference LAPP_GAAS_GFrame_BACKEND/dao/log/ArtDemandLstDAO.Insert @@ -395,18 +423,3 @@ func (impl *ArtDemandLstDAOImplement) SelectWithoutAuthority (predicates []grmi. return data, nil } -/****************************************************************************** - * - * @Reference LAPP_GAAS_GFrame_BACKEND/dao/log/ArtDemandLstDAO.SelectLastModify - * - ******************************************************************************/ -func (impl *ArtDemandLstDAOImplement) SelectLastModify() (data model.ArtDemandLst, err error) { - ok, err := impl.session.Table(impl.meta.TableName).Where("PlantNr = ? ", impl.plantNr).Desc("LastModify").Limit(1).Get(&data) - if err != nil { - return data, grmi.NewDataBaseError(err) - } - if !ok { - return data, grmi.NewBusinessError("数据不存在!") - } - return data, nil -} \ No newline at end of file diff --git a/models/log/log.go b/models/log/log.go index 52126c2..2cfbc58 100644 --- a/models/log/log.go +++ b/models/log/log.go @@ -1,5 +1,7 @@ package log +import "LAPP_GAAS_GFrame_BACKEND/grmi" + // 供应商需求明细状态值 const ( WaitReceivingStatus int = iota // 初始状态 @@ -110,3 +112,94 @@ type VendorUserLstInsert struct { VendorId string `json:"vendorId"` Records []VendorUserLst `json:"records"` } +/****************************************************************************** + * + * @Struct Name : SyncArtDemandHead + *----------------------------------------------------------------------------- + * + * @Description : ArtDemandHead的实体映射 + * + * @Author : 代码生成器创建 + * + * @Date : 2021-05-10 18:11:08 + * + ******************************************************************************/ +type SyncArtDemandHead struct { + PlantNr int `xorm:"pk int 'PlantNr'" json:"LOG_ArtDemandHead-PlantNr"` + ArtId string `xorm:"pk nvarchar(40) 'ArtId'" json:"LOG_ArtDemandHead-ArtId"` + DemandId string `xorm:"pk nvarchar(40) 'DemandId'" json:"LOG_ArtDemandHead-DemandId"` + DemandType string `xorm:"nvarchar(40) 'DemandType' not null" json:"LOG_ArtDemandHead-DemandType"` + DemandYear int `xorm:"int 'DemandYear' not null" json:"LOG_ArtDemandHead-DemandYear"` + DemandMonth int `xorm:"int 'DemandMonth' not null" json:"LOG_ArtDemandHead-DemandMonth"` + DemandWeek int `xorm:"int 'DemandWeek' not null" json:"LOG_ArtDemandHead-DemandWeek"` + DemandDate grmi.Date `xorm:"date 'DemandDate' not null" json:"LOG_ArtDemandHead-DemandDate"` + DemandHour int `xorm:"int 'DemandHour' not null" json:"LOG_ArtDemandHead-DemandHour"` + DemandTime grmi.DateTime `xorm:"datetime 'DemandTime'" json:"LOG_ArtDemandHead-DemandTime"` + DemandQty float64 `xorm:"float 'DemandQty' not null" json:"LOG_ArtDemandHead-DemandQty"` + QtyUomId string `xorm:"nvarchar(40) 'QtyUomId' not null" json:"LOG_ArtDemandHead-QtyUomId"` + Status int `xorm:"int 'Status' not null" json:"LOG_ArtDemandHead-Status"` + DemandSendTime grmi.DateTime `xorm:"datetime 'DemandSendTime'" json:"LOG_ArtDemandHead-DemandSendTime"` + DemandRecieveTime grmi.DateTime `xorm:"datetime 'DemandRecieveTime'" json:"LOG_ArtDemandHead-DemandRecieveTime"` + DemandConfirmTime grmi.DateTime `xorm:"datetime 'DemandConfirmTime'" json:"LOG_ArtDemandHead-DemandConfirmTime"` + DemandCloseTime grmi.DateTime `xorm:"datetime 'DemandCloseTime'" json:"LOG_ArtDemandHead-DemandCloseTime"` + DemandDeliveredQty float64 `xorm:"float 'DemandDeliveredQty' not null" json:"LOG_ArtDemandHead-DemandDeliveredQty"` + DemandCtrlPara1 int `xorm:"int 'DemandCtrlPara1' not null" json:"LOG_ArtDemandHead-DemandCtrlPara1"` + DemandCtrlPara2 int `xorm:"int 'DemandCtrlPara2' not null" json:"LOG_ArtDemandHead-DemandCtrlPara2"` + DemandCtrlPara3 string `xorm:"nvarchar(100) 'DemandCtrlPara3' not null" json:"LOG_ArtDemandHead-DemandCtrlPara3"` + DemandCtrlPara4 string `xorm:"nvarchar(100) 'DemandCtrlPara4' not null" json:"LOG_ArtDemandHead-DemandCtrlPara4"` + DemandCtrlTime1 grmi.DateTime `xorm:"datetime 'DemandCtrlTime1'" json:"LOG_ArtDemandHead-DemandCtrlTime1"` + DemandCtrlTime2 grmi.DateTime `xorm:"datetime 'DemandCtrlTime2'" json:"LOG_ArtDemandHead-DemandCtrlTime2"` + OrderStatus int `xorm:"int 'OrderStatus' not null" json:"LOG_ArtDemandHead-OrderStatus"` + UnproducedQty float64 `xorm:"float 'UnproducedQty' not null" json:"LOG_ArtDemandHead-UnproducedQty"` + Source string `xorm:"nvarchar(20) 'Source' not null" json:"LOG_ArtDemandHead-Source"` + LastModify grmi.DateTime `xorm:"datetime 'LastModify' not null" json:"LOG_ArtDemandHead-LastModify"` + LastUser string `xorm:"nvarchar(20) 'LastUser' not null" json:"LOG_ArtDemandHead-LastUser"` + CreateTime grmi.DateTime `xorm:"datetime 'CreateTime' not null" json:"LOG_ArtDemandHead-CreateTime"` +} + +/****************************************************************************** + * + * @Struct Name : SyncArtDemandLst + *----------------------------------------------------------------------------- + * + * @Description : ArtDemandLst的实体映射 + * + * @Author : 代码生成器创建 + * + * @Date : 2021-05-10 18:11:08 + * + ******************************************************************************/ +type SyncArtDemandLst struct { + PlantNr int `xorm:"pk int 'PlantNr'" json:"LOG_ArtDemandLst-PlantNr"` + DemandId string `xorm:"pk nvarchar(40) 'DemandId'" json:"LOG_ArtDemandLst-DemandId"` + Pos int `xorm:"pk int 'Pos'" json:"LOG_ArtDemandLst-Pos"` + ArtId string `xorm:"nvarchar(40) 'ArtId' not null" json:"LOG_ArtDemandLst-ArtId"` + DemandTime grmi.DateTime `xorm:"datetime2(0) 'DemandTime' not null" json:"LOG_ArtDemandLst-DemandTime"` + DemandYear int `xorm:"int 'DemandYear' not null" json:"LOG_ArtDemandLst-DemandYear"` + DemandMonth int `xorm:"int 'DemandMonth' not null" json:"LOG_ArtDemandLst-DemandMonth"` + DemandWeek int `xorm:"int 'DemandWeek' not null" json:"LOG_ArtDemandLst-DemandWeek"` + DemandDate grmi.Date `xorm:"date 'DemandDate' not null" json:"LOG_ArtDemandLst-DemandDate"` + DemandHour int `xorm:"int 'DemandHour' not null" json:"LOG_ArtDemandLst-DemandHour"` + DemandQty float64 `xorm:"float 'DemandQty' not null" json:"LOG_ArtDemandLst-DemandQty"` + QtyUomId string `xorm:"nvarchar(40) 'QtyUomId' not null" json:"LOG_ArtDemandLst-QtyUomId"` + DemandObjId string `xorm:"nvarchar(40) 'DemandObjId' not null" json:"LOG_ArtDemandLst-DemandObjId"` + DemandType string `xorm:"nvarchar(40) 'DemandType' not null" json:"LOG_ArtDemandLst-DemandType"` + Status int `xorm:"int 'Status' not null" json:"LOG_ArtDemandLst-Status"` + DemandSendTime grmi.DateTime `xorm:"datetime 'DemandSendTime'" json:"LOG_ArtDemandLst-DemandSendTime"` + DemandRecieveTime grmi.DateTime `xorm:"datetime 'DemandRecieveTime'" json:"LOG_ArtDemandLst-DemandRecieveTime"` + DemandConfirmTime grmi.DateTime `xorm:"datetime 'DemandConfirmTime'" json:"LOG_ArtDemandLst-DemandConfirmTime"` + DemandCloseTime grmi.DateTime `xorm:"datetime 'DemandCloseTime'" json:"LOG_ArtDemandLst-DemandCloseTime"` + DemandDeliveredQty float64 `xorm:"float 'DemandDeliveredQty' not null" json:"LOG_ArtDemandLst-DemandDeliveredQty"` + DemandCtrlPara1 int `xorm:"int 'DemandCtrlPara1' not null" json:"LOG_ArtDemandLst-DemandCtrlPara1"` + DemandCtrlPara2 int `xorm:"int 'DemandCtrlPara2' not null" json:"LOG_ArtDemandLst-DemandCtrlPara2"` + DemandCtrlPara3 string `xorm:"nvarchar(100) 'DemandCtrlPara3' not null" json:"LOG_ArtDemandLst-DemandCtrlPara3"` + DemandCtrlPara4 string `xorm:"nvarchar(100) 'DemandCtrlPara4' not null" json:"LOG_ArtDemandLst-DemandCtrlPara4"` + DemandCtrlTime1 grmi.DateTime `xorm:"datetime 'DemandCtrlTime1'" json:"LOG_ArtDemandLst-DemandCtrlTime1"` + DemandCtrlTime2 grmi.DateTime `xorm:"datetime 'DemandCtrlTime2'" json:"LOG_ArtDemandLst-DemandCtrlTime2"` + OrderStatus int `xorm:"int 'OrderStatus' not null" json:"LOG_ArtDemandLst-OrderStatus"` + UnproducedQty float64 `xorm:"float 'UnproducedQty' not null" json:"LOG_ArtDemandLst-UnproducedQty"` + Source string `xorm:"nvarchar(20) 'Source'" json:"LOG_ArtDemandLst-Source"` + LastModify grmi.DateTime `xorm:"datetime 'LastModify' not null" json:"LOG_ArtDemandLst-LastModify"` + LastUser string `xorm:"nvarchar(20) 'LastUser' not null" json:"LOG_ArtDemandLst-LastUser"` + CreateTime grmi.DateTime `xorm:"datetime 'CreateTime' not null" json:"LOG_ArtDemandLst-CreateTime"` +} \ No newline at end of file diff --git a/services/log/ArtDemandHead.service.go b/services/log/ArtDemandHead.service.go index df130f2..84f1700 100644 --- a/services/log/ArtDemandHead.service.go +++ b/services/log/ArtDemandHead.service.go @@ -237,6 +237,25 @@ type ArtDemandHeadService interface { * ******************************************************************************/ TransferDataToOrigin(string, string, int) + /****************************************************************************** + * + * @Function Name : SelectLastModify + *----------------------------------------------------------------------------- + * + * @Description : 查询最后一个ArtDemandLst订单 + * + * @Function Parameters : 当前访问人员信息 + * + * @Function Parameters : 查询参数 + * + * @Return Value : 执行时发生的错误 + * + * @Author : 娄文智 + * + * @Date : 2021-05-07 + * + ******************************************************************************/ + SelectLastModify(plantNr int) (string, error) } /****************************************************************************** diff --git a/services/log/ArtDemandLst.service.go b/services/log/ArtDemandLst.service.go index 8a235ad..3c1252a 100644 --- a/services/log/ArtDemandLst.service.go +++ b/services/log/ArtDemandLst.service.go @@ -219,25 +219,6 @@ type ArtDemandLstService interface { * ******************************************************************************/ ChangeArtDemandLstStatus(*models.Usertab, []model.ArtDemandLstStatusChange, string) error - /****************************************************************************** - * - * @Function Name : SelectLastModify - *----------------------------------------------------------------------------- - * - * @Description : 查询最后一个ArtDemandLst订单 - * - * @Function Parameters : 当前访问人员信息 - * - * @Function Parameters : 查询参数 - * - * @Return Value : 执行时发生的错误 - * - * @Author : 娄文智 - * - * @Date : 2021-05-07 - * - ******************************************************************************/ - SelectLastModify(plantNr int) (string, error) /****************************************************************************** * * @Function Name : SyncHronousData diff --git a/services/log/implments/ArtDemandHead.service.impl.go b/services/log/implments/ArtDemandHead.service.impl.go index 06dde5f..cd90d1c 100644 --- a/services/log/implments/ArtDemandHead.service.impl.go +++ b/services/log/implments/ArtDemandHead.service.impl.go @@ -1005,3 +1005,23 @@ func (impl *ArtDemandHeadServiceImplement) SaveToExcel(headLi *[]model.ArtDemand //return pathLi[1], nil return filepath, nil } + +/****************************************************************************** + * + * @Reference LAPP_GAAS_GFrame_BACKEND/services/log/ArtDemandLstService.SelectLastModify + * + ******************************************************************************/ +func (impl *ArtDemandHeadServiceImplement) SelectLastModify(plantNr int) (string, error) { + + //grmi.Log(user, "/services/om/implments/WorkOrder.service.impl.go", "SelectLastModify", "查询最后一个WorkOrder订单") + + engine := db.Eloquent.Master() + session := engine.NewSession() + defer session.Close() + dao := dal.NewArtDemandHeadDAO(session, plantNr, "syncPost") + data, err := dao.SelectLastModify() + if err != nil { + return "", err + } + return data.LastModify.ToString(), nil +} \ No newline at end of file diff --git a/services/log/implments/ArtDemandLst.service.impl.go b/services/log/implments/ArtDemandLst.service.impl.go index 816330c..2567aa9 100644 --- a/services/log/implments/ArtDemandLst.service.impl.go +++ b/services/log/implments/ArtDemandLst.service.impl.go @@ -810,26 +810,6 @@ func (impl *ArtDemandLstServiceImplement) ChangeArtDemandLstStatus(user *models. return nil } -/****************************************************************************** - * - * @Reference LAPP_GAAS_GFrame_BACKEND/services/log/ArtDemandLstService.SelectLastModify - * - ******************************************************************************/ -func (impl *ArtDemandLstServiceImplement) SelectLastModify(plantNr int) (string, error) { - - //grmi.Log(user, "/services/om/implments/WorkOrder.service.impl.go", "SelectLastModify", "查询最后一个WorkOrder订单") - - engine := db.Eloquent.Master() - session := engine.NewSession() - defer session.Close() - dao := dal.NewArtDemandLstDAO(session, plantNr, "syncPost") - data, err := dao.SelectLastModify() - if err != nil { - return "", err - } - return data.LastModify.ToString(), nil -} - /****************************************************************************** * * @Reference LAPP_GAAS_GFrame_BACKEND/services/log/ArtDemandLstService.SyncHronousData @@ -847,125 +827,189 @@ func (impl *ArtDemandLstServiceImplement) SyncHronousData(plantNr int, filePath if err != nil { return err } - heads := make([]model.ArtDemandHead, 0) + heads := make([]model.SyncArtDemandHead, 0) for k, row := range rows { if k == 0 { continue } - head := model.ArtDemandHead{} + head := model.SyncArtDemandHead{} head.PlantNr = utils.ValueToInt(row[0], 0) head.ArtId = utils.ValueToString(row[1], "") head.DemandId = utils.ValueToString(row[2], "") head.DemandType = utils.ValueToString(row[3], "") - head.DemandYear = utils.ValueToInt(row[3], 0) - head.DemandMonth = utils.ValueToInt(row[4], 0) - head.DemandWeek = utils.ValueToInt(row[5], 0) - DemandDateStr := utils.ValueToString(row[6], "") - DemandDate, _ := utils.TimeParseyyyyMMdd(DemandDateStr) + head.DemandYear = utils.ValueToInt(row[4], 0) + head.DemandMonth = utils.ValueToInt(row[5], 0) + head.DemandWeek = utils.ValueToInt(row[6], 0) + DemandDateStr := utils.ValueToString(row[7], "") + DemandDate, err := utils.TimeParseyyyyMMdd(DemandDateStr) + if err != nil{ + return err + } head.DemandDate = grmi.Date(DemandDate) - head.DemandHour = utils.ValueToInt(row[7], 0) - DemandTimeStr := utils.ValueToString(row[8], "") - DemandTime, _ := utils.TimeParseyyyyMMdd(DemandTimeStr) + head.DemandHour = utils.ValueToInt(row[8], 0) + DemandTimeStr := utils.ValueToString(row[9], "") + DemandTime, err := utils.TimeParse(DemandTimeStr) + if err != nil{ + return err + } head.DemandTime = grmi.DateTime(DemandTime) - head.DemandQty = utils.ValueToFloat(row[9], 0.0) - head.QtyUomId = utils.ValueToString(row[10], "") - head.Status = utils.ValueToInt(row[11], 0) - DemandSendTimeStr := utils.ValueToString(row[12], "") - DemandSendTime, _ := utils.TimeParseyyyyMMdd(DemandSendTimeStr) - head.DemandSendTime = grmi.DateTime(DemandSendTime) - DemandSendTimeStr = utils.ValueToString(row[13], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - head.DemandRecieveTime = grmi.DateTime(DemandSendTime) + head.DemandQty = utils.ValueToFloat(row[10], 0.0) + head.QtyUomId = utils.ValueToString(row[11], "") + head.Status = utils.ValueToInt(row[12], 0) + DemandSendTimeStr := utils.ValueToString(row[13], "") + if DemandSendTimeStr != "0001-01-01 00:00:00"{ + DemandSendTime, err := utils.TimeParse(DemandSendTimeStr) + if err != nil{ + return err + } + head.DemandSendTime = grmi.DateTime(DemandSendTime) + } DemandSendTimeStr = utils.ValueToString(row[14], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - head.DemandConfirmTime = grmi.DateTime(DemandSendTime) + if DemandSendTimeStr != "0001-01-01 00:00:00"{ + DemandSendTime, err := utils.TimeParse(DemandSendTimeStr) + if err != nil{ + return err + } + head.DemandRecieveTime = grmi.DateTime(DemandSendTime) + } DemandSendTimeStr = utils.ValueToString(row[15], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - head.DemandCloseTime = grmi.DateTime(DemandSendTime) - head.DemandDeliveredQty = utils.ValueToFloat(row[16], 0.0) - head.DemandCtrlPara1 = utils.ValueToInt(row[17], 0) - head.DemandCtrlPara2 = utils.ValueToInt(row[18], 0) - head.DemandCtrlPara3 = utils.ValueToString(row[19], "") - head.DemandCtrlPara4 = utils.ValueToString(row[20], "") - DemandSendTimeStr = utils.ValueToString(row[21], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - head.DemandCtrlTime1 = grmi.DateTime(DemandSendTime) + if DemandSendTimeStr != "0001-01-01 00:00:00" { + DemandSendTime, err := utils.TimeParse(DemandSendTimeStr) + if err != nil { + return err + } + head.DemandConfirmTime = grmi.DateTime(DemandSendTime) + } + DemandSendTimeStr = utils.ValueToString(row[16], "") + if DemandSendTimeStr != "0001-01-01 00:00:00" { + DemandSendTime, err := utils.TimeParse(DemandSendTimeStr) + if err != nil { + return err + } + head.DemandCloseTime = grmi.DateTime(DemandSendTime) + } + head.DemandDeliveredQty = utils.ValueToFloat(row[17], 0.0) + head.DemandCtrlPara1 = utils.ValueToInt(row[18], 0) + head.DemandCtrlPara2 = utils.ValueToInt(row[19], 0) + head.DemandCtrlPara3 = utils.ValueToString(row[20], "") + head.DemandCtrlPara4 = utils.ValueToString(row[21], "") DemandSendTimeStr = utils.ValueToString(row[22], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - head.DemandCtrlTime2 = grmi.DateTime(DemandSendTime) - head.OrderStatus = utils.ValueToInt(row[23], 0) - DemandSendTimeStr = utils.ValueToString(row[24], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - head.LastModify = grmi.DateTime(DemandSendTime) - head.LastUser = utils.ValueToString(row[25], "") - DemandSendTimeStr = utils.ValueToString(row[26], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - head.CreateTime = grmi.DateTime(DemandSendTime) + if DemandSendTimeStr != "0001-01-01 00:00:00" { + DemandSendTime, err := utils.TimeParse(DemandSendTimeStr) + if err != nil { + return err + } + head.DemandCtrlTime1 = grmi.DateTime(DemandSendTime) + } + DemandSendTimeStr = utils.ValueToString(row[23], "") + if DemandSendTimeStr != "0001-01-01 00:00:00" { + DemandSendTime, err := utils.TimeParse(DemandSendTimeStr) + if err != nil { + return err + } + head.DemandCtrlTime2 = grmi.DateTime(DemandSendTime) + } + head.OrderStatus = utils.ValueToInt(row[24], 0) + head.UnproducedQty = utils.ValueToFloat(row[25], 0.0) + head.Source = utils.ValueToString(row[26], "") + LastModifyStr := utils.ValueToString(row[27], "") + LastModify, err := utils.TimeParse(LastModifyStr) + if err != nil{ + return err + } + head.LastModify = grmi.DateTime(LastModify) + head.LastUser = utils.ValueToString(row[28], "") + DemandSendTimeStr = utils.ValueToString(row[29], "") + if DemandSendTimeStr != "0001-01-01 00:00:00" { + DemandSendTime, err := utils.TimeParse(DemandSendTimeStr) + if err != nil { + return err + } + head.CreateTime = grmi.DateTime(DemandSendTime) + } heads = append(heads, head) } - - // 获取 ArtDemandHead 上所有单元格 + // 获取 ArtDemandLst 上所有单元格 rows, err = f.GetRows("ArtDemandLst") if err != nil { return err } - lst := make([]model.ArtDemandLst, 0) + lst := make([]model.SyncArtDemandLst, 0) for k, row := range rows { if k == 0 { continue } - one := model.ArtDemandLst{} + one := model.SyncArtDemandLst{} one.PlantNr = utils.ValueToInt(row[0], 0) one.DemandId = utils.ValueToString(row[1], "") - one.DemandYear = utils.ValueToInt(row[2], 0) + one.Pos = utils.ValueToInt(row[2], 0) one.ArtId = utils.ValueToString(row[3], "") DemandTimeStr := utils.ValueToString(row[4], "") - DemandTime, _ := utils.TimeParseyyyyMMdd(DemandTimeStr) - one.DemandTime = grmi.DateTime(DemandTime) - one.DemandType = utils.ValueToString(row[5], "") - one.DemandYear = utils.ValueToInt(row[6], 0) - one.DemandMonth = utils.ValueToInt(row[7], 0) - one.DemandWeek = utils.ValueToInt(row[8], 0) - DemandDateStr := utils.ValueToString(row[9], "") + if DemandTimeStr != "0001-01-01 00:00:00" { + DemandTime, _ := utils.TimeParse(DemandTimeStr) + one.DemandTime = grmi.DateTime(DemandTime) + } + one.DemandYear = utils.ValueToInt(row[5], 0) + one.DemandMonth = utils.ValueToInt(row[6], 0) + one.DemandWeek = utils.ValueToInt(row[7], 0) + DemandDateStr := utils.ValueToString(row[8], "") DemandDate, _ := utils.TimeParseyyyyMMdd(DemandDateStr) one.DemandDate = grmi.Date(DemandDate) - one.DemandHour = utils.ValueToInt(row[7], 0) - one.DemandQty = utils.ValueToFloat(row[9], 0.0) - one.QtyUomId = utils.ValueToString(row[10], "") - one.DemandObjId = utils.ValueToString(row[11], "") - one.DemandType = utils.ValueToString(row[12], "") - one.Status = utils.ValueToInt(row[13], 0) - DemandSendTimeStr := utils.ValueToString(row[14], "") - DemandSendTime, _ := utils.TimeParseyyyyMMdd(DemandSendTimeStr) - one.DemandSendTime = grmi.DateTime(DemandSendTime) - DemandSendTimeStr = utils.ValueToString(row[13], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - one.DemandRecieveTime = grmi.DateTime(DemandSendTime) - DemandSendTimeStr = utils.ValueToString(row[14], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - one.DemandConfirmTime = grmi.DateTime(DemandSendTime) - DemandSendTimeStr = utils.ValueToString(row[15], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - one.DemandCloseTime = grmi.DateTime(DemandSendTime) - one.DemandDeliveredQty = utils.ValueToFloat(row[16], 0.0) - one.DemandCtrlPara1 = utils.ValueToInt(row[17], 0) - one.DemandCtrlPara2 = utils.ValueToInt(row[18], 0) - one.DemandCtrlPara3 = utils.ValueToString(row[19], "") - one.DemandCtrlPara4 = utils.ValueToString(row[20], "") - DemandSendTimeStr = utils.ValueToString(row[21], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - one.DemandCtrlTime1 = grmi.DateTime(DemandSendTime) - DemandSendTimeStr = utils.ValueToString(row[22], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - one.DemandCtrlTime2 = grmi.DateTime(DemandSendTime) - one.OrderStatus = utils.ValueToInt(row[23], 0) + one.DemandHour = utils.ValueToInt(row[9], 0) + one.DemandQty = utils.ValueToFloat(row[10], 0.0) + one.QtyUomId = utils.ValueToString(row[11], "") + one.DemandObjId = utils.ValueToString(row[12], "") + one.DemandType = utils.ValueToString(row[13], "") + one.Status = utils.ValueToInt(row[14], 0) + DemandSendTimeStr := utils.ValueToString(row[15], "") + if DemandSendTimeStr != "0001-01-01 00:00:00" { + DemandSendTime, _ := utils.TimeParse(DemandSendTimeStr) + one.DemandSendTime = grmi.DateTime(DemandSendTime) + } + DemandSendTimeStr = utils.ValueToString(row[16], "") + if DemandSendTimeStr != "0001-01-01 00:00:00" { + DemandSendTime, _ := utils.TimeParse(DemandSendTimeStr) + one.DemandRecieveTime = grmi.DateTime(DemandSendTime) + } + DemandSendTimeStr = utils.ValueToString(row[17], "") + if DemandSendTimeStr != "0001-01-01 00:00:00" { + DemandSendTime, _ := utils.TimeParse(DemandSendTimeStr) + one.DemandConfirmTime = grmi.DateTime(DemandSendTime) + } + DemandSendTimeStr = utils.ValueToString(row[18], "") + if DemandSendTimeStr != "0001-01-01 00:00:00" { + DemandSendTime, _ := utils.TimeParse(DemandSendTimeStr) + one.DemandCloseTime = grmi.DateTime(DemandSendTime) + } + one.DemandDeliveredQty = utils.ValueToFloat(row[19], 0.0) + one.DemandCtrlPara1 = utils.ValueToInt(row[20], 0) + one.DemandCtrlPara2 = utils.ValueToInt(row[21], 0) + one.DemandCtrlPara3 = utils.ValueToString(row[22], "") + one.DemandCtrlPara4 = utils.ValueToString(row[23], "") DemandSendTimeStr = utils.ValueToString(row[24], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - one.LastModify = grmi.DateTime(DemandSendTime) - one.LastUser = utils.ValueToString(row[25], "") - DemandSendTimeStr = utils.ValueToString(row[26], "") - DemandSendTime, _ = utils.TimeParseyyyyMMdd(DemandSendTimeStr) - one.CreateTime = grmi.DateTime(DemandSendTime) + if DemandSendTimeStr != "0001-01-01 00:00:00" { + DemandSendTime, _ := utils.TimeParse(DemandSendTimeStr) + one.DemandCtrlTime1 = grmi.DateTime(DemandSendTime) + } + DemandSendTimeStr = utils.ValueToString(row[25], "") + if DemandSendTimeStr != "0001-01-01 00:00:00" { + DemandSendTime, _ := utils.TimeParse(DemandSendTimeStr) + one.DemandCtrlTime2 = grmi.DateTime(DemandSendTime) + } + one.OrderStatus = utils.ValueToInt(row[26], 0) + one.UnproducedQty = utils.ValueToFloat(row[27], 0.0) + one.Source = utils.ValueToString(row[28], "") + DemandSendTimeStr = utils.ValueToString(row[29], "") + if DemandSendTimeStr != "0001-01-01 00:00:00" { + DemandSendTime, _ := utils.TimeParse(DemandSendTimeStr) + one.LastModify = grmi.DateTime(DemandSendTime) + } + one.LastUser = utils.ValueToString(row[30], "") + DemandSendTimeStr = utils.ValueToString(row[31], "") + if DemandSendTimeStr != "0001-01-01 00:00:00" { + DemandSendTime, _ := utils.TimeParse(DemandSendTimeStr) + one.CreateTime = grmi.DateTime(DemandSendTime) + } lst = append(lst, one) } @@ -985,13 +1029,13 @@ func (impl *ArtDemandLstServiceImplement) SyncHronousData(plantNr int, filePath return err } if ok != nil { - err = dao.UpdateOne(&v) + err = dao.SyncUpdateOne(&v) if err != nil { session.Rollback() return err } } else { - err = dao.InsertOne(&v) + err = dao.SyncInsertOne(&v) if err != nil { session.Rollback() return err @@ -1005,13 +1049,13 @@ func (impl *ArtDemandLstServiceImplement) SyncHronousData(plantNr int, filePath return err } if ok != nil { - err = logdao.UpdateOne(&vv) + err = logdao.SyncUpdateOne(&vv) if err != nil { session.Rollback() return err } } else { - err = logdao.InsertOne(&vv) + err = logdao.SyncInsertOne(&vv) if err != nil { session.Rollback() return err diff --git a/web/controllers/log/ArtDemandHead.rest.go b/web/controllers/log/ArtDemandHead.rest.go index 40186d8..e97b729 100644 --- a/web/controllers/log/ArtDemandHead.rest.go +++ b/web/controllers/log/ArtDemandHead.rest.go @@ -485,4 +485,37 @@ func RegisterAccomplishArtDemandHead(party router.Party, path string, method fun } supports.Ok(ctx, supports.OptionSuccess, nil) }) +} + + +/****************************************************************************** + * + * @Function Name : RegisterSelectLastModify + *----------------------------------------------------------------------------- + * + * @Description : 为一个查询WorkOrder的方法注册路由 + * + * @Function Parameters : 路由分组 + * + * @Function Parameters : 路径 + * + * @Function Parameters : 实际处理请求的方法 + * + * @Author : 代码生成器创建 + * + * @Date : 2021-04-19 14:04:47 + * + ******************************************************************************/ +func RegisterSelectLastModify(party router.Party, path string, method func(int) (string, error)) { + + party.Get(path, func(ctx iris.Context) { + plantNr, _ := ctx.URLParamInt("plantNr") + + result, err := method(plantNr) + if err != nil { + supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil) + return + } + supports.Ok(ctx, supports.OptionSuccess, result) + }) } \ No newline at end of file diff --git a/web/controllers/log/ArtDemandLst.rest.go b/web/controllers/log/ArtDemandLst.rest.go index 16ddddc..bead199 100644 --- a/web/controllers/log/ArtDemandLst.rest.go +++ b/web/controllers/log/ArtDemandLst.rest.go @@ -531,39 +531,6 @@ func RegisterAccomplishArtDemandLst(party router.Party, path string, method func }) } -/****************************************************************************** - * - * @Function Name : RegisterSelectLastModify - *----------------------------------------------------------------------------- - * - * @Description : 为一个查询WorkOrder的方法注册路由 - * - * @Function Parameters : 路由分组 - * - * @Function Parameters : 路径 - * - * @Function Parameters : 实际处理请求的方法 - * - * @Author : 代码生成器创建 - * - * @Date : 2021-04-19 14:04:47 - * - ******************************************************************************/ -func RegisterSelectLastModify(party router.Party, path string, method func(int) (string, error)) { - - party.Get(path, func(ctx iris.Context) { - plantNr, _ := ctx.URLParamInt("plantNr") - - result, err := method(plantNr) - if err != nil { - supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil) - return - } - supports.Ok(ctx, supports.OptionSuccess, result) - }) -} - - /****************************************************************************** * * @Function Name : RegisterSyncHronousData diff --git a/web/controllers/log/log.go b/web/controllers/log/log.go index 8bb1e22..cf78bdf 100644 --- a/web/controllers/log/log.go +++ b/web/controllers/log/log.go @@ -53,6 +53,8 @@ func RegisterRoutes() { RegisterConfirmArtDemandHead(artdemandhead, "/confirm", serviceOfArtDemandHead.ChangeArtDemandHeadStatus) // 供应商需求批次完成 RegisterAccomplishArtDemandHead(artdemandhead, "/accomplish", serviceOfArtDemandHead.ChangeArtDemandHeadStatus) + //获取最后的时间戳 + RegisterSelectLastModify(artdemandhead, "/selectlastmodify", serviceOfArtDemandHead.SelectLastModify) // ArtDemandLst的路由组 artdemandlst := party.Party("/artdemandlst") @@ -86,8 +88,6 @@ func RegisterRoutes() { RegisterAccomplishArtDemandLst(artdemandlst, "/accomplish", serviceOfArtDemandLst.ChangeArtDemandLstStatus) //接收文件 RegisterInsertSyncHronousData(artdemandlst, "/synchronous", serviceOfArtDemandLst.SyncHronousData) - //获取最后的时间戳 - RegisterSelectLastModify(artdemandlst, "/selectlastmodify", serviceOfArtDemandLst.SelectLastModify) // Vendor的路由组 vendor := party.Party("/vendor")