124 lines
4.0 KiB
C#
124 lines
4.0 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;
|
|
using ZR.Model.MES.mm.Dto;
|
|
using SqlSugar;
|
|
|
|
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 开始的数字
|
|
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 生成任务单
|
|
/// </summary>
|
|
/// <param name="task"></param>
|
|
/// <returns></returns>
|
|
public int Generatetask(IngredientTaskDto task,string name)
|
|
{
|
|
List<MmIngredientTask> ingredientTasks=new List<MmIngredientTask> ();
|
|
|
|
foreach(var item in task.workorders)
|
|
{
|
|
MmIngredientTask ingredientTask = new MmIngredientTask();
|
|
ingredientTask.AgvPosition = task.agv_position;
|
|
ingredientTask.TaskId = SnowFlakeSingle.Instance.NextId();
|
|
ingredientTask.Workorder = item.workorder;
|
|
ingredientTask.Partnumber = item.partnumber;
|
|
ingredientTask.PreviousNumber = item.previousNumber;
|
|
ingredientTask.PreviousNumbered=item.previousNumbered;
|
|
ingredientTask.CreatedBy = name;
|
|
|
|
|
|
ingredientTasks.Add(ingredientTask);
|
|
|
|
}
|
|
|
|
return Context.Insertable(ingredientTasks).ExecuteCommand();
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|