| | |
| | | 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; |
| | |
| | | [HttpGet("workPieceProcessMachiningPage")] |
| | | public async Task<PageResult<WorkPieceProcessOutput>> WorkPieceProcessMachiningPage([FromQuery] WorkPieceProcessSearch input) |
| | | { |
| | | //var LeftJoin = from emp in ListOfEmployees |
| | | // join dept in ListOfDepartment |
| | | // on emp.DeptID equals dept.ID into JoinedEmpDept |
| | | // from dept in JoinedEmpDept.DefaultIfEmpty() |
| | | // select new |
| | | // { |
| | | // EmployeeName = emp.Name, |
| | | // DepartmentName = dept != null ? dept.Name : null |
| | | // }; |
| | | 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() |
| | |
| | | && 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.CreatedUserName.Contains(string.IsNullOrEmpty(input.createUserName) ? "" : input.createUserName) |
| | | && process.UpdatedUserName.Contains(string.IsNullOrEmpty(input.updatedUserName) ? "" : input.updatedUserName) |
| | | |
| | | && 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.StartTimeEndTime.HasValue ? input.StartTimeEndTime : DateTime.MaxValue) |
| | | select new WorkPieceProcessOutput |
| | | { |
| | | UpdatedUserName = process.UpdatedUserName, |
| | | DataCapturePointCname = process.DataCapturePointCname, |
| | | UpdateDataCapturePointCname = process.UpdateDataCapturePointCname, |
| | | QualityNoOk = process.QualityNoOk, |
| | | QualityNoOkReason = process.QualityNoOkReason, |
| | | Id = process.Id, |
| | |
| | | .ProjectToType<WorkPieceProcessOutput>() |
| | | .ToADPagedListAsync(input.PageNo, input.PageSize); |
| | | |
| | | // var workPieceProcesss1 = _workPieceProcessRep.DetachedEntities.GroupJoin(_equipmentBaseInfoRep.DetachedEntities |
| | | // , process => process.EquipmentID |
| | | //, baseinfo => baseinfo.EquipmentId |
| | | //, (process, baseinfo) => new { a = process, b = baseinfo.FirstOrDefault() }) |
| | | // .Where(!string.IsNullOrEmpty(input.WorkPieceID), u => u.a.WorkPieceID.Contains(input.WorkPieceID)) |
| | | //.Where(!string.IsNullOrEmpty(input.QualityState.ToString()), u => u.a.QualityState == input.QualityState) |
| | | //.Where(!string.IsNullOrEmpty(input.EquipmentID), u => u.a.EquipmentID.Equals(input.EquipmentID)) |
| | | //.Where(!string.IsNullOrEmpty(input.WorkingProcedureCurrent), u => u.a.WorkingProcedureCurrent.Equals(input.WorkingProcedureCurrent)) |
| | | //.Where(!string.IsNullOrEmpty(input.StartTime.ToString()), u => u.a.StartTime >= input.StartTime) |
| | | //.Where(!string.IsNullOrEmpty(input.EndTime.ToString()), u => u.a.EndTime <= input.EndTime) |
| | | //.Select(s => new WorkPieceProcessOutput |
| | | //{ |
| | | // Id = s.a.Id, |
| | | // WorkPieceID = s.a.WorkPieceID, |
| | | // EquipmentID = s.a.EquipmentID, |
| | | // EquipmentName = (s.b == null ? "" : s.b.EquipmentName), |
| | | // WorkingProcedureCurrent = s.a.WorkingProcedureCurrent, |
| | | // StartTime = s.a.StartTime, |
| | | // EndTime = s.a.EndTime, |
| | | // QualityState = s.a.QualityState, |
| | | // QualityDataInfoID = s.a.QualityDataInfoID |
| | | //}).ToList(); |
| | | // .OrderBy(PageInputOrder.OrderBuilder<WorkPieceProcessSearch>(input)) |
| | | //.ProjectToType<WorkPieceProcessOutput>() |
| | | // .ToADPagedListAsync(input.PageNo, input.PageSize) |
| | | ; |
| | | |
| | | |
| | | //var workPieceProcesss = await _workPieceProcessRep.DetachedEntities |
| | | // .Join(_equipmentBaseInfoRep.DetachedEntities, a => a.EquipmentID, b => b.EquipmentId, (a, b) => new { a, b }) |
| | | // .Join(_sysDictDataRep.DetachedEntities, e => e.a.QualityState.ToString(), f => f.Code, (e, f) => new { e, f }) |
| | | // .Join(_sysDictTypeRep.DetachedEntities, g => g.f.TypeId, h => h.Id, (f, g) => new { f, g }) |
| | | // .Where(x => (x.g.Code.Equals("quality_state"))) |
| | | // .Where(!string.IsNullOrEmpty(input.WorkPieceID), u => u.f.e.a.WorkPieceID.Contains(input.WorkPieceID)) |
| | | // .Where(!string.IsNullOrEmpty(input.EquipmentID), u => u.f.e.a.EquipmentID.Equals(input.EquipmentID)) |
| | | // .Where(!string.IsNullOrEmpty(input.QualityState.ToString()), u => u.f.e.a.QualityState == input.QualityState) |
| | | // .Where(!string.IsNullOrEmpty(input.WorkingProcedureCurrent), u => u.f.e.a.WorkingProcedureCurrent.Equals(input.WorkingProcedureCurrent)) |
| | | // .Where(input.OnlineTimeBeginTime != null, u => u.f.e.a.StartTime >= input.OnlineTimeBeginTime) |
| | | // .Where(input.OnlineTimeEndTime != null, u => u.f.e.a.StartTime <= input.OnlineTimeEndTime) |
| | | // .Select(s => new WorkPieceProcessOutput |
| | | // { |
| | | // Id = s.f.e.a.Id, |
| | | // WorkPieceID = s.f.e.a.WorkPieceID, |
| | | // WorkingProcedureCurrent = s.f.e.a.WorkingProcedureCurrent, |
| | | // EquipmentID = s.f.e.a.EquipmentID, |
| | | // EquipmentName = s.f.e.b.EquipmentName, |
| | | // StartTime = s.f.e.a.StartTime, |
| | | // EndTime = s.f.e.a.EndTime, |
| | | // QualityStateName = s.f.f.Value, |
| | | // }) |
| | | // .Distinct() |
| | | // .OrderBy(PageInputOrder.OrderBuilder<WorkPieceProcessSearch>(input)) |
| | | // .ProjectToType<WorkPieceProcessOutput>() |
| | | // .ToADPagedListAsync(input.PageNo, input.PageSize); |
| | | return workPieceProcesss; |
| | | } |
| | | |
| | |
| | | && process.WorkingProcedureCurrent == (string.IsNullOrEmpty(input.WorkingProcedureCurrent) ? process.WorkingProcedureCurrent : input.WorkingProcedureCurrent) |
| | | && process.EquipmentID == (string.IsNullOrEmpty(input.EquipmentID) ? process.EquipmentID : input.EquipmentID) |
| | | && workPiece2.OP80NewCode == (string.IsNullOrEmpty(input.OP80NewCode) ? workPiece2.OP80NewCode : input.OP80NewCode) |
| | | |
| | | && process.CreatedUserName.Contains(string.IsNullOrEmpty(input.createUserName) ? "" : input.createUserName) |
| | | && process.UpdatedUserName.Contains(string.IsNullOrEmpty(input.updatedUserName) ? "" : input.updatedUserName) |
| | | |
| | | && 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) |
| | | select new WorkPieceProcessExcelOutput |
| | | { |
| | | |
| | | OP80NewCode = workPiece2.OP80NewCode, |
| | | |
| | | Id = process.Id, |
| | |
| | | .ProjectToType<WorkPieceProcessExcelOutput>() |
| | | .ToListAsync(); |
| | | |
| | | //var workPieceMachiningInfos = await _workPieceProcessRep.DetachedEntities |
| | | // .Join(_equipmentBaseInfoRep.DetachedEntities, a => a.EquipmentID, b => b.EquipmentId, (a, b) => new { a, b }) |
| | | // .Join(_sysDictDataRep.DetachedEntities, e => e.a.QualityState.ToString(), f => f.Code, (e, f) => new { e, f }) |
| | | // .Join(_sysDictTypeRep.DetachedEntities, g => g.f.TypeId, h => h.Id, (f, g) => new { f, g }) |
| | | // .Where(x => (x.g.Code.Equals("quality_state"))) |
| | | // .Where(!string.IsNullOrEmpty(input.WorkPieceID), u => u.f.e.a.WorkPieceID.Contains(input.WorkPieceID)) |
| | | // .Where(!string.IsNullOrEmpty(input.EquipmentID), u => u.f.e.a.EquipmentID.Equals(input.EquipmentID)) |
| | | // .Where(!string.IsNullOrEmpty(input.QualityState.ToString()), u => u.f.e.a.QualityState == input.QualityState) |
| | | // .Where(!string.IsNullOrEmpty(input.WorkingProcedureCurrent), u => u.f.e.a.WorkingProcedureCurrent.Equals(input.WorkingProcedureCurrent)) |
| | | // .Where(input.OnlineTimeBeginTime != null, u => u.f.e.a.StartTime >= input.OnlineTimeBeginTime) |
| | | // .Where(input.OnlineTimeEndTime != null, u => u.f.e.a.StartTime <= input.OnlineTimeEndTime) |
| | | // .Select(s => new WorkPieceProcessExcelOutput |
| | | // { |
| | | // Id = s.f.e.a.Id, |
| | | // WorkPieceID = s.f.e.a.WorkPieceID, |
| | | // WorkingProcedureCurrent = s.f.e.a.WorkingProcedureCurrent, |
| | | // EquipmentName = s.f.e.b.EquipmentName, |
| | | // StartTime = s.f.e.a.StartTime.ToString(), |
| | | // EndTime = s.f.e.a.EndTime.ToString(), |
| | | // QualityStateName = s.f.f.Value, |
| | | // }) |
| | | // .Distinct() |
| | | // .OrderBy(PageInputOrder.OrderBuilder<WorkPieceProcessSearch>(input)) |
| | | // .ProjectToType<WorkPieceProcessExcelOutput>() |
| | | // .ToListAsync(); |
| | | |
| | | foreach (WorkPieceProcessExcelOutput item in workPieceMachiningInfos) |
| | | { |
| | |
| | | |
| | | #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.PieceLogTypeName), u => u.PieceLogTypeName.Contains(input.PieceLogTypeName)) |
| | | .Where(input.PieceLogType != null, u => u.PieceLogType == input.PieceLogType) |
| | | .Where(!string.IsNullOrEmpty(input.remarks), u => u.Remarks.Contains(input.remarks)) |
| | | .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, |
| | | 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 |
| | | |
| | | /// <summary> |
| | | /// 分页查询工件加工(工件信息表) |
| | | /// </summary> |
| | |
| | | .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, |