jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
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
using HH.WMS.BLL;
using HH.WMS.BLL.External;
using HH.WMS.BLL.InStock;
using HH.WMS.BLL.SysMgr;
using HH.WMS.Common;
using HH.WMS.Common.External;
using HH.WMS.Common.Response;
using HH.WMS.DAL;
using HH.WMS.DAL.Algorithm;
using HH.WMS.Entitys;
using HH.WMS.Entitys.Algorithm;
using HH.WMS.Entitys.Common;
using HH.WMS.Entitys.Dto;
using HH.WMS.Entitys.External;
using HH.WMS.WebApi.App_Start;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
 
namespace HH.WMS.WebApi.WebService
{
    /// <summary>
    /// WMSWebService 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。 
    // [System.Web.Script.Services.ScriptService]
    public class WmsWebService : System.Web.Services.WebService
    {
 
        [WebMethod]
        public string InWorkArea(InWorkEntity inWorkEntity)
        {
            var logPara = LogType.LogPara("巨星调用InWorkArea WebService接口");
            Log.Detail(logPara, "InWorkArea接口请求参数:" + JsonConvert.SerializeObject(inWorkEntity));
            InWorkAreaEntity inWorkAreaEntity = new InWorkAreaEntity();
            if (inWorkEntity == null)
            {
                ExternalResponse eResponse = new ExternalResponse { success = false, errMsg = "参数不正确" };
                Log.Detail(logPara, "InWorkArea接口返回结果:" + JsonConvert.SerializeObject(eResponse));
                return JsonConvert.SerializeObject(eResponse);
            }
            if (string.IsNullOrEmpty(inWorkEntity.trayCode))
            {
                ExternalResponse eResponse = new ExternalResponse { success = false, errMsg = "托盘号不能为空" };
                Log.Detail(logPara, "InWorkArea接口返回结果:" + JsonConvert.SerializeObject(eResponse));
                return JsonConvert.SerializeObject(eResponse);
            }
            if (string.IsNullOrEmpty(inWorkEntity.startBit))
            {
                ExternalResponse eResponse = new ExternalResponse { success = false, errMsg = "起点不能为空" };
                Log.Detail(logPara, "InWorkArea接口返回结果:" + JsonConvert.SerializeObject(eResponse));
                return JsonConvert.SerializeObject(eResponse);
            }
            //if (string.IsNullOrEmpty(inWorkEntity.locationGear))
            //{
            //    ExternalResponse eResponse = new ExternalResponse { success = false, errMsg = "该托盘可入货位档位不能为空" };
            //    Log.Detail(logPara, "InWorkArea接口返回结果:" + JsonConvert.SerializeObject(eResponse));
            //    return JsonConvert.SerializeObject(eResponse);
            //}
            inWorkAreaEntity.trayCode = inWorkEntity.trayCode;
            inWorkAreaEntity.startBit = inWorkEntity.startBit;
            inWorkAreaEntity.locationGear = inWorkEntity.locationGear;
            inWorkAreaEntity.endArea = inWorkEntity.endArea;
            inWorkAreaEntity.endBit = inWorkEntity.endBit;
            inWorkAreaEntity.isTransport = "N";
            inWorkAreaEntity.needCreateAMSTask = "Y";
            List<InWorkAreaEntity> lstInWork = new List<InWorkAreaEntity>();
            lstInWork.Add(inWorkAreaEntity);
            return WmsApiBLLRoute.InWorkArea(lstInWork);
        }
 
        [WebMethod]
        public string OutWorkArea(OutWorkEntity outWorkEntity)
        {
            var logPara = LogType.LogPara("巨星调用OutWorkArea WebService接口");
            Log.Detail(logPara, "OutWorkArea接口请求参数:" + JsonConvert.SerializeObject(outWorkEntity));
            OutWorkAreaEntity outWorkAreaEntity = new OutWorkAreaEntity();
            if (outWorkEntity == null)
            {
                ExternalResponse eResponse = new ExternalResponse { success = false, errMsg = "参数不正确" };
                Log.Detail(logPara, "OutWorkArea接口返回结果:" + JsonConvert.SerializeObject(eResponse));
                return JsonConvert.SerializeObject(eResponse);
            }
            if (string.IsNullOrEmpty(outWorkEntity.trayCode))
            {
                ExternalResponse eResponse = new ExternalResponse { success = false, errMsg = "托盘号不能为空" };
                Log.Detail(logPara, "OutWorkArea接口返回结果:" + JsonConvert.SerializeObject(eResponse));
                return JsonConvert.SerializeObject(eResponse);
            }
            //if (string.IsNullOrEmpty(outWorkEntity.startBit))
            //{
            //    ExternalResponse eResponse = new ExternalResponse { success = false, errMsg = "起点不能为空" };
            //    Log.Detail(logPara, "OutWorkArea接口返回结果:" + JsonConvert.SerializeObject(eResponse));
            //    return JsonConvert.SerializeObject(eResponse);
            //}
            if (string.IsNullOrEmpty(outWorkEntity.trnSeqNo))
            {
                ExternalResponse eResponse = new ExternalResponse { success = false, errMsg = "搬运任务号不能为空" };
                Log.Detail(logPara, "OutWorkArea接口返回结果:" + JsonConvert.SerializeObject(eResponse));
                return JsonConvert.SerializeObject(eResponse);
            }
            outWorkAreaEntity.startBit = outWorkEntity.startBit;
            outWorkAreaEntity.trayCode = outWorkEntity.trayCode;
            outWorkAreaEntity.priority = outWorkEntity.priority;
            outWorkAreaEntity.endBit = outWorkEntity.endBit;
            outWorkAreaEntity.endArea = outWorkEntity.endArea;
            outWorkAreaEntity.remark = outWorkEntity.trnSeqNo;
            outWorkAreaEntity.IsTransport = "Y";
            outWorkAreaEntity.needCreateAMSTask = "Y";
            List<OutWorkAreaEntity> lstOutWork = new List<OutWorkAreaEntity>();
            lstOutWork.Add(outWorkAreaEntity);
            return WmsApiBLLRoute.OutWorkArea(lstOutWork);
        }
 
 
        [WebMethod]
        public string TranWorkArea(TranWorkEntity tranWorkEntity)
        {
            var logPara = LogType.LogPara("巨星调用TranWorkArea WebService接口");
            Log.Detail(logPara, "TranWorkArea接口请求参数:" + JsonConvert.SerializeObject(tranWorkEntity));
            InWorkAreaEntity inWorkAreaEntity = new InWorkAreaEntity();
            if (tranWorkEntity == null)
            {
                ExternalResponse eResponse = new ExternalResponse { success = false, errMsg = "参数不正确" };
                Log.Detail(logPara, "TranWorkArea接口返回结果:" + JsonConvert.SerializeObject(eResponse));
                return JsonConvert.SerializeObject(eResponse);
            }
            if (string.IsNullOrEmpty(tranWorkEntity.trayCode))
            {
                ExternalResponse eResponse = new ExternalResponse { success = false, errMsg = "托盘号不能为空" };
                Log.Detail(logPara, "TranWorkArea接口返回结果:" + JsonConvert.SerializeObject(eResponse));
                return JsonConvert.SerializeObject(eResponse);
            }
            if (string.IsNullOrEmpty(tranWorkEntity.startBit))
            {
                ExternalResponse eResponse = new ExternalResponse { success = false, errMsg = "起点不能为空" };
                Log.Detail(logPara, "TranWorkArea接口返回结果:" + JsonConvert.SerializeObject(eResponse));
                return JsonConvert.SerializeObject(eResponse);
            }
            inWorkAreaEntity.trayCode = tranWorkEntity.trayCode;
            inWorkAreaEntity.startBit = tranWorkEntity.startBit;
            inWorkAreaEntity.locationGear = tranWorkEntity.locationGear;
            inWorkAreaEntity.endArea = tranWorkEntity.endArea;
            inWorkAreaEntity.endBit = tranWorkEntity.endBit;
            inWorkAreaEntity.isTransport = "Y";
            inWorkAreaEntity.needCreateAMSTask = "Y";
            inWorkAreaEntity.trnSeqNo = tranWorkEntity.trnSeqNo;
            inWorkAreaEntity.needCallJobDetail = "N";
            List<InWorkAreaEntity> lstInWork = new List<InWorkAreaEntity>();
            lstInWork.Add(inWorkAreaEntity);
            return WmsApiBLLRoute.InWorkArea(lstInWork);
        }
 
        [WebMethod]
        public string BindingAndUnBinding(BindingAndUnBindingDto bindEntity)
        {
            var logPara = LogType.LogPara("绑定与解绑");
            Log.Detail(logPara, "BindingAndUnBinding接口请求参数:" + JsonConvert.SerializeObject(bindEntity));
            var result = WmsApiBLLRoute.BindingAndUnBinding(bindEntity);
            Log.Detail(logPara, "BindingAndUnBinding接口返回结果:" + JsonConvert.SerializeObject(result));
            return result;
        }
        [WebMethod]
        public string AGVLocationQuery(string stockCode, string strLocation)
        {
            OperateResult result = new OperateResult();
            List<AgvLocationQuery> dt = new List<AgvLocationQuery>();
            List<AgvLocationQuery> listData = new List<AgvLocationQuery>();
            try
            {
                dt = BLLCreator.Create<TN_WM_B_TRAY_LOCATIONBLL>().GetAGVLocationStatus(stockCode,strLocation);
                List<AutoBomAreaLocation_REntity> lstLogicEntity= DALCreator.Create<TN_WMS_AREADAL>().GetLogicAreaLocation(dt.Select(o => o.CN_S_LOCATION_CODE).ToList());
                listData = lstLogicEntity.Join(dt,
                  u => u.CN_S_LOCATION_CODE, d => d.CN_S_LOCATION_CODE, (u, d) => new { u, d })
                  .Select(o => new AgvLocationQuery
                  {
                      CN_S_TRAY_CODE = o.d.CN_S_TRAY_CODE,
                      CN_S_LOCATION_CODE = o.d.CN_S_LOCATION_CODE,
                      CN_S_LOCATION_STATE = o.d.CN_S_LOCATION_STATE,
                      CN_S_USE_STATE = o.d.CN_S_USE_STATE,
                      LOCATION_GEAR = o.u.CN_S_AREA_CODE
                  }).ToList();
                result.Success = true;
                result.Data = dt;
            }
            catch(Exception ex)
            {
                result.Success = true;
                result.Msg = "系统异常:"+ex.Message;
            }
            return JsonConvert.SerializeObject(result); ;
        }
    }
}