Tiandele
2026-03-20 daea1a90c2fa1b5cc2f52e62be15bd95cc4155f6
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
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
    {
        public WebResponseContent issuedCharacter(string rfidPrint, string stationNo, string palletCode)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                IssuedCharacterInfo characterInfo = new IssuedCharacterInfo()
                {
                    plantCode = "1052",
                    rfidPrint = rfidPrint,
                    vin = null,
                    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.PostAsync(wmsIpAddress, characterInfo.ToJson(), contentType, headers).Result;
                Console.WriteLine(MESrespon);
                WebResponseContent webResponse = JsonConvert.DeserializeObject<WebResponseContent>(MESrespon.ToString());
                if (webResponse.Code != 200)
                {
                    throw new Exception($"{webResponse.msg}");
                }
 
                IssuedCharacterRespon characterRespon = JsonConvert.DeserializeObject<IssuedCharacterRespon>(webResponse.Data.ToJson());
 
                Dt_CarBodyInfo CarBody = new Dt_CarBodyInfo()
                {
                    biwInPassTime = Convert.ToDateTime(characterRespon.biwInPassTime),
                    biwMaterialCode = characterRespon.biwMaterialCode,
                    skylightCharacteristic = characterRespon.skylightCharacteristic,
                    vehicleCharacteristic = characterRespon.vehicleCharacteristic,
                    workOrderNo = characterRespon.workOrderNo,
                    workOrderType = characterRespon.workOrderType,
                    BodyStatus = 1,
                    CarType = stationNo == "EL01RB01" ? 2 : 1,
                    CreateDate = DateTime.Now,
                    Creater = "System",
                    Description = "",
                    PalletCode = palletCode,
                    PVI = characterRespon.pvi,
                    RFID = rfidPrint
                };
 
                _carBodyRepository.AddData(CarBody);
 
                LogFactory.GetLog("请求焊装特征信息").Info(true, $"\r\r--------------------------------------");
                LogFactory.GetLog("请求焊装特征信息").Info(true, $"工位号:{stationNo},RFID:{rfidPrint},响应信息:{webResponse.ToJson()}");
 
 
                return content.OK("获取焊装白车身信息成功");
            }
            catch (Exception ex)
            {
                LogFactory.GetLog("请求焊装特征信息").Info(true, $"请求焊装特征信息异常RFID:{rfidPrint}异常信息:{ex.Message}");
                return content.Error($"请求焊装特征信息异常::{ex.Message}");
            }
        }
    }
}