| | |
| | | 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; |
| | |
| | | /// <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; |
| | |
| | | { |
| | | 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) |
| | |
| | | } |
| | | 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(); |
| | |
| | | { |
| | | try |
| | | { |
| | | addLog.WorkPieceID = input?.WorkPieceID; |
| | | addLog.WorkingProcedureCurrent = input?.WorkingProcedure; |
| | | addLog.QualityState = input?.QualityState; |
| | | |
| | | await _accessInterfaceLog.AddInterfaceLogAsync(addLog); |
| | | } |
| | |
| | | [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; |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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; |
| | | } |
| | |
| | | .ProjectToType<EquipmentCurrentMonitorOutputV2>() |
| | | .OrderBy(o => o.EquipmentID) |
| | | .ToListAsync(); |
| | | |
| | | |
| | | return equipmentCurrentMonitors; |
| | | } |
| | | |
| | |
| | | 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 |
| | | { |
| | | //获取最近一年下线工件的成品 |
| | |
| | | } |
| | | else |
| | | { |
| | | produceCompletionStatus.PlanCompletionRate = Math.Round(((double)produceCompletionStatus.CompletionNum / (double)produceCompletionStatus.PlanCompletionNum), 3) * 100; |
| | | produceCompletionStatus.PlanCompletionRate = (int)Math.Clamp( |
| | | Math.Round(((double)produceCompletionStatus.CompletionNum / (double)produceCompletionStatus.PlanCompletionNum), 3) * 100 |
| | | , 0, 100); |
| | | } |
| | | list.Add(produceCompletionStatus); |
| | | |
| | | } |
| | | |
| | | } |
| | | catch(Exception ex) |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | } |
| | |
| | | //获取当前月 |
| | | var month = DateTime.Now.ToString("yyyy-MM"); |
| | | //获取当前天 |
| | | var day = DateTime.Now.ToString("yyyy-MM-dd"); |
| | | 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) |
| | | { |
| | | |
| | | } |
| | |
| | | && 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 = "袁班长"; |
| | |
| | | { |
| | | //获取班次计划 |
| | | 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; |
| | | } |
| | |
| | | } |
| | | |
| | | } |
| | | catch(Exception ex) |
| | | catch (Exception ex) |
| | | { |
| | | currentProduceInfo.CurrentSafeProductionDay = "异常"; |
| | | } |
| | |
| | | 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(); |
| | |
| | | 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(); |
| | |
| | | { |
| | | try |
| | | { |
| | | |
| | | |
| | | var dicts = await _dict.GetDictTreeOutput(); |
| | | var dict = dicts.Where(o => o.Code.Equals("screen_refresh_frequency")); |
| | | if (dict.Any()) |
| | |
| | | return 5000; |
| | | } |
| | | } |
| | | catch(Exception ex) |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | return 6000; |
| | |
| | | /// <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 |
| | |
| | | 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; |
| | |
| | | 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>(); |
| | | } |
| | |
| | | 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 |
| | | } |