Admin
6 小时以前 1cd9280bbecf557f8978ad3839f14827ff9f4d34
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
using System;
using System.Collections.Generic;
using System.Text;
using WIDESEA_Common;
using WIDESEA_Common.LogEnum;
using WIDESEA_Common.TaskEnum;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Core.Utilities;
using WIDESEA_Entity.DomainModels;
using WIDESEA_Services.Repositories;
using WIDESEA_Services.Services.APIInvoke;
 
namespace WIDESEA_Services.Services.APIReceive.RGV
{
    public class WCSReceiveMsgFromRGV
    {
        /// <summary>
        /// WCS接收RGV上报的任务状态
        /// </summary>
        /// <param name="taskModel">任务信息</param>
        /// <returns></returns>
        //public static Dictionary<string, object> WCSReceiveRGVData(Dictionary<string, object> statusData)
        //{            
        //    Dictionary<string, object> resultDic = new Dictionary<string, object>();
        //    try
        //    {
        //        //任务编号
        //        string taskId = statusData["taskId"].ToString();
        //        //小车编号
        //        string reportTime = statusData["rgvId"].ToString();
        //        //任务状态
        //        int taskStatus = int.Parse(statusData["status"].ToString());
 
        //        Console.WriteLine($"接受到RGV上报的任务状态:任务号:{taskId},小车编号:{reportTime},任务状态:{taskStatus}");
        //        LogRecord.WriteLog(LogEnum.RGV, $"接受到RGV上报的任务状态:任务号:{taskId},小车编号:{reportTime},任务状态:{taskStatus}");
 
        //        //在此根据上报的任务号,更新任务状态以及任务完成后的相关操作
        //        VOLContext dbcontext = new VOLContext();
        //        Dt_TaskRGVinfoRepository taskRGVinfoRepository = new Dt_TaskRGVinfoRepository(dbcontext);
        //        Dt_TaskRGVinfo_HtyRepository taskRGVinfo_HtyRepository = new Dt_TaskRGVinfo_HtyRepository(dbcontext);
        //        Dt_TaskRGVinfo_HtyService taskRGVinfo_HtyService = new Dt_TaskRGVinfo_HtyService(taskRGVinfo_HtyRepository);
 
        //        Dt_TaskWCSinfoRepository taskWCSinfoRepository = new Dt_TaskWCSinfoRepository(dbcontext);
        //        Dt_TaskWCSinfo_HtyRepository taskWCSinfo_HtyRepository = new Dt_TaskWCSinfo_HtyRepository(dbcontext);
        //        Dt_TaskWCSinfo_HtyService taskWCSinfo_HtyService = new Dt_TaskWCSinfo_HtyService(taskWCSinfo_HtyRepository);
        //        Dt_TaskWCSinfo_Hty taskWCSinfo_Hty = new Dt_TaskWCSinfo_Hty();
        //        Dt_TaskRGVinfo_Hty taskRGVinfo_Hty = new Dt_TaskRGVinfo_Hty();
 
        //        Dt_TaskRGVinfo taskRGVinfo = taskRGVinfoRepository.FindFirst(x => x.rgvtask_taskId == taskId);
        //        Dt_TaskWCSinfo taskWCSinfo = taskWCSinfoRepository.FindFirst(x => x.wcstask_taskNumber == taskRGVinfo.rgvtask_wcsTaskNumber);
        //        if (taskRGVinfo != null)
        //        {
        //            WebResponseContent content = new WebResponseContent();
        //            //RGV上报对应的任务正常完成
        //            if (taskStatus == 1)
        //           {
 
        //                taskWCSinfoRepository.DbContextBeginTransaction(()=>
        //                {
        //                    try
        //                    {
        //                        //区分任务类型,如果是入库类型的任务,RGV完成,则总任务完成,出库型任务,RGV完成,则只是部分完成
        //                        //***空托入库*******
        //                        //***轴承组盘入库***
        //                        if (taskWCSinfo.wcstask_type == TaskType.TaskType_Empty_Pallet_Inbound.ToString() ||
        //                            taskWCSinfo.wcstask_type == TaskType.TaskType_Box_Pallet_Inbound.ToString())
        //                        {
        //                            //完成rgv、wcs任务、移动任务到历史
        //                            taskRGVinfoRepository.Delete(taskRGVinfo, true);
        //                            taskWCSinfoRepository.Delete(taskWCSinfo, true);
        //                            taskRGVinfo_HtyService.AddRgvTaskToHistory(taskRGVinfo, dbcontext);
        //                            taskWCSinfo_HtyService.AddWcsTaskToHistory(taskWCSinfo, dbcontext);
 
        //                            //上报WMS任务完成,对于入库来说,穿梭车的任务完成,即是整个任务的生命周期结束
        //                            content = WMSApi.TellWmsTaskFinished(taskRGVinfo.rgvtask_barCode);
        //                            if (content.Status)
        //                            {
        //                                content.OK();
        //                            }
        //                            else
        //                            {
        //                                throw new Exception($"【入库任务】上报WMS任务完成出错,WCS任务号:【{taskWCSinfo.wcstask_taskNumber}】,托盘号:【{taskWCSinfo.wcstask_barcode}】");
        //                            }
        //                        }
        //                        //***测量出库*******,不要删除库存,占着坑,等待测量完回库
        //                        else if (taskWCSinfo.wcstask_type == TaskType.TaskType_Box_Pallet_Measure_Out.ToString())
        //                        {
        //                            //更新rgv、wcs任务状态
        //                            taskRGVinfo.rgvtask_taskStatus = RGVTaskState.RgvTaskState_Done.ToString();
        //                            taskWCSinfo.wcstask_state = TaskState.TaskState_RGV_Finished.ToString();
 
        //                            //完成rgv、移动任务到历史
        //                            taskRGVinfoRepository.Delete(taskRGVinfo, true);
        //                            taskRGVinfo_HtyService.AddRgvTaskToHistory(taskRGVinfo, dbcontext);
 
        //                            //上报WMS最新任务状态,此处状态是穿梭车的任务完成
        //                            content = WMSApi.PostTaskStateToWMS(taskRGVinfo.rgvtask_barCode, TaskState.TaskState_RGV_Finished.ToString());
        //                            if (content.Status)
        //                            {
        //                                content.OK();
        //                                //进入线体的测量出库逻辑
 
        //                            }
        //                            else
        //                            {
        //                                throw new Exception($"【测量出库】上报WMS任务完成出错,WCS任务号:【{taskWCSinfo.wcstask_taskNumber}】,托盘号:【{taskWCSinfo.wcstask_barcode}】");
        //                            }
        //                        }
        //                        //***测量回库*******
        //                        else if (taskWCSinfo.wcstask_type == TaskType.TaskType_Box_Pallet_Measure_Back.ToString())
        //                        {
        //                            //完成rgv、wcs任务、移动任务到历史
        //                            taskRGVinfoRepository.Delete(taskRGVinfo, true);
        //                            taskWCSinfoRepository.Delete(taskWCSinfo, true);
        //                            taskRGVinfo_HtyService.AddRgvTaskToHistory(taskRGVinfo, dbcontext);
        //                            taskWCSinfo_HtyService.AddWcsTaskToHistory(taskWCSinfo, dbcontext);
 
        //                            //上报WMS任务完成,对于测量回库来说,穿梭车的任务完成,即是整个任务的生命周期结束
        //                            //由于测量出库的没有删除库存,所有只要放回去即可,要不生成库存,在WMS做逻辑
        //                            content = WMSApi.TellWmsTaskFinished(taskRGVinfo.rgvtask_barCode);
        //                            if (content.Status)
        //                            {
        //                                content.OK();
        //                            }
        //                            else
        //                            {
        //                                throw new Exception($"【测量回库】上报WMS任务完成出错,WCS任务号:【{taskWCSinfo.wcstask_taskNumber}】,托盘号:【{taskWCSinfo.wcstask_barcode}】");
        //                            }
        //                        }
 
 
        //                    }
        //                    catch(Exception ex)
        //                    {
        //                        content.Error(ex.Message);
        //                    }
 
        //                    return content;
        //                });
 
        //           }
        //        }
        //        else
        //        {
        //            Console.WriteLine($"RGV上报了任务状态,但是在RGV任务表中没有找到对应的任务,任务号:【{taskId}】");
        //        }
 
        //        resultDic.Add("Code", "1");
        //        resultDic.Add("Message", "Scuccess");
        //        resultDic.Add("data ", null);
        //    }
        //    catch (Exception ex)
        //    {
        //        resultDic.Add("Code", "0");
        //        resultDic.Add("Message", "Failed");
        //        resultDic.Add("data ", ex.Message);
        //    }
 
        //    return resultDic;
        //}
 
 
 
        /// <summary>
        /// WCS接收RGV上报的任务状态
        /// </summary>
        /// <param name="taskModel">任务信息</param>
        /// <returns></returns>
        //public static Dictionary<string, object> GetElevatorInfo()
        //{
        //    Dictionary<string, object> resultDic = new Dictionary<string, object>();
        //    try
        //    {
 
        //        resultDic.Add("code", "1");
        //        resultDic.Add("layer", "3");
        //        resultDic.Add("status ", "提升机当前状态");
        //    }
        //    catch (Exception ex)
        //    {
        //        resultDic.Add("code", "0");
        //        resultDic.Add("layer", "-1");
        //        resultDic.Add("status ", "获取提升机状态失败"+ex.Message);
        //    }
 
        //    return resultDic;
        //}
    }
}