2
schangxiang@126.com
2024-10-01 ffa9dc9c2d28c0b8d88b26d483ba9667e316db01
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
//using iWareCC.Common.Helper;
//using iWareCommon.Common.Globle;
//using iWareCommon.Utils;
//using iWareModel;
//using iWareModel.EnumType.XiGangPublicCommon;
//using iWareSql;
//using iWareSql.DataAccess;
//using iWareSql.DBModel;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading;
//using System.Threading.Tasks;
//using XiGang.Core.Model;
//using XiGang.Core.Model.PostParamModels.Task;
//using static WZ.Useful.Commons.NativeMethods;
 
//namespace iWareCC
//{
//    /// <summary>
//    /// 自动组盘 任务
//    /// </summary>
//    public static class AutoSalverMaterialBindTask
//    {
//        /// <summary>
//        /// 自动组盘任务
//        /// </summary>
//        public static void Handler()
//        {
//            var alertMsg = "";
//            while (true)
//            {
//                Thread.Sleep(2000);//休眠2秒,将休眠写到前面,是为了下面的continue方法执行后不显示错误信息的提示!!!【EditBy shaocx,2022-05-24】
//                SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = string.Empty;
//                try
//                {
//                    if (SystemValue.isAllowRuning_AutoSalverMaterialBindTask && SystemValue.isStartedModel)
//                    {
//                        EDevice rgvLocation = EDevice.入库口1019;
//                        var stationCode = Convert.ToInt32(rgvLocation).ToString();
//                        V_AllStore store = null;
 
//                        using (DbModel context = new DbModel())
//                        {
//                            //模拟
//                            bool isGD_HasCatogryForRgvStattion = true;
//                            bool isSys_HasCatogryForRgvStattion = MyExtendHelper.IsSys_HasCatogryForRgvStattion(context, stationCode, ref store);
//                            bool isExistOtherTaskDoing = PartTaskHandler.IsExistOtherTaskDoing(stationCode);
 
//                            if (isSys_HasCatogryForRgvStattion)
//                            {
//                                SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = $"{rgvLocation.ToString()}-系统有库存,此次循环结束";
//                                continue;
//                            }
//                            if (isExistOtherTaskDoing)
//                            {
//                                SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = $"{rgvLocation.ToString()}-有任务占用该站点,此次循环结束";
//                                continue;
//                            }
//                            if (!isGD_HasCatogryForRgvStattion)
//                            {
//                                SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = $"{rgvLocation.ToString()}-光电显示无货,此次循环结束";
//                                continue;
//                            }
//                            SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = $"{rgvLocation.ToString()}-光电有货";
//                            //需要读取 发动机扫描枪的信息
//                            var _scan_CargoNo = "_3118L067736B-DHP13Q667*01";  //模拟
//                            if (string.IsNullOrEmpty(_scan_CargoNo))
//                            {
//                                SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = $"读取的{rgvLocation.ToString()}位置,发动机码为空,不允许自动组盘";
//                                continue;
//                            }
//                            //验证该发动机库存已存在,要在WMS中处理
//                            //var isSys_HasCatogryForCargoNo = StoreHandler.IsSys_HasCatogryForCargoNo(context, _scan_CargoNo, ref store);
//                            //if (isSys_HasCatogryForCargoNo)
//                            //{
//                            //    SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = $"读取的{rgvLocation.ToString()}位置,发动机码为{_scan_CargoNo},该发动机库存已存在,在立库库位{store.SrmStationCode},在RGV库位{store.RgvStationCode},不允许自动组盘";
//                            //    continue;
//                            //}
//                            //需要读取 托盘号
//                            var _scan_salverCode = "XGT000205"; //模拟
//                            if (string.IsNullOrEmpty(_scan_salverCode))
//                            {
//                                SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = $"读取的{rgvLocation.ToString()}位置,托盘码为空,不允许自动组盘";
//                                continue;
//                            }
//                            var isSys_HasCatogryForSalverCode = StoreHandler.IsSys_HasCatogryForSalverCode(context, _scan_salverCode, ref store);
//                            if (isSys_HasCatogryForSalverCode)
//                            {
//                                SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = $"读取的{rgvLocation.ToString()}位置,托盘码为{_scan_salverCode},该托盘库存已存在,在立库库位{store.SrmStationCode},在RGV库位{store.RgvStationCode},不允许自动组盘";
//                                continue;
//                            }
//                            var isExistOtherTaskDoingForSalverCode = PartTaskHandler.IsExistOtherTaskDoingForSalverCode(stationCode);
//                            if (isExistOtherTaskDoingForSalverCode)
//                            {
//                                SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = $"读取的{rgvLocation.ToString()}位置,托盘码为{_scan_salverCode},该托盘已经有未结束的任务被占用,不允许自动组盘";
//                                continue;
//                            }
 
//                            //符合条件,即将进行自动组盘
//                            alertMsg = $"读取的{rgvLocation.ToString()}位置,发动机码为{_scan_CargoNo},托盘码为{_scan_salverCode},符合条件,即将进行自动组盘";
//                            SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = alertMsg;
//                            Log4NetHelper.WriteInfoLog(LogType.AutoSalverMaterialBindTask, alertMsg);
 
//                            try
//                            {
//                                //调用API
//                                AddMainTaskPostParam param = new AddMainTaskPostParam()
//                                {
//                                    InStoreNo = ((int)rgvLocation).ToString(),
//                                    CargoNo = _scan_CargoNo,
//                                    SalverCode = _scan_salverCode,
//                                };
//                                MessageModel<string> ret = WmsRequestHelper.SalverMaterialBind(param);
//                                if (ret.success)
//                                {
//                                    alertMsg = $"读取的{rgvLocation.ToString()}位置,发动机码为{_scan_CargoNo},托盘码为{_scan_salverCode},自动组盘请求WMSAPI成功!";
//                                    SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = alertMsg;
//                                    Log4NetHelper.WriteInfoLog(LogType.AutoSalverMaterialBindTask, alertMsg);
//                                }
//                                else
//                                {
//                                    alertMsg = $"读取的{rgvLocation.ToString()}位置,发动机码为{_scan_CargoNo},托盘码为{_scan_salverCode},自动组盘请求WMSAPI失败:WMS返回消息为->{ret.msg}";
//                                    SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = alertMsg;
//                                    Log4NetHelper.WriteInfoLog(LogType.AutoSalverMaterialBindTask, alertMsg);
//                                    Log4NetHelper.WriteErrorLog(LogType.AutoSalverMaterialBindTask, alertMsg, null);
//                                }
//                            }
//                            catch (Exception ex)
//                            {
//                                alertMsg = $"读取的{rgvLocation.ToString()}位置,发动机码为{_scan_CargoNo},托盘码为{_scan_salverCode},自动组盘请求WMSAPI失败:出现异常->{ex.Message}";
//                                SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask = alertMsg;
//                                Log4NetHelper.WriteInfoLog(LogType.AutoSalverMaterialBindTask, alertMsg);
//                                Log4NetHelper.WriteErrorLog(LogType.AutoSalverMaterialBindTask, alertMsg, ex);
//                            }
 
//                        }
//                    }
//                }
//                catch (Exception ex)
//                {
//                    SystemWarningMsg._lbl_alert_AutoSalverMaterialBindTask += "自动组盘 出现异常:" + ex.Message + SysGloble.SPLIT_STR;
//                    Log4NetHelper.WriteErrorLog(LogType.AutoSalverMaterialBindTask, "AutoSalverMaterialBindTask 出现异常:" + ex.Message, ex);
//                }
 
//            }
//        }
//    }
//}