From ddde4eb9d7e9d3aac67f55ef6ad151a469e7b2bb Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Sat, 21 Dec 2024 10:02:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A6=E6=91=B8=E5=B1=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Mobile/ReportFlowController.cs | 63 +++++++++++++++++++ .../appsettings.Development.json | 3 +- DOAN.Admin.WebApi/appsettings.Production.json | 2 +- .../MES/Device/DeviceTaskExecuteService.cs | 13 +--- .../Product/ProductSmartScreenService.cs | 1 - .../Mobile/IService/IReportFlowService.cs | 9 +++ DOAN.Service/Mobile/ReportFlowService.cs | 52 ++++++++++++++- .../TaskScheduler/Job_Device_Execute.cs | 1 + 8 files changed, 128 insertions(+), 16 deletions(-) diff --git a/DOAN.Admin.WebApi/Controllers/Mobile/ReportFlowController.cs b/DOAN.Admin.WebApi/Controllers/Mobile/ReportFlowController.cs index f47a5f5..c0122f9 100644 --- a/DOAN.Admin.WebApi/Controllers/Mobile/ReportFlowController.cs +++ b/DOAN.Admin.WebApi/Controllers/Mobile/ReportFlowController.cs @@ -1,4 +1,5 @@ using DOAN.Service.Mobile.IService; +using Infrastructure.Converter; using Microsoft.AspNetCore.Mvc; namespace DOAN.Admin.WebApi.Controllers.Mobile; @@ -17,6 +18,28 @@ public class ReportFlowController : BaseController { _reportFlowService = reportFlowService; } + /// + /// 根据指定日期获取工单列表 + /// + /// + /// + /// + /// + + [HttpGet("get_workorders_by_date")] + public IActionResult GetWorkOrdersByDate(DateTime startDate, DateTime endDate) + { + startDate = DOANConvertDate.ConvertLocalDate(startDate); + endDate = DOANConvertDate.ConvertLocalDate(endDate); + if(startDate == DateTime.MinValue||endDate==DateTime.MinValue) + { + throw new CustomException("date is error"); + } + var response = _reportFlowService.GetWorkOrdersByDate(startDate, endDate); + return SUCCESS(response); + } + + //TODO 查询工单详情 /// @@ -110,6 +133,46 @@ public class ReportFlowController : BaseController return SUCCESS(_reportFlowService.GetWorkOrderReportWorkList(workorder)); } + + + //TODO 输入姓名拼音,查询此人今日报工记录 + [HttpGet("get_report_info_by_name")] + public IActionResult GetReportInfoByName(string name) + { + if (string.IsNullOrEmpty(name)) + { + throw new CustomException("name is null"); + + } + var response= _reportFlowService.GetReportInfoByName(name); + return SUCCESS(response); + + } + + + + + //TODO 根据工艺路线获取所有工序 + [HttpGet("get_process_by_route")] + public IActionResult GetProcessByRoute(int route_id=32) + { + var response = _reportFlowService.GetProcessByRoute(route_id); + return SUCCESS(response); + + } + + + + //TODO 输入工序id 查询今天报工记录 + [HttpGet("get_report_by_processid")] + public IActionResult GetReportByProcessId(int processId) + { + if (processId <= 0) { + throw new CustomException("processId is error"); + } + var response = _reportFlowService.GetReportByProcessId(processId); + return SUCCESS(response); + } diff --git a/DOAN.Admin.WebApi/appsettings.Development.json b/DOAN.Admin.WebApi/appsettings.Development.json index 82e217b..4293b8e 100644 --- a/DOAN.Admin.WebApi/appsettings.Development.json +++ b/DOAN.Admin.WebApi/appsettings.Development.json @@ -2,6 +2,7 @@ "dbConfigs": [ { // 远程测试服务器 + //"Conn": "Data Source=192.168.1.106;User ID=root;Password=123456;Initial Catalog=bzfm_mes;Port=3306", "Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog=bzfm_mes;Port=3308", // "Conn": "Data Source=192.168.0.58;User ID=root;Password=123456;Initial Catalog=bzfm_mes;Port=3306", "DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4 @@ -19,7 +20,7 @@ "DbName": "bzfm_mes" //代码生成默认连接数据库,Oracle库是实例的名称 }, "ShowDbLog": true, //是否打印db日志 - "urls": "http://0.0.0.0:7000", //项目启动url,如果改动端口前端对应devServer也需要进行修改 + "urls": "http://127.0.0.1:7000", //项目启动url,如果改动端口前端对应devServer也需要进行修改 "corsUrls": [ "http://localhost:8887", "http://localhost:8886", "http://localhost:9090", "http://localhost:8080" ], //跨域地址(前端启动项目,前后端分离单独部署需要设置),多个用","隔开 "Upload": { "rootDirectory": "D:/MES_Test/file", diff --git a/DOAN.Admin.WebApi/appsettings.Production.json b/DOAN.Admin.WebApi/appsettings.Production.json index b2c95fa..0a35c82 100644 --- a/DOAN.Admin.WebApi/appsettings.Production.json +++ b/DOAN.Admin.WebApi/appsettings.Production.json @@ -2,7 +2,7 @@ "dbConfigs": [ { // 远程测试服务器 - "Conn": "Data Source=127.0.0.1;User ID=root;Password=123456;Initial Catalog=bzfm_mes;Port=3306", + "Conn": "Data Source=192.168.1.106;User ID=root;Password=123456;Initial Catalog=bzfm_mes;Port=3306", "DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4 "ConfigId": "0", //多租户唯一标识 "IsAutoCloseConnection": true diff --git a/DOAN.Service/MES/Device/DeviceTaskExecuteService.cs b/DOAN.Service/MES/Device/DeviceTaskExecuteService.cs index 03e864f..ef41cf6 100644 --- a/DOAN.Service/MES/Device/DeviceTaskExecuteService.cs +++ b/DOAN.Service/MES/Device/DeviceTaskExecuteService.cs @@ -200,6 +200,7 @@ namespace DOAN.Service.MES.dev .Where(it => it.LifeCycleStart <= DateTime.Now) .Where(it => it.LifeCycleEnd >= DateTime.Now) .ToList(); + // 今日时间 DateTime CurrentTime = new DateTime( DateTime.Now.Year, @@ -209,12 +210,11 @@ namespace DOAN.Service.MES.dev 0, 0 ); - //1. 扫描巡检 List deviceRouteInspectionPlan_execute_List = new List(); #region 1.1 每日类型处理 - + List RouteInspectionPlan_day_List = InitDataList .Where(it => it.ExcuteCycleType == 1) .ToList(); @@ -225,7 +225,7 @@ namespace DOAN.Service.MES.dev foreach (var item in RouteInspectionPlan_day_List) { //开始日期 - DateTime start_cal = (DateTime)item.CreatedTime; + DateTime start_cal =item.LifeCycleStart??DateTime.MinValue; start_cal = new DateTime( start_cal.Year, start_cal.Month, @@ -236,8 +236,6 @@ namespace DOAN.Service.MES.dev ); //循环周期 int cycle_period = (int)item.DayNum; - - DateTime date = start_cal; do { @@ -252,7 +250,6 @@ namespace DOAN.Service.MES.dev } } #endregion - #region 1.2 每周类型处理 @@ -299,7 +296,6 @@ namespace DOAN.Service.MES.dev } } #endregion - #region 1.3 每月类型处理 List DeviceRouteInspectionPlan_month_list = InitDataList @@ -333,8 +329,6 @@ namespace DOAN.Service.MES.dev } #endregion - - // 插入数据库 List executes = new List(); if (deviceRouteInspectionPlan_execute_List.Count > 0) @@ -357,7 +351,6 @@ namespace DOAN.Service.MES.dev result = Context.Insertable(executes).ExecuteCommand(); } } - return result; } diff --git a/DOAN.Service/MES/SmartScreen/Product/ProductSmartScreenService.cs b/DOAN.Service/MES/SmartScreen/Product/ProductSmartScreenService.cs index dd736d0..6d66392 100644 --- a/DOAN.Service/MES/SmartScreen/Product/ProductSmartScreenService.cs +++ b/DOAN.Service/MES/SmartScreen/Product/ProductSmartScreenService.cs @@ -21,7 +21,6 @@ namespace DOAN.Service.MES.SmartScreen.Product /// 数字翻牌器 /// /// - public DigitalTurntableModel DigitalTurntable() { DigitalTurntableModel digital=new DigitalTurntableModel(); diff --git a/DOAN.Service/Mobile/IService/IReportFlowService.cs b/DOAN.Service/Mobile/IService/IReportFlowService.cs index 19f3c3a..7c6a279 100644 --- a/DOAN.Service/Mobile/IService/IReportFlowService.cs +++ b/DOAN.Service/Mobile/IService/IReportFlowService.cs @@ -1,3 +1,5 @@ +using DOAN.Model.MES.base_; +using DOAN.Model.MES.base_.Dto; using DOAN.Model.MES.product; using DOAN.Model.Mobile.ReportFlow.Dto; @@ -6,6 +8,8 @@ namespace DOAN.Service.Mobile.IService; public interface IReportFlowService: IBaseService { + List GetWorkOrdersByDate(DateTime startDate, DateTime endDate); + ProWorkorder GetWorkOrderDetail(string workorder); ProReportwork01 GetProcessReportWorkDetail(string workorder, int process); @@ -17,4 +21,9 @@ public interface IReportFlowService: IBaseService bool ShipmentProcessReportwork(string workorder, int processId, int finish_num, int bad_num, string customer_order, string Worker); List GetWorkOrderReportWorkList(string workorder); + List GetReportInfoByName(string Name); + + List GetProcessByRoute(int route_id); + List GetReportByProcessId(int processId); + } \ No newline at end of file diff --git a/DOAN.Service/Mobile/ReportFlowService.cs b/DOAN.Service/Mobile/ReportFlowService.cs index ace5c56..57f8a9d 100644 --- a/DOAN.Service/Mobile/ReportFlowService.cs +++ b/DOAN.Service/Mobile/ReportFlowService.cs @@ -1,4 +1,5 @@ using DOAN.Model.MES.base_; +using DOAN.Model.MES.base_.Dto; using DOAN.Model.MES.product; using DOAN.Model.Mobile.ReportFlow.Dto; using DOAN.Model.Public; @@ -6,6 +7,7 @@ using DOAN.Model.System; using DOAN.Service.Mobile.IService; using DOAN.Service.Public.IPublicService; using Infrastructure.Attribute; +using Mapster; using Microsoft.AspNetCore.Mvc; using SqlSugar.DistributedSystem.Snowflake; using System.Diagnostics; @@ -22,6 +24,11 @@ public class ReportFlowService : BaseService, IReportFlowServic { return Context.Queryable().Where(x => x.Workorder == workorder).First(); } + public List GetWorkOrdersByDate(DateTime startDate, DateTime endDate) + { + return Context.Queryable() + .Where(it => it.WorkorderDate >= startDate && it.WorkorderDate <= endDate).ToList(); + } public ProReportwork01 GetProcessReportWorkDetail(string workorder, int process) { @@ -43,7 +50,7 @@ public class ReportFlowService : BaseService, IReportFlowServic int result = 0; bool Exist = Context.Queryable().Where(it => it.Workorder == workorder && it.ProcessId == processId).Any(); - string NickName= Context.Queryable().Where(it=>it.UserName==Worker).Select(it=>it.NickName).First(); + string NickName = Context.Queryable().Where(it => it.UserName == Worker).Select(it => it.NickName).First(); Worker = string.IsNullOrEmpty(NickName) ? Worker + "|异常人员|" : NickName; if (Exist) { @@ -132,13 +139,13 @@ public class ReportFlowService : BaseService, IReportFlowServic int result = 0; bool Exist = Context.Queryable().Where(it => it.Workorder == workorder && it.ProcessId == processId).Any(); string NickName = Context.Queryable().Where(it => it.UserName == Worker).Select(it => it.NickName).First(); - Worker = string.IsNullOrEmpty(NickName) ? Worker+"|异常人员|" : NickName; + Worker = string.IsNullOrEmpty(NickName) ? Worker + "|异常人员|" : NickName; if (Exist) { result = Context.Updateable() .Where(it => it.Workorder == workorder && it.ProcessId == processId) .SetColumns(it => it.FinishNum == finish_num) - .SetColumns(it=>it.BadNum == bad_num) + .SetColumns(it => it.BadNum == bad_num) .SetColumns(it => it.Worker == Worker) .SetColumns(it => it.JobDate == DateTime.Now) .SetColumns(it => it.UpdatedBy == Worker) @@ -181,10 +188,49 @@ public class ReportFlowService : BaseService, IReportFlowServic ProcessName = wp.Name, }, true) .ToList(); + } + public List GetReportInfoByName(string Name) + { + string NickName = Context.Queryable().Where(it => it.UserName == Name).Select(it => it.NickName).First(); + Name = string.IsNullOrEmpty(NickName) ? Name + "|异常人员|" : NickName; + return Context.Queryable() + .LeftJoin((rw, wp) => rw.ProcessId == wp.Id) + .Where((rw, wp) => rw.Worker == Name && rw.JobDate >= DateTime.Today && rw.JobDate < DateTime.Today.AddDays(1)) + .OrderBy(rw => rw.ProcessId) + .Select((rw, wp) => new ProReportWorkDetialDto() + { + ProcessName = wp.Name, + }, true) + .ToList(); } + + public List GetProcessByRoute(int route_id) + { + + return Context.Queryable() + .LeftJoin((rel, pro) => rel.FkWorkProcesses == pro.Id) + .Where((rel, pro) => rel.FkWorkRoute == route_id) + .Select((rel, pro) => pro) + .ToList() + .Adapt, List>(); + + } + + public List GetReportByProcessId(int processId) + { + return Context.Queryable() + .LeftJoin((rw, wp) => rw.ProcessId == wp.Id) + .Where((rw, wp) => rw.ProcessId == processId && rw.JobDate >= DateTime.Today && rw.JobDate < DateTime.Today.AddDays(1)) + .OrderBy(rw => rw.ProcessId) + .Select((rw, wp) => new ProReportWorkDetialDto() + { + ProcessName = wp.Name, + }, true) + .ToList(); + } } diff --git a/DOAN.Tasks/TaskScheduler/Job_Device_Execute.cs b/DOAN.Tasks/TaskScheduler/Job_Device_Execute.cs index e2b3794..c957d2f 100644 --- a/DOAN.Tasks/TaskScheduler/Job_Device_Execute.cs +++ b/DOAN.Tasks/TaskScheduler/Job_Device_Execute.cs @@ -14,6 +14,7 @@ using DOAN.Model.System; using DOAN.Model.MES.dev; using DOAN.Model.MES.dev.Dto; using DOAN.Service.MES.dev.IService; +using DOAN.Service.MES.dev; namespace DOAN.Tasks.TaskScheduler {