Просмотр исходного кода

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

luchm 3 лет назад
Родитель
Сommit
476f0908f8

+ 39 - 0
src/dashoo.cn/genepoint_srv/business/arrangeService/arrange.go

@@ -165,3 +165,42 @@ type Shelf struct {
 	XStation   int   // 位置 X代表第几列
 	YStation   int    // 位置 Y代表第几行
 }
+
+
+type Bank_Equipment struct {
+	Id             int       `xorm:"not null pk autoincr INT(10)"`
+	AccCode        string    `xorm:"VARCHAR(10)"`
+	ModelId        int       `xorm:"INT(10)"`
+	Code           string    `xorm:"VARCHAR(50)"`
+	Name           string    `xorm:"VARCHAR(255)"`
+	Brand          string    `xorm:"VARCHAR(255)"`
+	Cu             int       `xorm:"INT(2)"`
+	Ltu             int       `xorm:"INT(2)"`
+	ModelVersion   string    `xorm:"VARCHAR(255)"`
+	Item           int       `xorm:"INT(10)"`
+	EncodingType   int       `xorm:"INT(10)"`
+	RowNum         int       `xorm:"INT(10)"`
+	ColumnNum      int       `xorm:"INT(10)"`
+	Width          float32   `xorm:"FLOAT"`
+	Height         float32   `xorm:"FLOAT"`
+	Depth          float32   `xorm:"FLOAT"`
+	SampleType     string    `xorm:"VARCHAR(500)"`
+	State          int       `xorm:"TINYINT(4)"`
+	BarCode        string    `xorm:"VARCHAR(100)"`
+	BarCode2       string    `xorm:"VARCHAR(100)"`
+	HCode          string    `xorm:"VARCHAR(100)"`
+	SortCode       int       `xorm:"INT(10)"`
+	CreateUserId   int       `xorm:"INT(10)"`
+	CreateBy       string    `xorm:"VARCHAR(255)"`
+	CreateOn       time.Time `xorm:"DATETIME created"`
+	ModifiedUserId int       `xorm:"INT(10)"`
+	ModifiedBy     string    `xorm:"VARCHAR(255)"`
+	ModifiedOn     time.Time `xorm:"DATETIME updated"`
+	Remark         string    `xorm:"TEXT"`
+	IsLargeSpec    int       `xorm:"INT(10)"`
+	ProduceDate    time.Time `form:"ProduceDate,2006-1-2"`
+	UseDate        time.Time `form:"UseDate,2006-1-2"`
+	ValidityDate   time.Time `form:"ValidityDate,2006-1-2"`
+	RoomId         int       `xorm:"INT(11)"` // 房间ID
+}
+

+ 84 - 30
src/dashoo.cn/genepoint_srv/business/arrangeService/arrangeService.go

@@ -7,11 +7,11 @@ package arrangeService
 
 import (
 	"dashoo.cn/utils"
+	. "dashoo.cn/utils/db"
 	"encoding/json"
 	"fmt"
 	"github.com/Unknwon/com"
 	"github.com/go-xorm/xorm"
-	. "dashoo.cn/utils/db"
 	"github.com/gogf/gf/os/glog"
 	"strconv"
 	"strings"
@@ -160,7 +160,7 @@ func (this *ArrangeService) UpdateArrangeRes (entryNo string, resp string, messa
 func (this *ArrangeService) UpdateBoxInfo(entity ResponseEntity) (err error) {
 	//1.  获取当前返回的  冻存架信息,
 	var shelf Shelf
-
+	var equipment Bank_Equipment
 	glog.Info("entity.Data.Actual_data::", entity.Data.Actual_data)
 
 	// 循环处理返回的数据,如果出现多盒存入的分批处理
@@ -178,15 +178,31 @@ func (this *ArrangeService) UpdateBoxInfo(entity ResponseEntity) (err error) {
 
 		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,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) + "'"
+			"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.Id, shelf.XStation, shelf.YStation)
 
 		//  更新盒所在的冻存架的信息  计算位置信息,并更新
 		// 临时处理逻辑,默认 pos 为 盒子的  XStation
-		_, err = this.DBE.Exec("update bank_box set XStation ='" + utils.ToStr(Pos) + "',YStation =1 ,EquipmentId ='" + com.ToStr(shelf.EquipmentId) + "',shelfId =" + utils.ToStr(shelf.Id) + ",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  where Barcode ='" + boxBarcode + "' ")
 		// 更新 当前冰箱冻存盒容量 信息
 		_, err = this.DBE.Exec(" update bank_currboxcapacity  set  `A" + utils.ToStr(Pos) + "`= -1 where shelfId =" + utils.ToStr(shelf.Id) + "")
 
@@ -240,29 +256,35 @@ func (this *ArrangeService) UpdatePosition(taskId,rack_id string, tubes []Tube,
 	this.DBE.SQL(sql).Get(&box)
 	RowNum := box.RowNum
 	ColumnNum := box.ColumnNum
-	glog.Info("冻存盒的行数:", RowNum, ";冻存盒的列数:", ColumnNum)
-	for i := 0; i < len(tubes); i++ {
-		no := tubes[i].No
-		id := tubes[i].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("冻存盒的行数:", RowNum, ";冻存盒的列数:", ColumnNum) //
+	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
+			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)
-		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 + "' "
-		//执行sql 更新位置和坐标信息
-		this.DBE.Exec(sql)
-		this.UpdateDetail(id, entity, rack_id,taskId)
+			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 + "' "
+			//执行sql 更新位置和坐标信息
+			this.DBE.Exec(sql)
+			this.UpdateDetail(id, entity, rack_id,taskId)
+		}
+	}else{
+		this.UpdateDetail("", entity, rack_id,taskId)
 	}
+
 }
 
 /**
@@ -277,6 +299,7 @@ func (this *ArrangeService) UpdateDetail(BarCode string, entity ResponseEntity,
 	glog.Info("修改detail:", entity)
 	arrangeMain := this.GetArrangeMain(taskId)
 	var shelf Shelf
+	var equipment Bank_Equipment
 	var equipmentid string
 	var ShelfId string
 	for i := range entity.Data.Actual_data {
@@ -285,19 +308,50 @@ 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"{
+			// 更内库内整理 冻存盒信息 整理结果
+			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+"'"
+			this.DBE.Exec(updTaskSql)
+		}
+
 		//当  检测到数据 与当前操作盒子的数据一直时,更新  detail   和sample 信息
 		if entity.Data.Actual_data[i].Target.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) + "'"
+				"and  a.Ltu = '" + utils.ToStr(Ltu) + "'  and a.Group ='" + utils.ToStr(Group) + "'"
+
+			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)
 			sql = "update bank_sample set EquipmentId=" + equipmentid + ",ShelfId=" + ShelfId + " where barcode ='" + BarCode + "' "
 			this.DBE.Exec(sql)
-			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+"'"
-			this.DBE.Exec(updTaskSql)
+
+			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+"'"
+				this.DBE.Exec(updTaskSql)
+			}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+"'"
+				this.DBE.Exec(updTaskSql)
+			}
 		}
 
 

+ 42 - 0
src/dashoo.cn/genepoint_srv/business/converseService/converse.go

@@ -12,6 +12,8 @@ const FAILED = 4
 const SUCCESS = 5
 const RUNNING = 6
 const REJECT = 7
+const EXCEPTION = 8
+
 
 const SAMPLE_STATUS_OUT = 5
 const SAMPLE_STATUS_IN = 2
@@ -51,6 +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"`
 }
 
 type ResponseData struct {
@@ -174,6 +178,7 @@ type OutSingle struct {
 type Cause struct {
 	Cu     int `json:"cu"`
 	Reason int `json:"reason"`
+	Msg string `json:"msg"`
 }
 
 type Exception struct {
@@ -305,6 +310,43 @@ type EquipmentInfo struct {
 }
 
 
+type Bank_Equipment struct {
+	Id             int       `xorm:"not null pk autoincr INT(10)"`
+	AccCode        string    `xorm:"VARCHAR(10)"`
+	ModelId        int       `xorm:"INT(10)"`
+	Code           string    `xorm:"VARCHAR(50)"`
+	Name           string    `xorm:"VARCHAR(255)"`
+	Brand          string    `xorm:"VARCHAR(255)"`
+	Cu             int       `xorm:"INT(2)"`
+	Ltu             int       `xorm:"INT(2)"`
+	ModelVersion   string    `xorm:"VARCHAR(255)"`
+	Item           int       `xorm:"INT(10)"`
+	EncodingType   int       `xorm:"INT(10)"`
+	RowNum         int       `xorm:"INT(10)"`
+	ColumnNum      int       `xorm:"INT(10)"`
+	Width          float32   `xorm:"FLOAT"`
+	Height         float32   `xorm:"FLOAT"`
+	Depth          float32   `xorm:"FLOAT"`
+	SampleType     string    `xorm:"VARCHAR(500)"`
+	State          int       `xorm:"TINYINT(4)"`
+	BarCode        string    `xorm:"VARCHAR(100)"`
+	BarCode2       string    `xorm:"VARCHAR(100)"`
+	HCode          string    `xorm:"VARCHAR(100)"`
+	SortCode       int       `xorm:"INT(10)"`
+	CreateUserId   int       `xorm:"INT(10)"`
+	CreateBy       string    `xorm:"VARCHAR(255)"`
+	CreateOn       time.Time `xorm:"DATETIME created"`
+	ModifiedUserId int       `xorm:"INT(10)"`
+	ModifiedBy     string    `xorm:"VARCHAR(255)"`
+	ModifiedOn     time.Time `xorm:"DATETIME updated"`
+	Remark         string    `xorm:"TEXT"`
+	IsLargeSpec    int       `xorm:"INT(10)"`
+	ProduceDate    time.Time `form:"ProduceDate,2006-1-2"`
+	UseDate        time.Time `form:"UseDate,2006-1-2"`
+	ValidityDate   time.Time `form:"ValidityDate,2006-1-2"`
+	RoomId         int       `xorm:"INT(11)"` // 房间ID
+}
+
 
 
 

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

@@ -419,7 +419,11 @@ func handleQueryTube(entity *RequestEntity, detail *Sample_Storage_Task) {
  * @return
  **/
 func handleArrange (entity *RequestEntity, detail *Sample_Storage_Task) {
+	var ones []Arrange
 
+	if entity.Data.Task_data != nil {
+		ones  = entity.Data.Task_data.([]Arrange)
+	}
 	if entity.Data.Operation_mode == "" {
 		entity.Data.Operation_mode = detail.OperaMode
 	}
@@ -435,20 +439,15 @@ func handleArrange (entity *RequestEntity, detail *Sample_Storage_Task) {
 		Logic_id: 0,
 		Position:  position,
 	}
-	var ones []Arrange
-	ones = append(ones,one )
-	/*var one Arrange
-	one.Logic_id = 0 // 当前逻辑分区设置为 0
-	one.Position.Cu = detail.Cu
-	one.Position.Ltu = detail.Ltu
-	one.Position.Group = detail.Group
-	one.Position.Unit = detail.Unit
-	one.Position.Pos = detail.Pos*/
 
+	ones = append(ones,one )
+	entity.Data.Operation_mode = detail.OperaMode
+	entity.Data.Initiator = "genepoint"
+	entity.Data.Name = "库内整理"
 	entity.Data.Task_data = ones
 }
 // 查询申请单详情下状态,存在一条子任务失败的情况,则整个申请单状态为失败
-func (this *ConverseService) StatusModifyWithDetail(task_id string) error {
+func (this *ConverseService) StatusModifyWithDetail(task_id string,res ResponseEntity) error {
 	status := SUCCESS
 	// 关联查询申请详情表,申请主表中指定申请单下执行状态不为success的申请详情数量
 
@@ -471,6 +470,10 @@ func (this *ConverseService) StatusModifyWithDetail(task_id string) error {
 		status = FAILED
 	}
 
+	if res.Data.Type =="abnormal_end"{
+		status = EXCEPTION
+	}
+
 	// 更新任务状态
 	//updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(status) + "' WHERE task_id = '" + task_id + "'"
 	//_, err = this.DBE.Exec(updTaskSql)
@@ -733,6 +736,7 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
 func (this *ConverseService) UpdateBoxInfo(entity ResponseEntity,parentId int) (err error) {
 	//1.  获取当前返回的  冻存架信息,
 	var shelf Shelf
+	var equipment Bank_Equipment
 
 	glog.Info("entity.Data.Actual_data::", entity.Data.Actual_data)
 
@@ -752,15 +756,39 @@ func (this *ConverseService) UpdateBoxInfo(entity ResponseEntity,parentId int) (
 
 			fmt.Println("保存返回的冻存盒位置信息:cu:", Cu, ",Ltu", Ltu, ",Unit", Unit, ",Group", Group, ",Pos", Pos)
 
-			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) + "'"
+
+			// 判断是否是冷库,如果是冷库的话,查询容器架子信息时不需要组装 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) + "'"
+			// 冷库设备
+			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.Id, shelf.XStation, shelf.YStation)
 
 			//  更新盒所在的冻存架的信息  计算位置信息,并更新
 			// 临时处理逻辑,默认 pos 为 盒子的  XStation
-			_, err = this.DBE.Exec("update bank_box set XStation ='" + utils.ToStr(Pos) + "',YStation =1 ,EquipmentId ='" + com.ToStr(shelf.EquipmentId) + "',shelfId =" + utils.ToStr(shelf.Id) + ",IsLocked = 0  where Barcode ='" + boxBarcode + "' ")
+			pos := equipment.Code + "-" + utils.NumberToLetter(shelf.YStation) + utils.ToStr(shelf.XStation) + "-" +
+				"" + utils.NumberToLetter(    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 + "' "
+			// 冷库设备
+			_, err = this.DBE.Exec(possql)
 			// 更新 当前冰箱冻存盒容量 信息
 			_, err = this.DBE.Exec(" update bank_currboxcapacity  set  `A" + utils.ToStr(Pos) + "`= -1 where shelfId =" + utils.ToStr(shelf.Id) + "")
 
@@ -833,7 +861,7 @@ func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity,parentId int)
 
 		//  更新盒所在的冻存架的信息  计算位置信息,并更新
 		// 临时处理逻辑,默认 pos 为 盒子的  XStation
-		_, err = this.DBE.Exec("update bank_box set EquipmentId=null,shelfId=null,XStation =null,YStation =null,IsLocked = 0  where Barcode ='" + boxBarcode + "' ")
+		_, err = this.DBE.Exec("update bank_box set EquipmentId=null,shelfId=null,XStation =null,YStation =null,IsLocked = 0,Position =null   where Barcode ='" + boxBarcode + "' ")
 		// 更新 当前冰箱冻存盒容量 信息
 		_, 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) + "'"
@@ -880,6 +908,7 @@ func (this *ConverseService) UpdateDetail(BarCode string, entity ResponseEntity,
 	glog.Info("修改detail:", entity)
 
 	var shelf Shelf
+	var equipment Bank_Equipment
 	var equipmentid string
 	var ShelfId string
 	for i := range entity.Data.Actual_data {
@@ -890,8 +919,25 @@ 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  )
+
+
+			// 判断是否是冷库,如果是冷库的话,查询容器架子信息时不需要组装 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.Unit ='" + utils.ToStr(Unit) + "' and a.Group ='" + utils.ToStr(Group) + "'"
+				"and  a.Ltu = '" + utils.ToStr(Ltu) + "'  and a.Group ='" + utils.ToStr(Group) + "'"
+			// 冷库设备
+			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)
@@ -951,7 +997,7 @@ func (this *ConverseService) UpdatePosition(rack_id string, tubes []Tube, entity
 		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 + "' "
+			"" + utils.ToStr(box_x) + "',PositionInfo = '"+position+"'  , unit =  '"+  utils.ToStr( entity.Data.Actual_data[i].Target.Unit)+"'   where barcode ='" + id + "' "
 		//执行sql 更新位置和坐标信息
 		this.DBE.Exec(sql)
 
@@ -1205,6 +1251,8 @@ func (s *ConverseService) GetReason(cause Cause, equipmentName string) string {
 		break
 	case 8:
 		reasonStr = "半自动设备在不配置转运机器人的情况下,一个存管任务只允许操作一台设备;"
+	default:
+		reasonStr = cause.Msg
 	}
 
 	if cause.Cu != 0 {

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

@@ -83,9 +83,9 @@ func (this *ConverseController) SendMessage(req *RequestEntity, conn *websocket.
 }
 
 // 根据子任务结果修改状态,子任务中有一个失败,则整个申请单为失败状态
-func (this *ConverseController) StatusModifyWithDetail(task_id string) error {
+func (this *ConverseController) StatusModifyWithDetail(task_id string,res ResponseEntity ) error {
 	svc := GetConverseService(utils.DBE)
-	err := svc.StatusModifyWithDetail(task_id)
+	err := svc.StatusModifyWithDetail(task_id,res)
 	if err != nil {
 		return err
 	}
@@ -199,7 +199,7 @@ func (this *ConverseController) HandleMessage(n int, message []byte) {
 
 				// 所有入库单下子任务已完成,根据样本申请状态(有一个不为成功则更新为失败状态)更新申请单,任务状态
 				if isEnd {
-					err = this.StatusModifyWithDetail(taskId)
+					err = this.StatusModifyWithDetail(taskId,res)
 				}
 			}
 

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

@@ -269,13 +269,22 @@ func ListenToReadMsg() (pid int) {
 	return
 }
 
+
+func newWithSeconds() *cron.Cron {
+	secondParser := cron.NewParser(cron.Second | cron.Minute |
+		cron.Hour | cron.Dom | cron.Month | cron.DowOptional | cron.Descriptor)
+	return cron.New(cron.WithParser(secondParser), cron.WithChain())
+}
+
 // 定时查询接口任务,给基点接口发送请求
 func ListenToSendMsg() {
 	log.Println("发送消息>>>>>>>>>>>>>>>>>>>")
-	cron := cron.New()
+
+
+	cron := newWithSeconds()
 	// 定时规则:每隔10秒执行一次
 	tick := "*/10 * * * * ?"
-	err = cron.AddFunc(tick, func() {
+	_,err = cron.AddFunc(tick, func() {
 		// if temp {
 		// 	wsConn = initWebSocket()
 		// 	if wsConn != nil {
@@ -341,7 +350,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)
@@ -428,7 +437,7 @@ func BackupDatabase() {
 	//minute   hour   day   month   week   command
 	//tick := "0 0 0 * * ?"
 	tick := "0 0 0 * * ?"
-	err = cron.AddFunc(tick, func() {
+	_,err = cron.AddFunc(tick, func() {
 		BackupMySqlDb("")
 		if err != nil {
 			log.Println("数据库备份失败:", err)