11
pulg
2025-06-05 28bea7128b8c24a6a664e880f1425e1fa24b9b5f
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
using HH.WCS.Hexafluo;
using HH.WCS.Hexafluo.util;
using HH.WCS.SJML.Dto;
using HH.WCS.ZCQTJ.Entitys;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
 
namespace HH.WCS.ZCQTJ.dispatch
{
    public class MesTask
    {
        private static readonly HttpHelper apiHelper = new HttpHelper();
        private static readonly string baseUrl = Settings.MesHelperList;
 
        /// <summary>
        /// 任务取消
        /// </summary>
        /// <param name="mst"></param>
        /// <returns></returns>
        public OperateResult MesTaskEntity(ZCReceivePriorityEntity mst)
        {
 
            List<JObject> sendParams = new List<JObject>();
            JObject sendParam = new JObject();
            JObject sendData = new JObject
            {
                // 任务编码
                { "taskNo", mst.taskNo },
                // 任务执行状态
                { "taskStatus", mst.Data_status },
                //目的库位
                { "endStock", mst.End_big },
                //创建人
                { "updater", "WMS" },
                //创建时间
                { "updateTime", DateTime.Now.ToString() }
            };
            //sendData.Add("TOOLS_NO", mst.TOOLS_NO);
            sendParams.Add(sendParam);
 
            string sendDatas = JsonConvert.SerializeObject(sendParams);
            LogHelper.Info("发送给MES", "任务取消===>:" + sendData.ToString());
            LogHelper.Info("发送给MES", "任务取消===>调用接口:" + sendData.ToString());
            string result;
            result = apiHelper.Post(baseUrl + "/jfly.openapi/agv/updateTask", sendData.ToString());
            LogHelper.Info("发送给MES", "任务取消===>MES返回结果:" + result);
 
            if (result == "")
                return OperateResult.Error("请检查MES访问地址!");
            try
            {
                MesResponseResult s = JsonConvert.DeserializeObject<MesResponseResult>(result);
                if (s.code == 0)
                {
                    return OperateResult.Succeed();
                }
                else
                {
                    return OperateResult.Error(s.message);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Info("发送给MES", "任务取消===>MES返回结果异常" + ex.Message);
                return OperateResult.Error("MES返回结果异常");
            }
        }
 
        /// <summary>
        /// 错误反馈
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public OperateResult RollMesAllocation(ZCReceivePriorityEntity model)
        {
            List<JObject> sendParams = new List<JObject>();
            JObject sendParam = new JObject();
            JObject sendData = new JObject
            {
                // 任务号
                { "taskNo", model.taskNo },
                // 时间
                { "updateTime", model.operattime },
                // 错误原因
                { "remark", model.remark }
            };
            sendParams.Add(sendParam);
            string sendDatas = JsonConvert.SerializeObject(sendData);
            LogHelper.Info("发送给MES", "错误反馈===>" + sendDatas);
            string result;
            result = apiHelper.Post(baseUrl + "/jfly.openapi/agv/updateTask", sendData.ToString());
            LogHelper.Info("发送给MES", "错误反馈===>MES返回结果:" + result);
            if (string.IsNullOrEmpty(result))
                return OperateResult.Error("请检查MES访问地址!");
            try
            {
                MesResponseResult s = JsonConvert.DeserializeObject<MesResponseResult>(result);
                if (s.code == 0)
                {
                    return OperateResult.Succeed();
                }
                else
                {
                    return OperateResult.Error(s.message);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Info("发送给MES", "错误反馈===>MES返回结果异常" + ex.Message);
                return OperateResult.Error("MES返回结果异常");
            }
        }
 
        /// <summary>
        /// 获取工装物料信息
        /// </summary>
        /// <returns></returns>
        public MesResponseResultTwo SelectItemList(string stToolsNo, string taskNo)
        {
            List<JObject> sendParams = new List<JObject>();
            JObject sendParam = new JObject();
            JObject sendData = new JObject();
            MesResponseResultTwo res = new MesResponseResultTwo();
            // 工装编号
            sendData.Add("stToolsNo", stToolsNo);
            sendData.Add("taskNo", taskNo);//任务号
            string sendDatas = JsonConvert.SerializeObject(sendData);
            LogHelper.Info("发送给MES", "获取工装物料信息===>" + sendDatas);
            LogHelper.Info("发送给MES", "获取工装物料信息===> 接口" + baseUrl + "/jfly.openapi/job/toolTCardQuery/v2");
            var result = apiHelper.Post(baseUrl + "/jfly.openapi/job/toolTCardQuery/v2", sendData.ToString());
 
            LogHelper.Info("发送给MES", "获取工装物料信息 ===> 获取的参数" + JsonConvert.SerializeObject(result));
            try
            {
                return JsonConvert.DeserializeObject<MesResponseResultTwo>(result);
            }
            catch (Exception ex)
            {
                LogHelper.Info("发送给MES", "获取工装物料信息===>MES返回结果异常" + ex.Message);
                res.message = ex.Message;
                res.success = false;
                return res;
            }
        }
    }
 
    public class MesResponseResult
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public bool success { get; set; }
        /// <summary>
        /// 接口反馈码
        /// </summary>
 
        public int code { get; set; }
        /// <summary>
        /// 时间
        /// </summary>
        public DateTime lastTime { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        public string message { get; set; }
 
        public ZCReceiveTaskEntity data { get; set; }
    }
 
    public class MesResponseResultTwo
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public bool success { get; set; }
        /// <summary>
        /// 接口反馈码
        /// </summary>
 
        public string code { get; set; }
        /// <summary>
        /// 时间
        /// </summary>
        public DateTime lastTime { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        public string message { get; set; }
 
        public ZCReceiveTaskEntityTwo data { get; set; }
    }
 
 
    public class ZCReceiveTaskEntity
    {
        /// <summary>
        /// 任务号
        /// </summary>
        public string task_no { get; set; }
        /// <summary>
        /// 任务类型1:入库;2:出库;3-空桶任务
        /// </summary>
        public int Task_type { get; set; }
        /// <summary>
        /// 周转卡号
        /// </summary>
        public string TurnCardNum { get; set; }
        /// <summary>
        /// 标准重量
        /// </summary>
        public float standardWeight { get; set; }
        /// <summary>
        /// 工装类型
        /// </summary>
        public string TOOLS_TPYE { get; set; }
        /// <summary>
        /// 制品编号
        /// </summary>
        public string PROD_NO { get; set; }
        /// <summary>
        /// 工艺编号
        /// </summary>
        public string PROD_TECH { get; set; }
        /// <summary>
        /// 制品规格
        /// </summary>
        public string PROD_SPEC { get; set; }
        /// <summary>
        /// 制品类型
        /// </summary>
        public string PROD_BOM { get; set; }
        /// <summary>
        /// 制品特征值
        /// </summary>
        public string PROD_Feature { get; set; }
        /// <summary>
        /// 工装编号
        /// </summary>
        public string TOOLS_NO { get; set; }
        /// <summary>
        /// 载料数量
        /// </summary>
        public float ST_AMOUNT { get; set; }
        /// <summary>
        /// 当前数量
        /// </summary>
        public float CURRENT_AMOUNT { get; set; }
        /// <summary>
        /// 起始库位编号
        /// </summary>
        public string Location_From { get; set; }
        /// <summary>
        /// 目的库位编号
        /// </summary>
        public string Location_To { get; set; }
        /// <summary>
        /// 生产时间
        /// </summary>
        public DateTime PRODUCE_TIME { get; set; }
        /// <summary>
        /// 生效时间
        /// </summary>
        public DateTime SHELF_LIFE_TIME { get; set; }
        /// <summary>
        /// 失效时间
        /// </summary>
        public DateTime EXPIRED_TIME { get; set; }
        /// <summary>
        /// 缩短报告时间
        /// </summary>
        public float SHELF_REP { get; set; }
        /// <summary>
        /// 延长报告时间
        /// </summary>
        public float EXPIRED_REP { get; set; }
        /// <summary>
        /// 质检状态代码
        /// </summary>
        public string CHECK_CODE { get; set; }
        /// <summary>
        /// 质检状态
        /// </summary>
        public string CHECK_INFO { get; set; }
        /// <summary>
        /// 优先级0-普通:任务生成时,均为此级别;1-加急;2-紧急
        /// </summary>
        public int Priority { get; set; }
        /// <summary>
        /// 任务状态0-初始状态;1-进行中;2-完成;3-任务取消
        /// </summary>
        public int Data_status { get; set; }
        /// <summary>
        /// 业务类型
        /// 1    半成品满托入库
        /// 2    成型机半桶回库
        /// 3    成型机空桶回库
        /// 4    成型机满托出库
        /// 5    成型机带束回库
        /// 6    成型机带束满托出库
        /// 7   半成品空托出库
        /// 8   胶料入库
        /// 9   呼叫胶料
        /// 10  叠盘机空托入库
        /// 11  胶料半桶回库
        /// 100 绑定
        /// 200 解绑
        /// </summary>
        public string BUSI_TYPE { get; set; }
        public string Task_PDA { get; set; }
 
        /// <summary>
        /// 用于mes调wms库位查询接口使用
        /// </summary>
        public string Location_Area { get; set; }
 
        /// <summary>
        /// 绑定的货位
        /// </summary>
        public string LOCATION_CODE { get; set; }
 
    }
 
    public class ZCReceiveTaskEntityTwo
    {
        /// <summary>
        /// 工单号
        /// </summary>
        public string planNo { get; set; }
        /// <summary>
        /// 制品类型
        /// </summary>
        public string prodName { get; set; }
        /// <summary>
        /// 物料编码
        /// </summary>
        public string prodNo { get; set; }
        /// <summary>
        /// 质检状态
        /// </summary>
        public string prodSelfCheck { get; set; }
        /// <summary>
        /// 物料规格型号
        /// </summary>
        public string prodSpec { get; set; }
        /// <summary>
        /// 报产时间
        /// </summary>
        public DateTime produceTime { get; set; }
        /// <summary>
        /// 生效时间
        /// </summary>
        public DateTime shelfLifeTime { get; set; }
        /// <summary>
        /// 过期时间
        /// </summary>
        public DateTime expiredTime { get; set; }
        /// <summary>
        /// 工装
        /// </summary>
        public string stToolsNo { get; set; }
        /// <summary>
        /// 总数量
        /// </summary>
        public float stAmount { get; set; }
        /// <summary>
        /// 当前余量 
        /// </summary>
        public float currentAmount { get; set; }
        /// <summary>
        /// 周转卡号
        /// </summary>
        public string turnoverNo { get; set; }
        public string applyProdSpecList { get; set; }
    }
}