刘磊
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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.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请求焊装特征下发
    /// 接口描述: 车身进入BDC时,BDC读取车身上的一维条码向MES请求焊装特征信息
    /// </summary>
    public partial class MESService
    {
        /// <summary>
        ///  BDC请求焊装特征信息
        /// </summary>
        /// <param name="rfidPrint">RFID</param>
        /// <param name="vin">VIN号</param>
        /// <param name="stationNo">站台请求点位</param>
        /// <returns></returns>
        public WebResponseContent issuedCharacter(string rfidPrint, string vin, string stationNo)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                IssuedCharacterInfo characterInfo = new IssuedCharacterInfo()
                {
                    plantCode = "1022",
                    rfidPrint = rfidPrint,
                    vin = vin,
                    messageTime = DateTime.Now
                };
 
                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.IssuedCharacter)?.ConfigValue;
                if (wmsBase == null || ipAddress == null)
                {
                    throw new InvalidOperationException("WMS IP 未配置");
                }
                var wmsIpAddress = wmsBase + ipAddress;
 
                var MESrespon = HttpHelper.Post(wmsIpAddress, characterInfo.ToJson());
 
                IssuedCharacterRespon characterRespon = JsonConvert.DeserializeObject<IssuedCharacterRespon>(MESrespon);
                if (!characterRespon.success)
                {
                    throw new Exception($"{characterRespon}");
                }
 
                Dt_CarBody CarBody = new Dt_CarBody()
                {
                    BodyStatus = "",
                    CarType = 1,
                    CreateDate = DateTime.Now,
                    Creater = "system",
                    Description = "",
                    PalletCode = rfidPrint,
                    PVI = characterRespon.rfidPrint
                };
 
                _carBodyRepository.AddData(CarBody);
                return content;
            }
            catch (Exception ex)
            {
                return content.Error($"请求焊装特征信息异常::{ex.Message}");
            }
        }
    }
}