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
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_Core;
using WIDESEAWCS_DTO.WMSInfo;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob.Models;
 
namespace WIDESEAWCS_TaskInfoService
{
    public partial class TaskService
    {
 
        /// <summary>
        /// 输送线检测口向WMS申请入库
        /// </summary>
        /// <param name="palletCode">托盘号</param>
        /// <param name="sourceAddress">起始地址</param>
        /// <returns></returns>
        public WebResponseContent RequestWMSTask(ConveyorLineDTO lineDTO)
        {
            WebResponseContent content = new WebResponseContent();
 
            #region 向WMS申请
            var ResultData = HttpHelper.PostAsync(WMSInterfaceAddress.ConveyorLineRequestInbound, lineDTO.ToJson(), headers: new Dictionary<string, string>());
            if (ResultData.Result == null) throw new Exception($"向WMS请求入库超时");
 
            return JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result);
 
            #endregion
        }
 
        /// <summary>
        /// 输送线入库完成向WMS申请入库/堆垛机申请入库
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public WebResponseContent StackerCraneRequestInbound(Dt_Task task)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                ConveyorLineDTO lineDTO = new ConveyorLineDTO()
                {
                    stationCode = task.CurrentAddress,
                    TaskNum = task.TaskNum,
                    Barcode = task.PalletCode
                };
                var ResultData = HttpHelper.PostAsync(WMSInterfaceAddress.StackerCraneRequestInbound, lineDTO.ToJson(), headers: new Dictionary<string, string>());
                if (ResultData.Result == null) throw new Exception($"向WMS请求入库分配货位超时!任务号:{task.TaskNum}");
                content = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result);
                if (!content.Status) throw new Exception(content.Message);
 
                var receiveWMSInfo = JsonConvert.DeserializeObject<ReceiveWMSInfo>(content.Data.ToJson());
                task.IsPickPlace = receiveWMSInfo.IsPickPlace;
                task.TargetAddress = receiveWMSInfo.TargetAddress;
                task.NextAddress = task.TargetAddress;
                BaseDal.UpdateData(task);
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
    }
}