From c93711290e621449294f691e638044bf467a6bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AD=A3=E6=98=93?= Date: Fri, 31 May 2024 13:22:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E6=8E=92=E7=A8=8B=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=89=A9=E6=96=99=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/pro/ProWorkorderV2Controller.cs | 3 +- .../mes/pro/ProWorkplanV2Controller.cs | 22 ++- ZR.Model/MES/pro/DTO/ProWorkOrder.cs | 147 ++++++++++++++++++ ZR.Model/MES/pro/DTO/ProWorklplanDto.cs | 143 +++++++++++++++++ .../pro/IService/IProWorkorderServiceV2.cs | 2 +- .../mes/pro/IService/IProWorkplanServiceV2.cs | 8 +- ZR.Service/mes/pro/ProWorkorderServiceV2.cs | 92 ++++++++++- ZR.Service/mes/pro/ProWorkplanServiceV2.cs | 74 ++++++++- 8 files changed, 480 insertions(+), 11 deletions(-) create mode 100644 ZR.Model/MES/pro/DTO/ProWorkOrder.cs create mode 100644 ZR.Model/MES/pro/DTO/ProWorklplanDto.cs diff --git a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs index c65e1a17..bafa4189 100644 --- a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs +++ b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkorderV2Controller.cs @@ -12,6 +12,7 @@ using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; using ZR.Model.MES.pro; +using ZR.Model.MES.pro.DTO; using ZR.Service.mes.pro; using ZR.Service.mes.pro.IService; using static System.Runtime.InteropServices.JavaScript.JSType; @@ -38,7 +39,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro [HttpGet("getWorkoderList")] public IActionResult GetWorkorderList(int pageNum, int pageSize, int year = -1, int week = -1, int date = -1) { - (List, int) data = proWorkorderService.GetWorkorderList(pageNum, pageSize, year, week, date, 0); + (List, int) data = proWorkorderService.GetWorkorderList(pageNum, pageSize, year, week, date, 0); return ToResponse(new ApiResult(200, "success", data)); } diff --git a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs index 4bd07683..627ee1aa 100644 --- a/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs +++ b/ZR.Admin.WebApi/Controllers/mes/pro/ProWorkplanV2Controller.cs @@ -44,8 +44,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro [HttpGet("list")] public IActionResult List(int pageNum, int pageSize, int year = -1, int week = -1, string partNumber = "", string color = "") { - (List, int) data = proWorkplanService.GetAllData(pageNum, pageSize, year, week, partNumber, color); - + (List, int) data = proWorkplanService.GetAllData(pageNum, pageSize, year, week, partNumber, color); return ToResponse(new ApiResult(200, "success", data)); } @@ -240,7 +239,26 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro return ExportExcel(result.Item2, result.Item1); } + /// + /// 生产计划检查 + /// + /// 生产计划对象 + /// + [HttpPost("checkWorkPlan")] + public IActionResult CheckWorkPlan([FromBody] ProWorklplan_v2 proWorkplan) + { + try + { + int result = proWorkplanService.CheckWorkPlan(proWorkplan); + return ToResponse(new ApiResult(200, "success", result)); + } + catch (Exception ex) + { + return ToResponse(new ApiResult(500, ex.Message, 0)); + } + + } } } diff --git a/ZR.Model/MES/pro/DTO/ProWorkOrder.cs b/ZR.Model/MES/pro/DTO/ProWorkOrder.cs new file mode 100644 index 00000000..d08a33e7 --- /dev/null +++ b/ZR.Model/MES/pro/DTO/ProWorkOrder.cs @@ -0,0 +1,147 @@ +using MiniExcelLibs.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZR.Model.MES.pro.DTO +{ + public class ProWorkOrder + { + /// + /// 工单号WO20240301001 + /// + public string Id { get; set; } + + /// + /// 毛坯号 + /// + public string BlankNumber { get; set; } + + /// + /// 成品零件号 + /// + public string FinishedPartNumber { get; set; } + + /// + /// 产品描述 + /// + public string ProductDescription { get; set; } + + /// + /// 颜色 + /// + public string Colour { get; set; } + + /// + /// 规格 + /// + public string Specifications { get; set; } + + /// + /// 编码号 + /// + public int CodeNumber { get; set; } + + /// + /// 车数 + /// + public int VehicleNumber { get; set; } + + /// + /// 挂具摆放 + /// + public int hangNumber { get; set; } + + /// + /// 上件数 + /// + public int PreviousNumber { get; set; } + + /// + /// 双组号缸号 + /// + public string CylinderNumber { get; set; } + + /// + /// 备注1 + /// + public string Remark1 { get; set; } + + /// + /// 备注2 + /// + public string Remark2 { get; set; } + + + /// + /// 备注3,识别是否需要工单 + /// + public string Remark3 { get; set; } + + /// + /// 备注4 :来源 + /// + public string Remark4 { get; set; } + + /// + /// 序号 + /// + public int Sort { get; set; } + + /// + /// 客户工单号 + /// + public string ClientWorkorder { get; set; } + + + + /// + /// 状态:0初态 1上线 + /// + public int Status { get; set; } + + /// + /// 年 + /// + public int Year { get; set; } + + /// + /// 周 + /// + public int Week { get; set; } + + /// + /// 日 + /// + public int Date { get; set; } + + /// + /// 创建人 + /// + public string CreatedBy { get; set; } + + /// + /// 创建时间 + /// + public DateTime CreatedTime { get; set; } + + /// + /// 更新人 + /// + public string UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + public DateTime UpdatedTime { get; set; } + + + /// + /// 计划状态 0-正常 1-物料号不存在 2-规格颜色异常 + /// + /// + public int State { get; set; } + } +} diff --git a/ZR.Model/MES/pro/DTO/ProWorklplanDto.cs b/ZR.Model/MES/pro/DTO/ProWorklplanDto.cs new file mode 100644 index 00000000..72b74a0c --- /dev/null +++ b/ZR.Model/MES/pro/DTO/ProWorklplanDto.cs @@ -0,0 +1,143 @@ +using MiniExcelLibs.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZR.Model.MES.pro.DTO +{ + public class ProWorklplanDto + { + /// + /// WP2024030001 主键 + /// + public string Id { get; set; } + + /// + /// 零件号 + /// + public string Partnumber { get; set; } + + /// + /// 产品描述 + /// + public string ProductName { get; set; } + + + /// + /// 规格 + /// + public string Specification { get; set; } + /// + /// 颜色代码 + /// + public string ColorCode { get; set; } + + /// + /// 本周要货数量 + /// + public int RequireNum { get; set; } + + /// + /// 产品合格率 + /// + public double QualificationRate { get; set; } + + /// + /// 每挂数量 + /// + public float EveryHangerNum { get; set; } + + /// + /// 生产节拍(分钟) + /// + public decimal ProductionBeat { get; set; } + + /// + /// 总挂具数 + /// + public float AllHangerNum { get; set; } + + /// + /// 订单需生产挂具数量 + /// + /// + public float RequireHanger { get; set; } + + /// + /// 圈数 + /// + /// + public float TurnNumber { get; set; } + + /// + /// 订单生产时间(分钟) + /// + public float ProductTime { get; set; } + + + /// + /// 未排程数 + /// + public int NoSchedule { get; set; } + + /// + /// 毛坯号 + /// + public string BlankNum { get; set; } + + /// + /// 来源:手动插入,excel导入 + /// + public string Remark { get; set; } + + + + + + /// + /// 年 + /// + /// + public int Year { get; set; } + + /// + /// 周 + /// + /// + public int Week { get; set; } + + + /// + /// 创建人 + /// + /// + public string CreatedBy { get; set; } + + /// + /// 创建时间 + /// + /// + public DateTime CreatedTime { get; set; } + + /// + /// 更新人 + /// + /// + public string UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + /// + public DateTime UpdatedTime { get; set; } + + + /// + /// 计划状态 0-正常 1-物料号不存在 2-规格颜色异常 + /// + /// + public int State { get; set; } + } +} diff --git a/ZR.Service/mes/pro/IService/IProWorkorderServiceV2.cs b/ZR.Service/mes/pro/IService/IProWorkorderServiceV2.cs index 8aaf7a89..ebe07319 100644 --- a/ZR.Service/mes/pro/IService/IProWorkorderServiceV2.cs +++ b/ZR.Service/mes/pro/IService/IProWorkorderServiceV2.cs @@ -19,7 +19,7 @@ namespace ZR.Service.mes.pro.IService { - public (List, int) GetWorkorderList(int pageNum, int pageSize, int year, int week, int date, int isSchedule); + public (List, int) GetWorkorderList(int pageNum, int pageSize, int year, int week, int date, int isSchedule); public (List, int) GetWorkorderList_Piliang(int pageNum, int pageSize, int year, int week, int date, int isSchedule); diff --git a/ZR.Service/mes/pro/IService/IProWorkplanServiceV2.cs b/ZR.Service/mes/pro/IService/IProWorkplanServiceV2.cs index 97cfa4fa..0ff4cdc2 100644 --- a/ZR.Service/mes/pro/IService/IProWorkplanServiceV2.cs +++ b/ZR.Service/mes/pro/IService/IProWorkplanServiceV2.cs @@ -16,7 +16,7 @@ namespace ZR.Service.mes.pro.IService public interface IProWorkplanServiceV2 { - public (List, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color); + public (List, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color); /// /// 根据计划ID,获取对象 @@ -36,6 +36,12 @@ namespace ZR.Service.mes.pro.IService public (string,string) ExportExceldata(int year, int week); + /// + /// 生产计划字段数据检查 + /// + /// 计划字段 + /// 0-正常 1-物料号不存在 2-物料号与描述不匹配 + public int CheckWorkPlan(ProWorklplan_v2 proWorkplan); public WorkplanSummaryDto GetWeekSummary(int year ,int week); diff --git a/ZR.Service/mes/pro/ProWorkorderServiceV2.cs b/ZR.Service/mes/pro/ProWorkorderServiceV2.cs index 591805d8..fae8337a 100644 --- a/ZR.Service/mes/pro/ProWorkorderServiceV2.cs +++ b/ZR.Service/mes/pro/ProWorkorderServiceV2.cs @@ -26,6 +26,7 @@ using System.IO; using SqlSugar.Extensions; using ZR.Model.mes.pro; using SqlSugar; +using ZR.Model.MES.wms; namespace ZR.Service.mes.pro { @@ -33,7 +34,7 @@ namespace ZR.Service.mes.pro public class ProWorkorderServiceV2 : BaseService, IProWorkorderServiceV2 { - public (List, int) GetWorkorderList(int pageNum, int pageSize, int year, int week, int date, int isSchedule) + public (List, int) GetWorkorderList(int pageNum, int pageSize, int year, int week, int date, int isSchedule) { var predicate = Expressionable.Create() @@ -44,8 +45,42 @@ namespace ZR.Service.mes.pro int totalCount = 0; List proWorkorderList = Context.Queryable().Where(predicate).OrderBy(it => it.Sort).ToPageList(pageNum, pageSize, ref totalCount); + List orders = new(); + foreach (ProWorkorder_v2 item in proWorkorderList) + { + ProWorkOrder proWorkOrder = new() + { + Id = item.Id, + Week = item.Week, + Year = item.Year, + Date = item.Date, + BlankNumber = item.BlankNumber, + ClientWorkorder = item.ClientWorkorder, + FinishedPartNumber = item.FinishedPartNumber, + ProductDescription = item.ProductDescription, + Specifications = item.Specifications, + Colour = item.Colour, + CodeNumber = item.CodeNumber, + CylinderNumber = item.CylinderNumber, + hangNumber = item.hangNumber, + PreviousNumber = item.PreviousNumber, + VehicleNumber = item.VehicleNumber, + CreatedBy = item.CreatedBy, + CreatedTime = item.CreatedTime, + UpdatedBy = item.UpdatedBy, + UpdatedTime = item.UpdatedTime, + Sort = item.Sort, + Status = item.Status, + Remark1 = item.Remark1, + Remark2 = item.Remark2, + Remark3 = item.Remark3, + Remark4 = item.Remark4, + }; + proWorkOrder.State = CheckWorkOrder(item); + orders.Add(proWorkOrder); + } - return (proWorkorderList, totalCount); + return (orders, totalCount); } public (List, int) GetWorkorderList_Piliang(int pageNum, int pageSize, int year, int week, int date, int isSchedule) @@ -410,5 +445,58 @@ namespace ZR.Service.mes.pro } return finalreuslt; } + + /// + /// 判断 + /// + /// + /// + /// + public int CheckWorkOrder(ProWorkorder_v2 proWorkorder) + { + try + { + if (string.IsNullOrEmpty(proWorkorder.FinishedPartNumber)) + { + return 0; + } + WmMaterial material = Context.Queryable() + .Where(it => it.Partnumber == proWorkorder.FinishedPartNumber) + // .Where(it => it.Status == 1) + .First(); + // 物料号不存在 + if (material == null) + { + return 1; + } + // 毛坯号异常 + if (!string.IsNullOrEmpty(material.BlankNum) && material.BlankNum != proWorkorder.BlankNumber) + { + return 2; + } + // 颜色异常 + if (!string.IsNullOrEmpty(material.Color) && !material.Color.Contains(proWorkorder.Colour)) + { + return 3; + } + // 规格异常 + if (!string.IsNullOrEmpty(material.Specification) && !material.Specification.Contains(proWorkorder.Specifications)) + { + return 4; + } + // 描述异常不包含 + if (!string.IsNullOrEmpty(material.Description) && !material.Description.Contains(proWorkorder.ProductDescription)) + { + return 5; + } + // 全部正常 + return 0; + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + + } } } diff --git a/ZR.Service/mes/pro/ProWorkplanServiceV2.cs b/ZR.Service/mes/pro/ProWorkplanServiceV2.cs index 79bcda9d..be8e0175 100644 --- a/ZR.Service/mes/pro/ProWorkplanServiceV2.cs +++ b/ZR.Service/mes/pro/ProWorkplanServiceV2.cs @@ -16,6 +16,7 @@ using System.Text; using System.Threading.Tasks; using ZR.Model.mes.pro; using ZR.Model.MES.pro.DTO; +using ZR.Model.MES.wms; using ZR.Service.mes.pro.IService; using ZR.Service.MES.md.IService; @@ -26,7 +27,7 @@ namespace ZR.Service.mes.pro public class ProWorkplanServiceV2 : BaseService, IProWorkplanServiceV2 { - public (List, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color) + public (List, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color) { var predicate = Expressionable.Create() .AndIF(year > 0, it => it.Year == year) @@ -35,8 +36,44 @@ namespace ZR.Service.mes.pro .AndIF(!string.IsNullOrEmpty(color), it => it.ColorCode.Contains(color)) .ToExpression(); int totalCount = 0; - List proWorkplanList = Context.Queryable().Where(predicate).OrderBy(it => it.Id).ToPageList(pageNum, pageSize, ref totalCount); - return (proWorkplanList, totalCount); + List proWorkplanList = Context.Queryable() + .Where(predicate) + .OrderBy(it => it.Id) + .ToPageList(pageNum, pageSize, ref totalCount); + // 计划正确性检查 + List proWorkplanDtoList = new List(); + foreach (ProWorklplan_v2 item in proWorkplanList) + { + ProWorklplanDto plan = new() + { + Id = item.Id, + Week = item.Week, + Year = item.Year, + BlankNum = item.BlankNum, + Partnumber = item.Partnumber, + ProductName = item.ProductName, + Specification = item.Specification, + ColorCode = item.ColorCode, + ProductionBeat = item.ProductionBeat, + ProductTime = item.ProductTime, + NoSchedule = item.NoSchedule, + QualificationRate = item.QualificationRate, + RequireHanger = item.RequireHanger, + AllHangerNum = item.AllHangerNum, + EveryHangerNum = item.EveryHangerNum, + RequireNum = item.RequireNum, + TurnNumber = item.TurnNumber, + Remark = item.Remark, + CreatedBy = item.CreatedBy, + CreatedTime = item.CreatedTime, + UpdatedBy = item.UpdatedBy, + UpdatedTime = item.UpdatedTime, + }; + plan.State = CheckWorkPlan(item); + proWorkplanDtoList.Add(plan); + } + + return (proWorkplanDtoList, totalCount); } @@ -244,6 +281,35 @@ namespace ZR.Service.mes.pro return Context.Deleteable().Where(it => it.Year == year && it.Week == week).ExecuteCommand(); } - + public int CheckWorkPlan(ProWorklplan_v2 proWorkplan) + { + try + { + if (string.IsNullOrEmpty(proWorkplan.Partnumber)) + { + return 0; + } + WmMaterial material = Context.Queryable() + .Where(it => it.Partnumber == proWorkplan.Partnumber) + .Where(it => it.Status == 1) + .First(); + // 物料号不存在 + if(material == null) + { + return 1; + } + // 规格与颜色异常 + if(material.Specification != proWorkplan.Specification || material.Color != proWorkplan.ColorCode) + { + return 2; + } + + return 0; + }catch (Exception ex) + { + throw new Exception(ex.Message); + } + + } } }