From a19d2fd7d9f52f7daa15b32d434cb86fa7ffb30b Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周一, 09 9月 2024 14:38:34 +0800 Subject: [PATCH] 去掉不用的代码 --- iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterface/AccessInterfaceService.cs | 110 ++++++++++++++++++++++++++++++++----------------------- 1 files changed, 64 insertions(+), 46 deletions(-) diff --git a/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterface/AccessInterfaceService.cs b/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterface/AccessInterfaceService.cs index 7607dfc..40d8328 100644 --- a/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterface/AccessInterfaceService.cs +++ b/iWara.SCADA.Code/iWare.Wms.Application/Service/AccessInterface/AccessInterfaceService.cs @@ -48,6 +48,7 @@ private readonly IHttpContextAccessor _httpContextAccessor; private readonly IRepository<WorkPieceProcess, MasterDbContextLocator> _workPieceProcessRep; private readonly IAccessInterfaceLogService _accessInterfaceLog; + private readonly IAccessInterfaceLogForRequestService _accessInterfaceLogForRequest; private readonly IRepository<WorkPieceInfoLog, MasterDbContextLocator> _WorkPieceInfoLog; private readonly IRepository<EquipmentCurrentMonitor, MasterDbContextLocator> _equipmentCurrentMonitorRep; private readonly IRepository<EquipmentBaseInfo, MasterDbContextLocator> _equipmentBaseInfoRep; @@ -63,20 +64,23 @@ /// <param name="workPieceInfoRep"></param> /// <param name="httpContextAccessor"></param> /// <param name="accessInterfaceLog"></param> - public AccessInterfaceService(IRepository<QualityDataInfo, MasterDbContextLocator> qualityDataInfoRep, + public AccessInterfaceService( + IAccessInterfaceLogForRequestService accessInterfaceLogForRequest, + IRepository<QualityDataInfo, MasterDbContextLocator> qualityDataInfoRep, IRepository<QualityDataInfoLog, MasterDbContextLocator> qualityDataInfoLogRep, IRepository<WorkPieceInfo, MasterDbContextLocator> workPieceInfoRep, IHttpContextAccessor httpContextAccessor, IAccessInterfaceLogService accessInterfaceLog, IRepository<ThreadStatusMonitor, MasterDbContextLocator> threadStatusMonitorRep, IRepository<DataCaptureConfig, MasterDbContextLocator> dataCaptureConfigRep, - IRepository<WorkPieceProcess, MasterDbContextLocator> workPieceProcessRep, WorkPieceInfoService WorkPieceInfoService, - IRepository<WorkPieceInfoLog, MasterDbContextLocator> workPieceInfoLog, - IRepository<EquipmentCurrentMonitor, MasterDbContextLocator> equipmentCurrentMonitorRep, + IRepository<WorkPieceProcess, MasterDbContextLocator> workPieceProcessRep, WorkPieceInfoService WorkPieceInfoService, + IRepository<WorkPieceInfoLog, MasterDbContextLocator> workPieceInfoLog, + IRepository<EquipmentCurrentMonitor, MasterDbContextLocator> equipmentCurrentMonitorRep, IRepository<EquipmentBaseInfo, MasterDbContextLocator> equipmentBaseInfoRep, ISysDictTypeService dict , IRepository<ProductionPlanInfo, MasterDbContextLocator> productionPlanInfoRep , IRepository<ShiftInfo, MasterDbContextLocator> shiftInfoRep) { + _accessInterfaceLogForRequest = accessInterfaceLogForRequest; _qualityDataInfoRep = qualityDataInfoRep; _qualityDataInfoLogRep = qualityDataInfoLogRep; _workPieceInfoRep = workPieceInfoRep; @@ -127,9 +131,10 @@ { addLog.IpAddress = ipAddress.MapToIPv4().ToString(); } + AddQualityDataInfoInputV2 input = null; try { - var input = JsonConvert.DeserializeObject<AddQualityDataInfoInputV2>(json); + input = JsonConvert.DeserializeObject<AddQualityDataInfoInputV2>(json); addLog.Key = input.WorkPieceID; if (input == null || string.IsNullOrEmpty(input.WorkPieceID) || input.QualityState == 0) @@ -277,7 +282,7 @@ } updateinfo.WorkPieceState = (int)WorkPieceState.WIP;//鎺ㄥ嚭鍚庡拰SPC鎶芥鍚� 璐ㄩ噺褰曞叆鏃剁姸鎬佷慨鏀瑰洖鍦ㄥ埗鍝� updateinfo.QualityState = (int)EnumQualityState.Suspected; - updateinfo.QualityErrorInfo = $"宸ヤ欢{update.WorkPieceID}鍦ㄥ伐搴弡input.WorkingProcedure}鎶芥涓嶅悎鏍硷紝鐩稿叧宸ヤ欢璐ㄩ噺鐘舵�佸彉鏇翠负鐤戜技";; + updateinfo.QualityErrorInfo = $"宸ヤ欢{update.WorkPieceID}鍦ㄥ伐搴弡input.WorkingProcedure}鎶芥涓嶅悎鏍硷紝鐩稿叧宸ヤ欢璐ㄩ噺鐘舵�佸彉鏇翠负鐤戜技"; ; updateinfo.QualityStateUpdateUser = input.QualityStateUpdateUser; updateinfo.QualityStateUpdateTime = now; updateinfo.QualityStateUpdateMode = EnumQualityStateUpdateMode.SPC.ToString(); @@ -299,6 +304,9 @@ { try { + addLog.WorkPieceID = input?.WorkPieceID; + addLog.WorkingProcedureCurrent = input?.WorkingProcedure; + addLog.QualityState = input?.QualityState; await _accessInterfaceLog.AddInterfaceLogAsync(addLog); } @@ -320,7 +328,7 @@ [HttpGet("GetWorkingProcedureForID")] public async Task<AccessWorPieceInfoOutput> GetWorkingProcedureForID([FromQuery] AccessWorkPieceInfoInput input) { - AddAccessInterfaceLogInput addLog = new(); + AddAccessInterfaceLogForRequestInput addLog = new(); addLog.JsonString = JsonConvert.SerializeObject(input); addLog.Action = 2; addLog.Key = input.WorkPieceID; @@ -334,7 +342,9 @@ if (input == null || string.IsNullOrEmpty(input.WorkPieceID)) { addLog.Result = "浼犲叆鍙傛暟寮傚父锛氬伐浠跺彿涓嶈兘涓虹┖锛�"; - await _accessInterfaceLog.AddInterfaceLogAsync(addLog); + //await _accessInterfaceLog.AddInterfaceLogAsync(addLog); + //鏇挎崲[Editby shaocx,2024-09-04] + await _accessInterfaceLogForRequest.AddInterfaceLogForRequestAsync(addLog); throw Oops.Oh(addLog.Result); } @@ -343,14 +353,18 @@ if (workPieceInfo == null) { addLog.Result = $"浼犲叆鍙傛暟寮傚父锛氬伐浠跺彿{input.WorkPieceID}涓嶈兘鎵惧埌鎸囧畾宸ヤ欢锛�"; - await _accessInterfaceLog.AddInterfaceLogAsync(addLog); + //await _accessInterfaceLog.AddInterfaceLogAsync(addLog); + //鏇挎崲[Editby shaocx,2024-09-04] + await _accessInterfaceLogForRequest.AddInterfaceLogForRequestAsync(addLog); throw Oops.Oh(addLog.Result); } var re = workPieceInfo.Adapt<AccessWorPieceInfoOutput>(); addLog.Result = re; - await _accessInterfaceLog.AddInterfaceLogAsync(addLog); + //await _accessInterfaceLog.AddInterfaceLogAsync(addLog); + //鏇挎崲[Editby shaocx,2024-09-04] + await _accessInterfaceLogForRequest.AddInterfaceLogForRequestAsync(addLog); return re; } @@ -392,7 +406,7 @@ .ProjectToType<EquipmentCurrentMonitorOutputV2>() .OrderBy(o => o.EquipmentID) .ToListAsync(); - + return equipmentCurrentMonitors; } @@ -406,10 +420,10 @@ List<ProduceCompletionStatus> list = new List<ProduceCompletionStatus>(); //鑾峰彇褰撳墠骞寸殑绗竴澶� - var yearOneDay= DateTime.Now.AddDays(-((int)DateTime.Now.DayOfYear - 1)).Date; + var yearOneDay = DateTime.Now.AddDays(-((int)DateTime.Now.DayOfYear - 1)).Date; //鑾峰彇鏈堜唤璁″垝 var productionPlanInfos = _productionPlanInfoRep.DetachedEntities - .Where(o=>o.IsDeleted==false&& o.PlanType.Equals("2")).ToList(); + .Where(o => o.IsDeleted == false && o.PlanType.Equals("2")).ToList(); try { //鑾峰彇鏈�杩戜竴骞翠笅绾垮伐浠剁殑鎴愬搧 @@ -444,7 +458,7 @@ } } - catch(Exception ex) + catch (Exception ex) { } @@ -465,17 +479,17 @@ var day = DateTime.Now.ToString("yyyy-MM-dd"); //鑾峰彇褰撳墠鏈堜唤璁″垝 var productionPlanInfos = _productionPlanInfoRep.DetachedEntities.ProjectToType<ProductionPlanInfoOutput>().ToList() - .Where(o => o.PlanType.Equals("2")&& o.PlanTimeHand.Equals(month)).FirstOrDefault(); + .Where(o => o.PlanType.Equals("2") && o.PlanTimeHand.Equals(month)).FirstOrDefault(); //鑾峰彇鏈�杩戞湀涓嬬嚎宸ヤ欢鐨勬垚鍝� try { - var MonthCompletionnNum = _workPieceInfoRep.DetachedEntities.ProjectToType<WorkPieceInfoOutput>().ToList() - .Where(o => o.WorkPieceLastOfflineTimeHand.Equals(month) - && o.WorkPieceState == (int)WorkPieceState.FinishedProducts).Count(); + var MonthCompletionnNum = _workPieceInfoRep.DetachedEntities.ProjectToType<WorkPieceInfoOutput>().ToList() + .Where(o => o.WorkPieceLastOfflineTimeHand.Equals(month) + && o.WorkPieceState == (int)WorkPieceState.FinishedProducts).Count(); currentProduceInfo.CurrentMonthProduceNum = MonthCompletionnNum; } - catch(Exception ex) + catch (Exception ex) { } @@ -485,13 +499,13 @@ && o.WorkPieceState == (int)WorkPieceState.FinishedProducts).Count(); //鑾峰彇鐝鐝粍淇℃伅 - var shiftlist = _shiftInfoRep.DetachedEntities.ProjectToType<ShiftInfoOutput>().ToList().Where(o=>o.StartTime<DateTime.Now&&o.EndTime> DateTime.Now).FirstOrDefault(); + var shiftlist = _shiftInfoRep.DetachedEntities.ProjectToType<ShiftInfoOutput>().ToList().Where(o => o.StartTime < DateTime.Now && o.EndTime > DateTime.Now).FirstOrDefault(); currentProduceInfo.CurrentShiftProduceNum = DayCompletionnNum; currentProduceInfo.CurrentShiftPlanNum = 0; - currentProduceInfo.CurrentMonthPlanNum = (productionPlanInfos==null?0: productionPlanInfos.PlanProductionNum); + currentProduceInfo.CurrentMonthPlanNum = (productionPlanInfos == null ? 0 : productionPlanInfos.PlanProductionNum); - if(shiftlist==null) + if (shiftlist == null) { currentProduceInfo.CurrentTime = DateTime.Now; currentProduceInfo.CurrentTeamLeader = "琚佺彮闀�"; @@ -501,11 +515,11 @@ { //鑾峰彇鐝璁″垝 var shiftplan = _productionPlanInfoRep.DetachedEntities.ProjectToType<ProductionPlanInfoOutput>().ToList() - .Where(o => o.PlanType.Equals("1")&&o.TeamType.Equals(shiftlist.ShiftName)&& o.PlanTimeDayHand.Equals(day)).FirstOrDefault(); + .Where(o => o.PlanType.Equals("1") && o.TeamType.Equals(shiftlist.ShiftName) && o.PlanTimeDayHand.Equals(day)).FirstOrDefault(); currentProduceInfo.CurrentTime = DateTime.Now; currentProduceInfo.CurrentTeamLeader = shiftlist.ShiftRemark; currentProduceInfo.CurrentTeamName = shiftlist.ShiftName; - if(shiftplan!=null) + if (shiftplan != null) { currentProduceInfo.CurrentShiftPlanNum = shiftplan.PlanProductionNum; } @@ -532,7 +546,7 @@ } } - catch(Exception ex) + catch (Exception ex) { currentProduceInfo.CurrentSafeProductionDay = "寮傚父"; } @@ -564,16 +578,16 @@ case "OP10杩炴潌鍘氬害": qualityDataDisplay.QualityType = str; var datas = _qualityDataInfoRep.DetachedEntities.ProjectToType<QualityDataInfoOutput>() - .Where(o=>!string.IsNullOrEmpty(o.QualityOP10To1)&& !string.IsNullOrEmpty(o.WorkPieceID)) + .Where(o => !string.IsNullOrEmpty(o.QualityOP10To1) && !string.IsNullOrEmpty(o.WorkPieceID)) .OrderByDescending(o => o.OP10QualityReceiveTime) - .Select(o=>new QualityData() { WorkPieceID = o.WorkPieceID, QualityDataVaule = double.Parse( o.QualityOP10To1) }) + .Select(o => new QualityData() { WorkPieceID = o.WorkPieceID, QualityDataVaule = double.Parse(o.QualityOP10To1) }) .Take(10).Reverse().ToList(); qualityDataDisplay.list = datas; break; case "OP30娑ㄦ柇鍔涚煩": qualityDataDisplay.QualityType = str; var dataop30ch1 = _qualityDataInfoRep.DetachedEntities.ProjectToType<QualityDataInfoOutput>() - .Where(o => !string.IsNullOrEmpty(o.QualityOP30To1)&&!string.IsNullOrEmpty(o.WorkPieceID)) + .Where(o => !string.IsNullOrEmpty(o.QualityOP30To1) && !string.IsNullOrEmpty(o.WorkPieceID)) .OrderByDescending(o => o.OP30QualityReceiveTimeCH3) .Select(o => new QualityData() { WorkPieceID = o.WorkPieceID, QualityDataVaule = double.Parse(o.QualityOP30To1.Replace("kN", "")) }) .Take(10).Reverse().ToList(); @@ -582,7 +596,7 @@ case "OP35鍘嬭鍔涚煩": qualityDataDisplay.QualityType = str; var dataop35 = _qualityDataInfoRep.DetachedEntities.ProjectToType<QualityDataInfoOutput>() - .Where(o => !string.IsNullOrEmpty(o.QualityOP35To1)&&!string.IsNullOrEmpty(o.WorkPieceID)) + .Where(o => !string.IsNullOrEmpty(o.QualityOP35To1) && !string.IsNullOrEmpty(o.WorkPieceID)) .OrderByDescending(o => o.OP35QualityReceiveTime) .Select(o => new QualityData() { WorkPieceID = o.WorkPieceID, QualityDataVaule = double.Parse(o.QualityOP35To1) }) .Take(10).Reverse().ToList(); @@ -604,7 +618,7 @@ { try { - + var dicts = await _dict.GetDictTreeOutput(); var dict = dicts.Where(o => o.Code.Equals("screen_refresh_frequency")); if (dict.Any()) @@ -624,7 +638,7 @@ return 5000; } } - catch(Exception ex) + catch (Exception ex) { return 6000; @@ -640,20 +654,20 @@ /// <returns></returns> [HttpGet("GetProductionForTime")] [AllowAnonymous] - public async Task<List<ProductionInfo>> GetProductionForTime(DateTime start,DateTime end) + public async Task<List<ProductionInfo>> GetProductionForTime(DateTime start, DateTime end) { //鑾峰彇鏈�杩戞湀涓嬬嚎宸ヤ欢鐨勬垚鍝� var Production = from info in _workPieceInfoRep.DetachedEntities.ProjectToType<WorkPieceInfoOutput>().ToList() - where info.WorkPieceLastOfflineTime>=start - where info.WorkPieceLastOfflineTime<=end - where info.WorkPieceState==(int)WorkPieceState.FinishedProducts - group info by info.WorkPieceLastOfflineTimeDayHand into grouplist - select new ProductionInfo() - { - Day=grouplist.Key, - ProductionNum=grouplist.Count(), - }; - return Production.OrderBy(o=>o.Day).ToList(); + where info.WorkPieceLastOfflineTime >= start + where info.WorkPieceLastOfflineTime <= end + where info.WorkPieceState == (int)WorkPieceState.FinishedProducts + group info by info.WorkPieceLastOfflineTimeDayHand into grouplist + select new ProductionInfo() + { + Day = grouplist.Key, + ProductionNum = grouplist.Count(), + }; + return Production.OrderBy(o => o.Day).ToList(); } #endregion @@ -804,7 +818,7 @@ var workPieceInfo = await _workPieceInfoRep.DetachedEntities .FirstOrDefaultAsync(w => w.WorkPieceID == input.WorkPieceID.Trim()); - AddAccessInterfaceLogInput addLog = new(); + AddAccessInterfaceLogForRequestInput addLog = new(); addLog.JsonString = JsonConvert.SerializeObject(input); addLog.Action = 2; addLog.Key = input.WorkPieceID; @@ -815,7 +829,9 @@ addLog.IpAddress = ipAddress.MapToIPv4().ToString(); } addLog.OperateAddress = $"{_httpContextAccessor.HttpContext.Request.Path}";// {_httpContextAccessor.HttpContext.Request.QueryString}"; //_httpContextAccessor.HttpContext.Request.GetEncodedUrl(); - await _accessInterfaceLog.AddInterfaceLogAsync(addLog); + //鏇挎崲[Editby shaocx,2024-09-04] + // await _accessInterfaceLog.AddInterfaceLogAsync(addLog); + await _accessInterfaceLogForRequest.AddInterfaceLogForRequestAsync(addLog); return workPieceInfo == null ? null : workPieceInfo.Adapt<AccessWorPieceInfoOutput>(); } @@ -862,13 +878,15 @@ await _threadStatusMonitorRep.UpdateAsync(threadStatusMonitor); } } - AddAccessInterfaceLogInput addLog = new(); + AddAccessInterfaceLogForRequestInput addLog = new(); addLog.JsonString = JsonConvert.SerializeObject(input); addLog.Action = 1; addLog.Key = input.Threadcode; addLog.IpAddress = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString(); addLog.OperateAddress = $"{_httpContextAccessor.HttpContext.Request.Path}{_httpContextAccessor.HttpContext.Request.QueryString}"; - await _accessInterfaceLog.AddInterfaceLogAsync(addLog); + //鏇挎崲[Editby shaocx,2024-09-04] + // await _accessInterfaceLog.AddInterfaceLogAsync(addLog); + await _accessInterfaceLogForRequest.AddInterfaceLogForRequestAsync(addLog); } #endregion } -- Gitblit v1.9.3