diff --git a/ZR.Admin.WebApi/Controllers/mes/ql/PainLab03Controller.cs b/ZR.Admin.WebApi/Controllers/mes/ql/PainLab03Controller.cs index 7f26b2ab..05c2cfd4 100644 --- a/ZR.Admin.WebApi/Controllers/mes/ql/PainLab03Controller.cs +++ b/ZR.Admin.WebApi/Controllers/mes/ql/PainLab03Controller.cs @@ -73,6 +73,28 @@ namespace ZR.Admin.WebApi.Controllers.mes.ql } + /// + /// 根据工单自动生成批处理记录 + /// + /// 执行时间 + /// + [HttpGet("AddBatchListByWorkOrder2")] + public IActionResult AddBatchListByWorkOrder2(int year,int week,int day) + { + try + { + int ret = plBatchService.CreatePLBatchRecordsByWorkOrder(year,week,day); + + return ToResponse(new ApiResult(200, "success", ret)); + } + catch (Exception e) + { + return ToResponse(new ApiResult(500, "error", e.Message)); + throw; + } + + } + /// /// 删除测试数据记录 /// diff --git a/ZR.Service/mes/ql/IService/IPLBatchService.cs b/ZR.Service/mes/ql/IService/IPLBatchService.cs index 6d626512..8db0c6d9 100644 --- a/ZR.Service/mes/ql/IService/IPLBatchService.cs +++ b/ZR.Service/mes/ql/IService/IPLBatchService.cs @@ -18,6 +18,7 @@ namespace ZR.Service.mes.ql.IService public int CreatePLBatchRecordsByWorkOrder(DateTime actionDate); - + // 根据年月日生成数据 + public int CreatePLBatchRecordsByWorkOrder(int year,int week,int day); } } diff --git a/ZR.Service/mes/ql/PLBatchService.cs b/ZR.Service/mes/ql/PLBatchService.cs index 05411aea..4ad84b15 100644 --- a/ZR.Service/mes/ql/PLBatchService.cs +++ b/ZR.Service/mes/ql/PLBatchService.cs @@ -95,6 +95,52 @@ namespace ZR.Service.mes.ql } } + /// + /// 根据年月日生成实验室批量工单 + /// + /// + /// + /// + /// + /// + public int CreatePLBatchRecordsByWorkOrder(int year, int week, int day) + { + try + { + Context.Ado.BeginTran(); + // 查询工单 + var predicate = Expressionable + .Create() + .And(it => it.Year == year) + .And(it => it.Week == week) + .And(it => it.Date == day) + //.And(it => it.Remark2.Contains("调试")) + .And(it => it.Remark3 == "是") + .ToExpression(); + List workOrderList = Context.Queryable() + .Where(predicate) + .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; + } + catch (Exception) + { + Context.Ado.RollbackTran(); + throw; + } + } + /// /// 根据工单创建批量检测数据 /// @@ -200,6 +246,7 @@ namespace ZR.Service.mes.ql .AndIF(!string.IsNullOrEmpty(workOrder), it => it.Workorder.Contains(workOrder)) .AndIF(!string.IsNullOrEmpty(code), it => it.Code.Contains(code)) .AndIF(!string.IsNullOrEmpty(description), it => it.Description.Contains(description)) + .ToExpression(); //int totalNum = 0; @@ -291,5 +338,6 @@ namespace ZR.Service.mes.ql return (int)dayOfWeek; } } + } }