From c7ac595ca5993ca960dfeed016895ab08e4d0c06 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期二, 30 七月 2024 09:17:46 +0800 Subject: [PATCH] 标签模板方法更新 --- Tiger.Business.MES/LabelTemplate/BAS_LABEL_TEMP.cs | 29 ++++++++++++++++++++++++++--- 1 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Tiger.Business.MES/LabelTemplate/BAS_LABEL_TEMP.cs b/Tiger.Business.MES/LabelTemplate/BAS_LABEL_TEMP.cs index 20e8339..438184f 100644 --- a/Tiger.Business.MES/LabelTemplate/BAS_LABEL_TEMP.cs +++ b/Tiger.Business.MES/LabelTemplate/BAS_LABEL_TEMP.cs @@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Http; using Tiger.Model.Entitys.MES.BasLabelTemp; using System.Security.Cryptography; +using Tiger.Model.Entitys.MES.Position; namespace Tiger.Business.MES { @@ -82,12 +83,19 @@ prodCustTemp = input.Label; prodTemp = input.Label.Clone(); prodTemp.CUST_CODE = ""; - prodTemp.LABEL_CODE = $"{input.Label.LABEL_CODE}_{DateTime.Now.ToString("yyyyMMddhhmmss")}"; + prodTemp.LABEL_CODE = GenerateCodeName(input.Label.LABEL_CODE, "_L"); } else { prodCustTemp = input.Label; - prodCustTemp.LABEL_CODE = $"{input.Label.LABEL_CODE}_{DateTime.Now.ToString("yyyyMMddhhmmss")}"; + if (Biz.Db.Queryable<BAS_LABEL_TEMP>().Any(x => + x.LABEL_CODE == input.Label.LABEL_CODE && ( + (x.PROD_CODE != input.Label.PROD_CODE && x.CUST_CODE == input.Label.CUST_CODE) || + (x.PROD_CODE != input.Label.PROD_CODE && x.CUST_CODE != input.Label.CUST_CODE) || + (x.PROD_CODE == input.Label.PROD_CODE && x.CUST_CODE != input.Label.CUST_CODE)))) + { + prodCustTemp.LABEL_CODE = GenerateCodeName(input.Label.LABEL_CODE, "_L"); + } } } else @@ -96,7 +104,7 @@ prodTemp = input.Label; if (Biz.Db.Queryable<BAS_LABEL_TEMP>().Any(x => x.LABEL_CODE == input.Label.LABEL_CODE && x.PROD_CODE != input.Label.PROD_CODE)) { - prodTemp.LABEL_CODE = $"{input.Label.LABEL_CODE}_{DateTime.Now.ToString("yyyyMMddhhmmss")}"; + prodTemp.LABEL_CODE = GenerateCodeName(input.Label.LABEL_CODE, "_L"); } } var db = Biz.Db; @@ -165,5 +173,20 @@ } return await Task.FromResult(result); } + + /// <summary> + /// 鏍规嵁鍒嗛殧绗︾敓鎴怌ode鍚� + /// </summary> + /// <param name="data"></param> + /// <param name="separator"></param> + /// <returns></returns> + private string GenerateCodeName(string data, string separator) + { + string result = string.Empty; + var strs = data.Split("_L"); + result = strs.Length > 1 ? data.Replace(strs[1], DateTime.Now.ToString("yyyyMMddhhmmss")) : $"{data}_L{DateTime.Now.ToString("yyyyMMddhhmmss")}"; + return result; + } + } } -- Gitblit v1.9.3