wxw
2025-04-29 98b5cec700e6a89924951be841e0a9702848003c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Model.InterFaceModel;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using ZXing;
using static Model.InterFaceModel.RCSModel;
 
namespace Utility.Tools
{
    public static class RcsHelper
    {
        /// <summary>
        /// 下发任务
        /// </summary>
        /// <param name="taskDetial"></param>
        /// <param name="url"></param>
        /// <param name="agvMsg"></param>
        /// <param name="priority"></param>
        /// <returns></returns>
        public static bool CreateTaskForAgv(TaskDetial taskDetial, string url, out string agvMsg, string priority = null)
        {
            bool result = false;
 
            List<targetRoute> pahtList = new List<targetRoute>();
            //起始位置
            targetRoute royte1 = new targetRoute();
            royte1.seq = 0;
            royte1.type = "ZONE";
            royte1.code = taskDetial.Startport;
 
            pahtList.Add(royte1);
 
            //目标位置
            targetRoute royte2 = new targetRoute();
            royte2.seq = 0;
            royte2.type = "ZONE";
            royte2.code = taskDetial.Endport;
 
            pahtList.Add(royte2);
 
            AgvCreateTaskModel taskModel = new AgvCreateTaskModel();
            taskModel.taskType = "PF-LMR-COMMON";
            taskModel.targetRoute = pahtList;
 
            // 正式运行程序放开
            var jsonData = JsonConvert.SerializeObject(taskModel);
            string response = HttpHelper.DoPost(url, jsonData, "下发给AGV转运命令", "AGV");
            //解析返回数据 
            var agvModel = JsonConvert.DeserializeObject<OutCommanAgvDto>(response);
            if (agvModel.Code == "0")
            {
                result = true;//给下车下发任务成功
 
                agvMsg = "";
            }
            else
            {
                var logStr = $@".\log\AGV\下发给AGV转运命令" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
                LogFile.SaveLogToFile($"下发给AGV转运命令异常:( {agvModel.Message} ),", logStr);
 
                agvMsg = agvModel.Message;
            }
 
            return result;
        }
    }
}