From 9cf41d21a35fc8c5c6d20f564dce6b7e7076d0a1 Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Thu, 7 Nov 2024 16:45:06 +0800 Subject: [PATCH] 1 --- .../JobKanban/WorkOrderProgressController.cs | 11 +++++ .../MES/product/ProWorkorderController.cs | 15 +++++- .../IService/IWorkorderProgressService.cs | 2 + .../JobKanban/WorkorderProgressService.cs | 8 ++++ .../product/IService/IProWorkorderService.cs | 2 + .../MES/product/ProReportworkService.cs | 48 +++++++++++-------- .../MES/product/ProWorkorderService.cs | 32 +++++++++++++ 7 files changed, 98 insertions(+), 20 deletions(-) diff --git a/DOAN.Admin.WebApi/Controllers/JobKanban/WorkOrderProgressController.cs b/DOAN.Admin.WebApi/Controllers/JobKanban/WorkOrderProgressController.cs index 09b7e4b..a326790 100644 --- a/DOAN.Admin.WebApi/Controllers/JobKanban/WorkOrderProgressController.cs +++ b/DOAN.Admin.WebApi/Controllers/JobKanban/WorkOrderProgressController.cs @@ -64,6 +64,17 @@ public class WorkOrderProgressController : BaseController var response = workorderProgressService.GetWorkOrderListNoFinish(today, line_code, group_code); return SUCCESS(response); } + //TODO 获取全部工单 + //TODO 根据班组 ,产线 和日期获取all工单 + [HttpGet("get_workorder_list")] + public IActionResult GetWorkOrderList(string group_code, string line_code, DateTime handleDate) + { + if (string.IsNullOrEmpty(group_code) || string.IsNullOrEmpty(line_code) || handleDate == DateTime.MinValue) + return SUCCESS(null); + var response = workorderProgressService.GetWorkOrderList(group_code, line_code, handleDate); + + return SUCCESS(response); + } // 获取工单详情 diff --git a/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderController.cs b/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderController.cs index f255c0b..2d368a6 100644 --- a/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderController.cs +++ b/DOAN.Admin.WebApi/Controllers/MES/product/ProWorkorderController.cs @@ -361,6 +361,19 @@ namespace DOAN.Admin.WebApi.Controllers return SUCCESS(response); } - + + // TODO 如果没有id 传入工单 手动生成报工记录 + [HttpGet("manual_generation_reportwork")] + public IActionResult ManualGenerationOfReportWork(string workorder) + { + if (string.IsNullOrEmpty(workorder)) { + throw new CustomException("workorder is null"); + } + + var response = _ProWorkorderService.ManualGenerationOfReportWork(workorder,HttpContext.GetName()); + return SUCCESS(response); + } + + } } diff --git a/DOAN.Service/JobKanban/IService/IWorkorderProgressService.cs b/DOAN.Service/JobKanban/IService/IWorkorderProgressService.cs index 9bd30e8..25a8ad5 100644 --- a/DOAN.Service/JobKanban/IService/IWorkorderProgressService.cs +++ b/DOAN.Service/JobKanban/IService/IWorkorderProgressService.cs @@ -19,6 +19,8 @@ namespace DOAN.Service.JobKanban.IService List GetWorkOrderListNoFinish(DateTime today, string line_code, string group_code); + List GetWorkOrderList(string group_code, string line_code, DateTime handleDate); + ProWorkorderDto4 GetWorkOrderDetail(string workorder); diff --git a/DOAN.Service/JobKanban/WorkorderProgressService.cs b/DOAN.Service/JobKanban/WorkorderProgressService.cs index 1c2abd3..581d95c 100644 --- a/DOAN.Service/JobKanban/WorkorderProgressService.cs +++ b/DOAN.Service/JobKanban/WorkorderProgressService.cs @@ -23,7 +23,15 @@ public class WorkorderProgressService : BaseService, IWorkorderPro return Context.Queryable().Where(it => it.Status == 1).ToList(); } + public List GetWorkOrderList(string group_code, string line_code, DateTime handleDate) + { + handleDate = handleDate.ToLocalTime().Date; + return Context.Queryable().Where(it => it.GroupCode == group_code) + .Where(it => it.LineCode == line_code) + .Where(it => it.WorkorderDate == handleDate) + .ToList(); + } public List GetReportWorkRecord(string group_code, string line_code, DateTime handleDate) { diff --git a/DOAN.Service/MES/product/IService/IProWorkorderService.cs b/DOAN.Service/MES/product/IService/IProWorkorderService.cs index 1ffadfd..e4d9ba8 100644 --- a/DOAN.Service/MES/product/IService/IProWorkorderService.cs +++ b/DOAN.Service/MES/product/IService/IProWorkorderService.cs @@ -61,5 +61,7 @@ namespace DOAN.Service.MES.product.IService int WorkOrderLog(string workorder, string log, string Operator); + int ManualGenerationOfReportWork(string workorder, string CreatedBy); + } } diff --git a/DOAN.Service/MES/product/ProReportworkService.cs b/DOAN.Service/MES/product/ProReportworkService.cs index 5892fcc..42fb8bc 100644 --- a/DOAN.Service/MES/product/ProReportworkService.cs +++ b/DOAN.Service/MES/product/ProReportworkService.cs @@ -31,23 +31,33 @@ namespace DOAN.Service.MES.product /// public PagedInfo GetList(ProReportworkQueryDto parm) { - if(parm.TimeRange!=null&&parm.TimeRange.Length == 2) + if (parm.TimeRange != null && parm.TimeRange.Length == 2) { - parm.TimeRange[0]= parm.TimeRange[0].Date; - parm.TimeRange[1]= parm.TimeRange[1].Date.AddDays(1); + parm.TimeRange[0] = parm.TimeRange[0].Date; + parm.TimeRange[1] = parm.TimeRange[1].Date.AddDays(1); } - var predicate = Expressionable.Create() - .AndIF(!string.IsNullOrEmpty(parm.FkWorkorder),it=>it.FkWorkorder.Contains(parm.FkWorkorder)) - .AndIF(!string.IsNullOrEmpty(parm.GroupCode),it=>it.GroupCode==parm.FkWorkorder) - .AndIF(!string.IsNullOrEmpty(parm.LineCode),it=>it.LineCode==parm.FkWorkorder) - .AndIF(parm.TimeRange != null && parm.TimeRange.Length == 2 && parm.TimeRange[0]>DateTime.MinValue,it=>it.CreatedTime>= parm.TimeRange[0]) - .AndIF(parm.TimeRange != null && parm.TimeRange.Length == 2 && parm.TimeRange[1]>DateTime.MinValue,it=>it.CreatedTime<= parm.TimeRange[1]) + var predicate = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(parm.FkWorkorder), (w, r) => w.Workorder.Contains(parm.FkWorkorder)) + .AndIF(!string.IsNullOrEmpty(parm.GroupCode), (w, r) => w.GroupCode == parm.FkWorkorder) + .AndIF(!string.IsNullOrEmpty(parm.LineCode), (w, r) => w.LineCode == parm.FkWorkorder) + .AndIF(parm.TimeRange != null && parm.TimeRange.Length == 2 && parm.TimeRange[0] > DateTime.MinValue, (w, r) => w.WorkorderDate >= parm.TimeRange[0]) + .AndIF(parm.TimeRange != null && parm.TimeRange.Length == 2 && parm.TimeRange[1] > DateTime.MinValue, (w, r) => w.WorkorderDate <= parm.TimeRange[1]) ; - var response = Queryable() - .Where(predicate.ToExpression()) - .ToPage(parm); + + + var response = Context.Queryable().LeftJoin((w, r) => w.Workorder == r.FkWorkorder) + .Where(predicate.ToExpression()) + .Select((w, r) => new ProReportworkDto + { + Id = r.Id, + FkWorkorder =w.Workorder, + GroupCode = w.GroupCode, + LineCode = w.LineCode, + DispatchNum=w.DeliveryNum, + + }, true).ToPage_NO_Convert(parm); return response; } @@ -103,14 +113,14 @@ namespace DOAN.Service.MES.product public List UserExport(DateTime handleDate) { - // DateTime AddhandleDate = handleDate.AddDays(1); + // DateTime AddhandleDate = handleDate.AddDays(1); - return Context.Queryable() - .LeftJoin((w, r) => w.Workorder == r.FkWorkorder) - .Where((w, r) => w.WorkorderDate == handleDate) - .Select((w, r) => r) - .ToList() - .Adapt>(); + return Context.Queryable() + .LeftJoin((w, r) => w.Workorder == r.FkWorkorder) + .Where((w, r) => w.WorkorderDate == handleDate) + .Select((w, r) => r) + .ToList() + .Adapt>(); } diff --git a/DOAN.Service/MES/product/ProWorkorderService.cs b/DOAN.Service/MES/product/ProWorkorderService.cs index 4a15199..03912e6 100644 --- a/DOAN.Service/MES/product/ProWorkorderService.cs +++ b/DOAN.Service/MES/product/ProWorkorderService.cs @@ -34,6 +34,7 @@ using Microsoft.AspNetCore.Authentication; using System.Reflection; using Infrastructure; using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Http.HttpResults; namespace DOAN.Service.MES.product { @@ -1222,6 +1223,37 @@ namespace DOAN.Service.MES.product return result; + } + /// + /// 如果没有id 传入工单 手动生成报工记录 + /// + /// + /// + public int ManualGenerationOfReportWork(string workorder,string CreatedBy) + { + bool isEXsit= Context.Queryable().Where(it => it.FkWorkorder == workorder).Any(); + + if (isEXsit) { + return -1; + + } + ProWorkorder handleWorkorder= Context.Queryable().Where(it => it.Workorder == workorder).First(); + ProReportwork proReportwork =new + ProReportwork(); + proReportwork.Id = XueHua; + proReportwork.FkWorkorder = workorder; + proReportwork.DispatchNum = handleWorkorder.DeliveryNum; + proReportwork.FinishedNum = null; + proReportwork.GroupCode = handleWorkorder.GroupCode; + proReportwork.LineCode = handleWorkorder.LineCode; + proReportwork.CreatedBy = CreatedBy; + proReportwork.CreatedTime = DateTime.Now; + + return Context.Insertable(proReportwork).ExecuteCommand(); + + + + } }