hudong
4 天以前 3a3c5f5711a57439f34e772313fcbb18ba7885bc
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
using HH.WCS.Mobox3.pinggao.util;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Web.Services.Description;
 
namespace HH.WCS.Mobox3.pinggao.dispatch {
    /// <summary>
    /// 国自调度辅助类
    /// </summary>
    public class HanAo {
        private static readonly HttpHelper apiHelper = new HttpHelper();
        private static readonly string baseUrl = Settings.HASeverUrl;
        //private static readonly string logName = "hanao";
 
 
        public static bool CreateOrder(TaskInfoModel model) {
            var msg = "";
            var result = true;
            var request = JsonConvert.SerializeObject(model);
            var response = apiHelper.Post(baseUrl + ":9001/wcs-admin/api/receive", request);
            msg = $"[hanao-CreateOrder] request={request} response={response}";
            Console.WriteLine(msg);
            if (response != "") {
                try {
                    var dataResult = JsonConvert.DeserializeObject<HAResult>(response);
                    if (dataResult.code == "0") {
                        result = true;
                    }
                }
                catch (Exception ex) {
                    Console.WriteLine(ex.Message);
                }
            }
            else {
                msg = "[hanao-CreateOrder]创建订单失败";
                Console.WriteLine(msg);
            }
 
            LogHelper.Info(msg,"杭奥");
            return result;
        }
        public static bool CancelOrder(CancelModel model) {
            bool result = false;
            string msg = "";
            var request = JsonConvert.SerializeObject(model);
            var response = apiHelper.Post(baseUrl + ":9002/wcs-admin/api/cancel", request);
            msg = $"[hanao-CancelOrder] request={request};response={response}";
            Console.WriteLine(msg);
            if (response != "") {
                var dataResult = JsonConvert.DeserializeObject<HAResult>(response);
                if (dataResult.code == "0") {
                    result = true;
                }
            }
            else {
                msg = "[hanao-CancelOrder]取消订单失败";
                Console.WriteLine(msg);
            }
            LogHelper.Info(msg, "杭奥");
            return result;
        }
        public static bool QueryDevice(DeviceInfoModel model) {
            bool result = false;
            string msg = "";
            var request = JsonConvert.SerializeObject(model);
            var response = apiHelper.Get(baseUrl + ":9003//wcs-admin/api/dvc-state/", request);
            msg = $"[hanao-QueryDeviceResult] request={request};response={response}";
            Console.WriteLine(msg);
            if (response != "") {
                var dataResult = JsonConvert.DeserializeObject<HAResult>(response);
                if (dataResult.code == "0") {
                    result = true;
                }
            }
            else {
                msg = "[hanao-QueryOrderResult]查询订单信息失败";
                Console.WriteLine(msg);
            }
            LogHelper.Info(msg, "杭奥");
            return result;
        }
 
 
        public class TaskInfoModel {
            /// <summary>
            /// 请求pk
            /// </summary>
            public string requestPk { get; set; }
            /// <summary>
            /// 托盘条码
            /// </summary>
            public string contNo { get; set; }
            /// <summary>
            /// 托盘类型
            /// </summary>
            public string contType { get; set; } = "";
            /// <summary>
            /// 任务类型  1-入库 2-出库 3-移库 
            /// </summary>
            public string trkType { get; set; }
            /// <summary>
            /// 1-999(值越大优先级越高)
            /// </summary>
            public string trkPrty { get; set; } = "1";
            public string frmPos { get; set; }
            public string toPos { get; set; }
            public string noticeInfo { get; set; } = "";
            /// <summary>
            /// 0-空托盘 1-实物
            /// </summary>
            public string isFull { get; set; } = "0";
            public string groupNo { get; set; } = "";
            public string clientCode { get; set; } = "WMS";
            /// <summary>
            /// 格式:2022-11-11 11:32:08
            /// </summary>
            public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
 
        }
        public class HAResult {
            public string code { get; set; }
            public string msg { get; set; }
            public string requestPk { get; set; }
        }
        public class CancelModel {
            public string requestPk { get; set; }
            public string contNo { get; set; }
            public string clientCode { get; set; }
            public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        }
        public class DeviceInfoModel {
            public string requestPk { get; set; }
            public string dvcNo { get; set; }
            public string clientCode { get; set; }
            public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        }
        public class TaskStateInfoModel {
            public string requestPk { get; set; }
            public string contNo { get; set; }
            /// <summary>
            /// 双方系统共同定义 1-入库 2-出库 3-移库 (后续如有增加再协定)
            /// </summary>
            public string noticeType { get; set; }
            public string curPos { get; set; }
            public string noticeInfo { get; set; }
            /// <summary>
            /// 0-成功 (入库上架完成/出库下架完成/库内移库完成:移库只上报最终移库上架) 或 其他-异常码(反馈相关结果原因,WMS根据情况处理 
            /// 1-入库有货 2-入远近有货 3-出库无货 4-出远近有货)
            /// </summary>
            public string code { get; set; }
            public string result { get; set; }
            public string clientCode { get; set; }
            public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        }
 
    }
 
 
}