|
|
@@ -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) {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|