|
@@ -10,6 +10,7 @@ import (
|
|
cModel "gas-cylinder-api/common/model"
|
|
cModel "gas-cylinder-api/common/model"
|
|
log "gogs.baozhida.cn/zoie/OAuth-core/logger"
|
|
log "gogs.baozhida.cn/zoie/OAuth-core/logger"
|
|
"gogs.baozhida.cn/zoie/OAuth-core/service"
|
|
"gogs.baozhida.cn/zoie/OAuth-core/service"
|
|
|
|
+ "gorm.io/gorm/utils"
|
|
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm"
|
|
"time"
|
|
"time"
|
|
@@ -70,7 +71,7 @@ func (e *OperationLog) Get(d *dto.OperationLogGetReq, carInfoModel *model.Operat
|
|
func (e *OperationLog) Insert(c *dto.OperationLogInsertReq, p *actions.DataPermission) error {
|
|
func (e *OperationLog) Insert(c *dto.OperationLogInsertReq, p *actions.DataPermission) error {
|
|
var err error
|
|
var err error
|
|
data := make([]model.OperationLog, 0)
|
|
data := make([]model.OperationLog, 0)
|
|
- company, err := model.GetProvCode(p.DeptId)
|
|
|
|
|
|
+ //company, err := model.GetProvCodeById(p.DeptId)
|
|
if err != nil {
|
|
if err != nil {
|
|
e.Log.Errorf("db error: %s", err)
|
|
e.Log.Errorf("db error: %s", err)
|
|
return global.CreateFailedErr
|
|
return global.CreateFailedErr
|
|
@@ -91,17 +92,32 @@ func (e *OperationLog) Insert(c *dto.OperationLogInsertReq, p *actions.DataPermi
|
|
switch c.OptType {
|
|
switch c.OptType {
|
|
case "25", "27":
|
|
case "25", "27":
|
|
// 送气员领重瓶
|
|
// 送气员领重瓶
|
|
|
|
+ // 查询门店
|
|
|
|
+ store, err := model.GetDeptByCmpCode(c.CurrentEnterprise)
|
|
|
|
+ if err != nil {
|
|
|
|
+ tx.Rollback()
|
|
|
|
+ log.Errorf("db error: %s", err)
|
|
|
|
+ return errors.New("获取门店信息失败")
|
|
|
|
+ }
|
|
for _, chipUid := range c.ChipUidList {
|
|
for _, chipUid := range c.ChipUidList {
|
|
// 1、通过高频ID查询气瓶内编码
|
|
// 1、通过高频ID查询气瓶内编码
|
|
var gasCylinder model.GasCylinder
|
|
var gasCylinder model.GasCylinder
|
|
err = tx.Where("uid = ?", chipUid).First(&gasCylinder).Error
|
|
err = tx.Where("uid = ?", chipUid).First(&gasCylinder).Error
|
|
|
|
+ if err != nil {
|
|
|
|
+ tx.Rollback()
|
|
|
|
+ log.Errorf("db error: %s", err)
|
|
|
|
+ return global.CreateFailedErr
|
|
|
|
+ }
|
|
operationLog := model.OperationLog{
|
|
operationLog := model.OperationLog{
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
InnerCode: gasCylinder.InnerCode,
|
|
InnerCode: gasCylinder.InnerCode,
|
|
OptType: c.OptType,
|
|
OptType: c.OptType,
|
|
OptUser: user.ProvUserId,
|
|
OptUser: user.ProvUserId,
|
|
CompanyId: user.ProvUser.CmpCode,
|
|
CompanyId: user.ProvUser.CmpCode,
|
|
- CurrentEnterprise: company.CmpCode,
|
|
|
|
|
|
+ CurrentEnterprise: user.ProvUser.CmpCode,
|
|
|
|
+ CurrentStore: store.CmpCode,
|
|
|
|
+ Lng: utils.ToString(store.ProvStore.Lng),
|
|
|
|
+ Lat: utils.ToString(store.ProvStore.Lat),
|
|
OptTime: time.Now().Format("2006-01-02 15:04:05"),
|
|
OptTime: time.Now().Format("2006-01-02 15:04:05"),
|
|
},
|
|
},
|
|
ControlBy: cModel.ControlBy{
|
|
ControlBy: cModel.ControlBy{
|
|
@@ -165,6 +181,8 @@ func (e *OperationLog) Insert(c *dto.OperationLogInsertReq, p *actions.DataPermi
|
|
CompanyId: user.ProvUser.CmpCode,
|
|
CompanyId: user.ProvUser.CmpCode,
|
|
CurrentEnterprise: user.ProvUser.CmpCode,
|
|
CurrentEnterprise: user.ProvUser.CmpCode,
|
|
CurrentStore: user.ProvUser.CmpCode,
|
|
CurrentStore: user.ProvUser.CmpCode,
|
|
|
|
+ Lng: utils.ToString(user.Dept.ProvStore.Lng),
|
|
|
|
+ Lat: utils.ToString(user.Dept.ProvStore.Lat),
|
|
OptTime: time.Now().Format("2006-01-02 15:04:05"),
|
|
OptTime: time.Now().Format("2006-01-02 15:04:05"),
|
|
},
|
|
},
|
|
ControlBy: cModel.ControlBy{
|
|
ControlBy: cModel.ControlBy{
|