仓库模块_出库货物记录:init

This commit is contained in:
qianhao.xu
2024-03-22 08:54:11 +08:00
parent 2074ea2e84
commit dac58ddb77
20 changed files with 800 additions and 20 deletions

View File

@@ -8,6 +8,8 @@ using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using Mapster;
using System.Collections.Generic;
using System.Data;
using JinianNet.JNTemplate.Dynamic;
namespace ZR.Service.mes.wms
{
@@ -220,5 +222,188 @@ namespace ZR.Service.mes.wms
return (material_stockQuantity_list, total);
}
/// <summary>
/// 查询出货单的物料信息
/// </summary>
/// <param name="shipment_num"></param>
/// <returns></returns>
public List<WmMaterialQuery_print> Queryoutoder_matrials(string shipment_num)
{
List<WmMaterialQuery_print> stockList = Context.Queryable<WmMaterialOutorder>()
.LeftJoin<WmMaterial>((mo, m) => mo.FkMaterialId == m.Id)
.Where(mo => mo.FkOutorderId == shipment_num)
.Select((mo, m) => new WmMaterialQuery_print()
{
//物料号
Partnumber = m.Partnumber,
// 描述
ProductName = m.ProductName,
//需求零件数
RequireOutNum = mo.OuthouseNum
}).ToList();
if (stockList != null && stockList.Count > 0)
{
foreach (var stock in stockList)
{
//现有箱数
stock.PackageNum = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == shipment_num).Count();
//现有零件数
int? num = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == shipment_num).Sum(it => it.GoodsNumLogic);
stock.PackageNum = num ?? 0;
}
}
return stockList;
}
/// <summary>
/// 生成出货单的出货计划
/// </summary>
/// <param name="shipment_num">出货单号</param>
/// <returns></returns>
public List<WmOutOrderPlan> Generate_outorderplan(string shipment_num)
{
List<WmOutOrderPlan> wmOutOrderPlans = new List<WmOutOrderPlan>();
// 获取当前出货单下的物料信息
List<WmMaterialQuery_print> materialQuery_Prints = this.Queryoutoder_matrials(shipment_num);
if (materialQuery_Prints != null && materialQuery_Prints.Count > 0)
{
foreach (var material in materialQuery_Prints)
{
//todo 判断要出多少货 按照最早工单和批次号 进行出货(重要算法)
//1. 这个物料要出多少货
int require_num = material.RequireOutNum;
// 物料号
string partnumber = material.Partnumber;
/*此物料下的最早列表
List<WmGoodsNowProduction> wmGoodsNows = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == partnumber)
.OrderByDescending(it => it.EntryWarehouseTime).ToList();
if (wmGoodsNows != null && wmGoodsNows.Count > 0)
{
foreach (var witem in wmGoodsNows)
{
if (require_num >= witem.GoodsNumLogic)
{ // 取出同一批次下列表
string patchcode = witem.PackageCodeClient.Split("_")[0];
List<WmGoodsNowProduction> Samebatch_wmGoodsNows = Context.Queryable<WmGoodsNowProduction>()
.Where(it => it.Partnumber == partnumber)
.Where(it => it.PackageCodeClient.StartsWith(patchcode)).ToList();
出货计划
WmOutOrderPlan orderPlan = new WmOutOrderPlan();
orderPlan.FkOutOrderId = shipment_num;
orderPlan.Patchcode = witem.PackageCodeClient;
orderPlan.MaterialCode = witem.Partnumber;
orderPlan.WarehouseCode = witem.LocationCode;
orderPlan.PackageNum = 1;
orderPlan.RequireNum = require_num;
orderPlan.Patchtime = Resolution_bath(witem.PackageCodeClient);
wmOutOrderPlans.Add(orderPlan);
}
else
{
一个箱子就可以做一个出货计划
WmOutOrderPlan orderPlan = new WmOutOrderPlan();
orderPlan.FkOutOrderId = shipment_num;
orderPlan.Patchcode = witem.PackageCodeClient;
orderPlan.MaterialCode = witem.Partnumber;
orderPlan.WarehouseCode = witem.LocationCode;
orderPlan.PackageNum = 1;
orderPlan.RequireNum = require_num;
orderPlan.Patchtime = Resolution_bath(witem.PackageCodeClient);
}
}
}*/
List<WmGoodsNowProduction> wmGoodsNowsList = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == partnumber)
.OrderByDescending(it => it.PackageCodeClient).ToList();
foreach(var witem in wmGoodsNowsList)
{
int accumulation_num = 0;
if (require_num>= accumulation_num)
{
WmOutOrderPlan orderPlan = new WmOutOrderPlan();
orderPlan.FkOutOrderId = shipment_num;
orderPlan.Patchcode = witem.PackageCodeClient;
orderPlan.MaterialCode = witem.Partnumber;
orderPlan.WarehouseCode = witem.LocationCode;
orderPlan.PackageNum =int.Parse( witem.PackageCodeClient.Split("_")[1] );
orderPlan.RequireNum = require_num;
orderPlan.Patchtime = Resolution_bath(witem.PackageCodeClient);
wmOutOrderPlans.Add(orderPlan);
accumulation_num = accumulation_num+ witem.GoodsNumLogic??0;
}
else
{ //超了
break;
}
}
}
}
foreach (var witem in wmOutOrderPlans)
{
witem.Outorder = wmOutOrderPlans.IndexOf(witem);
}
return wmOutOrderPlans;
}
/// <summary>
/// 传入批次号 解析出时间 BNW240318007_105
/// </summary>
/// <param name="bath_code"></param>
/// <returns></returns>
private string Resolution_bath(string bath_code)
{
if (string.IsNullOrEmpty(bath_code))
{
return "";
}
string temp = bath_code.Split("_")[0];
return "20" + temp.Substring(2, 6);
}
}
}