wxw
2025-04-27 33572be8da5fd6534b56e1e22d70e8cf56f5fe41
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
69
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
    {
        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
            {
                string logMsg = "";
                if (taskDetial.Crtype == "1")//叫桶(桶出库)
                {
                    logMsg = "申请叫桶";
                }
                else if (taskDetial.Crtype == "0")//申请储位(桶入库)
                {
                    logMsg = "申请储位";
                }
                var logStr = $@".\log\AGV\AGV{logMsg}" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
                LogFile.SaveLogToFile($"AGV{logMsg}异常:( {agvModel.Message} ),", logStr);
 
                agvMsg = agvModel.Message;
            }
 
            return result;
        }
    }
}