From 263f30822ee7748e58f87469e9ed27a6cfe58645 Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Thu, 25 Apr 2024 08:47:25 +0800 Subject: [PATCH] 122 --- .../mes/mm/MaterialInputController.cs | 62 ++++++++++++ ZR.Model/MES/mm/AgvLocation.cs | 69 ++++++++++++++ ZR.Model/MES/mm/Dto/WorkorderqueryDto.cs | 13 +++ .../mes/mm/IService/IMaterialInputService.cs | 18 ++++ ZR.Service/mes/mm/MaterialInputService.cs | 94 +++++++++++++++++++ 5 files changed, 256 insertions(+) create mode 100644 ZR.Admin.WebApi/Controllers/mes/mm/MaterialInputController.cs create mode 100644 ZR.Model/MES/mm/AgvLocation.cs create mode 100644 ZR.Model/MES/mm/Dto/WorkorderqueryDto.cs create mode 100644 ZR.Service/mes/mm/IService/IMaterialInputService.cs create mode 100644 ZR.Service/mes/mm/MaterialInputService.cs diff --git a/ZR.Admin.WebApi/Controllers/mes/mm/MaterialInputController.cs b/ZR.Admin.WebApi/Controllers/mes/mm/MaterialInputController.cs new file mode 100644 index 00000000..6176426c --- /dev/null +++ b/ZR.Admin.WebApi/Controllers/mes/mm/MaterialInputController.cs @@ -0,0 +1,62 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using ZR.Model.MES.mm.Dto; +using ZR.Service.mes.mm; +using ZR.Service.mes.mm.IService; + +namespace ZR.Admin.WebApi.Controllers.mes.mm +{ + /// + /// 生产投料 + /// + [Route("mes/mm/materialinput")] + + public class MaterialInputController : BaseController + { + + IMaterialInputService materialInputService; + + public MaterialInputController(IMaterialInputService materialInputService) + { + this.materialInputService = materialInputService; + + } + /// + /// 获取AGV 上料 开始起点 + /// + /// + [HttpGet("getstartpoints")] + public IActionResult Getstart_AGV_points() + { + var response = materialInputService.Getstart_AGV_points(); + return SUCCESS(response); + + } + + /// + /// 获取AGV 上料 终点 + /// + /// + [HttpGet("getendpoints")] + public IActionResult Getend_AGV_points() + { + var response = materialInputService.Getend_AGV_points(); + return SUCCESS(response); + + } + /// + /// 获取工单list + /// + /// + [HttpPost("getworkorderlist")] + public IActionResult Getworkorderlist([FromBody] WorkorderqueryDto query) + { + if(query == null|| query.datetimespan==null) + { + SUCCESS(null); + } + var response = materialInputService.Getworkorderlist(query.datetimespan); + return SUCCESS(response); + } + } +} \ No newline at end of file diff --git a/ZR.Model/MES/mm/AgvLocation.cs b/ZR.Model/MES/mm/AgvLocation.cs new file mode 100644 index 00000000..91d60bf7 --- /dev/null +++ b/ZR.Model/MES/mm/AgvLocation.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using SqlSugar; + +namespace ZR.Model.MES.mm +{ + /// + /// agv位置表 + /// + [SugarTable("agv_location")] + public class AgvLocation + { + /// + /// Id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + + /// + /// 区域 + /// + [SugarColumn(ColumnName = "area_code")] + public int? AreaCode { get; set; } + + + + /// + /// 区域 + /// + public string Area { get; set; } + + /// + /// 类型(0: 起点,1:终点) + /// + public int? Type { get; set; } + + /// + /// 坐标 + /// + public string Coordinate { get; set; } + + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "cREATED_BY")] + public string CreatedBy { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "cREATED_TIME")] + public DateTime? CreatedTime { get; set; } + + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "uPDATED_BY")] + public string UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "uPDATED_TIME")] + public DateTime? UpdatedTime { get; set; } + + } +} \ No newline at end of file diff --git a/ZR.Model/MES/mm/Dto/WorkorderqueryDto.cs b/ZR.Model/MES/mm/Dto/WorkorderqueryDto.cs new file mode 100644 index 00000000..f486aee9 --- /dev/null +++ b/ZR.Model/MES/mm/Dto/WorkorderqueryDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZR.Model.MES.mm.Dto +{ + public class WorkorderqueryDto + { + public DateTime datetimespan { set; get; } + } +} diff --git a/ZR.Service/mes/mm/IService/IMaterialInputService.cs b/ZR.Service/mes/mm/IService/IMaterialInputService.cs new file mode 100644 index 00000000..456503ea --- /dev/null +++ b/ZR.Service/mes/mm/IService/IMaterialInputService.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZR.Model.MES.pro; + +namespace ZR.Service.mes.mm.IService +{ + public interface IMaterialInputService + { + string[] Getstart_AGV_points(); + string[] Getend_AGV_points(); + + List Getworkorderlist(DateTime datetimespan); + + } +} diff --git a/ZR.Service/mes/mm/MaterialInputService.cs b/ZR.Service/mes/mm/MaterialInputService.cs new file mode 100644 index 00000000..23ddda4e --- /dev/null +++ b/ZR.Service/mes/mm/MaterialInputService.cs @@ -0,0 +1,94 @@ +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, IMaterialInputService + { + /// + /// 获取AGV上料起点 + /// + /// + public string[] Getstart_AGV_points() + { + List positions = Context.Queryable() + .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; + } + + + /// + /// 获取AGV上料终点 + /// + /// + public string[] Getend_AGV_points() + { + List positions = Context.Queryable() + .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; + } + + + /// + /// 获取工单列表 + /// + /// + /// + public List 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 WorkorderList = Context.Queryable() + .Where(it => it.Year == year) + .Where(it => it.Week == week) + .Where(it => it.Date == dayOfWeekNumber) + .Where(it=>it.Remark3=="是") + .ToList(); + + + return WorkorderList; + } + + } +} +