فهرست منبع

测试任务模块功能

liling 1 سال پیش
والد
کامیت
29f8015120

+ 1 - 1
service/conf/app.conf

@@ -3,7 +3,7 @@ appid=scd_check_tools
 copyrequestbody = true
 appport=9527
 runmode=dev
-unittest=false
+unittest=true
 loglevel=5
 interval=5
 noauthrouter=/api/*,/api/getversion,/api/logout,/api/login,receive_service,/api/uploadfile,/api/version/*,/api/ws/getconnect,/api/qui/getelestatusrealtime

+ 3 - 4
service/conf/mysql-dev.cnf

@@ -1,9 +1,8 @@
 {
-	"host":"127.0.0.1",
+	"host":"47.103.17.219",
 	"port":"3306",
-	"dbname":"scd",
+	"dbname":"scd_check_tools",
 	"user":"root",
-	"pwd":"ljy20080511",
+	"pwd":"Ljy@20080511",
 	"charset":""
 }
-

+ 1 - 1
service/conf/mysql-prod.cnf

@@ -1,7 +1,7 @@
 {
 	"host":"47.103.17.219",
 	"port":"3306",
-	"dbname":"new_scd",
+	"dbname":"scd_check_tools",
 	"user":"root",
 	"pwd":"Ljy@20080511",
 	"charset":""

+ 4 - 4
service/controllers/wsController.go

@@ -11,10 +11,10 @@
 package controllers
 
 import (
-	"scd_check_tools/conf"
-	"scd_check_tools/models"
 	"fmt"
 	"log"
+	"scd_check_tools/conf"
+	"scd_check_tools/tools"
 )
 
 type WsController struct {
@@ -51,7 +51,7 @@ func (c *WsController) GetWsConnect() {
 	appKey := conf.GlobalConfig["appkey"]
 	appSecret := conf.GlobalConfig["appsecret"]
 	fss := fmt.Sprintf("{\"appKey\":\"%s\",\"appSecret\":\"%s\"}", appKey, appSecret)
-	res, err := models.PostJson(token_url, fss)
+	res, err := tools.PostJson(token_url, fss)
 	if err != nil {
 		log.Println(err)
 		c.Data["json"] = c.ResultError("获取电梯平台的token出错!")
@@ -75,7 +75,7 @@ func (c *WsController) GetWsConnect() {
 		accessToken = resTmp2["accessToken"]
 		get_ws_url = get_ws_url + accessToken.(string)
 	}
-	wsRes, err := models.PostJson(get_ws_url, "{}")
+	wsRes, err := tools.PostJson(get_ws_url, "{}")
 	if wsRes == nil || err != nil {
 		log.Println(err)
 		c.Data["json"] = c.ResultError("获取电梯平台的wsurl出错!")

+ 1 - 1
service/lastupdate.tmp

@@ -1 +1 @@
-{"G:\\工作目录\\ME\\GoProject\\src\\scd_check_tools\\controllers":1696930180791304100,"G:\\工作目录\\ME\\GoProject\\src\\scd_check_tools\\upgrade":1696478096045316200}
+{"G:\\工作目录\\ME\\GoProject\\src\\scd_check_tools\\controllers":1697012970168849700,"G:\\工作目录\\ME\\GoProject\\src\\scd_check_tools\\upgrade":1697010325409069900}

+ 3 - 3
service/main.go

@@ -104,7 +104,7 @@ func main() {
 	go mqtt.Start()
 	if runmode == "dev" {
 		//自动生成接口权限定义
-		//new(ApiDoc).Run()
+		new(ApiDoc).Run()
 	}
 	new(ApiDoc).CacheApiDoc()
 	bo.LoadSysParam()
@@ -398,6 +398,6 @@ var AuthFilter = func(ctx *context.Context) {
 		}
 		return
 	}
-	//10秒过期的随机数
-	global.GoCahce.Set(nonce, nonce, 10*time.Second)
+	//3秒过期的随机数
+	global.GoCahce.Set(nonce, nonce, 3*time.Second)
 }

+ 7 - 6
service/models/bo/scd_file_parse.go

@@ -729,6 +729,9 @@ func (c *ScdParse) XmlIEDParse(stationid, scdPath, scdName string) (scdid string
 			scdPath = "." + fline + scdPath
 		}
 	}
+	data := map[string]string{"name": scdName, "stationid": stationid, "rootid": "", "state": "0", "node": "load-file", "msg": ""}
+	dataMsg, _ := json.Marshal(data)
+	mqtt.PublishMessage(fmt.Sprintf("/jujutong/scd_check_tools/parse/%s", stationid), string(dataMsg))
 	//判断该scd是否已经存在,已存在则不再解析
 	db := orm.NewOrm()
 	sql := "select id from t_scd_scl where scd_name=? and path=?"
@@ -738,6 +741,9 @@ func (c *ScdParse) XmlIEDParse(stationid, scdPath, scdName string) (scdid string
 		scdid = tools.IsEmpty(rowset[0]["id"])
 		if _, h := global.GoCahce.Get(scdid); h {
 			//已经解析到内存中,则不再解析
+			data := map[string]string{"name": scdName, "stationid": stationid, "rootid": "", "state": "1", "node": "load-file", "msg": ""}
+			dataMsg, _ := json.Marshal(data)
+			mqtt.PublishMessage(fmt.Sprintf("/jujutong/scd_check_tools/parse/%s", stationid), string(dataMsg))
 			return scdid, nil
 		} else {
 			//判断是否有解析完成的持久化文件
@@ -746,9 +752,6 @@ func (c *ScdParse) XmlIEDParse(stationid, scdPath, scdName string) (scdid string
 			logger.Logger.Debug(fmt.Sprintf("%s:%+v ====== %+v", parsedFile, f, err))
 			if f != nil || os.IsExist(err) {
 				logger.Logger.Debug("=====结果文件" + scdPath + ".parsed.xml已存在,直接加载")
-				data := map[string]string{"name": scdName, "stationid": stationid, "rootid": "", "state": "0", "node": "load-file", "msg": ""}
-				dataMsg, _ := json.Marshal(data)
-				mqtt.PublishMessage(fmt.Sprintf("/jujutong/scd_check_tools/parse/%s", stationid), string(dataMsg))
 				sclNodeObj, err := c.LoadScdXml(scdPath + ".parsed.xml")
 				if err == nil {
 					global.GoCahce.Set(scdPath, scdid, -1)
@@ -775,12 +778,10 @@ func (c *ScdParse) XmlIEDParse(stationid, scdPath, scdName string) (scdid string
 	//判断当前服务器性能是否达到阀值
 	canparse, msg := new(ScdMgr).CheckParseMaxLimit()
 	if canparse {
+		mqtt.PublishMessage(fmt.Sprintf("/jujutong/scd_check_tools/parse/%s/%d/error", stationid, 0), "系统繁忙:"+msg+",请稍候(约5分钟)再试")
 		return "", errors.New("系统繁忙:" + msg + ",请稍候(约5分钟)再试")
 	}
 	logger.Logger.Debug(fmt.Sprintf("=======开始加载解析SCD:%s", scdName))
-	data := map[string]string{"name": scdName, "stationid": stationid, "rootid": "", "state": "0", "node": "load-file", "msg": ""}
-	dataMsg, _ := json.Marshal(data)
-	mqtt.PublishMessage(fmt.Sprintf("/jujutong/scd_check_tools/parse/%s", stationid), string(dataMsg))
 	//新解析scd,先进行文件格式化。搞成一行一行的
 	node_cnt, err2 := c.ForamtScdPath(scdPath)
 	if err2 != nil {

+ 0 - 327
service/models/edgexCall.go

@@ -1,327 +0,0 @@
-package models
-
-import (
-	"bytes"
-	"encoding/json"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"mime/multipart"
-	"net"
-	"net/http"
-	"net/url"
-	"os"
-	"strconv"
-	"strings"
-	"time"
-)
-
-func Get(url string, authinfo ...string) (interface{}, error) {
-	timeout := time.Duration(5 * time.Second)
-	client := &http.Client{Timeout: timeout}
-	req, reqerr := http.NewRequest("GET", url, nil)
-	if reqerr != nil {
-		fmt.Println(url)
-		return nil, reqerr
-	}
-	if len(authinfo) > 0 && authinfo[0] != "" {
-		req.Header.Set("Authorization", authinfo[0])
-	}
-	result, httperr := client.Do(req)
-	//defer result.Body.Close()
-	if httperr != nil {
-		fmt.Println(url)
-		return nil, httperr
-	}
-	body, err := ioutil.ReadAll(result.Body)
-	if err != nil {
-		return nil, err
-	}
-	result.Close = true
-	return returnBody(body)
-}
-
-func Post(url string, data interface{}, authinfo ...string) (interface{}, error) {
-	timeout := time.Duration(5 * time.Second)
-	client := &http.Client{Timeout: timeout}
-	req, reqerr := http.NewRequest("POST", url, strings.NewReader(data.(string)))
-	if reqerr != nil {
-		return nil, reqerr
-	}
-	if len(authinfo) > 0 && authinfo[0] != "" {
-		req.Header.Set("Authorization", authinfo[0])
-		//req.Header.Set("Content-Type", "application/json;charset=utf-8")
-	}
-	req.Header.Set("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")
-
-	result, httperr := client.Do(req)
-	//defer result.Body.Close()
-	if httperr != nil {
-		fmt.Println(url)
-		fmt.Println(data)
-		return nil, httperr
-	}
-	body, err := ioutil.ReadAll(result.Body)
-	if err != nil {
-		return nil, err
-	}
-	result.Close = true
-	return returnBody(body)
-}
-
-func PostJson(url string, data interface{}, authinfo ...string) (interface{}, error) {
-	timeout := time.Duration(5 * time.Second)
-	client := &http.Client{Timeout: timeout}
-	req, reqerr := http.NewRequest("POST", url, strings.NewReader(data.(string)))
-	if reqerr != nil {
-		fmt.Println(url)
-		fmt.Println(data)
-		return nil, reqerr
-	}
-	if len(authinfo) > 0 && authinfo[0] != "" {
-		req.Header.Set("Authorization", authinfo[0])
-		//
-	}
-	req.Header.Set("Content-Type", "application/json;charset=utf-8")
-
-	result, httperr := client.Do(req)
-	//defer result.Body.Close()
-	if httperr != nil {
-		fmt.Println(url)
-		fmt.Println(data)
-		return nil, httperr
-	}
-	body, err := ioutil.ReadAll(result.Body)
-	if err != nil {
-		return nil, err
-	}
-	result.Close = true
-	return returnBody(body)
-}
-
-func PostRaw(url string, data interface{}) (interface{}, error) {
-	result, httperr := http.Post(url, "text/plain;charset=utf-8", strings.NewReader(data.(string)))
-	if httperr != nil {
-		fmt.Println(url)
-		fmt.Println(data)
-		return nil, httperr
-	}
-	body, err := ioutil.ReadAll(result.Body)
-	if err != nil {
-		return nil, err
-	}
-	result.Close = true
-	return returnBody(body)
-}
-
-func PostForm(url string, data url.Values, authinfo ...string) (interface{}, error) {
-	timeout := time.Duration(5 * time.Second)
-	client := &http.Client{Timeout: timeout}
-	req, reqerr := http.NewRequest("POST", url, strings.NewReader(data.Encode()))
-	if reqerr != nil {
-		fmt.Println(url)
-		fmt.Println(data)
-		return nil, reqerr
-	}
-	if len(authinfo) > 0 && authinfo[0] != "" {
-		req.Header.Set("Authorization", authinfo[0])
-	}
-	req.Header.Set("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")
-	result, httperr := client.Do(req)
-	//defer result.Body.Close()
-	if httperr != nil {
-		fmt.Println(url)
-		fmt.Println(data)
-		return nil, httperr
-	}
-	body, err := ioutil.ReadAll(result.Body)
-	if err != nil {
-		return nil, err
-	}
-	result.Close = true
-	return returnBody(body)
-}
-
-func PostRawBasicAuth(url string, data interface{}, user string, pwd string) (interface{}, error) {
-	client := http.Client{
-		Transport: &http.Transport{
-			Dial: func(netw, addr string) (net.Conn, error) {
-				c, err := net.DialTimeout(netw, addr, time.Second*5)
-				if err != nil {
-					fmt.Println("dail timeout", err)
-					return nil, err
-				}
-				return c, nil
-
-			},
-			MaxIdleConnsPerHost:   10,
-			ResponseHeaderTimeout: time.Second * 5,
-		},
-	}
-	req, _ := http.NewRequest("POST", url, strings.NewReader(data.(string)))
-	req.SetBasicAuth(user, pwd)
-	req.Header.Set("Content-Type", "text/plain;charset=utf-8")
-	result, httperr := client.Do(req)
-	//result, httperr := http.Post(url, "text/plain;charset=utf-8", strings.NewReader(data.(string)))
-	if httperr != nil {
-		fmt.Println(url)
-		fmt.Println(data)
-		return nil, httperr
-	}
-	body, err := ioutil.ReadAll(result.Body)
-	if err != nil {
-		return nil, err
-	}
-	result.Close = true
-	return returnBody(body)
-}
-
-func Put(url string, data interface{}) (interface{}, error) {
-	req, httperr := http.NewRequest("PUT", url, strings.NewReader(data.(string)))
-	if httperr != nil {
-		return nil, httperr
-	}
-	res, httperr := http.DefaultClient.Do(req)
-	if httperr != nil {
-		return nil, httperr
-	}
-	body, err := ioutil.ReadAll(res.Body)
-	if err != nil {
-		return nil, err
-	}
-	res.Close = true
-	return returnBody(body)
-}
-
-func Delete(url string) (interface{}, error) {
-	req, httperr := http.NewRequest("DELETE", url, nil)
-	//req.Header.Add("Authorization", "5F6MJ3N2Tk9ruL_6XQpx-uxkkg:o56-nIwtgTzUX80YCNpbcjUL8iM=:eyJyZXNvdXJjZSI6IF9mbG93RGF0YVNvdXJjZTEiLCJleHBpcmVzIjoxNTM2NzU4ODE2LCJjb250ZW50TUQ1IjoiIiwiY29udGVudFR5cGUiOiIiLCJoZWFkZXJzIjoiIiwibWV0aG9kIjoiREVMRVRFIn0=")
-	if httperr != nil {
-		return nil, httperr
-	}
-	res, httperr := http.DefaultClient.Do(req)
-	if httperr != nil {
-		return nil, httperr
-	}
-	body, httperr := ioutil.ReadAll(res.Body)
-	if httperr != nil {
-		return nil, httperr
-	}
-	res.Close = true
-	return returnBody(body)
-}
-
-func PostFile(targetUrl string, filename string, filed string) (interface{}, error) {
-	bodyBuf := &bytes.Buffer{}
-	bodyWriter := multipart.NewWriter(bodyBuf)
-
-	//关键的一步操作
-	fileWriter, err := bodyWriter.CreateFormFile(filed, filename)
-	if err != nil {
-		fmt.Println("error writing to buffer")
-		return nil, err
-	}
-
-	//打开文件句柄操作
-	fh, err := os.Open(filename)
-	if err != nil {
-		fmt.Println("error opening file")
-		return nil, err
-	}
-	defer fh.Close()
-
-	//iocopy
-	_, err = io.Copy(fileWriter, fh)
-	if err != nil {
-		return nil, err
-	}
-
-	contentType := bodyWriter.FormDataContentType()
-	bodyWriter.Close()
-
-	resp, err := http.Post(targetUrl, contentType, bodyBuf)
-	if err != nil {
-		return nil, err
-	}
-	body, err := ioutil.ReadAll(resp.Body)
-	if err != nil {
-		return nil, err
-	}
-	resp.Close = true
-	return returnBody(body)
-}
-
-func Soap11(url string, databody string) (interface{}, error) {
-	reqBody := `<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
-	  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
-	  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
-	  <soap:Body>` + databody + `</soap:Body> 
-	</soap:Envelope>`
-
-	res, err := http.Post(url, "text/xml; charset=UTF-8", strings.NewReader(reqBody))
-	if nil != err {
-		fmt.Println("http post err:", err)
-		return nil, err
-	}
-	defer res.Body.Close()
-
-	// return status
-	if http.StatusOK != res.StatusCode {
-		fmt.Println("WebService soap1.1 request fail, status: %s\n", res.StatusCode)
-		return strconv.Itoa(http.StatusOK), nil
-	}
-
-	data, err := ioutil.ReadAll(res.Body)
-	if nil != err {
-		fmt.Println("ioutil ReadAll err:", err)
-		return nil, err
-	}
-	return string(data), nil
-}
-
-func Soap12(url string, databody string) (interface{}, error) {
-	reqBody := `<?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
-	  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
-	  xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
-	  <soap12:Body>` + databody + `</soap12:Body> 
-	</soap12:Envelope>`
-
-	res, err := http.Post(url, "application/soap+xml; charset=UTF-8", strings.NewReader(reqBody))
-	if nil != err {
-		fmt.Println("http post err:", err)
-		return nil, err
-	}
-	defer res.Body.Close()
-
-	// return status
-	if http.StatusOK != res.StatusCode {
-		fmt.Println("WebService soap1.1 request fail, status: %s\n", res.StatusCode)
-		return strconv.Itoa(http.StatusOK), nil
-	}
-
-	data, err := ioutil.ReadAll(res.Body)
-	if nil != err {
-		fmt.Println("ioutil ReadAll err:", err)
-		return nil, err
-	}
-	return string(data), nil
-}
-
-func returnBody(body []byte) (interface{}, error) {
-	if len(body) == 0 {
-		return "", nil
-	}
-	jsonStr := string(body)
-	firstChar := jsonStr[0:1]
-	if firstChar == "[" || firstChar == "{" {
-		jsondata := make(map[string]interface{})
-		newStr := `{"a":` + jsonStr + `}`
-		err := json.Unmarshal([]byte(newStr), &jsondata)
-		if err != nil {
-			return jsonStr, err
-		}
-		return jsondata["a"], nil
-	} else {
-		return jsonStr, nil
-	}
-}

+ 70 - 1
service/static/swagger/swagger.json

@@ -4618,6 +4618,36 @@
                 "summary": "初始化系统数据"
             }
         },
+        "/task/delete": {
+            "post": {
+                "tags": [
+                    "scd_check_tools/controllersTaskController"
+                ],
+                "summary": "删除指定的检测任务",
+                "description": "删除指定的检测任务",
+                "parameters": [
+                    {
+                        "in": "formData",
+                        "name": "id",
+                        "description": "检测任务ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "成功",
+                        "schema": {
+                            "$ref": "#/definitions/ResultOK"
+                        }
+                    },
+                    "500": {
+                        "description": "{object} ResultError  失败"
+                    }
+                }
+            }
+        },
         "/task/list": {
             "get": {
                 "tags": [
@@ -4706,9 +4736,48 @@
                     {
                         "in": "formData",
                         "name": "id",
-                        "description": "任务ID",
+                        "description": "任务ID。指定id值大于0时为编辑操作;否则为新增操作",
                         "type": "integer",
                         "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "name",
+                        "description": "任务名称",
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "station_id",
+                        "description": "变电站ID",
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "memo",
+                        "description": "任务说明",
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "report_id",
+                        "description": "报告模板ID",
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "scd_id",
+                        "description": "SCD文件ID",
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "modelids",
+                        "description": "检测模型ID。多个模型id之间逗号分隔",
+                        "type": "string"
                     }
                 ],
                 "responses": {

+ 48 - 1
service/static/swagger/swagger.yml

@@ -3127,6 +3127,26 @@ paths:
       tags:
       - scd_check_tools/controllersApiController
       summary: 初始化系统数据
+  /task/delete:
+    post:
+      tags:
+      - scd_check_tools/controllersTaskController
+      summary: 删除指定的检测任务
+      description: 删除指定的检测任务
+      parameters:
+      - in: formData
+        name: id
+        description: 检测任务ID
+        required: true
+        type: integer
+        format: int64
+      responses:
+        "200":
+          description: 成功
+          schema:
+            $ref: '#/definitions/ResultOK'
+        "500":
+          description: '{object} ResultError  失败'
   /task/list:
     get:
       tags:
@@ -3189,9 +3209,36 @@ paths:
       parameters:
       - in: formData
         name: id
-        description: 任务ID
+        description: 任务ID。指定id值大于0时为编辑操作;否则为新增操作
         type: integer
         format: int64
+      - in: formData
+        name: name
+        description: 任务名称
+        type: string
+      - in: formData
+        name: station_id
+        description: 变电站ID
+        type: integer
+        format: int64
+      - in: formData
+        name: memo
+        description: 任务说明
+        type: string
+      - in: formData
+        name: report_id
+        description: 报告模板ID
+        type: integer
+        format: int64
+      - in: formData
+        name: scd_id
+        description: SCD文件ID
+        type: integer
+        format: int64
+      - in: formData
+        name: modelids
+        description: 检测模型ID。多个模型id之间逗号分隔
+        type: string
       responses:
         "200":
           description: 成功

+ 70 - 1
service/swagger/swagger.json

@@ -4618,6 +4618,36 @@
                 "summary": "初始化系统数据"
             }
         },
+        "/task/delete": {
+            "post": {
+                "tags": [
+                    "scd_check_tools/controllersTaskController"
+                ],
+                "summary": "删除指定的检测任务",
+                "description": "删除指定的检测任务",
+                "parameters": [
+                    {
+                        "in": "formData",
+                        "name": "id",
+                        "description": "检测任务ID",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "成功",
+                        "schema": {
+                            "$ref": "#/definitions/ResultOK"
+                        }
+                    },
+                    "500": {
+                        "description": "{object} ResultError  失败"
+                    }
+                }
+            }
+        },
         "/task/list": {
             "get": {
                 "tags": [
@@ -4706,9 +4736,48 @@
                     {
                         "in": "formData",
                         "name": "id",
-                        "description": "任务ID",
+                        "description": "任务ID。指定id值大于0时为编辑操作;否则为新增操作",
                         "type": "integer",
                         "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "name",
+                        "description": "任务名称",
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "station_id",
+                        "description": "变电站ID",
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "memo",
+                        "description": "任务说明",
+                        "type": "string"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "report_id",
+                        "description": "报告模板ID",
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "scd_id",
+                        "description": "SCD文件ID",
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "formData",
+                        "name": "modelids",
+                        "description": "检测模型ID。多个模型id之间逗号分隔",
+                        "type": "string"
                     }
                 ],
                 "responses": {

+ 48 - 1
service/swagger/swagger.yml

@@ -3127,6 +3127,26 @@ paths:
       tags:
       - scd_check_tools/controllersApiController
       summary: 初始化系统数据
+  /task/delete:
+    post:
+      tags:
+      - scd_check_tools/controllersTaskController
+      summary: 删除指定的检测任务
+      description: 删除指定的检测任务
+      parameters:
+      - in: formData
+        name: id
+        description: 检测任务ID
+        required: true
+        type: integer
+        format: int64
+      responses:
+        "200":
+          description: 成功
+          schema:
+            $ref: '#/definitions/ResultOK'
+        "500":
+          description: '{object} ResultError  失败'
   /task/list:
     get:
       tags:
@@ -3189,9 +3209,36 @@ paths:
       parameters:
       - in: formData
         name: id
-        description: 任务ID
+        description: 任务ID。指定id值大于0时为编辑操作;否则为新增操作
         type: integer
         format: int64
+      - in: formData
+        name: name
+        description: 任务名称
+        type: string
+      - in: formData
+        name: station_id
+        description: 变电站ID
+        type: integer
+        format: int64
+      - in: formData
+        name: memo
+        description: 任务说明
+        type: string
+      - in: formData
+        name: report_id
+        description: 报告模板ID
+        type: integer
+        format: int64
+      - in: formData
+        name: scd_id
+        description: SCD文件ID
+        type: integer
+        format: int64
+      - in: formData
+        name: modelids
+        description: 检测模型ID。多个模型id之间逗号分隔
+        type: string
       responses:
         "200":
           description: 成功

+ 41 - 4
service/test/test.go

@@ -1,14 +1,16 @@
 package test
 
 import (
-	"scd_check_tools/conf"
-	"scd_check_tools/email"
-	"scd_check_tools/logger"
-	"scd_check_tools/models/bo"
 	"encoding/json"
 	"fmt"
 	"reflect"
 	"regexp"
+	"scd_check_tools/conf"
+	"scd_check_tools/email"
+	"scd_check_tools/logger"
+	"scd_check_tools/models/bo"
+	"scd_check_tools/tools"
+	"strings"
 	"time"
 )
 
@@ -102,3 +104,38 @@ func (t *UnitTest) GetRuleCheckList() {
 	resultStr, _ := json.Marshal(result)
 	logger.Logger.Println(fmt.Sprintf("============[获取规则校验统计结果]测试结果:%+v", string(resultStr)))
 }
+
+//测试:解析scd文件的间隔和装置
+
+func (t *UnitTest) PScdIed() {
+	appport := conf.GlobalConfig["appport"]
+	url := "http://127.0.0.1:" + appport + "/api/screen/scd/parse/step1"
+	logger.Logger.Println(fmt.Sprintf("============正在测试解析scd文件的间隔和装置方法,请求URL:%s", url))
+	postdata := []string{"station_id=100", "scd_path=/static/download/曲山20210520.scd", "scd_name=曲山20210520.scd"}
+	postdataStr := strings.Join(postdata, "&")
+	testResult, _ := tools.Post(url, postdataStr, UnitTestToken)
+	logger.Logger.Println(fmt.Sprintf("============解析scd文件的间隔和装置方法测试结果:%+v", testResult))
+}
+
+//测点:创建测试任务
+func (t *UnitTest) CTask() {
+	return
+	appport := conf.GlobalConfig["appport"]
+	url := "http://127.0.0.1:" + appport + "/api/task/save"
+	logger.Logger.Println(fmt.Sprintf("============正在测试创建任务方法,请求URL:%s", url))
+	postdata := []string{"id=0", "name=UnitTest_检测任务", "station_id=10", "memo=这是一个检测任务", "report_id=10", "scd_id=10", "modelids=1,2,4"}
+	postdataStr := strings.Join(postdata, "&")
+	testResult, _ := tools.Post(url, postdataStr, UnitTestToken)
+	logger.Logger.Println(fmt.Sprintf("============创建任务方法测试结果:%+v", testResult))
+}
+
+//测点:删除测试任务
+func (t *UnitTest) DTask() {
+	appport := conf.GlobalConfig["appport"]
+	url := "http://127.0.0.1:" + appport + "/api/task/delete"
+	logger.Logger.Println(fmt.Sprintf("============正在测试删除任务方法,请求URL:%s", url))
+	postdata := []string{"id=5"}
+	postdataStr := strings.Join(postdata, "&")
+	testResult, _ := tools.Post(url, postdataStr, UnitTestToken)
+	logger.Logger.Println(fmt.Sprintf("============删除任务方法测试结果:%+v", testResult))
+}

+ 6 - 6
service/upgrade/client.go

@@ -1,12 +1,6 @@
 package upgrade
 
 import (
-	"scd_check_tools/conf"
-	"scd_check_tools/global"
-	"scd_check_tools/logger"
-	httpService "scd_check_tools/models"
-	"scd_check_tools/models/bo"
-	"scd_check_tools/tools"
 	"fmt"
 	"io"
 	"io/ioutil"
@@ -16,6 +10,12 @@ import (
 	"os/exec"
 	"path/filepath"
 	"runtime"
+	"scd_check_tools/conf"
+	"scd_check_tools/global"
+	"scd_check_tools/logger"
+	"scd_check_tools/models/bo"
+	"scd_check_tools/tools"
+	httpService "scd_check_tools/tools"
 	"strconv"
 	"strings"
 	"time"