仓库管理:出货计划:update
This commit is contained in:
@@ -165,7 +165,8 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
return SUCCESS(null);
|
||||
}
|
||||
List<WmOutOrderPlan> WmOutOrderPlanList= _WmOutOrderService.Generate_outorderplan(shipment_num);
|
||||
// TODO 1.返回值修改为 对象 返回是否可生成计划,计划结果:{canPlan:true,resultList:[]}
|
||||
List<WmOutOrderPlan> WmOutOrderPlanList = _WmOutOrderService.Generate_outorderplan(shipment_num);
|
||||
|
||||
return SUCCESS(WmOutOrderPlanList);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,14 @@
|
||||
{
|
||||
|
||||
//本地连接服务器
|
||||
// "Conn": "Data Source=localhost;User ID=root;Password=123456;Initial Catalog=ZrAdmin;",
|
||||
// "Conn": "Data Source=localhost;User ID=root;Password=123456;Initial Catalog=ZrAdmin;",
|
||||
|
||||
//外网连接服务器
|
||||
//"Conn": "Data Source=47.116.122.230;Port=3307;User ID=root;Password=123456;Initial Catalog=ZrAdmin;",
|
||||
// 干巷服务器
|
||||
"Conn": "Data Source=192.168.60.251;Port=3306;User ID=root;Password=123456;Initial Catalog=ZrAdmin;",
|
||||
//内网连接服务器
|
||||
"Conn": "Data Source=192.168.0.36;Port=3306;User ID=root;Password=123456;Initial Catalog=ZrAdmin;",
|
||||
//"Conn": "Data Source=192.168.0.36;Port=3306;User ID=root;Password=123456;Initial Catalog=ZrAdmin;",
|
||||
"Type": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4,
|
||||
"ConfigId": "0", //多租户唯一标识
|
||||
"IsAutoCloseConnection": true
|
||||
|
||||
@@ -27,6 +27,11 @@ namespace ZR.Model.MES.wms
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "patchcode")]
|
||||
public string Patchcode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 短批次号
|
||||
/// </summary>
|
||||
public string Patchcode_short { get; set; }
|
||||
/// <summary>
|
||||
/// 物料号
|
||||
///</summary>
|
||||
|
||||
@@ -10,6 +10,9 @@ using Mapster;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using JinianNet.JNTemplate.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.Xml;
|
||||
using System.Collections;
|
||||
|
||||
namespace ZR.Service.mes.wms
|
||||
{
|
||||
@@ -65,13 +68,13 @@ namespace ZR.Service.mes.wms
|
||||
foreach (var moItem in moList)
|
||||
{
|
||||
WmMaterial material = Context.Queryable<WmMaterial>().Where(it => it.Id == moItem.FkMaterialId).First();
|
||||
if(material != null)
|
||||
if (material != null)
|
||||
{
|
||||
WmMaterialQuery_stockQuantityDto2 dto2 = material.Adapt<WmMaterialQuery_stockQuantityDto2>();
|
||||
dto2.requireOutNum = moItem.OuthouseNum;
|
||||
Material_stock.Add(dto2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
wmOutOrderItem.MaterialList = Material_stock;
|
||||
}
|
||||
@@ -248,19 +251,17 @@ namespace ZR.Service.mes.wms
|
||||
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();
|
||||
stock.PackageNum = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == stock.Partnumber).Count();
|
||||
|
||||
//现有零件数
|
||||
int? num = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == shipment_num).Sum(it => it.GoodsNumLogic);
|
||||
stock.PackageNum = num ?? 0;
|
||||
int? num = Context.Queryable<WmGoodsNowProduction>().Where(it => it.Partnumber == stock.Partnumber).Sum(it => it.GoodsNumLogic);
|
||||
stock.ItemNum = num ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,11 +281,15 @@ namespace ZR.Service.mes.wms
|
||||
public List<WmOutOrderPlan> Generate_outorderplan(string shipment_num)
|
||||
{
|
||||
|
||||
List<WmOutOrderPlan> wmOutOrderPlans = new List<WmOutOrderPlan>();
|
||||
List<WmOutOrderPlan> wmOutOrderPlans = new List<WmOutOrderPlan>();
|
||||
// 获取当前出货单下的物料信息
|
||||
List<WmMaterialQuery_print> materialQuery_Prints = this.Queryoutoder_matrials(shipment_num);
|
||||
if (materialQuery_Prints != null && materialQuery_Prints.Count > 0)
|
||||
{
|
||||
// TODO 1.判断能否完整出货
|
||||
|
||||
// TODO 2.生成出货单
|
||||
|
||||
foreach (var material in materialQuery_Prints)
|
||||
{
|
||||
//todo 判断要出多少货 按照最早工单和批次号 进行出货(重要算法)
|
||||
@@ -293,24 +298,18 @@ namespace ZR.Service.mes.wms
|
||||
|
||||
// 物料号
|
||||
string partnumber = material.Partnumber;
|
||||
// 原始编号
|
||||
|
||||
// 该物料下 ,现有货物列表
|
||||
|
||||
List<WmGoodsNowProduction> wmGoodsNowsList = Context.Queryable<WmGoodsNowProduction>()
|
||||
.Where(it => it.Partnumber == partnumber)
|
||||
.OrderByDescending(it => it.PackageCodeClient)
|
||||
.ToList();
|
||||
// TODO 1.根据入库时间,进行排序
|
||||
|
||||
// 该物料下 ,现有货物列表
|
||||
List<WmGoodsNowProduction> wmGoodsNowsList = Context.Queryable<WmGoodsNowProduction>()
|
||||
.Where(it => it.Partnumber == partnumber)
|
||||
.OrderByDescending(it => it.PackageCodeClient)
|
||||
.ToList();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO 2.根据排序结果,检查数量是否达标(require_num<=accumulation_num)向最终结果数组进行添加
|
||||
List< WmGoodsNowProduction > planList = new List<WmGoodsNowProduction>();
|
||||
|
||||
|
||||
foreach (var witem in wmGoodsNowsList)
|
||||
@@ -328,27 +327,27 @@ namespace ZR.Service.mes.wms
|
||||
orderPlan.RequireNum = require_num;
|
||||
orderPlan.Patchtime = Resolution_bath(witem.PackageCodeClient);
|
||||
wmOutOrderPlans.Add(orderPlan);
|
||||
|
||||
accumulation_num = accumulation_num + witem.GoodsNumLogic ?? 0;
|
||||
|
||||
// 实际值计算
|
||||
accumulation_num = accumulation_num + witem.GoodsNumAction ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
else
|
||||
{
|
||||
// 超过要用零头箱
|
||||
if(require_num- accumulation_num<= witem.GoodsNumLogic)
|
||||
if (require_num - accumulation_num <= witem.GoodsNumAction)
|
||||
{
|
||||
WmOutOrderPlan orderPlan = new WmOutOrderPlan();
|
||||
orderPlan.FkOutOrderId = shipment_num;
|
||||
|
||||
orderPlan.Patchcode = witem.PackageCodeClient;
|
||||
orderPlan.Patchcode_short = witem.PackageCodeClient.Split("_")[0];
|
||||
orderPlan.MaterialCode = witem.Partnumber;
|
||||
orderPlan.WarehouseCode = witem.LocationCode;
|
||||
orderPlan.PackageNum = int.Parse(witem.PackageCodeClient.Split("_")[1]);
|
||||
orderPlan.RequireNum = require_num;
|
||||
orderPlan.PackageNum = 1; //短批次需求累加
|
||||
orderPlan.RequireNum = require_num; //总需求
|
||||
orderPlan.Patchtime = Resolution_bath(witem.PackageCodeClient);
|
||||
wmOutOrderPlans.Add(orderPlan);
|
||||
|
||||
accumulation_num = accumulation_num + witem.GoodsNumLogic ?? 0;
|
||||
accumulation_num = accumulation_num + witem.GoodsNumAction ?? 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -356,18 +355,29 @@ namespace ZR.Service.mes.wms
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// todo 把该物料下的箱子 按照短批次号 进行分组聚合
|
||||
|
||||
if (wmOutOrderPlans.Count > 0)
|
||||
{
|
||||
var item = wmOutOrderPlans.GroupBy(it => it.Patchcode_short).Select(g => new
|
||||
{
|
||||
FkOutOrderId = g.Max(p => p.FkOutOrderId),
|
||||
Patchcode = g.Max(p => p.Patchcode),
|
||||
Patchcode_short = g.Max(p => p.Patchcode_short),
|
||||
WarehouseCode = g.Max(p => p.WarehouseCode),
|
||||
PackageNum = g.Count(),
|
||||
RequireNum = g.Max(p => p.RequireNum),
|
||||
Patchtime = g.Max(p => p.Patchtime),
|
||||
});
|
||||
wmOutOrderPlans.Clear();
|
||||
wmOutOrderPlans.Add(item.Adapt<WmOutOrderPlan>());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
foreach (var witem in wmOutOrderPlans)
|
||||
{
|
||||
witem.Outorder = wmOutOrderPlans.IndexOf(witem);
|
||||
witem.Outorder = wmOutOrderPlans.IndexOf(witem) + 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -380,14 +390,14 @@ namespace ZR.Service.mes.wms
|
||||
/// </summary>
|
||||
/// <param name="doMaterialOut"></param>
|
||||
/// <returns></returns>
|
||||
public (int,int) DoMaterialOut(WmDoMaterialOut_Dto doMaterialOut, string Createby)
|
||||
public (int, int) DoMaterialOut(WmDoMaterialOut_Dto doMaterialOut, string Createby)
|
||||
{
|
||||
int sum_delete = 0;
|
||||
int sum_insert = 0;
|
||||
string shipnumber = doMaterialOut.ShipmentNum;
|
||||
if(doMaterialOut.PatchCode!=null&& doMaterialOut.PatchCode.Length > 0)
|
||||
if (doMaterialOut.PatchCode != null && doMaterialOut.PatchCode.Length > 0)
|
||||
{
|
||||
foreach(var item in doMaterialOut.PatchCode)
|
||||
foreach (var item in doMaterialOut.PatchCode)
|
||||
{
|
||||
UseTran2(() =>
|
||||
{
|
||||
@@ -399,7 +409,7 @@ namespace ZR.Service.mes.wms
|
||||
if (nowProduction != null)
|
||||
{
|
||||
record.FkNowProductionId = nowProduction.Id;
|
||||
record.PackageCodeClient= nowProduction.PackageCodeClient;
|
||||
record.PackageCodeClient = nowProduction.PackageCodeClient;
|
||||
record.PackageCode = nowProduction.PackageCode;
|
||||
record.PackageCodeOriginal = nowProduction.PackageCodeOriginal;
|
||||
record.LocationCode = nowProduction.LocationCode;
|
||||
@@ -411,26 +421,26 @@ namespace ZR.Service.mes.wms
|
||||
record.CreatedTime = DateTime.Now;
|
||||
record.CreatedBy = Createby;
|
||||
record.FkOutOrderId = shipnumber;
|
||||
sum_insert= Context.Insertable(record).ExecuteCommand();
|
||||
sum_delete+= Context.Deleteable<WmGoodsNowProduction>()
|
||||
sum_insert = Context.Insertable(record).ExecuteCommand();
|
||||
sum_delete += Context.Deleteable<WmGoodsNowProduction>()
|
||||
.Where(it => it.PackageCodeClient == item)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return (sum_delete, sum_insert);
|
||||
}
|
||||
|
||||
public bool OverOutorderplan(string shipment_num)
|
||||
public bool OverOutorderplan(string shipment_num)
|
||||
{
|
||||
int reult= Context.Updateable<WmOutOrder>().Where(it=>it.ShipmentNum==shipment_num)
|
||||
.SetColumns(it => it.Type == 2)
|
||||
.ExecuteCommand();
|
||||
if(reult>0)
|
||||
int reult = Context.Updateable<WmOutOrder>().Where(it => it.ShipmentNum == shipment_num)
|
||||
.SetColumns(it => it.Type == 2)
|
||||
.ExecuteCommand();
|
||||
if (reult > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user