Selaa lähdekoodia

Merge branch 'dev' of http://code.dashoo.cn/dashoo/genepoint_service into dev

xuchl 4 vuotta sitten
vanhempi
commit
afe479b3a0

+ 26 - 36
src/dashoo.cn/genepoint_srv/business/converseService/converseService.go

@@ -125,19 +125,15 @@ func (this *ConverseService) ScanNewTaskDetail() []Sample_Storage_Task {
 	return tasks
 }
 
-
 // 获取申请单创建人
-func (this *ConverseService)GetOperUser(EntryNo string)(user string ){
+func (this *ConverseService) GetOperUser(EntryNo string) (user string) {
 
 	// 获取当前任务的操作人
-	sql := " select  a.UserName from   base_user a left join   bank_apply_main b  on a.id = b.CreateUserId  where b.EntryNo ='"+EntryNo +"' "
+	sql := " select  a.UserName from   base_user a left join   bank_apply_main b  on a.id = b.CreateUserId  where b.EntryNo ='" + EntryNo + "' "
 	this.DBE.SQL(sql).Get(&user)
 	return user
 }
 
-
-
-
 //新任务数量
 func (this *ConverseService) GetNewTaskBasic() []Sample_Storage_Task {
 	//var count64 int64
@@ -179,7 +175,7 @@ func (this *ConverseService) GetNewTaskBasic() []Sample_Storage_Task {
 //}
 
 // 生成请求实体,根据任务类型获取requestName
-func (this *ConverseService) GenerateRequestEntity(taskType int, task_id ,user string) *RequestEntity {
+func (this *ConverseService) GenerateRequestEntity(taskType int, task_id, user string) *RequestEntity {
 	var requestName string
 	switch taskType {
 	case 1:
@@ -338,9 +334,9 @@ func handleTubeStore(entity *RequestEntity, detail *Sample_Storage_Task) {
 		var one Single
 		//one.Rack = 101			// 测试临时使用
 		//one.Tube = 201			// 测试临时使用
-		one.Rack = detail.BoxType   // 样本库系统,没有添加该字段信息逻辑,临时注释
-		one.Tube = detail.TubeType  // 样本库系统,没有添加该字段信息逻辑,临时注释
-		one.Rack_id = detail.SourceBox		 	// 此处需要添加源盒编码  SourceBox
+		one.Rack = detail.BoxType      // 样本库系统,没有添加该字段信息逻辑,临时注释
+		one.Tube = detail.TubeType     // 样本库系统,没有添加该字段信息逻辑,临时注释
+		one.Rack_id = detail.SourceBox // 此处需要添加源盒编码  SourceBox
 		//one.Source.Cu = CU		// 测试临时使用
 		one.Source.Cu = detail.Cu
 		one.Source.Ee = EE
@@ -445,13 +441,12 @@ func (this *ConverseService) TaskStatusModify(statusCode int, task_id string) er
 
 // 修改出入库单状态
 func (this *ConverseService) SampleApplyStatusModify(statusCode int, entryNo string) error {
-	set  :=""
-	if statusCode==1 || statusCode==2 || statusCode==3 || statusCode==5 || statusCode==6 {
+	set := ""
+	if statusCode == 1 || statusCode == 2 || statusCode == 3 || statusCode == 5 || statusCode == 6 {
 		set = "  ,exception='' "
 	}
 
-
-	sql := "UPDATE " + TABLE_SAMPLE_APPLY + " SET taskstatus = '" + strconv.Itoa(statusCode) + "' "+set+"  WHERE entryno = '" + entryNo + "'"
+	sql := "UPDATE " + TABLE_SAMPLE_APPLY + " SET taskstatus = '" + strconv.Itoa(statusCode) + "' " + set + "  WHERE entryno = '" + entryNo + "'"
 	_, err := this.DBE.Exec(sql)
 	return err
 }
@@ -558,7 +553,8 @@ func (this *ConverseService) handleSampleSuccess(idsStr string, response string,
 //入库成功, 修改样本数据库状态信息
 func (this *ConverseService) sampleRKSuccessDBModify(idsStr string, parentId int) error {
 	updatesql := "UPDATE " + TABLE_APPLY_DETAIL + " SET IsLocked = '" + STATUS_UNLOCK + "', taskstatus = '" + strconv.Itoa(SUCCESS) + "' WHERE barcode IN (" + idsStr + ")" + " AND parentid = '" + strconv.Itoa(parentId) + "'"
-	updatesql2 := "UPDATE " + TABLE_SAMPLE + " SET IsLocked = '" + STATUS_UNLOCK + "', IState = '" + RK_PASS + "' WHERE barcode IN (" + idsStr + ")"
+	// 更新样本状态解锁,原盒子id置为0
+	updatesql2 := "UPDATE " + TABLE_SAMPLE + " SET IsLocked = '" + STATUS_UNLOCK + "', IState = '" + RK_PASS + "',SourceBoxId = 0 WHERE barcode IN (" + idsStr + ")"
 
 	//更新每个样本的孔位信息
 
@@ -607,13 +603,13 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
 	var operaIds, abnormalIds, taskType string
 	if applyMain.ApplyType == TASK_TUBE_STORING && strings.Contains(resp, "_storing") {
 
-		fmt.Println("开始入库1",entity)
+		fmt.Println("开始入库1", entity)
 
 		taskType = "tube_storing" //  冻存管入库
 		// 获取返回报文中成功的样本 和失败的样本
 		operaIds, abnormalIds = this.getOperaSampleIdsStr(applyMain.ApplyType, applyMain.Id, resp, entity)
 
-		for _,value :=range  entity.Data.Actual_data{
+		for _, value := range entity.Data.Actual_data {
 			//获取报文中的 盒子信息
 			var Rack_id string = value.Target.Rack_id
 			fmt.Println("冻存盒盒子编号:", Rack_id)
@@ -624,7 +620,6 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
 			this.UpdatePosition(Rack_id, tubes, entity, applyMain.Id)
 		}
 
-
 	} else if applyMain.ApplyType == TASK_TUBE_RETREIVING && strings.Contains(resp, "_storing") {
 		fmt.Println("开始入库2")
 		//lite设备 部分管子出库
@@ -637,7 +632,6 @@ func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, r
 		operaIds, abnormalIds = this.getAllSampleIdsFromResEntity(entity)
 	} else {
 
-
 		return
 	}
 
@@ -665,15 +659,13 @@ func (this *ConverseService) UpdateBoxInfo(entity ResponseEntity) (err error) {
 	//1.  获取当前返回的  冻存架信息,
 	var shelf Shelf
 
-	glog.Info("entity.Data.Actual_data::",entity.Data.Actual_data)
-
-
+	glog.Info("entity.Data.Actual_data::", entity.Data.Actual_data)
 
 	// 循环处理返回的数据,如果出现多盒存入的分批处理
 
 	for i := range entity.Data.Actual_data {
 
-		glog.Info("操作地  ",i,"  条数据")
+		glog.Info("操作地  ", i, "  条数据")
 
 		boxBarcode := entity.Data.Actual_data[i].Rack_id // 冻存盒编号
 		Cu := entity.Data.Actual_data[i].Target.Cu       // 设备编号
@@ -722,7 +714,7 @@ func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity) (err error)
 		//sql := "select a.id,a.XStation,a.YStation from bank_shelf a left join bank_equipment b  on a.EquipmentId = b.id  where  b.cu = '"+utils.ToStr(Cu)+"' " +
 		//	"and  a.Ltu = '"+utils.ToStr(Ltu)+"' and a.Unit ='"+utils.ToStr(Unit) +"' and a.Group ='"+utils.ToStr(Group)+"'"
 
-		sql :=" select shelfId , EquipmentId from bank_box where code = '"+boxBarcode+"'"
+		sql := " select shelfId , EquipmentId from bank_box where code = '" + boxBarcode + "'"
 
 		this.DBE.SQL(sql).Get(&shelf)
 		fmt.Println("冻存架信息:", shelf.Id, shelf.XStation, shelf.YStation)
@@ -737,12 +729,13 @@ func (this *ConverseService) UpdateBoxInfoCK(entity ResponseEntity) (err error)
 	return err
 
 }
+
 /**
- 修改detail 信息
- */
-func (this *ConverseService) UpdateDetail(BarCode string, entity ResponseEntity, parentId int,rack_id string ) {
+修改detail 信息
+*/
+func (this *ConverseService) UpdateDetail(BarCode string, entity ResponseEntity, parentId int, rack_id string) {
 
-	glog.Info("修改detail:",entity)
+	glog.Info("修改detail:", entity)
 
 	var shelf Shelf
 	var equipmentid string
@@ -753,9 +746,8 @@ func (this *ConverseService) UpdateDetail(BarCode string, entity ResponseEntity,
 		Unit := entity.Data.Actual_data[i].Target.Unit
 		Group := entity.Data.Actual_data[i].Target.Group
 
-
 		//当  检测到数据 与当前操作盒子的数据一直时,更新  detail   和sample 信息
-		if entity.Data.Actual_data[i].Target.Rack_id  == rack_id{
+		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) + "'"
 			this.DBE.SQL(sql).Get(&shelf)
@@ -767,7 +759,6 @@ func (this *ConverseService) UpdateDetail(BarCode string, entity ResponseEntity,
 			this.DBE.Exec(sql)
 		}
 
-
 	}
 }
 
@@ -801,10 +792,10 @@ func (this *ConverseService) UpdatePosition(rack_id string, tubes []Tube, entity
 
 		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 = "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, parentId,rack_id)
+		this.UpdateDetail(id, entity, parentId, rack_id)
 	}
 }
 
@@ -1111,13 +1102,12 @@ func RecordDeviceData(list []List_Data) {
 	svc.InsertEntity(data)
 }
 
-
 // 更新异常信息
-func (s *ConverseService)SaveErrInfo(err ,taskid string){
+func (s *ConverseService) SaveErrInfo(err, taskid string) {
 	// 任务发送失败,,,修改任务状态,,,,提示任务执行失败
 	// 请求发送失败
 
-	svc :=  GetConverseService(utils.DBE)
+	svc := GetConverseService(utils.DBE)
 
 	svc.SaveTaskExcepMsg(err, taskid)
 	svc.SaveSampleExcepMsg(err, taskid)