浏览代码

返回报文测试工具

luchm 5 年之前
父节点
当前提交
9d25897f72

+ 30 - 13
src/dashoo.cn/genepoint_srv/business/converseService/converseService.go

@@ -2,7 +2,6 @@ package converseService
 
 import (
 	"crypto/md5"
-	"database/sql"
 	"fmt"
 	"github.com/gogf/gf/os/glog"
 	"log"
@@ -390,22 +389,33 @@ func handleQueryTube(entity *RequestEntity, detail *Sample_Storage_Task) {
 func (this *ConverseService) StatusModifyWithDetail(task_id string) error {
 	status := SUCCESS
 	// 关联查询申请详情表,申请主表中指定申请单下执行状态不为success的申请详情数量
-	total, err := this.DBE.Table(TABLE_APPLY_DETAIL + " a, " + TABLE_SAMPLE_APPLY + "b ").Where(" a.parentid = b.Id and b.entryno = '" + task_id + "' and a.taskstatus <> " + strconv.Itoa(SUCCESS)).Count()
-	if err != nil && err != sql.ErrNoRows {
-		return err
-	}
+
+	sql :="SELECT count(*) FROM `"+TABLE_APPLY_DETAIL+"` a  JOIN `"+TABLE_SAMPLE_APPLY+"` b ON a.parentid = b.Id WHERE ( a.parentid = b.Id and b.entryno = '"+task_id+"' and a.taskstatus <> "+strconv.Itoa(SUCCESS)+")"
+
+	//total, err := this.DBE.Table(TABLE_APPLY_DETAIL ).Join("", TABLE_SAMPLE_APPLY ,"a.parentid = b.Id").Where(" a.parentid = b.Id and b.entryno = '" + task_id + "' and a.taskstatus <> " + strconv.Itoa(SUCCESS)).Count()
+	//if err != nil && err != sql.ErrNoRows {
+	//	return err
+	//}
+
+	var total int
+	//_, err := this.DBE.Exec(sql)
+	this.DBE.SQL(sql).Get(&total)
+
+	//total ,_ := result.RowsAffected()
+	fmt.Println("数量:",total)
+
 	// 存在未执行成功的子任务
 	if total > 0 {
 		status = FAILED
 	}
 
 	// 更新任务状态
-	updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(status) + "' WHERE task_id = '" + task_id + "'"
-	_, err = this.DBE.Exec(updTaskSql)
+	//updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(status) + "' WHERE task_id = '" + task_id + "'"
+	//_, err = this.DBE.Exec(updTaskSql)
 
 	// 更新申请主表状态
 	updApplySql := "UPDATE " + TABLE_SAMPLE_APPLY + " SET taskstatus = '" + strconv.Itoa(status) + "' WHERE entryno = '" + task_id + "'"
-	_, err = this.DBE.Exec(updApplySql)
+	_, err := this.DBE.Exec(updApplySql)
 	return err
 }
 
@@ -502,8 +512,14 @@ func (this *ConverseService) ModifySampleAllRejectStatus(res ResponseEntity) err
 
 //修改样本失败状态
 func (this *ConverseService) handleSampleFailed(idsStr string, response string, parentId int) {
+	// 更新任务明细信息
 	updatesql := "UPDATE " + TABLE_APPLY_DETAIL + " SET taskstatus = '" + strconv.Itoa(FAILED) + "' WHERE barcode IN (" + idsStr + ")" + " AND parentid = '" + strconv.Itoa(parentId) + "'"
 	this.DBE.Exec(updatesql)
+
+	// 更新任务状态
+	updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(FAILED) + "' WHERE  barcode IN (" + idsStr + ")"
+	this.DBE.Exec(updTaskSql)
+
 }
 
 //处理样本执行成功状态
@@ -563,6 +579,7 @@ func (this *ConverseService) GetApplyMain(entryNo string) Bank_Apply_Main {
 func (this *ConverseService) ModifySampleStatusByApplyMainInfo(entryNo string, resp string, entity ResponseEntity) {
 
 	applyMain := this.GetApplyMain(entryNo)
+
 	var operaIds, abnormalIds, taskType string
 	if applyMain.ApplyType == TASK_TUBE_STORING && strings.Contains(resp, "_storing") {
 		taskType = "tube_storing" //  冻存管入库
@@ -616,12 +633,12 @@ func (this *ConverseService) UpdatePosition(rack_id string, tubes []Tube) {
 		//计算管子在盒子中的坐标
 		var box_x, box_y int
 
-		if no%RowNum == 0 { // 如果 取余数为0 则 证明该数是能被  10 整除的数  为该行 最后一个孔位
-			box_y = 10
-			box_x = no / RowNum
+		if no%ColumnNum == 0 { // 如果 取余数为0 则 证明该数是能被  10 整除的数  为该行 最后一个孔位
+			box_y = ColumnNum
+			box_x = no / ColumnNum
 		} else {
-			box_y = no % RowNum
-			box_x = (no / RowNum) + 1
+			box_y = no % ColumnNum
+			box_x = (no / ColumnNum) + 1
 		}
 
 		glog.Info("管子在盒子中的位置坐标为:", box_y, ";", box_x)

+ 218 - 26
src/dashoo.cn/genepoint_srv/business/test/test_test.go

@@ -6,6 +6,7 @@ import (
 	"dashoo.cn/utils"
 	"encoding/json"
 	"fmt"
+	"time"
 
 	"strings"
 	"testing"
@@ -33,25 +34,224 @@ func  Test_Trim(t *testing.T) {
 
 
 	// 定义请求报文
-	var paymentData =`{"response":"tube_retrieving",
-"result":200,"time":"2020-12-16T08:59:00Z",
-"data":{"type":"accept","task_id":"559126787905298400_1608109140",
-"taskMsg":[{"cu":10,"model":"whole_rack","total":1,
-"list":[{"index":1,"rack":101,"rack_id":"GA00000623","tube":201,"tube_number":1}]},
-{"cu":11,"model":"whole_rack","total":1,
-"list":[{"index":1,"rack":101,"rack_id":"B20200803000508","tube":201,"tube_number":1}]}]}}`
+//	var paymentData =`{"response":"tube_retrieving",
+//"result":200,"time":"2020-12-16T08:59:00Z",
+//"data":{"type":"accept","task_id":"559126787905298400_1608109140",
+//"taskMsg":[{"cu":10,"model":"whole_rack","total":1,
+//"list":[{"index":1,"rack":101,"rack_id":"GA00000623","tube":201,"tube_number":1}]},
+//{"cu":11,"model":"whole_rack","total":1,
+//"list":[{"index":1,"rack":101,"rack_id":"B20200803000508","tube":201,"tube_number":1}]}]}}`
+	var paymentData =` {
+"response":"tube_retrieving",
+"result":200,
+"time":"2018-09-15T13:45:32Z",
+"data":{
+"type":"end",
+"task_id":"426466061139845100_1608100330",
+"is_end":true,
+"execution_time":52,
+"exceptions":[
+{
+"cu":1,
+"codes":[
+30305
+]
+}
+],
+"actual_data":[
+{
+"rack":101,
+"tube":201,
+"rack_id":"B20201221000002",
+"target":{
+"cu":1,
+"ltu":1,
+"group":1,
+"unit":1,
+"pos":1
+},
+"tubes":[
+{
+"no":1,
+"id":"559917887934963712",
+"exception":30305
+},
+{
+"no":2,
+"id":"560616560226476032",
+"exception":30305
+},
+{
+"no":6,
+"id":"560616561790951424",
+"exception":0
+},
+{
+"no":8,
+"id":"560913004158263296",
+"exception":0
+},
+{
+"no":9,
+"id":"560913305091186688",
+"exception":0
+}
+]
+}
+]
+}
+}`
+//var paymentData1 =` {
+//"response":"rack_storing",
+//"result":200,
+//"time":"2018-09-15T13:45:32Z",
+//"data":{
+//"type":"end",
+//"task_id":"426466061139845100_1608100330",
+//"is_end":false,
+//"execution_time":52,
+//"exceptions":[
+//{
+//"cu":2,
+//"codes":[
+//30305
+//]
+//}
+//],
+//"actual_data":[
+//{
+//"rack":101,
+//"tube":201,
+//"rack_id":"B20201215000208",
+//"target":{
+//"cu":1,
+//"ltu":1,
+//"group":1,
+//"unit":1,
+//"pos":1
+//},
+//"tubes":[
+//{
+//"no":1,
+//"id":"562431137612308481",
+//"exception":30305
+//},
+//{
+//"no":2,
+//"id":"562431137612308482",
+//"exception":30305
+//},
+//{
+//"no":4,
+//"id":"562431137612308483",
+//"exception":0
+//},
+//{
+//"no":7,
+//"id":"562431137612308484",
+//"exception":0
+//},
+//{
+//"no":5,
+//"id":"562431137612308485",
+//"exception":0
+//}
+//]
+//}
+//]
+//}
+//}`
+//var paymentData2 =` {
+//"response":"rack_storing",
+//"result":200,
+//"time":"2018-09-15T13:45:32Z",
+//"data":{
+//"type":"end",
+//"task_id":"426466061139845100_1608100330",
+//"is_end":true,
+//"execution_time":52,
+//"exceptions":[
+//{
+//"cu":3,
+//"codes":[
+//30305
+//]
+//}
+//],
+//"actual_data":[
+//{
+//"rack":101,
+//"tube":201,
+//"rack_id":"B20201215000209",
+//"target":{
+//"cu":1,
+//"ltu":1,
+//"group":1,
+//"unit":1,
+//"pos":1
+//},
+//"tubes":[
+//{
+//"no":2,
+//"id":"5624311376123084811",
+//"exception":30305
+//},
+//{
+//"no":8,
+//"id":"5624311376123084822",
+//"exception":30305
+//},
+//{
+//"no":16,
+//"id":"5624311376123084833",
+//"exception":0
+//},
+//{
+//"no":11,
+//"id":"5624311376123084844",
+//"exception":0
+//},
+//{
+//"no":12,
+//"id":"5624311376123084855",
+//"exception":0
+//}
+//]
+//}
+//]
+//}
+//}`
+
+var str  [1]string
+
+str[0] =paymentData
+//str[1] =paymentData1
+//str[2] =paymentData2
+
+
+
+
+
+
+
+
+
+for i:=range str{
+	fmt.Println("当前时间1",time.Now())
+	time.Sleep(10000)
+	fmt.Println("当前时间2",time.Now())
 
 
 	// 报文转换为本系统可读
 	var res converse.ResponseEntity
-	json.Unmarshal([]byte(paymentData), &res)
+	json.Unmarshal([]byte(str[i]), &res)
 
 	fmt.Println("res:",res)
 
 	var  message []byte
 
-	message,_ = json.Marshal(&paymentData)
-	fmt.Println("paymentData;",paymentData)
+	message,_ = json.Marshal(&str[i])
+	fmt.Println("paymentData;",str[i])
 	json.Unmarshal(message, &res)
 
 	fmt.Println("message:",message)
@@ -102,17 +302,7 @@ func  Test_Trim(t *testing.T) {
 			svc := converse.GetConverseService(utils.DBE)
 			svc.ModifySampleStatusByApplyMainInfo(taskId, resp, res)
 			//this.SampleAllStatusModify(res,SUCCESS)
-		} else if taskType == "abnormal_end" {
-			if isEnd {
-				fmt.Println("----------修改失败状态----------")
-				//保存异常信息
-				controller.SaveExcepMsg(res, taskId)
-				err = controller.StatusModify(FAILED, taskId)
-			}
-			svc := converse.GetConverseService(utils.DBE)
-			svc.ModifySampleStatusByApplyMainInfo(taskId, resp, res)
-			//this.SamplePartsStatusModify(res)
-		} else if taskType == "task_activate" {
+		}   else if taskType == "task_activate" {
 			fmt.Println(">>>>>>>>>>修改激活状态>>>>>>>>>>")
 			if res.Data.Status == 3 {
 				err = controller.StatusModify(REJECT, taskId)
@@ -126,14 +316,11 @@ func  Test_Trim(t *testing.T) {
 			fmt.Println(">>>>>>>>>>修改执行中状态>>>>>>>>>>")
 			err = controller.StatusModify(RUNNING, taskId)
 		}
-	} else if result == 300 && taskType == "reject" {
-		fmt.Println("----------修改失败状态----------")
+	}  else if result == 300 && taskType == "reject" {
+		fmt.Println("----------任务[" + taskId + "]任务拒绝----------")
 		//保存异常信息
 		controller.SaveExcepMsg(res, taskId)
 		err = controller.StatusModify(REJECT, taskId)
-		//this.SampleAllStatusModify(res,REJECT)
-		svc := converse.GetConverseService(utils.DBE)
-		svc.ModifySampleAllRejectStatus(res)
 	}
 
 	if err != nil {
@@ -141,4 +328,9 @@ func  Test_Trim(t *testing.T) {
 	}
 
 
+
+}
+
+
+
 }