diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs index 7aeaff95..36b66fe6 100644 --- a/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs @@ -1,15 +1,8 @@ -using Infrastructure.Extensions; -using JinianNet.JNTemplate; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.IdentityModel.Tokens; +using Microsoft.AspNetCore.Mvc; using ZR.Admin.WebApi.Extensions; -using ZR.Model.Dto; -using ZR.Model.MES.qu; using ZR.Model.MES.wms; using ZR.Model.MES.wms.Dto; using ZR.Service.mes.wms.IService; -using static System.Runtime.InteropServices.JavaScript.JSType; namespace ZR.Admin.WebApi.Controllers.mes.wms { @@ -26,6 +19,8 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms this.wm_entryWarehousing_productService = wm_entryWarehousing_productService; } + + /// /// 1. 判断是否为库位码 /// @@ -92,7 +87,8 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms if (state) { msg = "满箱"; - }else + } + else { msg = "零头箱"; } @@ -113,20 +109,20 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms return ToResponse(new ApiResult(200, "传入为空", false)); } string msg = ""; - + string createName = HttpContext.GetName(); int num = this.wm_entryWarehousing_productService.IntoProductwarehouse(wmgoodsDto, createName); if (num == 0) { msg = "数据插入异常"; - + } else if (num >= 1) { - msg = "成功入库"+num+"个"; - + msg = "成功入库" + num + "个"; + } return ToResponse(new ApiResult(200, msg, num)); @@ -164,6 +160,10 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms return ToResponse(new ApiResult(200, "传入为空", false)); } ResultionPackageCodeDto data = this.wm_entryWarehousing_productService.ResolutionPackage(code); + if (data == null) + { + return ToResponse(new ApiResult(500, "外标签解析异常", data)); + } return ToResponse(new ApiResult(200, "success", data)); } @@ -191,12 +191,33 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms { msg = "不存在"; } - + return ToResponse(new ApiResult(200, msg, data)); } + /// + /// all.判断标签扫描结果是否可入库(综合结果判断) + /// + /// + [HttpGet("checkWarehousing")] + [Log(Title = "判断标签扫描结果是否可入库")] + public IActionResult CheckWarehousing(string production_packcode = "", string location = "", + bool isStrict = false) + { + string msg = this.wm_entryWarehousing_productService.checkWarehousing(production_packcode, location, isStrict); + if ("ok".Equals(msg)) + { + // 可入库 + return ToResponse(new ApiResult(200, msg, true)); + } + else + { + // 不可入库 + return ToResponse(new ApiResult(200, msg, false)); + } + } } } diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WmMaterialController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WmMaterialController.cs index fddfb89f..5f9e3545 100644 --- a/ZR.Admin.WebApi/Controllers/mes/wms/WmMaterialController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WmMaterialController.cs @@ -1,12 +1,9 @@ using Microsoft.AspNetCore.Mvc; -using ZR.Model.Dto; - using ZR.Admin.WebApi.Extensions; using ZR.Admin.WebApi.Filters; -using ZR.Service.mes.wms.IService; -using ZR.Model.MES.wms.Dto; using ZR.Model.MES.wms; -using Org.BouncyCastle.Crypto; +using ZR.Model.MES.wms.Dto; +using ZR.Service.mes.wms.IService; //创建时间:2024-03-16 namespace ZR.Admin.WebApi.Controllers @@ -52,8 +49,8 @@ namespace ZR.Admin.WebApi.Controllers public IActionResult GetWmMaterial(string Id) { var response = _WmMaterialService.GetInfo(Id); - - + + return SUCCESS(response); } @@ -115,7 +112,7 @@ namespace ZR.Admin.WebApi.Controllers { return SUCCESS(null); } - WmGoodsNowProduction nowProduction= _WmMaterialService.GetInfoByPatchCode(patchCode); + WmGoodsNowProduction nowProduction = _WmMaterialService.GetInfoByPatchCode(patchCode); return SUCCESS(nowProduction); } diff --git a/ZR.Model/MES/wms/Dto/ResultionPackageCodeDto.cs b/ZR.Model/MES/wms/Dto/ResultionPackageCodeDto.cs index fc2658de..b454d0e0 100644 --- a/ZR.Model/MES/wms/Dto/ResultionPackageCodeDto.cs +++ b/ZR.Model/MES/wms/Dto/ResultionPackageCodeDto.cs @@ -1,21 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ZR.Model.MES.wms.Dto +namespace ZR.Model.MES.wms.Dto { public class ResultionPackageCodeDto { /// /// 原始码 /// - public string originalCode { get; set; } + public string originalCode { get; set; } /// - /// 批次号(工单号+箱子号) + /// 批次号(工单号+箱子号+班组) /// - public string PatchCode { get; set; } + public string PatchCode { get; set; } + + /// + /// 班组 + /// + public string Team { get; set; } /// /// 零件号 /// @@ -33,12 +32,12 @@ namespace ZR.Model.MES.wms.Dto /// /// 生产时间 /// - public string ProductionTime { get; set; } + public string ProductionTime { get; set; } /// /// 产品描述 /// - public string ProductionDescribe { get; set; } + public string ProductionDescribe { get; set; } diff --git a/ZR.Service/mes/wms/IService/IWMentryWarehousing_productService.cs b/ZR.Service/mes/wms/IService/IWMentryWarehousing_productService.cs index 6f24bdb6..85dc309d 100644 --- a/ZR.Service/mes/wms/IService/IWMentryWarehousing_productService.cs +++ b/ZR.Service/mes/wms/IService/IWMentryWarehousing_productService.cs @@ -1,25 +1,18 @@ -using Microsoft.AspNetCore.Mvc; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ZR.Model.MES.qc.DTO; -using ZR.Model.MES.wms; +using ZR.Model.MES.wms; using ZR.Model.MES.wms.Dto; -using static Org.BouncyCastle.Crypto.Engines.SM2Engine; namespace ZR.Service.mes.wms.IService { - public interface IWMentryWarehousing_productService + public interface IWMentryWarehousing_productService { - + // 判断是否可以入库(入参为扫描结果)(附加参数bol 是否严格控制模式) + public string checkWarehousing(string production_packcode, string location, bool isStrict); // 获取库位列表 public bool IsProductionLoacation(string production_location_code); // 判断是否为成品箱子码 - public int isProductionPackage(string production_packcode); + public int isProductionPackage(string production_packcode); //判断箱子是否满 public bool isFullPackage(string production_packcode); diff --git a/ZR.Service/mes/wms/WMentryWarehousing_productService.cs b/ZR.Service/mes/wms/WMentryWarehousing_productService.cs index ad804ecd..5e7e7cd4 100644 --- a/ZR.Service/mes/wms/WMentryWarehousing_productService.cs +++ b/ZR.Service/mes/wms/WMentryWarehousing_productService.cs @@ -1,23 +1,12 @@ -using Aliyun.OSS; -using Infrastructure.Attribute; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.DependencyInjection; -using Model.DBModel; +using Infrastructure.Attribute; using SqlSugar; using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; -using ZR.Model.mes.pro; using ZR.Model.MES.pro; -using ZR.Model.MES.qu; 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 { @@ -38,7 +27,7 @@ namespace ZR.Service.mes.wms for (int i = 0; i < wmgoods.packagelist.Count(); i++) { - ResultionPackageCodeDto resultionPackage= ResolutionPackagecode(wmgoods.packagelist[i]); + ResultionPackageCodeDto resultionPackage = ResolutionPackagecode(wmgoods.packagelist[i]); WmGoodsNowProduction wmGood = new WmGoodsNowProduction(); wmGood.Id = SnowFlakeSingle.Instance.NextId().ToString(); @@ -47,11 +36,12 @@ namespace ZR.Service.mes.wms try { flow_num = Convert.ToInt32(flow); - }catch(Exception ex) + } + catch (Exception ex) { flow_num = -1; } - + wmGood.PackageCode = Getpack_no(resultionPackage.WorkoderID, flow_num.ToString("000")); wmGood.PackageCodeClient = resultionPackage.PatchCode; wmGood.Partnumber = resultionPackage.PartNumner; @@ -66,8 +56,8 @@ namespace ZR.Service.mes.wms // .Where(it => it.WorkOrderNum == workorder_id) // .Count(); - wmGood.GoodsNumLogic = (resultionPackage.Quantity)??0; - wmGood.GoodsNumAction= wmGood.GoodsNumLogic; + wmGood.GoodsNumLogic = (resultionPackage.Quantity) ?? 0; + wmGood.GoodsNumAction = wmGood.GoodsNumLogic; wmGood.EntryWarehouseTime = DateTime.Now; wmGood.CreatedBy = createName; wmGood.CreatedTime = DateTime.Now; @@ -182,7 +172,7 @@ namespace ZR.Service.mes.wms .Where(it => it.Location.Equals(production_location_code)).Any(); } - + //获取库位已经存在的货物 public List Getpackagelist(string location) @@ -191,75 +181,29 @@ namespace ZR.Service.mes.wms } - /// - /// 解析外箱标签码 - /// - /// - /// - 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 = int.Parse(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 = "生产计划无此零件号"; - // } - ProWorkorder_v2 workorder= Context.Queryable() - .Where(it => it.FinishedPartNumber == partnumber) - .First(); - - if (workorder != null) - { - resultionPackageCode.ProductionDescribe = workorder.ProductDescription; - } - else - { - resultionPackageCode.ProductionDescribe = "生产工单无此零件号"; - } - - - } - catch (Exception ex) - { - logger.Error($"外箱标签码,解析失败 {ex.Message}"); - - } - - return resultionPackageCode; - } //解析外箱标签码 public ResultionPackageCodeDto ResolutionPackage(string code) { - - - return ResolutionPackagecode(code); + // 初步进行解析检测,增加解析成功率 + string[] splitstr = code.Split('^'); + if (splitstr.Length < 1) + { + return null; + } + // 第一类 + if (splitstr[0].Contains("Code=")) + { + return ResolutionPackagecode1(code); + } + // 第二类 + if (splitstr[3].Contains("Cd=")) + { + return ResolutionPackagecode2(code); + } + // 解析失败 + return null; } @@ -271,9 +215,223 @@ namespace ZR.Service.mes.wms /// public bool IsExistedWarehouse(string originalCode) { - ResultionPackageCodeDto resultionPackage= ResolutionPackagecode(originalCode); + ResultionPackageCodeDto resultionPackage = ResolutionPackage(originalCode); return Context.Queryable().Where(it => it.PackageCodeClient == resultionPackage.PatchCode).Any(); } + + + // 检查是否可入库(ok 可入库,其余返回情况) + public string checkWarehousing(string production_packcode, string location, bool isStrict) + { + if (string.IsNullOrEmpty(production_packcode)) + { + return "扫描结果为空!"; + } + // 1.判断能否解析 + ResultionPackageCodeDto resultionPackage = ResolutionPackage(production_packcode); + if (resultionPackage == null) + { + return "标签解析异常!"; + } + // 2.判断是否已入库 + bool isExistedWarehouse = Context.Queryable().Where(it => it.PackageCodeClient == resultionPackage.PatchCode).Any(); + if (isExistedWarehouse) + { + return "该箱号已入库!"; + } + // 提取库位信息 + WmInfo wmInfo = Context.Queryable().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() + .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"; + } + + /// + /// 最早版本解析外箱标签码 + /// + /// + /// + 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 = int.Parse(product_num); + //todo 产品描述 partnumber + ProWorkorder_v2 workorder = Context.Queryable() + .Where(it => it.FinishedPartNumber == partnumber) + .First(); + if (workorder != null) + { + resultionPackageCode.ProductionDescribe = workorder.ProductDescription; + } + else + { + resultionPackageCode.ProductionDescribe = "生产工单无此零件号"; + } + } + catch (Exception ex) + { + logger.Error($"外箱标签码,解析失败 {ex.Message}"); + return null; + } + + return resultionPackageCode; + } + /// + /// 1-解析鲨鱼鳍外箱标签码 + /// + /// + /// + private ResultionPackageCodeDto ResolutionPackagecode1(string packagecode) + { + ResultionPackageCodeDto resultionPackageCode = new ResultionPackageCodeDto(); + try + { + resultionPackageCode.originalCode = packagecode; + // 解析外箱标签码 + string[] splitstr = packagecode.Split('^'); + // 解析批次号 + resultionPackageCode.PatchCode = splitstr[0].Substring(5); + // 解析零件号 + string partnumber = splitstr[1].Substring(11); + // 有的零件号带了-FL,不是很标准 + resultionPackageCode.PartNumner = partnumber; + // 解析工单号 工单号会带个W,需要去掉 + string workoderidid = splitstr[2].Substring(7); + resultionPackageCode.WorkoderID = workoderidid; + // 解析生产时间 工单号生产时间提取 + resultionPackageCode.ProductionTime = string.Concat("20", workoderidid.AsSpan(0, 6)); + // 解析箱子中产品数量 + string product_num = splitstr[3].Substring(4); + resultionPackageCode.Quantity = int.Parse(product_num); + // 解析产品描述 partnumber 从物料列表抓取数据 + WmMaterial material = Context.Queryable().Where(it => it.Partnumber == partnumber).First(); + if (material == null) + { + resultionPackageCode.ProductionDescribe = "物料记录未录入此零件号信息!"; + return resultionPackageCode; + } + string des1 = material.Description; + string des2 = material.ProductName; + if (string.IsNullOrEmpty(des1)) + { + resultionPackageCode.ProductionDescribe = des1; + } + if (string.IsNullOrEmpty(des2)) + { + resultionPackageCode.ProductionDescribe = des2; + } + return resultionPackageCode; + } + catch (Exception ex) + { + logger.Error($"外箱标签码,解析失败 {ex.Message}"); + return null; + } + } + // 2-解析门把手 + private ResultionPackageCodeDto ResolutionPackagecode2(string packagecode) + { + ResultionPackageCodeDto resultionPackageCode = new ResultionPackageCodeDto(); + try + { + // 原始编码 + resultionPackageCode.originalCode = packagecode; + // 解析外箱标签码 + string[] splitstr = packagecode.Split('^'); + // 解析批次号 + resultionPackageCode.PatchCode = splitstr[3].Substring(3); + // 解析零件号 + string partnumber = splitstr[4].Substring(3); + resultionPackageCode.PartNumner = partnumber; + // 解析工单号 + string workoderidid = splitstr[3].Substring(6, 6); + resultionPackageCode.WorkoderID = workoderidid; + // 生产时间 + resultionPackageCode.ProductionTime = "20" + workoderidid.Substring(0, 6); + //todo 解析箱子中产品数量 + string product_num = splitstr[5].Substring(3); + resultionPackageCode.Quantity = int.Parse(product_num); + // 解析产品描述 partnumber 从物料列表抓取数据 + WmMaterial material = Context.Queryable().Where(it => it.Partnumber == partnumber).First(); + if (material == null) + { + resultionPackageCode.ProductionDescribe = "物料记录未录入此零件号信息!"; + return resultionPackageCode; + } + string des1 = material.Description; + string des2 = material.ProductName; + if (!string.IsNullOrEmpty(des1)) + { + resultionPackageCode.ProductionDescribe = des1; + } + else if (!string.IsNullOrEmpty(des2)) + { + resultionPackageCode.ProductionDescribe = des2; + } + else + { + resultionPackageCode.ProductionDescribe = "物料记录内未填写详情信息!"; + } + return resultionPackageCode; + } + catch (Exception ex) + { + logger.Error($"外箱标签码,解析失败 {ex.Message}"); + return null; + } + } + } }