zhaojs
2023-09-27 74098f1401afe40f961d1d167bb18dd0a71c4d59
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
using BaiDuSdk;
using CommonUtil;
using CommonUtil.RabbitMQ;
using Newtonsoft.Json.Linq;
using Operater.DAL;
using Operater.DTO.System;
using Operater.Service.System;
using ProductDistribution.Handle;
using System;
using static CommonUtil.RabbitMQ.MQClientFullChannel;
 
namespace ProductDistribution
{
    class Program
    {
 
        /// <summary>
        /// 店铺铺货
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            if (false)
            {
                ProductDistributionMq mq = new ProductDistributionMq()
                {
                    TaskId="1000"
                };
                ProductCheckHandle.MainMethod(mq);
                Console.WriteLine("执行完成");
                Console.ReadLine();
            }
 
 
            Console.Title = "铺货处理";
            //string str = "{\"TaskId\":\"111\"}";
            //HandleExecute(str);
            MainMethod();
        }
 
        public static void HandleExecute(string message)
        {
            Console.WriteLine(message);
            ProductDistributionMq msg = JSONUtil.JsonToObject<ProductDistributionMq>(message);
            switch (msg.TaskType)
            {
                case 1://代发商品铺货单获取
                    Console.WriteLine("代发商品铺货单获取任务");
                    DistributebillGetHandle.MainMethod(msg);
                    break;
                case 2://批量修改
                    Console.WriteLine("批量修改任务");
                    BatchUpdatePriceHandle.MainMethod(msg);
                    break;
                default://铺货
                    Console.WriteLine("铺货任务");
                    ProductDistribute.MainMethod(message);
                    break;
            }
            Console.WriteLine("任务执行完成!");
        }
 
        #region 主方法
        private static void MainMethod()
        {
            try
            {
                MQClientFullChannel mQClientFullChannel = new MQClientFullChannel("product_distribution");
                mQClientFullChannel.reConnectTime = 8000;
                mQClientFullChannel.OnMessage += OnMessage;
                mQClientFullChannel.OnConnected += OnConnected;
                mQClientFullChannel.OnDisConnected += OnDisConnected;
                mQClientFullChannel.Connect(0);
                Console.WriteLine("工具已正常开启--");
                Console.ReadLine();
            }
            catch
            {
 
            }
        }
 
        public static void OnMessage(EventMessageResultCluster result)
        {
 
            HandleExecute(result.Content);
 
        }
 
        public static void OnConnected(MQClientParam param)
        {
            // Console.WriteLine(JSONUtil.ObjectToJson(param) + " --> 链接成功");
        }
 
        public static void OnDisConnected(MQClientParam param)
        {
            // Console.WriteLine(JSONUtil.ObjectToJson(param) + " --> 链接关闭");
        }
        #endregion
 
 
    }
}