diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsActionController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsActionController.cs
index c02237a9..8b3ae3db 100644
--- a/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsActionController.cs
+++ b/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsActionController.cs
@@ -13,7 +13,7 @@ namespace ZR.Admin.WebApi.Controllers
///
/// 仓库操作
///
- [Verify]
+ // [Verify]
[Route("/mes/wm/WmGoodsAction")]
public class WmGoodsActionController : BaseController
{
@@ -38,6 +38,10 @@ namespace ZR.Admin.WebApi.Controllers
public IActionResult doConsolidationGoods([FromBody] WmGoodsConsolidationDto parm)
{
WmGoodsChangeLog response = _WmGoodsActionService.doConsolidationGoods(parm);
+ if(response == null)
+ {
+ return ToResponse(new ApiResult(500, "拼箱异常!", "拼箱异常!"));
+ }
return SUCCESS(response);
}
diff --git a/ZR.Model/MES/wms/Dto/WmGoodsActionDto.cs b/ZR.Model/MES/wms/Dto/WmGoodsActionDto.cs
index 78250d49..c841f649 100644
--- a/ZR.Model/MES/wms/Dto/WmGoodsActionDto.cs
+++ b/ZR.Model/MES/wms/Dto/WmGoodsActionDto.cs
@@ -7,7 +7,9 @@ namespace ZR.Model.MES.wms.Dto
///
public class WmGoodsConsolidationDto
{
- public List List { get; set; }
+ public List PackageList { get; set; }
+
+ public string CreateBy { get; set; }
}
@@ -16,7 +18,8 @@ namespace ZR.Model.MES.wms.Dto
///
public class WmGoodsUnpackingDto
{
- public List List { get; set; }
+ public ResultionPackageCodeDto Package { get; set; }
+ public string CreateBy { get; set; }
}
}
\ No newline at end of file
diff --git a/ZR.Service/mes/wms/WmGoodsActionService.cs b/ZR.Service/mes/wms/WmGoodsActionService.cs
index 66bc2c65..b1dda3c9 100644
--- a/ZR.Service/mes/wms/WmGoodsActionService.cs
+++ b/ZR.Service/mes/wms/WmGoodsActionService.cs
@@ -10,6 +10,7 @@ using ZR.Service.Business.IBusinessService;
using System.Linq;
using ZR.Service.mes.wms.IService;
using ZR.Model.MES.wms.Dto;
+using System.Text.Json;
namespace ZR.Service.Business
{
@@ -21,12 +22,104 @@ namespace ZR.Service.Business
{
public WmGoodsChangeLog doConsolidationGoods(WmGoodsConsolidationDto parm)
{
- throw new NotImplementedException();
+ List list = parm.PackageList;
+
+ string description = "";
+ // 拼箱计数器
+ int num = 0;
+ int? quantityCount = 0;
+ List ids = new();
+ // 箱验证
+ foreach (ResultionPackageCodeDto package in list)
+ {
+ num++;
+ WmGoodsNowProduction check1 = Context.Queryable().Where(it => it.PackageCodeClient == package.PatchCode).First();
+ if (check1 == null)
+ {
+ return null;
+ }
+ if (num == 1)
+ {
+ description = "主箱:" + package.PatchCode + ",次箱:";
+ }
+ else
+ {
+ ids.Add(check1.Id);
+ description += package.PatchCode + ",";
+ }
+ quantityCount += package.Quantity;
+ }
+ ResultionPackageCodeDto mainPackage = list[0];
+ // 短批次
+ string shortPatchCode = mainPackage.PatchCode.Split('_')[0];
+ // 该批次最后一个拼箱记录
+ WmGoodsNowProduction lastConsolidationPackage = Context.Queryable().Where(it => it.PackageCodeClient.Contains(shortPatchCode + "_4")).OrderBy(it => it.PackageCodeClient, OrderByType.Desc).First();
+ string newShortPatchCode = shortPatchCode;
+
+ int lastCode = 400;
+ if (lastConsolidationPackage == null)
+ {
+ newShortPatchCode += "_401";
+ }
+ else
+ {
+ if (int.TryParse(lastConsolidationPackage.PackageCodeClient.Split('_')[1], out lastCode))
+ {
+
+ if (lastCode > 400)
+ {
+ newShortPatchCode += "_" + (lastCode + 1);
+ }
+ else
+ {
+ newShortPatchCode += "_401";
+ }
+ }
+ }
+ description += "拼箱结果:" + newShortPatchCode;
+ var jsonObject = new
+ {
+ packageList = list
+ };
+ // 日志记录
+ WmGoodsChangeLog log = new WmGoodsChangeLog();
+ log.CreatedBy = parm.CreateBy;
+ log.CreatedTime = DateTime.Now.ToLocalTime();
+ log.Description = description;
+ log.JsonMsg = JsonSerializer.Serialize(jsonObject);
+ log.Type = 1;
+ Context.Insertable(log).ExecuteReturnEntity();
+ // 执行修改
+ // 1.主箱查出并修改参数
+ WmGoodsNowProduction nowProduction = Context.Queryable()
+ .Where(it => it.PackageCodeClient == mainPackage.PatchCode).First();
+ if (nowProduction == null)
+ {
+ return null;
+ }
+ nowProduction.UpdatedBy = parm.CreateBy;
+ nowProduction.UpdatedTime = DateTime.Now.ToLocalTime();
+ nowProduction.PackageCodeClient = newShortPatchCode;
+ nowProduction.PackageCodeOriginal = "Code=" + newShortPatchCode
+ + "^ItemNumber=" + nowProduction.Partnumber
+ + "^Order=" + newShortPatchCode.Split('_')[0]
+ + "^Qty=" + quantityCount;
+ nowProduction.GoodsNumLogic = quantityCount;
+ nowProduction.GoodsNumAction = quantityCount;
+ nowProduction.Remark = "拼箱";
+ // 修改主箱
+ Context.Updateable(nowProduction).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
+ // TODO修改打印记录
+
+ // 删除分箱
+ Context.Deleteable().In(ids).ExecuteCommand();
+
+ return log;
}
public WmGoodsChangeLog doUnpackingGoods(WmGoodsUnpackingDto parm)
{
- throw new NotImplementedException();
+ return null;
}
}
}
\ No newline at end of file