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}");
|
}
|
}
|
}
|
}
|