2
schangxiang@126.com
2024-11-22 76fc40d4f1e0dbd15383c0f3e29fd8bcb6dcff2a
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
using Admin.NET.Application;
using iWareCC.Common.Helper;
using iWareCC.StationService;
using iWareCommon.Common.Globle;
using iWareCommon.Utils;
using iWareModel;
using iWareSql.DataAccess;
using iWareSql.DBModel;
using iWareSql.WmsDBModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Configuration;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using WZ.Useful.Commons;
using XiGang.Core.Model;
 
namespace iWareCC.ThreadService
{
    /// <summary>
    /// 机器人缓存岛 模式切换 处理
    /// </summary>
    public static class DataProcess_RobotBuffer_ModeChange
    {
        public static async void Handler()
        {
            var alertMsg = "";
            LogType logType = LogType.DataProcess_BZ39;
            while (true)
            {
                Thread.Sleep(2000);//休眠2秒,将休眠写到前面,是为了下面的continue方法执行后不显示错误信息的提示!!!【EditBy shaocx,2022-05-24】
                SystemWarningMsg._lbl_alert_DataProcess_BZ39 = string.Empty;
                try
                {
                    if (SystemValue.isAllowRuning_DataProcess_BZ39 && SystemValue.isStartedModel)
                    {
 
                        if (FormCC.IsAllowRunOutMode)
                        {
                            using (WmsDBModel wmsDB = new WmsDBModel())
                            {
                                var rbRunMode = wmsDB.wms_rbline_runmode.FirstOrDefault();
                                if (rbRunMode.LineRunMode == (int)RbRunModeEnum.出库模式)
                                {
                                    SystemWarningMsg._lbl_alert_DataProcess_BZ39 = $"已经是出库模式了,此次循环结束";
                                    continue;
                                }
                                rbRunMode.LineRunMode = (int)RbRunModeEnum.出库模式;
                                rbRunMode.LineRunModeName = RbRunModeEnum.出库模式.ToString();
                                rbRunMode.UpdateTime = DateTime.Now;
 
                                //推送给PLC切换模式
                                //using (StationServiceClient client = new StationServiceClient())
                                //{
                                //    var res = await client.WriteOutStoreTaskInfoAsync((int)EDevice.Station, rgvLocation, doTask.PlaceCode, Convert.ToInt32(doTask.TaskNo));
                                //    if (!res.result)
                                //    {
                                //        SystemWarningMsg._lbl_alert_DataProcess_BZ39 = $"{rgvLocation.ToString()}-下发出库任务 失败,WriteOutStoreTaskInfoAsync 返回:{res.resMsg}";
                                //        continue;
                                //    }
                                //    else
                                //    {
                                //        Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发出库任务 成功,WriteOutStoreTaskInfoAsync,参数: 站点{rgvLocation}");
                                //    }
                                //}
 
 
                                wmsDB.SaveChanges();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    SystemWarningMsg._lbl_alert_DataProcess_BZ39 += " 出现异常:" + ex.Message + SysGloble.SPLIT_STR;
                    Log4NetHelper.WriteErrorLog(logType, " 出现异常:" + ex.Message, ex);
                }
            }
        }
 
    }
}