Przeglądaj źródła

update:查询任务信息frpc切换为直连

zoie 1 miesiąc temu
rodzic
commit
352aa52ef2

+ 4 - 6
Nats/Nats.go

@@ -46,15 +46,15 @@ func ReconnectNATS() {
 	var err error
 	for {
 		time.Sleep(1 * time.Minute)
-		//time.Sleep(1 * time.Minute)
 
 		if (lib.Nats != nil && !lib.Nats.IsConnected()) || lib.Nats == nil {
 			lib.Nats, err = nats.Connect("nats://" + conf.NatsServer_Url)
 			if err != nil {
 				logs.Println("无法重新连接到 NATS:", err)
 				continue
+			} else {
+				logs.Println("成功重新连接到 NATS...")
 			}
-			logs.Println("成功重新连接到 NATS...")
 		}
 	}
 
@@ -85,7 +85,7 @@ func NatsInit() {
 		}
 		T_uuid, T_task_id := t_r.T_uuid, t_r.T_task_id
 
-		Task_r, err := NatsServer.Read_Task(T_task_id)
+		Task_r, err := Task.Read_Task(T_task_id)
 		if err != nil {
 			logs.Error(lib.FuncName(), err)
 			return
@@ -217,8 +217,6 @@ func NatsInit() {
 			i++
 		}
 
-
-
 		logs.Info("--------开始导入数据到【线上】---------")
 		j := 0
 		flag := false
@@ -284,7 +282,7 @@ func NatsInit() {
 		T_uuid := "9b6b9f9d-f8f2-46fb-82c8-101d4a309c34"
 		T_task_id := string(m.Data)
 
-		Task_r, err := NatsServer.Read_Task(T_task_id)
+		Task_r, err := Task.Read_Task(T_task_id)
 		if err != nil {
 			logs.Error(lib.FuncName(), err)
 			return

+ 3 - 1
Nats/NatsServer/NatsServer.go

@@ -49,11 +49,13 @@ func Read_Task(T_task_id string) (task Task.Task, err error) {
 	//logs.Println("Nats =>", lib.FuncName(), T_task_id)
 
 	if lib.Nats == nil || !lib.Nats.IsConnected() {
+
 		lib.Nats, err = nats.Connect("nats://" + conf.NatsServer_Url)
 		if err != nil {
 			logs.Println("无法重新连接到 NATS:", err)
+		} else {
+			logs.Println("成功重新连接到 NATS...")
 		}
-		logs.Println("成功重新连接到 NATS...")
 	}
 
 	msg, err := lib.Nats.Request("ColdVerify_Server_Read_Task", []byte(T_task_id), 3*time.Second)

+ 3 - 4
conf/app.conf

@@ -19,10 +19,9 @@ Redis_dbNum = "2"
 # Mysql 本地
 Local_AliasName = "default"
 MysqlServer_UrlPort = "192.168.11.23:3306"
-# MysqlServer_UrlPort = "111.85.177.202:13306"
-MysqlServer_Database = "coldverify_local"
-MysqlServer_Username = "coldverify_local"
-MysqlServer_Password = "hmZbXNWdpXKB3K8x"
+MysqlServer_Database = "coldverify"
+MysqlServer_Username = "coldverify"
+MysqlServer_Password = "Bd3d34yJ7aibiEi!"
 MysqlServer_MaxIdleConnections = 100
 MysqlServer_MaxOpenConnections = 200
 

+ 71 - 74
controllers/TaskData.go

@@ -52,9 +52,9 @@ func (c *TaskDataController) TaskData_List() {
 	T_id := c.GetString("T_id")
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -124,9 +124,9 @@ func (c *TaskDataController) TaskData_Pdf(Time_start, Time_end, T_task_id, T_sni
 	Time_start_b := Time_start
 	Time_end_b := Time_end
 
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		return errors.New("T_task_id 错误!")
+		return errors.New("获取任务信息失败!")
 	}
 	if Task_r.T_collection_state == 2 {
 		return errors.New("数据采集中,请稍后!")
@@ -488,9 +488,9 @@ func (c *TaskDataController) TaskDataClass_List() {
 		page_z = conf.Page_size
 	}
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -513,9 +513,9 @@ func (c *TaskDataController) TaskDataClass_Edit() {
 	T_task_id := c.GetString("T_task_id")
 	T_sn := c.GetString("T_sn")
 	T_id := c.GetString("T_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -556,9 +556,9 @@ func (c *TaskDataController) TaskDataClass_Del() {
 
 	T_task_id := c.GetString("T_task_id")
 	T_sn := c.GetString("T_sn")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -583,9 +583,9 @@ func (c *TaskDataController) TaskData_AddS() {
 	T_uuid, _ := lib.GetAdminT_Uuid(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -603,7 +603,7 @@ func (c *TaskDataController) TaskData_AddS() {
 	println(len(T_Data_list), "len(T_Data_list)")
 	var T_Data_list_x = 0
 
-	Task.UpdateAUTO_INCREMENT(conf.Local_AliasName,Task_r.T_task_id)
+	Task.UpdateAUTO_INCREMENT(conf.Local_AliasName, Task_r.T_task_id)
 
 	snMaps := make(map[string]string)
 
@@ -684,13 +684,13 @@ func (c *TaskDataController) TaskData_AddS_Excel() {
 	T_uuid, _ := lib.GetAdminT_Uuid(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
-	Task.UpdateAUTO_INCREMENT(conf.Local_AliasName,Task_r.T_task_id)
+	Task.UpdateAUTO_INCREMENT(conf.Local_AliasName, Task_r.T_task_id)
 
 	// 获取上传的文件
 	file, _, err := c.GetFile("file")
@@ -844,13 +844,13 @@ func (c *TaskDataController) TaskData_Add() {
 	}
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
-	Task.UpdateAUTO_INCREMENT(conf.Local_AliasName,Task_r.T_task_id)
+	Task.UpdateAUTO_INCREMENT(conf.Local_AliasName, Task_r.T_task_id)
 
 	sn, err := Task.Read_TaskData_ByT_id(Task_r.T_task_id, T_id)
 	if err != nil && !errors.Is(err, orm.ErrNoRows) {
@@ -923,9 +923,9 @@ func (c *TaskDataController) TaskData_Up() {
 	T_time := c.GetString("T_time")
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -957,9 +957,9 @@ func (c *TaskDataController) TaskData_Del() {
 	}
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -985,9 +985,9 @@ func (c *TaskDataController) TaskData_Del_t_id() {
 	Id := c.GetString("Id")
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -1018,9 +1018,9 @@ func (c *TaskDataController) Export_Data_Excel() {
 	//}
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -1092,14 +1092,14 @@ func (c *TaskDataController) Export_Data_Excel() {
 
 func (c *TaskDataController) Check() {
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if Task_r.T_collection_state == 2 {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "数据采集中,请稍后!"}
 		c.ServeJSON()
 		return
 	}
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -1184,14 +1184,14 @@ func (c *TaskDataController) Check() {
 
 func (c *TaskDataController) Check_Asyn() {
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if Task_r.T_collection_state == 2 {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "数据采集中,请稍后!"}
 		c.ServeJSON()
 		return
 	}
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -1305,9 +1305,9 @@ func (c *TaskDataController) TaskData_Import_TaskData() {
 	T_uuid, _ := lib.GetAdminT_Uuid(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
 
 	T_task_id := c.GetString("T_task_id")
-	_, err := NatsServer.Read_Task(T_task_id)
+	_, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -1362,9 +1362,9 @@ func (c *TaskDataController) TaskData_Up_TaskData() {
 
 	T_task_id := c.GetString("T_task_id")
 
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -1430,9 +1430,9 @@ func (c *TaskDataController) TaskData_Up_TaskData_Back() {
 
 	T_task_id := c.GetString("T_task_id")
 
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -1450,7 +1450,6 @@ func (c *TaskDataController) TaskData_Up_TaskData_Back() {
 		return
 	}
 
-
 	// 采集中
 	Task_r.T_delivery_state = 2
 	err = NatsServer.Update_Task(Task_r)
@@ -1460,8 +1459,6 @@ func (c *TaskDataController) TaskData_Up_TaskData_Back() {
 		return
 	}
 
-
-
 	data := Nats.Up_TaskData_Back{
 		T_uuid: T_uuid,
 		Task:   Task_r,
@@ -1511,9 +1508,9 @@ func (c *TaskDataController) CopyFromPosition() {
 	SN_List := strings.Split(strings.Trim(c.GetString("SN_List"), "|"), "|")
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -1575,9 +1572,9 @@ func (c *TaskDataController) RepairSensorData() {
 	SN_List := strings.Split(strings.Trim(c.GetString("SN_List"), "|"), "|")
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -1665,9 +1662,9 @@ func (c *TaskDataController) DataSensorDataTrend() {
 	SN_List := strings.Split(strings.Trim(c.GetString("SN_List"), "|"), "|")
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -1754,9 +1751,9 @@ func (c *TaskDataController) UpdateRand() {
 	SN_List := strings.Split(strings.Trim(c.GetString("SN_List"), "|"), "|")
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -1813,9 +1810,9 @@ func (c *TaskDataController) UpdateFix() {
 	SN_List := strings.Split(strings.Trim(c.GetString("SN_List"), "|"), "|")
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -1869,9 +1866,9 @@ func (c *TaskDataController) DataSensorDataSmooth() {
 	SN_List := strings.Split(strings.Trim(c.GetString("SN_List"), "|"), "|")
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -1968,9 +1965,9 @@ func (c *TaskDataController) CopyFromPositionAverageSN() {
 		return
 	}
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -2078,9 +2075,9 @@ func (c *TaskDataController) CopyFromPositionSN() {
 		return
 	}
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -2122,9 +2119,9 @@ func (c *TaskDataController) DataRemoveDuplicates() {
 	T_uuid, _ := lib.GetAdminT_Uuid(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -2178,9 +2175,9 @@ func (c *TaskDataController) DataSkewingInterval() {
 	SN_List := strings.Split(strings.Trim(c.GetString("SN_List"), "|"), "|")
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -2269,9 +2266,9 @@ func (c *TaskDataController) DataGeometricScale() {
 	SN_List := strings.Split(strings.Trim(c.GetString("SN_List"), "|"), "|")
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -2330,9 +2327,9 @@ func (c *TaskDataController) DataBatchDelete() {
 	SN_List := strings.Split(strings.Trim(c.GetString("SN_List"), "|"), "|")
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -2372,9 +2369,9 @@ func (c *TaskDataController) TaskDataCopy_List() {
 	}
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -2402,9 +2399,9 @@ func (c *TaskDataController) TaskDataCopy_List() {
 func (c *TaskDataController) TaskDataCopy_Add() {
 
 	T_task_id := c.GetString("T_task_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -2465,9 +2462,9 @@ func (c *TaskDataController) TaskDataCopy_Del() {
 func (c *TaskDataController) TaskDataCopy_Recover() {
 	T_task_id := c.GetString("T_task_id")
 	T_copy_id := c.GetString("T_copy_id")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -2537,9 +2534,9 @@ func (c *TaskDataController) TaskData_JPG() {
 
 	T_task_id := c.GetString("T_task_id")
 	SN_List := c.GetString("SN_List")
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}
@@ -2703,9 +2700,9 @@ func (c *TaskDataController) Certificate_List() {
 	if page_z < 1 {
 		page_z = conf.Page_size
 	}
-	Task_r, err := NatsServer.Read_Task(T_task_id)
+	Task_r, err := Task.Read_Task(T_task_id)
 	if err != nil {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取任务信息失败!"}
 		c.ServeJSON()
 		return
 	}

+ 75 - 3
models/Task/Task.go

@@ -1,6 +1,13 @@
 package Task
 
 import (
+	"ColdVerify_local/conf"
+	"ColdVerify_local/lib"
+	"ColdVerify_local/logs"
+	"encoding/json"
+	"fmt"
+	"github.com/astaxie/beego/cache"
+	orm2 "github.com/beego/beego/v2/client/orm"
 	_ "github.com/go-sql-driver/mysql"
 	"time"
 )
@@ -9,6 +16,7 @@ import (
 type Task struct {
 	Id                     int    `orm:"column(ID);size(11);auto;pk"`
 	T_class                int    `orm:"size(200);default(0)"` // 分类id
+	T_InfoCollection_id    string `orm:"size(256);null"`       // 信息采集ID
 	T_task_id              string `orm:"size(256);null"`       // 任务ID
 	T_uuid                 string `orm:"size(256);null"`       // 用户 UUID
 	T_name                 string `orm:"size(256);null"`       // 标题
@@ -23,6 +31,7 @@ type Task struct {
 	T_collection_state     int    `orm:"size(2);default(0)"`   // 数据采集 状态 0 未完成 1 数据来源已完成 2 处理中 3 已采集-无数据 4-数据编辑已完成
 	T_reporting_state      int    `orm:"size(2);default(0)"`   // 报告编写 状态 0 未完成 1 已完成
 	T_delivery_state       int    `orm:"size(2);default(0)"`   // 交付审核 状态 0 未完成 1 已完成 2 处理中
+	T_marking_state        int    `orm:"size(2);default(0)"`   // 验证标识 状态 0 未完成 1 已完成
 
 	T_VerifyDeviceDataStartTime string `orm:"size(256);null"` // 验证设备数据开始时间
 	T_VerifyDeviceDataEndTime   string `orm:"size(256);null"` // 验证设备数据开始时间
@@ -35,10 +44,73 @@ type Task struct {
 	T_pdf2 string `orm:"type(text);null"` // 报告
 	T_doc3 string `orm:"type(text);null"` // 证书
 	T_pdf3 string `orm:"type(text);null"` // 证书
+	T_pdf4 string `orm:"type(text);null"` // 验证标识
+
+	T_Show  int `orm:"size(2);default(1)"`   // 0 隐藏   1 公开
+	T_Visit int `orm:"size(200);default(0)"` // 浏览量
+	T_State int `orm:"size(2);default(1)"`   // 0 删除   1 正常
+
+	T_step int `orm:"size(2);default(-1)"` // 验证步骤
+
+	T_sn                        string `orm:"size(256);null"` // sn
+	T_CalibrationExpirationTime string `orm:"size(256);null"` // 校准到期时间
 
-	T_Show     int       `orm:"size(2);default(1)"`                                    // 0 隐藏   1 公开
-	T_Visit    int       `orm:"size(200);default(0)"`                                  // 浏览量
-	T_State    int       `orm:"size(2);default(1)"`                                    // 0 删除   1 正常
 	CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"` //auto_now_add 第一次保存时才设置时间
 	UpdateTime time.Time `orm:"column(update_time);type(timestamp);null;auto_now"`     //auto_now 每次 model 保存时都会对时间自动更新
 }
+
+var redisCache_Task cache.Cache
+
+func init() {
+	orm2.RegisterModel(new(Task))
+	config := fmt.Sprintf(`{"key":"%s","conn":"%s","dbNum":"%s","password":"%s"}`,
+		"redis_"+"Task", conf.Redis_address, conf.Redis_dbNum, conf.Redis_password)
+	logs.Println(config)
+	var err error
+	redisCache_Task, err = cache.NewCache("redis", config)
+	if err != nil || redisCache_Task == nil {
+		errMsg := "failed to init redis"
+		logs.Println(errMsg, err)
+	}
+}
+
+func Redis_Task_Get(key string) (r Task, is bool) {
+	if redisCache_Task.IsExist(key) {
+		logs.Println("找到key:", key)
+		v := redisCache_Task.Get(key)
+		json.Unmarshal(v.([]byte), &r)
+		return r, true
+	}
+	logs.Println("没有 找到key:", key)
+	return Task{}, false
+}
+func Redis_Task_Set(key string, r Task) (err error) {
+	//json序列化
+	str, err := json.Marshal(r)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+		return
+	}
+	err = redisCache_Task.Put(key, str, 24*time.Hour)
+	if err != nil {
+		logs.Println("set key:", key, ",value:", str, err)
+	}
+	return
+}
+func Read_Task(T_task_id string) (r Task, err error) {
+	if task, is := Redis_Task_Get(T_task_id); is == true {
+		return task, nil
+	}
+
+	serverOrm := orm2.NewOrmUsingDB(conf.Server_AliasName)
+
+	qs := serverOrm.QueryTable(new(Task))
+	//err := qs.Filter("T_task_id", T_task_id).Filter("T_State", 1).One(&r)
+	err = qs.Filter("T_task_id", T_task_id).Filter("T_State", 1).One(&r)
+	if err != nil {
+		return r, err
+	}
+
+	Redis_Task_Set(T_task_id, r)
+	return r, nil
+}

+ 1 - 1
models/Task/TaskCopy.go

@@ -50,7 +50,7 @@ type TaskCopy struct {
 	UpdateTime time.Time `orm:"column(update_time);type(timestamp);null;auto_now"`     //auto_now 每次 model 保存时都会对时间自动更新
 }
 
-func (t *Task) TableName() string {
+func (t *TaskCopy) TableName() string {
 	return "task_copy" // 数据库名称   // ************** 替换 FormulaList **************
 }