diff --git a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.csproj b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.csproj index 6ae891a..ee853ef 100644 --- a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.csproj +++ b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.csproj @@ -25,6 +25,7 @@ + diff --git a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml index 2555923..27a7288 100644 --- a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml +++ b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml @@ -552,6 +552,11 @@ 批次号 + + + 工单当前状态 + + 创建时间 @@ -1256,6 +1261,11 @@ 日志消息 + + + 更新时间 + + 名 称 :用户日志 @@ -7139,7 +7149,7 @@ 获取产品生产统计 - + @@ -7153,14 +7163,14 @@ 获取成品生产统计 - + 获取物料统计 - + @@ -8703,7 +8713,7 @@ 主键 - + 关键字 diff --git a/backend/BPA.MES.Base.Application/Entitys/App/Pztj_BucketMaterialsRecordEntity.cs b/backend/BPA.MES.Base.Application/Entitys/App/Pztj_BucketMaterialsRecordEntity.cs index ad131b7..3332257 100644 --- a/backend/BPA.MES.Base.Application/Entitys/App/Pztj_BucketMaterialsRecordEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/App/Pztj_BucketMaterialsRecordEntity.cs @@ -12,22 +12,27 @@ /// /// 桶Id /// + [SugarColumn(IsNullable = true)] public string BucketId { get; set; } /// /// 物料Id /// + [SugarColumn(IsNullable = true)] public string MaterialId { get; set; } /// /// 添加时间 /// + [SugarColumn(IsNullable = true)] public DateTime? CreateTime { get; set; } /// /// 重量 /// + [SugarColumn(IsNullable = true)] public string Weight { get; set; } /// /// 工单Id /// + [SugarColumn(IsNullable = true)] public string WorkId { get; set; } } } diff --git a/backend/BPA.MES.Base.Application/Entitys/App/Pztj_DevicesInfoEntity.cs b/backend/BPA.MES.Base.Application/Entitys/App/Pztj_DevicesInfoEntity.cs index eb27067..d80f4a1 100644 --- a/backend/BPA.MES.Base.Application/Entitys/App/Pztj_DevicesInfoEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/App/Pztj_DevicesInfoEntity.cs @@ -22,18 +22,22 @@ /// /// 设备类型 /// + [SugarColumn(IsNullable = true)] public string DeviceType { get; set; } /// /// 设备描述 /// + [SugarColumn(IsNullable = true)] public string Describe { get; set; } /// /// 设备维保时间 /// + [SugarColumn(IsNullable = true)] public string RepairDate { get; set; } /// /// 设备创建时间 /// + [SugarColumn(IsNullable = true)] public string CreateTime { get; set; } } } diff --git a/backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoEntity.cs b/backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoEntity.cs index ca0d237..d43dbd6 100644 --- a/backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoEntity.cs @@ -36,6 +36,11 @@ /// public string BatchId { get; set; } /// + /// 工单当前状态 + /// + [SugarColumn(IsNullable = true)] + public WorkOrderStatusEnum? Status { get; set; } + /// /// 创建时间 /// public DateTime CreateTime { get; set; } diff --git a/backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoStatusEntity.cs b/backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoStatusEntity.cs index bbad5c8..ab8d0ff 100644 --- a/backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoStatusEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoStatusEntity.cs @@ -12,18 +12,22 @@ /// /// 工单Id /// + [SugarColumn(IsNullable = true)] public string WorkId { get; set; } /// /// 工单状态 /// + [SugarColumn(IsNullable = true)] public WorkOrderStatusEnum? Status { get; set; } /// /// 创建时间 /// + [SugarColumn(IsNullable = true)] public DateTime CreateTime { get; set; } /// /// 备注 /// + [SugarColumn(IsNullable = true)] public string Remark { get; set; } } } diff --git a/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoMaterialsRecordEntity.cs b/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoMaterialsRecordEntity.cs index 1fc2c2e..b94c2a0 100644 --- a/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoMaterialsRecordEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoMaterialsRecordEntity.cs @@ -12,14 +12,17 @@ /// /// 物料名称 /// + [SugarColumn(IsNullable = true)] public string MaterialName { get; set; } /// /// 物料id /// + [SugarColumn(IsNullable = true)] public string MaterialId { get; set; } /// /// 工单id /// + [SugarColumn(IsNullable = true)] public string WorkId { get; set; } /// /// 重量 @@ -34,6 +37,7 @@ /// /// 配方Id /// + [SugarColumn(IsNullable = true)] public string RecipeId { get; set; } /// /// 配方名称 @@ -53,6 +57,7 @@ /// /// 误差 /// + [SugarColumn(IsNullable = true)] public string ErrorWeight { get; set; } } } diff --git a/backend/BPA.MES.Base.Application/Entitys/Base/DeviceProductFunctionEntity.cs b/backend/BPA.MES.Base.Application/Entitys/Base/DeviceProductFunctionEntity.cs index c27f26e..aaa58d6 100644 --- a/backend/BPA.MES.Base.Application/Entitys/Base/DeviceProductFunctionEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/Base/DeviceProductFunctionEntity.cs @@ -12,14 +12,17 @@ /// /// 设备产品Id /// + [SugarColumn(IsNullable = true)] public string DeviceProductId { get; set; } /// /// 功能名称 /// + [SugarColumn(IsNullable = true)] public string Name { get; set; } /// /// 功能编码 /// + [SugarColumn(IsNullable = true)] public string Code { get; set; } /// /// 描述 @@ -29,6 +32,7 @@ /// /// 方法参数 /// + [SugarColumn(IsNullable = true, ColumnDataType = "longtext")] public string Params { get; set; } } } diff --git a/backend/BPA.MES.Base.Application/Entitys/Logs/ProgramLogEntity.cs b/backend/BPA.MES.Base.Application/Entitys/Logs/ProgramLogEntity.cs index 8dd6d8f..c117ec6 100644 --- a/backend/BPA.MES.Base.Application/Entitys/Logs/ProgramLogEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/Logs/ProgramLogEntity.cs @@ -12,13 +12,12 @@ /// /// 日志类型 /// - [SugarColumn(IsNullable = true)] + [SugarColumn(IsNullable = true, ColumnDataType = "varchar",Length = 200)] public string LogType { get; set; } - /// /// 日志消息 /// - [SugarColumn(IsNullable = true)] + [SugarColumn(IsNullable = true, ColumnDataType = "longtext")] public string MsgInfo { get; set; } /// /// 日期 diff --git a/backend/BPA.MES.Base.Application/Entitys/Logs/RunLogEntity.cs b/backend/BPA.MES.Base.Application/Entitys/Logs/RunLogEntity.cs index 6c66919..9317b17 100644 --- a/backend/BPA.MES.Base.Application/Entitys/Logs/RunLogEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/Logs/RunLogEntity.cs @@ -6,6 +6,8 @@ /// 创建时间 : 2023/8/21 10:18:34 /// 描 述 : /// + [SplitTable(SplitType.Month)] + //[SugarTable("runlog_{year}{month}{day}")] [SugarTable("runlog")] public class RunLogEntity : DEntityBase { @@ -17,7 +19,7 @@ /// /// 日志消息 /// - [SugarColumn(IsNullable = true)] + [SugarColumn(IsNullable = true, ColumnDataType = "longtext")] public string MsgInfo { get; set; } /// /// 日期 @@ -32,7 +34,12 @@ /// /// 日志消息 /// - [SugarColumn(IsNullable = true)] + [SugarColumn(IsNullable = true),SplitField] public DateTime CreateDate { get; set; } + /// + /// 更新时间 + /// + [SugarColumn(IsNullable = true)]//设置为可空字段 + public DateTime UpdateTime { get; set; } } } diff --git a/backend/BPA.MES.Base.Application/Services/LogService/Services/RunLogService.cs b/backend/BPA.MES.Base.Application/Services/LogService/Services/RunLogService.cs index a85d548..759ef34 100644 --- a/backend/BPA.MES.Base.Application/Services/LogService/Services/RunLogService.cs +++ b/backend/BPA.MES.Base.Application/Services/LogService/Services/RunLogService.cs @@ -75,6 +75,7 @@ .WhereIF(!string.IsNullOrEmpty(input.MsgInfo), x => x.MsgInfo.Contains(input.MsgInfo)) .WhereIF(input.StartTime.HasVal(), x => x.CreateDate >= input.StartTime.Value) .WhereIF(input.EndTime.HasVal(), x => x.CreateDate <= input.EndTime.Value) + //.SplitTable(input.StartTime.Value, input.EndTime.Value) .OrderByDescending(x => x.CreateDate) .ToPagedListAsync(input.PageIndex, input.PageSize); SqlSugarPagedList output = entity.Adapt>(); diff --git a/backend/BPA.MES.Base.Application/Services/ReportService/Dtos/MaterialsInputDto.cs b/backend/BPA.MES.Base.Application/Services/ReportService/Dtos/MaterialsInputDto.cs index d50cac4..23067f6 100644 --- a/backend/BPA.MES.Base.Application/Services/ReportService/Dtos/MaterialsInputDto.cs +++ b/backend/BPA.MES.Base.Application/Services/ReportService/Dtos/MaterialsInputDto.cs @@ -6,10 +6,10 @@ using System.Threading.Tasks; namespace BPA.MES.Base.Application.Services.ReportService.Dtos { - public class MaterialsInputDto + public class MaterialsInputDto: RequestPage { public DateTime? StartTime { get; set; } public DateTime? EndTime { get; set; } - public string MaterialsName { get; set; } + public string MaterialName { get; set; } } } diff --git a/backend/BPA.MES.Base.Application/Services/ReportService/Dtos/ProductInputDto.cs b/backend/BPA.MES.Base.Application/Services/ReportService/Dtos/ProductInputDto.cs index 6943b98..b5b26bf 100644 --- a/backend/BPA.MES.Base.Application/Services/ReportService/Dtos/ProductInputDto.cs +++ b/backend/BPA.MES.Base.Application/Services/ReportService/Dtos/ProductInputDto.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace BPA.MES.Base.Application.Services.ReportService.Dtos { - public class ProductInputDto + public class ProductInputDto : RequestPage { public DateTime? StartTime { get; set; } public DateTime? EndTime { get; set; } diff --git a/backend/BPA.MES.Base.Application/Services/ReportService/IReportService.cs b/backend/BPA.MES.Base.Application/Services/ReportService/IReportService.cs index b64eedc..18816d6 100644 --- a/backend/BPA.MES.Base.Application/Services/ReportService/IReportService.cs +++ b/backend/BPA.MES.Base.Application/Services/ReportService/IReportService.cs @@ -12,15 +12,15 @@ namespace BPA.MES.Base.Application.Services.ReportService /// /// 获取产品生产统计 /// - /// + /// /// - Task> GetProductReport(ProductInputDto inputDto); + Task> GetProductReport(ProductInputDto input); /// /// 获取物料统计 /// /// /// - Task> GetMaterialsReport(MaterialsInputDto inputDto); + Task> GetMaterialsReport(MaterialsInputDto inputDto); } } diff --git a/backend/BPA.MES.Base.Application/Services/ReportService/ReportService.cs b/backend/BPA.MES.Base.Application/Services/ReportService/ReportService.cs index a21d51e..7fb128b 100644 --- a/backend/BPA.MES.Base.Application/Services/ReportService/ReportService.cs +++ b/backend/BPA.MES.Base.Application/Services/ReportService/ReportService.cs @@ -20,29 +20,24 @@ namespace BPA.MES.Base.Application.Services.ReportService /// /// 获取成品生产统计 /// - /// + /// /// [HttpPost] - public async Task> GetProductReport(ProductInputDto inputDto) + public async Task> GetProductReport(ProductInputDto input) { - var res = await _dbContext.Queryable - ((a, b,c) => - new JoinQueryInfos( - JoinType.Left, a.Id == b.WorkId, - JoinType.Left,a.FinalId==c.Id) - ) - .Where((a,b,c)=>b.Status== WorkOrderStatusEnum.Completed) - .WhereIF(!string.IsNullOrEmpty(inputDto.ProductName),(a,b,c)=>c.Name.Contains(inputDto.ProductName)) - .WhereIF(inputDto.StartTime.HasVal(),(a,b,c)=>b.CreateTime>=inputDto.StartTime.Value) - .WhereIF(inputDto.EndTime.HasVal(), (a, b, c) => b.CreateTime >= inputDto.EndTime.Value) + var res = await _dbContext.Queryable().LeftJoin((a, b) => a.FinalId == b.Id) + .WhereIF(!string.IsNullOrEmpty(input.ProductName), (a, b) => b.Name.Contains(input.ProductName)) + .WhereIF(input.StartTime.HasVal(), (a, b) => a.CreateTime >= input.StartTime.Value) + .WhereIF(input.EndTime.HasVal(), (a, b) => a.CreateTime <= input.EndTime.Value) + .Where((a, b) => a.Status == WorkOrderStatusEnum.Completed) + .GroupBy((a, b) => b.Name) + .Select((a, b) => new ProductOutDto + { + ProductName = b.Name, + Count = SqlFunc.AggregateSum(Convert.ToDecimal(a.Number)), - .Select((a,b,c) => new ProductOutDto() - { - Count = SqlFunc.AggregateSum(Convert.ToInt32(a.Number)), - ProductId=a.FinalId, - ProductName=c.Name + }).ToPagedListAsync(input.PageIndex, input.PageSize); - }).ToListAsync(); return res; } @@ -50,66 +45,25 @@ namespace BPA.MES.Base.Application.Services.ReportService /// /// 获取物料统计 /// - /// + /// /// [HttpPost] - public async Task> GetMaterialsReport(MaterialsInputDto inputDto) + public async Task> GetMaterialsReport(MaterialsInputDto input) { - var result = new List(); - var res = await _dbContext.Queryable - ((a, b, c) => - new JoinQueryInfos( - JoinType.Left, a.Id == b.WorkId, - JoinType.Left, a.FinalId == c.Id) - ) - .Where((a, b, c) => b.Status != WorkOrderStatusEnum.Draft) - .WhereIF(inputDto.StartTime.HasVal(), (a, b, c) => b.CreateTime >= inputDto.StartTime.Value) - .WhereIF(inputDto.EndTime.HasVal(), (a, b, c) => b.CreateTime >= inputDto.EndTime.Value) - .Select((a, b, c) => new - { - ProductId = a.FinalId, - Count = SqlFunc.AggregateSum(Convert.ToInt32(a.Number)), - c.RecipeId - - }).ToListAsync(); - var recipeId = res.Select(x => x.RecipeId).ToList(); - - var recipes = await _dbContext.Queryable() - .Where(x => recipeId.Contains(x.RecipesId)) - .Select(x => new - { - x.MaterialId, - x.Weight, - x.RecipesId - }) .ToListAsync(); - - var materialsId= recipes.Select(x => x.MaterialId).ToList(); - - var materials = await _dbContext.Queryable() - .Where(x=> materialsId.Contains(x.Id)) - .WhereIF(!string.IsNullOrEmpty(inputDto.MaterialsName),x=>x.Name.Contains(inputDto.MaterialsName)) - .ToListAsync(); - - foreach (var item in materials) - { - var count = 0; - foreach (var item2 in res.GroupBy(x=>x.RecipeId)) - { - var data = recipes.Where(x=>x.RecipesId==item2.Key &&x.MaterialId==item.Id).FirstOrDefault(); - count=item2.First().Count*Convert.ToInt32(data==null? 0: data.Weight); - - } - - result.Add(new MaterialsOutDto() + var result = await _dbContext.Queryable() + .LeftJoin((a, b) => a.WorkId == b.Id) + .Where((a, b) => b.Status == WorkOrderStatusEnum.Completed) + .WhereIF(!string.IsNullOrEmpty(input.MaterialName), (a, b) => a.MaterialName.Contains(input.MaterialName)) + .WhereIF(input.StartTime.HasVal(), (a, b) => b.CreateTime >= input.StartTime.Value) + .WhereIF(input.EndTime.HasVal(), (a, b) => b.CreateTime <= input.EndTime.Value) + .GroupBy((a, b) => a.MaterialName) + .Select((a, b) => new MaterialsOutDto { - MaterialId=item.Id, - MaterialName=item.Name, - Count= count, - }); - } + Count = SqlFunc.AggregateSumNoNull(Convert.ToDecimal(a.Weight)), + MaterialName = a.MaterialName, + }).ToPagedListAsync(input.PageIndex, input.PageSize); return result; } - } } diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/EmployeeInput.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/EmployeeInput.cs index 7b6669c..baaa41f 100644 --- a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/EmployeeInput.cs +++ b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/EmployeeInput.cs @@ -84,7 +84,7 @@ /// /// 关键字 /// - public string Keyword { get; set; } + public string name { get; set; } /// /// 状态 /// diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs index 2b85c33..8359ee2 100644 --- a/backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs +++ b/backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs @@ -352,8 +352,9 @@ var entity = await db.Queryable() - .WhereIF(!string.IsNullOrEmpty(input.Keyword), t => t.Name.Contains(input.Keyword)) - .WhereIF(input.Status > 0, t => t.Status == input.Status).WhereIF(input.Gender > 0, t => t.Gender == input.Gender) + .WhereIF(!string.IsNullOrEmpty(input.name), t => t.Name.Contains(input.name)) + .WhereIF(input.Status > 0, t => t.Status == input.Status). + WhereIF(input.Gender > 0, t => t.Gender == input.Gender) .Where(t => t.IsAdmin == false) .Select(t => new EmployeeOutput() @@ -443,7 +444,21 @@ [HttpGet] public async Task> RoleModuleList(string RoleId) { - var entitys = await _dbContext.Queryable().Where(x => x.RoleId == RoleId&&x.ParentId!="").ToListAsync(); + var entitys = await _dbContext.Queryable().Where(x => x.RoleId == RoleId).ToListAsync(); + var tementity = entitys.Where(x => x.ParentId == "").ToList();//查询出主菜单 + var delentity = new List(); + foreach (var item in tementity)//查询出主菜单是否有多个 + { + var v = entitys.Where(x=>x.ParentId==item.ModuleId).ToList(); + if (v.Count>0)//如果只有一个,就不删除 + { + delentity.Add(item); + } + } + foreach (var item in delentity) + { + entitys.Remove(item); + } var output = entitys.Adapt>(); return output; } diff --git a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkBatchDto.cs b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkBatchDto.cs index cefe65a..5a4e905 100644 --- a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkBatchDto.cs +++ b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkBatchDto.cs @@ -92,5 +92,7 @@ /// public int Count { get; set; } + public List WorkList { get; set; } = new(); + } } \ No newline at end of file diff --git a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkBatchService.cs b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkBatchService.cs index 17065e4..cfec498 100644 --- a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkBatchService.cs +++ b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkBatchService.cs @@ -11,10 +11,12 @@ { private readonly ISqlSugarClient _dbContext; private readonly IMQTTService _MQTTService; - public WorkBatchService(ISqlSugarClient db, IMQTTService MQTTService) + private readonly IWorkInfoService _workInfoService; + public WorkBatchService(ISqlSugarClient db, IMQTTService MQTTService, IWorkInfoService WorkInfoService) { _dbContext = db; _MQTTService = MQTTService; + _workInfoService = WorkInfoService; } public async Task Add(WorkBatchAddInput input) { @@ -61,10 +63,10 @@ Count = SqlFunc.Subqueryable().Where(d=>d.BatchId==x.Id).Count() }) .ToPagedListAsync(input.PageIndex, input.PageSize); - //foreach (var item in entity.Items) - //{ - // item.Status = WorkOrderStatusEnum.Started - //} + foreach (var item in entity.Items) + { + item.WorkList = await _workInfoService.List(new WorkInfoQueryInput { BatchId = item.Id }); + } return entity; } diff --git a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs index 9e81bfb..da77b4e 100644 --- a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs +++ b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs @@ -154,23 +154,27 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services var entity = await _dbContext.Queryable() .LeftJoin((a, b) => a.FinalId == b.Id) .LeftJoin((a, b, c) => a.LineId == c.Id) - .LeftJoin((a, b, c, d) => d.Id == SqlFunc.Subqueryable().Where(s => s.WorkId == a.Id).OrderByDesc(s => s.CreateTime).Select(s => s.Id)) - .LeftJoin((a,b,c,d,e)=>a.DeviceId==e.Id) + .LeftJoin((a, b, c, d) =>a.DeviceId==d.Id) .WhereIF(!string.IsNullOrEmpty(input.Name), (a, b, c, d) => b.Name.Contains(input.Name)) .WhereIF(!string.IsNullOrEmpty(input.Id), (a, b, c, d) => a.Id.Contains(input.Id)) .WhereIF(!string.IsNullOrEmpty(input.BatchId), (a, b, c, d) => a.BatchId == input.BatchId) - .WhereIF(input.Status != null, (a, b, c, d) => input.Status.Contains(d.Status)) + .WhereIF(input.Status != null, (a, b, c, d) => input.Status.Contains(a.Status)) .WhereIF(input.StartTime != null, (a, b, c, d) => input.StartTime <= Convert.ToDateTime(a.CreateTime)) .WhereIF(input.EndTime != null, (a, b, c, d) => input.EndTime.Value.AddHours(23).AddMinutes(59).AddSeconds(59) >= Convert.ToDateTime(a.CreateTime)) .OrderByDescending((a, b, c, d) => a.CreateTime) - .Select((a, b, c, d,e) => new WorkInfoOutput + .Select((a, b, c, d) => new WorkInfoOutput { - Id = a.Id.SelectAll(), + Id = a.Id, FinalName = b.Name, LineName = c.Name, DeviceId = a.DeviceId == null ? "" : a.DeviceId, - DeviceName = e.Name, - Status = d.Status == null ? WorkOrderStatusEnum.Draft : d.Status + DeviceName =d.Name, + Status = a.Status == null ? WorkOrderStatusEnum.Draft : a.Status, + BatchId = a.BatchId, + Number = a.Number, + FinalId = a.FinalId, + LineId = a.LineId, + DeviceCode = a.DeviceId }).ToListAsync(); return entity; } @@ -185,21 +189,20 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services var entity = await _dbContext.Queryable() .LeftJoin((a, b) => a.FinalId == b.Id) .LeftJoin((a, b, c) => a.LineId == c.Id) - .LeftJoin((a, b, c, d) => d.Id == SqlFunc.Subqueryable().Where(s => s.WorkId == a.Id).OrderByDesc(s => s.CreateTime).Select(s => s.Id)) - .WhereIF(!string.IsNullOrEmpty(input.Name), (a, b, c, d) => b.Name.Contains(input.Name)) - .WhereIF(!string.IsNullOrEmpty(input.Id), (a, b, c, d) => a.Id.Contains(input.Id)) - .WhereIF(!string.IsNullOrEmpty(input.BatchId), (a, b, c, d) => a.BatchId==input.BatchId) - .WhereIF(input.Status != null, (a, b, c, d) => input.Status.Contains(d.Status)) - .WhereIF(input.StartTime != null, (a, b, c, d) => input.StartTime <= Convert.ToDateTime(a.CreateTime)) - .WhereIF(input.EndTime != null, (a, b, c, d) => input.EndTime.Value.AddHours(23).AddMinutes(59).AddSeconds(59) >= Convert.ToDateTime(a.CreateTime)) - .OrderByDescending((a, b, c, d) => a.CreateTime) - .Select((a, b, c, d) => new WorkInfoOutput + .WhereIF(!string.IsNullOrEmpty(input.Name), (a, b, c) => b.Name.Contains(input.Name)) + .WhereIF(!string.IsNullOrEmpty(input.Id), (a, b, c) => a.Id.Contains(input.Id)) + .WhereIF(!string.IsNullOrEmpty(input.BatchId), (a, b, c) => a.BatchId==input.BatchId) + .WhereIF(input.Status != null, (a, b, c) => input.Status.Contains(a.Status)) + .WhereIF(input.StartTime != null, (a, b, c) => input.StartTime <= Convert.ToDateTime(a.CreateTime)) + .WhereIF(input.EndTime != null, (a, b, c) => input.EndTime.Value.AddHours(23).AddMinutes(59).AddSeconds(59) >= Convert.ToDateTime(a.CreateTime)) + .OrderByDescending((a, b, c) => a.CreateTime) + .Select((a, b, c) => new WorkInfoOutput { Id = a.Id.SelectAll(), FinalName = b.Name, LineName = c.Name, - DeviceId = a.DeviceId == null?"": a.DeviceId, - Status = d.Status == null ? WorkOrderStatusEnum.Draft : d.Status + DeviceId = a.DeviceId ?? "", + Status = a.Status == null ? WorkOrderStatusEnum.Draft : a.Status }) .ToPagedListAsync(input.PageIndex, input.PageSize); return entity; @@ -215,19 +218,18 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services var entity = await _dbContext.Queryable() .LeftJoin((a, b) => a.FinalId == b.Id) .LeftJoin((a, b, c) => a.LineId == c.Id) - .LeftJoin((a, b, c, d) => d.Id == SqlFunc.Subqueryable().Where(s => s.WorkId == a.Id).OrderByDesc(s => s.CreateTime).Select(s => s.Id)) - .WhereIF(!string.IsNullOrEmpty(input.Name), (a, b, c, d) => b.Name.Contains(input.Name)) - .WhereIF(!string.IsNullOrEmpty(input.Id), (a, b, c, d) => a.Id.Contains(input.Id)) - .WhereIF(input.Status != null, (a, b, c, d) => input.Status.Contains(d.Status)) - .WhereIF(input.StartTime != null, (a, b, c, d) => input.StartTime <= Convert.ToDateTime(a.CreateTime)) - .WhereIF(input.EndTime != null, (a, b, c, d) => input.EndTime.Value.AddHours(23).AddMinutes(59).AddSeconds(59) >= Convert.ToDateTime(a.CreateTime)) - .OrderByDescending((a, b, c, d) => a.CreateTime) - .Select((a, b, c, d) => new WorkInfoOutput + .WhereIF(!string.IsNullOrEmpty(input.Name), (a, b, c) => b.Name.Contains(input.Name)) + .WhereIF(!string.IsNullOrEmpty(input.Id), (a, b, c) => a.Id.Contains(input.Id)) + .WhereIF(input.Status != null, (a, b, c) => input.Status.Contains(a.Status)) + .WhereIF(input.StartTime != null, (a, b, c) => input.StartTime <= Convert.ToDateTime(a.CreateTime)) + .WhereIF(input.EndTime != null, (a, b, c) => input.EndTime.Value.AddHours(23).AddMinutes(59).AddSeconds(59) >= Convert.ToDateTime(a.CreateTime)) + .OrderByDescending((a, b, c) => a.CreateTime) + .Select((a, b, c) => new WorkInfoOutput { Id = a.Id.SelectAll(), FinalName = b.Name, LineName = c.Name, - Status = d.Status == null ? WorkOrderStatusEnum.Draft : d.Status + Status = a.Status == null ? WorkOrderStatusEnum.Draft : a.Status }) .ToPagedListAsync(input.PageIndex, input.PageSize); return entity; @@ -548,10 +550,21 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services [HttpPost] public async Task UpdateStatus(WorkInfoStatusUpdateInput input) { - Pztj_WorkInfoStatusEntity entity = input.Adapt(); - var res = await _dbContext.Insertable(entity).IgnoreColumns(true).ExecuteCommandIdentityIntoEntityAsync(); var entitys = await _dbContext.Queryable().Where(x => x.Id == input.WorkId) - .FirstAsync(); + .FirstAsync(); + Pztj_WorkInfoStatusEntity entity = input.Adapt(); + try + { + _dbContext.Ado.BeginTran(); + await _dbContext.Insertable(entity).IgnoreColumns(true).ExecuteCommandIdentityIntoEntityAsync(); + await _dbContext.Updateable().SetColumns(x => x.Status == input.Status).Where(x => x.Id == input.WorkId).ExecuteCommandAsync(); + _dbContext.Ado.CommitTran(); + } + catch (Exception ex) + { + _dbContext.Ado.RollbackTran(); + throw Oops.Bah("更新失败"); + } var workItems = await _dbContext.Queryable().LeftJoin((a, b) => a.Id == b.WorkId).Where(a => a.BatchId == entitys.BatchId) .Select((a, b) => new WorkInfoOutput { @@ -567,7 +580,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services { await _dbContext.Updateable().SetColumns(x => x.Status == workItems.Max(x => x.Status)).Where(x => x.Id == entitys.BatchId).ExecuteCommandAsync(); } - return res; + return true; } /// /// 修改工单物料状态 @@ -632,14 +645,13 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services { string userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value; string userName = App.User?.FindFirst(ClaimConst.CLAINM_NAME)?.Value; - Pztj_WorkInfoStatusEntity entity = new() + await UpdateStatus(new WorkInfoStatusUpdateInput { WorkId = workId, Status = WorkOrderStatusEnum.Completed, - Remark = $"{userName}[{userId}]点击你强制结束" - }; - var res = await _dbContext.Insertable(entity).IgnoreColumns(true).ExecuteCommandIdentityIntoEntityAsync(); - return res; + Remark = $"{userName}[{userId}]点击了强制结束" + }); + return true; } /// /// 工单状态变更记录 diff --git a/backend/BPA.MES.Base.Web.Core/Startup.cs b/backend/BPA.MES.Base.Web.Core/Startup.cs index 6254849..cbfc3b5 100644 --- a/backend/BPA.MES.Base.Web.Core/Startup.cs +++ b/backend/BPA.MES.Base.Web.Core/Startup.cs @@ -69,7 +69,7 @@ public class Startup : AppStartup } app.UseHttpsRedirection(); - + app.UseStaticFiles(); app.UseRouting(); app.UseCorsAccessor(); @@ -77,7 +77,7 @@ public class Startup : AppStartup app.UseAuthentication(); app.UseAuthorization(); - app.UseInject(string.Empty); + app.UseInject("swagger"); app.UseEndpoints(endpoints => { diff --git a/backend/BPA.MES.Base.Web.Entry/BPA.MES.Base.Web.Entry.csproj b/backend/BPA.MES.Base.Web.Entry/BPA.MES.Base.Web.Entry.csproj index 6839cff..4f228e6 100644 --- a/backend/BPA.MES.Base.Web.Entry/BPA.MES.Base.Web.Entry.csproj +++ b/backend/BPA.MES.Base.Web.Entry/BPA.MES.Base.Web.Entry.csproj @@ -19,6 +19,11 @@ + + + + + diff --git a/backend/BPA.MES.Base.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml b/backend/BPA.MES.Base.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml index 9fe54a3..ee4a573 100644 --- a/backend/BPA.MES.Base.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml +++ b/backend/BPA.MES.Base.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml @@ -16,6 +16,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121. net6.0 win-x64 c8d99f52-edc7-411f-8300-6db14bf59e8c - false + true \ No newline at end of file diff --git a/backend/BPA.MES.Base.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml.user b/backend/BPA.MES.Base.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml.user index 1b2bcd0..deceaec 100644 --- a/backend/BPA.MES.Base.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/backend/BPA.MES.Base.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -5,6 +5,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121. <_PublishTargetUrl>E:\PZTJ.MES\backend\BPA.MES.Base.Web.Entry\bin\Release\net6.0\publish\ - True|2024-01-27T02:07:54.6475711Z;True|2024-01-27T10:07:00.1713996+08:00;True|2024-01-27T10:06:39.3502684+08:00; + True|2024-05-31T07:31:49.0731968Z;True|2024-05-31T15:16:29.2827947+08:00;True|2024-05-23T12:24:54.2540638+08:00;False|2024-05-23T12:24:24.6362916+08:00;True|2024-05-23T12:11:13.9636411+08:00;True|2024-05-23T12:10:21.6566433+08:00;True|2024-05-08T17:55:07.3841087+08:00;True|2024-01-27T10:07:54.6475711+08:00;True|2024-01-27T10:07:00.1713996+08:00;True|2024-01-27T10:06:39.3502684+08:00; \ No newline at end of file