diff --git a/ZR.Admin.WebApi/Controllers/System/TasksController.cs b/ZR.Admin.WebApi/Controllers/System/TasksController.cs index 8f8cf736..494024d0 100644 --- a/ZR.Admin.WebApi/Controllers/System/TasksController.cs +++ b/ZR.Admin.WebApi/Controllers/System/TasksController.cs @@ -87,8 +87,10 @@ namespace ZR.Admin.WebApi.Controllers throw new CustomException($"程序集或者类名不能为空"); } //从 Dto 映射到 实体 + var tasksQz = parm.Adapt().ToCreate(); - tasksQz.Create_by = HttpContext.GetName(); + //tasksQz.Create_by = HttpContext.GetName(); + tasksQz.Create_by = "admin"; tasksQz.ID = SnowFlakeSingle.Instance.NextId().ToString(); return SUCCESS(_tasksQzService.AddTasks(tasksQz)); @@ -127,7 +129,8 @@ namespace ZR.Admin.WebApi.Controllers throw new CustomException($"该任务正在运行中,请先停止在更新"); } var model = parm.Adapt(); - model.Update_by = HttpContextExtension.GetName(HttpContext); + model.Update_by = "admin"; + //model.Update_by = HttpContextExtension.GetName(HttpContext); int response = _tasksQzService.UpdateTasks(model); if (response > 0) { diff --git a/ZR.Admin.WebApi/Controllers/mes/ql/PainLab03Controller.cs b/ZR.Admin.WebApi/Controllers/mes/ql/PainLab03Controller.cs index d6169ba8..f83e85bc 100644 --- a/ZR.Admin.WebApi/Controllers/mes/ql/PainLab03Controller.cs +++ b/ZR.Admin.WebApi/Controllers/mes/ql/PainLab03Controller.cs @@ -50,6 +50,28 @@ namespace ZR.Admin.WebApi.Controllers.mes.ql return ToResponse(new ApiResult(200, "success", ret)); } + /// + /// 根据工单自动生成批处理记录 + /// + /// 执行时间 + /// + [HttpGet("AddBatchListByWorkOrder")] + public IActionResult AddBatchListByWorkOrder(DateTime actionDate) + { + try + { + int ret = plBatchService.CreatePLBatchRecordsByWorkOrder(actionDate); + + return ToResponse(new ApiResult(200, "success", ret)); + } + catch (Exception e) + { + return ToResponse(new ApiResult(500, "error", e.Message)); + throw; + } + + } + /// /// 删除测试数据记录 /// @@ -89,6 +111,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.ql PLBatch pLBatch = new PLBatch(); pLBatch.Id = pLBatchDto.Id; pLBatch.IdGroup = pLBatchDto.plIdGroup; + pLBatch.Workorder = pLBatchDto.Workorder; pLBatch.Description = pLBatchDto.Description; pLBatch.Code = pLBatchDto.plCode; pLBatch.Dt = pLBatchDto.plDt; diff --git a/ZR.Admin.WebApi/Extensions/EntityExtension.cs b/ZR.Admin.WebApi/Extensions/EntityExtension.cs index 622879fd..fc06210d 100644 --- a/ZR.Admin.WebApi/Extensions/EntityExtension.cs +++ b/ZR.Admin.WebApi/Extensions/EntityExtension.cs @@ -14,11 +14,13 @@ namespace ZR.Admin.WebApi.Extensions types.GetProperty("CreateTime", flag)?.SetValue(source, DateTime.Now, null); types.GetProperty("CreatedTime", flag)?.SetValue(source, DateTime.Now, null); types.GetProperty("AddTime", flag)?.SetValue(source, DateTime.Now, null); - types.GetProperty("CreateBy", flag)?.SetValue(source, context.GetName(), null); - types.GetProperty("Create_by", flag)?.SetValue(source, context.GetName(), null); - types.GetProperty("CreatedBy", flag)?.SetValue(source, context.GetName(), null); - types.GetProperty("UserId", flag)?.SetValue(source, context.GetUId(), null); - + if(context != null) + { + types.GetProperty("CreateBy", flag)?.SetValue(source, context.GetName(), null); + types.GetProperty("Create_by", flag)?.SetValue(source, context.GetName(), null); + types.GetProperty("CreatedBy", flag)?.SetValue(source, context.GetName(), null); + types.GetProperty("UserId", flag)?.SetValue(source, context.GetUId(), null); + } return source; } @@ -31,10 +33,12 @@ namespace ZR.Admin.WebApi.Extensions types.GetProperty("UpdateTime", flag)?.SetValue(source, DateTime.Now, null); types.GetProperty("Update_time", flag)?.SetValue(source, DateTime.Now, null); types.GetProperty("UpdatedTime", flag)?.SetValue(source, DateTime.Now, null); - types.GetProperty("UpdateBy", flag)?.SetValue(source, context.GetName(), null); - types.GetProperty("Update_by", flag)?.SetValue(source, context.GetName(), null); - types.GetProperty("UpdatedBy", flag)?.SetValue(source, context.GetName(), null); - + if(context != null) + { + types.GetProperty("UpdateBy", flag)?.SetValue(source, context.GetName(), null); + types.GetProperty("Update_by", flag)?.SetValue(source, context.GetName(), null); + types.GetProperty("UpdatedBy", flag)?.SetValue(source, context.GetName(), null); + } return source; } diff --git a/ZR.Model/MES/ql/DTO/PLBatchDto.cs b/ZR.Model/MES/ql/DTO/PLBatchDto.cs index 2ababb18..e216d844 100644 --- a/ZR.Model/MES/ql/DTO/PLBatchDto.cs +++ b/ZR.Model/MES/ql/DTO/PLBatchDto.cs @@ -16,6 +16,11 @@ /// public string plIdGroup { get; set; } + /// + /// 来源工单号 + /// + public string Workorder { get; set; } + /// /// 产品描述 /// diff --git a/ZR.Model/MES/ql/PLBatch.cs b/ZR.Model/MES/ql/PLBatch.cs index a1bf312c..586279a1 100644 --- a/ZR.Model/MES/ql/PLBatch.cs +++ b/ZR.Model/MES/ql/PLBatch.cs @@ -20,6 +20,12 @@ public string IdGroup { get; set; } + /// + /// 来源工单号 + /// + [SugarColumn(ColumnName = "workorder")] + public string Workorder { get; set; } + /// /// 产品描述 /// diff --git a/ZR.Model/MES/wms/Dto/WmMaterialDto.cs b/ZR.Model/MES/wms/Dto/WmMaterialDto.cs index a56d137a..3535a193 100644 --- a/ZR.Model/MES/wms/Dto/WmMaterialDto.cs +++ b/ZR.Model/MES/wms/Dto/WmMaterialDto.cs @@ -176,6 +176,7 @@ namespace ZR.Model.MES.wms.Dto public string Key { get; set; } public string Label { get; set; } public string Value { get; set; } + public string Color { get; set; } } } \ No newline at end of file diff --git a/ZR.Service/mes/ql/PLBatchService.cs b/ZR.Service/mes/ql/PLBatchService.cs index 5a5c76be..ee01612e 100644 --- a/ZR.Service/mes/ql/PLBatchService.cs +++ b/ZR.Service/mes/ql/PLBatchService.cs @@ -1,6 +1,7 @@ using Infrastructure.Attribute; using SqlSugar; using System; +using System.Collections.Generic; using System.Globalization; using ZR.Model.MES.pro; using ZR.Model.MES.ql; @@ -73,14 +74,18 @@ namespace ZR.Service.mes.ql .ToExpression(); List workOrderList = Context.Queryable() .Where(predicate) - .OrderBy(it => it.Sort) + .OrderByDescending(it => it.Sort) .ToList(); foreach(ProWorkorder_v2 workorder in workOrderList) { - + List pLBatches = CreatePLBatchRecordsByWorkOrder(workorder); + int res = Context.Insertable(pLBatches).ExecuteCommand(); + if (res == 0) + { + Context.Ado.RollbackTran(); + throw new Exception("插入批量检测记录异常,异常工单:" + workorder.ClientWorkorder); + } } - - Context.Ado.CommitTran(); return 1; } @@ -106,6 +111,40 @@ namespace ZR.Service.mes.ql PLBatch t4 = GetDefaultPLBatch(); PLBatch t5 = GetDefaultPLBatch(); PLBatch t6 = GetDefaultPLBatch(); + + // 工单信息录入 + t1.Dt = DateTime.Now.ToString("yyyy.MM.dd"); + t1.Description = workorder.ProductDescription; + t1.Code = workorder.Colour; + t1.Workorder = workorder.ClientWorkorder; + + t2.Dt = DateTime.Now.ToString("yyyy.MM.dd"); + t2.Description = workorder.ProductDescription; + t2.Code = workorder.Colour; + t2.Workorder = workorder.ClientWorkorder; + + t3.Dt = DateTime.Now.ToString("yyyy.MM.dd"); + t3.Description = workorder.ProductDescription; + t3.Code = workorder.Colour; + t3.Workorder = workorder.ClientWorkorder; + + t4.Dt = DateTime.Now.ToString("yyyy.MM.dd"); + t4.Description = workorder.ProductDescription; + t4.Code = workorder.Colour; + t4.Workorder = workorder.ClientWorkorder; + + t5.Dt = DateTime.Now.ToString("yyyy.MM.dd"); + t5.Description = workorder.ProductDescription; + t5.Code = workorder.Colour; + t5.Workorder = workorder.ClientWorkorder; + + t6.Dt = DateTime.Now.ToString("yyyy.MM.dd"); + t6.Description = workorder.ProductDescription; + t6.Code = workorder.Colour; + t6.Workorder = workorder.ClientWorkorder; + + + t1.Value01 = "15°"; t1.Value07 = "0"; t1.Value09 = "R1"; t1.Value14 = "底漆"; t1.Value19 = "2"; t2.Value01 = "25°"; t2.Value07 = "0"; t2.Value09 = "R2"; t2.Value14 = "色漆"; t2.Value19 = "2"; t3.Value01 = "45°"; t3.Value07 = "0"; t3.Value09 = "R3"; t3.Value14 = "云母"; t3.Value19 = "2"; @@ -155,8 +194,8 @@ namespace ZR.Service.mes.ql endTime = endTime.ToLocalTime(); int totalNum = 0; var predicate = Expressionable.Create() - .AndIF(starttime > new DateTime(2023, 1, 1, 0, 0, 0), it => it.CreatedTime >= starttime.ToLocalTime()) - .AndIF(endTime > new DateTime(2023, 1, 1, 0, 0, 0), it => it.CreatedTime <= endTime.ToLocalTime()) + .AndIF(starttime > new DateTime(2023, 1, 1, 0, 0, 0), it => it.CreatedTime >= starttime) + .AndIF(endTime > new DateTime(2023, 1, 1, 0, 0, 0), it => it.CreatedTime <= endTime) .AndIF(!string.IsNullOrEmpty(code), it => it.Code.Contains(code)) .AndIF(!string.IsNullOrEmpty(description), it => it.Description.Contains(description)) .ToExpression(); @@ -187,6 +226,7 @@ namespace ZR.Service.mes.ql { Id = 0, IdGroup = DateTime.Now.ToString("yyyyMMddHHmmssfff"), + Workorder = "", Description = "", Dt = "", Code = "", @@ -246,7 +286,7 @@ namespace ZR.Service.mes.ql } else { - return (int)dayOfWeek + 1; + return (int)dayOfWeek; } } } diff --git a/ZR.Service/mes/ql/PLRawMaterialService.cs b/ZR.Service/mes/ql/PLRawMaterialService.cs index 9fc64517..25eab44c 100644 --- a/ZR.Service/mes/ql/PLRawMaterialService.cs +++ b/ZR.Service/mes/ql/PLRawMaterialService.cs @@ -158,7 +158,8 @@ namespace ZR.Service.mes.ql { Key = it.Id, Label = "[ " + it.Partnumber + " ] " + it.Description, - Value = it.Description + Value = it.Description, + Color = it.Color } ) .Take(10) diff --git a/ZR.Tasks/TaskScheduler/Job_Blank.cs b/ZR.Tasks/TaskScheduler/Job_Blank.cs index f56f233e..580fd43c 100644 --- a/ZR.Tasks/TaskScheduler/Job_Blank.cs +++ b/ZR.Tasks/TaskScheduler/Job_Blank.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.Threading.Tasks; using Infrastructure.Attribute; using JinianNet.JNTemplate; +using Mapster.Utils; using Model.DBModel; using Quartz; using SqlSugar; @@ -31,6 +32,7 @@ namespace ZR.Tasks.TaskScheduler public async Task Run() { + Console.WriteLine("执行毛坯调试自动出库"); await Task.Delay(1); //TODO 业务逻辑 DateTime nowTime = DateTime.Now;