|
|
@@ -563,22 +563,26 @@ func (this *ConverseService) ModifySampleAllRejectStatus(res ResponseEntity) err
|
|
|
//}
|
|
|
|
|
|
//修改样本失败状态
|
|
|
-func (this *ConverseService) handleSampleFailed(idsStr string, response string, parentId int) {
|
|
|
- // 更新任务明细信息
|
|
|
- updatesql := "UPDATE " + TABLE_APPLY_DETAIL + " SET taskstatus = '" + strconv.Itoa(FAILED) + "' WHERE barcode IN (" + idsStr + ")" + " AND parentid = '" + strconv.Itoa(parentId) + "'"
|
|
|
- this.DBE.Exec(updatesql)
|
|
|
|
|
|
- // 更新任务状态
|
|
|
- updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(FAILED) + "' WHERE barcode IN (" + idsStr + ")"
|
|
|
- this.DBE.Exec(updTaskSql)
|
|
|
+
|
|
|
+func (this *ConverseService) handleSampleFailed(idsStr string, response string, parentId int) {
|
|
|
+ if (strings.Contains(response, "tube_")) {
|
|
|
+ // 更新任务明细信息
|
|
|
+ updatesql := "UPDATE " + TABLE_APPLY_DETAIL + " SET taskstatus = '" + strconv.Itoa(FAILED) + "' WHERE barcode IN (" + idsStr + ")" + " AND parentid = '" + strconv.Itoa(parentId) + "'"
|
|
|
+ this.DBE.Exec(updatesql)
|
|
|
+
|
|
|
+ // 更新任务状态
|
|
|
+ updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(FAILED) + "' WHERE barcode IN (" + idsStr + ")"
|
|
|
+ this.DBE.Exec(updTaskSql)
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
//处理样本执行成功状态
|
|
|
func (this *ConverseService) handleSampleSuccess(idsStr string, response string, applyMainId int) {
|
|
|
- if strings.Contains(response, "_storing") {
|
|
|
+ if strings.Contains(response, "tube_storing") {
|
|
|
this.sampleRKSuccessDBModify(idsStr, applyMainId)
|
|
|
- } else if strings.Contains(response, "_retrieving") {
|
|
|
+ } else if strings.Contains(response, "tube_retrieving") {
|
|
|
this.sampleCKSuccessDBModify(idsStr, applyMainId)
|
|
|
}
|
|
|
|
|
|
@@ -654,83 +658,118 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
|
|
|
this.UpdatePosition(Rack_id, tubes, entity, applyMain.Id)
|
|
|
}
|
|
|
|
|
|
- } else if applyMain.ApplyType == TASK_TUBE_RETREIVING && strings.Contains(resp, "_storing") {
|
|
|
- fmt.Println("开始入库2")
|
|
|
- //lite设备 部分管子出库
|
|
|
- taskType = "tube_retrieving"
|
|
|
- operaIds, abnormalIds = this.getOperaSampleIdsStr(applyMain.ApplyType, applyMain.Id, resp, entity)
|
|
|
+ //} else if applyMain.ApplyType == TASK_TUBE_RETREIVING && strings.Contains(resp, "_storing") {
|
|
|
+ // fmt.Println("开始入库2")
|
|
|
+ // //lite设备 部分管子出库
|
|
|
+ // taskType = "tube_retrieving"
|
|
|
+ // operaIds, abnormalIds = this.getOperaSampleIdsStr(applyMain.ApplyType, applyMain.Id, resp, entity)
|
|
|
} else if applyMain.ApplyType == TASK_TUBE_RETREIVING && strings.Contains(resp, "_retrieving") /*resp == "rack_retrieving"*/ /*&& entity.Data.Is_end*/ {
|
|
|
- fmt.Println("开始入库3")
|
|
|
+ fmt.Println("开始出库3")
|
|
|
//lite设备 整盒出库
|
|
|
taskType = "tube_retrieving"
|
|
|
- operaIds, abnormalIds = this.getAllSampleIdsFromResEntity(entity)
|
|
|
+ //operaIds, abnormalIds = this.getAllSampleIdsFromResEntity(entity)
|
|
|
+ operaIds, abnormalIds = this.getOperaSampleIdsStr(applyMain.ApplyType, applyMain.Id, resp, entity)
|
|
|
}
|
|
|
- //else {
|
|
|
- //
|
|
|
- // return
|
|
|
- //}
|
|
|
|
|
|
// 此处判断,如果是冻存盒整盒入库,需要更新盒子位置信息 盒 冻存盒当前的 所在的冻存架的id
|
|
|
if resp == "rack_storing" {
|
|
|
- this.UpdateBoxInfo(entity)
|
|
|
+ fmt.Println("冻存盒入库")
|
|
|
+ this.UpdateBoxInfo(entity,applyMain.Id)
|
|
|
} else if resp == "rack_retrieving" {
|
|
|
- fmt.Println("出库")
|
|
|
- //rack_retrieving
|
|
|
+ fmt.Println("冻存盒出库")
|
|
|
//rack_retrieving
|
|
|
// 冻存盒出库任务完成以后,需要清空冻存盒中的冻存架信息,同时清空
|
|
|
- this.UpdateBoxInfoCK(entity)
|
|
|
+ this.UpdateBoxInfoCK(entity,applyMain.Id)
|
|
|
}
|
|
|
|
|
|
- //
|
|
|
- this.handleSampleSuccess(operaIds, taskType, applyMain.Id)
|
|
|
- if entity.Data.Type == "abnormal_end" {
|
|
|
- this.handleSampleFailed(abnormalIds, taskType, applyMain.Id)
|
|
|
+ // 根据管操作 或 盒操作 判断是否执行以下更新
|
|
|
+ if (applyMain.ApplyType == TASK_TUBE_STORING && strings.Contains(resp, "_storing")) || (applyMain.ApplyType == TASK_TUBE_RETREIVING && strings.Contains(resp, "_retrieving")) {
|
|
|
+ this.handleSampleSuccess(operaIds, taskType, applyMain.Id)
|
|
|
+ if entity.Data.Type == "abnormal_end" {
|
|
|
+ this.handleSampleFailed(abnormalIds, taskType, applyMain.Id)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//2021/01/09 by 卢传敏
|
|
|
// 根据入库返回报文,更新 冻存盒的信息盒
|
|
|
-func (this *ConverseService) UpdateBoxInfo(entity ResponseEntity) (err error) {
|
|
|
+func (this *ConverseService) UpdateBoxInfo(entity ResponseEntity,parentId int) (err error) {
|
|
|
//1. 获取当前返回的 冻存架信息,
|
|
|
var shelf Shelf
|
|
|
|
|
|
glog.Info("entity.Data.Actual_data::", entity.Data.Actual_data)
|
|
|
|
|
|
- // 循环处理返回的数据,如果出现多盒存入的分批处理
|
|
|
+ // 判断是否存在处理成功的数据
|
|
|
+ if len(entity.Data.Actual_data) > 0{
|
|
|
+ // 循环处理返回的数据,如果出现多盒存入的分批处理
|
|
|
+ for i := range entity.Data.Actual_data {
|
|
|
|
|
|
- for i := range entity.Data.Actual_data {
|
|
|
+ glog.Info("操作地 ", i, " 条数据")
|
|
|
|
|
|
- glog.Info("操作地 ", i, " 条数据")
|
|
|
-
|
|
|
- boxBarcode := entity.Data.Actual_data[i].Rack_id // 冻存盒编号
|
|
|
- Cu := entity.Data.Actual_data[i].Target.Cu // 设备编号
|
|
|
- Ltu := entity.Data.Actual_data[i].Target.Ltu //
|
|
|
- Unit := entity.Data.Actual_data[i].Target.Unit
|
|
|
- Pos := entity.Data.Actual_data[i].Target.Pos
|
|
|
- Group := entity.Data.Actual_data[i].Target.Group
|
|
|
+ boxBarcode := entity.Data.Actual_data[i].Rack_id // 冻存盒编号
|
|
|
+ Cu := entity.Data.Actual_data[i].Target.Cu // 设备编号
|
|
|
+ Ltu := entity.Data.Actual_data[i].Target.Ltu //
|
|
|
+ Unit := entity.Data.Actual_data[i].Target.Unit
|
|
|
+ Pos := entity.Data.Actual_data[i].Target.Pos
|
|
|
+ Group := entity.Data.Actual_data[i].Target.Group
|
|
|
|
|
|
- fmt.Println("保存返回的冻存盒位置信息:cu:", Cu, ",Ltu", Ltu, ",Unit", Unit, ",Group", Group, ",Pos", Pos)
|
|
|
+ fmt.Println("保存返回的冻存盒位置信息:cu:", Cu, ",Ltu", Ltu, ",Unit", Unit, ",Group", Group, ",Pos", Pos)
|
|
|
|
|
|
- sql := "select b.id EquipmentId,a.id,a.XStation,a.YStation from bank_shelf a left join bank_equipment b on a.EquipmentId = b.id where b.cu = '" + utils.ToStr(Cu) + "' " +
|
|
|
- "and a.Ltu = '" + utils.ToStr(Ltu) + "' and a.Unit ='" + utils.ToStr(Unit) + "' and a.Group ='" + utils.ToStr(Group) + "'"
|
|
|
+ sql := "select b.id EquipmentId,a.id,a.XStation,a.YStation from bank_shelf a left join bank_equipment b on a.EquipmentId = b.id where b.cu = '" + utils.ToStr(Cu) + "' " +
|
|
|
+ "and a.Ltu = '" + utils.ToStr(Ltu) + "' and a.Unit ='" + utils.ToStr(Unit) + "' and a.Group ='" + utils.ToStr(Group) + "'"
|
|
|
|
|
|
- this.DBE.SQL(sql).Get(&shelf)
|
|
|
- fmt.Println("冻存架信息:", shelf.Id, shelf.XStation, shelf.YStation)
|
|
|
+ this.DBE.SQL(sql).Get(&shelf)
|
|
|
+ fmt.Println("冻存架信息:", shelf.Id, shelf.XStation, shelf.YStation)
|
|
|
|
|
|
- // 更新盒所在的冻存架的信息 计算位置信息,并更新
|
|
|
- // 临时处理逻辑,默认 pos 为 盒子的 XStation
|
|
|
- _, err = this.DBE.Exec("update bank_box set XStation ='" + utils.ToStr(Pos) + "',YStation =1 ,EquipmentId ='" + com.ToStr(shelf.EquipmentId) + "',shelfId =" + utils.ToStr(shelf.Id) + ",IsLocked = 0 where Barcode ='" + boxBarcode + "' ")
|
|
|
- // 更新 当前冰箱冻存盒容量 信息
|
|
|
- _, err = this.DBE.Exec(" update bank_currboxcapacity set `A" + utils.ToStr(Pos) + "`= -1 where shelfId =" + utils.ToStr(shelf.Id) + "")
|
|
|
+ // 更新盒所在的冻存架的信息 计算位置信息,并更新
|
|
|
+ // 临时处理逻辑,默认 pos 为 盒子的 XStation
|
|
|
+ _, err = this.DBE.Exec("update bank_box set XStation ='" + utils.ToStr(Pos) + "',YStation =1 ,EquipmentId ='" + com.ToStr(shelf.EquipmentId) + "',shelfId =" + utils.ToStr(shelf.Id) + ",IsLocked = 0 where Barcode ='" + boxBarcode + "' ")
|
|
|
+ // 更新 当前冰箱冻存盒容量 信息
|
|
|
+ _, err = this.DBE.Exec(" update bank_currboxcapacity set `A" + utils.ToStr(Pos) + "`= -1 where shelfId =" + utils.ToStr(shelf.Id) + "")
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
+ err = this.UpdateBoxAbnormalInfo(entity,parentId)
|
|
|
return err
|
|
|
|
|
|
}
|
|
|
|
|
|
+func (this *ConverseService) UpdateBoxAbnormalInfo(entity ResponseEntity,parentId int) (err error) {
|
|
|
+ glog.Info("entity.Data.Abnormal_data::", entity.Data.Abnormal_data)
|
|
|
+ AbnormalRack := ""
|
|
|
+ // 判断是否存在处理失败的数据
|
|
|
+ rackEntity := entity.Data.Abnormal_data.Racks
|
|
|
+ if rackEntity != nil {
|
|
|
+ // 获取处理失败的 数据 判断失败的盒是否为空
|
|
|
+ if len(rackEntity) > 0 {
|
|
|
+ for _, v := range rackEntity {
|
|
|
+ // 不为空则需要将数据取出
|
|
|
+ AbnormalRack += v.Rack_id + ","
|
|
|
+ }
|
|
|
+ AbnormalRack = AbnormalRack[0 : len(AbnormalRack) -1]
|
|
|
+
|
|
|
+ // 更新盒 的任务状态
|
|
|
+ // 处理异常任务数据
|
|
|
+ updatesql := "UPDATE " + TABLE_SAMPLE_APPLY + " SET taskstatus = '" + strconv.Itoa(FAILED) + "' WHERE parentid = '" + strconv.Itoa(parentId) + "'"
|
|
|
+ _,err = this.DBE.Exec(updatesql)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ // 更新任务状态
|
|
|
+ updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(FAILED) + "' WHERE BoxBarcode IN (" + AbnormalRack + ")"
|
|
|
+ _,err =this.DBE.Exec(updTaskSql)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ this.UpdateBoxIsLocked(utils.ToStr(parentId))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
//2021/01/09 by 卢传敏
|
|
|
// 根据出库返回报文,更新 冻存盒的信息盒
|
|
|
-func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity) (err error) {
|
|
|
+func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity,parentId int) (err error) {
|
|
|
//1. 获取当前返回的 冻存架信息,
|
|
|
var shelf Shelf
|
|
|
|
|
|
@@ -761,6 +800,8 @@ func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity) (err error)
|
|
|
_, err = this.DBE.Exec(" update bank_currboxcapacity set `A" + utils.ToStr(Pos) + "`= -2 where shelfId =" + utils.ToStr(shelf.Id) + "")
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ err = this.UpdateBoxAbnormalInfo(entity,parentId)
|
|
|
return err
|
|
|
|
|
|
}
|
|
|
@@ -904,8 +945,8 @@ func (this *ConverseService) getOperaSampleIdsStr(applyType, parentId int, resp
|
|
|
if applyType == TASK_TUBE_RETREIVING {
|
|
|
for _, sampleId := range sampleIds {
|
|
|
//操作成功样本Id
|
|
|
- for index, tubeId := range actualTubeIds {
|
|
|
- if index == len(actualTubeIds)-1 && tubeId != sampleId {
|
|
|
+ for _, tubeId := range actualTubeIds {
|
|
|
+ if sampleId == tubeId {
|
|
|
operaTubeIds = append(operaTubeIds, sampleId)
|
|
|
}
|
|
|
}
|
|
|
@@ -919,9 +960,10 @@ func (this *ConverseService) getOperaSampleIdsStr(applyType, parentId int, resp
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
actualIds = "'" + strings.Join(operaTubeIds, "','") + "'"
|
|
|
abnormalIds = "'" + strings.Join(failTubeIds, ",") + "'"
|
|
|
+ glog.Info("处理成功数据:", actualIds)
|
|
|
+ glog.Info("处理失败数据:", abnormalIds)
|
|
|
return
|
|
|
}
|
|
|
|