From 5e5fdb99bc5c9116a7a306f1235d1e3efb23d158 Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Tue, 10 Jun 2025 10:41:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E8=BF=9B=E5=BA=A6=E7=9C=8B?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Infrastructure/ERP/Util/MD5Encryption.cs | 3 +- .../BI/ProductionDashboardController.cs | 64 +++++++++++++ .../IService/IProductionDashboardService.cs | 32 +++++++ ZR.Service/BI/ProductionDashboardService.cs | 90 +++++++++++++++++++ ZRAdmin.sln | 6 -- 5 files changed, 188 insertions(+), 7 deletions(-) create mode 100644 ZR.Admin.WebApi/Controllers/BI/ProductionDashboardController.cs create mode 100644 ZR.Service/BI/IService/IProductionDashboardService.cs create mode 100644 ZR.Service/BI/ProductionDashboardService.cs diff --git a/Infrastructure/ERP/Util/MD5Encryption.cs b/Infrastructure/ERP/Util/MD5Encryption.cs index 3237061b..0ab1ea7e 100644 --- a/Infrastructure/ERP/Util/MD5Encryption.cs +++ b/Infrastructure/ERP/Util/MD5Encryption.cs @@ -1,4 +1,5 @@ -using System.Security.Cryptography; +using System; +using System.Security.Cryptography; using System.Text; namespace U8Server.Util diff --git a/ZR.Admin.WebApi/Controllers/BI/ProductionDashboardController.cs b/ZR.Admin.WebApi/Controllers/BI/ProductionDashboardController.cs new file mode 100644 index 00000000..406a8781 --- /dev/null +++ b/ZR.Admin.WebApi/Controllers/BI/ProductionDashboardController.cs @@ -0,0 +1,64 @@ +using Microsoft.AspNetCore.Mvc; +using ZR.Admin.WebApi.Extensions; +using ZR.Admin.WebApi.Filters; +using ZR.Admin.WebApi.Filters; +using ZR.Service.BI.IService; +using ZR.Service.mes.mm; + +namespace ZR.Admin.WebApi.Controllers.BI +{ + /// + /// 生产看板BI + /// + + [Route("BI/productionDashboard")] + public class ProductionDashboardController : BaseController + { + + IProductionDashboardService productionDashboard; + public ProductionDashboardController(IProductionDashboardService productionDashboard) + { + + this.productionDashboard = productionDashboard; + } + + /// + /// 查询今日未开始的生产工单 + /// + /// + [HttpGet("todayNoStartProWorkorder")] + public IActionResult TodayNoStartProWorkorder() + { + var response = productionDashboard.TodayNoStartProWorkorder(); + return SUCCESS(response); + + } + + /// + /// 查询今日正在生产的工单 + /// + /// + [HttpGet("todayProductiongProWorkorder")] + public IActionResult TodayProductiongProWorkorder() + { + var response = productionDashboard.TodayProductiongProWorkorder(); + return SUCCESS(response); + + } + + + /// + /// 查询今日已完成的生产工单 + /// + /// + [HttpGet("todayFinishProductionProWorkorder")] + public IActionResult TodayFinishProductionProWorkorder() + { + var response = productionDashboard.TodayFinishProductionProWorkorder(); + return SUCCESS(response); + + } + + + } +} diff --git a/ZR.Service/BI/IService/IProductionDashboardService.cs b/ZR.Service/BI/IService/IProductionDashboardService.cs new file mode 100644 index 00000000..2a5d02be --- /dev/null +++ b/ZR.Service/BI/IService/IProductionDashboardService.cs @@ -0,0 +1,32 @@ +using Model.DBModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZR.Model.MES.pro; +using ZR.Model.MES.pro.DTO; + +namespace ZR.Service.BI.IService +{ + public interface IProductionDashboardService + { + /// + /// 查询今日未开始的生产工单 + /// + /// + List TodayNoStartProWorkorder(); + /// + /// 查询今日正在生产的工单 + /// + /// + List TodayProductiongProWorkorder(); + /// + /// 查询今日已完成的生产工单 + /// + /// + List TodayFinishProductionProWorkorder(); + + + } +} diff --git a/ZR.Service/BI/ProductionDashboardService.cs b/ZR.Service/BI/ProductionDashboardService.cs new file mode 100644 index 00000000..2755d7d4 --- /dev/null +++ b/ZR.Service/BI/ProductionDashboardService.cs @@ -0,0 +1,90 @@ +using Infrastructure.Attribute; +using Model.DBModel; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZR.Model.MES.pro; +using ZR.Service.BI.IService; +using ZR.Service.mes.mm.IService; + +namespace ZR.Service.BI +{ + [AppService(ServiceType = typeof(IProductionDashboardService), ServiceLifetime = LifeTime.Transient)] + public class ProductionDashboardService : BaseService, IProductionDashboardService + { + /// + /// 获取指定日期的ISO年份、周数和星期几(周一=1) + /// + /// 输入日期时间 + /// 元组(year, week, day) 其中day范围1-7(周一到周日) + public static (int year, int week, int day) GetIsoWeekInfo(DateTime dateTime) + { + // 使用.NET内置的ISOWeek类(需要.NET Core 3.0+/.NET Standard 2.1+) + int year = ISOWeek.GetYear(dateTime); + int week = ISOWeek.GetWeekOfYear(dateTime); + + // 转换星期几(周一=1 到 周日=7) + int day = dateTime.DayOfWeek switch + { + DayOfWeek.Monday => 1, + DayOfWeek.Tuesday => 2, + DayOfWeek.Wednesday => 3, + DayOfWeek.Thursday => 4, + DayOfWeek.Friday => 5, + DayOfWeek.Saturday => 6, + DayOfWeek.Sunday => 7, + _ => throw new ArgumentOutOfRangeException() + }; + + return (year, week, day); + } + /// + /// 查询今日未开始的生产工单 + /// + /// + public List TodayNoStartProWorkorder() + { + (int year, int week, int day) = GetIsoWeekInfo(DateTime.Now); + return Context.Queryable().Where(it => it.Remark2 == "批量") + .Where(it => it.Status == 0) + .Where(it=>it.Year==year) + .Where(it=>it.Week== week) + .Where(it=>it.Date== day) + .ToList(); + + } + /// + /// 查询今日正在生产的工单 + /// + /// + public List TodayProductiongProWorkorder() + { + (int year, int week, int day) = GetIsoWeekInfo(DateTime.Now); + return Context.Queryable().Where(it => it.Remark2 == "批量") + .Where(it => it.Status == 1) + .Where(it => it.Year == year) + .Where(it => it.Week == week) + .Where(it => it.Date == day) + .ToList(); + } + /// + /// 查询今日已完成的生产工单 + /// + /// + public List TodayFinishProductionProWorkorder() + { + (int year, int week, int day) = GetIsoWeekInfo(DateTime.Now); + return Context.Queryable().Where(it => it.Remark2 == "批量") + .Where(it => it.Status == 2) + .Where(it => it.Year == year) + .Where(it => it.Week == week) + .Where(it => it.Date == day) + .ToList(); + } + + + } +} diff --git a/ZRAdmin.sln b/ZRAdmin.sln index 2538cc51..633d2abc 100644 --- a/ZRAdmin.sln +++ b/ZRAdmin.sln @@ -19,8 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZR.Repository", "ZR.Reposit EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZR.CodeGenerator", "ZR.CodeGenerator\ZR.CodeGenerator.csproj", "{B353DE0B-12C6-4C15-909A-DB68F71D5AE9}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "U8Server", "U8Server\U8Server.csproj", "{B1F5C2C3-8E09-4140-A573-C19FD2E33ADE}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -59,10 +57,6 @@ Global {B353DE0B-12C6-4C15-909A-DB68F71D5AE9}.Debug|Any CPU.Build.0 = Debug|Any CPU {B353DE0B-12C6-4C15-909A-DB68F71D5AE9}.Release|Any CPU.ActiveCfg = Release|Any CPU {B353DE0B-12C6-4C15-909A-DB68F71D5AE9}.Release|Any CPU.Build.0 = Release|Any CPU - {B1F5C2C3-8E09-4140-A573-C19FD2E33ADE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B1F5C2C3-8E09-4140-A573-C19FD2E33ADE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B1F5C2C3-8E09-4140-A573-C19FD2E33ADE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B1F5C2C3-8E09-4140-A573-C19FD2E33ADE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE