using Newtonsoft.Json; using WIDESEA_Common; using WIDESEA_Common.MES; using WIDESEA_Core; using WIDESEA_Core.Const; using WIDESEA_Core.Helper; using WIDESEA_DTO; using WIDESEA_StorageBasicRepository; namespace WIDESEA_StoragIntegrationServices { public partial class MESService { /// /// 车身过点 /// /// /// 扫二维码信息 /// /// public WebResponseContent PassPoint(RequestTaskDto json) { WebResponseContent content = new WebResponseContent(); try { 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.AVIPASS)?.ConfigValue; if (wmsBase == null || ipAddress == null) { throw new InvalidOperationException("WMS IP 未配置"); } var wmsIpAddress = wmsBase + ipAddress; var carBodyInfo = _carBodyRepository.QueryFirst(x => x.RFID == json.PVI); if (carBodyInfo == null) throw new Exception($"未找到PVI{json.PVI}的车身数据"); //将白车身更新成彩车身 //carBodyInfo.CarType = 2; //_carBodyRepository.UpdateData(carBodyInfo); var stationInfo = _stationManagerRepository.QueryFirst(x => x.stationChildCode == json.Position); if (stationInfo == null) throw new Exception($"请求车身过点失败:点位{json.Position}未找到"); PassPointInfo passPoint = new PassPointInfo() { union_key = Guid.NewGuid().ToString(), line_code = stationInfo.stationEquipMES, //todo 需替换成点位信息时对应MES点位 message_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), plant_code = "1052", pvi = json.PVI, station_code = stationInfo.stationEquipMES, vin = "", pass_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; var MESrespon = HttpHelper.PostAsync(wmsIpAddress, passPoint.ToJson(), contentType, headers).Result; MesResponse responseContent = JsonConvert.DeserializeObject(MESrespon.ToString()); if (responseContent.code != 200) { //if (!responseContent.message.Contains("重复报工")) throw new Exception($"车身过点异常:{responseContent.message}"); } LogFactory.GetLog("车身过点").Info(true, $"\r\r--------------------------------------"); LogFactory.GetLog("车身过点").Info(true, $"工位号:{json.Position},RFID:{json.PVI},响应信息:{responseContent.ToJson}"); return content.OK(); } catch (Exception ex) { LogFactory.GetLog("车身过点").Info(true, $"\r\r--------------------------------------"); LogFactory.GetLog("车身过点").Info(true, $"工位号:{json.Position},RFID:{json.PVI},异常信息:{ex.Message}"); return content.Error(ex.Message); } } } }