luchm %!s(int64=5) %!d(string=hai) anos
pai
achega
a4ff8668b6

+ 16 - 1
src/dashoo.cn/genepoint_srv/business/converseService/converse.go

@@ -143,7 +143,7 @@ type Tube struct {
 	S_no int    `json:"s_no,omitempty"`
 	Oper bool   `json:"oper,omitempty"`
 }
-
+// 正常入库的结构体
 type Single struct {
 	Rack       int    `json:"rack,omitempty"`
 	Tube       int    `json:"tube,omitempty"`
@@ -154,6 +154,21 @@ type Single struct {
 	Tubes      []Tube `json:"tubes"`
 	Exceptions []int  `json:"exceptions,omitempty"`
 }
+/**
+ *出库的结构体    不需要   Target
+ */
+type OutSingle struct {
+	Rack       int    `json:"rack,omitempty"`
+	Tube       int    `json:"tube,omitempty"`
+	Id         string `json:"id,omitempty"`
+	Rack_id    string `json:"rack_id,omitempty"`
+	Source     Source `json:"source,omitempty"`
+	//Target     Target `json:"target,omitempty"`
+	Tubes      []Tube `json:"tubes"`
+	Exceptions []int  `json:"exceptions,omitempty"`
+}
+
+
 
 type Cause struct {
 	Cu     int `json:"cu"`

+ 49 - 25
src/dashoo.cn/genepoint_srv/business/converseService/converseService.go

@@ -209,7 +209,7 @@ func (this *ConverseService) HandleTaskDetail(taskType int, entity *RequestEntit
 	case 2: //冻存盒出库
 		handleRackRetrieve(entity, detail)
 		break
-	case 3, 8: //冻存管
+	case 3, 8: //冻存管入库
 		handleTubeStore(entity, detail)
 		break
 	case 4: // 冻存管出库
@@ -350,19 +350,19 @@ label:
 
 //处理冻存管出库任务信息
 func handleTubeRetrieve(entity *RequestEntity, detail *Sample_Storage_Task) {
-	var one Single
-	var exist bool
+	var one OutSingle
+	//var exist bool
 	if entity.Data.Task_data != nil {
-		one = entity.Data.Task_data.(Single)
-		exist = true
+		one = entity.Data.Task_data.(OutSingle)
+		//exist = true
 	}
 
-	if !exist {
-		//one.Target.Cu = CU
-		one.Target.Cu = detail.Cu
-		one.Target.Ee = EE
-		one.Target.Pos = POS
-	}
+	//if !exist {
+	//	//one.Target.Cu = CU
+	//	one.Target.Cu = detail.Cu
+	//	one.Target.Ee = EE
+	//	one.Target.Pos = POS
+	//}
 	var tube Tube
 	tube.Id = detail.BarCode
 	one.Tubes = append(one.Tubes, tube)
@@ -422,7 +422,7 @@ func (this *ConverseService) StatusModifyWithDetail(task_id string) error {
 
 //修改任务表状态码
 func (this *ConverseService) TaskStatusModify(statusCode int, task_id string) error {
-	sql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(statusCode) + "' WHERE task_id = '" + task_id + "'"
+	sql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(statusCode) + "', exception=''  WHERE task_id = '" + task_id + "'"
 	_, err := this.DBE.Exec(sql)
 	return err
 }
@@ -580,6 +580,7 @@ func (this *ConverseService) GetApplyMain(entryNo string) Bank_Apply_Main {
 func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, resp string, entity ResponseEntity) {
 
 	applyMain := this.GetApplyMain(entryNo)
+	fmt.Println("resp:", resp)
 
 	var operaIds, abnormalIds, taskType string
 	if applyMain.ApplyType == TASK_TUBE_STORING && strings.Contains(resp, "_storing") {
@@ -613,14 +614,18 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
 		taskType = "tube_retrieving"
 		operaIds, abnormalIds = this.getAllSampleIdsFromResEntity(entity)
 	} else {
+
+
 		return
 	}
 
-	fmt.Println("resp:", resp)
 	// 此处判断,如果是冻存盒整盒入库,需要更新位置信息  盒  冻存盒当前的 所在的冻存架的id
 	if resp == "rack_storing" {
 		this.UpdateBoxInfo(entity)
 	} else if resp == "rack_retrieving" {
+		fmt.Println("出库")
+		//rack_retrieving
+		//rack_retrieving
 		// 冻存盒出库任务完成以后,需要清空冻存盒中的冻存架信息,同时清空
 		this.UpdateBoxInfoCK(entity)
 	}
@@ -700,7 +705,7 @@ func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity) (err error)
 
 		//  更新盒所在的冻存架的信息  计算位置信息,并更新
 		// 临时处理逻辑,默认 pos 为 盒子的  XStation
-		_, err = this.DBE.Exec("update bank_box set XStation =null,YStation =null ,   where Barcode ='" + boxBarcode + "' ")
+		_, err = this.DBE.Exec("update bank_box set shelfId=null,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) + "")
 
@@ -711,7 +716,7 @@ func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity) (err error)
 /**
  修改detail 信息
  */
-func (this *ConverseService) UpdateDetail(BarCode string, entity ResponseEntity, parentId int) {
+func (this *ConverseService) UpdateDetail(BarCode string, entity ResponseEntity, parentId int,rack_id string ) {
 
 	glog.Info("修改detail:",entity)
 
@@ -723,15 +728,22 @@ func (this *ConverseService) UpdateDetail(BarCode string, entity ResponseEntity,
 		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)
+
+
+		//当  检测到数据 与当前操作盒子的数据一直时,更新  detail   和sample 信息
+		if entity.Data.Actual_data[i].Rack_id  == rack_id{
+			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)
+		}
+
+
 	}
 }
 
@@ -768,7 +780,7 @@ func (this *ConverseService) UpdatePosition(rack_id string, tubes []Tube, entity
 		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)
+		this.UpdateDetail(id, entity, parentId,rack_id)
 	}
 }
 
@@ -1074,3 +1086,15 @@ func RecordDeviceData(list []List_Data) {
 	svc := GetConverseService(utils.DBE)
 	svc.InsertEntity(data)
 }
+
+
+// 更新异常信息
+func (s *ConverseService)SaveErrInfo(err ,taskid string){
+	// 任务发送失败,,,修改任务状态,,,,提示任务执行失败
+	// 请求发送失败
+
+	svc :=  GetConverseService(utils.DBE)
+
+	svc.SaveTaskExcepMsg(err, taskid)
+	svc.SaveSampleExcepMsg(err, taskid)
+}

+ 21 - 4
src/dashoo.cn/genepoint_srv/main.go

@@ -155,22 +155,39 @@ func ListenToSendMsg(conn *websocket.Conn) {
 	// 定时规则:每隔10秒执行一次
 	tick := "*/10 * * * * ?"
 	err = cron.AddFunc(tick, func() {
+		//
+		svc := converseService.GetConverseService(utils.DBE)
+
 		// 查询任务,生成指令
 		reqMap := ctrl.SearchDatabase()
 		if err != nil {
 			log.Println("read err:", err)
+			// 任务发送失败,,,修改任务状态,,,,提示任务执行失败
+			for taskid, _ := range reqMap{
+				err = ctrl.StatusModify(converseService.FAILED, taskid)
+				svc.SaveErrInfo(err.Error(),taskid)
+			}
+
+
 		}
 		//判断conn是否还在  todo
 
 		// 发送消息
 		for taskid, reqEntity := range reqMap {
 			log.Println("-reqMap-taskid:",taskid)
-			err := conn.WriteJSON(reqEntity)
-			if err != nil {
-				log.Println("write err:", err)
+			err1 := conn.WriteJSON(reqEntity)
+			log.Println("write err----:", err1)
+			if err1 != nil   {
+				log.Println("请求发送失败")
+				// 任务发送失败,,,修改任务状态,,,,提示任务执行失败
+				err1 = ctrl.StatusModify(converseService.FAILED, taskid)
+				// 跟新异常信息
+				totalMsg:="请求发送失败"
+				svc.SaveErrInfo(totalMsg ,taskid)
+
 			} else {
 				// 发送成功,修改状态
-				err = ctrl.StatusModify(converseService.SENT, taskid)
+				err1 = ctrl.StatusModify(converseService.SENT, taskid)
 			}
 		}
 	})