刘磊
2026-01-17 f1d726e3de8f15cdfe30d4ca5fbba733d73a1e56
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
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common;
using WIDESEA_Common.MES;
using WIDESEA_Common.MES.Request;
using WIDESEA_Core;
using WIDESEA_Core.Const;
using WIDESEA_Core.Helper;
using WIDESEA_Model.Models;
 
namespace WIDESEA_StoragIntegrationServices
{
    /// <summary>
    /// BDC向MES请求车辆特征信息
    /// 接口描述: BDC在PBS01前一个工位通过(PVI+白车身后4位)向MES请求VIN+车辆特征信息写入tag
    /// </summary>
    public partial class MESService
    {
        /// <summary>
        ///  BDC请求车辆特征信息
        /// </summary>
        /// <param name="rfidPrint">RFID</param>
        /// <param name="stationNo">站台请求点位</param>
        /// <returns></returns>
        public WebResponseContent getCharacteristic(string stationNo, string rfidPrint)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                CarCharacteristicInfo characterInfo = new CarCharacteristicInfo()
                {
                    plantCode = "1052",
                    rfidPrint = rfidPrint,
                    vin = "",
                    messageTime = DateTime.Now.ToString(),
                    unionKey = Guid.NewGuid().ToString(),
                };
 
                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.getCharacteristic)?.ConfigValue;
                if (wmsBase == null || ipAddress == null)
                {
                    throw new InvalidOperationException("WMS IP 未配置");
                }
                var wmsIpAddress = wmsBase + ipAddress;
 
                var MESrespon = HttpHelper.PostAsync(wmsIpAddress, characterInfo.ToJson()).Result;
 
                GetCarCharacteristicInfo characterRespon = JsonConvert.DeserializeObject<GetCarCharacteristicInfo>(MESrespon);
                if (!characterRespon.success)
                {
                    throw new Exception($"{characterRespon}");
                }
 
                LogFactory.GetLog("BDC请求车辆特征信息").Info(true, $"\r\r--------------------------------------");
                LogFactory.GetLog("BDC请求车辆特征信息").Info(true, $"工位号:{stationNo},RFID:{rfidPrint}");
 
                return content;
            }
            catch (Exception ex)
            {
                return content.Error($"BDC请求车辆特征信息::{ex.Message}");
            }
        }
    }
}