|
|
@@ -5,17 +5,19 @@ import (
|
|
|
"dashoo.cn/genepoint_srv/business/arrangeService"
|
|
|
"dashoo.cn/genepoint_srv/business/common"
|
|
|
"fmt"
|
|
|
- "github.com/Unknwon/com"
|
|
|
+ "github.com/gogf/gf/util/gconv"
|
|
|
+ "github.com/unknwon/com"
|
|
|
+
|
|
|
"github.com/gogf/gf/os/glog"
|
|
|
"log"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
|
- "github.com/go-xorm/xorm"
|
|
|
+ "xorm.io/xorm"
|
|
|
|
|
|
- "dashoo.cn/utils"
|
|
|
- . "dashoo.cn/utils/db"
|
|
|
+ "dashoo.cn/base_common/utils"
|
|
|
+ . "dashoo.cn/base_common/utils/db"
|
|
|
)
|
|
|
|
|
|
const CU = 1
|
|
|
@@ -37,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
|
|
|
@@ -150,7 +152,6 @@ func (this *ConverseService) GetNewTaskBasic() []Sample_Storage_Task {
|
|
|
log.Println(err)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
return tasks
|
|
|
}
|
|
|
|
|
|
@@ -416,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 = "库内整理"
|
|
|
@@ -449,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的申请详情数量
|
|
|
|
|
|
@@ -485,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
|
|
|
}
|
|
|
|
|
|
@@ -493,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 + "'"
|
|
|
@@ -516,14 +505,14 @@ 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{
|
|
|
+ } else {
|
|
|
+ if msg != "" {
|
|
|
+ set = " ,exception='" + msg + "' "
|
|
|
+ } else {
|
|
|
set = " ,exception='' "
|
|
|
}
|
|
|
}
|
|
|
@@ -547,8 +536,6 @@ func (this *ConverseService) SampleApplyDetailStatusModify(statusCode int, entry
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//任务执行驳回, 修改全部样本失败状态
|
|
|
func (this *ConverseService) ModifySampleAllRejectStatus(res ResponseEntity) error {
|
|
|
//获取出入库单Id
|
|
|
@@ -561,12 +548,10 @@ func (this *ConverseService) ModifySampleAllRejectStatus(res ResponseEntity) err
|
|
|
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)
|
|
|
@@ -594,7 +579,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 + "'"
|
|
|
@@ -616,12 +601,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)
|
|
|
@@ -660,7 +645,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") {
|
|
|
@@ -694,15 +679,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)
|
|
|
}
|
|
|
|
|
|
// 根据管操作 或 盒操作 判断是否执行以下更新
|
|
|
@@ -716,7 +701,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
|
|
|
@@ -724,7 +709,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 {
|
|
|
|
|
|
@@ -739,36 +724,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))
|
|
|
|
|
|
- possql := "update bank_box set XStation ='" + utils.ToStr(Pos) + "' "+YStation+"," +
|
|
|
+ // 冻存盒入库需要先校验,当前盒子是否存在样本,如果不存在,则证明盒子为空盒,修改冻存盒状态为空盒
|
|
|
+ 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 + "," +
|
|
|
" EquipmentId ='" + com.ToStr(shelf.EquipmentId) + "'," +
|
|
|
" shelfId =" + utils.ToStr(shelf.Id) + ",IsLocked = 0 ," +
|
|
|
- " Position ='"+pos+"'" +
|
|
|
+ " Position ='" + pos + "'" +
|
|
|
" where Barcode ='" + boxBarcode + "' "
|
|
|
// 冷库设备
|
|
|
_, err = this.DBE.Exec(possql)
|
|
|
@@ -777,12 +765,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 := ""
|
|
|
// 判断是否存在处理失败的数据
|
|
|
@@ -792,20 +780,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
|
|
|
}
|
|
|
@@ -817,7 +805,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
|
|
|
|
|
|
@@ -840,19 +828,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
|
|
|
|
|
|
}
|
|
|
@@ -867,9 +855,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
|
|
|
@@ -895,24 +883,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)
|
|
|
@@ -935,19 +918,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)
|
|
|
@@ -972,16 +954,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)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1073,8 +1054,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 + "'"
|
|
|
@@ -1213,7 +1192,7 @@ func RecordDeviceData(list []List_Data) {
|
|
|
}
|
|
|
|
|
|
// 更新异常信息
|
|
|
-func (s *ConverseService) SaveErrInfo(err, taskid string,reqType string) {
|
|
|
+func (s *ConverseService) SaveErrInfo(err, taskid string, reqType string) {
|
|
|
// 任务发送失败,,,修改任务状态,,,,提示任务执行失败
|
|
|
// 请求发送失败
|
|
|
|
|
|
@@ -1228,3 +1207,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, "")
|
|
|
+ }
|
|
|
+
|
|
|
+}
|