工单排程添加物料检测
This commit is contained in:
parent
6677691305
commit
c93711290e
@ -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<ProWorkorder_v2>, int) data = proWorkorderService.GetWorkorderList(pageNum, pageSize, year, week, date, 0);
|
||||
(List<ProWorkOrder>, int) data = proWorkorderService.GetWorkorderList(pageNum, pageSize, year, week, date, 0);
|
||||
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
@ -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<ProWorklplan_v2>, int) data = proWorkplanService.GetAllData(pageNum, pageSize, year, week, partNumber, color);
|
||||
|
||||
(List<ProWorklplanDto>, 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产计划检查
|
||||
/// </summary>
|
||||
/// <param name="proWorkplan">生产计划对象</param>
|
||||
/// <returns></returns>
|
||||
[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));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
147
ZR.Model/MES/pro/DTO/ProWorkOrder.cs
Normal file
147
ZR.Model/MES/pro/DTO/ProWorkOrder.cs
Normal file
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 工单号WO20240301001
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 毛坯号
|
||||
/// </summary>
|
||||
public string BlankNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 成品零件号
|
||||
/// </summary>
|
||||
public string FinishedPartNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品描述
|
||||
/// </summary>
|
||||
public string ProductDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 颜色
|
||||
/// </summary>
|
||||
public string Colour { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规格
|
||||
/// </summary>
|
||||
public string Specifications { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码号
|
||||
/// </summary>
|
||||
public int CodeNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车数
|
||||
/// </summary>
|
||||
public int VehicleNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 挂具摆放
|
||||
/// </summary>
|
||||
public int hangNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上件数
|
||||
/// </summary>
|
||||
public int PreviousNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 双组号缸号
|
||||
/// </summary>
|
||||
public string CylinderNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注1
|
||||
/// </summary>
|
||||
public string Remark1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注2
|
||||
/// </summary>
|
||||
public string Remark2 { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 备注3,识别是否需要工单
|
||||
/// </summary>
|
||||
public string Remark3 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注4 :来源
|
||||
/// </summary>
|
||||
public string Remark4 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
public int Sort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户工单号
|
||||
/// </summary>
|
||||
public string ClientWorkorder { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 状态:0初态 1上线
|
||||
/// </summary>
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 年
|
||||
/// </summary>
|
||||
public int Year { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 周
|
||||
/// </summary>
|
||||
public int Week { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日
|
||||
/// </summary>
|
||||
public int Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
public string CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新人
|
||||
/// </summary>
|
||||
public string UpdatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime UpdatedTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 计划状态 0-正常 1-物料号不存在 2-规格颜色异常
|
||||
/// </summary>
|
||||
///
|
||||
public int State { get; set; }
|
||||
}
|
||||
}
|
||||
143
ZR.Model/MES/pro/DTO/ProWorklplanDto.cs
Normal file
143
ZR.Model/MES/pro/DTO/ProWorklplanDto.cs
Normal file
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// WP2024030001 主键
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 零件号
|
||||
/// </summary>
|
||||
public string Partnumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品描述
|
||||
/// </summary>
|
||||
public string ProductName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 规格
|
||||
/// </summary>
|
||||
public string Specification { get; set; }
|
||||
/// <summary>
|
||||
/// 颜色代码
|
||||
/// </summary>
|
||||
public string ColorCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 本周要货数量
|
||||
/// </summary>
|
||||
public int RequireNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品合格率
|
||||
/// </summary>
|
||||
public double QualificationRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 每挂数量
|
||||
/// </summary>
|
||||
public float EveryHangerNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产节拍(分钟)
|
||||
/// </summary>
|
||||
public decimal ProductionBeat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总挂具数
|
||||
/// </summary>
|
||||
public float AllHangerNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单需生产挂具数量
|
||||
/// </summary>
|
||||
///
|
||||
public float RequireHanger { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 圈数
|
||||
/// </summary>
|
||||
///
|
||||
public float TurnNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单生产时间(分钟)
|
||||
/// </summary>
|
||||
public float ProductTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 未排程数
|
||||
/// </summary>
|
||||
public int NoSchedule { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 毛坯号
|
||||
/// </summary>
|
||||
public string BlankNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来源:手动插入,excel导入
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 年
|
||||
/// </summary>
|
||||
///
|
||||
public int Year { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 周
|
||||
/// </summary>
|
||||
///
|
||||
public int Week { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
///
|
||||
public string CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
///
|
||||
public DateTime CreatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新人
|
||||
/// </summary>
|
||||
///
|
||||
public string UpdatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
///
|
||||
public DateTime UpdatedTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 计划状态 0-正常 1-物料号不存在 2-规格颜色异常
|
||||
/// </summary>
|
||||
///
|
||||
public int State { get; set; }
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,7 @@ namespace ZR.Service.mes.pro.IService
|
||||
{
|
||||
|
||||
|
||||
public (List<ProWorkorder_v2>, int) GetWorkorderList(int pageNum, int pageSize, int year, int week, int date, int isSchedule);
|
||||
public (List<ProWorkOrder>, int) GetWorkorderList(int pageNum, int pageSize, int year, int week, int date, int isSchedule);
|
||||
public (List<ProWorkorder_v2>, int) GetWorkorderList_Piliang(int pageNum, int pageSize, int year, int week, int date, int isSchedule);
|
||||
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ namespace ZR.Service.mes.pro.IService
|
||||
public interface IProWorkplanServiceV2
|
||||
{
|
||||
|
||||
public (List<ProWorklplan_v2>, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color);
|
||||
public (List<ProWorklplanDto>, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color);
|
||||
|
||||
/// <summary>
|
||||
/// 根据计划ID,获取对象
|
||||
@ -36,6 +36,12 @@ namespace ZR.Service.mes.pro.IService
|
||||
|
||||
public (string,string) ExportExceldata(int year, int week);
|
||||
|
||||
/// <summary>
|
||||
/// 生产计划字段数据检查
|
||||
/// </summary>
|
||||
/// <param name="proWorkplan">计划字段</param>
|
||||
/// <returns>0-正常 1-物料号不存在 2-物料号与描述不匹配</returns>
|
||||
public int CheckWorkPlan(ProWorklplan_v2 proWorkplan);
|
||||
|
||||
public WorkplanSummaryDto GetWeekSummary(int year ,int week);
|
||||
|
||||
|
||||
@ -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<ProWorkorder_v2>, IProWorkorderServiceV2
|
||||
{
|
||||
|
||||
public (List<ProWorkorder_v2>, int) GetWorkorderList(int pageNum, int pageSize, int year, int week, int date, int isSchedule)
|
||||
public (List<ProWorkOrder>, int) GetWorkorderList(int pageNum, int pageSize, int year, int week, int date, int isSchedule)
|
||||
{
|
||||
|
||||
var predicate = Expressionable.Create<ProWorkorder_v2>()
|
||||
@ -44,8 +45,42 @@ namespace ZR.Service.mes.pro
|
||||
|
||||
int totalCount = 0;
|
||||
List<ProWorkorder_v2> proWorkorderList = Context.Queryable<ProWorkorder_v2>().Where(predicate).OrderBy(it => it.Sort).ToPageList(pageNum, pageSize, ref totalCount);
|
||||
List<ProWorkOrder> 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<ProWorkorder_v2>, 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断
|
||||
/// </summary>
|
||||
/// <param name="proWorkplan"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public int CheckWorkOrder(ProWorkorder_v2 proWorkorder)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(proWorkorder.FinishedPartNumber))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
WmMaterial material = Context.Queryable<WmMaterial>()
|
||||
.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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<ProWorklplan_v2>, IProWorkplanServiceV2
|
||||
{
|
||||
|
||||
public (List<ProWorklplan_v2>, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color)
|
||||
public (List<ProWorklplanDto>, int) GetAllData(int pageNum, int pageSize, int year, int week, string partNumber, string color)
|
||||
{
|
||||
var predicate = Expressionable.Create<ProWorklplan_v2>()
|
||||
.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<ProWorklplan_v2> proWorkplanList = Context.Queryable<ProWorklplan_v2>().Where(predicate).OrderBy(it => it.Id).ToPageList(pageNum, pageSize, ref totalCount);
|
||||
return (proWorkplanList, totalCount);
|
||||
List<ProWorklplan_v2> proWorkplanList = Context.Queryable<ProWorklplan_v2>()
|
||||
.Where(predicate)
|
||||
.OrderBy(it => it.Id)
|
||||
.ToPageList(pageNum, pageSize, ref totalCount);
|
||||
// 计划正确性检查
|
||||
List<ProWorklplanDto> proWorkplanDtoList = new List<ProWorklplanDto>();
|
||||
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<ProWorklplan_v2>().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<WmMaterial>()
|
||||
.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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user