仓库-仓库拼箱拆箱待打印记录功能添加

This commit is contained in:
2024-05-10 14:57:47 +08:00
parent 1727cb651f
commit 1a1062fb64
10 changed files with 575 additions and 56 deletions

View File

@@ -0,0 +1,24 @@
using System;
using ZR.Model;
using ZR.Model.Dto;
using ZR.Model.MES.wms;
using System.Collections.Generic;
using ZR.Model.MES.wms.Dto;
namespace ZR.Service.mes.wms.IService
{
/// <summary>
/// 拼箱/拆箱待打标签记录表service接口
/// </summary>
public interface IWmPackageLclService : IBaseService<WmPackageLcl>
{
PagedInfo<WmPackageLclDto> GetList(WmPackageLclQueryDto parm);
WmPackageLcl GetInfo(string Id);
WmPackageLcl AddWmPackageLcl(WmPackageLcl parm);
int UpdateWmPackageLcl(WmPackageLcl parm);
}
}

View File

@@ -15,6 +15,8 @@ using MimeKit.Utils;
using System.Collections.Generic;
using Org.BouncyCastle.Crypto;
using static System.Runtime.InteropServices.JavaScript.JSType;
using Microsoft.AspNetCore.Http.HttpResults;
using System.Text.Json.Nodes;
namespace ZR.Service.Business
{
@@ -62,7 +64,7 @@ namespace ZR.Service.Business
secondId = check1.Id;
description += package.PatchCode + " 数量:" + package.Quantity + ",";
}
// 第二箱数量为正数且比箱子总数量小
// 如果PDA所填合并的数量为正数且比箱子总数量小
if (num == 2 && secondNum < package.Quantity && secondNum > 0)
{
isDelete = false;
@@ -87,6 +89,7 @@ namespace ZR.Service.Business
.OrderBy(it => it.PackageCodeClient, OrderByType.Desc)
.First();
string newPatchCode = shortPatchCode;
// 最终初始编号
int lastCode = 400;
// 检测包装是否已打印4XX标签
// 该工单标签最大一个
@@ -99,38 +102,46 @@ namespace ZR.Service.Business
.Where(packingrecordExp)
.OrderBy(it=>it.PackingCode, OrderByType.Desc)
.First();
if (lastConsolidationPackage == null && lastPackingrecord == null)
// 优先处理箱打印有历史数据情况
if (lastPackingrecord != null)
{
newPatchCode += "_401";
}
else
{
int lastPackingrecordCode = 0;
// 优先处理箱打印有历史数据情况
if (lastPackingrecord != null)
int subIndex = lastPackingrecord.PackingCode.Length - 5;
// XXX 此代码中 AsSpan 方法 .NET Framework 4.7.2 不支持需要更高版本 或替换为 Substring
if (int.TryParse(lastPackingrecord.PackingCode.AsSpan(subIndex).TrimStart('0'), out int lastPackingrecordCode))
{
int subIndex = lastPackingrecord.PackingCode.Length - 5;
// XXX 此代码中 AsSpan 方法 .NET Framework 4.7.2 不支持需要更高版本 或替换为 Substring
if (int.TryParse(lastPackingrecord.PackingCode.AsSpan(subIndex).TrimStart('0'), out lastPackingrecordCode))
{
}
}
if (int.TryParse(lastConsolidationPackage.PackageCodeClient.Split('_')[1], out lastCode))
{
// 取最大值
if (lastPackingrecordCode > lastCode)
{
lastCode = lastPackingrecordCode;
}
if (lastCode > 400)
}
else
{
throw new Exception("生成标签数据异常:" + lastPackingrecord.PackingCode);
}
}
// 其次处理成品库历史最大数字
if (lastConsolidationPackage != null)
{
if (int.TryParse(lastConsolidationPackage.PackageCodeClient.Split('_')[1], out int lastConsolidationPackageCode))
{
// 取最大值
if (lastConsolidationPackageCode > lastCode)
{
newPatchCode += "_" + (lastCode + 1);
}
else
{
newPatchCode += "_401";
lastCode = lastConsolidationPackageCode;
}
}
else
{
throw new Exception("生成标签数据异常:" + lastConsolidationPackage.PackageCodeClient);
}
}
if (lastCode > 400)
{
newPatchCode += "_" + (lastCode + 1);
}
else
{
newPatchCode += "_401";
}
description += "\n拼箱结果:" + newPatchCode + " 总数量:" + quantityCount;
DateTime nowTime = DateTime.Now.ToLocalTime();
@@ -181,6 +192,54 @@ namespace ZR.Service.Business
//TODO 20240422开会讨论结果拼箱完需要重新扫码入库原数据删除
Context.Deleteable<WmGoodsNowProduction>().Where(it => it.Id == nowProduction.Id).ExecuteCommand();
Context.Deleteable<WmGoodsNowProduction>().Where(it => it.Id == secondId).ExecuteCommand();
//TODO 20240510添加标签记录信息到标签记录信息表
try
{
Context.Ado.BeginTran();
WmPackageLcl mainPackageLcl = new()
{
Id = SnowFlakeSingle.instance.NextId().ToString(),
Partnumber = nowProduction.Partnumber,
PackageCode = newPatchCode,
SerialNumber = newPatchCode.Split('_')[1],
LocationCode = nowProduction.LocationCode,
GoodsNum = nowProduction.GoodsNumAction ?? 0,
Team = "C",
Type = 1,
Status = 0,
CreatedBy = "拼箱",
CreatedTime = nowTime,
Remark = "拼箱整箱"
};
Context.Insertable(mainPackageLcl).ExecuteCommand();
if (!isDelete)
{
WmPackageLcl oddPackageLcl = new()
{
Id = SnowFlakeSingle.instance.NextId().ToString(),
Partnumber = list[1].PartNumner,
PackageCode = list[1].PatchCode,
SerialNumber = list[1].PatchCode.Split('_')[1],
LocationCode = "LS",
GoodsNum = secondHas ?? 0,
Team = "C",
Type = 1,
Status = 0,
CreatedBy = "拼箱",
CreatedTime = nowTime,
Remark = "拼箱零头箱"
};
Context.Insertable(oddPackageLcl).ExecuteCommand();
}
Context.Ado.CommitTran();
return log;
}
catch (Exception ex)
{
Context.Ado.RollbackTran();
throw new Exception("生成打印标签信息异常!" + ex);
}
return log;
// 修改主箱
Context.Updateable(nowProduction).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
@@ -246,40 +305,46 @@ namespace ZR.Service.Business
.OrderBy(it => it.PackingCode, OrderByType.Desc)
.First();
int lastCode = 400;
if (lastConsolidationPackage == null && lastPackingrecord == null)
// 优先处理箱打印有历史数据情况
if (lastPackingrecord != null)
{
newPatchCode1 += "_401";
newPatchCode2 += "_402";
}
else
{
int lastPackingrecordCode = 0;
// 优先处理箱打印有历史数据情况
if (lastPackingrecord != null)
int subIndex = lastPackingrecord.PackingCode.Length - 5;
// XXX 此代码中 AsSpan 方法 .NET Framework 4.7.2 不支持需要更高版本 或替换为 Substring
if (int.TryParse(lastPackingrecord.PackingCode.AsSpan(subIndex).TrimStart('0'), out int lastPackingrecordCode))
{
int subIndex = lastPackingrecord.PackingCode.Length - 5;
// XXX 此代码中 AsSpan 方法 .NET Framework 4.7.2 不支持需要更高版本 或替换为 Substring
if (int.TryParse(lastPackingrecord.PackingCode.AsSpan(subIndex).TrimStart('0'), out lastPackingrecordCode))
{
}
}
if (int.TryParse(lastConsolidationPackage.PackageCodeClient.Split('_')[1], out lastCode))
{
if(lastPackingrecordCode > lastCode)
if (lastPackingrecordCode > lastCode)
{
lastCode = lastPackingrecordCode;
}
if (lastCode > 400)
}
else
{
throw new Exception("生成标签数据异常:" + lastPackingrecord.PackingCode);
}
}
if(lastConsolidationPackage != null )
{
if (int.TryParse(lastConsolidationPackage.PackageCodeClient.Split('_')[1], out int lastConsolidationPackageCode))
{
if (lastConsolidationPackageCode > lastCode)
{
newPatchCode1 += "_" + (lastCode + 1);
newPatchCode2 += "_" + (lastCode + 2);
}
else
{
newPatchCode1 += "_401";
newPatchCode2 += "_402";
lastCode = lastConsolidationPackageCode;
}
}
else
{
throw new Exception("生成标签数据异常:" + lastConsolidationPackage.PackageCodeClient);
}
}
if (lastCode > 400)
{
newPatchCode1 += "_" + (lastCode + 1);
newPatchCode2 += "_" + (lastCode + 2);
}
else
{
newPatchCode1 += "_401";
newPatchCode2 += "_402";
}
int firstNum = parm.firstNum;
@@ -326,6 +391,50 @@ namespace ZR.Service.Business
Context.Insertable(log).ExecuteReturnEntity();
//TODO 20240422开会讨论结果拆箱完需要重新扫码入库原主箱数据删除
Context.Deleteable<WmGoodsNowProduction>().Where(it => it.Id == mainNowProduction.Id).ExecuteCommand();
//TODO 20240510 添加待打印的记录
try
{
Context.Ado.BeginTran();
WmPackageLcl packageLcl1 = new()
{
Id = SnowFlakeSingle.instance.NextId().ToString(),
Partnumber = mainNowProduction.Partnumber,
PackageCode = jsonObject.newPatchCode1,
SerialNumber = jsonObject.serialNumber1,
LocationCode = mainNowProduction.LocationCode,
GoodsNum = jsonObject.firstNum,
Team = "C",
Type = 2,
Status = 0,
CreatedBy = "拆箱",
CreatedTime = nowTime,
Remark = "拆箱1"
};
Context.Insertable(packageLcl1).ExecuteCommand();
WmPackageLcl packageLcl2 = new()
{
Id = SnowFlakeSingle.instance.NextId().ToString(),
Partnumber = mainNowProduction.Partnumber,
PackageCode = jsonObject.newPatchCode2,
SerialNumber = jsonObject.serialNumber2,
LocationCode = "LS",
GoodsNum = jsonObject.secondNum ?? 0,
Team = "C",
Type = 2,
Status = 0,
CreatedBy = "拆箱",
CreatedTime = nowTime,
Remark = "拆箱2"
};
Context.Insertable(packageLcl2).ExecuteCommand();
Context.Ado.CommitTran();
return log;
}
catch (Exception ex)
{
Context.Ado.RollbackTran();
throw new Exception("生成打印标签信息异常!" + ex);
}
return log;
// 执行修改
// 1.主箱修改为1号分箱参数

View File

@@ -36,6 +36,7 @@ namespace ZR.Service.mes.wms
var response = Queryable()
.Where(predicate.ToExpression())
.OrderByDescending(x=>x.EntryWarehouseTime)
.ToPage<WmGoodsNowProduction, WmGoodsNowProductionDto>(parm);
foreach (WmGoodsNowProductionDto item in response.Result)

View File

@@ -53,6 +53,7 @@ namespace ZR.Service.mes.wms
;
var response = Queryable()
.Where(predicate.ToExpression())
.OrderByDescending(it=>it.CreatedTime)
.ToPage<WmOutOrder, WmOutOrderDto>(parm);
return response;

View File

@@ -0,0 +1,114 @@
using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using ZR.Model;
using ZR.Model.Dto;
using ZR.Model.MES.wms;
using ZR.Repository;
using ZR.Service.Business.IBusinessService;
using System.Linq;
using ZR.Service.mes.wms.IService;
using ZR.Model.MES.wms.Dto;
using System.Collections.Generic;
namespace ZR.Service.mes.wms
{
/// <summary>
/// 拼箱/拆箱待打标签记录表Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IWmPackageLclService), ServiceLifetime = LifeTime.Transient)]
public class WmPackageLclService : BaseService<WmPackageLcl>, IWmPackageLclService
{
/// <summary>
/// 查询拼箱/拆箱待打标签记录表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<WmPackageLclDto> GetList(WmPackageLclQueryDto parm)
{
var predicate = Expressionable.Create<WmPackageLcl>()
.AndIF(!string.IsNullOrEmpty(parm.Partnumber), it => it.Partnumber.Contains(parm.Partnumber))
.AndIF(!string.IsNullOrEmpty(parm.LocationCode), it => it.Partnumber.Contains(parm.LocationCode))
.AndIF(!string.IsNullOrEmpty(parm.PackageCode), it => it.Partnumber.Contains(parm.PackageCode))
.AndIF(parm.Status > -1, it => it.Status == parm.Status)
.AndIF(parm.Type > 0, it => it.Type == parm.Type)
;
var response = Queryable()
.Where(predicate.ToExpression())
.OrderByDescending(it => it.CreatedTime)
.ToPage<WmPackageLcl, WmPackageLclDto>(parm);
if( response.Result.Count > 0)
{
foreach (WmPackageLclDto item in response.Result)
{
WmMaterial material = Context.Queryable<WmMaterial>()
.Where(it => it.Partnumber == item.Partnumber)
.First();
if (material == null)
{
item.Description = "此零件号不在物料清单内!";
continue;
}
item.Description = !string.IsNullOrEmpty(material.Description) ? material.Description : material.ProductName;
}
}
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public WmPackageLcl GetInfo(string Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加拼箱/拆箱待打标签记录表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public WmPackageLcl AddWmPackageLcl(WmPackageLcl model)
{
model.Id = SnowFlakeSingle.Instance.NextId().ToString();
model.Remark = "手动添加";
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改拼箱/拆箱待打标签记录表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateWmPackageLcl(WmPackageLcl model)
{
//var response = Update(w => w.Id == model.Id, it => new WmPackageLcl()
//{
// Partnumber = model.Partnumber,
// PackageCode = model.PackageCode,
// SerialNumber = model.SerialNumber,
// LocationCode = model.LocationCode,
// GoodsNum = model.GoodsNum,
// Team = model.Team,
// Status = model.Status,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
//});
//return response;
model.Remark = "手动修改";
return Update(model, true);
}
}
}