5
0

2 Commity 584eb6ac00 ... 5b37080a30

Autor SHA1 Správa Dátum
  luchuanmin 5b37080a30 fix(bug): 库内整理异常处理 2 rokov pred
  luchm 7a139ef891 feature: 连接方式升级为MQ 3 rokov pred

+ 72 - 54
src/dashoo.cn/genepoint_srv/business/arrangeService/arrangeService.go

@@ -58,14 +58,14 @@ func (this *ArrangeService) GetOperUser(EntryNo string) (user string) {
  * @return
  **/
 // 修改出入库单状态
-func (this *ArrangeService) ArrangeMainStatusModify(statusCode int, entryNo,msg string) error {
+func (this *ArrangeService) ArrangeMainStatusModify(statusCode int, entryNo, msg string) error {
 	set := ""
-	if statusCode == 1 || statusCode == 2 || statusCode == 3 || statusCode == 5   {
+	if statusCode == 1 || statusCode == 2 || statusCode == 3 || statusCode == 5 {
 		set = "  ,exception='' "
-	}else{
-		if msg!=""{
-			set = "  ,exception='"+msg+"' "
-		}else{
+	} else {
+		if msg != "" {
+			set = "  ,exception='" + msg + "' "
+		} else {
 			set = "  ,exception='' "
 		}
 	}
@@ -75,6 +75,24 @@ func (this *ArrangeService) ArrangeMainStatusModify(statusCode int, entryNo,msg
 	return err
 }
 
+/**
+ * 判断单据类型。如果是整理单,但会moving
+ */
+func (this *ArrangeService) CheckType(entryNo string) (types string) {
+	//  判断是否整理单据信息
+	glog.Info(" 判断是否整理单据信息  ")
+	var Main Bank_Arrange_Main
+	sql := " select * from Bank_Arrange_Main where entryno = '" + entryNo + "'"
+
+	this.DBE.SQL(sql).Get(&Main)
+	glog.Info(" 整理单据信息:  ", Main)
+	if Main.EntryNo == entryNo {
+		return "moving"
+	}
+	return ""
+
+}
+
 /**
  * @Author EDZ
  * @Description // 修改整理单详情表信息
@@ -84,12 +102,16 @@ func (this *ArrangeService) ArrangeMainStatusModify(statusCode int, entryNo,msg
  **/
 func (this *ArrangeService) ArrangeDetailStatusModify(statusCode int, entryNo string) error {
 	//获取出入库单Id
-	getId := "SELECT id FROM " + TABLE_ARRANGE_MAIN+ " WHERE entryno = '" + entryNo + "'"
+	getId := "SELECT id FROM " + TABLE_ARRANGE_MAIN + " WHERE entryno = '" + entryNo + "'"
 	var idList []Id
 	err := this.DBE.SQL(getId).Find(&idList)
-	//批量更新全部成功或失败的任务样本状态
-	sql := "UPDATE " + TABLE_ARRANGE_DETAIL + " SET taskstatus = '" + strconv.Itoa(statusCode) + "' WHERE parentid = '" + strconv.Itoa(idList[0].Id) + "' and taskstatus !=5"
-	_, err = this.DBE.Exec(sql)
+
+	if len(idList) > 0 {
+		//批量更新全部成功或失败的任务样本状态
+		sql := "UPDATE " + TABLE_ARRANGE_DETAIL + " SET taskstatus = '" + strconv.Itoa(statusCode) + "' WHERE parentid = '" + strconv.Itoa(idList[0].Id) + "' and taskstatus !=5"
+		_, err = this.DBE.Exec(sql)
+
+	}
 
 	return err
 }
@@ -115,7 +137,7 @@ func (this *ArrangeService) SaveArrangeExcepMsg(msg, entryNo string) error {
  * @Param
  * @return
  **/
-func (this *ArrangeService) UpdateArrangeRes (entryNo string, resp string, message []byte) error {
+func (this *ArrangeService) UpdateArrangeRes(entryNo string, resp string, message []byte) error {
 	var res ResponseEntity
 	err := json.Unmarshal(message, &res)
 	if err != nil {
@@ -125,7 +147,7 @@ func (this *ArrangeService) UpdateArrangeRes (entryNo string, resp string, messa
 	isEnd := res.Data.Is_end
 
 	// 判断是否全部成功, 更新失败的任务状态
-	this.GetAbnormalDataAndUpdate(taskId,res)
+	this.GetAbnormalDataAndUpdate(taskId, res)
 	// 先更新盒子的原位置
 	err = this.UpdateBoxInfoCK(res)
 	if err != nil {
@@ -147,7 +169,7 @@ func (this *ArrangeService) UpdateArrangeRes (entryNo string, resp string, messa
 		var tubes = value.Tubes
 		fmt.Println("样本位置信息:", tubes)
 		//新增方法 更新位置信息
-		this.UpdatePosition(taskId,Rack_id, tubes, res)
+		this.UpdatePosition(taskId, Rack_id, tubes, res)
 	}
 	if isEnd {
 		// 根据盒子中样本数量更新样本信息
@@ -157,7 +179,6 @@ func (this *ArrangeService) UpdateArrangeRes (entryNo string, resp string, messa
 	return err
 }
 
-
 /**
  * @Author 徐春林
  * @Description // 获取整理成功的 盒子信息并保存
@@ -178,8 +199,8 @@ func (this *ArrangeService) UpdateBoxInfo(entity ResponseEntity) (err error) {
 		glog.Info("操作地  ", i, "  条数据")
 
 		boxBarcode := entity.Data.Actual_data[i].RackId // 冻存盒编号
-		Cu := entity.Data.Actual_data[i].Target.Cu       // 设备编号
-		Ltu := entity.Data.Actual_data[i].Target.Ltu     //
+		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
@@ -190,25 +211,24 @@ func (this *ArrangeService) UpdateBoxInfo(entity ResponseEntity) (err error) {
 		lengSql := " select  * from bank_equipment    where  cu = '" + utils.ToStr(Cu) + "'  and    Ltu = '" + utils.ToStr(Ltu) + "'  "
 		this.DBE.SQL(lengSql).Get(&equipment)
 
-
 		sql := "select b.id EquipmentId,a.id,b.code,b.name,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.Group ='" + utils.ToStr(Group) + "'"
 
 		// 拼接冻存盒位置信息
 		position := equipment.Code + "-" + common.Boxlinename(shelf.XStation) + utils.ToStr(shelf.YStation) + "-" +
-			"" + common.Boxlinename( Pos )
+			"" + common.Boxlinename(Pos)
 
 		// 冷库设备
-		YStation:="  "
-		if equipment.Ltu  == 0    {
+		YStation := "  "
+		if equipment.Ltu == 0 {
 			sql += "  and a.Unit ='" + utils.ToStr(Unit) + "'   "
-			YStation  = " , YStation =1  "
+			YStation = " , YStation =1  "
 			position += utils.ToStr(1)
-			fmt.Println("保存返回的冻存盒位置信息:YStation1:1 ",  YStation)
-		}else{
-			YStation  = " ,   YStation =    "+ utils.ToStr(Unit)
+			fmt.Println("保存返回的冻存盒位置信息:YStation1:1 ", YStation)
+		} else {
+			YStation = " ,   YStation =    " + utils.ToStr(Unit)
 			position += utils.ToStr(utils.ToStr(Unit))
-			fmt.Println("保存返回的冻存盒位置信息:cYStation1:2 ",  YStation)
+			fmt.Println("保存返回的冻存盒位置信息:cYStation1:2 ", YStation)
 		}
 
 		this.DBE.SQL(sql).Get(&shelf)
@@ -217,8 +237,8 @@ func (this *ArrangeService) UpdateBoxInfo(entity ResponseEntity) (err error) {
 
 		//  更新盒所在的冻存架的信息  计算位置信息,并更新
 		// 临时处理逻辑,默认 pos 为 盒子的  XStation
-		_, err = this.DBE.Exec("update bank_box set XStation ='" + utils.ToStr(Pos) + "'  "+YStation+" ,EquipmentId ='" + utils.ToStr(shelf.EquipmentId) + "'," +
-			" shelfId =" + utils.ToStr(shelf.Id) + ",IsLocked = 0 , position = '"+position+"'  where Barcode ='" + boxBarcode + "' ")
+		_, err = this.DBE.Exec("update bank_box set XStation ='" + utils.ToStr(Pos) + "'  " + YStation + " ,EquipmentId ='" + utils.ToStr(shelf.EquipmentId) + "'," +
+			" shelfId =" + utils.ToStr(shelf.Id) + ",IsLocked = 0 , position = '" + position + "'  where Barcode ='" + boxBarcode + "' ")
 		// 更新 当前冰箱冻存盒容量 信息
 		_, err = this.DBE.Exec(" update bank_currboxcapacity  set  `A" + utils.ToStr(Pos) + "`= -1 where shelfId =" + utils.ToStr(shelf.Id) + "")
 
@@ -265,7 +285,7 @@ func (this *ArrangeService) UpdateBoxInfoCK(entity ResponseEntity) (err error) {
  * @Param
  * @return
  **/
-func (this *ArrangeService) UpdatePosition(taskId,rack_id string, tubes []Tube, entity ResponseEntity) {
+func (this *ArrangeService) UpdatePosition(taskId, rack_id string, tubes []Tube, entity ResponseEntity) {
 	// 根据返回的报文中的盒子标识,获取盒子类型
 	sql := "select Id,RowNum,ColumnNum,EquipmentId,ShelfId,XStation,YStation  from bank_box where Barcode ='" + rack_id + "'"
 	var box Box
@@ -275,17 +295,17 @@ func (this *ArrangeService) UpdatePosition(taskId,rack_id string, tubes []Tube,
 	ColumnNum := box.ColumnNum
 
 	//  获取容器信息
-	equipmentsql := " select Id,Code,Name from bank_equipment where id = '"+   box.EquipmentId+"'   "
+	equipmentsql := " select Id,Code,Name from bank_equipment where id = '" + box.EquipmentId + "'   "
 	var equipmentInfo EquipmentInfo
 	this.DBE.SQL(equipmentsql).Get(&equipmentInfo)
 	//  获取架子信息
-	shelfsql := " select Id,XStation,YStation from bank_shelf where id = '"+  box.ShelfId+"'   "
+	shelfsql := " select Id,XStation,YStation from bank_shelf where id = '" + box.ShelfId + "'   "
 	var shelf Shelf
 	this.DBE.SQL(shelfsql).Get(&shelf)
 
 	glog.Info("冻存盒的行数:", RowNum, ";冻存盒的列数:", ColumnNum) //
-	glog.Info("冻存盒内管数量len(tubes) : " ,len(tubes) ) //
-	if len(tubes) >0{
+	glog.Info("冻存盒内管数量len(tubes) : ", len(tubes))            //
+	if len(tubes) > 0 {
 		for i := 0; i < len(tubes); i++ {
 			no := tubes[i].No
 			id := tubes[i].Id
@@ -304,16 +324,16 @@ func (this *ArrangeService) UpdatePosition(taskId,rack_id string, tubes []Tube,
 			glog.Info("管子在盒子中的位置坐标为:", box_y, ";", box_x)
 
 			position := equipmentInfo.Code + "-" + common.Boxlinename(shelf.YStation) + utils.ToStr(shelf.XStation) + "-" +
-				"" + common.Boxlinename(box.YStation) + utils.ToStr(box.XStation)+"-"+common.Boxlinename(box_x) + utils.ToStr(box_y)
+				"" + common.Boxlinename(box.YStation) + utils.ToStr(box.XStation) + "-" + common.Boxlinename(box_x) + utils.ToStr(box_y)
 
 			sql = "update bank_sample set BoxId = '" + utils.ToStr(box.Id) + "',Position = '" + utils.ToStr(box_y) + ";" + utils.ToStr(box_x) + "' , " +
 				"PositionInfo  =  '" + position + "'   where barcode ='" + id + "' "
 			//执行sql 更新位置和坐标信息
 			this.DBE.Exec(sql)
-			this.UpdateDetail(id, entity, rack_id,taskId)
+			this.UpdateDetail(id, entity, rack_id, taskId)
 		}
-	}else{
-		this.UpdateDetail("", entity, rack_id,taskId)
+	} else {
+		this.UpdateDetail("", entity, rack_id, taskId)
 	}
 
 }
@@ -325,7 +345,7 @@ func (this *ArrangeService) UpdatePosition(taskId,rack_id string, tubes []Tube,
  * @Param
  * @return
  **/
-func (this *ArrangeService) UpdateDetail(BarCode string, entity ResponseEntity, rack_id,taskId string) {
+func (this *ArrangeService) UpdateDetail(BarCode string, entity ResponseEntity, rack_id, taskId string) {
 
 	glog.Info("修改detail:", entity)
 	arrangeMain := this.GetArrangeMain(taskId)
@@ -339,17 +359,16 @@ func (this *ArrangeService) UpdateDetail(BarCode string, entity ResponseEntity,
 		Unit := entity.Data.Actual_data[i].Target.Unit
 		Group := entity.Data.Actual_data[i].Target.Group
 
-
 		// 判断是否是冷库,如果是冷库的话,查询容器架子信息时不需要组装 unit
 		lengSql := " select  * from bank_equipment    where  cu = '" + utils.ToStr(Cu) + "'  and    Ltu = '" + utils.ToStr(Ltu) + "'  "
 		this.DBE.SQL(lengSql).Get(&equipment)
 
-		if  entity.Response == "moving"{
+		if entity.Response == "moving" {
 			// 更内库内整理 冻存盒信息 整理结果
 			updatesql := "UPDATE bank_arrange_detail SET IsLocked = '0', taskstatus = '" + strconv.Itoa(SUCCESS) + "' WHERE barcode = '" + entity.Data.Actual_data[i].Target.Rack_id + "'" + " AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
 			this.DBE.Exec(updatesql)
 			// 更内库内整理 冻存盒信息 整理结果
-			updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(SUCCESS) + "' WHERE  boxbarcode = '" +  entity.Data.Actual_data[i].Target.Rack_id + "' and task_id = '"+taskId+"'"
+			updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(SUCCESS) + "' WHERE  boxbarcode = '" + entity.Data.Actual_data[i].Target.Rack_id + "' and task_id = '" + taskId + "'"
 			this.DBE.Exec(updTaskSql)
 		}
 
@@ -358,7 +377,7 @@ func (this *ArrangeService) UpdateDetail(BarCode string, entity ResponseEntity,
 			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.Group ='" + utils.ToStr(Group) + "'"
 
-			if equipment.Ltu  == 0    {
+			if equipment.Ltu == 0 {
 				sql += "  and a.Unit ='" + utils.ToStr(Unit) + "'   "
 			}
 
@@ -373,24 +392,23 @@ func (this *ArrangeService) UpdateDetail(BarCode string, entity ResponseEntity,
 			sql = "update bank_sample set EquipmentId=" + equipmentid + ",ShelfId=" + ShelfId + "    where barcode ='" + BarCode + "' "
 			this.DBE.Exec(sql)
 
-			if  entity.Response == "moving"{
+			if entity.Response == "moving" {
 				// 更内库内整理 冻存盒信息 整理结果
 				updatesql := "UPDATE bank_arrange_detail SET IsLocked = '0', taskstatus = '" + strconv.Itoa(SUCCESS) + "' WHERE barcode = '" + entity.Data.Actual_data[i].Target.Rack_id + "'" + " AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
 				this.DBE.Exec(updatesql)
 				// 更内库内整理 冻存盒信息 整理结果
-				updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(SUCCESS) + "' WHERE  boxbarcode = '" +  entity.Data.Actual_data[i].Target.Rack_id + "' and task_id = '"+taskId+"'"
+				updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(SUCCESS) + "' WHERE  boxbarcode = '" + entity.Data.Actual_data[i].Target.Rack_id + "' and task_id = '" + taskId + "'"
 				this.DBE.Exec(updTaskSql)
-			}else{
+			} else {
 				// 更新库内整理 样本整理结果
 				updatesql := "UPDATE bank_arrange_detail SET IsLocked = '0', taskstatus = '" + strconv.Itoa(SUCCESS) + "' WHERE barcode = '" + BarCode + "'" + " AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
 				this.DBE.Exec(updatesql)
 
-				updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(SUCCESS) + "' WHERE  barcode = '" + BarCode + "' and task_id = '"+taskId+"'"
+				updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(SUCCESS) + "' WHERE  barcode = '" + BarCode + "' and task_id = '" + taskId + "'"
 				this.DBE.Exec(updTaskSql)
 			}
 		}
 
-
 	}
 }
 
@@ -436,7 +454,7 @@ func (this *ArrangeService) GetAbnormalDataAndUpdate(taskId string, entity Respo
 	racks := entity.Data.Abnormal_data.Racks
 	arrangeMain := this.GetArrangeMain(taskId)
 	var shelf Shelf
-	if len(racks) > 0  {
+	if len(racks) > 0 {
 		for _, v := range racks {
 			// 根据盒编码,任务编码查询 任务信息,任务存在更新状态
 			sql := "SELECT count(*) FROM `" + TABLE_TAST + " WHERE task_id = '" + taskId + "' and BoxBarCode = '" + v.RackId + "'"
@@ -447,9 +465,9 @@ func (this *ArrangeService) GetAbnormalDataAndUpdate(taskId string, entity Respo
 			// 存在未执行成功的子任务
 			if total > 0 {
 				// 更新任务明细信息
-				updatesql := "UPDATE " + TABLE_ARRANGE_DETAIL + " SET taskstatus = '" + strconv.Itoa(FAILED) + "' WHERE BoxBarCode = '" +  v.RackId + "' AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
+				updatesql := "UPDATE " + TABLE_ARRANGE_DETAIL + " SET taskstatus = '" + strconv.Itoa(FAILED) + "' WHERE BoxBarCode = '" + v.RackId + "' AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
 				this.DBE.Exec(updatesql)
-				updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(FAILED) + "' WHERE  BoxBarCode = '" +  v.RackId + "' and task_id = '" + taskId + "'"
+				updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(FAILED) + "' WHERE  BoxBarCode = '" + v.RackId + "' and task_id = '" + taskId + "'"
 				this.DBE.Exec(updTaskSql)
 				continue
 			}
@@ -461,11 +479,11 @@ func (this *ArrangeService) GetAbnormalDataAndUpdate(taskId string, entity Respo
 
 			// 根据架编码,任务Id 查询 任务信息, 任务存在更新状态
 			// 更新任务明细信息
-			updatesql := "UPDATE " + TABLE_ARRANGE_DETAIL + " SET taskstatus = '" + strconv.Itoa(FAILED) + "' WHERE ShelfId = " +strconv.Itoa( shelf.Id)+ " AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
+			updatesql := "UPDATE " + TABLE_ARRANGE_DETAIL + " SET taskstatus = '" + strconv.Itoa(FAILED) + "' WHERE ShelfId = " + strconv.Itoa(shelf.Id) + " AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
 			this.DBE.Exec(updatesql)
 
 			// 更新任务状态
-			updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(FAILED) + "' WHERE  ShelfId = " +strconv.Itoa( shelf.Id)+ "and task_id = '" + taskId + "'"
+			updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(FAILED) + "' WHERE  ShelfId = " + strconv.Itoa(shelf.Id) + "and task_id = '" + taskId + "'"
 			this.DBE.Exec(updTaskSql)
 		}
 	}
@@ -484,7 +502,7 @@ func (this *ArrangeService) GetArrangeMain(entryNo string) Bank_Arrange_Main {
 	sql := "SELECT * FROM bank_arrange_main WHERE " + where
 	//results, err := this.DBE.Query(sql)
 	//fmt.Println(results)
-	_,err := this.DBE.SQL(sql).Get(&entity)
+	_, err := this.DBE.SQL(sql).Get(&entity)
 	fmt.Println("执行错误:", err)
 	return entity
 }
@@ -496,8 +514,8 @@ func (this *ArrangeService) GetArrangeMain(entryNo string) Bank_Arrange_Main {
  * @Param
  * @return
  **/
-func (this *ArrangeService) GetAllBox(taskId string)  {
+func (this *ArrangeService) GetAllBox(taskId string) {
 	arrangeMain := this.GetArrangeMain(taskId)
-	sql := "update bank_box a set a.IsEmpty = (case when (select count(b.Id) from bank_sample b where a.Id = b.BoxId) > 0 then 0 else 1 end) where a.EquipmentId = '"+utils.ToStr(arrangeMain.EquipmentId)+"'"
+	sql := "update bank_box a set a.IsEmpty = (case when (select count(b.Id) from bank_sample b where a.Id = b.BoxId) > 0 then 0 else 1 end) where a.EquipmentId = '" + utils.ToStr(arrangeMain.EquipmentId) + "'"
 	this.DBE.Exec(sql)
 }

+ 62 - 43
src/dashoo.cn/genepoint_srv/business/converseService/converse.go

@@ -15,7 +15,6 @@ const REJECT = 7
 const EXCEPTION = 8
 const RACKRETRIEVING = 9
 
-
 const SAMPLE_STATUS_OUT = 5
 const SAMPLE_STATUS_IN = 2
 const TASK_TUBE_STORING = 1
@@ -44,7 +43,7 @@ type RequestData struct {
 	Rack_id        string        `json:"rack_id,omitempty"`
 	Tube_id        string        `json:"tube_id,omitempty"`
 	Task_id        string        `json:"task_id,omitempty"`
-	Operation_user        string        `json:"operation_user,omitempty"`  //
+	Operation_user string        `json:"operation_user,omitempty"` //
 	Task_data      interface{}   `json:"task_data,omitempty"`
 	List           []interface{} `json:"list,omitempty"`
 	Operation_mode string        `json:"operation_mode,omitempty"`
@@ -54,8 +53,8 @@ type RequestData struct {
 	Group          int           `json:"group,omitempty"`
 	Unit           int           `json:"unit,omitempty"`
 	Pos            int           `json:"pos,omitempty"`
-	Name           string 			`json:"name"`
-	Initiator      string `json:"initiator"`
+	Name           string        `json:"name"`
+	Initiator      string        `json:"initiator"`
 }
 
 type ResponseData struct {
@@ -64,10 +63,11 @@ type ResponseData struct {
 	Key            string        `json:"key,omitempty"`
 	Task_id        string        `json:"task_id,omitempty"`
 	Task_msg       []interface{} `json:"task_msg,omitempty"`
-	Msg       	   string      `json:"msg,omitempty"`
+	Msg            string        `json:"msg,omitempty"`
 	Causes         []Cause       `json:"causes,omitempty"`
 	Is_end         bool          `json:"is_end,omitempty"`
 	Execution_time int           `json:"execution_time,omitempty"`
+	Cu             int           `json:"cu,omitempty"`
 	Exceptions     []Exception   `json:"exceptions,omitempty"`
 	Actual_data    []Single      `json:"actual_data,omitempty"`
 	Abnormal_data  Abmormal_data `json:"abnormal_data,omitempty"`
@@ -150,6 +150,7 @@ type Tube struct {
 	S_no int    `json:"s_no,omitempty"`
 	Oper bool   `json:"oper,omitempty"`
 }
+
 // 正常入库的结构体
 type Single struct {
 	Rack       int    `json:"rack,omitempty"`
@@ -161,26 +162,25 @@ 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"`
+	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"`
-	Reason int `json:"reason"`
-	Msg string `json:"msg"`
+	Cu     int    `json:"cu"`
+	Reason int    `json:"reason"`
+	Msg    string `json:"msg"`
 }
 
 type Exception struct {
@@ -229,7 +229,7 @@ type Sample_Storage_Task struct {
 	OperaMode   string
 	Exception   string `xorm:"VARCHAR(512)"`
 	Remark      string
-	SourceBox   string   // 源盒编码
+	SourceBox   string // 源盒编码
 }
 
 type Id struct {
@@ -295,23 +295,23 @@ type Bank_Apply_Main struct {
 type Equipment struct {
 	Name string
 }
+
 // 盒子规格信息
 type Box struct {
-	EquipmentId  string // 容器id
-	ShelfId  string  // 冻存架id
-	Id  int    // 盒子id
-	ColumnNum int		// 盒子列数
-	RowNum int          //盒子行数
-	XStation   int   // 位置 X代表第几列
-	YStation   int    // 位置 Y代表第几行
+	EquipmentId string // 容器id
+	ShelfId     string // 冻存架id
+	Id          int    // 盒子id
+	ColumnNum   int    // 盒子列数
+	RowNum      int    //盒子行数
+	XStation    int    // 位置 X代表第几列
+	YStation    int    // 位置 Y代表第几行
 }
 type EquipmentInfo struct {
-	Id  int    // id
-	Code  string     // 编码
-	Name string   // 名称
+	Id   int    // id
+	Code string // 编码
+	Name string // 名称
 }
 
-
 type Bank_Equipment struct {
 	Id             int       `xorm:"not null pk autoincr INT(10)"`
 	AccCode        string    `xorm:"VARCHAR(10)"`
@@ -320,7 +320,7 @@ type Bank_Equipment struct {
 	Name           string    `xorm:"VARCHAR(255)"`
 	Brand          string    `xorm:"VARCHAR(255)"`
 	Cu             int       `xorm:"INT(2)"`
-	Ltu             int       `xorm:"INT(2)"`
+	Ltu            int       `xorm:"INT(2)"`
 	ModelVersion   string    `xorm:"VARCHAR(255)"`
 	Item           int       `xorm:"INT(10)"`
 	EncodingType   int       `xorm:"INT(10)"`
@@ -349,30 +349,49 @@ type Bank_Equipment struct {
 	RoomId         int       `xorm:"INT(11)"` // 房间ID
 }
 
-
-
-
 // 冻存架信息
 type Shelf struct {
-	EquipmentId  int // 设备id
-	Code  string   // 容器编码
-	Name  string   // 容器名称
-	Id int // 冻存架id
-	XStation   int   // 位置 X代表第几列
-	YStation   int    // 位置 Y代表第几行
+	EquipmentId int    // 设备id
+	Code        string // 容器编码
+	Name        string // 容器名称
+	Id          int    // 冻存架id
+	XStation    int    // 位置 X代表第几列
+	YStation    int    // 位置 Y代表第几行
 }
 
 // 自动库内整理结构体
 type Arrange struct {
-	Logic_id int `json:"logic_id"`
-	Position Position	`json:"position,omitempty"`
+	Logic_id int      `json:"logic_id"`
+	Position Position `json:"position,omitempty"`
 }
 
 // 整理范围结构体
 type Position struct {
-	Cu int	`json:"cu"`
-	Ltu int	`json:"ltu"`
-	Group int	`json:"group"`
-	Unit int	`json:"unit"`
-	Pos int	`json:"pos"`
+	Cu    int `json:"cu"`
+	Ltu   int `json:"ltu"`
+	Group int `json:"group"`
+	Unit  int `json:"unit"`
+	Pos   int `json:"pos"`
+}
+
+// 同步位置信息返回结构体信息
+type SamplePostion struct {
+	Response string            `json:"response"`
+	Result   int               `json:"result"`
+	Time     string            `json:"time"`
+	Data     SamplePostionData `json:"data,omitempty"`
+}
+
+type SamplePostionData struct {
+	Cu      int    `json:"cu"`
+	Ltu     int    `json:"ltu"`
+	Group   int    `json:"group"`
+	Unit    int    `json:"unit"`
+	Pos     int    `json:"pos"`
+	Rack_id string `json:"rack_id"`
+	List    []List `json:"list"`
+}
+type List struct {
+	No int    `json:"no"`
+	Id string `json:"id"`
 }

+ 294 - 99
src/dashoo.cn/genepoint_srv/business/converseService/converseService.go

@@ -5,6 +5,9 @@ import (
 	"dashoo.cn/genepoint_srv/business/arrangeService"
 	"dashoo.cn/genepoint_srv/business/common"
 	"fmt"
+	"github.com/gogf/gf/os/gtime"
+	"github.com/gogf/gf/util/gconv"
+	"github.com/unknwon/com"
 	"log"
 	"strconv"
 	"strings"
@@ -36,7 +39,7 @@ const STATUS_UNLOCK = "0"
 const RK_PASS = "2"
 const CK_PASS_ONHOLD = "3" //保留位置
 const CK_PASS_DONE = "4"   //已归档
-const LOGIC_ID = "0"   // 逻辑分区Id
+const LOGIC_ID = "0"       // 逻辑分区Id
 
 type ConverseService struct {
 	ServiceBase
@@ -149,7 +152,6 @@ func (this *ConverseService) GetNewTaskBasic() []Sample_Storage_Task {
 		log.Println(err)
 	}
 
-
 	return tasks
 }
 
@@ -415,29 +417,29 @@ func handleQueryTube(entity *RequestEntity, detail *Sample_Storage_Task) {
  * @Param
  * @return
  **/
-func handleArrange (entity *RequestEntity, detail *Sample_Storage_Task) {
+func handleArrange(entity *RequestEntity, detail *Sample_Storage_Task) {
 	var ones []Arrange
 
 	if entity.Data.Task_data != nil {
-		ones  = entity.Data.Task_data.([]Arrange)
+		ones = entity.Data.Task_data.([]Arrange)
 	}
 	if entity.Data.Operation_mode == "" {
 		entity.Data.Operation_mode = detail.OperaMode
 	}
 
 	position := Position{
-		Cu: detail.Cu,
-		Ltu:  detail.Ltu,
-		Group:  detail.Group,
+		Cu:    detail.Cu,
+		Ltu:   detail.Ltu,
+		Group: detail.Group,
 		Unit:  detail.Unit,
-		Pos:  detail.Pos,
+		Pos:   detail.Pos,
 	}
 	one := Arrange{
 		Logic_id: 0,
-		Position:  position,
+		Position: position,
 	}
 
-	ones = append(ones,one )
+	ones = append(ones, one)
 	entity.Data.Operation_mode = detail.OperaMode
 	entity.Data.Initiator = "genepoint"
 	entity.Data.Name = "库内整理"
@@ -448,20 +450,12 @@ func handleArrange (entity *RequestEntity, detail *Sample_Storage_Task) {
  * 卢传敏
  * 响应报文,任务执行提示
  */
-func handleTaskActivate(entity *RequestEntity, detail *Sample_Storage_Task){
+func handleTaskActivate(entity *RequestEntity, detail *Sample_Storage_Task) {
 
 }
 
-
-
-
-
-
-
-
-
 // 查询申请单详情下状态,存在一条子任务失败的情况,则整个申请单状态为失败
-func (this *ConverseService) StatusModifyWithDetail(task_id string,res ResponseEntity) error {
+func (this *ConverseService) StatusModifyWithDetail(task_id string, res ResponseEntity) error {
 	status := SUCCESS
 	// 关联查询申请详情表,申请主表中指定申请单下执行状态不为success的申请详情数量
 
@@ -484,7 +478,7 @@ func (this *ConverseService) StatusModifyWithDetail(task_id string,res ResponseE
 		status = FAILED
 	}
 
-	if res.Data.Type =="abnormal_end"{
+	if res.Data.Type == "abnormal_end" {
 		status = EXCEPTION
 	}
 
@@ -492,21 +486,17 @@ func (this *ConverseService) StatusModifyWithDetail(task_id string,res ResponseE
 	//updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(status) + "' WHERE task_id = '" + task_id + "'"
 	//_, err = this.DBE.Exec(updTaskSql)
 
-
-
-	set :=""
-	if res.Data.Type =="end" {
+	set := ""
+	if res.Data.Type == "end" {
 		set = "  ,exception='' "
 	}
 
 	// 更新申请主表状态
-	updApplySql := "UPDATE " + TABLE_SAMPLE_APPLY + " SET taskstatus = '" + strconv.Itoa(status) + "' "+set+"  WHERE entryno = '" + task_id + "'"
+	updApplySql := "UPDATE " + TABLE_SAMPLE_APPLY + " SET taskstatus = '" + strconv.Itoa(status) + "' " + set + "  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 + "'"
@@ -515,14 +505,19 @@ func (this *ConverseService) TaskStatusModify(statusCode int, task_id string) er
 }
 
 // 修改出入库单状态
-func (this *ConverseService) SampleApplyStatusModify(statusCode int, entryNo,msg string) error {
+func (this *ConverseService) SampleApplyStatusModify(statusCode int, entryNo, msg string) error {
 	set := "    "
-	if statusCode == 1 || statusCode == 2 || statusCode == 3 || statusCode == 5   {
+	if statusCode == 1 || statusCode == 2 || statusCode == 3 || statusCode == 5 {
 		set = "  ,exception='' "
-	}else{
-		if msg!=""{
-			set = "  ,exception='"+msg+"' "
-		}else{
+		if statusCode == 5 {
+			// 任务执行成功以后,需要记录执行时间
+			set = "  ,exception='', ExecutionTime =  " + gconv.String(gtime.Now()) + ", ModifiedOn =  " + gconv.String(gtime.Now())
+		}
+
+	} else {
+		if msg != "" {
+			set = "  ,exception='" + msg + "' "
+		} else {
 			set = "  ,exception='' "
 		}
 	}
@@ -539,33 +534,34 @@ func (this *ConverseService) SampleApplyDetailStatusModify(statusCode int, entry
 	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) + "' and taskstatus !=5"
-	_, err = this.DBE.Exec(sql)
+	if len(idList) > 0 {
+		//批量更新全部成功或失败的任务样本状态
+		sql := "UPDATE " + TABLE_APPLY_DETAIL + " SET taskstatus = '" + strconv.Itoa(statusCode) + "' WHERE parentid = '" + strconv.Itoa(idList[0].Id) + "' and taskstatus !=5"
+		_, err = this.DBE.Exec(sql)
+	}
 
 	return err
 }
 
-
-
 //任务执行驳回, 修改全部样本失败状态
 func (this *ConverseService) ModifySampleAllRejectStatus(res ResponseEntity) error {
 	//获取出入库单Id
 	getId := "SELECT id FROM " + TABLE_SAMPLE_APPLY + " WHERE entryno = '" + res.Data.Task_id + "'"
 	var idList []Id
 	err := this.DBE.SQL(getId).Find(&idList)
-	//批量更新全部成功或失败的任务样本状态
-	sql := "UPDATE " + TABLE_APPLY_DETAIL + " SET taskstatus = '" + strconv.Itoa(REJECT) + "' WHERE parentid = '" + strconv.Itoa(idList[0].Id) + "'"
-	_, err = this.DBE.Exec(sql)
+	if len(idList) > 0 {
+		//批量更新全部成功或失败的任务样本状态
+		sql := "UPDATE " + TABLE_APPLY_DETAIL + " SET taskstatus = '" + strconv.Itoa(REJECT) + "' WHERE parentid = '" + strconv.Itoa(idList[0].Id) + "'"
+		_, err = this.DBE.Exec(sql)
+	}
+
 	return err
 }
 
-
 //修改样本失败状态
 
-
 func (this *ConverseService) handleSampleFailed(idsStr string, response string, parentId int) {
-	if (strings.Contains(response, "tube_")) {
+	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)
@@ -593,7 +589,7 @@ func (this *ConverseService) sampleRKSuccessDBModify(idsStr string, parentId int
 	// add by 徐春林  基点入库成功, 根据样本入库详情表中 更新 样本的 剩余容量
 	var list []Bank_Apply_Detail
 	// add by 徐春林 20211224 添加主单Id 作为条件
-	err := this.DBE.Where("barcode IN (" + idsStr + ")  and ParentId = '" + strconv.Itoa(parentId)+"'").Find(&list)
+	err := this.DBE.Where("barcode IN (" + idsStr + ")  and ParentId = '" + strconv.Itoa(parentId) + "'").Find(&list)
 	for _, one := range list {
 		fmt.Println("更新入库容量:", one.BarCode)
 		sql := "UPDATE " + TABLE_SAMPLE + " a SET Capacity = (SELECT Capacity from " + TABLE_APPLY_DETAIL + " b where b.BarCode = '" + one.BarCode + "' and b.ParentId = '" + strconv.Itoa(parentId) + "' ) Where barcode = '" + one.BarCode + "'"
@@ -615,12 +611,12 @@ func (this *ConverseService) sampleCKSuccessDBModify(idsStr string, parentId int
 	var onHold []string
 	var done []string
 	// add by 徐春林 20211224 添加主单Id 作为条件
-	err := this.DBE.Where("barcode IN (" + idsStr + ")   and ParentId = '" + strconv.Itoa(parentId)+"'").Find(&list)
+	err := this.DBE.Where("barcode IN (" + idsStr + ")   and ParentId = '" + strconv.Itoa(parentId) + "'").Find(&list)
 	for _, one := range list {
 		// add by   记录冻融次数
 		//beforeSql := "UPDATE "+TABLE_SAMPLE+" a SET a.FreezingNum = ( select   FreezingNum    from "+TABLE_APPLY_DETAIL+" b where b.BarCode = '"+one.BarCode+"' and b.ParentId = '"+ strconv.Itoa(parentId)+"' ) Where barcode = '"+one.BarCode+"'"
-		beforeSql := "UPDATE "+TABLE_SAMPLE+" a SET a.FreezingNum = (a.FreezingNum +1 )    Where barcode = '"+one.BarCode+"'"
-		_,err =this.DBE.Exec(beforeSql)
+		beforeSql := "UPDATE " + TABLE_SAMPLE + " a SET a.FreezingNum = (a.FreezingNum +1 )    Where barcode = '" + one.BarCode + "'"
+		_, err = this.DBE.Exec(beforeSql)
 		if strconv.Itoa(one.RecoveryId) == CK_PASS_ONHOLD {
 			// 查询样本出库详情, 更新 取出帶放回
 			onHold = append(onHold, one.BarCode)
@@ -659,7 +655,7 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
 	// 此处判断,如果是冻存盒整盒入库,需要更新盒子位置信息  盒  冻存盒当前的 所在的冻存架的id
 	if resp == "rack_storing" {
 		fmt.Println("冻存盒入库")
-		this.UpdateBoxInfo(entity,applyMain.Id)
+		this.UpdateBoxInfo(entity, applyMain.Id)
 	}
 
 	if applyMain.ApplyType == TASK_TUBE_STORING && strings.Contains(resp, "_storing") {
@@ -693,15 +689,15 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
 		//operaIds, abnormalIds = this.getAllSampleIdsFromResEntity(entity)
 		operaIds, abnormalIds = this.getOperaSampleIdsStr(applyMain.ApplyType, applyMain.Id, resp, entity)
 		// 管出库需要 更新 转运空盒 为 源盒
-		this.UpdateBoxInfoCK(entity,applyMain.Id)
+		this.UpdateBoxInfoCK(entity, applyMain.Id)
 	}
 
 	// 此处判断,如果是冻存盒整盒入库,需要更新盒子位置信息  盒  冻存盒当前的 所在的冻存架的id
-	  if resp == "rack_retrieving" {
+	if resp == "rack_retrieving" {
 		fmt.Println("冻存盒出库")
 		//rack_retrieving
 		// 冻存盒出库任务完成以后,需要清空冻存盒中的冻存架信息,同时清空
-		this.UpdateBoxInfoCK(entity,applyMain.Id)
+		this.UpdateBoxInfoCK(entity, applyMain.Id)
 	}
 
 	// 根据管操作 或 盒操作 判断是否执行以下更新
@@ -715,7 +711,7 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
 
 //2021/01/09 by 卢传敏
 // 根据入库返回报文,更新 冻存盒的信息盒
-func (this *ConverseService) UpdateBoxInfo(entity ResponseEntity,parentId int) (err error) {
+func (this *ConverseService) UpdateBoxInfo(entity ResponseEntity, parentId int) (err error) {
 	//1.  获取当前返回的  冻存架信息,
 	var shelf Shelf
 	var equipment Bank_Equipment
@@ -723,7 +719,7 @@ func (this *ConverseService) UpdateBoxInfo(entity ResponseEntity,parentId int) (
 	glog.Info("entity.Data.Actual_data::", entity.Data.Actual_data)
 
 	// 判断是否存在处理成功的数据
-	if len(entity.Data.Actual_data) > 0{
+	if len(entity.Data.Actual_data) > 0 {
 		// 循环处理返回的数据,如果出现多盒存入的分批处理
 		for i := range entity.Data.Actual_data {
 
@@ -738,36 +734,39 @@ func (this *ConverseService) UpdateBoxInfo(entity ResponseEntity,parentId int) (
 
 			fmt.Println("保存返回的冻存盒位置信息:cu:", Cu, ",Ltu", Ltu, ",Unit", Unit, ",Group", Group, ",Pos", Pos)
 
-
 			// 判断是否是冷库,如果是冷库的话,查询容器架子信息时不需要组装 unit
 			lengSql := " select  * from bank_equipment    where  cu = '" + utils.ToStr(Cu) + "'  and    Ltu = '" + utils.ToStr(Ltu) + "'  "
 			this.DBE.SQL(lengSql).Get(&equipment)
 
-			sql  := "select b.id EquipmentId,b.code,b.name,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) + "' " +
+			sql := "select b.id EquipmentId,b.code,b.name,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.Group ='" + utils.ToStr(Group) + "'"
 			// 冷库设备
-			YStation:="  "
-			if equipment.Ltu  == 0    {
+			YStation := "  "
+			if equipment.Ltu == 0 {
 				sql += "  and a.Unit ='" + utils.ToStr(Unit) + "'   "
-				YStation  = " , YStation =1  "
-				fmt.Println("保存返回的冻存盒位置信息:YStation1:1 ",  YStation)
-			}else{
-				YStation  = " ,   YStation =    "+ utils.ToStr(Unit)
-				fmt.Println("保存返回的冻存盒位置信息:cYStation1:2 ",  YStation)
+				YStation = " , YStation =1  "
+				fmt.Println("保存返回的冻存盒位置信息:YStation1:1 ", YStation)
+			} else {
+				YStation = " ,   YStation =    " + utils.ToStr(Unit)
+				fmt.Println("保存返回的冻存盒位置信息:cYStation1:2 ", YStation)
 			}
 
 			this.DBE.SQL(sql).Get(&shelf)
-			fmt.Println("冻存架信息:",shelf.Code,shelf.Name, shelf.Id, shelf.XStation, shelf.YStation)
+			fmt.Println("冻存架信息:", shelf.Code, shelf.Name, shelf.Id, shelf.XStation, shelf.YStation)
 
 			//  更新盒所在的冻存架的信息  计算位置信息,并更新
 			// 临时处理逻辑,默认 pos 为 盒子的  XStation
 			pos := shelf.Code + "-" + common.Boxlinename(shelf.YStation) + utils.ToStr(shelf.XStation) + "-" +
-				"" + common.Boxlinename(    Unit  ) + utils.ToStr(utils.ToStr(Pos))
+				"" + common.Boxlinename(Unit) + utils.ToStr(utils.ToStr(Pos))
+
+			//  冻存盒入库需要先校验,当前盒子是否存在样本,如果不存在,则证明盒子为空盒,修改冻存盒状态为空盒
+			IsEmptysql := "update bank_box a set a.IsEmpty = (case when (select count(b.Id) from bank_sample b where    b.DeletionStateCode!=1 and    a.Id = b.BoxId  ) > 0 then 0 else 1 end) where a.Barcode = '" + boxBarcode + "'"
+			this.DBE.Exec(IsEmptysql)
 
-			possql := "update bank_box set XStation ='" + utils.ToStr(Pos) + "'  "+YStation+"," +
+			possql := "update bank_box set XStation ='" + utils.ToStr(Pos) + "'  " + YStation + "," +
 				" EquipmentId ='" + utils.ToStr(shelf.EquipmentId) + "'," +
 				" shelfId =" + utils.ToStr(shelf.Id) + ",IsLocked = 0 ," +
-				" Position  ='"+pos+"'" +
+				" Position  ='" + pos + "'" +
 				"  where Barcode ='" + boxBarcode + "' "
 			// 冷库设备
 			_, err = this.DBE.Exec(possql)
@@ -776,12 +775,12 @@ func (this *ConverseService) UpdateBoxInfo(entity ResponseEntity,parentId int) (
 
 		}
 	}
-	err = this.UpdateBoxAbnormalInfo(entity,parentId)
+	err = this.UpdateBoxAbnormalInfo(entity, parentId)
 	return err
 
 }
 
-func (this *ConverseService) UpdateBoxAbnormalInfo(entity ResponseEntity,parentId int) (err error) {
+func (this *ConverseService) UpdateBoxAbnormalInfo(entity ResponseEntity, parentId int) (err error) {
 	glog.Info("entity.Data.Abnormal_data::", entity.Data.Abnormal_data)
 	AbnormalRack := ""
 	// 判断是否存在处理失败的数据
@@ -791,20 +790,20 @@ func (this *ConverseService) UpdateBoxAbnormalInfo(entity ResponseEntity,parentI
 		if len(rackEntity) > 0 {
 			for _, v := range rackEntity {
 				// 不为空则需要将数据取出
-				AbnormalRack +=  v.Rack_id + ","
+				AbnormalRack += v.Rack_id + ","
 			}
-			AbnormalRack = AbnormalRack[0 : len(AbnormalRack) -1]
+			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)
+			_, 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)
+			_, err = this.DBE.Exec(updTaskSql)
 			if err != nil {
 				return err
 			}
@@ -816,7 +815,7 @@ func (this *ConverseService) UpdateBoxAbnormalInfo(entity ResponseEntity,parentI
 
 //2021/01/09 by 卢传敏
 // 根据出库返回报文,更新 冻存盒的信息盒
-func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity,parentId int) (err error) {
+func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity, parentId int) (err error) {
 	//1.  获取当前返回的  冻存架信息,
 	var shelf Shelf
 
@@ -839,19 +838,19 @@ func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity,parentId int)
 		// 更新 当前冰箱冻存盒容量 信息
 		_, err = this.DBE.Exec(" update bank_currboxcapacity  set  `A" + utils.ToStr(Pos) + "`= -2 where shelfId =" + utils.ToStr(shelf.Id) + "")
 		updatesql := "UPDATE " + TABLE_DETAIL + " SET taskstatus = '" + strconv.Itoa(SUCCESS) + "' WHERE parentid = '" + strconv.Itoa(parentId) + "'"
-		_,err = this.DBE.Exec(updatesql)
+		_, err = this.DBE.Exec(updatesql)
 		if err != nil {
 			return err
 		}
 		// 更新任务状态
-		updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(SUCCESS) + "' WHERE  BoxBarcode = '" + boxBarcode + "' and task_id = '"+TaskId+"'"
-		_,err =this.DBE.Exec(updTaskSql)
+		updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(SUCCESS) + "' WHERE  BoxBarcode = '" + boxBarcode + "' and task_id = '" + TaskId + "'"
+		_, err = this.DBE.Exec(updTaskSql)
 		if err != nil {
 			return err
 		}
 	}
 
-	err = this.UpdateBoxAbnormalInfo(entity,parentId)
+	err = this.UpdateBoxAbnormalInfo(entity, parentId)
 	return err
 
 }
@@ -866,9 +865,9 @@ func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity,parentId int)
 func (this *ConverseService) UpdateBoxIsLocked(taskId string) (err error) {
 	var task Sample_Storage_Task
 
-	 sql := "SELECT id FROM " + TABLE_TAST + " WHERE taskId = '" + taskId + "'"
+	sql := "SELECT id FROM " + TABLE_TAST + " WHERE taskId = '" + taskId + "'"
 
-	 err = this.DBE.SQL(sql).Find(&task)
+	err = this.DBE.SQL(sql).Find(&task)
 
 	_, err = this.DBE.Exec("update bank_box set IsLocked = 0  where Barcode ='" + task.BoxId + "' ")
 	return err
@@ -894,24 +893,19 @@ func (this *ConverseService) UpdateDetail(BarCode string, entity ResponseEntity,
 		//当  检测到数据 与当前操作盒子的数据一直时,更新  detail   和sample 信息
 		if entity.Data.Actual_data[i].Target.Rack_id == rack_id {
 
-
-
-			fmt.Println("保存返回的冻存盒位置信息:cu:", Cu, ",Ltu", Ltu, ",Unit", Unit, ",Group", Group  )
-
+			fmt.Println("保存返回的冻存盒位置信息:cu:", Cu, ",Ltu", Ltu, ",Unit", Unit, ",Group", Group)
 
 			// 判断是否是冷库,如果是冷库的话,查询容器架子信息时不需要组装 unit
 			lengSql := " select  * from bank_equipment    where  cu = '" + utils.ToStr(Cu) + "'  and    Ltu = '" + utils.ToStr(Ltu) + "'  "
 			this.DBE.SQL(lengSql).Get(&equipment)
 
-
 			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.Group ='" + utils.ToStr(Group) + "'"
 			// 冷库设备
-			if equipment.Ltu ==0 {
+			if equipment.Ltu == 0 {
 				sql += "  and a.Unit ='" + utils.ToStr(Unit) + "' "
 			}
 
-
 			this.DBE.SQL(sql).Get(&shelf)
 			equipmentid = strconv.Itoa(shelf.EquipmentId)
 			ShelfId = strconv.Itoa(shelf.Id)
@@ -934,19 +928,18 @@ func (this *ConverseService) UpdatePosition(rack_id string, tubes []Tube, entity
 	sql := "select Id,RowNum,ColumnNum,EquipmentId,ShelfId,XStation,YStation   from bank_box where Barcode ='" + rack_id + "'"
 	var box Box
 	this.DBE.SQL(sql).Get(&box)
-	glog.Info("盒信息: ",  box)
-	glog.Info("容器Id: ", box.EquipmentId, ";字符串:", utils.ToStr( box.EquipmentId))
+	glog.Info("盒信息: ", box)
+	glog.Info("容器Id: ", box.EquipmentId, ";字符串:", utils.ToStr(box.EquipmentId))
 	// 根据盒子信息获取容器和冻存架信息, 用于更新样本孔位信息
 	//  获取容器信息
-	equipmentsql := " select Id,Code,Name from bank_equipment where id = '"+  box.EquipmentId+"'   "
+	equipmentsql := " select Id,Code,Name from bank_equipment where id = '" + box.EquipmentId + "'   "
 	var equipmentInfo EquipmentInfo
 	this.DBE.SQL(equipmentsql).Get(&equipmentInfo)
 	//  获取架子信息
-	shelfsql := " select Id,XStation,YStation from bank_shelf where id = '"+box.ShelfId+"'   "
+	shelfsql := " select Id,XStation,YStation from bank_shelf where id = '" + box.ShelfId + "'   "
 	var shelf Shelf
 	this.DBE.SQL(shelfsql).Get(&shelf)
 
-
 	RowNum := box.RowNum
 	ColumnNum := box.ColumnNum
 	glog.Info("冻存盒的行数:", RowNum, ";冻存盒的列数:", ColumnNum)
@@ -971,16 +964,15 @@ func (this *ConverseService) UpdatePosition(rack_id string, tubes []Tube, entity
 		position := equipmentInfo.Code + "-" + common.Boxlinename(shelf.YStation) + utils.ToStr(shelf.XStation) + "-" +
 			"" + common.Boxlinename(box.YStation) + utils.ToStr(box.XStation) + "-" + common.Boxlinename(box_x) + utils.ToStr(box_y)
 		sql = "update bank_sample set BoxId = '" + utils.ToStr(box.Id) + "',Position = '" + utils.ToStr(box_y) + ";" +
-			"" + utils.ToStr(box_x) + "',PositionInfo = '"+position+"'  " +
+			"" + utils.ToStr(box_x) + "',PositionInfo = '" + position + "'  " +
 			// " , unit =  '"+  utils.ToStr( entity.Data.Actual_data[i].Target.Unit)+"'" +
 			"    where barcode ='" + id + "' "
 		//执行sql 更新位置和坐标信息
 		this.DBE.Exec(sql)
 
-
 		this.UpdateDetail(id, entity, parentId, rack_id)
 		//卢传敏  新增更新盒子位置信息操作,因为新的业务处理,冻存管必须放在冻存盒中才能入库
-		this.UpdateBoxInfo(entity,parentId)
+		this.UpdateBoxInfo(entity, parentId)
 	}
 }
 
@@ -1072,8 +1064,6 @@ func (this *ConverseService) getAllSampleIdsFromResEntity(entity ResponseEntity)
 	return
 }
 
-
-
 //保存异常信息
 func (this *ConverseService) SaveTaskExcepMsg(msg, taskId string) error {
 	sql := "UPDATE " + TABLE_TAST + " SET exception = '" + msg + "' WHERE task_id = '" + taskId + "'"
@@ -1212,7 +1202,7 @@ func RecordDeviceData(list []List_Data) {
 }
 
 // 更新异常信息
-func (s *ConverseService) SaveErrInfo(err, taskid string,reqType string) {
+func (s *ConverseService) SaveErrInfo(err, taskid string, reqType string) {
 	// 任务发送失败,,,修改任务状态,,,,提示任务执行失败
 	// 请求发送失败
 
@@ -1227,3 +1217,208 @@ func (s *ConverseService) SaveErrInfo(err, taskid string,reqType string) {
 		svc.SaveSampleExcepMsg(err, taskid)
 	}
 }
+
+// 修改同步申请库单状态
+func (this *ConverseService) ApplyStatusModify(statusCode int, entryNo, msg string) error {
+	set := "    "
+	if statusCode == 1 || statusCode == 2 || statusCode == 3 || statusCode == 5 {
+		set = "  ,exception='' "
+	} else {
+		if msg != "" {
+			set = "  ,exception='" + msg + "' "
+		} else {
+			set = "  ,exception='' "
+		}
+	}
+
+	sql := "UPDATE " + "bank_synchronization_main" + " SET taskstatus = '" + strconv.Itoa(statusCode) + "' " + set + "  " +
+		" WHERE entryno = '" + entryNo + "'   "
+	_, err := this.DBE.Exec(sql)
+	return err
+}
+
+//修改任务表状态码
+func (this *ConverseService) ApplyTaskStatusModify(statusCode int, task_id, rack_id string) error {
+	sql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(statusCode) + "'   WHERE " +
+		" task_id = '" + task_id + "' and BoxBarcode = '" + rack_id + "' "
+	_, err := this.DBE.Exec(sql)
+	return err
+}
+
+// 同步更新盒子位置信息
+func (this *ConverseService) UpdateBoxPosition(res ResponseEntity) {
+
+	for k, v := range res.Data.List {
+		glog.Info("操作地  ", k, "  条数据")
+
+		boxBarcode := v.Rack_id // 冻存盒编号
+		Cu := res.Data.Cu       // 设备编号
+		Ltu := v.Ltu            //
+		Unit := v.Unit
+		Pos := v.Pos
+		Group := v.Group
+
+		fmt.Println("保存返回的冻存盒位置信息:cu:", Cu, ",Ltu", Ltu, ",Unit", Unit, ",Group", Group, ",Pos", Pos)
+		var shelf Shelf
+		var equipment Bank_Equipment
+		// 判断是否是冷库,如果是冷库的话,查询容器架子信息时不需要组装 unit
+		lengSql := " select  * from bank_equipment    where  cu = '" + utils.ToStr(res.Data.Cu) + "'  and    Ltu = '" + utils.ToStr(Ltu) + "'  "
+		this.DBE.SQL(lengSql).Get(&equipment)
+
+		sql := "select b.id EquipmentId,b.code,b.name,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.Group ='" + utils.ToStr(Group) + "'"
+		// 冷库设备
+		YStation := "  "
+		if equipment.Ltu == 0 {
+			sql += "  and a.Unit ='" + utils.ToStr(Unit) + "'   "
+			YStation = " , YStation =1  "
+			fmt.Println("保存返回的冻存盒位置信息:YStation1:1 ", YStation)
+		} else {
+			YStation = " ,   YStation =    " + utils.ToStr(Unit)
+			fmt.Println("保存返回的冻存盒位置信息:cYStation1:2 ", YStation)
+		}
+
+		this.DBE.SQL(sql).Get(&shelf)
+		fmt.Println("冻存架信息:", shelf.Code, shelf.Name, shelf.Id, shelf.XStation, shelf.YStation)
+
+		//  更新盒所在的冻存架的信息  计算位置信息,并更新
+		// 临时处理逻辑,默认 pos 为 盒子的  XStation
+		pos := shelf.Code + "-" + common.Boxlinename(shelf.YStation) + utils.ToStr(shelf.XStation) + "-" +
+			"" + common.Boxlinename(Unit) + utils.ToStr(utils.ToStr(Pos))
+
+		possql := "update bank_box set XStation ='" + utils.ToStr(Pos) + "'  " + YStation + "," +
+			" EquipmentId ='" + com.ToStr(shelf.EquipmentId) + "'," +
+			" shelfId =" + utils.ToStr(shelf.Id) + ",IsLocked = 0 ," +
+			" Position  ='" + pos + "'" +
+			"  where Barcode ='" + boxBarcode + "' "
+		// 冷库设备
+		this.DBE.Exec(possql)
+		// 更新 当前冰箱冻存盒容量 信息
+		this.DBE.Exec(" update bank_currboxcapacity  set  `A" + utils.ToStr(Pos) + "`= -1 where shelfId =" + utils.ToStr(shelf.Id) + "")
+
+	}
+
+	var task Sample_Storage_Task
+	sql := " select * from Sample_Storage_Task where   " +
+		" cu = '" + gconv.String(res.Data.Cu) + "' " + "  and   Task_type =5  and  StatusCode  =1  "
+	this.DBE.SQL(sql).Get(&task)
+
+	// 跟新任务状态
+	this.DBE.Exec(" update sample_storage_task set StatusCode =5 where   " +
+		" cu = '" + gconv.String(res.Data.Cu) + "' " + "  and   Task_type =5  and  StatusCode  =1  ")
+
+	this.ApplyStatusModify(SUCCESS, task.Task_id, "")
+
+}
+
+// 更新同步返回的位置信息
+func (this *ConverseService) UpdateSamplePosition(res SamplePostion) {
+
+	boxBarcode := res.Data.Rack_id // 冻存盒编号
+	Cu := res.Data.Cu              // 设备编号
+	Ltu := res.Data.Ltu            //
+	Unit := res.Data.Unit
+	Pos := res.Data.Pos
+	Group := res.Data.Group
+
+	fmt.Println("保存返回的冻存盒位置信息:cu:", Cu, ",Ltu", Ltu, ",Unit", Unit, ",Group", Group, ",Pos", Pos)
+	var shelf Shelf
+	var equipment Bank_Equipment
+	// 判断是否是冷库,如果是冷库的话,查询容器架子信息时不需要组装 unit
+	lengSql := " select  * from bank_equipment    where  cu = '" + utils.ToStr(res.Data.Cu) + "'  and    Ltu = '" + utils.ToStr(Ltu) + "'  "
+	this.DBE.SQL(lengSql).Get(&equipment)
+
+	sql := "select b.id EquipmentId,b.code,b.name,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.Group ='" + utils.ToStr(Group) + "'"
+	// 冷库设备
+	YStation := "  "
+	if equipment.Ltu == 0 {
+		sql += "  and a.Unit ='" + utils.ToStr(Unit) + "'   "
+		YStation = " , YStation =1  "
+		fmt.Println("保存返回的冻存盒位置信息:YStation1:1 ", YStation)
+	} else {
+		YStation = " ,   YStation =    " + utils.ToStr(Unit)
+		fmt.Println("保存返回的冻存盒位置信息:cYStation1:2 ", YStation)
+	}
+
+	this.DBE.SQL(sql).Get(&shelf)
+	fmt.Println("冻存架信息:", shelf.Code, shelf.Name, shelf.Id, shelf.XStation, shelf.YStation)
+
+	//  更新盒所在的冻存架的信息  计算位置信息,并更新
+	// 临时处理逻辑,默认 pos 为 盒子的  XStation
+	pos := shelf.Code + "-" + common.Boxlinename(shelf.YStation) + utils.ToStr(shelf.XStation) + "-" +
+		"" + common.Boxlinename(Unit) + utils.ToStr(utils.ToStr(Pos))
+
+	possql := "update bank_box set XStation ='" + utils.ToStr(Pos) + "'  " + YStation + "," +
+		" EquipmentId ='" + com.ToStr(shelf.EquipmentId) + "'," +
+		" shelfId =" + utils.ToStr(shelf.Id) + ",IsLocked = 0 ," +
+		" Position  ='" + pos + "'" +
+		"  where Barcode ='" + boxBarcode + "' "
+	// 冷库设备
+	this.DBE.Exec(possql)
+	// 更新 当前冰箱冻存盒容量 信息
+	this.DBE.Exec(" update bank_currboxcapacity  set  `A" + utils.ToStr(Pos) + "`= -1 where shelfId =" + utils.ToStr(shelf.Id) + "")
+
+	//根据返回的报文中的盒子标识,获取盒子类型
+	boxsql := "select Id,RowNum,ColumnNum,EquipmentId,ShelfId,XStation,YStation   from bank_box where Barcode ='" + res.Data.Rack_id + "'"
+	var box Box
+	this.DBE.SQL(boxsql).Get(&box)
+	glog.Info("盒信息: ", box)
+	glog.Info("容器Id: ", box.EquipmentId, ";字符串:", utils.ToStr(box.EquipmentId))
+	// 根据盒子信息获取容器和冻存架信息, 用于更新样本孔位信息
+
+	RowNum := box.RowNum
+	ColumnNum := box.ColumnNum
+	glog.Info("冻存盒的行数:", RowNum, ";冻存盒的列数:", ColumnNum)
+
+	//  因为每次只会同步一个盒子的数据,所以按照一个盒子的来
+	for _, v := range res.Data.List {
+		no := v.No
+		id := v.Id
+		glog.Info("样本在盒子中的位置:", no, ";样本条码: ", id)
+		//计算管子在盒子中的坐标
+		var box_x, box_y int
+
+		if no%ColumnNum == 0 { // 如果 取余数为0 则 证明该数是能被  10 整除的数  为该行 最后一个孔位
+			box_y = ColumnNum
+			box_x = no / ColumnNum
+		} else {
+			box_y = no % ColumnNum
+			box_x = (no / ColumnNum) + 1
+		}
+
+		glog.Info("管子在盒子中的位置坐标为:", box_y, ";", box_x)
+		//var position = utils.NumberToLetter(box_x) + utils.ToStr(box_y)
+
+		position := shelf.Code + "-" + common.Boxlinename(shelf.YStation) + utils.ToStr(shelf.XStation) + "-" +
+			"" + common.Boxlinename(box.YStation) + utils.ToStr(box.XStation) + "-" + common.Boxlinename(box_x) + utils.ToStr(box_y)
+		sql = "update bank_sample set BoxId = '" + utils.ToStr(box.Id) + "',Position = '" + utils.ToStr(box_y) + ";" +
+			"" + utils.ToStr(box_x) + "',PositionInfo = '" + position + "'  " +
+			// " , unit =  '"+  utils.ToStr( entity.Data.Actual_data[i].Target.Unit)+"'" +
+			"    where barcode ='" + id + "' "
+		//执行sql 更新位置和坐标信息
+		this.DBE.Exec(sql)
+
+	}
+
+	var task Sample_Storage_Task
+	tasksql := " select * from Sample_Storage_Task where   " +
+		" boxBarcode = '" + res.Data.Rack_id + "' " + "  and   Task_type =6  and  StatusCode  =1  "
+	this.DBE.SQL(tasksql).Get(&task)
+
+	// 跟新任务状态
+	this.DBE.Exec(" update sample_storage_task set StatusCode =5 where   " +
+		"  id = " + gconv.String(task.Id) + " ")
+
+	// 判断所有任务是否全部执行完成
+
+	count, _ := this.DBE.Table("  sample_storage_task ").Where(" task_id = '" + task.Task_id + "'").
+		Where(" StatusCode  !=5  ").Count()
+
+	glog.Info("  count   ", count)
+
+	if count == 0 {
+		this.ApplyStatusModify(SUCCESS, task.Task_id, "")
+	}
+
+}

+ 27 - 9
src/dashoo.cn/genepoint_srv/business/test/test_test.go

@@ -3,6 +3,8 @@ package test
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/gogf/gf/os/glog"
+	"github.com/gogf/gf/util/gconv"
 	"strings"
 	"testing"
 	"time"
@@ -60,7 +62,7 @@ func Test_Time2(t *testing.T) {
 	cron.Stop()
 }
 
-func test_Trim(t *testing.T) {
+func Test_Trim(t *testing.T) {
 
 	// 初始化数据库连接
 	utils.LoadConfig("../../conf/app.conf")
@@ -316,11 +318,11 @@ func test_Trim(t *testing.T) {
 
 				// 所有入库单下子任务已完成,根据样本申请状态(有一个不为成功则更新为失败状态)更新申请单,任务状态
 				if isEnd {
-					err = controller.StatusModifyWithDetail(taskId)
+					err = controller.StatusModifyWithDetail(taskId, res)
 				}
 				//若非正常结束,保存异常信息
 				if taskType == "abnormal_end" {
-					controller.SaveExcepMsg(res, taskId)
+					controller.SaveExcepMsg(res, taskId, "")
 				}
 				//处理任务下申请
 				svc := converse.GetConverseService(utils.DBE)
@@ -329,22 +331,38 @@ func test_Trim(t *testing.T) {
 			} else if taskType == "task_activate" {
 				fmt.Println(">>>>>>>>>>修改激活状态>>>>>>>>>>")
 				if res.Data.Status == 3 {
-					err = controller.StatusModify(REJECT, taskId)
+					err = controller.StatusModify(REJECT, taskId, "", "")
 				} else {
-					err = controller.StatusModify(ACTIVE, taskId)
+					err = controller.StatusModify(ACTIVE, taskId, "", "")
 				}
 			} else if taskType == "accept" {
 				fmt.Println(">>>>>>>>>>修改接受状态>>>>>>>>>>")
-				err = controller.StatusModify(ACCEPT, taskId)
+				err = controller.StatusModify(ACCEPT, taskId, "", "")
 			} else if taskType == "running" {
 				fmt.Println(">>>>>>>>>>修改执行中状态>>>>>>>>>>")
-				err = controller.StatusModify(RUNNING, taskId)
+				err = controller.StatusModify(RUNNING, taskId, "", "")
+			}
+
+			// 设备数据同步接口,单独处理
+			if res.Response == "stock_rack" {
+				glog.Info("    entity ", res)
+				svc := converse.GetConverseService(utils.DBE)
+				svc.UpdateBoxPosition(res)
+			}
+			// 设备数据同步接口,单独处理
+			if res.Response == "stock_rack_tube" {
+				var sampres converse.SamplePostion
+				glog.Info(gconv.String(message))
+				json.Unmarshal([]byte(str[i]), &sampres)
+				svc := converse.GetConverseService(utils.DBE)
+				svc.UpdateSamplePosition(sampres)
 			}
 		} else if result == 300 && taskType == "reject" {
 			fmt.Println("----------任务[" + taskId + "]任务拒绝----------")
 			//保存异常信息
-			controller.SaveExcepMsg(res, taskId)
-			err = controller.StatusModify(REJECT, taskId)
+			//保存异常信息
+			controller.SaveExcepMsg(res, taskId, "")
+			err = controller.StatusModify(REJECT, taskId, "", "")
 		}
 
 		if err != nil {

+ 5 - 2
src/dashoo.cn/genepoint_srv/conf/app.conf

@@ -3,7 +3,10 @@ appname = genepoint_sevice
 
 [server]
 #gpServiceUrl=ws://39.105.83.226:22225/socket
-gpServiceUrl=amqp://genepoint:genepoint2021@47.108.116.228:5672/dashu
+gpServiceUrl=amqp://genepoint:genepoint2021@47.108.116.228:5672/dashu   ## 端口号固定为 5672
+
+gpServiceUrl=amqp://genepoint:genepoint2021@47.108.116.228:5672   ## 线上环境为    端口号固定为 5672
+
 #gpServiceUrl=ws://270100d53m.wicp.vip:46538/socket
 #gpServiceUrl=ws://127.0.0.1:8080/echo
 
@@ -23,7 +26,7 @@ type=mysql
 #pwd=dfmgAkThwVDzJsNz
 
 # 252 测试数据库
-name=biobank_dev
+name=b_ebh_xinhuayiyuan
 host=192.168.0.252
 db_port=3306
 user=root

+ 66 - 23
src/dashoo.cn/genepoint_srv/controllers/converse/converse.go

@@ -2,6 +2,7 @@ package converse
 
 import (
 	"encoding/json"
+	"github.com/gogf/gf/os/glog"
 	"log"
 	"strconv"
 	"strings"
@@ -58,18 +59,17 @@ func (this *ConverseController) SearchDatabase() map[string]*RequestEntity {
 
 		//如果没有任务实体, 则创建新任务实体
 		if _, ok := reqMap[value.Task_id]; !ok {
-			entity := svc.GenerateRequestEntity(value.Task_type /*value.Task_id*/, taskid,user)
+			entity := svc.GenerateRequestEntity(value.Task_type /*value.Task_id*/, taskid, user)
 			reqMap[value.Task_id] = entity
 		}
 		//处理任务详细
 		svc.HandleTaskDetail(value.Task_type, reqMap[value.Task_id], &value)
 
-
 	}
 	for _, v := range reqMap {
 		//log.Println("****************************")
 		m, _ := json.Marshal(v)
-		log.Println("组装报文成功",string(m))
+		log.Println("组装报文成功", string(m))
 	}
 	//log.Println("组装请求数据报文:",reqMap)
 	return reqMap
@@ -84,9 +84,9 @@ func (this *ConverseController) SendMessage(req *RequestEntity, conn *websocket.
 }
 
 // 根据子任务结果修改状态,子任务中有一个失败,则整个申请单为失败状态
-func (this *ConverseController) StatusModifyWithDetail(task_id string,res ResponseEntity ) error {
+func (this *ConverseController) StatusModifyWithDetail(task_id string, res ResponseEntity) error {
 	svc := GetConverseService(utils.DBE)
-	err := svc.StatusModifyWithDetail(task_id,res)
+	err := svc.StatusModifyWithDetail(task_id, res)
 	if err != nil {
 		return err
 	}
@@ -94,7 +94,7 @@ func (this *ConverseController) StatusModifyWithDetail(task_id string,res Respon
 }
 
 // 修改任务状态码
-func (this *ConverseController) StatusModify(statusCode int, task_id string,reqType,msg string) error {
+func (this *ConverseController) StatusModify(statusCode int, task_id string, reqType, msg string) error {
 	svc := GetConverseService(utils.DBE)
 
 	asvc := arrangeService.GetArrangeService(utils.DBE)
@@ -104,8 +104,11 @@ func (this *ConverseController) StatusModify(statusCode int, task_id string,reqT
 		return err
 	}
 
-	if reqType == "moving" {
-		err = asvc.ArrangeMainStatusModify(statusCode, task_id,msg)
+	// 此处需要判断一下是否为库内整理的单据
+	retype := asvc.CheckType(task_id)
+
+	if reqType == "moving" || retype == "moving" {
+		err = asvc.ArrangeMainStatusModify(statusCode, task_id, msg)
 		if err != nil {
 			return err
 		}
@@ -117,7 +120,7 @@ func (this *ConverseController) StatusModify(statusCode int, task_id string,reqT
 		}
 	} else {
 		//修改出入库任务状态
-		err = svc.SampleApplyStatusModify(statusCode, task_id,msg )
+		err = svc.SampleApplyStatusModify(statusCode, task_id, msg)
 		if err != nil {
 			return err
 		}
@@ -139,6 +142,30 @@ func (this *ConverseController) StatusModify(statusCode int, task_id string,reqT
 	return nil
 }
 
+// 修改 同步任务 任务状态码
+func (this *ConverseController) StatusModifyApply(statusCode int, task_id string, reqType, Rack_id, msg string) error {
+	svc := GetConverseService(utils.DBE)
+
+	err := svc.ApplyTaskStatusModify(statusCode, task_id, Rack_id)
+
+	err = svc.ApplyStatusModify(statusCode, task_id, msg)
+	if err != nil {
+		return err
+	}
+	if statusCode != SUCCESS && statusCode != FAILED {
+		err = svc.ApplyStatusModify(statusCode, task_id, "")
+		if err != nil {
+			return err
+		}
+	}
+
+	//if statusCode == SUCCESS || statusCode == REJECT {
+	//	svc.SampleApplyDetailStatusBatchModify(statusCode,task_id)
+	//}
+
+	return nil
+}
+
 //修改部分执行成功样本状态
 //func (this *ConverseController)SamplePartsStatusModify(res ResponseEntity){
 //	svc :=  GetConverseService(utils.DBE)
@@ -158,7 +185,7 @@ func (this *ConverseController) StatusModify(statusCode int, task_id string,reqT
 //}
 
 // 处理基点接口返回的信息
-func (this *ConverseController) HandleMessage( message []byte) {
+func (this *ConverseController) HandleMessage(message []byte) {
 	var res ResponseEntity
 	json.Unmarshal(message, &res)
 
@@ -190,9 +217,9 @@ func (this *ConverseController) HandleMessage( message []byte) {
 				this.SaveExcepMsg(res, taskId, resp)
 			}
 			// add by 徐春林 库内整理任务需要单独处理
-			if resp == "moving"{
+			if resp == "moving" {
 				asvc := arrangeService.GetArrangeService(utils.DBE)
-				err = asvc.UpdateArrangeRes(taskId,resp,message)
+				err = asvc.UpdateArrangeRes(taskId, resp, message)
 			} else {
 				//处理任务下申请
 				svc := GetConverseService(utils.DBE)
@@ -200,25 +227,25 @@ func (this *ConverseController) HandleMessage( message []byte) {
 
 				// 所有入库单下子任务已完成,根据样本申请状态(有一个不为成功则更新为失败状态)更新申请单,任务状态
 				if isEnd {
-					err = this.StatusModifyWithDetail(taskId,res)
+					err = this.StatusModifyWithDetail(taskId, res)
 				}
 			}
 			//this.SampleAllStatusModify(res,SUCCESS)
 		} else if taskType == "task_activate" {
 			log.Println(">>>>>>>>>>任务[" + taskId + "]激活>>>>>>>>>>")
 			if res.Data.Status == 3 {
-				err = this.StatusModify(REJECT, taskId,resp,res.Data.Msg)
-			} else if res.Data.Status == 6 ||   res.Data.Status == 7  {
-				err = this.StatusModify(RUNNING, taskId, resp,res.Data.Msg)
-			}else{
-				err = this.StatusModify(ACTIVE, taskId, resp,res.Data.Msg)
+				err = this.StatusModify(REJECT, taskId, resp, res.Data.Msg)
+			} else if res.Data.Status == 6 || res.Data.Status == 7 {
+				err = this.StatusModify(RUNNING, taskId, resp, res.Data.Msg)
+			} else {
+				err = this.StatusModify(ACTIVE, taskId, resp, res.Data.Msg)
 			}
 		} else if taskType == "accept" {
 			log.Println(">>>>>>>>>>任务[" + taskId + "]接受>>>>>>>>>>")
-			err = this.StatusModify(ACCEPT, taskId, resp,"")
+			err = this.StatusModify(ACCEPT, taskId, resp, "")
 		} else if taskType == "running" {
 			log.Println(">>>>>>>>>>任务[" + taskId + "]执行中>>>>>>>>>>")
-			err = this.StatusModify(RUNNING, taskId, resp,  res.Data.Msg)
+			err = this.StatusModify(RUNNING, taskId, resp, res.Data.Msg)
 		} else if taskType == "rack_retrieving" {
 			log.Println(">>>>>>>>>>任务[" + taskId + "]执行中>>>>>>>>>>")
 			err = this.StatusModify(RACKRETRIEVING, taskId, resp, res.Data.Msg)
@@ -234,11 +261,27 @@ func (this *ConverseController) HandleMessage( message []byte) {
 				err = this.StatusModify(ACTIVE, taskId, resp, res.Data.Msg)
 			}
 		}
+
+		// 设备数据同步接口 - 同步冻存盒位置信息
+		if resp == "stock_rack" {
+			svc := GetConverseService(utils.DBE)
+			svc.UpdateBoxPosition(res)
+		}
+		// 设备数据同步接口 - 同步冻存管位置信息
+		if res.Response == "stock_rack_tube" {
+			var sampres SamplePostion
+			json.Unmarshal(message, &sampres)
+
+			glog.Info("    entity ", res)
+			svc := GetConverseService(utils.DBE)
+			svc.UpdateSamplePosition(sampres)
+		}
+
 	} else if result == 300 && taskType == "reject" {
 		log.Println("----------任务[" + taskId + "]任务拒绝----------")
 		//保存异常信息
 		this.SaveExcepMsg(res, taskId, resp)
-		err = this.StatusModify(REJECT, taskId, resp,res.Data.Causes[0].Msg)
+		err = this.StatusModify(REJECT, taskId, resp, res.Data.Causes[0].Msg)
 		// 判断如果为盒操作, 需要将 盒解锁, 重新执行时再上锁
 		if resp == "rack_storing" || resp == "rack_retrieving" {
 			err = this.UpdateBoxIsLocked(taskId)
@@ -249,7 +292,7 @@ func (this *ConverseController) HandleMessage( message []byte) {
 		log.Println(err)
 	}
 }
-func (this *ConverseController) UpdateBoxIsLocked(taskId string) error{
+func (this *ConverseController) UpdateBoxIsLocked(taskId string) error {
 	svc := GetConverseService(utils.DBE)
 	err := svc.UpdateBoxIsLocked(taskId)
 	if err != nil {
@@ -259,7 +302,7 @@ func (this *ConverseController) UpdateBoxIsLocked(taskId string) error{
 }
 
 //保存异常信息
-func (this *ConverseController) SaveExcepMsg(res ResponseEntity, taskId ,reqType string) {
+func (this *ConverseController) SaveExcepMsg(res ResponseEntity, taskId, reqType string) {
 	svc := GetConverseService(utils.DBE)
 	//causeByte,_ := json.Marshal(res.Data.Causes)
 	//causeMsg := string(causeByte)

+ 1 - 0
src/dashoo.cn/genepoint_srv/go.mod

@@ -8,6 +8,7 @@ require (
 	github.com/gorilla/websocket v1.4.2
 	github.com/robfig/cron v1.2.0
 	github.com/robfig/cron/v3 v3.0.1
+	github.com/unknwon/com v1.0.1 // indirect
 	github.com/wagslane/go-rabbitmq v0.10.0 // indirect
 	xorm.io/xorm v1.1.2
 )

+ 36 - 0
src/dashoo.cn/genepoint_srv/go.sum

@@ -1,7 +1,9 @@
 gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
 gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
+github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
+github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw=
 github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
 github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
 github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@@ -9,17 +11,23 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
 github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
 github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
 github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
+github.com/astaxie/beego v1.12.3 h1:SAQkdD2ePye+v8Gn1r4X6IKZM1wd28EyUOVQ3PDSOOQ=
 github.com/astaxie/beego v1.12.3/go.mod h1:p3qIm0Ryx7zeBHLljmd7omloyca1s4yu1a8kM1FkpIA=
 github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=
 github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU=
 github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
+github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
 github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
+github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=
 github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
 github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
 github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=
+github.com/casbin/casbin v1.9.1 h1:ucjbS5zTrmSLtH4XogqOG920Poe6QatdXtz1FEbApeM=
 github.com/casbin/casbin v1.9.1/go.mod h1:z8uPsfBJGUsnkagrt3G8QvjgTKFMBJ32UP8HpZllfog=
+github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
 github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28 h1:LdXxtjzvZYhhUaonAaAKArG3pyC67kGL3YY+6hGG8G4=
 github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
 github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
 github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
@@ -27,6 +35,7 @@ github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:sr
 github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
 github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
 github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
@@ -39,6 +48,7 @@ github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo
 github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc=
 github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
 github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
 github.com/glendc/gopher-json v0.0.0-20170414221815-dc4743023d0c/go.mod h1:Gja1A+xZ9BoviGJNA2E9vFkPjjsl+CoJxSXiQM1UXtw=
 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
@@ -68,8 +78,10 @@ github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4
 github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
 github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
 github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
 github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
 github.com/gomodule/redigo v1.8.5/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
+github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
 github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
 github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
 github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
@@ -82,10 +94,13 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
 github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
 github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
 github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0=
 github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
+github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
 github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
+github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
 github.com/jmoiron/sqlx v1.3.1/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ=
 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
@@ -102,27 +117,34 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
 github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
 github.com/ledisdb/ledisdb v0.0.0-20200510135210-d35789ec47e6/go.mod h1:n931TsDuKuq+uX4v1fulaMbA/7ZLLhjc85h7chZGBCQ=
 github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
 github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
 github.com/lib/pq v1.7.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
+github.com/lib/pq v1.10.0 h1:Zx5DJFEYQXio93kgXnQ09fXNiUKsqv4OUEu2UtGcB1E=
 github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
 github.com/lunny/godbc v0.0.0-20131220142036-57f94ee1eb13 h1:aQopy7KTYTKDFWHzYusiT8lLRIiHECYk2v7VShtkWNE=
 github.com/lunny/godbc v0.0.0-20131220142036-57f94ee1eb13/go.mod h1:8e6WOK6PpJb5JSDf2cutQwrywJw3TimZhvpj8Z3m7F0=
 github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
 github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
+github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
 github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
 github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
 github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
 github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
 github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
 github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
+github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
 github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
 github.com/mediocregopher/radix.v2 v0.0.0-20181115013041-b67df6e626f9/go.mod h1:fLRUbhbSd5Px2yKUaGYYPltlyxi1guJz1vCmo1RQL50=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
 github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
 github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0=
@@ -130,6 +152,7 @@ github.com/naoina/toml v0.1.1/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4
 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
 github.com/nsqio/go-nsq v1.1.0/go.mod h1:vKq36oyeVXgsS5Q8YEO7WghqidAVXQlcFxzQbQTuDEY=
+github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
 github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
 github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@@ -144,17 +167,22 @@ github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHu
 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
 github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
+github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U=
 github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
 github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
 github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
 github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
+github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
 github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
 github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
+github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
 github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
 github.com/rabbitmq/amqp091-go v1.3.4 h1:tXuIslN1nhDqs2t6Jrz3BAoqvt4qIZzxvdbdcxWtHYU=
 github.com/rabbitmq/amqp091-go v1.3.4/go.mod h1:ogQDLSOACsLPsIq0NpbtiifNZi2YOz0VTJ0kHRghqbM=
@@ -164,12 +192,14 @@ github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
 github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
 github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
 github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
+github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
 github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
 github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s=
 github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
 github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
+github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
 github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
 github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 h1:Jpy1PXuP99tXNrhbq2BaPz9B+jNAvH1JPQQpG/9GCXY=
@@ -188,9 +218,12 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
 github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
+github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
 github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
 github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
+github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs=
 github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM=
+github.com/unknwon/goconfig v0.0.0-20200908083735-df7de6a44db8 h1:b/rWs6xu47ewpFN3BZDJ5ppuaPC/yObRC0WJFIlQUZk=
 github.com/unknwon/goconfig v0.0.0-20200908083735-df7de6a44db8/go.mod h1:qu2ZQ/wcC/if2u32263HTVC39PeOQRSmidQk3DuDFQ8=
 github.com/wagslane/go-rabbitmq v0.10.0 h1:y9Bw8Q/9gOvsHfjMOGQjCW3033aYTKabxDm8eyjUGjs=
 github.com/wagslane/go-rabbitmq v0.10.0/go.mod h1:u6xM1V7OO4D0szUy/F6Bya/9r0lLae/2FXBijkAQmn0=
@@ -206,6 +239,7 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
 golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
@@ -251,6 +285,7 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
@@ -320,6 +355,7 @@ modernc.org/z v1.0.1 h1:WyIDpEpAIx4Hel6q/Pcgj/VhaQV5XPJ2I6ryIYbjnpc=
 modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA=
 xorm.io/builder v0.3.8 h1:P/wPgRqa9kX5uE0aA1/ukJ23u9KH0aSRpHLwDKXigSE=
 xorm.io/builder v0.3.8/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
+xorm.io/core v0.7.3 h1:W8ws1PlrnkS1CZU1YWaYLMQcQilwAmQXU0BJDJon+H0=
 xorm.io/core v0.7.3/go.mod h1:jJfd0UAEzZ4t87nbQYtVjmqpIODugN6PD2D9E+dJvdM=
 xorm.io/xorm v1.1.2 h1:bje+1KZvK3m5AHtZNfUDlKEEyuw/IRHT+an0CLIG5TU=
 xorm.io/xorm v1.1.2/go.mod h1:Cb0DKYTHbyECMaSfgRnIZp5aiUgQozxcJJ0vzcLGJSg=

+ 14 - 8
src/dashoo.cn/genepoint_srv/main.go

@@ -35,6 +35,7 @@ var consumerName = "dashoo"
 // 初始化基点接口服务器
 func initGpServiceUrl() {
 	gpServiceUrl = utils.Cfg.MustValue("server", "gpServiceUrl")
+	fmt.Println(" gpServiceUrl :", gpServiceUrl)
 }
 
 func main() {
@@ -77,7 +78,7 @@ func main() {
 		},
 		"genepoint.dispatch.to.lims",
 		[]string{""},
-		func (ops *rabbitmq.ConsumeOptions) {
+		func(ops *rabbitmq.ConsumeOptions) {
 			if ops.QueueArgs == nil {
 				ops.QueueArgs = rabbitmq.Table{}
 			}
@@ -170,10 +171,9 @@ func newWithSeconds() *cron.Cron {
 // 定时查询接口任务,给基点接口发送请求
 func ListenToSendMsg() {
 	log.Println("准备发送消息>>>>>>>>>>>>>>>>>>>")
-	cron := newWithSeconds()
+	c := cron.New()
 	// 定时规则:每隔10秒执行一次
-	tick := "*/10 * * * * ?"
-	_,err = cron.AddFunc(tick, func() {
+	_, err = c.AddFunc("@every 10s", func() {
 		svc := converseService.GetConverseService(utils.DBE)
 		// 查询任务,生成指令
 		reqMap := ctrl.SearchDatabase()
@@ -181,8 +181,13 @@ func ListenToSendMsg() {
 			log.Println("read err:", err)
 			// 任务发送失败,,,修改任务状态,,,,提示任务执行失败
 			for taskid, reqEntity := range reqMap {
-				err = ctrl.StatusModify(converseService.FAILED, taskid,reqEntity.Request,"")
-				svc.SaveErrInfo(err.Error(), taskid,reqEntity.Request)
+				if reqEntity.Request == "" {
+					err = ctrl.StatusModifyApply(converseService.FAILED, taskid, reqEntity.Request, reqEntity.Data.Rack_id, "")
+				} else {
+					err = ctrl.StatusModify(converseService.FAILED, taskid, reqEntity.Request, "")
+					svc.SaveErrInfo(err.Error(), taskid, reqEntity.Request)
+				}
+
 			}
 		}
 		// 发送消息
@@ -195,7 +200,7 @@ func ListenToSendMsg() {
 				// 跟新异常信息
 				totalMsg := "请求发送失败"
 				svc.SaveErrInfo(totalMsg, taskid, reqEntity.Request)
-			}else {
+			} else {
 				// 基点采用的广播(fanout)形式,Exchange为:genepoint.lims.to.dispatch,不需要指定Routing key
 				err = mqPublisher.Publish(
 					message,
@@ -222,6 +227,7 @@ func ListenToSendMsg() {
 			}
 		}
 	})
+	c.Start()
 	if err != nil {
 		log.Println(err)
 	}
@@ -239,7 +245,7 @@ func ClearSuccessfulTask() {
 	cron := cron.New()
 	//每天0时清除任务表
 	tick := "0 0 0 * * ?"
-	_,err = cron.AddFunc(tick, func() {
+	_, err = cron.AddFunc(tick, func() {
 		ctrl.DeleteAccomplishedTask()
 		if err != nil {
 			log.Println("read:", err)