仓库-拆箱功能完成

This commit is contained in:
赵正易
2024-04-19 14:00:33 +08:00
parent d7e8206976
commit c8a9f3b648
3 changed files with 130 additions and 20 deletions

View File

@@ -19,6 +19,8 @@ namespace ZR.Model.MES.wms.Dto
public class WmGoodsUnpackingDto public class WmGoodsUnpackingDto
{ {
public ResultionPackageCodeDto Package { get; set; } public ResultionPackageCodeDto Package { get; set; }
public int firstNum { get; set; }
public string CreateBy { get; set; } public string CreateBy { get; set; }
} }

View File

@@ -11,6 +11,9 @@ using System.Linq;
using ZR.Service.mes.wms.IService; using ZR.Service.mes.wms.IService;
using ZR.Model.MES.wms.Dto; using ZR.Model.MES.wms.Dto;
using System.Text.Json; using System.Text.Json;
using MimeKit.Utils;
using System.Collections.Generic;
using Org.BouncyCastle.Crypto;
namespace ZR.Service.Business namespace ZR.Service.Business
{ {
@@ -40,7 +43,7 @@ namespace ZR.Service.Business
} }
if (num == 1) if (num == 1)
{ {
description = "主箱:" + package.PatchCode + ",次箱:"; description = "\n主箱:" + package.PatchCode + ",\n次箱:";
} }
else else
{ {
@@ -54,12 +57,11 @@ namespace ZR.Service.Business
string shortPatchCode = mainPackage.PatchCode.Split('_')[0]; string shortPatchCode = mainPackage.PatchCode.Split('_')[0];
// 该批次最后一个拼箱记录 // 该批次最后一个拼箱记录
WmGoodsNowProduction lastConsolidationPackage = Context.Queryable<WmGoodsNowProduction>().Where(it => it.PackageCodeClient.Contains(shortPatchCode + "_4")).OrderBy(it => it.PackageCodeClient, OrderByType.Desc).First(); WmGoodsNowProduction lastConsolidationPackage = Context.Queryable<WmGoodsNowProduction>().Where(it => it.PackageCodeClient.Contains(shortPatchCode + "_4")).OrderBy(it => it.PackageCodeClient, OrderByType.Desc).First();
string newShortPatchCode = shortPatchCode; string newPatchCode = shortPatchCode;
int lastCode = 400; int lastCode = 400;
if (lastConsolidationPackage == null) if (lastConsolidationPackage == null)
{ {
newShortPatchCode += "_401"; newPatchCode += "_401";
} }
else else
{ {
@@ -68,26 +70,32 @@ namespace ZR.Service.Business
if (lastCode > 400) if (lastCode > 400)
{ {
newShortPatchCode += "_" + (lastCode + 1); newPatchCode += "_" + (lastCode + 1);
} }
else else
{ {
newShortPatchCode += "_401"; newPatchCode += "_401";
} }
} }
} }
description += "拼箱结果:" + newShortPatchCode; description += "\n拼箱结果:" + newPatchCode;
DateTime nowTime = DateTime.Now.ToLocalTime();
var jsonObject = new var jsonObject = new
{ {
packageList = list packageList = list,
newPatchCode = newPatchCode,
newQuantityCount = quantityCount,
time = DateUtils.FormatDate(nowTime)
}; };
// 日志记录 // 日志记录
WmGoodsChangeLog log = new WmGoodsChangeLog(); WmGoodsChangeLog log = new()
log.CreatedBy = parm.CreateBy; {
log.CreatedTime = DateTime.Now.ToLocalTime(); CreatedBy = parm.CreateBy,
log.Description = description; CreatedTime = nowTime,
log.JsonMsg = JsonSerializer.Serialize(jsonObject); Description = description,
log.Type = 1; JsonMsg = JsonSerializer.Serialize(jsonObject),
Type = 1
};
Context.Insertable(log).ExecuteReturnEntity(); Context.Insertable(log).ExecuteReturnEntity();
// 执行修改 // 执行修改
// 1.主箱查出并修改参数 // 1.主箱查出并修改参数
@@ -98,11 +106,11 @@ namespace ZR.Service.Business
return null; return null;
} }
nowProduction.UpdatedBy = parm.CreateBy; nowProduction.UpdatedBy = parm.CreateBy;
nowProduction.UpdatedTime = DateTime.Now.ToLocalTime(); nowProduction.UpdatedTime = nowTime;
nowProduction.PackageCodeClient = newShortPatchCode; nowProduction.PackageCodeClient = newPatchCode;
nowProduction.PackageCodeOriginal = "Code=" + newShortPatchCode nowProduction.PackageCodeOriginal = "Code=" + newPatchCode
+ "^ItemNumber=" + nowProduction.Partnumber + "^ItemNumber=" + nowProduction.Partnumber
+ "^Order=" + newShortPatchCode.Split('_')[0] + "^Order=" + newPatchCode.Split('_')[0].Substring(2)
+ "^Qty=" + quantityCount; + "^Qty=" + quantityCount;
nowProduction.GoodsNumLogic = quantityCount; nowProduction.GoodsNumLogic = quantityCount;
nowProduction.GoodsNumAction = quantityCount; nowProduction.GoodsNumAction = quantityCount;
@@ -119,7 +127,107 @@ namespace ZR.Service.Business
public WmGoodsChangeLog doUnpackingGoods(WmGoodsUnpackingDto parm) public WmGoodsChangeLog doUnpackingGoods(WmGoodsUnpackingDto parm)
{ {
return null; string description = "";
// 待拆箱
ResultionPackageCodeDto mainPackage = parm.Package;
// 验证
WmGoodsNowProduction mainNowProduction = Context.Queryable<WmGoodsNowProduction>().Where(it => it.PackageCodeClient == mainPackage.PatchCode).First();
if (mainNowProduction == null)
{
return null;
}
description += "\n由主箱:" + mainPackage.PatchCode + "拆分:";
// 短批次
string shortPatchCode = mainPackage.PatchCode.Split('_')[0];
// 该批次最后一个拼箱记录
WmGoodsNowProduction lastConsolidationPackage = Context.Queryable<WmGoodsNowProduction>().Where(it => it.PackageCodeClient.Contains(shortPatchCode + "_4")).OrderBy(it => it.PackageCodeClient, OrderByType.Desc).First();
string newPatchCode1 = shortPatchCode;
string newPatchCode2 = shortPatchCode;
int lastCode = 400;
if (lastConsolidationPackage == null)
{
newPatchCode1 += "_401";
newPatchCode2 += "_402";
}
else
{
if (int.TryParse(lastConsolidationPackage.PackageCodeClient.Split('_')[1], out lastCode))
{
if (lastCode > 400)
{
newPatchCode1 += "_" + (lastCode + 1);
newPatchCode2 += "_" + (lastCode + 2);
}
else
{
newPatchCode1 += "_401";
newPatchCode2 += "_402";
}
}
}
int firstNum = parm.firstNum;
int? secondNum = mainNowProduction.GoodsNumAction - firstNum;
if (secondNum <= 0)
{
return null;
}
description += "\n拆箱结果1:" + newPatchCode1 + "数量为" + firstNum + "个";
description += "\n拆箱结果2:" + newPatchCode2 + "数量为" + secondNum + "个";
DateTime nowTime = DateTime.Now.ToLocalTime();
var jsonObject = new
{
mainPackage = mainPackage,
newPatchCode1 = newPatchCode1,
newPatchCode2 = newPatchCode2,
firstNum = firstNum,
secondNum = secondNum,
time = DateUtils.FormatDate(nowTime)
};
// 日志记录
WmGoodsChangeLog log = new()
{
CreatedBy = parm.CreateBy,
CreatedTime = nowTime,
Description = description,
JsonMsg = JsonSerializer.Serialize(jsonObject),
Type = 2
};
Context.Insertable(log).ExecuteReturnEntity();
// 执行修改
// 1.主箱修改为1号分箱参数
WmGoodsNowProduction newPackage1 = mainNowProduction;
newPackage1.UpdatedBy = parm.CreateBy;
newPackage1.UpdatedTime = nowTime;
newPackage1.PackageCodeClient = newPatchCode1;
newPackage1.PackageCodeOriginal = "Code=" + newPatchCode1
+ "^ItemNumber=" + newPackage1.Partnumber
+ "^Order=" + newPatchCode1.Split('_')[0].Substring(2)
+ "^Qty=" + firstNum;
newPackage1.GoodsNumLogic = firstNum;
newPackage1.GoodsNumAction = firstNum;
newPackage1.Remark = "拆箱";
// 修改主箱
Context.Updateable(newPackage1).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
// 2.添加一个分箱
WmGoodsNowProduction newPackage2 = mainNowProduction;
newPackage2.CreatedBy = parm.CreateBy;
newPackage2.CreatedTime = nowTime;
newPackage2.PackageCodeClient = newPatchCode2;
newPackage2.PackageCodeOriginal = "Code=" + newPatchCode2
+ "^ItemNumber=" + newPackage2.Partnumber
+ "^Order=" + newPatchCode2.Split('_')[0].Substring(2)
+ "^Qty=" + secondNum;
newPackage2.GoodsNumLogic = secondNum;
newPackage2.GoodsNumAction = secondNum;
newPackage2.Remark = "拆箱";
newPackage2.Id = SnowFlakeSingle.Instance.NextId().ToString();
// 修改主箱
Context.Insertable(newPackage1).ExecuteCommand();
// TODO修改打印记录
return log;
} }
} }
} }

View File

@@ -38,8 +38,8 @@ namespace ZR.Service.Business
; ;
var response = Queryable() var response = Queryable()
.Where(predicate.ToExpression()) .Where(predicate.ToExpression())
.OrderBy(it=>it.CreatedTime,OrderByType.Desc)
.ToPage<WmGoodsChangeLog, WmGoodsChangeLogDto>(parm); .ToPage<WmGoodsChangeLog, WmGoodsChangeLogDto>(parm);
return response; return response;
} }