|
|
@ -1818,7 +1818,7 @@ func (impl *PackOrderServiceImplement) SaveOfflineError(session *xorm.Session, u |
|
|
|
Step: step, |
|
|
|
ErrorInfo: errInfo, |
|
|
|
Location: location, |
|
|
|
SeatData: seatData, |
|
|
|
SeatData: seatData, |
|
|
|
} |
|
|
|
return packOrderPlcErrDao.InsertOne(&errData) |
|
|
|
} |
|
|
@ -1849,7 +1849,7 @@ func (impl *PackOrderServiceImplement) WriteSeatDataToPLC(seatData string, locat |
|
|
|
if location == model.PACK_LOCATION_ON_LINE { |
|
|
|
DBAddress = conf.DbConfig.OfflineDBSave |
|
|
|
} |
|
|
|
valueType = "Byte" |
|
|
|
valueType = "String" |
|
|
|
data = baseModel.PLC{ |
|
|
|
PLCType: plcType, |
|
|
|
PLCAddress: plcAddress, |
|
|
@ -1857,6 +1857,7 @@ func (impl *PackOrderServiceImplement) WriteSeatDataToPLC(seatData string, locat |
|
|
|
ValueType: valueType, |
|
|
|
RetryCount: retryCount, |
|
|
|
ValueText: seatData, |
|
|
|
ByteCount: conf.DbConfig.OfflineDBSaveLen, |
|
|
|
} |
|
|
|
err = impl.SeatOfflineWriteSeatData(data) |
|
|
|
if err != nil { |
|
|
@ -1911,23 +1912,30 @@ func (impl *PackOrderServiceImplement) SeatOfflineReadSign(data baseModel.PLC) e |
|
|
|
return grmi.NewBusinessError("座椅下线plc写入,读取标识位调用后台失败, 后台返回错误, 错误:" + response.Msg) |
|
|
|
} |
|
|
|
plcData, ok := response.Data.(map[string]interface{}) |
|
|
|
if ok { |
|
|
|
successInterface, exist := plcData["IsSuccess"] |
|
|
|
if !exist { |
|
|
|
log.Error("座椅下线plc写入, 读取写入标识后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
|
return grmi.NewBusinessError("座椅下线plc写入, 读取写入标识后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
|
} |
|
|
|
success, ok := successInterface.(bool) |
|
|
|
if !ok { |
|
|
|
log.Error("座椅下线plc写入, 读取写入标识后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
|
return grmi.NewBusinessError("座椅下线plc写入, 读取写入标识后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
|
} |
|
|
|
if !success { |
|
|
|
log.Error("座椅下线plc写入, 读取写入标识后台plc执行失败, 后台数据:" + string(boday)) |
|
|
|
return grmi.NewBusinessError("座椅下线plc写入, 读取写入标识后台plc执行失败, 后台数据:" + string(boday)) |
|
|
|
} |
|
|
|
if !ok { |
|
|
|
log.Error("座椅下线plc写入, 写入座椅数据后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
|
return grmi.NewBusinessError("座椅下线plc写入, 写入座椅数据后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
|
} |
|
|
|
sign, ok := response.Data.(bool) |
|
|
|
successInterface, exist := plcData["IsSuccess"] |
|
|
|
if !exist { |
|
|
|
log.Error("座椅下线plc写入, 读取写入标识后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
|
return grmi.NewBusinessError("座椅下线plc写入, 读取写入标识后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
|
} |
|
|
|
success, ok := successInterface.(bool) |
|
|
|
if !ok { |
|
|
|
log.Error("座椅下线plc写入, 读取写入标识后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
|
return grmi.NewBusinessError("座椅下线plc写入, 读取写入标识后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
|
} |
|
|
|
if !success { |
|
|
|
log.Error("座椅下线plc写入, 读取写入标识后台plc执行失败, 后台数据:" + string(boday)) |
|
|
|
return grmi.NewBusinessError("座椅下线plc写入, 读取写入标识后台plc执行失败, 后台数据:" + string(boday)) |
|
|
|
} |
|
|
|
content, exist := plcData["Content"] |
|
|
|
if !exist { |
|
|
|
log.Error("座椅下线plc写入, 读取写入标识后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
|
return grmi.NewBusinessError("座椅下线plc写入, 读取写入标识后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
|
} |
|
|
|
sign, ok := content.(bool) |
|
|
|
if !ok { |
|
|
|
log.Error("座椅下线plc写入, 读取标识位后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
|
return grmi.NewBusinessError("座椅下线plc写入, 读取标识位后台返回data格式不正确, 后台数据:" + string(boday)) |
|
|
@ -1950,13 +1958,14 @@ func (impl *PackOrderServiceImplement) SeatOfflineReadSign(data baseModel.PLC) e |
|
|
|
|
|
|
|
func (impl *PackOrderServiceImplement) SeatOfflineWriteSeatData(data baseModel.PLC) error { |
|
|
|
log, _ := logger.NewLogger("plc", "JIT") |
|
|
|
//data.ValueText = hex.EncodeToString([]byte(data.ValueText.(string)))
|
|
|
|
postData, err := json.Marshal(data) |
|
|
|
if err != nil { |
|
|
|
log.Error("座椅下线plc写入, 序列化座椅数据请求数据失败, error:" + err.Error()) |
|
|
|
return grmi.NewBusinessError("座椅下线plc写入, 序列化座椅数据请求数据失败, error:" + err.Error()) |
|
|
|
} |
|
|
|
log.Debug("座椅下线plc写入, 写入座椅数据请求参数:" + string(postData) + ", url:" + conf.DbConfig.PLCWriteBackend) |
|
|
|
boday, err := utils.Post(conf.DbConfig.PLCWriteBackend, postData) |
|
|
|
log.Debug("座椅下线plc写入, 写入座椅数据请求参数:" + string(postData) + ", url:" + conf.DbConfig.PLCWriteStringBackend) |
|
|
|
boday, err := utils.Post(conf.DbConfig.PLCWriteStringBackend, postData) |
|
|
|
if err != nil { |
|
|
|
log.Error("座椅下线plc写入,写入座椅数据调用失败, error:" + err.Error()) |
|
|
|
return grmi.NewBusinessError("座椅下线plc写入, 写入座椅数据调用失败, error:" + err.Error()) |
|
|
@ -2080,24 +2089,28 @@ func (impl *PackOrderServiceImplement) MakeUpSeatData(session *xorm.Session, use |
|
|
|
return "", grmi.NewBusinessError(errInfo) |
|
|
|
} |
|
|
|
seatData += product.MachineCode |
|
|
|
seatData += product.ColorValue |
|
|
|
product, exist = seatMap[meModel.PRODUCT_TYPE_PS] |
|
|
|
if !exist { |
|
|
|
errInfo := "包装单子项中不存在副驾" |
|
|
|
return "", grmi.NewBusinessError(errInfo) |
|
|
|
} |
|
|
|
seatData += product.MachineCode |
|
|
|
seatData += product.ColorValue |
|
|
|
product, exist = seatMap[meModel.PRODUCT_TYPE_40] |
|
|
|
if !exist { |
|
|
|
errInfo := "包装单子项中不存在40%" |
|
|
|
return "", grmi.NewBusinessError(errInfo) |
|
|
|
} |
|
|
|
seatData += product.MachineCode |
|
|
|
seatData += product.ColorValue |
|
|
|
product, exist = seatMap[meModel.PRODUCT_TYPE_60] |
|
|
|
if !exist { |
|
|
|
errInfo := "包装单子项中不存在60%" |
|
|
|
return "", grmi.NewBusinessError(errInfo) |
|
|
|
} |
|
|
|
seatData += product.MachineCode |
|
|
|
seatData += product.ColorValue |
|
|
|
product, exist = seatMap[meModel.PRODUCT_TYPE_CUSHION] |
|
|
|
if !exist { |
|
|
|
errInfo := "包装单子项中不存在坐垫" |
|
|
@ -2196,10 +2209,11 @@ func (impl *PackOrderServiceImplement) RepairPlcErr(user *global.User, packOrder |
|
|
|
} |
|
|
|
return err |
|
|
|
} |
|
|
|
if packOrderError.Location == model.PACK_LOCATION_ON_LINE{ |
|
|
|
if packOrderError.Location == model.PACK_LOCATION_ON_LINE { |
|
|
|
DBAddress = conf.DbConfig.OfflineDBSave |
|
|
|
} |
|
|
|
valueType = "Byte" |
|
|
|
valueType = "String" |
|
|
|
|
|
|
|
data = baseModel.PLC{ |
|
|
|
PLCType: plcType, |
|
|
|
PLCAddress: plcAddress, |
|
|
@ -2207,6 +2221,7 @@ func (impl *PackOrderServiceImplement) RepairPlcErr(user *global.User, packOrder |
|
|
|
ValueType: valueType, |
|
|
|
RetryCount: retryCount, |
|
|
|
ValueText: packOrderError.SeatData, |
|
|
|
ByteCount: conf.DbConfig.OfflineDBSaveLen, |
|
|
|
} |
|
|
|
err = impl.SeatOfflineWriteSeatData(data) |
|
|
|
if err != nil { |
|
|
@ -2253,5 +2268,4 @@ func (impl *PackOrderServiceImplement) RepairPlcErr(user *global.User, packOrder |
|
|
|
} |
|
|
|
return nil |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |