Răsfoiți Sursa

feau(bug): 基点冷库自动化联调bug修复

luchm 3 ani în urmă
părinte
comite
6ee0cee5f9

+ 12 - 1
src/dashoo.cn/genepoint_srv/business/arrangeService/arrange.go

@@ -154,9 +154,15 @@ type Equipment struct {
 }
 // 盒子规格信息
 type Box struct {
+
+	EquipmentId  string // 容器id
+	ShelfId  string  // 冻存架id
 	Id  int    // 盒子id
-	RowNum int          //盒子行数
 	ColumnNum int		// 盒子列数
+	RowNum int          //盒子行数
+	XStation   int   // 位置 X代表第几列
+	YStation   int    // 位置 Y代表第几行
+
 }
 // 冻存架信息
 type Shelf struct {
@@ -165,6 +171,11 @@ type Shelf struct {
 	XStation   int   // 位置 X代表第几列
 	YStation   int    // 位置 Y代表第几行
 }
+type EquipmentInfo struct {
+	Id  int    // id
+	Code  string     // 编码
+	Name string   // 名称
+}
 
 
 type Bank_Equipment struct {

+ 33 - 5
src/dashoo.cn/genepoint_srv/business/arrangeService/arrangeService.go

@@ -186,23 +186,31 @@ func (this *ArrangeService) UpdateBoxInfo(entity ResponseEntity) (err error) {
 		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) + "'"
 
+		// 拼接冻存盒位置信息
+		position := equipment.Code + "-" + utils.NumberToLetter(shelf.XStation) + utils.ToStr(shelf.YStation) + "-" +
+			"" + utils.NumberToLetter( Pos )
+
 		// 冷库设备
 		YStation:="  "
 		if equipment.Ltu  == 0    {
 			sql += "  and a.Unit ='" + utils.ToStr(Unit) + "'   "
 			YStation  = " , YStation =1  "
+			position += utils.ToStr(1)
 			fmt.Println("保存返回的冻存盒位置信息:YStation1:1 ",  YStation)
 		}else{
 			YStation  = " ,   YStation =    "+ utils.ToStr(Unit)
+			position += utils.ToStr(utils.ToStr(Unit))
 			fmt.Println("保存返回的冻存盒位置信息:cYStation1:2 ",  YStation)
 		}
 
 		this.DBE.SQL(sql).Get(&shelf)
 		fmt.Println("冻存架信息:", shelf.Id, shelf.XStation, shelf.YStation)
 
+
 		//  更新盒所在的冻存架的信息  计算位置信息,并更新
 		// 临时处理逻辑,默认 pos 为 盒子的  XStation
-		_, err = this.DBE.Exec("update bank_box set XStation ='" + utils.ToStr(Pos) + "',"+YStation+" ,EquipmentId ='" + com.ToStr(shelf.EquipmentId) + "',shelfId =" + utils.ToStr(shelf.Id) + ",IsLocked = 0  where Barcode ='" + boxBarcode + "' ")
+		_, err = this.DBE.Exec("update bank_box set XStation ='" + utils.ToStr(Pos) + "'  "+YStation+" ,EquipmentId ='" + com.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) + "")
 
@@ -251,11 +259,22 @@ func (this *ArrangeService) UpdateBoxInfoCK(entity ResponseEntity) (err error) {
  **/
 func (this *ArrangeService) UpdatePosition(taskId,rack_id string, tubes []Tube, entity ResponseEntity) {
 	// 根据返回的报文中的盒子标识,获取盒子类型
-	sql := "select Id,RowNum,ColumnNum from bank_box where Barcode ='" + rack_id + "'"
+	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)
+
 	RowNum := box.RowNum
 	ColumnNum := box.ColumnNum
+
+	//  获取容器信息
+	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+"'   "
+	var shelf Shelf
+	this.DBE.SQL(shelfsql).Get(&shelf)
+
 	glog.Info("冻存盒的行数:", RowNum, ";冻存盒的列数:", ColumnNum) //
 	glog.Info("冻存盒内管数量len(tubes) : " ,len(tubes) ) //
 	if len(tubes) >0{
@@ -275,8 +294,12 @@ func (this *ArrangeService) UpdatePosition(taskId,rack_id string, tubes []Tube,
 			}
 
 			glog.Info("管子在盒子中的位置坐标为:", box_y, ";", box_x)
-			var position = utils.NumberToLetter(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  = concat( REVERSE(SUBSTR(REVERSE(PositionInfo) FROM INSTR(REVERSE(PositionInfo),'-')+1)),'-" + position + "' ) where barcode ='" + id + "' "
+
+			position := equipmentInfo.Code + "-" + utils.NumberToLetter(shelf.YStation) + utils.ToStr(shelf.XStation) + "-" +
+				"" + utils.NumberToLetter(box.YStation) + utils.ToStr(box.XStation)+"-"+utils.NumberToLetter(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)
@@ -334,7 +357,12 @@ func (this *ArrangeService) UpdateDetail(BarCode string, entity ResponseEntity,
 			this.DBE.SQL(sql).Get(&shelf)
 			equipmentid = strconv.Itoa(shelf.EquipmentId)
 			ShelfId = strconv.Itoa(shelf.Id)
-			sql = "update bank_sample set EquipmentId=" + equipmentid + ",ShelfId=" + ShelfId + " where barcode ='" + BarCode + "' "
+
+			//pos := equipment.Code + "-" + utils.NumberToLetter(shelf.YStation) + utils.ToStr(shelf.XStation) + "-" +
+			//	"" + utils.NumberToLetter(shelf.YStation) + utils.ToStr(shelf.XStation)
+
+			//sql = "update bank_sample set EquipmentId=" + equipmentid + ",ShelfId=" + ShelfId + " , PositionInfo = CONCAT('"+pos+"-', PositionInfo)  where barcode ='" + BarCode + "' "
+			sql = "update bank_sample set EquipmentId=" + equipmentid + ",ShelfId=" + ShelfId + "    where barcode ='" + BarCode + "' "
 			this.DBE.Exec(sql)
 
 			if  entity.Response == "moving"{