|
@@ -426,7 +426,15 @@ func (e *Waybill) Update(c *dto.WaybillUpdateReq, p *actions.DataPermission) err
|
|
|
}
|
|
|
|
|
|
c.Generate(&waybillModel)
|
|
|
- err = tx.Save(&waybillModel).Error
|
|
|
+ var count int64
|
|
|
+ for _, drug := range c.Drugs {
|
|
|
+ e.Orm.Model(&model.Drug{}).Where("code = ?", drug.Code).Count(&count)
|
|
|
+ if count > 0 {
|
|
|
+ return errors.New("药品编号已存在")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ waybillModel.Drugs = append(waybillModel.Drugs, c.Drugs...)
|
|
|
+ err = tx.Where("id = ?", waybillModel.Id).Updates(&waybillModel).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
return global.UpdateFailedErr
|
|
@@ -470,7 +478,7 @@ func (e *Waybill) Audit(c *dto.WaybillUpdateReqaudit, p *actions.DataPermission)
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-// 管理员审核订单
|
|
|
+// AdminAudit 管理员审核订单
|
|
|
func (e *Waybill) AdminAudit(c *dto.WaybillAdmin, p *actions.DataPermission) error {
|
|
|
var err error
|
|
|
tx := e.Orm.Begin()
|
|
@@ -545,7 +553,7 @@ func (e *Waybill) UpdateStatus(c *dto.UpdateStatusReq, p *actions.DataPermission
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-// 派单
|
|
|
+// Delivery 派单
|
|
|
func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission) error {
|
|
|
var err error
|
|
|
|
|
@@ -606,7 +614,7 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- if !user.Dept.IsOutStorage {
|
|
|
+ if user.Dept.IsOutStorage {
|
|
|
if iceRaft.IceRaftRecord.Status != model.IceRaftRecordStatusWaitUse {
|
|
|
err = errors.New(fmt.Sprintf("冰排【%s】状态为%s,出库保温箱失败!", code, model.GetIceRaftRecordStatus(iceRaft.IceRaftRecord.Status)))
|
|
|
return err
|
|
@@ -627,6 +635,7 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
|
|
|
err = tx.Model(&model.IceRaftRecord{}).
|
|
|
Where("ice_raft_id = ? and status = ?", iceRaft.Id, model.IceRaftRecordStatusFreezing).
|
|
|
Or("ice_raft_id = ? and status = ?", iceRaft.Id, model.IceRaftRecordStatusWaitUse).
|
|
|
+ Or("ice_raft_id = ? and status = ?", iceRaft.Id, model.IceRaftRecordReleasedInTheCold).
|
|
|
Updates(map[string]interface{}{
|
|
|
"status": model.IceRaftRecordStatusUsing,
|
|
|
"out_storage_time": time.Now(),
|
|
@@ -679,9 +688,7 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
|
|
|
}
|
|
|
//派单时添加
|
|
|
//waybillModeStatus := waybillModel.Status
|
|
|
- if waybillModel.Status == model.WaybillStatusInDeliverys ||
|
|
|
- (waybillModel.Status == model.WaybillStatusInDeliverys && waybillModel.CoolerBoxId != c.CoolerBoxId) ||
|
|
|
- (waybillModel.Status == model.WaybillStatusInDeliverys && !lib.StrListEqual(c.IceRaftCode, c.OldIceRaftCode)) {
|
|
|
+ if waybillModel.Status == model.WaybillStatusInDeliverys || (waybillModel.Status == model.WaybillStatusInDeliverys && waybillModel.CoolerBoxId != c.CoolerBoxId) || (waybillModel.Status == model.WaybillStatusInDeliverys && !lib.StrListEqual(c.IceRaftCode, c.OldIceRaftCode)) {
|
|
|
waybillModel.Status = model.WaybillStatusInDeliverys
|
|
|
waybillModel.TamperProofLabel = c.TamperProofLabel
|
|
|
waybillModel.TamperProofLabelImg = c.TamperProofLabelImg // 防拆标签
|
|
@@ -690,6 +697,7 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
|
|
|
waybillModel.CoolerBoxId = c.CoolerBoxId
|
|
|
waybillModel.DeliveryTime = model2.Time(time.Now())
|
|
|
waybillModel.IceRaftCode = c.IceRaftCode
|
|
|
+ waybillModel.SecondaryTime = model2.Time(time.Now()) //分配时间
|
|
|
if c.Status == model.WaybillStatusInShippeds {
|
|
|
waybillModel.Status = c.Status
|
|
|
var data model.IceRaft
|
|
@@ -699,7 +707,7 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
|
|
|
Scopes(
|
|
|
actions.Permission(data.TableName(), p),
|
|
|
IceRaftNameRecordStatusScopes(model.IceRaftRecordStatusUsing),
|
|
|
- IceRaftNameRecordCoolerBoxIdScopes(coolerBox.Id),
|
|
|
+ IceRaftNameRecordCoolerBoxIdScopes(c.CoolerBoxId),
|
|
|
).
|
|
|
Joins("left join ice_raft_record on ice_raft.ice_raft_record_id = ice_raft_record.id").
|
|
|
Find(&list).Error
|
|
@@ -713,11 +721,20 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
|
|
|
e.Orm.Scopes(actions.Permission(cooler.TableName(), p)).
|
|
|
Where("cooler_box_id = ?", c.CoolerBoxId).Where("status = ?", 1).First(&cooler).Count(&count)
|
|
|
if count == 0 {
|
|
|
+ cooler.CoolerBoxId = c.CoolerBoxId
|
|
|
+ cooler.Name = coolerBox.Name
|
|
|
+ cooler.Sn = coolerBox.Sn
|
|
|
cooler.CoolerUseUsers = user.NickName
|
|
|
- cooler.HistoryCode = append(cooler.HistoryCode, list...)
|
|
|
- cooler.HistoryCode = cDto.UniqueSlice(cooler.HistoryCode)
|
|
|
+ if len(list) == 0 {
|
|
|
+ cooler.HistoryCode = append(cooler.HistoryCode, c.IceRaftCode...)
|
|
|
+ cooler.HistoryCode = cDto.UniqueSlice(cooler.HistoryCode)
|
|
|
+ } else {
|
|
|
+ cooler.HistoryCode = append(cooler.HistoryCode, list...)
|
|
|
+ cooler.HistoryCode = cDto.UniqueSlice(cooler.HistoryCode)
|
|
|
+ }
|
|
|
cooler.CoolerUserTime = model2.Time(time.Now())
|
|
|
cooler.Status = "2" //使用结束
|
|
|
+ cooler.DeptId = user.DeptId
|
|
|
err := e.Orm.Save(&cooler).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("保存保温箱记录失败: %s", err)
|
|
@@ -725,8 +742,13 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
|
|
|
}
|
|
|
} else {
|
|
|
cooler.CoolerUseUsers = user.NickName
|
|
|
- cooler.HistoryCode = append(cooler.HistoryCode, list...)
|
|
|
- cooler.HistoryCode = cDto.UniqueSlice(cooler.HistoryCode)
|
|
|
+ if len(list) == 0 {
|
|
|
+ cooler.HistoryCode = append(cooler.HistoryCode, c.IceRaftCode...)
|
|
|
+ cooler.HistoryCode = cDto.UniqueSlice(cooler.HistoryCode)
|
|
|
+ } else {
|
|
|
+ cooler.HistoryCode = append(cooler.HistoryCode, list...)
|
|
|
+ cooler.HistoryCode = cDto.UniqueSlice(cooler.HistoryCode)
|
|
|
+ }
|
|
|
cooler.CoolerUserTime = model2.Time(time.Now())
|
|
|
cooler.Status = "2" //使用结束
|
|
|
err = e.Orm.Updates(&cooler).Where("id = ?", cooler.Id).Error
|
|
@@ -748,71 +770,88 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
|
|
|
Phone: waybillModel.ConsigneeAddressPhone,
|
|
|
Content: "【冷链送药追溯平台】您的运单正在派送中,点击查看详情:" + addr,
|
|
|
}
|
|
|
- // 查询任务
|
|
|
- var logistics model.WaybillLogistics
|
|
|
+ //// 查询任务
|
|
|
+ //var logistics model.WaybillLogistics
|
|
|
// 添加物流
|
|
|
- logisticsObj := model.WaybillLogistics{
|
|
|
- WaybillNo: waybillModel.WaybillNo,
|
|
|
- Status: waybillModel.Status,
|
|
|
- CoolerBoxId: coolerBox.Id,
|
|
|
- ControlBy: model2.ControlBy{
|
|
|
- CreateBy: p.UserId,
|
|
|
- },
|
|
|
- DeptBy: model2.DeptBy{
|
|
|
- DeptId: p.DeptId,
|
|
|
- },
|
|
|
- }
|
|
|
- err = tx.Create(&logisticsObj).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return errors.New(fmt.Sprintf("保存运单物流信息失败:%s", err))
|
|
|
- }
|
|
|
- logistics.CoolerBoxId = coolerBox.Id
|
|
|
- err = tx.Save(&logistics).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return errors.New(fmt.Sprintf("保存运单物流信息失败:%s", err))
|
|
|
- }
|
|
|
+ //logisticsObj := model.WaybillLogistics{
|
|
|
+ // WaybillNo: waybillModel.WaybillNo,
|
|
|
+ // Status: waybillModel.Status,
|
|
|
+ // CoolerBoxId: coolerBox.Id,
|
|
|
+ // ControlBy: model2.ControlBy{
|
|
|
+ // CreateBy: p.UserId,
|
|
|
+ // },
|
|
|
+ // DeptBy: model2.DeptBy{
|
|
|
+ // DeptId: p.DeptId,
|
|
|
+ // },
|
|
|
+ //}
|
|
|
+ //err = tx.Create(&logisticsObj).Error
|
|
|
+ //if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return errors.New(fmt.Sprintf("保存运单物流信息失败:%s", err))
|
|
|
+ //}
|
|
|
+ //logistics.CoolerBoxId = coolerBox.Id
|
|
|
+ //err = tx.Save(&logistics).Error
|
|
|
+ //if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return errors.New(fmt.Sprintf("保存运单物流信息失败:%s", err))
|
|
|
+ //}
|
|
|
}
|
|
|
+ // 查询任务
|
|
|
err = tx.Save(&waybillModel).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
return global.UpdateFailedErr
|
|
|
}
|
|
|
-
|
|
|
// 查询任务
|
|
|
- var logistics model.WaybillLogistics
|
|
|
- err = tx.Model(&logistics).Where("waybill_no = ?", waybillModel.WaybillNo).
|
|
|
- Last(&logistics).Error
|
|
|
+ //var logistics model.WaybillLogistics
|
|
|
+ //err = tx.Model(&logistics).Where("waybill_no = ?", waybillModel.WaybillNo).
|
|
|
+ // Last(&logistics).Error
|
|
|
+ //if err != nil {
|
|
|
+ // if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
+ // // 添加物流
|
|
|
+ // logisticsObj := model.WaybillLogistics{
|
|
|
+ // WaybillNo: waybillModel.WaybillNo,
|
|
|
+ // Status: waybillModel.Status,
|
|
|
+ // CoolerBoxId: coolerBox.Id,
|
|
|
+ // ControlBy: model2.ControlBy{
|
|
|
+ // CreateBy: p.UserId,
|
|
|
+ // },
|
|
|
+ // DeptBy: model2.DeptBy{
|
|
|
+ // DeptId: p.DeptId,
|
|
|
+ // },
|
|
|
+ // }
|
|
|
+ // err = tx.Create(&logisticsObj).Error
|
|
|
+ // if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return errors.New(fmt.Sprintf("保存运单物流信息失败:%s", err))
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return errors.New(fmt.Sprintf("保存运单物流信息失败:%s", err))
|
|
|
+ // }
|
|
|
+ // logistics.CoolerBoxId = coolerBox.Id
|
|
|
+ // err = tx.Save(&logistics).Error
|
|
|
+ // if err != nil {
|
|
|
+ // e.Log.Errorf("db error: %s", err)
|
|
|
+ // return errors.New(fmt.Sprintf("保存运单物流信息失败:%s", err))
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ // 添加物流
|
|
|
+ logisticsObj := model.WaybillLogistics{
|
|
|
+ WaybillNo: waybillModel.WaybillNo,
|
|
|
+ Status: waybillModel.Status,
|
|
|
+ CoolerBoxId: coolerBox.Id,
|
|
|
+ ControlBy: model2.ControlBy{
|
|
|
+ CreateBy: p.UserId,
|
|
|
+ },
|
|
|
+ DeptBy: model2.DeptBy{
|
|
|
+ DeptId: p.DeptId,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ err = tx.Create(&logisticsObj).Error
|
|
|
if err != nil {
|
|
|
- if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
- // 添加物流
|
|
|
- logisticsObj := model.WaybillLogistics{
|
|
|
- WaybillNo: waybillModel.WaybillNo,
|
|
|
- Status: waybillModel.Status,
|
|
|
- CoolerBoxId: coolerBox.Id,
|
|
|
- ControlBy: model2.ControlBy{
|
|
|
- CreateBy: p.UserId,
|
|
|
- },
|
|
|
- DeptBy: model2.DeptBy{
|
|
|
- DeptId: p.DeptId,
|
|
|
- },
|
|
|
- }
|
|
|
- err = tx.Create(&logisticsObj).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return errors.New(fmt.Sprintf("保存运单物流信息失败:%s", err))
|
|
|
- }
|
|
|
- } else {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return errors.New(fmt.Sprintf("保存运单物流信息失败:%s", err))
|
|
|
- }
|
|
|
- logistics.CoolerBoxId = coolerBox.Id
|
|
|
- err = tx.Save(&logistics).Error
|
|
|
- if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return errors.New(fmt.Sprintf("保存运单物流信息失败:%s", err))
|
|
|
- }
|
|
|
+ e.Log.Errorf("db error: %s", err)
|
|
|
+ return errors.New(fmt.Sprintf("保存运单物流信息失败:%s", err))
|
|
|
}
|
|
|
// 查询任务
|
|
|
var task model.WaybillTask
|
|
@@ -840,10 +879,17 @@ func (e *Waybill) Delivery(c *dto.WaybillDeliveryReq, p *actions.DataPermission)
|
|
|
return errors.New(fmt.Sprintf("保存运单任务信息失败:%s", err))
|
|
|
}
|
|
|
} else {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
- return errors.New(fmt.Sprintf("查询运单任务信息失败:%s", err))
|
|
|
+ //task.StartTime = model2.Time(time.Now())
|
|
|
+ task.UpdateBy = p.UserId
|
|
|
+ task.CoolerBoxId = coolerBox.Id
|
|
|
+ task.Sn = coolerBox.Sn
|
|
|
+ err = tx.Save(&task).Error
|
|
|
+ if err != nil {
|
|
|
+ e.Log.Errorf("db error: %s", err)
|
|
|
+ return errors.New(fmt.Sprintf("保存运单任务信息失败:%s", err))
|
|
|
+ }
|
|
|
}
|
|
|
- task.StartTime = model2.Time(time.Now())
|
|
|
+ } else {
|
|
|
task.UpdateBy = p.UserId
|
|
|
task.CoolerBoxId = coolerBox.Id
|
|
|
task.Sn = coolerBox.Sn
|
|
@@ -957,7 +1003,6 @@ func (e *Waybill) Receipt(c *dto.WaybillReceiptReq, p *actions.DataPermission) e
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
|
return errors.New(fmt.Sprintf("保存运单信息失败:%s", err))
|
|
|
}
|
|
|
-
|
|
|
var lng, lat string
|
|
|
lng, lat, err = e.GetSite(waybillModel.DeptId, coolerBox.Sn, waybillModel.ReceiptTime.String())
|
|
|
if err != nil {
|
|
@@ -976,6 +1021,7 @@ func (e *Waybill) Receipt(c *dto.WaybillReceiptReq, p *actions.DataPermission) e
|
|
|
// 未下车 直接点签收
|
|
|
if time.Time(task.EndTime).IsZero() {
|
|
|
task.EndTime = model2.Time(time.Now())
|
|
|
+ task.CoolerBoxId = coolerBox.Id
|
|
|
//task.UpdateBy = p.UserIds
|
|
|
err = tx.Save(&task).Error
|
|
|
if err != nil {
|
|
@@ -1687,6 +1733,16 @@ func (e *Waybill) SecondaryDistribution(c *dto.WaybillAssignment, p *actions.Dat
|
|
|
if !waybillModel.IsSecondaryDistribution {
|
|
|
return errors.New("该订单不允许二次分配")
|
|
|
}
|
|
|
+ var coolerBox = model.CoolerBox{}
|
|
|
+ // 查询保温箱信息
|
|
|
+ if c.CoolerBoxId != 0 {
|
|
|
+ err = tx.Scopes(actions.Permission(coolerBox.TableName(), p)).
|
|
|
+ First(&coolerBox, waybillModel.CoolerBoxId).Error
|
|
|
+ if err != nil {
|
|
|
+ e.Log.Errorf("获取保温箱信息失败: %s", err)
|
|
|
+ return errors.New("获取保温箱信息失败")
|
|
|
+ }
|
|
|
+ }
|
|
|
var waybil model.Waybill
|
|
|
sole, err := e.CreateSole()
|
|
|
var no string
|
|
@@ -1716,7 +1772,14 @@ func (e *Waybill) SecondaryDistribution(c *dto.WaybillAssignment, p *actions.Dat
|
|
|
waybil.DeliveryPhone = waybillModel.DeliveryPhone
|
|
|
waybil.OrderTime = model2.Time(time.Now())
|
|
|
waybil.IsSecondaryDistribution = false
|
|
|
- c.Generate(&waybil)
|
|
|
+ waybil.ReCheckId = waybillModel.ReCheckId
|
|
|
+ waybil.IceRaftCode = waybillModel.IceRaftCode
|
|
|
+ waybil.CoolerBoxId = waybillModel.CoolerBoxId
|
|
|
+ waybil.IsChild = true
|
|
|
+ waybil.ConsigneeAddressDetails = c.ConsigneeAddressDetails
|
|
|
+ waybil.ConsigneeAddressName = c.ConsigneeAddressName
|
|
|
+ waybil.ConsigneeAddressPhone = c.ConsigneeAddressPhone
|
|
|
+ //c.Generate(&waybil)
|
|
|
err = tx.Create(&waybil).Error
|
|
|
if err != nil {
|
|
|
e.Log.Errorf("db error: %s", err)
|
|
@@ -1756,9 +1819,14 @@ func (e *Waybill) SecondaryDistribution(c *dto.WaybillAssignment, p *actions.Dat
|
|
|
drugs.Code = drug.Code
|
|
|
err = tx.Save(&drugs).Error
|
|
|
if err != nil {
|
|
|
- e.Log.Errorf("db error: %s", err)
|
|
|
+ e.Log.Errorf("保存药品信息失败: %s", err)
|
|
|
return errors.New("保存药品信息失败")
|
|
|
}
|
|
|
+ err := e.Orm.Table(model.Drug{}.TableName()).Where("waybill_no = ?", waybillModel.WaybillNo).Where("code = ?", drug.Code).Update("is_assignment", true).Error
|
|
|
+ if err != nil {
|
|
|
+ e.Log.Errorf("更新药品状态失败: %s", err)
|
|
|
+ return errors.New("更新药品状态失败")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
waybillModel.ChildWaybills = append(waybillModel.ChildWaybills, waybil.WaybillNo)
|
|
@@ -1770,15 +1838,62 @@ func (e *Waybill) SecondaryDistribution(c *dto.WaybillAssignment, p *actions.Dat
|
|
|
// 二次分配订单发送短信
|
|
|
ss := sms.NewSMS(conf.ExtConfig.SubMail.Appid, conf.ExtConfig.SubMail.Signature)
|
|
|
addr := conf.ExtConfig.Applet.WaybillUrl + url.QueryEscape(lib.AesEncryptCBC(waybil.WaybillNo, lib.AesKey))
|
|
|
- res, err1 := ss.SmsXSend(waybil.ConsigneeAddressPhone, addr)
|
|
|
+ res, err1 := ss.SmsXSend(c.ConsigneeAddressPhone, addr)
|
|
|
if err1 != nil || res.Status != sms.SUCCESS {
|
|
|
e.Log.Errorf("派单短信发送失败", zap.Any("res", res), zap.Error(err1))
|
|
|
err = errors.New("派单短信发送失败,请检查收件人电话是否正确!")
|
|
|
return err
|
|
|
}
|
|
|
waybil.SendLog = model.WaybillSendLog{
|
|
|
- Phone: waybil.ConsigneeAddressPhone,
|
|
|
+ Phone: c.ConsigneeAddressPhone,
|
|
|
Content: "【冷链送药追溯平台】您的运单正在派送中,点击查看详情:" + addr,
|
|
|
}
|
|
|
+ // 添加物流
|
|
|
+ logisticsObj := model.WaybillLogistics{
|
|
|
+ WaybillNo: waybil.WaybillNo,
|
|
|
+ Status: waybil.Status,
|
|
|
+ CoolerBoxId: waybil.CoolerBoxId,
|
|
|
+ ControlBy: model2.ControlBy{
|
|
|
+ CreateBy: p.UserId,
|
|
|
+ },
|
|
|
+ DeptBy: model2.DeptBy{
|
|
|
+ DeptId: p.DeptId,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ err = tx.Create(&logisticsObj).Error
|
|
|
+ if err != nil {
|
|
|
+ e.Log.Errorf("db error: %s", err)
|
|
|
+ return errors.New(fmt.Sprintf("保存运单物流信息失败:%s", err))
|
|
|
+ }
|
|
|
+ // 查询任务
|
|
|
+ var task model.WaybillTask
|
|
|
+ err = tx.Model(&task).Where("waybill_no = ? ", waybil.WaybillNo).
|
|
|
+ Last(&task).Error
|
|
|
+ if err != nil {
|
|
|
+ if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
+ // 添加任务
|
|
|
+ taskObj := model.WaybillTask{
|
|
|
+ WaybillNo: waybil.WaybillNo,
|
|
|
+ CoolerBoxId: waybil.CoolerBoxId,
|
|
|
+ UserId: p.UserId,
|
|
|
+ Sn: coolerBox.Sn,
|
|
|
+ StartTime: model2.Time(time.Now()),
|
|
|
+ ControlBy: model2.ControlBy{
|
|
|
+ CreateBy: p.UserId,
|
|
|
+ },
|
|
|
+ DeptBy: model2.DeptBy{
|
|
|
+ DeptId: p.DeptId,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ err = tx.Create(&taskObj).Error
|
|
|
+ if err != nil {
|
|
|
+ e.Log.Errorf("db error: %s", err)
|
|
|
+ return errors.New(fmt.Sprintf("保存运单任务信息失败:%s", err))
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ e.Log.Errorf("db error: %s", err)
|
|
|
+ return errors.New(fmt.Sprintf("查询运单任务信息失败:%s", err))
|
|
|
+ }
|
|
|
+ }
|
|
|
return nil
|
|
|
}
|