shgx_tz_mom/ZR.Service/mes/mm/MaterialInputService.cs
2024-04-26 15:35:03 +08:00

95 lines
3.1 KiB
C#

using Infrastructure.Attribute;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.MES.op.ZR.Model.mes.md;
using ZR.Service.MES.op.IService;
using ZR.Service;
using ZR.Service.mes.mm.IService;
using ZR.Model.MES.mm;
using ZR.Model.MES.pro;
using System.Globalization;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace ZR.Service.mes.mm
{
[AppService(ServiceType = typeof(IMaterialInputService), ServiceLifetime = LifeTime.Transient)]
public class MaterialInputService : BaseService<MmAgvLocation>, IMaterialInputService
{
/// <summary>
/// 获取AGV上料起点
/// </summary>
/// <returns></returns>
public string[] Getstart_AGV_points()
{
List<MmAgvLocation> positions = Context.Queryable<MmAgvLocation>()
.Where(it => it.AreaCode == 2)
.Where(it => it.Type == 0)
.ToList();
string[] cors = new string[positions.Count];
for (int i = 0; i < positions.Count; i++) cors[i] = positions[i].Coordinate.ToString();
return cors;
}
/// <summary>
/// 获取AGV上料终点
/// </summary>
/// <returns></returns>
public string[] Getend_AGV_points()
{
List<MmAgvLocation> positions = Context.Queryable<MmAgvLocation>()
.Where(it => it.AreaCode == 2)
.Where(it => it.Type == 1)
.ToList();
string[] cors = new string[positions.Count];
for (int i = 0; i < positions.Count; i++) cors[i] = positions[i].Coordinate.ToString();
return cors;
}
/// <summary>
/// 获取工单列表
/// </summary>
/// <param name="datetimespan"></param>
/// <returns></returns>
public List<ProWorkorder_v2> Getworkorderlist(DateTime datetimespan)
{
// 获取年份和周数
Calendar calendar = new GregorianCalendar();
int year = calendar.GetYear(datetimespan);
int week = calendar.GetWeekOfYear(datetimespan, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday);
// 获取这一周中的第几天
DayOfWeek dayOfWeek = datetimespan.DayOfWeek;
int dayOfWeekNumber = (int)dayOfWeek + 1; // 将 DayOfWeek 枚举转换为从 1 开始的数字
Console.WriteLine($"日期:{datetimespan}");
Console.WriteLine($"年份:{year}");
Console.WriteLine($"周数:{week}");
Console.WriteLine($"这一周中的第几天:{dayOfWeekNumber}");
List<ProWorkorder_v2> WorkorderList = Context.Queryable<ProWorkorder_v2>()
.Where(it => it.Year == year)
.Where(it => it.Week == week)
.Where(it => it.Date == dayOfWeekNumber)
.Where(it=>it.Remark3=="是")
.ToList();
return WorkorderList;
}
}
}