| | |
| | | private readonly IRepository<EquipmentBaseInfo, MasterDbContextLocator> _equipmentBaseInfoRep; |
| | | private readonly IRepository<SysDictType, MasterDbContextLocator> _sysDictTypeRep; |
| | | private readonly IRepository<SysDictData, MasterDbContextLocator> _sysDictDataRep; |
| | | private readonly IRepository<WorkPieceLog, MasterDbContextLocator> _workPieceLogRep; |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="sysDictTypeRep"></param> |
| | | /// <param name="sysDictDataRep"></param> |
| | | public WorkPieceProcessService( |
| | | IRepository<WorkPieceLog, MasterDbContextLocator> workPieceLogRep, |
| | | IRepository<WorkPieceProcess, MasterDbContextLocator> workPieceProcessRep, |
| | | IRepository<WorkPieceInfo, MasterDbContextLocator> workPieceInfoRep, |
| | | IRepository<EquipmentBaseInfo, MasterDbContextLocator> equipmentBaseInfoRep, |
| | |
| | | IRepository<SysDictData, MasterDbContextLocator> sysDictDataRep |
| | | ) |
| | | { |
| | | _workPieceLogRep = workPieceLogRep; |
| | | _workPieceInfoRep = workPieceInfoRep; |
| | | _workPieceProcessRep = workPieceProcessRep; |
| | | _equipmentBaseInfoRep = equipmentBaseInfoRep; |
| | |
| | | && process.StartTime <= (input.StartTimeEndTime.HasValue ? input.StartTimeEndTime : DateTime.MaxValue) |
| | | select new WorkPieceProcessOutput |
| | | { |
| | | |
| | | QualityNoOk = process.QualityNoOk, |
| | | QualityNoOkReason = process.QualityNoOkReason, |
| | | Id = process.Id, |
| | | WorkPieceID = process.WorkPieceID, |
| | | EquipmentID = process.EquipmentID, |
| | |
| | | QualityDataInfoID = process.QualityDataInfoID, |
| | | OperationType = process.OperationType, |
| | | CreateUserName = process.CreatedUserName |
| | | }).OrderBy(o => o.StartTime) |
| | | }).OrderByDescending(o => o.StartTime) |
| | | .ProjectToType<WorkPieceProcessOutput>() |
| | | .ToADPagedListAsync(input.PageNo, input.PageSize); |
| | | |
| | |
| | | EndTime = process.EndTime.ToString(), |
| | | //QualityState = process.QualityState, |
| | | CreateUserName = process.CreatedUserName |
| | | }).OrderBy(o => o.StartTime).Distinct() |
| | | }).OrderByDescending(o => o.StartTime).Distinct() |
| | | .ProjectToType<WorkPieceProcessExcelOutput>() |
| | | .ToListAsync(); |
| | | |
| | |
| | | //EquipmentID = process.EquipmentID, |
| | | //EquipmentName = baseinfo2.EquipmentName, |
| | | WorkingProcedureCurrent = process.WorkingProcedureCurrent, |
| | | WorkPieceID = process.WorkPieceID, |
| | | //StartTime = grouped.Key.StartTime, |
| | | YieldCount = 0 |
| | | }).ToListAsync(); |
| | | }).Distinct().ToListAsync(); |
| | | |
| | | |
| | | var workPieceProcesss = workPieceProcesss2.GroupBy(x => new { x.WorkingProcedureCurrent }).Select(y => new QueryYieldOutput |
| | | { |
| | |
| | | .OrderBy(x => x.WorkingProcedureCurrent) |
| | | .ToADPagedList(input.PageNo, input.PageSize); |
| | | |
| | | //var workPieceProcesss = await (from process in _workPieceProcessRep.DetachedEntities |
| | | // join baseinfo in _equipmentBaseInfoRep.DetachedEntities on process.EquipmentID equals baseinfo.EquipmentId into joinedEmpty |
| | | // from baseinfo2 in joinedEmpty.DefaultIfEmpty() |
| | | // join workPiece in _workPieceInfoRep.DetachedEntities on process.WorkPieceID equals workPiece.WorkPieceID into joined2Empty |
| | | // from workPiece2 in joined2Empty.DefaultIfEmpty() |
| | | // where process.IsDeleted == false && process.WorkPieceID.Contains(string.IsNullOrEmpty(input.WorkPieceID) ? "" : input.WorkPieceID) |
| | | // && process.QualityState == (input.QualityState.HasValue ? input.QualityState.Value : process.QualityState) |
| | | // && process.EquipmentID == (string.IsNullOrEmpty(input.EquipmentID) ? process.EquipmentID : input.EquipmentID) |
| | | // && process.WorkingProcedureCurrent == (string.IsNullOrEmpty(input.WorkingProcedureCurrent) ? process.WorkingProcedureCurrent : input.WorkingProcedureCurrent) |
| | | // && workPiece2.OP80NewCode == (string.IsNullOrEmpty(input.OP80NewCode) ? workPiece2.OP80NewCode : input.OP80NewCode) |
| | | // && process.EquipmentID == (string.IsNullOrEmpty(input.EquipmentID) ? process.EquipmentID : input.EquipmentID) |
| | | // && process.OperationType == (string.IsNullOrEmpty(input.OperationType) ? process.OperationType : input.OperationType) |
| | | // && !string.IsNullOrEmpty(process.WorkPieceID) |
| | | // && process.StartTime >= (input.StartTimeBeginTime.HasValue ? input.StartTimeBeginTime : DateTime.MinValue) |
| | | // && process.StartTime <= (input.StartTimeEndTime.HasValue ? input.StartTimeEndTime : DateTime.MaxValue) |
| | | // //group new { process, baseinfo2 } by new { process.WorkingProcedureCurrent, process.EquipmentID, baseinfo2.EquipmentName } into grouped |
| | | // //group process by new { process.WorkingProcedureCurrent, process.EquipmentID } into grouped |
| | | // group process by new { process.WorkingProcedureCurrent } into grouped |
| | | // select new QueryYieldOutput |
| | | // { |
| | | // // EquipmentID = grouped.Key.EquipmentID, |
| | | // //EquipmentName = grouped.Key.EquipmentName, |
| | | // WorkingProcedureCurrent = grouped.Key.WorkingProcedureCurrent, |
| | | // //StartTime = grouped.Key.StartTime, |
| | | // YieldCount = grouped.ToList().Count, |
| | | |
| | | // }).OrderBy(o => o.StartTime) |
| | | // .ProjectToType<QueryYieldOutput>() |
| | | // .ToADPagedListAsync(input.PageNo, input.PageSize); |
| | | |
| | | return workPieceProcesss; |
| | | } |
| | |
| | | var workPieceMachiningInfos2 = QueryYield(input); |
| | | var workPieceMachiningInfos = workPieceMachiningInfos2.Result.Rows.ToList(); |
| | | var daList = workPieceMachiningInfos.Adapt<List<ExportYieldOutput>>(); |
| | | |
| | | MemoryStream ms = new(); |
| | | DataConvertUtil.ToExcelData(daList, _sysDictTypeRep, _sysDictDataRep, out List<string> headers, |
| | | out List<List<object>> data, out string sheetName); |
| | | |
| | | ExcelUtil.ToExcel(headers, data, sheetName, ms); |
| | | ms.Position = 0; |
| | | var fileName = HttpUtility.UrlEncode($"{sheetName}[{DateTimeOffset.Now:yyyy-MM-dd}].xlsx", Encoding.GetEncoding("UTF-8")); |
| | | return new FileStreamResult(ms, "application/octet-stream") { FileDownloadName = fileName }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region 采集日志查询 [Editby shaocx,2024-06-08] |
| | | |
| | | /// <summary> |
| | | /// 采集日志查询 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpGet("queryWorkPieceLogYield")] |
| | | public async Task<PageResult<QueryWorkPieceLogYieldOutput>> QueryWorkPieceLogYield([FromQuery] WorkPieceLogYieldInput input) |
| | | { |
| | | |
| | | var resutlt = await _workPieceLogRep.DetachedEntities |
| | | .Where(!string.IsNullOrEmpty(input.WorkPieceID), u => u.WorkPieceID.Contains(input.WorkPieceID)) |
| | | .Where(!string.IsNullOrEmpty(input.workingProcedure), u => u.WorkingProcedure.Contains(input.workingProcedure)) |
| | | .Where(!string.IsNullOrEmpty(input.createdUserName), u => u.CreatedUserName.Contains(input.createdUserName)) |
| | | .Where(!string.IsNullOrEmpty(input.StartTimeBeginTime.ToString()), u => u.CreatedTime >= input.StartTimeBeginTime) |
| | | .Where(!string.IsNullOrEmpty(input.StartTimeEndTime.ToString()), u => u.CreatedTime <= input.StartTimeEndTime) |
| | | |
| | | |
| | | .OrderBy(PageInputOrder.OrderBuilder<WorkPieceLogYieldInput>(input)) |
| | | .ProjectToType<QueryWorkPieceLogYieldOutput>() |
| | | .ToADPagedListAsync(input.PageNo, input.PageSize); |
| | | return resutlt; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 导出采集日志查询 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns>导出的Excel文件</returns> |
| | | [HttpGet("exportWorkPieceLogYield")] |
| | | public async Task<IActionResult> ExportWorkPieceLogYield([FromQuery] WorkPieceLogYieldInput input) |
| | | { |
| | | input.PageNo = 1; |
| | | input.PageSize = 1000000; |
| | | var workPieceMachiningInfos2 = QueryWorkPieceLogYield(input); |
| | | var workPieceMachiningInfos = workPieceMachiningInfos2.Result.Rows.ToList(); |
| | | var daList = workPieceMachiningInfos.Adapt<List<ExportYQueryWorkPieceLogYieldOutput>>(); |
| | | |
| | | MemoryStream ms = new(); |
| | | DataConvertUtil.ToExcelData(daList, _sysDictTypeRep, _sysDictDataRep, out List<string> headers, |
| | |
| | | .Where(o => o.f.e.a.QualityState == (input.QualityState.HasValue ? input.QualityState.Value : o.f.e.a.QualityState)) |
| | | .Select(s => new WorkPieceInfoMachiningPageOutput |
| | | { |
| | | QualityNoOk = s.f.e.a.QualityNoOk, |
| | | QualityNoOkReason = s.f.e.a.QualityNoOkReason, |
| | | Id = s.f.e.a.Id, |
| | | |
| | | WorkPieceID = s.f.e.a.WorkPieceID, |
| | | WorkPieceState = s.f.e.a.WorkPieceState, |
| | | WorkPieceStateName = s.f.f.Value, |