using AngleSharp.Dom; using Mapster; using Masuit.Tools; using SqlSugar; using System.Collections.Generic; using System.Drawing.Printing; using System.Linq.Expressions; using WIDESEA_Core; using WIDESEA_DTO.Basic; using WIDESEA_IStoragIntegrationServices; namespace WIDESEA_StorageBasicService; public class VV_MesLockInfoService : ServiceBase, IVV_MesLockInfoService { private readonly IVV_StockInfoRepository _stockInfoRepository; private readonly IDt_MESLockInfoRepository _MESLockInfoRepository; private readonly IDt_CarBodyInfoRepository _carBodyInfoRepository; private readonly IMESService _MESService; public VV_MesLockInfoService(IVV_MesLockInfoRepository BaseDal, IVV_StockInfoRepository stockInfoRepository, IDt_MESLockInfoRepository MESLockInfoRepository, IDt_CarBodyInfoRepository carBodyInfoRepository, IMESService MESService) : base(BaseDal) { _stockInfoRepository = stockInfoRepository; _MESLockInfoRepository = MESLockInfoRepository; _carBodyInfoRepository = carBodyInfoRepository; _MESService = MESService; } public WebResponseContent GetMesLockInfo() { WebResponseContent content = new WebResponseContent(); try { List mesLockInfos = BaseDal.QueryData(x => x.LockStatue == 1 || x.LockStatue == 0).OrderBy(x => x.sequenceNo).ToList(); List stockInfos = _stockInfoRepository.QueryData(x => x.CarType == 2).OrderBy(x => x.CreateDate).Take(50).ToList(); List mesLockDTOs = new List(); mesLockInfos.ForEach(x => { mesLockDTOs.Add(new MesLockDTO { lockStatue = x.LockStatue, pvi = x.PVI, vehicleCharacteristic = x.vehicleCharacteristic, carBodyCharacteristic = x.carBodyCharacteristic }); }); stockInfos.ForEach(x => { mesLockDTOs.Add(new MesLockDTO { lockStatue = 2, pvi = x.PVI, vehicleCharacteristic = x.vehicleCharacteristic, carBodyCharacteristic = x.carBodyCharacteristic }); }); return content.OK(data: mesLockDTOs); } catch (Exception ex) { return content.Error(ex.Message); } } public WebResponseContent GetStockInfo(string PVI) { WebResponseContent content = new WebResponseContent(); try { VV_StockInfo stockInfos = _stockInfoRepository.QueryFirst(x => x.PVI == PVI); return content.OK(data: stockInfos); } catch (Exception ex) { return content.Error(ex.Message); } } public WebResponseContent MesLock(object[] keys) { WebResponseContent content = new WebResponseContent(); try { List bodyInfos = new List(); List lockinfo = new List(); foreach (var item in keys) { } if (!bodyInfos.Any()) throw new Exception("锁车上报失败:无锁车数据"); var mesLock = _MESLockInfoRepository.QueryFirst(x => x.Id == Convert.ToInt32(keys)); mesLock.LockStatue = 3; //异常锁车 var carInfo = _carBodyInfoRepository.QueryFirst(x => x.Id == mesLock.carBodyID); if (carInfo != null) { bodyInfos.Add(carInfo); lockinfo.Add(mesLock); } WebResponseContent webResponse = _MESService.LockRequest(carInfo, 1); if (webResponse.Status) { _MESLockInfoRepository.UpdateData(lockinfo); content.OK(); } else { content.Error(); } } catch (Exception ex) { content.Error(ex.Message); } return content; } public WebResponseContent MesUnLock(object[] keys) { WebResponseContent content = new WebResponseContent(); try { List bodyInfos = new List(); foreach (var item in keys) { } if (!bodyInfos.Any()) throw new Exception("锁车上报失败:无锁车数据"); var mesLock = _MESLockInfoRepository.QueryFirst(x => x.Id == Convert.ToInt32(keys)); var carInfo = _carBodyInfoRepository.QueryFirst(x => x.Id == mesLock.carBodyID); if (carInfo != null) bodyInfos.Add(carInfo); WebResponseContent webResponse = _MESService.LockRequest(carInfo, 1); if (webResponse.Status) { content.OK(); } else { content.Error(); } } catch (Exception ex) { content.Error(ex.Message); } return content; } }