wangxinhui
2024-09-23 a3eb67538c4716aef9967f1e6301720cce095e3c
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
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using WIDESEA_Common.Tools;
using WIDESEA_Core.Utilities;
using WIDESEA_Entity.DomainModels.Mes;
using WIDESEA_WCS.JobsPart.Public;
using WIDESEA_WCS.WCSClient;
 
namespace WIDESEA_WCS
{
    public partial class ToMesServer
    {
        public static List<string> ZhengJiTiShenji = new List<string>()
        {
            "提升机2", "提升机3"
        };
 
        public static List<string> FuJiTiShenji = new List<string>()
        {
            "提升机4", "提升机5"
        };
 
        /// <summary>
        /// 三楼叫料临时
        /// </summary>
        /// <param name="requestTemp"></param>
        /// <returns></returns>
        public WebResponseContent Float3Rquired(MesRequestTemp requestTemp)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                if (WCSService.Clients == null)
                {
                    throw new Exception("服务未启动!");
                }
                bool haveAdd = false;
                List<PLCClient> clientList = null;
 
                if (requestTemp.TiArea == "正极")
                {
                    clientList = WCSService.Clients.Where(t => ZhengJiTiShenji.Contains(t.PLCName)).ToList();
                }
                else if (requestTemp.TiArea == "负极")
                {
                    clientList = WCSService.Clients.Where(t => FuJiTiShenji.Contains(t.PLCName)).ToList();
                }
                foreach (var item in clientList)
                {
                    var stationStatus = (byte[])item.ReadDBValue("DB6.1293", 1);
                    if (stationStatus[0] == 0x0)
                    {
                        //上料
                        var station = centerEqDBList.FirstOrDefault(t => t.tiShenJiName == item.PLCName)
                            ?.stationInfos.FirstOrDefault(t => t.tiShenJiUniCode == 4);
                        WCSCommon.CreateTask(station, true, requestTemp.Type);
                        haveAdd = true;
                        break;
                    }
                }
                if (haveAdd)
                {
                    content.OK();
                }
                else
                {
                    throw new Exception("当前提升机无空闲入口");
                }
            }
            catch (Exception ex)
            {
                WriteLog.GetLog().Write($"【error】{ex.Message}\n{JsonConvert.SerializeObject(requestTemp)}" + "\n", "三楼模拟叫料");
                content.Error(ex.Message);
            }
            return content;
        }
    }
}