入库功能
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using ZR.Model.MES.qc.DTO;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
using static Org.BouncyCastle.Crypto.Engines.SM2Engine;
|
||||
|
||||
namespace ZR.Service.mes.wms.IService
|
||||
{
|
||||
@@ -29,6 +30,11 @@ namespace ZR.Service.mes.wms.IService
|
||||
//获取库位已经存在的货物
|
||||
public List<WmGoodsNowProduction> Getpackagelist(string location);
|
||||
|
||||
//解析外箱标签码
|
||||
public ResultionPackageCodeDto ResolutionPackage(string code);
|
||||
|
||||
public bool IsExistedWarehouse(string originalCode);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Aliyun.OSS;
|
||||
using Infrastructure.Attribute;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Model.DBModel;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -13,28 +15,48 @@ using ZR.Model.MES.wms;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
using ZR.Service.mes.qc.IService;
|
||||
using ZR.Service.mes.wms.IService;
|
||||
using static Org.BouncyCastle.Crypto.Engines.SM2Engine;
|
||||
|
||||
namespace ZR.Service.mes.wms
|
||||
{
|
||||
[AppService(ServiceType = typeof(IWMentryWarehousing_productService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class WMentryWarehousing_productService : BaseService<WmInfo>, IWMentryWarehousing_productService
|
||||
{
|
||||
|
||||
private NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
//货物入库
|
||||
public int IntoProductwarehouse(WmgoodsDto wmgoods, string createName)
|
||||
{
|
||||
List<WmGoodsNowProduction> preparegoodsList = new List<WmGoodsNowProduction>();
|
||||
|
||||
|
||||
|
||||
if (wmgoods.packagelist != null && wmgoods.packagelist.Count() > 0)
|
||||
{
|
||||
for (int i = 0; i < wmgoods.packagelist.Count(); i++)
|
||||
{
|
||||
|
||||
ResultionPackageCodeDto resultionPackage= ResolutionPackagecode(wmgoods.packagelist[i]);
|
||||
WmGoodsNowProduction wmGood = new WmGoodsNowProduction();
|
||||
wmGood.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
||||
|
||||
string flow = resultionPackage.PatchCode.Split('_')[1];
|
||||
int flow_num = 0;
|
||||
try
|
||||
{
|
||||
flow_num = Convert.ToInt32(flow);
|
||||
}catch(Exception ex)
|
||||
{
|
||||
flow_num = -1;
|
||||
}
|
||||
|
||||
wmGood.PackageCode = Getpack_no(resultionPackage.WorkoderID, flow_num.ToString("000"));
|
||||
wmGood.PackageCodeClient = resultionPackage.PatchCode;
|
||||
wmGood.PackageCodeOriginal = resultionPackage.originalCode;
|
||||
|
||||
wmGood.PackageCode = Getpack_no(wmgoods.packagelist[i]);
|
||||
wmGood.LocationCode = wmgoods.location;
|
||||
|
||||
string workorder_id = wmgoods.packagelist[i].Substring(3, 9);
|
||||
string workorder_id = resultionPackage.WorkoderID;
|
||||
|
||||
|
||||
wmGood.GoodsNumLogic = Context.Queryable<WmPackingrecord>()
|
||||
@@ -57,84 +79,21 @@ namespace ZR.Service.mes.wms
|
||||
return result;
|
||||
}
|
||||
|
||||
//判断箱子是否满
|
||||
public bool isFullPackage(string production_packcode)
|
||||
{
|
||||
string workorder_id = production_packcode.Substring(3, 9);
|
||||
string flow_id = production_packcode.Substring(13, 3);
|
||||
bool isExist = Context.Queryable<WmPackingrecord>()
|
||||
.Where(it => it.WorkOrderNum == workorder_id)
|
||||
.Where(it => it.PackingCode.EndsWith(flow_id))
|
||||
.Where(it => it.BFilled == true).Any();
|
||||
return isExist;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否为成品箱子码
|
||||
/// 获取mes的箱子码
|
||||
/// </summary>
|
||||
/// <param name="production_packcode"></param>
|
||||
/// <param name="workordorid">工单</param>
|
||||
/// <param name="flow">序号</param>
|
||||
/// <returns></returns>
|
||||
public int isProductionPackage(string production_packcode)
|
||||
{
|
||||
Regex r = new Regex("CodeBNW\\d{9}_\\d{0,3}");
|
||||
Regex r1 = new Regex("Code=BNW\\d{9}_\\d{0,3}");
|
||||
|
||||
|
||||
//todo 不是箱子
|
||||
if (!r.IsMatch(production_packcode)& !r1.IsMatch(production_packcode))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
// 匹配 CodeBNW\\d{9}_\\d{0,3}
|
||||
|
||||
if (r.IsMatch(production_packcode))
|
||||
{
|
||||
//string workorder_id = production_packcode.Substring(3, 9);
|
||||
//string flow_id = production_packcode.Substring(13, 3).ToString("000");
|
||||
|
||||
}
|
||||
|
||||
if (r1.IsMatch(production_packcode))
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
string workorder_id = production_packcode.Substring(3, 9);
|
||||
string flow_id = production_packcode.Substring(13, 3);
|
||||
bool isExist = Context.Queryable<WmPackingrecord>()
|
||||
.Where(it => it.WorkOrderNum == workorder_id)
|
||||
.Where(it => it.PackingCode.EndsWith(flow_id))
|
||||
.Any();
|
||||
if (!isExist)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
bool IWMentryWarehousing_productService.IsProductionLoacation(string production_location_code)
|
||||
private string Getpack_no(string workordorid, string flow)
|
||||
{
|
||||
|
||||
return Context.Queryable<WmInfo>().Where(it => it.WarehouseNum == 1)
|
||||
.Where(it => it.Location.Equals(production_location_code)).Any();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取箱子唯一识别号
|
||||
/// </summary>
|
||||
/// <param name="production_packcode"></param>
|
||||
/// <returns></returns>
|
||||
private string Getpack_no(string production_packcode)
|
||||
{
|
||||
string workorder_id = production_packcode.Substring(3, 9);
|
||||
string flow_id = production_packcode.Substring(13, 3);
|
||||
|
||||
WmPackingrecord record = Context.Queryable<WmPackingrecord>()
|
||||
.Where(it => it.WorkOrderNum == workorder_id)
|
||||
.Where(it => it.PackingCode.EndsWith(flow_id))
|
||||
.Where(it => it.WorkOrderNum == workordorid)
|
||||
.Where(it => it.PackingCode.EndsWith(flow))
|
||||
.First();
|
||||
|
||||
|
||||
@@ -146,11 +105,162 @@ namespace ZR.Service.mes.wms
|
||||
return record.ProductCode;
|
||||
}
|
||||
|
||||
//3 判断箱子是否满
|
||||
public bool isFullPackage(string production_packcode)
|
||||
{
|
||||
ResultionPackageCodeDto Identity = ResolutionPackagecode(production_packcode);
|
||||
if (Identity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string packingCode = Identity.PatchCode.Split('_')[1];
|
||||
|
||||
|
||||
bool isExist = Context.Queryable<WmPackingrecord>()
|
||||
.Where(it => it.WorkOrderNum == Identity.WorkoderID)
|
||||
.Where(it => it.PackingCode.EndsWith(packingCode))
|
||||
.Where(it => it.BFilled == true)
|
||||
.Any();
|
||||
|
||||
|
||||
|
||||
return isExist;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 2 判断是否为成品箱子码
|
||||
/// </summary>
|
||||
/// <param name="production_packcode"></param>
|
||||
/// <returns></returns>
|
||||
public int isProductionPackage(string production_packcode)
|
||||
{
|
||||
|
||||
|
||||
Regex r = new Regex("Code=BNW\\d{9}_\\d{0,3}");
|
||||
|
||||
|
||||
//todo 不是箱子
|
||||
if (!r.IsMatch(production_packcode))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
ResultionPackageCodeDto Identity = ResolutionPackagecode(production_packcode);
|
||||
if (Identity == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
string packingCode = Identity.PatchCode.Split('_')[1];
|
||||
|
||||
|
||||
|
||||
|
||||
bool isExist = Context.Queryable<WmPackingrecord>()
|
||||
.Where(it => it.WorkOrderNum == Identity.WorkoderID)
|
||||
.Where(it => it.PackingCode.EndsWith(packingCode))
|
||||
.Any();
|
||||
if (!isExist)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
//1 判断是否为库位码
|
||||
bool IWMentryWarehousing_productService.IsProductionLoacation(string production_location_code)
|
||||
{
|
||||
|
||||
return Context.Queryable<WmInfo>().Where(it => it.WarehouseNum == 1)
|
||||
.Where(it => it.Location.Equals(production_location_code)).Any();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//获取库位已经存在的货物
|
||||
public List<WmGoodsNowProduction> Getpackagelist(string location)
|
||||
{
|
||||
return Context.Queryable<WmGoodsNowProduction>().Where(it=>it.LocationCode==location).ToList();
|
||||
return Context.Queryable<WmGoodsNowProduction>().Where(it => it.LocationCode == location).ToList();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析外箱标签码
|
||||
/// </summary>
|
||||
/// <param name="packagecode"></param>
|
||||
/// <returns></returns>
|
||||
private ResultionPackageCodeDto ResolutionPackagecode(string packagecode)
|
||||
{
|
||||
ResultionPackageCodeDto resultionPackageCode = new ResultionPackageCodeDto();
|
||||
try
|
||||
{
|
||||
resultionPackageCode.originalCode= packagecode;
|
||||
|
||||
// todo 解析外箱标签码
|
||||
string[] splitstr = packagecode.Split('^');
|
||||
resultionPackageCode.PatchCode = splitstr[0].Substring(5);
|
||||
|
||||
//todo 解析零件号
|
||||
string partnumber = splitstr[1].Substring(11);
|
||||
//int length = lingshi.Length - 2;
|
||||
//string partnumber = lingshi.Substring(0, length);
|
||||
resultionPackageCode.PartNumner = partnumber;
|
||||
//todo 解析工单号
|
||||
string workoderidid = splitstr[2].Substring(7);
|
||||
resultionPackageCode.WorkoderID = workoderidid;
|
||||
//todo 生产描述
|
||||
resultionPackageCode.ProductionTime="20"+ workoderidid.Substring(0,6);
|
||||
//todo 解析箱子中产品数量
|
||||
string product_num = splitstr[3].Substring(4);
|
||||
resultionPackageCode.Quantity = product_num;
|
||||
//todo 产品描述 partnumber
|
||||
ProWorklplan_v2 plan= Context.Queryable<ProWorklplan_v2>().Where(it => it.Partnumber == partnumber).First();
|
||||
if(plan != null)
|
||||
{
|
||||
resultionPackageCode.ProductionDescribe = plan.ProductName;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultionPackageCode.ProductionDescribe = "生产计划无此零件号";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error($"外箱标签码,解析失败 {ex.Message}");
|
||||
|
||||
}
|
||||
|
||||
return resultionPackageCode;
|
||||
}
|
||||
|
||||
//解析外箱标签码
|
||||
public ResultionPackageCodeDto ResolutionPackage(string code)
|
||||
{
|
||||
|
||||
|
||||
return ResolutionPackagecode(code);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断箱子是否在成品库中
|
||||
/// </summary>
|
||||
/// <param name="PatchCode"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public bool IsExistedWarehouse(string originalCode)
|
||||
{
|
||||
ResultionPackageCodeDto resultionPackage= ResolutionPackagecode(originalCode);
|
||||
|
||||
return Context.Queryable<WmGoodsNowProduction>().Where(it => it.PackageCodeClient == resultionPackage.PatchCode).Any();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user