工单排程添加物料检测

This commit is contained in:
2024-05-31 13:22:07 +08:00
parent 6677691305
commit c93711290e
8 changed files with 480 additions and 11 deletions

View File

@@ -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);
}
}
}
}