刘磊
2025-11-17 efbeb93b3d454f06d65dbcc68ad828cc95bc9404
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
using Newtonsoft.Json;
using WIDESEA_Common;
using WIDESEA_Core;
using WIDESEA_Core.Const;
using WIDESEA_Core.Helper;
 
namespace WIDESEA_StoragIntegrationServices
{
    /// <summary>
    /// 车身过点请求
    /// </summary>
    public partial class MESService
    {
        public WebResponseContent PassPoint(string stationCode)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_MESIPAddress);
                var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MESIPAddress)?.ConfigValue;
                var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.PassPoint)?.ConfigValue;
                if (wmsBase == null || ipAddress == null)
                {
                    throw new InvalidOperationException("WMS IP 未配置");
                }
                var wmsIpAddress = wmsBase + ipAddress;
 
                var stationInfo = _stationManagerRepository.QueryFirst(x => x.stationChildCode == stationCode);
 
                PassPointInfo passPoint = new PassPointInfo()
                {
                    union_key = Guid.NewGuid().ToString(),
                    line_code = stationInfo.stationChildCode,
                    message_time = DateTime.Now,
                    plant_code = "",
                    pvi = "",
                    station_code = stationInfo.stationChildCode,
                    vin = "",
                    pass_time = DateTime.Now
                };
 
                var MESrespon = HttpHelper.Post(wmsIpAddress, passPoint.ToJson());
 
                WebResponseContent responseContent = JsonConvert.DeserializeObject<WebResponseContent>(MESrespon);
                if (!responseContent.Status)
                {
                    throw new Exception($"车身过点异常:{responseContent.Message}");
                }
 
                return content;
            }
            catch (Exception ex)
            {
                return content.Error(ex.Message);
            }
        }
    }
}