根据产线和日期查询物料需求计划
This commit is contained in:
parent
0b3c6338d1
commit
3f122ab4ef
@ -146,6 +146,17 @@ namespace DOAN.Admin.WebApi.Controllers
|
||||
|
||||
}
|
||||
|
||||
//TODO 根据产线和日期查询物料需求计划
|
||||
|
||||
[HttpPost("get_material_require_plan_byline")]
|
||||
public IActionResult GetMaterialRequirePlanByline([FromBody] MmRequirePlanQueryDto2 parm)
|
||||
{
|
||||
var response = _MmRequirePlanService.GetMaterialRequirePlanByline(parm);
|
||||
return SUCCESS(response);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
44
DOAN.Model/MES/mm/Dto/MmPreparationTaskLineDto.cs
Normal file
44
DOAN.Model/MES/mm/Dto/MmPreparationTaskLineDto.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
|
||||
namespace DOAN.Model.MES.mm.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 产前备料任务 以线为单位查询对象
|
||||
/// </summary>
|
||||
public class MmPreparationTaskLineQueryDto : PagerInfo
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 产前备料任务 以线为单位输入输出对象
|
||||
/// </summary>
|
||||
public class MmPreparationTaskLineDto
|
||||
{
|
||||
[Required(ErrorMessage = "雪花id不能为空")]
|
||||
public string Id { get; set; }
|
||||
|
||||
public int? SerialNum { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "任务code(工单号_no)不能为空")]
|
||||
public string TaskCode { get; set; }
|
||||
|
||||
public string LineCode { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "任务日期不能为空")]
|
||||
public DateTime? TaskDate { get; set; }
|
||||
|
||||
public int? PreparationStatus { get; set; }
|
||||
|
||||
public string CreatedBy { get; set; }
|
||||
|
||||
public DateTime? CreatedTime { get; set; }
|
||||
|
||||
public string UpdatedBy { get; set; }
|
||||
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,19 @@ namespace DOAN.Model.MES.mm.Dto
|
||||
|
||||
public DateTime? RequireDate { get; set; }
|
||||
}
|
||||
public class MmRequirePlanQueryDto2 : PagerInfo
|
||||
{
|
||||
public string MaterialCode { get; set; }
|
||||
|
||||
public string MaterialName { get; set; }
|
||||
|
||||
public DateTime? RequireDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产线code
|
||||
/// </summary>
|
||||
public string line_code { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物料需求计划输入输出对象
|
||||
|
||||
70
DOAN.Model/MES/mm/MmPreparationTaskLine.cs
Normal file
70
DOAN.Model/MES/mm/MmPreparationTaskLine.cs
Normal file
@ -0,0 +1,70 @@
|
||||
namespace DOAN.Model.MES.mm
|
||||
{
|
||||
/// <summary>
|
||||
/// 产前备料任务 以线为单位
|
||||
/// </summary>
|
||||
[SugarTable("mm_preparation_task_line")]
|
||||
public class MmPreparationTaskLine
|
||||
{
|
||||
/// <summary>
|
||||
/// 雪花id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "serial_num")]
|
||||
public int? SerialNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务code(工单号_no)
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "task_code")]
|
||||
public string TaskCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产线code
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "line_code")]
|
||||
public string LineCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务日期
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "task_date")]
|
||||
public DateTime? TaskDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备货状态(1 未备料,2 备料完成)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "preparation_status")]
|
||||
public int? PreparationStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "cREATED_BY")]
|
||||
public string CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "cREATED_TIME")]
|
||||
public DateTime? CreatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "uPDATED_BY")]
|
||||
public string UpdatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "uPDATED_TIME")]
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ using DOAN.Model;
|
||||
using DOAN.Model.MES.mm.Dto;
|
||||
using DOAN.Model.MES.mm;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DOAN.Service.group.IService
|
||||
{
|
||||
@ -26,5 +27,8 @@ namespace DOAN.Service.group.IService
|
||||
int AllUpdateMaterialStatus(DateTime? handledate, int status, string name);
|
||||
|
||||
bool CheckCommunicationERPInventory();
|
||||
|
||||
|
||||
PagedInfo<MmRequirePlanDto> GetMaterialRequirePlanByline(MmRequirePlanQueryDto2 parm);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ using DOAN.Model.MES.base_;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NPOI;
|
||||
using DOAN.Model.MES.ERP;
|
||||
using Mapster;
|
||||
|
||||
namespace DOAN.Service.group
|
||||
{
|
||||
@ -279,5 +280,134 @@ namespace DOAN.Service.group
|
||||
return childDb.Queryable<CustDevMesCurrentStock>().Any();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据产线和日期查询物料需求计划
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<MmRequirePlanDto> GetMaterialRequirePlanByline(MmRequirePlanQueryDto2 parm)
|
||||
{
|
||||
//查询当日线下所有工单
|
||||
parm.RequireDate = parm.RequireDate.Value.ToLocalTime().Date;
|
||||
|
||||
int result = 0;
|
||||
|
||||
Dictionary<string, float> need_Materials = new Dictionary<string, float>();
|
||||
Dictionary<string, HashSet<string>> need_Materials_workOrder = new Dictionary<string, HashSet<string>>();
|
||||
List<MmRequirePlan> mmRequirePlans = new List<MmRequirePlan>();
|
||||
//获取当天所有工单
|
||||
List<ProWorkorder> ProWorkorderList = Context.Queryable<ProWorkorder>().Where(it => it.LineCode == parm.line_code)
|
||||
.Where(it => it.WorkorderDate == parm.RequireDate).ToList();
|
||||
if (ProWorkorderList != null && ProWorkorderList.Count > 0)
|
||||
{
|
||||
foreach (var workorder_item in ProWorkorderList)
|
||||
{
|
||||
|
||||
//遍历每个工单的产品
|
||||
if (!string.IsNullOrEmpty(workorder_item.ProductionCode))
|
||||
{
|
||||
|
||||
//每个产品的原材料 BOM
|
||||
//var query= Context.Queryable<BaseMaterialBom>().Where(it => it.InvCode == workorder_item.ProductionCode);
|
||||
List<BaseMaterialBom> boms = Context.Queryable<BaseMaterialBom>().Where(it => it.InvCode == workorder_item.ProductionCode).ToList();
|
||||
if (boms != null && boms.Count > 0)
|
||||
{
|
||||
|
||||
//遍历所有子件
|
||||
foreach (var item in boms)
|
||||
{
|
||||
float need_num = (workorder_item.DeliveryNum ?? 1) * (float.Parse(item.Iusequantity));
|
||||
if (need_Materials.ContainsKey(item.SubInvCode))
|
||||
{
|
||||
float pre_num = need_Materials[item.SubInvCode];
|
||||
need_Materials[item.SubInvCode] = pre_num + need_num;
|
||||
}
|
||||
else
|
||||
{
|
||||
need_Materials.Add(item.SubInvCode, need_num);
|
||||
}
|
||||
if (need_Materials_workOrder.ContainsKey(item.SubInvCode))
|
||||
{
|
||||
|
||||
need_Materials_workOrder[item.SubInvCode].Add(workorder_item.Workorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
need_Materials_workOrder.Add(item.SubInvCode, new HashSet<string>() { workorder_item.Workorder });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (need_Materials.Count > 0)
|
||||
{
|
||||
string[] SubInvCode = need_Materials.Keys.ToArray();
|
||||
List<BaseMaterialList> baseMaterialList = Context.Queryable<BaseMaterialList>().Where(it => SubInvCode.Contains(it.Code)).ToList();
|
||||
|
||||
if (baseMaterialList != null && baseMaterialList.Count() > 0)
|
||||
{
|
||||
string[] search_codes = baseMaterialList.Select(it => it.Code).ToArray();
|
||||
var childDb = Context.AsTenant().GetConnectionWithAttr<CustDevMesCurrentStock>();
|
||||
var search_code_List = childDb.Queryable<CustDevMesCurrentStock>().Where(it => search_codes.Contains(it.InvCode)).ToList();
|
||||
foreach (var item in baseMaterialList)
|
||||
{
|
||||
|
||||
decimal IQuantity = search_code_List.Where(it => it.InvCode == item.Code).Select(it => it.IQuantity).FirstOrDefault();
|
||||
|
||||
MmRequirePlan mmRequirePlan = new MmRequirePlan();
|
||||
mmRequirePlan.Id = XueHua;
|
||||
mmRequirePlan.MaterialCode = item.Code;
|
||||
mmRequirePlan.MaterialName = item.Name;
|
||||
mmRequirePlan.RequireNum = (decimal)(need_Materials.TryGetValue(item.Code, out float value) ? value : default(float));
|
||||
mmRequirePlan.WhQuantity = IQuantity;
|
||||
mmRequirePlan.RequireDate = parm.RequireDate;
|
||||
if (mmRequirePlan.RequireNum > mmRequirePlan.WhQuantity)
|
||||
{
|
||||
mmRequirePlan.IsSufficient = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mmRequirePlan.IsSufficient = 2;
|
||||
}
|
||||
|
||||
mmRequirePlan.CreatedBy = "";
|
||||
mmRequirePlan.CreatedTime = DateTime.Now;
|
||||
|
||||
|
||||
if (need_Materials_workOrder.ContainsKey(item.Code))
|
||||
{
|
||||
|
||||
mmRequirePlan.WorkorderArray = String.Join(", ", need_Materials_workOrder[item.Code].ToArray());
|
||||
}
|
||||
|
||||
|
||||
mmRequirePlans.Add(mmRequirePlan);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
PagedInfo<MmRequirePlanDto> pagedInfo = new PagedInfo<MmRequirePlanDto>();
|
||||
pagedInfo.PageSize= parm.PageSize;
|
||||
pagedInfo.PageIndex = (parm.PageNum - 1) * parm.PageSize;
|
||||
pagedInfo.TotalNum = mmRequirePlans.Count();
|
||||
pagedInfo.Result = mmRequirePlans.Skip((parm.PageNum - 1) * parm.PageSize).Take(parm.PageSize).ToList().Adapt<List<MmRequirePlanDto>>();
|
||||
|
||||
|
||||
|
||||
return pagedInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user