From 53950f0fa04a894a2b3880f2da788c837bd84ead Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期一, 27 十一月 2023 09:25:49 +0800
Subject: [PATCH] 修改码段拼接前后缀时判断码值是否为空,为空时不进行拼接

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
index f8946ea..c596095 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -69,11 +69,7 @@
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cache.Cache;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.TransactionStatus;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.transaction.support.DefaultTransactionDefinition;
-import org.springframework.transaction.support.TransactionTemplate;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
@@ -701,14 +697,16 @@
 
         //娌℃湁闄愬埗鍒嗙被锛屼絾鏄竴涓ā鏉垮彧鍙兘鍦ㄤ竴涓笟鍔$被鍨嬮噷闈紝鎵�浠ョ洿鎺ユ煡璇㈣繖涓笟鍔$被鍨嬪嵆鍙�
         if (!CollectionUtils.isEmpty(conditionMap)) {
-			conditionMap.put("CODETEMPLATEOID","'" + orderDTO.getTemplateOid() + "'");
+			// TODO: 鍚屼竴涓簱鍒ら噸涓嶉渶瑕佸尯鍒嗗垎绫籵id
+			// conditionMap.put("CODETEMPLATEOID","'" + orderDTO.getTemplateOid() + "'");
 //			final String[] sql = {"select count(*) from " + VciBaseUtil.getTableName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()) + " t where 1 = 1 "};
             R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(classifyFullInfo.getTopClassifyVO().getBtmTypeId()));
 //				String referTable = VciBaseUtil.getTableName(referVO.getReferType());
             if (!listR.isSuccess() || listR.getData().size() == 0) {
                 throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
             }
-            final String[] sql = {"select count(*) from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "};
+            //final String[] sql = {"select count(*) from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "};
+			final String[] sql = {"select id from " + listR.getData().get(0).getTableName() + " t where 1 = 1 "};
             conditionMap.forEach((key, value) -> {
 				if(StringUtils.isBlank(value)||value.equals(QueryOptionConstant.ISNULL)) {
 					sql[0] += " and " + key + " is null";
@@ -723,11 +721,16 @@
                 sql[0] += " and oid != '" + orderDTO.getCopyFromVersion() + "'";
             }
             sql[0] += " and lastR = '1' and lastV = '1' ";
+			String isParticipateCheckOids = classifyService.selectLeafByParentClassifyOid(classifyFullInfo.getTopClassifyVO().getOid(), classifyFullInfo.getCurrentClassifyVO().getOid());
+			if(Func.isNotEmpty(isParticipateCheckOids)){
+				sql[0] += " and codeclsfid not in(" + isParticipateCheckOids + ")";
+			}
 //			if (boService.queryCountBySql(sql[0], new HashMap<>()) > 0) {
-            if (Integer.parseInt(commonsMapper.selectById(sql[0]).get(0)) > 0) {
+			List<String> repeatData = commonsMapper.selectList(sql[0]);
+			if (!repeatData.isEmpty()) {
                 String ruleInfoMsg = keyRuleVO == null ? "" : "鏌ヨ瑙勫垯锛氬幓闄ょ┖鏍�--{0},蹇界暐澶у皬鍐�--{1},蹇界暐鍏ㄥ崐瑙�--{2},蹇界暐鍏ㄩ儴绌烘牸--{3}";
                 String[] objs = new String[]{trim ? "鏄�" : "鍚�", ignoreCase ? "鏄�" : "鍚�", ignoreWidth ? "鏄�" : "鍚�", trimAll ? "鏄�" : "鍚�"};
-                throw new VciBaseException("鏍规嵁鎮ㄥ~鍐欑殑鍏抽敭灞炴�х殑鍐呭锛岀粨鍚堝叧閿睘鎬ф煡璇㈣鍒欙紝鍙戠幇杩欎釜鏁版嵁宸茬粡鍦ㄧ郴缁熶腑瀛樺湪浜嗐�傝淇!銆�" + ruleInfoMsg, objs);
+                throw new VciBaseException("鏍规嵁鎮ㄥ~鍐欑殑鍏抽敭灞炴�х殑鍐呭锛岀粨鍚堝叧閿睘鎬ф煡璇㈣鍒欙紝鍙戠幇璇ユ暟鎹凡缁忎笌绯荤粺涓紪鍙蜂负"+repeatData.stream().collect(Collectors.joining(","))+"鐨勬暟鎹噸澶嶃�傝淇!銆�" + ruleInfoMsg, objs);
             }
         }
     }
@@ -870,13 +873,13 @@
                     //涓嶅拷鐣ュぇ灏忓啓銆佷笉鍘荤┖銆佷笉蹇界暐鍏ㄥ崐瑙�
                     temp = "%s";
                 }
-                queryKey = String.format(temp, "t." + attrId);
+				queryKey = String.format(temp, "nvl("+ "t." + attrId +",'/')");
                 queryValue = String.format(temp, "'" + (trim ? value.trim() : value) + "'");
                 conditionMap.put(queryKey, queryValue);
             } else {
 				if(StringUtils.isNotBlank(value)) {
 					//涓虹┖鐨勬椂鍊欎笉浠h〃涓嶆牎楠岋紝鍙槸涓嶅幓闄ょ浉鍏崇殑淇℃伅
-					conditionMap.put("t." + attrId, "'" + value + "'");
+					conditionMap.put("nvl("+ "t." + attrId+",'/')", "'" + value + "'");
 				}else{
 					conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL);
 				}
@@ -1793,7 +1796,6 @@
         }
     }
 
-
     /**
      * 鏍规嵁妯℃澘灞炴�х敓鎴愮浉搴旂殑sql淇℃伅
      *
@@ -1959,6 +1961,8 @@
         String sqlHasPage = pageHelper.getLimit() > 0 ? ("select * from (select A.*,rownum RN from (" + sql + whereSubfixForPage) : sql;
         String sqlCount = "select count(1) from " + tableName + SPACE + "t" + SPACE + joinTableList.values().stream().collect(Collectors.joining(SPACE))
                 + (StringUtils.isBlank(whereSql) ? "" : " where ") + whereSql;
+		String sqlId = "select t.ID from " + tableName + SPACE + "t" + SPACE + joinTableList.values().stream().collect(Collectors.joining(SPACE))
+			+ (StringUtils.isBlank(whereSql) ? "" : " where ") + whereSql;
         CodeTemplateAttrSqlBO sqlBO = new CodeTemplateAttrSqlBO();
         sqlBO.setTableName(tableName);
         sqlBO.setJoinTable(joinTableList);
@@ -1967,9 +1971,9 @@
         sqlBO.setSqlHasPage(sqlHasPage);
         sqlBO.setSqlCount(sqlCount);
         sqlBO.setSqlUnPage(sql);
+		sqlBO.setSqlId(sqlId);
         return sqlBO;
     }
-
 
     /**
      * 缁勫悎鏌ヨ鏉′欢鐨剆ql

--
Gitblit v1.9.3