using Infrastructure.Attribute; using System; using ZR.Model.MES.pro; using ZR.Model.MES.wms; using ZR.Model.MES.wms.Dto; using ZR.Service.mes.wms.IService; namespace ZR.Service.mes.wms { [AppService(ServiceType = typeof(IWMExitwarehouseService), ServiceLifetime = LifeTime.Transient)] public class WMExitwarehouseService : BaseService, IWMExitwarehouseService { private NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); // 直接退库 public bool ExitwarehouseCommmon(string original) { ResultionPackageCodeDto packageCode = ResolutionPackagecode(original); string patchCode = packageCode.PatchCode; int result = Context.Deleteable().Where(it => it.PackageCodeClient == patchCode).ExecuteCommand(); if (result == 0) { return false; } return true; } /// /// 判断箱子是否在成品库中 /// /// /// /// public bool IsExistedWarehouse(string originalCode) { ResultionPackageCodeDto resultionPackage = ResolutionPackagecode(originalCode); return Context.Queryable().Where(it => it.PackageCodeClient == resultionPackage.PatchCode).Any(); } /// /// 解析外箱标签码 /// /// /// 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; } } }