Parcourir la source

修改任务号分隔符
修改detail添加shelfid 容器id 样本的shelfid 容器id

刘鹏飞 il y a 5 ans
Parent
commit
2a439adf0c

+ 47 - 28
src/dashoo.cn/genepoint_srv/business/converseService/converseService.go

@@ -391,7 +391,7 @@ func (this *ConverseService) StatusModifyWithDetail(task_id string) error {
 	status := SUCCESS
 	// 关联查询申请详情表,申请主表中指定申请单下执行状态不为success的申请详情数量
 
-	sql :="SELECT count(*) FROM `"+TABLE_APPLY_DETAIL+"` a  JOIN `"+TABLE_SAMPLE_APPLY+"` b ON a.parentid = b.Id WHERE ( a.parentid = b.Id and b.entryno = '"+task_id+"' and a.taskstatus <> "+strconv.Itoa(SUCCESS)+")"
+	sql := "SELECT count(*) FROM `" + TABLE_APPLY_DETAIL + "` a  JOIN `" + TABLE_SAMPLE_APPLY + "` b ON a.parentid = b.Id WHERE ( a.parentid = b.Id and b.entryno = '" + task_id + "' and a.taskstatus <> " + strconv.Itoa(SUCCESS) + ")"
 
 	//total, err := this.DBE.Table(TABLE_APPLY_DETAIL ).Join("", TABLE_SAMPLE_APPLY ,"a.parentid = b.Id").Where(" a.parentid = b.Id and b.entryno = '" + task_id + "' and a.taskstatus <> " + strconv.Itoa(SUCCESS)).Count()
 	//if err != nil && err != sql.ErrNoRows {
@@ -403,7 +403,7 @@ func (this *ConverseService) StatusModifyWithDetail(task_id string) error {
 	this.DBE.SQL(sql).Get(&total)
 
 	//total ,_ := result.RowsAffected()
-	fmt.Println("数量:",total)
+	fmt.Println("数量:", total)
 
 	// 存在未执行成功的子任务
 	if total > 0 {
@@ -597,15 +597,14 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
 		var tubes = entity.Data.Actual_data[0].Tubes
 		fmt.Println("样本位置信息:", tubes)
 		//新增方法 更新位置信息
-		defer this.UpdatePosition(Rack_id, tubes)
-
+		defer 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, "_retrieving") /*resp == "rack_retrieving"*/ /*&& entity.Data.Is_end*/ {
+	} else if applyMain.ApplyType == TASK_TUBE_RETREIVING && strings.Contains(resp, "_retrieving") /*resp == "rack_retrieving"*/ /*&& entity.Data.Is_end*/ {
 		fmt.Println("开始入库3")
 		//lite设备 整盒出库
 		taskType = "tube_retrieving"
@@ -614,11 +613,11 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
 		return
 	}
 
-	fmt.Println("resp:",resp)
+	fmt.Println("resp:", resp)
 	// 此处判断,如果是冻存盒整盒入库,需要更新位置信息  盒  冻存盒当前的 所在的冻存架的id
-	if resp == "rack_storing"{
+	if resp == "rack_storing" {
 		this.UpdateBoxInfo(entity)
-	}else if  resp == "rack_retrieving"{
+	} else if resp == "rack_retrieving" {
 		// 冻存盒出库任务完成以后,需要清空冻存盒中的冻存架信息,同时清空
 		this.UpdateBoxInfoCK(entity)
 	}
@@ -632,48 +631,49 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
 
 //2021/01/09 by 卢传敏
 // 根据入库返回报文,更新 冻存盒的信息盒
-func (this *ConverseService) UpdateBoxInfo( entity ResponseEntity )(err error){
+func (this *ConverseService) UpdateBoxInfo(entity ResponseEntity) (err error) {
 	//1.  获取当前返回的  冻存架信息,
 	var shelf Shelf
 
 	// 循环处理返回的数据,如果出现多盒存入的分批处理
 
-	for i := range entity.Data.Actual_data{
-		boxBarcode := entity.Data.Actual_data[i].Rack_id   // 冻存盒编号
-		Cu := entity.Data.Actual_data[i].Target.Cu			// 设备编号
-		Ltu := entity.Data.Actual_data[i].Target.Ltu		//
+	for i := range entity.Data.Actual_data {
+		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 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)
+		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)+" where boxBarcode ='"+boxBarcode+"' ")
+		_, err = this.DBE.Exec("update bank_box set XStation ='" + utils.ToStr(Pos) + "',YStation =1 ,EquipmentId ='" + com.ToStr(shelf.EquipmentId) + "',shelfId =" + utils.ToStr(shelf.Id) + " where Barcode ='" + boxBarcode + "' ")
 		// 更新 当前冰箱冻存盒容量 信息
-		_,err = this.DBE.Exec(" update bank_currboxcapacity  set  `A"+utils.ToStr(Pos)+"`= -1 where shelfId ="+utils.ToStr(shelf.Id)+"" )
+		_, err = this.DBE.Exec(" update bank_currboxcapacity  set  `A" + utils.ToStr(Pos) + "`= -1 where shelfId =" + utils.ToStr(shelf.Id) + "")
 
 	}
 	return err
 
 }
+
 //2021/01/09 by 卢传敏
 // 根据出库返回报文,更新 冻存盒的信息盒
-func (this *ConverseService) UpdateBoxInfoCK( entity ResponseEntity )(err error){
+func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity) (err error) {
 	//1.  获取当前返回的  冻存架信息,
 	var shelf Shelf
 
 	// 循环处理返回的数据,如果出现多盒存入的分批处理
 
-	for i := range entity.Data.Actual_data{
-		boxBarcode := entity.Data.Actual_data[i].Rack_id   // 冻存盒编号
+	for i := range entity.Data.Actual_data {
+		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
@@ -686,28 +686,46 @@ func (this *ConverseService) UpdateBoxInfoCK( entity ResponseEntity )(err error)
 		//	"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)
+		fmt.Println("冻存架信息:", shelf.Id, shelf.XStation, shelf.YStation)
 
 		//  更新盒所在的冻存架的信息  计算位置信息,并更新
 		// 临时处理逻辑,默认 pos 为 盒子的  XStation
-		_,err = this.DBE.Exec("update bank_box set XStation =null,YStation =null ,   where boxBarcode ='"+boxBarcode+"' ")
+		_, err = this.DBE.Exec("update bank_box set XStation =null,YStation =null ,   where Barcode ='" + boxBarcode + "' ")
 		// 更新 当前冰箱冻存盒容量 信息
-		_,err = this.DBE.Exec(" update bank_currboxcapacity  set  `A"+utils.ToStr(Pos)+"`= -2 where shelfId ="+utils.ToStr(shelf.Id)+"" )
+		_, err = this.DBE.Exec(" update bank_currboxcapacity  set  `A" + utils.ToStr(Pos) + "`= -2 where shelfId =" + utils.ToStr(shelf.Id) + "")
 
 	}
 	return err
 
 }
 
-
-
+func (this *ConverseService) UpdateDetail(BarCode string, entity ResponseEntity, parentId int) {
+	var shelf Shelf
+	var equipmentid string
+	var ShelfId string
+	for i := range entity.Data.Actual_data {
+		Cu := entity.Data.Actual_data[i].Target.Cu   // 设备编号
+		Ltu := entity.Data.Actual_data[i].Target.Ltu //
+		Unit := entity.Data.Actual_data[i].Target.Unit
+		Group := entity.Data.Actual_data[i].Target.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)
+		equipmentid = strconv.Itoa(shelf.EquipmentId)
+		ShelfId = strconv.Itoa(shelf.Id)
+		sql = "Update bank_apply_detail Set EquipmentId=" + equipmentid + ",ShelfId=" + ShelfId + " where BarCode='" + BarCode + "' and ParentId=" + strconv.Itoa(parentId)
+		this.DBE.Exec(sql)
+		sql = "update bank_sample set EquipmentId=" + equipmentid + ",ShelfId=" + ShelfId + " where barcode ='" + BarCode + "' "
+		this.DBE.Exec(sql)
+	}
+}
 
 //  20201026 卢传敏新增根据返回报文,更新位置信息
 /**
  * rack_id 盒子编号
  * tubes 报文中返回的 位置和样本条码
  */
-func (this *ConverseService) UpdatePosition(rack_id string, tubes []Tube) {
+func (this *ConverseService) UpdatePosition(rack_id string, tubes []Tube, entity ResponseEntity, parentId int) {
 	// 根据返回的报文中的盒子标识,获取盒子类型
 	sql := "select RowNum,ColumnNum from bank_box where Barcode ='" + rack_id + "'"
 	var box Box
@@ -735,6 +753,7 @@ func (this *ConverseService) UpdatePosition(rack_id string, tubes []Tube) {
 		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)
+		this.UpdateDetail(id, entity, parentId)
 	}
 }
 

+ 2 - 2
src/dashoo.cn/genepoint_srv/controllers/converse/converse.go

@@ -28,7 +28,7 @@ func (this *ConverseController) SearchDatabase() map[string]*RequestEntity {
 	for _, value := range tasks {
 		var time int64 = time.Now().Unix()
 
-		taskid :=/* value.Task_id + "@" +*/ strconv.FormatInt(time, 10)
+		taskid := value.Task_id + "@" + strconv.FormatInt(time, 10)
 		log.Println("taskid:", taskid)
 		//如果没有任务实体, 则创建新任务实体
 		if _, ok := reqMap[value.Task_id]; !ok {
@@ -133,7 +133,7 @@ func (this *ConverseController) HandleMessage(n int, message []byte) {
 
 	resp := res.Response
 	result := res.Result
-	taskId := strings.Split(res.Data.Task_id, "_")[0]
+	taskId := strings.Split(res.Data.Task_id, "@")[0]
 	isEnd := res.Data.Is_end
 	taskType := res.Data.Type