仓库-优化入库出库接口,添加trycatch判断

This commit is contained in:
赵正易
2024-03-28 12:29:39 +08:00
parent 8e279bdd8a
commit d78f810f42
2 changed files with 94 additions and 69 deletions

View File

@@ -227,60 +227,68 @@ namespace ZR.Service.mes.wms
// 检查是否可入库(ok 可入库,其余返回情况)
public string checkWarehousing(string production_packcode, string location, bool isStrict)
{
if (string.IsNullOrEmpty(production_packcode))
try
{
return "扫描结果为空!";
}
// 1.判断能否解析
ResultionPackageCodeDto resultionPackage = ResolutionPackage(production_packcode);
if (resultionPackage == null)
{
return "标签解析异常!";
}
// 2.判断是否已入库
bool isExistedWarehouse = Context.Queryable<WmGoodsNowProduction>().Where(it => it.PackageCodeClient == resultionPackage.PatchCode).Any();
if (isExistedWarehouse)
{
return "该箱号已入库!";
}
// 提取库位信息
WmInfo wmInfo = Context.Queryable<WmInfo>().Where(it => it.Location == location).First();
if (wmInfo == null)
{
return "库位参数异常";
}
if (isStrict && wmInfo.Remark != "临时")
{
// 3.isStrict = TRUE时判断是否是满箱标签
string packingCode = resultionPackage.PatchCode.Split('_')[1];
bool isExist = Context.Queryable<WmPackingrecord>()
.Where(it => it.WorkOrderNum == resultionPackage.WorkoderID)
.Where(it => it.PackingCode.EndsWith(packingCode))
.Where(it => it.BFilled == true)
.Any();
if (!isExist)
if (string.IsNullOrEmpty(production_packcode))
{
return "该标签不为满箱标签!请入临时仓库";
return "扫描结果为空";
}
// 4.isStrict = TRUE时判断能否追溯
string flow = resultionPackage.PatchCode.Split('_')[1];
int flow_num = 0;
try
// 1.判断能否解析
ResultionPackageCodeDto resultionPackage = ResolutionPackage(production_packcode);
if (resultionPackage == null)
{
flow_num = Convert.ToInt32(flow);
return "标签解析异常!";
}
catch (Exception ex)
// 2.判断是否已入库
bool isExistedWarehouse = Context.Queryable<WmGoodsNowProduction>().Where(it => it.PackageCodeClient == resultionPackage.PatchCode).Any();
if (isExistedWarehouse)
{
flow_num = -1;
return "该箱号已入库!";
}
//mes追溯码
string PackageCode = Getpack_no(resultionPackage.WorkoderID, flow_num.ToString("000"));
if (PackageCode == null)
// 提取库位信息
WmInfo wmInfo = Context.Queryable<WmInfo>().Where(it => it.Location == location).First();
if (wmInfo == null)
{
return "该标签不可追溯!请入临时仓库!";
return "库位参数异常";
}
if (isStrict && wmInfo.Remark != "临时")
{
// 3.isStrict = TRUE时判断是否是满箱标签
string packingCode = resultionPackage.PatchCode.Split('_')[1];
bool isExist = Context.Queryable<WmPackingrecord>()
.Where(it => it.WorkOrderNum == resultionPackage.WorkoderID)
.Where(it => it.PackingCode.EndsWith(packingCode))
.Where(it => it.BFilled == true)
.Any();
if (!isExist)
{
return "该标签不为满箱标签!请入临时仓库!";
}
// 4.isStrict = TRUE时判断能否追溯
string flow = resultionPackage.PatchCode.Split('_')[1];
int flow_num = 0;
try
{
flow_num = Convert.ToInt32(flow);
}
catch (Exception ex)
{
flow_num = -1;
}
//mes追溯码
string PackageCode = Getpack_no(resultionPackage.WorkoderID, flow_num.ToString("000"));
if (PackageCode == null)
{
return "该标签不可追溯!请入临时仓库!";
}
}
return "ok";
}
return "ok";
catch(Exception e)
{
return "标签存在异常!";
}
}
/// <summary>

View File

@@ -475,35 +475,52 @@ namespace ZR.Service.mes.wms
/// <returns></returns>
public string CheckProductionOut(string production_packcode, string shipment_num)
{
if (shipment_num == "" || production_packcode == "")
try
{
return "传入数据为空!请检查参数";
}
MaterialUtils materialToos = new MaterialUtils();
// 1.解析标签编码
ResultionPackageCodeDto resultionPackage = materialToos.ResolutionPackage(production_packcode);
if (resultionPackage == null)
{
return "标签解析异常!请检查标签";
}
// 2.判断是否已入库
bool isExistedWarehouse = Context.Queryable<WmGoodsNowProduction>().Where(it => it.PackageCodeClient == resultionPackage.PatchCode).Any();
if (!isExistedWarehouse)
{
return "该箱号未入库!请先入库";
}
// 3.获取出库单号对应的出库计划
List<WmOutOrderPlan> orderPlans = Generate_outorderplan(shipment_num);
// 4.配对是否符合出库条件
foreach(var orderPlan in orderPlans)
{
// 存在匹配条件: 箱标签批次号包含计划短批次号
if(orderPlan != null && resultionPackage.PatchCode.Contains(orderPlan.Patchcode_short) )
if (shipment_num == "" || production_packcode == "")
{
return "ok";
return "传入数据为空!请检查参数";
}
// 1.判断工单是否处于已完成状态
bool isOutOrderCanUse = Context.Queryable<WmOutOrder>().Where(it => it.ShipmentNum == shipment_num).Where(it => it.Type == 1).Any();
if (!isOutOrderCanUse)
{
return "出库单已完成或已弃用!请检查出库单";
}
MaterialUtils materialToos = new MaterialUtils();
// 2.解析标签编码
ResultionPackageCodeDto resultionPackage = materialToos.ResolutionPackage(production_packcode);
if (resultionPackage == null)
{
return "标签解析异常!请检查标签";
}
// 3.判断是否已入库
bool isExistedWarehouse = Context.Queryable<WmGoodsNowProduction>().Where(it => it.PackageCodeClient == resultionPackage.PatchCode).Any();
if (!isExistedWarehouse)
{
return "该箱号未入库!请先入库";
}
// 4.获取出库单号对应的出库计划
List<WmOutOrderPlan> orderPlans = Generate_outorderplan(shipment_num);
// 5.配对是否符合出库条件
foreach (var orderPlan in orderPlans)
{
// 存在匹配条件: 箱标签批次号包含计划短批次号
if (orderPlan != null && resultionPackage.PatchCode.Contains(orderPlan.Patchcode_short))
{
return "ok";
}
}
return "此箱标签不可出库,批次号不在出库单计划内!请检查出库单计划!";
}
return "此箱标签不可出库,批次号不在出库单计划内!请检查出库单计划!";
catch (Exception ex)
{
return "此箱标签存在异常不可出库!";
}
}
}
}