add
zongzhibin
2024-11-24 d89732b82ff7fc047628ca3772311a0fbeea3553
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
 
using iWareCC.BLL;
using iWareCC.Common.Helper;
using iWareCommon.Utils;
using iWareModel;
using iWareModel.Entity;
using iWareModel.Entity.Device;
using iWareSql.DataAccess;
using iWareSql.DBModel;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using XiGang.Core.Model;
using XiGang.Core.Model.PostParamModels;
using XiGang.Core.Model.PostParamModels.Task;
 
namespace iWareCC.WCF
{
    // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的类名“CCWcfService”。
    public class CCWcfService : ICCWcfService
    {
        /// <summary>
        /// MES提供某个发动机的详细信息
        /// </summary>
        /// <param name="_barCode"></param>
        public string getEngineInfo(string mes_url, string XiGang_Mes_Url_getEngineInfo, string token, string _barCode)
        {
            return MyMesService.getEngineInfo(mes_url, XiGang_Mes_Url_getEngineInfo, token, _barCode);
        }
 
        /// <summary>
        /// 获取设备坐标
        /// </summary>
        /// <returns></returns>
        public DeviceCoordinat GetDeviceCoordinat()
        {
            DeviceCoordinat result = null;
            try
            {
                result = new DeviceCoordinat()
                {
 
                };
 
                result.RgvCoordinate = FormCC.rgvView.R_RGV_Coordinate;
 
                result.Srm1Coordinat = FormCC.srmViewDict[(int)EDevice.一号堆垛机].R_PosXmm.ToString();
                result.Srm2Coordinat = FormCC.srmViewDict[(int)EDevice.二号堆垛机].R_PosXmm.ToString();
                result.Srm3Coordinat = FormCC.srmViewDict[(int)EDevice.三号堆垛机].R_PosXmm.ToString();
                result.Srm4Coordinat = FormCC.srmViewDict[(int)EDevice.四号堆垛机].R_PosXmm.ToString();
 
                return result;
            }
            catch (Exception ex)
            {
                Log4NetHelper.WriteErrorLog(LogType.CCWCFService, "GetDeviceCoordinat出现异常:" + ex.Message, ex);
                return result;
            }
        }
 
        /// <summary>
        /// 模式是否正在运行
        /// </summary>
        /// <returns></returns>
        public bool IsStartedModel()
        {
            return SystemValue.isStartedModel;
        }
 
        /// <summary>
        /// 生成最新的任务序列号
        /// </summary>
        /// <param name="edm"></param>
        /// <returns></returns>
        public TaskSequenceEntity GenerateTaskSequence()
        {
            try
            {
                using (DbModel edm = new DbModel())
                {
                    TaskSequenceEntity entity = new TaskSequenceEntity();
                    entity = MainTaskHandler.GetTaskSequenceEntity(edm);
                    return entity;
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.WriteErrorLog(LogType.CCWCFService, "GenerateTaskSequence出现异常:" + ex.Message, ex);
                return null;
            }
        }
 
 
 
        /// <summary>
        /// 组盘入库
        /// </summary>
        /// <param name="taskSequence"></param>
        /// <param name="taskSequenceGuid"></param>
        /// <param name="isBtj"></param>
        /// <param name="Task_InStoreSlaver"></param>
        /// <param name="request"></param>
        /// <param name="userName"></param>
        /// <param name="userId"></param>
        /// <param name="inStoreNo">入库口</param>
        /// <returns></returns>
        public FunRetEntity SalverMaterialBind(bool isValidate1015ScanValue,
            bool isBtj,
            C_Task_InStoreSlaverParam Task_InStoreSlaver, C_AnalyzeMaterialPostParam request,
            string userName, int userId, string inStoreNo)
        {
            try
            {
                var ret = SalverMaterialBindBLL.SalverMaterialBind(isValidate1015ScanValue, isBtj, Task_InStoreSlaver, request, userName, userId, inStoreNo);
                if (ret.success)
                {
                    return FunRetEntity.Success("成功");
                }
                return FunRetEntity.Fail(ret.msg);
            }
            catch (Exception ex)
            {
                return FunRetEntity.Fail("异常:" + ex.Message);
            }
        }
 
        /// <summary>
        /// 重新扫描输送线1015上的托盘号
        /// </summary>
        /// <returns></returns>
        public FunRetEntity Write1015ReScan(bool value)
        {
            try
            {
                if (WCSConfigHelper.GetConfig_IsSimulationPLC())
                {
                    return FunRetEntity.Success("模拟成功", "");
                }
 
                using (RgvService.RgvServiceClient client = new RgvService.RgvServiceClient())
                {
                    iWareCC.RgvService.SdaResEntity result = client.Write1015ReScan((int)EDevice.RGV, value);
                    if (result.result)
                    {
                        return FunRetEntity.Success("成功", "");
                    }
                    else
                    {
                        return FunRetEntity.Fail(result.resMsg, "");
                    }
                }
            }
            catch (Exception ex)
            {
                return FunRetEntity.Fail("获取输送线1015上扫描的托盘号出现异常:" + ex.Message);
            }
        }
 
        /// <summary>
        /// 获取输送线1015上的扫描值
        /// </summary>
        /// <returns></returns>
        public FunRetEntity GetScanValueFor1015()
        {
            try
            {
                //注意:这里是模拟的,发布要改过来啊!!!
                if (WCSConfigHelper.GetConfig_IsSimulationPLC())
                {
                    return FunRetEntity.Success("模拟成功", "XGT000205");
                }
 
                return FunRetEntity.Success("成功", FormCC.rgvView.R_1015_Scan);
            }
            catch (Exception ex)
            {
                return FunRetEntity.Fail("获取输送线1015上扫描的托盘号出现异常:" + ex.Message);
            }
        }
 
        /// <summary>
        /// 重新扫描输送线1019上的托盘号
        /// </summary>
        /// <returns></returns>
        public FunRetEntity Write1019ReScan(bool value)
        {
            try
            {
                if (WCSConfigHelper.GetConfig_IsSimulationPLC())
                {
                    return FunRetEntity.Success("模拟成功", "");
                }
 
                using (RgvService.RgvServiceClient client = new RgvService.RgvServiceClient())
                {
                    iWareCC.RgvService.SdaResEntity result = client.Write1019ReScan((int)EDevice.RGV, value);
                    if (result.result)
                    {
                        return FunRetEntity.Success("成功", "");
                    }
                    else
                    {
                        return FunRetEntity.Fail(result.resMsg, "");
                    }
                }
            }
            catch (Exception ex)
            {
                return FunRetEntity.Fail("获取输送线1019上扫描的托盘号出现异常:" + ex.Message);
            }
        }
 
        /// <summary>
        /// 获取输送线1019上的扫描值
        /// </summary>
        /// <returns></returns>
        public FunRetEntity GetScanValueFor1019()
        {
            try
            {
                //注意:这里是模拟的,发布要改过来啊!!!
                if (WCSConfigHelper.GetConfig_IsSimulationPLC())
                {
                    return FunRetEntity.Success("模拟成功", "XGT000205");
                }
                else
                {
                    return FunRetEntity.Success("成功", FormCC.rgvView.R_1019_Scan);
                }
            }
            catch (Exception ex)
            {
                return FunRetEntity.Fail("获取输送线1019上扫描的托盘号出现异常:" + ex.Message);
            }
        }
 
        #region 1015和1019
        #endregion
 
 
        /// <summary>
        /// 寻找空闲的立库空库位 (普通物料)
        /// </summary>
        /// <returns></returns>
        public Base_Station FindBestEmptyPlaceForOrdinaryMaterial(string orderNo)
        {
            try
            {
                using (DbModel edm = new DbModel())
                {
                    var item = StationHandler.FindBestEmptyPlaceForOrdinaryMaterial(edm, orderNo, MaterialTypeEnum.一般物料);
                    return item;
                }
            }
            catch (Exception ex)
            {
                return null;
            }
        }
 
    }
}