生产进度看板

This commit is contained in:
qianhao.xu 2025-06-10 10:41:30 +08:00
parent fcf68711fe
commit 5e5fdb99bc
5 changed files with 188 additions and 7 deletions

View File

@ -1,4 +1,5 @@
using System.Security.Cryptography;
using System;
using System.Security.Cryptography;
using System.Text;
namespace U8Server.Util

View File

@ -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
{
/// <summary>
/// 生产看板BI
/// </summary>
[Route("BI/productionDashboard")]
public class ProductionDashboardController : BaseController
{
IProductionDashboardService productionDashboard;
public ProductionDashboardController(IProductionDashboardService productionDashboard)
{
this.productionDashboard = productionDashboard;
}
/// <summary>
/// 查询今日未开始的生产工单
/// </summary>
/// <returns></returns>
[HttpGet("todayNoStartProWorkorder")]
public IActionResult TodayNoStartProWorkorder()
{
var response = productionDashboard.TodayNoStartProWorkorder();
return SUCCESS(response);
}
/// <summary>
/// 查询今日正在生产的工单
/// </summary>
/// <returns></returns>
[HttpGet("todayProductiongProWorkorder")]
public IActionResult TodayProductiongProWorkorder()
{
var response = productionDashboard.TodayProductiongProWorkorder();
return SUCCESS(response);
}
/// <summary>
/// 查询今日已完成的生产工单
/// </summary>
/// <returns></returns>
[HttpGet("todayFinishProductionProWorkorder")]
public IActionResult TodayFinishProductionProWorkorder()
{
var response = productionDashboard.TodayFinishProductionProWorkorder();
return SUCCESS(response);
}
}
}

View File

@ -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
{
/// <summary>
/// 查询今日未开始的生产工单
/// </summary>
/// <returns></returns>
List<ProWorkorder_v2> TodayNoStartProWorkorder();
/// <summary>
/// 查询今日正在生产的工单
/// </summary>
/// <returns></returns>
List<ProWorkorder_v2> TodayProductiongProWorkorder();
/// <summary>
/// 查询今日已完成的生产工单
/// </summary>
/// <returns></returns>
List<ProWorkorder_v2> TodayFinishProductionProWorkorder();
}
}

View File

@ -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<ProWorklplan_v2>, IProductionDashboardService
{
/// <summary>
/// 获取指定日期的ISO年份、周数和星期几周一=1
/// </summary>
/// <param name="dateTime">输入日期时间</param>
/// <returns>元组(year, week, day) 其中day范围1-7周一到周日</returns>
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);
}
/// <summary>
/// 查询今日未开始的生产工单
/// </summary>
/// <returns></returns>
public List<ProWorkorder_v2> TodayNoStartProWorkorder()
{
(int year, int week, int day) = GetIsoWeekInfo(DateTime.Now);
return Context.Queryable<ProWorkorder_v2>().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();
}
/// <summary>
/// 查询今日正在生产的工单
/// </summary>
/// <returns></returns>
public List<ProWorkorder_v2> TodayProductiongProWorkorder()
{
(int year, int week, int day) = GetIsoWeekInfo(DateTime.Now);
return Context.Queryable<ProWorkorder_v2>().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();
}
/// <summary>
/// 查询今日已完成的生产工单
/// </summary>
/// <returns></returns>
public List<ProWorkorder_v2> TodayFinishProductionProWorkorder()
{
(int year, int week, int day) = GetIsoWeekInfo(DateTime.Now);
return Context.Queryable<ProWorkorder_v2>().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();
}
}
}

View File

@ -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