|
|
@@ -2,6 +2,7 @@ package converseService
|
|
|
|
|
|
import (
|
|
|
"crypto/md5"
|
|
|
+ "database/sql"
|
|
|
"fmt"
|
|
|
"github.com/gogf/gf/os/glog"
|
|
|
"log"
|
|
|
@@ -174,7 +175,7 @@ func (this *ConverseService) GenerateRequestEntity(taskType int, task_id string)
|
|
|
case 2:
|
|
|
requestName = "rack_retrieving"
|
|
|
break
|
|
|
- case 3,8:
|
|
|
+ case 3, 8:
|
|
|
requestName = "tube_storing"
|
|
|
break
|
|
|
case 4:
|
|
|
@@ -202,19 +203,19 @@ func (this *ConverseService) GenerateRequestEntity(taskType int, task_id string)
|
|
|
// 按类型进行任务处理
|
|
|
func (this *ConverseService) HandleTaskDetail(taskType int, entity *RequestEntity, detail *Sample_Storage_Task) {
|
|
|
switch taskType {
|
|
|
- case 1://冻存盒 入库
|
|
|
+ case 1: //冻存盒 入库
|
|
|
handleRackStore(entity, detail)
|
|
|
break
|
|
|
- case 2: //冻存盒出库
|
|
|
+ case 2: //冻存盒出库
|
|
|
handleRackRetrieve(entity, detail)
|
|
|
break
|
|
|
- case 3,8: //冻存管
|
|
|
+ case 3, 8: //冻存管
|
|
|
handleTubeStore(entity, detail)
|
|
|
break
|
|
|
- case 4:// 冻存管出库
|
|
|
+ case 4: // 冻存管出库
|
|
|
handleTubeRetrieve(entity, detail)
|
|
|
break
|
|
|
- case 5: // 获取设备库存情况及冻存盒信息
|
|
|
+ case 5: // 获取设备库存情况及冻存盒信息
|
|
|
handleQueryRack(entity, detail)
|
|
|
break
|
|
|
case 6: // 根据冻存盒编号查询冻存管信息
|
|
|
@@ -297,6 +298,7 @@ func handleTubeStore(entity *RequestEntity, detail *Sample_Storage_Task) {
|
|
|
entity.Data.Operation_mode = detail.OperaMode
|
|
|
}
|
|
|
|
|
|
+ // 盒子存在追加样本
|
|
|
if entity.Data.Task_data != nil {
|
|
|
ones = entity.Data.Task_data.([]Single)
|
|
|
for idx, value := range ones {
|
|
|
@@ -316,6 +318,7 @@ func handleTubeStore(entity *RequestEntity, detail *Sample_Storage_Task) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 盒子不存在新加盒子及管信息
|
|
|
if !exist {
|
|
|
var one Single
|
|
|
//one.Rack = 101 //测试临时使用
|
|
|
@@ -383,6 +386,29 @@ func handleQueryTube(entity *RequestEntity, detail *Sample_Storage_Task) {
|
|
|
entity.Data.Tube_id = detail.BarCode
|
|
|
}
|
|
|
|
|
|
+// 查询申请单详情下状态,存在一条子任务失败的情况,则整个申请单状态为失败
|
|
|
+func (this *ConverseService) StatusModifyWithDetail(task_id string) error {
|
|
|
+ status := SUCCESS
|
|
|
+ // 关联查询申请详情表,申请主表中指定申请单下执行状态不为success的申请详情数量
|
|
|
+ total, err := this.DBE.Table(TABLE_APPLY_DETAIL + " a, " + TABLE_SAMPLE_APPLY + "b ").Where(" a.parentid = b.Id and b.entryno = '" + task_id + "' and a.taskstatus <> " + strconv.Itoa(SUCCESS)).Count()
|
|
|
+ if err != nil && err != sql.ErrNoRows {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ // 存在未执行成功的子任务
|
|
|
+ if total > 0 {
|
|
|
+ status = FAILED
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新任务状态
|
|
|
+ updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(status) + "' WHERE task_id = '" + task_id + "'"
|
|
|
+ _, err = this.DBE.Exec(updTaskSql)
|
|
|
+
|
|
|
+ // 更新申请主表状态
|
|
|
+ updApplySql := "UPDATE " + TABLE_SAMPLE_APPLY + " SET taskstatus = '" + strconv.Itoa(status) + "' WHERE entryno = '" + task_id + "'"
|
|
|
+ _, err = this.DBE.Exec(updApplySql)
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
//修改任务表状态码
|
|
|
func (this *ConverseService) TaskStatusModify(statusCode int, task_id string) error {
|
|
|
sql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(statusCode) + "' WHERE task_id = '" + task_id + "'"
|
|
|
@@ -398,20 +424,19 @@ func (this *ConverseService) SampleApplyStatusModify(statusCode int, entryNo str
|
|
|
}
|
|
|
|
|
|
//2020/12/18新增 根据当前任务报文返回状态批量更新当前任务下所有的样本状态
|
|
|
-func (this *ConverseService)SampleApplyDetailStatusModify(statusCode int , entryNo string) error {
|
|
|
+func (this *ConverseService) SampleApplyDetailStatusModify(statusCode int, entryNo string) error {
|
|
|
|
|
|
//获取出入库单Id
|
|
|
getId := "SELECT id FROM " + TABLE_SAMPLE_APPLY + " WHERE entryno = '" + entryNo + "'"
|
|
|
var idList []Id
|
|
|
err := this.DBE.SQL(getId).Find(&idList)
|
|
|
//批量更新全部成功或失败的任务样本状态
|
|
|
- sql:= "UPDATE " + TABLE_APPLY_DETAIL + " SET taskstatus = '" + strconv.Itoa(statusCode) + "' WHERE parentid = '" + strconv.Itoa(idList[0].Id) + "'"
|
|
|
- _,err = this.DBE.Exec(sql)
|
|
|
+ sql := "UPDATE " + TABLE_APPLY_DETAIL + " SET taskstatus = '" + strconv.Itoa(statusCode) + "' WHERE parentid = '" + strconv.Itoa(idList[0].Id) + "'"
|
|
|
+ _, err = this.DBE.Exec(sql)
|
|
|
|
|
|
- return err
|
|
|
+ return err
|
|
|
}
|
|
|
|
|
|
-
|
|
|
////批量更新全部成功或失败的任务样本状态
|
|
|
//func (this *ConverseService)SampleApplyDetailStatusBatchModify(statusCode int , entryNo string) error {
|
|
|
//
|
|
|
@@ -534,7 +559,6 @@ func (this *ConverseService) GetApplyMain(entryNo string) Bank_Apply_Main {
|
|
|
return entity
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//根据出入库单信息判断任务信息, 并修改样本状态
|
|
|
func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, resp string, entity ResponseEntity) {
|
|
|
|
|
|
@@ -542,17 +566,17 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
|
|
|
var operaIds, abnormalIds, taskType string
|
|
|
if applyMain.ApplyType == TASK_TUBE_STORING && strings.Contains(resp, "_storing") {
|
|
|
taskType = "tube_storing" // 冻存管入库
|
|
|
+ // 获取返回报文中成功的样本 和失败的样本
|
|
|
operaIds, abnormalIds = this.getOperaSampleIdsStr(applyMain.ApplyType, applyMain.Id, resp, entity)
|
|
|
|
|
|
//获取报文中的 盒子信息
|
|
|
var Rack_id string = entity.Data.Actual_data[0].Rack_id
|
|
|
- glog.Info("冻存盒盒子编号:",Rack_id)
|
|
|
+ glog.Info("冻存盒盒子编号:", Rack_id)
|
|
|
// 获取报文中的 位置信息和 样本编码
|
|
|
- var tubes = entity.Data.Actual_data[0].Tubes
|
|
|
- glog.Info("样本位置信息:",tubes)
|
|
|
+ var tubes = entity.Data.Actual_data[0].Tubes
|
|
|
+ glog.Info("样本位置信息:", tubes)
|
|
|
//新增方法 更新位置信息
|
|
|
- defer this.UpdatePosition(Rack_id,tubes)
|
|
|
-
|
|
|
+ defer this.UpdatePosition(Rack_id, tubes)
|
|
|
|
|
|
} else if applyMain.ApplyType == TASK_TUBE_RETREIVING && strings.Contains(resp, "_storing") {
|
|
|
//lite设备 部分管子出库
|
|
|
@@ -572,46 +596,44 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 20201026 卢传敏新增根据返回报文,更新位置信息
|
|
|
/**
|
|
|
* rack_id 盒子编号
|
|
|
* tubes 报文中返回的 位置和样本条码
|
|
|
*/
|
|
|
-func (this *ConverseService) UpdatePosition(rack_id string ,tubes []Tube){
|
|
|
+func (this *ConverseService) UpdatePosition(rack_id string, tubes []Tube) {
|
|
|
// 根据返回的报文中的盒子标识,获取盒子类型
|
|
|
- sql := "select RowNum,ColumnNum from bank_box where Barcode ='"+rack_id+"'"
|
|
|
+ sql := "select RowNum,ColumnNum from bank_box where Barcode ='" + rack_id + "'"
|
|
|
var box Box
|
|
|
this.DBE.SQL(sql).Get(&box)
|
|
|
- RowNum := box.RowNum
|
|
|
+ RowNum := box.RowNum
|
|
|
ColumnNum := box.ColumnNum
|
|
|
- glog.Info("冻存盒的行数:",RowNum,";冻存盒的列数:",ColumnNum)
|
|
|
- for i:=0;i<len(tubes);i++ {
|
|
|
+ glog.Info("冻存盒的行数:", RowNum, ";冻存盒的列数:", ColumnNum)
|
|
|
+ for i := 0; i < len(tubes); i++ {
|
|
|
no := tubes[i].No
|
|
|
id := tubes[i].Id
|
|
|
- glog.Info("样本在盒子中的位置:",no,";样本条码: ",id)
|
|
|
+ glog.Info("样本在盒子中的位置:", no, ";样本条码: ", id)
|
|
|
//计算管子在盒子中的坐标
|
|
|
- var box_x,box_y int
|
|
|
-
|
|
|
- if no%RowNum ==0{// 如果 取余数为0 则 证明该数是能被 10 整除的数 为该行 最后一个孔位
|
|
|
- box_y =10
|
|
|
- box_x = no/RowNum
|
|
|
- }else{
|
|
|
- box_y =no%RowNum
|
|
|
- box_x = (no/RowNum)+1
|
|
|
+ var box_x, box_y int
|
|
|
+
|
|
|
+ if no%RowNum == 0 { // 如果 取余数为0 则 证明该数是能被 10 整除的数 为该行 最后一个孔位
|
|
|
+ box_y = 10
|
|
|
+ box_x = no / RowNum
|
|
|
+ } else {
|
|
|
+ box_y = no % RowNum
|
|
|
+ box_x = (no / RowNum) + 1
|
|
|
}
|
|
|
|
|
|
- glog.Info("管子在盒子中的位置坐标为:",box_y,";",box_x)
|
|
|
- var position = utils.NumberToLetter(box_x)+utils.ToStr(box_y)
|
|
|
- sql ="update bank_sample set Position = '"+utils.ToStr(box_y)+";"+utils.ToStr(box_x)+"' ,PositionInfo = concat( REVERSE(SUBSTR(REVERSE(PositionInfo) FROM INSTR(REVERSE(PositionInfo),'-')+1)),'-"+position+"' ) where barcode ='"+id+"' "
|
|
|
+ glog.Info("管子在盒子中的位置坐标为:", box_y, ";", box_x)
|
|
|
+ var position = utils.NumberToLetter(box_x) + utils.ToStr(box_y)
|
|
|
+ sql = "update bank_sample set Position = '" + utils.ToStr(box_y) + ";" + utils.ToStr(box_x) + "' ,PositionInfo = concat( REVERSE(SUBSTR(REVERSE(PositionInfo) FROM INSTR(REVERSE(PositionInfo),'-')+1)),'-" + position + "' ) where barcode ='" + id + "' "
|
|
|
//执行sql 更新位置和坐标信息
|
|
|
this.DBE.Exec(sql)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//获取当前操作样本的id, 正常和异常的
|
|
|
-func (this *ConverseService) getOperaSampleIdsStr(applyType, parentId int, resp string, entity ResponseEntity) (actualIds string, abnormalIds string,) {
|
|
|
+func (this *ConverseService) getOperaSampleIdsStr(applyType, parentId int, resp string, entity ResponseEntity) (actualIds string, abnormalIds string) {
|
|
|
|
|
|
//获取出入库单中所有样本信息
|
|
|
var list []Bank_Apply_Detail
|
|
|
@@ -832,7 +854,7 @@ func (s *ConverseService) GetReason(cause Cause, equipmentName string) string {
|
|
|
var reasonStr string
|
|
|
switch cause.Reason {
|
|
|
case 1:
|
|
|
- reasonStr = "存储位不够;"
|
|
|
+ reasonStr = staticVariable
|
|
|
break
|
|
|
case 2:
|
|
|
reasonStr = "单次任务涉及的冻存盒数量超出限制;"
|
|
|
@@ -912,4 +934,3 @@ func RecordDeviceData(list []List_Data) {
|
|
|
svc := GetConverseService(utils.DBE)
|
|
|
svc.InsertEntity(data)
|
|
|
}
|
|
|
-
|