From 2099805a6b7190ddfbdedbea7ca0aaccdfa458ca Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Fri, 15 Mar 2024 17:55:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WMentryWarehousing_productController.cs | 85 +++++- ZR.Admin.WebApi/ZR.Admin.WebApi.csproj | 2 - ZR.Admin.WebApi/appsettings.development.json | 7 +- ZR.Admin.WebApi/appsettings.production.json | 2 +- ZR.Common/ZR.Common.csproj | 2 + .../MES/wms/Dto/ResultionPackageCodeDto.cs | 46 ++++ ZR.Model/MES/wms/Dto/WmgoodsDto.cs | 2 +- ZR.Model/MES/wms/WmGoodsNowProduction.cs | 15 +- .../mes/wms/IService/IWMWarehousingService.cs | 6 + .../wms/WMentryWarehousing_productService.cs | 258 +++++++++++++----- ZR.Tasks/ZR.Tasks.csproj | 1 - 11 files changed, 331 insertions(+), 95 deletions(-) create mode 100644 ZR.Model/MES/wms/Dto/ResultionPackageCodeDto.cs diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs index d294c392..6047f6ea 100644 --- a/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs @@ -31,9 +31,10 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms /// /// [HttpGet("is_production_location")] + [Log(Title = "判断是否为库位码")] public IActionResult IsProductionLocation(string production_location_code = "") { - if(string.IsNullOrEmpty(production_location_code)) + if (string.IsNullOrEmpty(production_location_code)) { return ToResponse(new ApiResult(200, "传入为空", false)); @@ -49,6 +50,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms /// /// [HttpGet("is_production_package")] + [Log(Title = "判断是否为成品库箱子码")] public IActionResult IsProductionPackage(string package_code = "") { if (string.IsNullOrEmpty(package_code)) @@ -76,6 +78,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms /// /// [HttpGet("is_full_package")] + [Log(Title = "判断是否为满箱")] public IActionResult IsFullPackage(string package_code = "") { @@ -85,9 +88,16 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms } bool state = this.wm_entryWarehousing_productService.isFullPackage(package_code); - string msg = state ? "满箱" : "不满箱"; - - return ToResponse(new ApiResult(200, msg, true)); + string msg = null; + if (state) + { + msg = "满箱"; + }else + { + msg = "零头箱"; + } + + return ToResponse(new ApiResult(200, msg, state)); } /// /// 4.入库 @@ -95,24 +105,25 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms /// /// [HttpPost("into_product_warehouse")] - public IActionResult IntoProductwarehouse([FromBody] WmgoodsDto wmgoodsDto) + [Log(Title = "入库")] + public IActionResult IntoProductwarehouse([FromBody] WmgoodsDto wmgoodsDto) { - if(wmgoodsDto == null) + if (wmgoodsDto == null) { return ToResponse(new ApiResult(200, "传入为空", false)); } string msg = ""; bool data = false; - string createName=HttpContext.GetName(); + string createName = HttpContext.GetName(); - int status=this.wm_entryWarehousing_productService.IntoProductwarehouse(wmgoodsDto, createName); - if(status == 0) + int status = this.wm_entryWarehousing_productService.IntoProductwarehouse(wmgoodsDto, createName); + if (status == 0) { msg = "数据插入异常"; data = false; } - else if(status == 1) + else if (status == 1) { msg = "success"; data = true; @@ -126,18 +137,66 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms /// /// [HttpGet("packagelist")] + [Log(Title = "获取库位已经存在箱子")] public IActionResult Getpackagelist(string locationcode) { - if(string.IsNullOrEmpty(locationcode)) + if (string.IsNullOrEmpty(locationcode)) { return ToResponse(new ApiResult(200, "传入为空", false)); } string msg = null; - List productionList= this.wm_entryWarehousing_productService.Getpackagelist(locationcode); - + List productionList = this.wm_entryWarehousing_productService.Getpackagelist(locationcode); + return ToResponse(new ApiResult(200, msg, productionList)); } + /// + /// 解析外标签码 + /// + /// + /// + [HttpGet("resolution_package")] + public IActionResult ResolutionPackage(string code = "") + { + if (string.IsNullOrEmpty(code)) + { + + return ToResponse(new ApiResult(200, "传入为空", false)); + } + ResultionPackageCodeDto data = this.wm_entryWarehousing_productService.ResolutionPackage(code); + return ToResponse(new ApiResult(200, "success", data)); + + } + /// + /// 7 判断箱子是否存在成品库仓库里 + /// + /// + /// + [HttpGet("is_existed_warehouse")] + public IActionResult IsExistedWarehouse(string originalCode = "") + { + if (string.IsNullOrEmpty(originalCode)) + { + + return ToResponse(new ApiResult(200, "传入为空", false)); + } + string msg = null; + bool data = this.wm_entryWarehousing_productService.IsExistedWarehouse(originalCode); + if (data) + { + msg = "存在"; + + } + else + { + msg = "不存在"; + } + + return ToResponse(new ApiResult(200, msg, data)); + + } + + } } diff --git a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj index 1661fd65..e4f213a0 100644 --- a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj +++ b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj @@ -41,8 +41,6 @@ - - diff --git a/ZR.Admin.WebApi/appsettings.development.json b/ZR.Admin.WebApi/appsettings.development.json index 19cf5430..1be1a9b5 100644 --- a/ZR.Admin.WebApi/appsettings.development.json +++ b/ZR.Admin.WebApi/appsettings.development.json @@ -11,9 +11,12 @@ { //外网连接服务器 - "Conn": "Data Source=47.116.122.230;Port=3307;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", + "Conn": "Data Source=127.0.0.01;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", + + //外网连接服务器 + //"Conn": "Data Source=47.116.122.230;Port=3307;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", //内网连接服务器 - //"Conn": "Data Source=192.168.0.36;Port=3306;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", + //"Conn": "Data Source=192.168.0.36;Port=3306;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", "Type": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4, "ConfigId": "0", //多租户唯一标识 "IsAutoCloseConnection": true diff --git a/ZR.Admin.WebApi/appsettings.production.json b/ZR.Admin.WebApi/appsettings.production.json index d664dd28..569c59e8 100644 --- a/ZR.Admin.WebApi/appsettings.production.json +++ b/ZR.Admin.WebApi/appsettings.production.json @@ -11,7 +11,7 @@ { //"Conn": "Data Source=147.116.122.230;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", //"Conn": "Data Source=47.116.122.230;Port=3307;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", - "Conn": "Data Source=192.168.0.36;Port=3306;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", + "Conn": "Data Source=192.168.60.251;Port=3306;User ID=root;Password=123456;Initial Catalog=ZrAdmin;", "DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4 "ConfigId": "0", //多租户唯一标识 "IsAutoCloseConnection": true diff --git a/ZR.Common/ZR.Common.csproj b/ZR.Common/ZR.Common.csproj index 942ceb01..b890470b 100644 --- a/ZR.Common/ZR.Common.csproj +++ b/ZR.Common/ZR.Common.csproj @@ -11,6 +11,8 @@ + + diff --git a/ZR.Model/MES/wms/Dto/ResultionPackageCodeDto.cs b/ZR.Model/MES/wms/Dto/ResultionPackageCodeDto.cs new file mode 100644 index 00000000..a59d0d8a --- /dev/null +++ b/ZR.Model/MES/wms/Dto/ResultionPackageCodeDto.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZR.Model.MES.wms.Dto +{ + public class ResultionPackageCodeDto + { + /// + /// 原始码 + /// + public string originalCode { get; set; } + /// + /// 批次号 + /// + public string PatchCode { get; set; } + /// + /// 零件号 + /// + public string PartNumner { get; set; } + + /// + /// 工单号 + /// + public string WorkoderID { get; set; } + /// + /// 数量 + /// + public string Quantity { get; set; } + + /// + /// 生产时间 + /// + public string ProductionTime { get; set; } + + /// + /// 产品描述 + /// + public string ProductionDescribe { get; set; } + + + + } +} diff --git a/ZR.Model/MES/wms/Dto/WmgoodsDto.cs b/ZR.Model/MES/wms/Dto/WmgoodsDto.cs index 1d46812d..33eabfab 100644 --- a/ZR.Model/MES/wms/Dto/WmgoodsDto.cs +++ b/ZR.Model/MES/wms/Dto/WmgoodsDto.cs @@ -16,7 +16,7 @@ namespace ZR.Model.MES.wms.Dto /// public string location { set; get; } /// - /// 箱子列表 + /// 箱子列表(原始外箱标签码) /// public string[] packagelist { set; get; } } diff --git a/ZR.Model/MES/wms/WmGoodsNowProduction.cs b/ZR.Model/MES/wms/WmGoodsNowProduction.cs index 39421fcc..5d0d7d0f 100644 --- a/ZR.Model/MES/wms/WmGoodsNowProduction.cs +++ b/ZR.Model/MES/wms/WmGoodsNowProduction.cs @@ -16,10 +16,23 @@ namespace ZR.Model.MES.wms [SugarColumn(ColumnName = "id", IsPrimaryKey = true)] public string Id { get; set; } /// - /// 箱子编号 + /// 箱子编号 (MES) /// [SugarColumn(ColumnName = "package_code")] public string PackageCode { get; set; } + /// + /// 箱子编号 (批次号) + /// + [SugarColumn(ColumnName = "package_code_client")] + public string PackageCodeClient { get; set; } + + /// + /// 箱子编号 (批次号) + /// + [SugarColumn(ColumnName = "package_code_original")] + public string PackageCodeOriginal { get; set; } + + /// /// 库位编号 /// diff --git a/ZR.Service/mes/wms/IService/IWMWarehousingService.cs b/ZR.Service/mes/wms/IService/IWMWarehousingService.cs index 62584d02..6f24bdb6 100644 --- a/ZR.Service/mes/wms/IService/IWMWarehousingService.cs +++ b/ZR.Service/mes/wms/IService/IWMWarehousingService.cs @@ -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 Getpackagelist(string location); + //解析外箱标签码 + public ResultionPackageCodeDto ResolutionPackage(string code); + + public bool IsExistedWarehouse(string originalCode); + } diff --git a/ZR.Service/mes/wms/WMentryWarehousing_productService.cs b/ZR.Service/mes/wms/WMentryWarehousing_productService.cs index dd9482fb..05cf9ef9 100644 --- a/ZR.Service/mes/wms/WMentryWarehousing_productService.cs +++ b/ZR.Service/mes/wms/WMentryWarehousing_productService.cs @@ -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, IWMentryWarehousing_productService { + + private NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); //货物入库 public int IntoProductwarehouse(WmgoodsDto wmgoods, string createName) { List preparegoodsList = new List(); + + + 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() @@ -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() - .Where(it => it.WorkOrderNum == workorder_id) - .Where(it => it.PackingCode.EndsWith(flow_id)) - .Where(it => it.BFilled == true).Any(); - return isExist; - } + /// - /// 判断是否为成品箱子码 + /// 获取mes的箱子码 /// - /// + /// 工单 + /// 序号 /// - 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() - .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().Where(it => it.WarehouseNum == 1) - .Where(it => it.Location.Equals(production_location_code)).Any(); - - } - /// - /// 获取箱子唯一识别号 - /// - /// - /// - 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() - .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() + .Where(it => it.WorkOrderNum == Identity.WorkoderID) + .Where(it => it.PackingCode.EndsWith(packingCode)) + .Where(it => it.BFilled == true) + .Any(); + + + + return isExist; + } + + /// + /// 2 判断是否为成品箱子码 + /// + /// + /// + 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() + .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().Where(it => it.WarehouseNum == 1) + .Where(it => it.Location.Equals(production_location_code)).Any(); + + } + + //获取库位已经存在的货物 public List Getpackagelist(string location) { - return Context.Queryable().Where(it=>it.LocationCode==location).ToList(); + return Context.Queryable().Where(it => it.LocationCode == location).ToList(); } + + /// + /// 解析外箱标签码 + /// + /// + /// + 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().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); + } + + + /// + /// 判断箱子是否在成品库中 + /// + /// + /// + /// + public bool IsExistedWarehouse(string originalCode) + { + ResultionPackageCodeDto resultionPackage= ResolutionPackagecode(originalCode); + + return Context.Queryable().Where(it => it.PackageCodeClient == resultionPackage.PatchCode).Any(); + } } } diff --git a/ZR.Tasks/ZR.Tasks.csproj b/ZR.Tasks/ZR.Tasks.csproj index 92526344..19106ef8 100644 --- a/ZR.Tasks/ZR.Tasks.csproj +++ b/ZR.Tasks/ZR.Tasks.csproj @@ -6,7 +6,6 @@ -