From 12e17bd651b4275cffde8279231f07830652b330 Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Tue, 3 Dec 2024 19:39:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=B7=A5=E5=BA=8F=E6=8A=A5?= =?UTF-8?q?=E5=B7=A5=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Mobile/ReportFlowController.cs | 23 +++++++++++ .../Mobile/IService/IReportFlowService.cs | 6 ++- DOAN.Service/Mobile/ReportFlowService.cs | 41 ++++++++++++++++++- .../WebExtensions/HttpContextExtension.cs | 7 ++++ 4 files changed, 75 insertions(+), 2 deletions(-) diff --git a/DOAN.Admin.WebApi/Controllers/Mobile/ReportFlowController.cs b/DOAN.Admin.WebApi/Controllers/Mobile/ReportFlowController.cs index a5be093..d7cf7ea 100644 --- a/DOAN.Admin.WebApi/Controllers/Mobile/ReportFlowController.cs +++ b/DOAN.Admin.WebApi/Controllers/Mobile/ReportFlowController.cs @@ -26,6 +26,29 @@ public class ReportFlowController : BaseController throw new CustomException("workOrderId 是空"); return SUCCESS(_reportFlowService.GetWorkOrderDetail(workOrder)); } + //TODO 查询工序报工详情 + [HttpGet("get_process_reportwork_detail")] + public IActionResult GetProcessReportWorkDetail(string workorder, string process) + { + if (string.IsNullOrEmpty(workorder) || string.IsNullOrEmpty(process)) + { + throw new CustomException("workorder or process is null"); + } + return SUCCESS(_reportFlowService.GetProcessReportWorkDetail(workorder, process)); + } + + //TODO 工序报工 + [HttpGet("process_reportwork")] + public IActionResult ProcessReportWork(string workorder, string process, int finish_num,int bad_num) + { + if (string.IsNullOrEmpty(workorder) || string.IsNullOrEmpty(process)) + { + throw new CustomException("workorder or process is null"); + } + + return SUCCESS(_reportFlowService.ProcessReportWork(workorder, process, finish_num,bad_num,HttpContext.GetNickName())); + } + } \ No newline at end of file diff --git a/DOAN.Service/Mobile/IService/IReportFlowService.cs b/DOAN.Service/Mobile/IService/IReportFlowService.cs index a05b31c..a3445ed 100644 --- a/DOAN.Service/Mobile/IService/IReportFlowService.cs +++ b/DOAN.Service/Mobile/IService/IReportFlowService.cs @@ -5,6 +5,10 @@ namespace DOAN.Service.Mobile.IService; public interface IReportFlowService: IBaseService { - ProWorkorder GetWorkOrderDetail(string workorder); + ProWorkorder GetWorkOrderDetail(string workorder); + + ProReportwork01 GetProcessReportWorkDetail(string workorder, string process); + + bool ProcessReportWork(string workorder, string process, int finish_num,int bad_num,string Worker); } \ No newline at end of file diff --git a/DOAN.Service/Mobile/ReportFlowService.cs b/DOAN.Service/Mobile/ReportFlowService.cs index 3e2e888..833df49 100644 --- a/DOAN.Service/Mobile/ReportFlowService.cs +++ b/DOAN.Service/Mobile/ReportFlowService.cs @@ -15,7 +15,46 @@ public class ReportFlowService : BaseService, IReportFlowServic { public ProWorkorder GetWorkOrderDetail(string workorder) { - return Context.Queryable().Where(x => x.Workorder == workorder).Single(); + return Context.Queryable().Where(x => x.Workorder == workorder).First(); + } + + public ProReportwork01 GetProcessReportWorkDetail(string workorder, string process) + { + return Context.Queryable().Where(x => x.Workorder == workorder && x.ProcessCode == process).First(); + } + + public bool ProcessReportWork(string workorder, string process, int finish_num,int bad_num,string Worker) + { + int result = 0; + bool Exist= Context.Queryable().Where(it => it.Workorder == workorder&&it.ProcessCode==process).Any(); + if (Exist) + { + result= Context.Updateable().Where(it => it.Workorder == workorder && it.ProcessCode == process) + .SetColumns(it => it.FinishNum == finish_num) + .SetColumns(it => it.BadNum == bad_num) + .SetColumns(it => it.Worker == Worker) + .SetColumns(it => it.JobDate == DateTime.Today) + .SetColumns(it => it.UpdatedBy == Worker) + .SetColumns(it => it.UpdatedTime == DateTime.Now) + .ExecuteCommand(); + + } + else + { + ProReportwork01 proReportwork01=new ProReportwork01(); + proReportwork01.Id = XueHua; + proReportwork01.Workorder = workorder; + proReportwork01.ProcessCode = process; + proReportwork01.FinishNum = finish_num; + proReportwork01.BadNum = bad_num; + proReportwork01.Worker = Worker; + proReportwork01.JobDate = DateTime.Today; + proReportwork01.CreatedBy = Worker; + proReportwork01.CreatedTime = DateTime.Now; + result= Context.Insertable(proReportwork01).ExecuteCommand(); + + } + return result>0; } } diff --git a/Infrastructure/WebExtensions/HttpContextExtension.cs b/Infrastructure/WebExtensions/HttpContextExtension.cs index da276f7..f33445f 100644 --- a/Infrastructure/WebExtensions/HttpContextExtension.cs +++ b/Infrastructure/WebExtensions/HttpContextExtension.cs @@ -9,6 +9,7 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using UAParser; using DOAN.Infrastructure.IPTools; +using Infrastructure.Model; namespace Infrastructure.Extensions { @@ -103,6 +104,12 @@ namespace Infrastructure.Extensions return uid; } + public static string GetNickName(this HttpContext context) + { + + TokenModel tokenModel= JwtUtil.GetLoginUser(context); + return tokenModel?.UserName; + } /// /// 判断是否是管理员