schangxiang@126.com
2025-09-17 ff43ddf18764629ff875478e4e47a7281cbd230a
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
using iWareCommon;
using iWareCommon.Utils;
using iWareSql.MyDbContext;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
 
namespace iWareCC
{
    /// <summary>
    /// 库存快照
    /// </summary>
    public class InventorySnapshotHandler
    {
        public static string host = ConfigHelper.GetConfigString("WmsApiHost");
        //public static DateTime? dateTime = null;
        private static bool isHasRunHour1_Task = false;//是否执行了 每天1点的任务
        private static bool isHasRunHour23_Month_Task = false;//是否执行了 每个月底的23点执行一次的任务
 
        public static void Handler()
        {
            SystemWarningMsg._lbl_Alert_InventorySnapshotHandler = "线程启动了。。。。";
            Log4NetHelper.WriteInfoLog(LogType.InventorySnapshotHandler, "库存快照线程启动了。。。。");
 
            while (true)
            {
                Thread.Sleep(10000);//休眠10秒
                try
                {
 
                    if (SystemValue.isAllowRuning_InventorySnapshotHandler && SystemValue.isStartedModel)
                    {
                        #region 每天1点执行一次
 
                        //每天1点执行一次
                        if (DateTime.Now.Hour == 1)
                        {//1点的时刻
                            if (isHasRunHour1_Task == false)
                            {
                                isHasRunHour1_Task = true;
 
                                _Getcurrentstock();
 
                            }
                        }
                        else
                        {//非1点的时刻
                            isHasRunHour1_Task = false;
                        }
 
                        #endregion
                    }
 
                }
                catch (Exception ex)
                {
                    SystemWarningMsg._lbl_Alert_InventorySnapshotHandler = "库存快照异常" + ex.Message;
                    Log4NetHelper.WriteErrorLog(LogType.InventorySnapshotHandler, "库存快照) 出现异常:" + ex.Message, ex);
                }
            }
        }
 
 
 
 
        /// <summary>
        /// 增加库存快照
        /// </summary>
        private static void _Getcurrentstock()
        {
            try
            {
                //增加库存快照
                //var result = HttpHelper.Post(host + "inventory/material/getcurrentstock", "");
                //Log4NetHelper.WriteInfoLog(LogType.InventorySnapshotHandler, "库存快照" + result);
            }
            catch (Exception ex)
            {
                SystemWarningMsg._lbl_Alert_InventorySnapshotHandler = "库存快照异常" + ex.Message;
                Log4NetHelper.WriteErrorLog(LogType.InventorySnapshotHandler, "库存快照异常) 出现异常:" + ex.Message, ex);
 
            }
        }
 
        ///// <summary>
        ///// 库存预警
        ///// </summary>
        //private static void _Handlestockwarning()
        //{
        //    try
        //    {
        //        //库存预警
        //        HttpHelper.Post(host + "WareNotifications/handlestockwarning", "");
        //    }
        //    catch (Exception ex)
        //    {
        //        SystemWarningMsg._lbl_Alert_InventorySnapshotHandler = "库存提醒异常" + ex.Message;
        //        Log4NetHelper.WriteErrorLog(LogType.InventorySnapshotHandler, "库存提醒异常) 出现异常:" + ex.Message, ex);
        //    }
        //}
 
 
 
    }
 
    public class DeliveryOrderDeleteInput
    {
        public string[] OrderNo { get; set; }
    }
}