91 lines
3.3 KiB
C#
91 lines
3.3 KiB
C#
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();
|
||
}
|
||
|
||
|
||
}
|
||
}
|