|
|
@@ -30,6 +30,11 @@ func (e *GasCylinderAllot) GetPage(c *dto.GasCylinderAllotGetPageReq, list *[]mo
|
|
|
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
|
|
|
actions.Permission(data.TableName(), p),
|
|
|
).
|
|
|
+ Where("allot_user_id = ?", p.UserId).
|
|
|
+ Preload("AllotUser").
|
|
|
+ Preload("AcceptUser").
|
|
|
+ Preload("AllotCompany").
|
|
|
+ Preload("AcceptCompany").
|
|
|
Find(list).Limit(-1).Offset(-1).
|
|
|
Count(count).Error
|
|
|
if err != nil {
|
|
|
@@ -84,6 +89,10 @@ func (e *GasCylinderAllot) Insert(c *dto.GasCylinderAllotInsertReq) error {
|
|
|
var err error
|
|
|
var data model.GasCylinderAllot
|
|
|
|
|
|
+ if err = e.Check(c); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
tx := e.Orm.Begin()
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
@@ -118,6 +127,28 @@ func (e *GasCylinderAllot) Insert(c *dto.GasCylinderAllotInsertReq) error {
|
|
|
|
|
|
}
|
|
|
|
|
|
+func (e *GasCylinderAllot) Check(c *dto.GasCylinderAllotInsertReq) error {
|
|
|
+
|
|
|
+ if global.CheckElementExists(c.OptType, []string{"016", "17", "033", "31", "35", "25"}) {
|
|
|
+ if c.GasCylinderStatus != model.GasCylinderStatusWeighty {
|
|
|
+ return errors.New("该流转步骤仅能接收重瓶!")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if global.CheckElementExists(c.OptType, []string{"11", "13", "21"}) {
|
|
|
+ if c.GasCylinderStatus != model.GasCylinderStatusEmpty {
|
|
|
+ return errors.New("该流转步骤仅能接收空瓶!")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if global.CheckElementExists(c.OptType, []string{"Unqualified"}) {
|
|
|
+ if c.GasCylinderStatus != model.GasCylinderStatusUnqualified {
|
|
|
+ return errors.New("该流转步骤仅能接收不合格瓶!")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
// Update 修改GasCylinderAllot对象
|
|
|
func (e *GasCylinderAllot) Update(c *dto.GasCylinderAllotUpdateReq, p *actions.DataPermission) error {
|
|
|
var err error
|
|
|
@@ -297,19 +328,19 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
switch c.OptType {
|
|
|
case "25":
|
|
|
// 25送气员领重瓶 37 门店重瓶出库
|
|
|
- for _, chipUid := range c.InnerCodeList {
|
|
|
+ for _, innerCode := range c.InnerCodeList {
|
|
|
// 1、通过高频ID查询气瓶内编码
|
|
|
- var gasCylinder model.GasCylinder
|
|
|
- err = tx.Where("uid = ?", chipUid).First(&gasCylinder).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return global.CreateFailedErr
|
|
|
- }
|
|
|
+ //var gasCylinder model.GasCylinder
|
|
|
+ //err = tx.Where("uid = ?", innerCode).First(&gasCylinder).Error
|
|
|
+ //if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return global.CreateFailedErr
|
|
|
+ //}
|
|
|
|
|
|
// 25送气员领重瓶
|
|
|
operationLog25 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: c.OptType,
|
|
|
OptUser: acceptUser.ProvUserId,
|
|
|
ObjectUser: acceptUser.ProvUserId,
|
|
|
@@ -331,7 +362,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
// 37 门店重瓶出库
|
|
|
operationLog37 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: "37",
|
|
|
OptUser: allotUser.ProvUserId,
|
|
|
ObjectUser: allotUser.ProvUserId,
|
|
|
@@ -352,7 +383,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
data = append(data, operationLog37)
|
|
|
|
|
|
gasCylinderStatus := &model.GasCylinderStatus{
|
|
|
- InnerCode: chipUid,
|
|
|
+ InnerCode: innerCode,
|
|
|
UserId: acceptUser.Id,
|
|
|
CompanyId: acceptUser.Dept.Id,
|
|
|
Status: model.GasCylinderStatusWeighty,
|
|
|
@@ -365,7 +396,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
|
|
|
// 添加送气员重瓶
|
|
|
- err = tx.Where(model.GasCylinderStatus{InnerCode: chipUid, UserId: acceptUser.Id, CompanyId: acceptUser.Dept.Id}).
|
|
|
+ err = tx.Where(model.GasCylinderStatus{InnerCode: innerCode, UserId: acceptUser.Id, CompanyId: acceptUser.Dept.Id}).
|
|
|
Assign(model.GasCylinderStatus{Status: model.GasCylinderStatusWeighty}).FirstOrCreate(&gasCylinderStatus).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
@@ -381,19 +412,19 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
case "21":
|
|
|
// 21门店回收空瓶 27送气员回收空瓶
|
|
|
- for _, chipUid := range c.InnerCodeList {
|
|
|
+ for _, innerCode := range c.InnerCodeList {
|
|
|
// 1、通过高频ID查询气瓶内编码
|
|
|
- var gasCylinder model.GasCylinder
|
|
|
- err = tx.Where("uid = ?", chipUid).First(&gasCylinder).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return global.CreateFailedErr
|
|
|
- }
|
|
|
+ //var gasCylinder model.GasCylinder
|
|
|
+ //err = tx.Where("uid = ?", innerCode).First(&gasCylinder).Error
|
|
|
+ //if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return global.CreateFailedErr
|
|
|
+ //}
|
|
|
|
|
|
// 21门店回收空瓶
|
|
|
operationLog21 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: c.OptType,
|
|
|
ObjectUser: acceptUser.ProvUserId,
|
|
|
OptUser: acceptUser.ProvUserId,
|
|
|
@@ -415,7 +446,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
|
|
|
// 添加门店空瓶
|
|
|
gasCylinderStatus := &model.GasCylinderStatus{
|
|
|
- InnerCode: chipUid,
|
|
|
+ InnerCode: innerCode,
|
|
|
UserId: 0,
|
|
|
CompanyId: acceptUser.Dept.Id,
|
|
|
Status: model.GasCylinderStatusWeighty,
|
|
|
@@ -426,7 +457,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
DeptId: acceptUser.DeptId,
|
|
|
},
|
|
|
}
|
|
|
- err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", chipUid, acceptUser.Dept.Id).
|
|
|
+ err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", innerCode, acceptUser.Dept.Id).
|
|
|
Assign(model.GasCylinderStatus{Status: model.GasCylinderStatusEmpty}).FirstOrCreate(&gasCylinderStatus).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
@@ -442,14 +473,14 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
case "11":
|
|
|
// 10 门店空瓶出库 11 司机确认空瓶装车
|
|
|
- for _, chipUid := range c.InnerCodeList {
|
|
|
+ for _, innerCode := range c.InnerCodeList {
|
|
|
// 1、通过高频ID查询气瓶内编码
|
|
|
- var gasCylinder model.GasCylinder
|
|
|
- err = tx.Where("uid = ?", chipUid).First(&gasCylinder).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return global.CreateFailedErr
|
|
|
- }
|
|
|
+ //var gasCylinder model.GasCylinder
|
|
|
+ //err = tx.Where("uid = ?", innerCode).First(&gasCylinder).Error
|
|
|
+ //if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return global.CreateFailedErr
|
|
|
+ //}
|
|
|
|
|
|
// 11 司机确认空瓶装车
|
|
|
var truckUserCarInfo model.TruckUserCarInfo
|
|
|
@@ -461,7 +492,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
operationLog11 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: c.OptType,
|
|
|
ObjectUser: acceptUser.ProvUserId,
|
|
|
OptUser: acceptUser.ProvUserId,
|
|
|
@@ -483,7 +514,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
// 10 门店空瓶出库
|
|
|
operationLog10 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: "10",
|
|
|
ObjectUser: acceptUser.ProvUserId,
|
|
|
OptUser: allotUser.ProvUserId,
|
|
|
@@ -505,7 +536,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
|
|
|
data = append(data, operationLog11)
|
|
|
gasCylinderStatus := &model.GasCylinderStatus{
|
|
|
- InnerCode: chipUid,
|
|
|
+ InnerCode: innerCode,
|
|
|
UserId: acceptUser.Id,
|
|
|
CompanyId: acceptUser.Dept.Id,
|
|
|
Status: model.GasCylinderStatusWeighty,
|
|
|
@@ -518,7 +549,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
|
|
|
// 添加司机空瓶
|
|
|
- err = tx.Where(model.GasCylinderStatus{InnerCode: chipUid, UserId: acceptUser.Id, CompanyId: acceptUser.Dept.Id}).
|
|
|
+ err = tx.Where(model.GasCylinderStatus{InnerCode: innerCode, UserId: acceptUser.Id, CompanyId: acceptUser.Dept.Id}).
|
|
|
Assign(model.GasCylinderStatus{Status: model.GasCylinderStatusEmpty}).FirstOrCreate(&gasCylinderStatus).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
@@ -534,14 +565,14 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
case "13":
|
|
|
// 12 司机运输空瓶到达气站 13 气站确认空瓶到达气站
|
|
|
- for _, chipUid := range c.InnerCodeList {
|
|
|
+ for _, innerCode := range c.InnerCodeList {
|
|
|
// 1、通过高频ID查询气瓶内编码
|
|
|
- var gasCylinder model.GasCylinder
|
|
|
- err = tx.Where("uid = ?", chipUid).First(&gasCylinder).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return global.CreateFailedErr
|
|
|
- }
|
|
|
+ //var gasCylinder model.GasCylinder
|
|
|
+ //err = tx.Where("uid = ?", innerCode).First(&gasCylinder).Error
|
|
|
+ //if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return global.CreateFailedErr
|
|
|
+ //}
|
|
|
var truckUserCarInfo model.TruckUserCarInfo
|
|
|
err = tx.Where("prov_user_id = ?", allotUser.ProvUserId).First(&truckUserCarInfo).Error
|
|
|
if err != nil {
|
|
|
@@ -553,7 +584,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
// 13 气站确认空瓶到达气站
|
|
|
operationLog13 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: c.OptType,
|
|
|
ObjectUser: acceptUser.ProvUserId,
|
|
|
OptUser: acceptUser.ProvUserId,
|
|
|
@@ -576,7 +607,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
// 12 司机运输空瓶到达气站
|
|
|
operationLog12 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: "12",
|
|
|
ObjectUser: allotUser.ProvUserId,
|
|
|
OptUser: allotUser.ProvUserId,
|
|
|
@@ -597,7 +628,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
data = append(data, operationLog12)
|
|
|
|
|
|
gasCylinderStatus := &model.GasCylinderStatus{
|
|
|
- InnerCode: chipUid,
|
|
|
+ InnerCode: innerCode,
|
|
|
UserId: 0,
|
|
|
CompanyId: acceptUser.Dept.Id,
|
|
|
Status: model.GasCylinderStatusEmpty,
|
|
|
@@ -610,7 +641,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
|
|
|
// 添加气站空瓶
|
|
|
- err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", chipUid, acceptUser.Dept.Id).
|
|
|
+ err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", innerCode, acceptUser.Dept.Id).
|
|
|
Assign(model.GasCylinderStatus{Status: model.GasCylinderStatusEmpty}).FirstOrCreate(&gasCylinderStatus).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
@@ -626,14 +657,14 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
case "17":
|
|
|
// 15 气站重瓶出库 17 司机确认重瓶从气站出库
|
|
|
- for _, chipUid := range c.InnerCodeList {
|
|
|
+ for _, innerCode := range c.InnerCodeList {
|
|
|
// 1、通过高频ID查询气瓶内编码
|
|
|
- var gasCylinder model.GasCylinder
|
|
|
- err = tx.Where("uid = ?", chipUid).First(&gasCylinder).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return global.CreateFailedErr
|
|
|
- }
|
|
|
+ //var gasCylinder model.GasCylinder
|
|
|
+ //err = tx.Where("uid = ?", innerCode).First(&gasCylinder).Error
|
|
|
+ //if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return global.CreateFailedErr
|
|
|
+ //}
|
|
|
var truckUserCarInfo model.TruckUserCarInfo
|
|
|
err = tx.Where("prov_user_id = ?", acceptUser.ProvUserId).First(&truckUserCarInfo).Error
|
|
|
if err != nil {
|
|
|
@@ -651,7 +682,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
operationLog17 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: c.OptType,
|
|
|
OptUser: acceptUser.ProvUserId,
|
|
|
CompanyId: acceptUser.ProvUser.CmpCode,
|
|
|
@@ -673,7 +704,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
// 15 气站重瓶出库
|
|
|
operationLog15 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: "15",
|
|
|
OptUser: allotUser.ProvUserId,
|
|
|
ObjectUser: allotUser.ProvUserId,
|
|
|
@@ -695,7 +726,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
|
|
|
// 司机添加重瓶
|
|
|
gasCylinderStatus := &model.GasCylinderStatus{
|
|
|
- InnerCode: chipUid,
|
|
|
+ InnerCode: innerCode,
|
|
|
UserId: acceptUser.Id,
|
|
|
CompanyId: acceptUser.Dept.Id,
|
|
|
Status: model.GasCylinderStatusWeighty,
|
|
|
@@ -706,7 +737,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
DeptId: acceptUser.DeptId,
|
|
|
},
|
|
|
}
|
|
|
- err = tx.Where(model.GasCylinderStatus{InnerCode: chipUid, UserId: acceptUser.Id, CompanyId: acceptUser.Dept.Id}).
|
|
|
+ err = tx.Where(model.GasCylinderStatus{InnerCode: innerCode, UserId: acceptUser.Id, CompanyId: acceptUser.Dept.Id}).
|
|
|
Assign(model.GasCylinderStatus{Status: model.GasCylinderStatusWeighty}).FirstOrCreate(&gasCylinderStatus).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
@@ -723,14 +754,14 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
case "31":
|
|
|
// 19 司机交付门店 31 门店确认重瓶卸货入库
|
|
|
- for _, chipUid := range c.InnerCodeList {
|
|
|
+ for _, innerCode := range c.InnerCodeList {
|
|
|
// 1、通过高频ID查询气瓶内编码
|
|
|
- var gasCylinder model.GasCylinder
|
|
|
- err = tx.Where("uid = ?", chipUid).First(&gasCylinder).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return global.CreateFailedErr
|
|
|
- }
|
|
|
+ //var gasCylinder model.GasCylinder
|
|
|
+ //err = tx.Where("uid = ?", innerCode).First(&gasCylinder).Error
|
|
|
+ //if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return global.CreateFailedErr
|
|
|
+ //}
|
|
|
var truckUserCarInfo model.TruckUserCarInfo
|
|
|
err = tx.Where("prov_user_id = ?", allotUser.ProvUserId).First(&truckUserCarInfo).Error
|
|
|
if err != nil {
|
|
|
@@ -742,7 +773,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
// 31 门店确认重瓶卸货入库
|
|
|
operationLog31 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: c.OptType,
|
|
|
OptUser: acceptUser.ProvUserId,
|
|
|
ObjectUser: acceptUser.ProvUserId,
|
|
|
@@ -765,7 +796,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
// 19 司机交付门店
|
|
|
operationLog19 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: "19",
|
|
|
OptUser: allotUser.ProvUserId,
|
|
|
ObjectUser: allotUser.ProvUserId,
|
|
|
@@ -786,7 +817,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
data = append(data, operationLog19)
|
|
|
|
|
|
gasCylinderStatus := &model.GasCylinderStatus{
|
|
|
- InnerCode: chipUid,
|
|
|
+ InnerCode: innerCode,
|
|
|
UserId: 0,
|
|
|
CompanyId: acceptUser.Dept.Id,
|
|
|
Status: model.GasCylinderStatusWeighty,
|
|
|
@@ -799,7 +830,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
|
|
|
// 门店添加重瓶
|
|
|
- err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", chipUid, acceptUser.Dept.Id).
|
|
|
+ err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", innerCode, acceptUser.Dept.Id).
|
|
|
Assign(model.GasCylinderStatus{Status: model.GasCylinderStatusWeighty}).FirstOrCreate(&gasCylinderStatus).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
@@ -816,32 +847,18 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
case "35":
|
|
|
// 35 门店确认未配送重瓶返库
|
|
|
- for _, chipUid := range c.InnerCodeList {
|
|
|
+ for _, innerCode := range c.InnerCodeList {
|
|
|
// 1、通过高频ID查询气瓶内编码
|
|
|
- var gasCylinder model.GasCylinder
|
|
|
- err = tx.Where("uid = ?", chipUid).First(&gasCylinder).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return global.CreateFailedErr
|
|
|
- }
|
|
|
- var truckUserCarInfo model.TruckUserCarInfo
|
|
|
- err = tx.Where("prov_user_id = ?", allotUser.ProvUserId).First(&truckUserCarInfo).Error
|
|
|
- if err != nil {
|
|
|
- tx.Rollback()
|
|
|
- e.Log.Errorf("获取车辆信息失败: %s", err)
|
|
|
- return errors.New("获取车辆信息失败")
|
|
|
- }
|
|
|
+ //var gasCylinder model.GasCylinder
|
|
|
+ //err = tx.Where("uid = ?", innerCode).First(&gasCylinder).Error
|
|
|
+ //if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return global.CreateFailedErr
|
|
|
+ //}
|
|
|
|
|
|
- // 2、上报气瓶流转信息
|
|
|
- err = tx.Where("prov_user_id = ?", acceptUser.ProvUserId).First(&truckUserCarInfo).Error
|
|
|
- if err != nil {
|
|
|
- tx.Rollback()
|
|
|
- e.Log.Errorf("获取车辆信息失败: %s", err)
|
|
|
- return errors.New("获取车辆信息失败")
|
|
|
- }
|
|
|
operationLog35 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: c.OptType,
|
|
|
OptUser: acceptUser.ProvUserId,
|
|
|
CompanyId: acceptUser.ProvUser.CmpCode,
|
|
|
@@ -861,7 +878,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
data = append(data, operationLog35)
|
|
|
|
|
|
gasCylinderStatus := &model.GasCylinderStatus{
|
|
|
- InnerCode: chipUid,
|
|
|
+ InnerCode: innerCode,
|
|
|
UserId: 0,
|
|
|
CompanyId: acceptUser.Dept.Id,
|
|
|
Status: model.GasCylinderStatusWeighty,
|
|
|
@@ -874,7 +891,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
|
|
|
// 门店添加重瓶
|
|
|
- err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", chipUid, acceptUser.Dept.Id).
|
|
|
+ err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", innerCode, acceptUser.Dept.Id).
|
|
|
Assign(model.GasCylinderStatus{Status: model.GasCylinderStatusWeighty}).FirstOrCreate(&gasCylinderStatus).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
@@ -891,14 +908,14 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
case "033":
|
|
|
// 33 门店将重瓶退回司机
|
|
|
- for _, chipUid := range c.InnerCodeList {
|
|
|
+ for _, innerCode := range c.InnerCodeList {
|
|
|
// 1、通过高频ID查询气瓶内编码
|
|
|
- var gasCylinder model.GasCylinder
|
|
|
- err = tx.Where("uid = ?", chipUid).First(&gasCylinder).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return global.CreateFailedErr
|
|
|
- }
|
|
|
+ //var gasCylinder model.GasCylinder
|
|
|
+ //err = tx.Where("uid = ?", innerCode).First(&gasCylinder).Error
|
|
|
+ //if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return global.CreateFailedErr
|
|
|
+ //}
|
|
|
var truckUserCarInfo model.TruckUserCarInfo
|
|
|
// 2、上报气瓶流转信息
|
|
|
err = tx.Where("prov_user_id = ?", acceptUser.ProvUserId).First(&truckUserCarInfo).Error
|
|
|
@@ -909,7 +926,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
operationLog33 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: "33",
|
|
|
OptUser: allotUser.ProvUserId,
|
|
|
CompanyId: allotUser.ProvUser.CmpCode,
|
|
|
@@ -929,7 +946,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
data = append(data, operationLog33)
|
|
|
|
|
|
gasCylinderStatus := &model.GasCylinderStatus{
|
|
|
- InnerCode: chipUid,
|
|
|
+ InnerCode: innerCode,
|
|
|
UserId: acceptUser.Id,
|
|
|
CompanyId: acceptUser.Dept.Id,
|
|
|
Status: model.GasCylinderStatusWeighty,
|
|
|
@@ -942,7 +959,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
|
|
|
// 司机添加重瓶
|
|
|
- err = tx.Where(model.GasCylinderStatus{InnerCode: chipUid, UserId: acceptUser.Id, CompanyId: acceptUser.Dept.Id}).
|
|
|
+ err = tx.Where(model.GasCylinderStatus{InnerCode: innerCode, UserId: acceptUser.Id, CompanyId: acceptUser.Dept.Id}).
|
|
|
Assign(model.GasCylinderStatus{Status: model.GasCylinderStatusWeighty}).FirstOrCreate(&gasCylinderStatus).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
@@ -959,14 +976,14 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
case "016":
|
|
|
// 16 司机将订单退回气站
|
|
|
- for _, chipUid := range c.InnerCodeList {
|
|
|
+ for _, innerCode := range c.InnerCodeList {
|
|
|
// 1、通过高频ID查询气瓶内编码
|
|
|
- var gasCylinder model.GasCylinder
|
|
|
- err = tx.Where("uid = ?", chipUid).First(&gasCylinder).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return global.CreateFailedErr
|
|
|
- }
|
|
|
+ //var gasCylinder model.GasCylinder
|
|
|
+ //err = tx.Where("uid = ?", innerCode).First(&gasCylinder).Error
|
|
|
+ //if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return global.CreateFailedErr
|
|
|
+ //}
|
|
|
|
|
|
// 2、上报气瓶流转信息
|
|
|
var truckUserCarInfo model.TruckUserCarInfo
|
|
|
@@ -978,7 +995,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
operationLog16 := model.OperationLog{
|
|
|
ProvOperationLog: model.ProvOperationLog{
|
|
|
- InnerCode: gasCylinder.InnerCode,
|
|
|
+ InnerCode: innerCode,
|
|
|
OptType: "16",
|
|
|
ObjectUser: allotUser.ProvUserId,
|
|
|
OptUser: allotUser.ProvUserId,
|
|
|
@@ -1000,7 +1017,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
data = append(data, operationLog16)
|
|
|
|
|
|
gasCylinderStatus := &model.GasCylinderStatus{
|
|
|
- InnerCode: chipUid,
|
|
|
+ InnerCode: innerCode,
|
|
|
UserId: 0,
|
|
|
CompanyId: acceptUser.Dept.Id,
|
|
|
Status: model.GasCylinderStatusWeighty,
|
|
|
@@ -1013,7 +1030,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
|
|
|
// 气站添加重瓶
|
|
|
- err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", chipUid, acceptUser.Dept.Id).
|
|
|
+ err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", innerCode, acceptUser.Dept.Id).
|
|
|
Assign(model.GasCylinderStatus{Status: model.GasCylinderStatusWeighty}).FirstOrCreate(&gasCylinderStatus).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
@@ -1034,10 +1051,10 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
if allotUser.ProvUser.UserType == 3 && allotUser.ProvUser.Isorders == 0 {
|
|
|
// 送气员到门店 送气员不合格- 门店+
|
|
|
if acceptUser.ProvUser.UserType == 3 && acceptUser.ProvUser.Isorders == 1 {
|
|
|
- for _, chipUid := range c.InnerCodeList {
|
|
|
+ for _, innerCode := range c.InnerCodeList {
|
|
|
|
|
|
gasCylinderStatus := &model.GasCylinderStatus{
|
|
|
- InnerCode: chipUid,
|
|
|
+ InnerCode: innerCode,
|
|
|
UserId: 0,
|
|
|
CompanyId: acceptUser.Dept.Id,
|
|
|
Status: model.GasCylinderStatusUnqualified,
|
|
|
@@ -1050,7 +1067,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
|
|
|
// 门店添加不合格瓶
|
|
|
- err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", chipUid, acceptUser.Dept.Id).
|
|
|
+ err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", innerCode, acceptUser.Dept.Id).
|
|
|
Assign(model.GasCylinderStatus{Status: model.GasCylinderStatusUnqualified}).FirstOrCreate(&gasCylinderStatus).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
@@ -1072,10 +1089,10 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
} else if allotUser.ProvUser.UserType == 3 && allotUser.ProvUser.Isorders == 1 {
|
|
|
// 门店到司机 门店- 司机+
|
|
|
if acceptUser.ProvUser.UserType == 4 {
|
|
|
- for _, chipUid := range c.InnerCodeList {
|
|
|
+ for _, innerCode := range c.InnerCodeList {
|
|
|
|
|
|
gasCylinderStatus := &model.GasCylinderStatus{
|
|
|
- InnerCode: chipUid,
|
|
|
+ InnerCode: innerCode,
|
|
|
UserId: acceptUser.Id,
|
|
|
CompanyId: acceptUser.Dept.Id,
|
|
|
Status: model.GasCylinderStatusUnqualified,
|
|
|
@@ -1088,7 +1105,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
|
|
|
// 司机添加不合格瓶
|
|
|
- err = tx.Where(model.GasCylinderStatus{InnerCode: chipUid, UserId: acceptUser.Id, CompanyId: acceptUser.Dept.Id}).
|
|
|
+ err = tx.Where(model.GasCylinderStatus{InnerCode: innerCode, UserId: acceptUser.Id, CompanyId: acceptUser.Dept.Id}).
|
|
|
Assign(model.GasCylinderStatus{Status: model.GasCylinderStatusUnqualified}).FirstOrCreate(&gasCylinderStatus).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
@@ -1108,12 +1125,45 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
return err
|
|
|
}
|
|
|
} else if allotUser.ProvUser.UserType == 4 {
|
|
|
- // 司机->气站 司机- 气站+
|
|
|
- if acceptUser.ProvUser.UserType == 3 && acceptUser.ProvUser.Isorders == 0 {
|
|
|
- for _, chipUid := range c.InnerCodeList {
|
|
|
+ // 司机给门店
|
|
|
+ if acceptUser.ProvUser.UserType == 3 && acceptUser.ProvUser.Isorders == 1 {
|
|
|
+ for _, innerCode := range c.InnerCodeList {
|
|
|
+
|
|
|
+ gasCylinderStatus := &model.GasCylinderStatus{
|
|
|
+ InnerCode: innerCode,
|
|
|
+ UserId: 0,
|
|
|
+ CompanyId: acceptUser.Dept.Id,
|
|
|
+ Status: model.GasCylinderStatusUnqualified,
|
|
|
+ ControlBy: cModel.ControlBy{
|
|
|
+ CreateBy: p.UserId,
|
|
|
+ },
|
|
|
+ DeptBy: cModel.DeptBy{
|
|
|
+ DeptId: acceptUser.DeptId,
|
|
|
+ },
|
|
|
+ }
|
|
|
+
|
|
|
+ // 门店添加不合格瓶
|
|
|
+ err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", innerCode, acceptUser.Dept.Id).
|
|
|
+ Assign(model.GasCylinderStatus{Status: model.GasCylinderStatusUnqualified}).FirstOrCreate(&gasCylinderStatus).Error
|
|
|
+ if err != nil {
|
|
|
+ e.Log.Errorf("db error: %s", err)
|
|
|
+ return global.CreateFailedErr
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 删除司机不合格瓶
|
|
|
+ err = tx.Where("inner_code in (?) and user_id = ? and company_id = ? and status = ?",
|
|
|
+ c.InnerCodeList, allotUser.Id, allotUser.Dept.Id, model.GasCylinderStatusUnqualified).
|
|
|
+ Delete(&model.GasCylinderStatus{}).Error
|
|
|
+ if err != nil {
|
|
|
+ e.Log.Errorf("db error: %s", err)
|
|
|
+ return global.CreateFailedErr
|
|
|
+ }
|
|
|
+ } else if acceptUser.ProvUser.UserType == 5 && acceptUser.ProvUser.Isorders == 0 {
|
|
|
+ // 司机->气站 司机- 气站+
|
|
|
+ for _, innerCode := range c.InnerCodeList {
|
|
|
|
|
|
gasCylinderStatus := &model.GasCylinderStatus{
|
|
|
- InnerCode: chipUid,
|
|
|
+ InnerCode: innerCode,
|
|
|
UserId: 0,
|
|
|
CompanyId: acceptUser.Dept.Id,
|
|
|
Status: model.GasCylinderStatusUnqualified,
|
|
|
@@ -1126,7 +1176,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
}
|
|
|
|
|
|
// 气站添加不合格瓶
|
|
|
- err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", chipUid, acceptUser.Dept.Id).
|
|
|
+ err = tx.Where("inner_code = ? and user_id = 0 and company_id = ? ", innerCode, acceptUser.Dept.Id).
|
|
|
Assign(model.GasCylinderStatus{Status: model.GasCylinderStatusUnqualified}).FirstOrCreate(&gasCylinderStatus).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
@@ -1142,7 +1192,7 @@ func (e *GasCylinderAllot) Submit(c *dto.GasCylinderAllotSubmitReq, p *actions.D
|
|
|
return global.CreateFailedErr
|
|
|
}
|
|
|
} else {
|
|
|
- err = errors.New("请气站出示正确的回收不合格瓶调拨码")
|
|
|
+ err = errors.New("请门店/气站出示正确的回收不合格瓶调拨码")
|
|
|
return err
|
|
|
}
|
|
|
}
|