| | |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Const; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEAWCS_BasicInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | |
| | | /// </summary> |
| | | public partial class MESService |
| | | { |
| | | public WebResponseContent Lock(object jsondata) |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="carBody">䏿¥é车ç车身信æ¯</param> |
| | | /// <param name="operationType">䏿¥ç±»åï¼1-å¼å¸¸é车 2-å¼å¸¸æ¢å¤</param> |
| | | /// <returns></returns> |
| | | 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.bindWorkOrder)?.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 carBodyInfo = _carBodyRepository.QueryFirst(x => x.RFID == ""); |
| | | |
| | | if (carBodyInfo == null) throw new Exception($"æªæ¾å°PVIçè½¦èº«æ°æ®"); |
| | | |
| | | BindWorkOrder bindOrder = new BindWorkOrder() |
| | | { |
| | | unionKey = Guid.NewGuid().ToString(), |
| | | stationCode = "", |
| | | messageTime = DateTime.Now.ToString(), |
| | | plantCode = "1052", |
| | | pvi = carBodyInfo.PVI, |
| | | }; |
| | | |
| | | var MESrespon = HttpHelper.PostAsync(wmsIpAddress, bindOrder.ToJson(), contentType, headers).Result; |
| | | var MESrespon = HttpHelper.PostAsync(wmsIpAddress, lockInfo.ToJson(), contentType, headers).Result; |
| | | |
| | | Console.WriteLine(MESrespon); |
| | | WebResponseContent webResponse = JsonConvert.DeserializeObject<WebResponseContent>(MESrespon.ToString()); |
| | |
| | | throw new Exception($"{webResponse.msg}"); |
| | | } |
| | | |
| | | BindWorkOrderRespon characterRespon = JsonConvert.DeserializeObject<BindWorkOrderRespon>(webResponse.Data.ToJson()); |
| | | LockInfoRespon characterRespon = JsonConvert.DeserializeObject<LockInfoRespon>(webResponse.Data.ToJson()); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | LogFactory.GetLog("éè½¦ä¸æ¥").Info(true, $"\r\r--------------------------------------"); |
| | | LogFactory.GetLog("éè½¦ä¸æ¥").Info(true, jsondata.ToJsonString()); |
| | | |
| | | 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); |
| | | } |
| | | } |