using AngleSharp.Common; using Masuit.Tools; using Newtonsoft.Json; using System; using System.Collections.Generic; 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; using WIDESEAWCS_BasicInfoService; using WIDESEAWCS_Model.Models; namespace WIDESEA_StoragIntegrationServices { /// /// 锁车上报 /// public partial class MESService { /// /// /// /// 上报锁车的车身信息 /// 上报类型:1-异常锁车 2-异常恢复 /// public WebResponseContent LockRequest(Dt_CarBodyInfo carBody, int operationType) { WebResponseContent content = new WebResponseContent(); try { lockInfo lockInfo = new lockInfo() { unionKey = Guid.NewGuid().ToString(), plantCode = "1052", sendStatus = operationType.ToString(), messageTime = DateTime.Now.ToString(), insertWorkOrder = "", }; 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.LockRequest)?.ConfigValue; if (wmsBase == null || ipAddress == null) { throw new InvalidOperationException("WMS IP 未配置"); } var wmsIpAddress = wmsBase + ipAddress; var MESrespon = HttpHelper.PostAsync(wmsIpAddress, lockInfo.ToJson(), contentType, headers).Result; Console.WriteLine(MESrespon); WebResponseContent webResponse = JsonConvert.DeserializeObject(MESrespon.ToString()); if (webResponse.Code != 200) { throw new Exception($"{webResponse.msg}"); } LockInfoRespon characterRespon = JsonConvert.DeserializeObject(webResponse.Data.ToJson()); _unitOfWorkManage.BeginTran(); LogFactory.GetLog("锁车上报").Info(true, $"\r\r--------------------------------------"); LogFactory.GetLog("锁车上报").Info(true, lockInfo.ToJsonString()); _unitOfWorkManage.CommitTran(); return content.OK(); } catch (Exception ex) { LogFactory.GetLog("锁车上报").Info(true, "上报异常" + carBody.ToJsonString()); return content.Error(ex.Message); } } } }