杨前锦
4 天以前 06a8b6963d6d4f229d4e196b4b09ce57e2cbf2dd
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
using HH.WCS.Mobox3.YNJT_BZP_GT.api;
using HH.WCS.Mobox3.YNJT_BZP_GT.device;
using HH.WCS.Mobox3.YNJT_BZP_GT.dispatch;
using HH.WCS.Mobox3.YNJT_BZP_GT.models;
using HH.WCS.Mobox3.YNJT_BZP_GT.process;
using HH.WCS.Mobox3.YNJT_BZP_GT.util;
using HH.WCS.Mobox3.YNJT_BZP_GT.wms;
using Newtonsoft.Json;
using SqlSugar.DistributedSystem.Snowflake;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using static HH.WCS.Mobox3.YNJT_BZP_GT.dispatch.WMSDispatch;
 
namespace HH.WCS.Mobox3.YNJT_BZP_GT.core
{
    /// <summary>
    /// 定时轮询任务
    /// </summary>
    internal class Monitor
    {
 
        /// <summary>
        /// 同步物料条码信息表
        /// 1.查询上次记录时间
        /// 2.根据记录时间,查询大于等于记录时间的物料条码信息
        /// 3.将物料条码信息同步到wms
        /// </summary>
        internal static void MonitorMatlBarcode() {
            try
            {
                var lastTimeStr = WMSDispatch.findDataLastSynTime(new SynTableModel() { tableType = 1 });
                if (lastTimeStr != null)
                {
                    if (DateTime.TryParse(lastTimeStr, out DateTime lastTime))
                    {
                        /* CultureInfo enGB = new CultureInfo("en-GB");*/
                        var maltInformations = WMSHelper.getMaltInfoList(lastTime);
                        if (maltInformations != null && maltInformations.Count > 0)
                        {
                            WMSDispatch.synMatlInformation(new SynMatlInformationModel() { matlInformationList = maltInformations });
                        }
                    }
                    else 
                    {
                        LogHelper.Info($"同步物料条码信息错误,错误原因:日期解析错误", "WMS");
                    }
                }      
            }
            catch (Exception ex)
            {
                LogHelper.Info($"同步物料条码信息错误,错误原因:{ex.Message}", "WMS");
            }
        }
 
        /// <summary>
        /// 同步半制品物料状态
        /// 1.查询上次记录时间
        /// 2.根据记录时间,查询大于等于记录时间,且符合条件的物料状态信息
        /// 3.将物料条码信息同步到wms
        /// </summary>
        internal static void MonitorMatlStatus()
        {
            try
            {
                var lastTimeStr = WMSDispatch.findDataLastSynTime(new SynTableModel() { tableType = 2 });
                if (lastTimeStr != null)
                {
                    if (DateTime.TryParse(lastTimeStr, out DateTime lastTime))
                    {
                        /* CultureInfo enGB = new CultureInfo("en-GB");*/
                        var barcodeStatuses = WMSHelper.getMaltStatusList(lastTime);
                        if (barcodeStatuses != null && barcodeStatuses.Count > 0)
                        {
                            WMSDispatch.synUpdateMatlStatus(new SynBarcodeStatusModel() { barcodeStatusList = barcodeStatuses });
                        }
                    }
                    else 
                    {
                        LogHelper.Info($"同步半制品物料状态错误,错误原因:日期解析错误", "WMS");
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Info($"同步半制品物料状态错误,错误原因:{ex.Message}", "WMS");
            }
        }
 
        /// <summary>
        /// 同步半制品抽检物料状态
        /// </summary>
        internal static void MonitorSpotCheckMatlStatus()
        {
            try
            {
                var lastTimeStr = WMSDispatch.findDataLastSynTime(new SynTableModel() { tableType = 3 });
                if (lastTimeStr != null)
                {
                    if (DateTime.TryParse(lastTimeStr, out DateTime lastTime))
                    {
                        /* CultureInfo enGB = new CultureInfo("en-GB");*/
                        var sampleStatuses = WMSHelper.getSampleMaltStatusList(lastTime);
                        if (sampleStatuses != null && sampleStatuses.Count > 0)
                        {
                            WMSDispatch.synUpdateSampleMatlStatus(new SynSampleStatusModel() { sampleStatusList = sampleStatuses });
                        }
                    }
                    else
                    {
                        LogHelper.Info($"同步半制品抽检物料状态错误,错误原因:日期解析错误", "WMS");
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Info($"同步半制品物料状态错误,错误原因:{ex.Message}", "WMS");
            }
        }
 
    }
}