From d02571d59633367ac76b7f58ab38584698b1aa1b Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期四, 17 十月 2024 09:55:37 +0800
Subject: [PATCH] 高级查询中增加范围查询功能

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java |  324 +++++++++++++++++++++++++++++++++--------------------
 1 files changed, 201 insertions(+), 123 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 8c7b56b..9fff05b 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
@@ -147,6 +147,7 @@
 	 */
 	@Value("${bzApply.seriesFlow:seriesFlow}")
 	private String seriesFlow;
+
 	/***
 	 * 鏄惁鍙樻洿绯诲垪
 	 */
@@ -175,6 +176,11 @@
 	 */
 	@Resource
 	private MdmProductCodeService productCodeService;
+
+	/**
+	 * 杩戜箟璇嶈鍒欐煡璇㈡湇鍔�
+	 */
+	@Autowired ICodeSynonymService codeSynonymService;
 
 	/**
 	 * 鍙緭鍙�夌殑鏈嶅姟
@@ -253,8 +259,9 @@
 	 */
 	@Autowired
 	private ICodeRuleService ruleService;
+
 	/**
-	 * 缂栫爜瑙勫垯鐨勬湇鍔�
+	 * 鐮佸�肩殑鏈嶅姟
 	 */
 	@Autowired
 	private ICodeAllCodeService codeAllCodeService;
@@ -310,6 +317,12 @@
 	public static final String BTM_NAME = "btm:name";
 
 	/**
+	 * 閰嶇疆鐨勭敤鏉ョ敵璇烽泦鍥㈢爜鐨勭敤鎴�
+	 */
+	@Value("${docking.apply.personUserAccount:28201728}")
+	public String applyCodeUserAccount;
+
+	/**
 	 * 瀵嗙骇鐨勫瓧娈�
 	 */
 	public static final String SECRET_FILED = "secretgrade";
@@ -358,7 +371,6 @@
 	 */
 	@Autowired
 	private SaveLogUtil saveLogUtil;
-
 
 	/**
 	 * 浣跨敤鍒嗙被鐨勪富閿幏鍙栧彲浠ヤ娇鐢ㄧ殑妯℃澘瀵硅薄
@@ -423,8 +435,7 @@
 		try {
 			VciBaseUtil.alertNotNull(baseModelDTO, "鏁版嵁淇℃伅", baseModelDTO.getOid(), "涓婚敭", baseModelDTO.getBtmname(), "涓氬姟绫诲瀷", baseModelDTO.getLcStatus(), "鐩爣鐘舵��");
 			List<String> oids = VciBaseUtil.str2List(baseModelDTO.getOid());
-			List<BaseModel> baseModels = new ArrayList<>();
-			baseModels = selectByTypeAndOid(baseModelDTO.getBtmname(), baseModelDTO.getOid());
+			List<BaseModel> baseModels = selectByTypeAndOid(baseModelDTO.getBtmname(), baseModelDTO.getOid());
 			if (baseModels.size() == 0) {
 				throw new VciBaseException("鏈煡璇㈠埌鐩稿叧鏁版嵁銆�");
 			}
@@ -447,7 +458,7 @@
 				}
 				R r = updateBatchByBaseModel(baseModelDTO.getBtmname(), baseModels);
 				if (!r.isSuccess()) {
-					throw new VciBaseException("鏇存柊鏁版嵁鍑洪敊锛岄噸璇曪紒" + r.getMsg());
+					throw new VciBaseException("鏇存柊鏁版嵁鍑洪敊锛岃閲嶈瘯锛�" + r.getMsg());
 				}
 			}
 			// 鍒氬ソ椤哄簭鏄竴鑷寸殑锛屾墍浠ョ洿鎺ユ寜鐓odeallcode鐨勯『搴忔潵鎷夸笟鍔℃暟鎹�
@@ -756,27 +767,36 @@
 		//娉ㄦ剰鐨勬槸keyRuleVO鍙兘涓虹┖锛岃〃绀轰笉浣跨敤瑙勫垯鎺у埗
 		//鑾峰彇鎵�鏈夌殑鍏抽敭灞炴��
 		Map<String, CodeClassifyTemplateAttrVO> ketAttrMap = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getKeyAttrFlag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
+		// TODO:2024-02-01 鍏堣幏鍙栭厤缃簡杩戜箟璇嶆煡璇㈣鍒欑殑灞炴�э紝涓嶅悓浜庡叧閿睘鎬э紝璁剧疆浜嗚繎涔夎瘝鏌ヨ瑙勫垯鐨勫睘鎬у彲鑳芥槸澶氭潯涓嶅悓鐨勮繎涔夎瘝鏌ヨ瑙勫垯
+		Map<String, CodeClassifyTemplateAttrVO> sysonymAttrMaps = templateVO.getAttributes().stream().filter(item -> Func.isNotBlank(item.getSysonymRuleOids())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
+		// 鑾峰彇鏄惁鏈夐厤缃繎涔夎瘝鏌ヨ瑙勫垯灞炴��
+		Map<String, List<CodeSynonym>> codeSynonymMaps = new HashMap<>();
+		if(!sysonymAttrMaps.isEmpty()){
+			// 鏌ヨ杩戜箟璇嶈鍒欙紝瀛樺偍鏂瑰紡key锛氬睘鎬d锛寁alue杩戜箟璇嶆煡璇㈣鍒欏垪琛�
+			codeSynonymMaps = codeSynonymService.getCodeSynonymByOids(sysonymAttrMaps);
+		}
 		Map<String, String> conditionMap = new HashMap<>();
 		boolean trimAll = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag());
 		//鍏ㄩ儴鍘荤┖鐨勪紭鍏堢骇澶т簬鍘荤┖
 		boolean trim = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorespaceflag());
 		boolean ignoreCase = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorecaseflag());
 		boolean ignoreWidth = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorewidthflag());
+		Map<String, List<CodeSynonym>> finalCodeSynonymMaps = codeSynonymMaps;
 		ketAttrMap.forEach((attrId, attrVO) -> {
 			String value = getValueFromOrderDTO(orderDTO, attrId);
 			if (value == null) {
 				value = "";
 			}
-			wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
+			wrapperKeyAttrConditionMap(value, keyRuleVO, finalCodeSynonymMaps.get(attrId), attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
 		});
 
 		//娌℃湁闄愬埗鍒嗙被锛屼絾鏄竴涓ā鏉垮彧鍙兘鍦ㄤ竴涓笟鍔$被鍨嬮噷闈紝鎵�浠ョ洿鎺ユ煡璇㈣繖涓笟鍔$被鍨嬪嵆鍙�
 		if (!CollectionUtils.isEmpty(conditionMap)) {
 			// TODO: 鍚屼竴涓簱鍒ら噸涓嶉渶瑕佸尯鍒嗗垎绫籵id
 			// conditionMap.put("CODETEMPLATEOID","'" + orderDTO.getTemplateOid() + "'");
-//			final String[] sql = {"select count(*) from " + VciBaseUtil.getTableName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()) + " t where 1 = 1 "};
+			// 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());
+			// String referTable = VciBaseUtil.getTableName(referVO.getReferType());
 			if (!listR.isSuccess() || listR.getData().size() == 0) {
 				throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
 			}
@@ -801,7 +821,7 @@
 			if (Func.isNotEmpty(isParticipateCheckOids)) {
 				sql[0] += " and codeclsfid not in(" + isParticipateCheckOids + ")";
 			}
-//			if (boService.queryCountBySql(sql[0], new HashMap<>()) > 0) {
+			// if (boService.queryCountBySql(sql[0], new HashMap<>()) > 0) {
 			List<String> repeatData = commonsMapper.selectList(sql[0]);
 			if (!repeatData.isEmpty()) {
 				String ruleInfoMsg = keyRuleVO == null ? "" : "鏌ヨ瑙勫垯锛氬幓闄ょ┖鏍�--{0},蹇界暐澶у皬鍐�--{1},蹇界暐鍏ㄥ崐瑙�--{2},蹇界暐鍏ㄩ儴绌烘牸--{3}";
@@ -826,18 +846,27 @@
 		//娉ㄦ剰鐨勬槸keyRuleVO鍙兘涓虹┖锛岃〃绀轰笉浣跨敤瑙勫垯鎺у埗
 		//鑾峰彇鎵�鏈夌殑鍏抽敭灞炴��
 		Map<String, CodeClassifyTemplateAttrVO> ketAttrMap = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getKeyAttrFlag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
+		// TODO:2024-02-01 鍏堣幏鍙栭厤缃簡杩戜箟璇嶆煡璇㈣鍒欑殑灞炴�э紝涓嶅悓浜庡叧閿睘鎬э紝璁剧疆浜嗚繎涔夎瘝鏌ヨ瑙勫垯鐨勫睘鎬у彲鑳芥槸澶氭潯涓嶅悓鐨勮繎涔夎瘝鏌ヨ瑙勫垯
+		Map<String, CodeClassifyTemplateAttrVO> sysonymAttrMaps = templateVO.getAttributes().stream().filter(item -> Func.isNotBlank(item.getSysonymRuleOids())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
+		// 鑾峰彇鏄惁鏈夐厤缃繎涔夎瘝鏌ヨ瑙勫垯灞炴��
+		Map<String, List<CodeSynonym>> codeSynonymMaps = new HashMap<>();
+		if(!sysonymAttrMaps.isEmpty()){
+			// 鏌ヨ杩戜箟璇嶈鍒欙紝瀛樺偍鏂瑰紡key锛氬睘鎬d锛寁alue杩戜箟璇嶆煡璇㈣鍒欏垪琛�
+			codeSynonymMaps = codeSynonymService.getCodeSynonymByOids(sysonymAttrMaps);
+		}
 		Map<String, String> conditionMap = new HashMap<>();
 		boolean trimAll = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag());
 		//鍏ㄩ儴鍘荤┖鐨勪紭鍏堢骇澶т簬鍘荤┖
 		boolean trim = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorespaceflag());
 		boolean ignoreCase = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorecaseflag());
 		boolean ignoreWidth = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorewidthflag());
+		Map<String, List<CodeSynonym>> finalCodeSynonymMaps = codeSynonymMaps;
 		ketAttrMap.forEach((attrId, attrVO) -> {
 			String value = getValueFromOrderDTO(orderDTO, attrId);
 			if (value == null) {
 				value = "";
 			}
-			wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
+			wrapperKeyAttrConditionMap(value, keyRuleVO, finalCodeSynonymMaps.get(attrId), attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
 		});
 
 		//娌℃湁闄愬埗鍒嗙被锛屼絾鏄竴涓ā鏉垮彧鍙兘鍦ㄤ竴涓笟鍔$被鍨嬮噷闈紝鎵�浠ョ洿鎺ユ煡璇㈣繖涓笟鍔$被鍨嬪嵆鍙�
@@ -928,7 +957,7 @@
 		}
 		//鏄惁绯诲垪
 		if (!codeBZApplyDTO.isSeries()) {
-			boolean isSeriesValue = codeBZApplyDTO.getData().get(isSeries).equals("true") ? true : false;
+			boolean isSeriesValue = Func.toBoolean(codeBZApplyDTO.getData().get(isSeries));
 			codeBZApplyDTO.setSeries(isSeriesValue);
 		}
 		//鍘熸爣鍑嗗彿
@@ -948,7 +977,7 @@
 		}
 		//鏄惁鍙樻洿绯诲垪
 		if (!codeBZApplyDTO.isEditSeries()) {
-			boolean isEditSeriesValue = codeBZApplyDTO.getData().get(isEditSeries).equals("true") ? true : false;
+			boolean isEditSeriesValue = Func.toBoolean(codeBZApplyDTO.getData().get(isEditSeries));
 			codeBZApplyDTO.setEditSeries(isEditSeriesValue);
 		}
 		VciBaseUtil.alertNotNull(codeBZApplyDTO.getOperationType(), "鎿嶄綔绫诲瀷",
@@ -966,7 +995,7 @@
 		} else if (codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_DISABLE.getValue())) {//浣滃簾
 			code = amendmentDataBZ(codeBZApplyDTO, authUser);
 			createChangeOder(code, codeBZApplyDTO, authUser);
-		} else if (codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_AMENDMENT.getValue())) {//澶囨煡
+		} else if (codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_FOR_REFERENCE.getValue())) {//澶囨煡
 			code = amendmentDataBZ(codeBZApplyDTO, authUser);
 			createChangeOder(code, codeBZApplyDTO, authUser);
 		}
@@ -1236,14 +1265,18 @@
 	 * @param conditionMap 鏌ヨ鏉′欢
 	 */
 	@Override
-	public void wrapperKeyAttrConditionMap(String value, CodeKeyAttrRepeatVO keyRuleVO, String attrId,
+	public void wrapperKeyAttrConditionMap(String value, CodeKeyAttrRepeatVO keyRuleVO,
+										   List<CodeSynonym> codeSynonymMaps, String attrId,
 										   boolean trim, boolean ignoreCase, boolean ignoreWidth,
 										   boolean trimAll, Map<String, String> conditionMap) {
 		boolean ignoreSpace = trim || trimAll;
 		if (StringUtils.isBlank(value)) {
-			//涓虹┖鐨勬椂鍊欙紝涓嶈兘鐢≦ueryOperation.ISNULL锛屽钩鍙颁笉鐭ラ亾鍟ユ椂鍊欎笉澶勭悊杩欑浜�
+			//鍊间负绌虹殑鏃跺�欙紝涓嶈兘鐢≦ueryOperation.ISNULL锛屽钩鍙颁笉鐭ラ亾鍟ユ椂鍊欎笉澶勭悊杩欑浜�
 			conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL);
 		} else {
+			//杩戜箟璇嶆煡璇㈣鍒檝alu鍊艰浆鎹�
+			value = this.getValueToSynony(codeSynonymMaps, value);
+
 			if (keyRuleVO != null) {
 				String queryKey = "";
 				String queryValue = "";
@@ -1279,13 +1312,30 @@
 				conditionMap.put(queryKey, queryValue);
 			} else {
 				if (StringUtils.isNotBlank(value)) {
-					//涓虹┖鐨勬椂鍊欎笉浠h〃涓嶆牎楠岋紝鍙槸涓嶅幓闄ょ浉鍏崇殑淇℃伅
+					//鍏抽敭灞炴�ф煡閲嶈鍒欎负绌虹殑鏃跺�欎笉浠h〃涓嶆牎楠岋紝鍙槸涓嶅幓闄ょ浉鍏崇殑淇℃伅
 					conditionMap.put("nvl(" + "t." + attrId + ",'/')", "'" + SpecialCharacterConverter.escapeSpecialCharacters(value) + "'");
 				} else {
 					conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL);
 				}
 			}
 		}
+	}
+
+	/**
+	 * 杩戜箟璇嶆煡璇㈣鍒欒浆鎹�
+	 * @param codeSynonymMaps
+	 * @param value
+	 * @return
+	 */
+	public String getValueToSynony(/*杩戜箟璇嶆煡璇㈣鍒�*/List<CodeSynonym> codeSynonymMaps,String value){
+		// 鑾峰彇骞跺垽鏂槸鍚﹂厤缃簡杩戜箟璇嶆煡璇㈣鍒�
+		// TODO锛氳繎涔夎瘝鏇挎崲鎴愭簮鍊硷紙婧愬�兼槸姝g‘鐨勫�硷紝杩戜箟璇嶆槸鐩稿綋浜庤緭閿欑瑪璇殑瀛楃锛�
+		if(Func.isNotEmpty(codeSynonymMaps)){
+			for (int i = 0; i < codeSynonymMaps.size(); i++) {
+				value = value.replace(codeSynonymMaps.get(i).getSynonymValue(),codeSynonymMaps.get(i).getSourceValue());
+			}
+		}
+		return value;
 	}
 
 	/**
@@ -1510,7 +1560,6 @@
 		wrapperResemble(templateVO, uiInfoVO);
 		return uiInfoVO;
 	}
-
 
 	/**
 	 * 妯℃澘灞炴�ц浆鎹负琛ㄥ崟瀹氫箟鐨勪俊鎭�
@@ -1948,7 +1997,7 @@
 			boolean ignoreCase = VciBaseUtil.getBoolean(resembleRuleVO.getIgnorecaseflag());
 			boolean ignoreWidth = VciBaseUtil.getBoolean(resembleRuleVO.getIgnorewidthflag());
 			boolean trimAll = VciBaseUtil.getBoolean(resembleRuleVO.getIgnoreallspaceflag());
-			boolean trim = VciBaseUtil.getBoolean(resembleRuleVO.getIgnoreallspaceflag());
+			boolean trim = VciBaseUtil.getBoolean(resembleRuleVO.getIgnorecaseflag());
 			String temp = "";
 			if (ignoreCase && ignoreSpace && ignoreWidth) {
 				//蹇界暐澶у皬鍐欙紝涓斿幓绌猴紝蹇界暐鍏ㄥ崐瑙�
@@ -1982,7 +2031,7 @@
 					temp = "replace(" + temp + ",'" + s + "','')";
 				}
 			}
-			queryValue = String.format(temp, (trim ? value.trim() : value));
+			queryValue = String.format(temp, (trim ? "'"+value.trim()+"'" : "'"+value+"'"));
 			temp = temp.replace("to_single_byte('%s')", "to_single_byte(%s)");
 			queryKey = String.format(temp, "t." + attrId);
 			conditionMap.put(queryKey, QueryOptionConstant.OR + queryValue);
@@ -2001,14 +2050,14 @@
 	@Override
 	public DataGrid<Map<String, String>> queryGrid(String btmType, CodeClassifyTemplateVO templateVO, Map<String, String> conditionMap, PageHelper pageHelper) {
 		CodeTemplateAttrSqlBO sqlBO = getSqlByTemplateVO(btmType, templateVO, conditionMap, pageHelper);
-//		List<Map> maps = boService.queryByOnlySqlForMap(sqlBO.getSqlHasPage());
+		// List<Map> maps = boService.queryByOnlySqlForMap(sqlBO.getSqlHasPage());
 		List<Map<String, String>> maps = null;
 		try {
 			maps = commonsMapper.queryByOnlySqlForMap(sqlBO.getSqlHasPage());
 		} catch (Exception e) {
 			String errorMessage = e.getMessage();
 			if (errorMessage.contains("鏃犳硶瑙f瀽鐨勬垚鍛樿闂〃杈惧紡")) {
-				throw new ServiceException("缂哄皯" + errorMessage.substring(errorMessage.indexOf("[t.") + 1, errorMessage.indexOf("]")) + "瀛楁");
+				throw new ServiceException("缂哄皯" + errorMessage.substring(errorMessage.indexOf("[T.") + 1, errorMessage.indexOf("]")) + "瀛楁");
 			}
 			throw new ServiceException(e.getMessage());
 		}
@@ -2021,39 +2070,39 @@
 				for (String s : map.keySet()) {
 					data.put(s.toLowerCase(Locale.ROOT), map.get(s) == null ? null : String.valueOf(map.get(s)));
 				}
-//				map.forEach((key, value) -> {
-//					data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
-//				});
+				//	map.forEach((key, value) -> {
+				//		data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
+				//	});
 				dataList.add(data);
 			});
 			wrapperData(dataList, templateVO, sqlBO.getSelectFieldList(), false);
-//			maps.stream().forEach(map -> {
-//				Map<String, String> data = new HashMap<>();
-////				map.forEach((key, value) -> {
-////					data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
-////				});
-//				for (String s : map.keySet()) {
-//					data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s)));
-//				}
-//				dataList.add(data);
-//			});
+			// maps.stream().forEach(map -> {
+			// 	Map<String, String> data = new HashMap<>();
+			// 	map.forEach((key, value) -> {
+			// 		data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
+			// 	});
+			// 	for (String s : map.keySet()) {
+			// 		data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s)));
+			// 	}
+			// 	dataList.add(data);
+			// });
 		}
-//		dataGrid.setData(dataList);
-//		if (!CollectionUtils.isEmpty(maps)) {
-//			wrapperData(maps, templateVO, sqlBO.getSelectFieldList(), false);
-//			maps.stream().forEach(map -> {
-//				Map<String, String> data = new HashMap<>();
-////				map.forEach((key, value) -> {
-////					data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
-////				});
-//				for (String s : map.keySet()) {
-//					data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s)));
-//				}
-//				dataList.add(data);
-//			});
+		//		dataGrid.setData(dataList);
+		//		if (!CollectionUtils.isEmpty(maps)) {
+		//			wrapperData(maps, templateVO, sqlBO.getSelectFieldList(), false);
+		//			maps.stream().forEach(map -> {
+		//				Map<String, String> data = new HashMap<>();
+		////				map.forEach((key, value) -> {
+		////					data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
+		////				});
+		//				for (String s : map.keySet()) {
+		//					data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s)));
+		//				}
+		//				dataList.add(data);
+		//			});
 		dataGrid.setData(dataList);
 		dataGrid.setTotal(Long.parseLong(commonsMapper.selectBySql(sqlBO.getSqlCount()).get(0).values().toArray()[0].toString()));
-//		}
+		//		}
 		return dataGrid;
 	}
 
@@ -2130,7 +2179,7 @@
 					userVOMap.put(String.valueOf(data.getId()), data);
 				}
 			}
-//			Map<String, SmUserVO> userVOMap = Optional.ofNullable(userQueryService.listUserByUserIds(userIds)).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
+			// Map<String, SmUserVO> userVOMap = Optional.ofNullable(userQueryService.listUserByUserIds(userIds)).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
 			dataMap.stream().forEach(data -> {
 				String creator = data.getOrDefault("creator", null);
 				if (StringUtils.isNotBlank(creator) && userVOMap.containsKey(creator.toLowerCase(Locale.ROOT))) {
@@ -2143,7 +2192,6 @@
 			});
 		}
 	}
-
 
 	/**
 	 * 澶勭悊鏃堕棿鏍煎紡
@@ -2171,7 +2219,6 @@
 			});
 		}
 	}
-
 
 	/**
 	 * 澶勭悊鏋氫妇鐨勫唴瀹癸紝濡傛灉涓嶅湪鏋氫妇涓紝浼氳繑鍥炲師鏈殑鍊�
@@ -2522,8 +2569,19 @@
 				if (referFieldMap.containsKey(field)) {
 					return VciBaseUtil.toInSql(referFieldMap.get(field), value);  //referFieldMap.get(field) + SPACE + "= '" + value + "'" + SPACE;
 				} else {
-					return (field.contains(".") ? "" : "t.") + field + SPACE + "= " + getStringValueInWhere(field, value, attrVOMap) + "" + SPACE;
+					//TODO:鏆傛椂娌¤�冭檻IN>1000鏉$殑闂
+					//return (field.contains(".") ? "" : "t.") + field + SPACE + "= " + getStringValueInWhere(field, value, attrVOMap) + "" + SPACE;
+					return (field.contains(".") ? "" : "t.") + field + SPACE + "IN (" + getStringValueInWhere(field, "IN//"+value, attrVOMap) + ")" + SPACE;
 				}
+			} else if (key.endsWith("_notin")) {
+				String field = UBCSSqlKeyword.getColumn(key, "_in");
+				if (referFieldMap.containsKey(field)) {
+					return VciBaseUtil.toInSql(referFieldMap.get(field), value);  //referFieldMap.get(field) + SPACE + "= '" + value + "'" + SPACE;
+				} else {
+					//return (field.contains(".") ? "" : "t.") + field + SPACE + "not in (" + getStringValueInWhere(field, "IN//"+value, attrVOMap) + ")" + SPACE;
+					return (field.contains(".") ? "" : "t.") + field + SPACE + "IN (" + getStringValueInWhere(field, "IN//"+value, attrVOMap) + ")" + SPACE;
+				}
+
 			} else {
 //                if (referFieldMap.containsKey(key)) {
 //                    //璇存槑鏄弬鐓х殑锛屾垜浠弬鐓х殑鏌ヨ閮借涓烘槸瀛楃涓诧紝濡傛灉鏄椂闂存牸寮忕殑鏌ヨ鑲畾鏈夐棶棰橈紝
@@ -2620,13 +2678,21 @@
 					|| VciFieldTypeEnum.VTInteger.equals(fieldTypeEnum)) {
 					return value;
 				} else {
+					if(value.contains("IN//")){
+						return MybatisParameterUtil.getInClause(Func.toStrList(value.replace("IN//","")));
+					}
 					return "'" + value + "'";
 				}
 			} else {
 				if ((value.startsWith("(") && value.endsWith(")")) || (value.startsWith("'") && value.endsWith("'"))) {
 					return value;
+				}else if(value.contains("IN//")){
+					//鏆傛椂涓嶈�冭檻>1000鐨勬儏鍐碉紝鍥犱负鎼滅储涓�鑸篃涓嶄細鍑虹幇鎼滅储1000鏉$殑鎯呭喌
+					//return MybatisParameterUtil.convertToOrConditions(field, Func.toStrList(value.replace("IN//","")));
+					return MybatisParameterUtil.getInClause(Func.toStrList(value.replace("IN//","")));
+				}else{
+					return "'" + value + "'";
 				}
-				return "'" + value + "'";
 			}
 		}
 
@@ -2965,7 +3031,7 @@
 			conditionMap = new HashMap<>();
 		}
 		pageHelper.addDefaultDesc("createTime");
-//        pageHelper.addDefaultDesc("id");
+		// pageHelper.addDefaultDesc("id");
 		if (!classifyService.checkHasChild(codeClassifyOid)) {
 			conditionMap.put("t." + CODE_CLASSIFY_OID_FIELD, codeClassifyOid);
 		} else {
@@ -2982,6 +3048,9 @@
 		conditionMap.put("t.lastr", "1");
 		conditionMap.put("t.lastv", "1");
 		DataGrid<Map<String, String>> mapDataGrid = queryGrid(btmTypeId, templateVO, conditionMap, pageHelper);
+		if(templateVO.getAttributes().isEmpty()){
+			throw new ServiceException(String.format("涓婚敭涓猴細{}鐨勬ā鏉夸笅锛屾ā鏉垮睘鎬ч厤缃负绌猴紒",templateVO.getOid()));
+		}
 		//澶勭悊杩斿洖鏁版嵁涓庢ā鏉挎暟鎹厤缃殑瀛楁涓嶄竴鏍烽棶棰�
 		templateVO.getAttributes().stream().forEach(e -> {
 			for (Map<String, String> datum : mapDataGrid.getData()) {
@@ -2992,26 +3061,26 @@
 			}
 		});
 		return mapDataGrid;
-//        List<String> selectFieldList = templateVO.getAttributes().stream().map(CodeClassifyTemplateAttrVO::getId).collect(Collectors.toList());
-//        //鍙傜収璁╁钩鍙扮洿鎺ユ煡璇㈠氨琛�
-//        List<String> finalSelectFieldList = selectFieldList;
-//        List<CodeClassifyTemplateAttrVO> referAttrVOs = templateVO.getAttributes().stream().filter(
-//                s -> StringUtils.isNotBlank(s.getReferbtmid())
-//                        &&
-//                        (finalSelectFieldList.size() ==0 || finalSelectFieldList.contains(s.getId().toLowerCase(Locale.ROOT)))
-//        ).collect(Collectors.toList());
-//        if(!CollectionUtils.isEmpty(referAttrVOs)){
-//            for (int i = 0; i < referAttrVOs.size(); i++) {
-//                selectFieldList.add(referAttrVOs.get(i).getId() + ".name");
-//            }
-//        }
-//        //鎴戜滑浣跨敤鍜屼笟鍔$被鍨嬬殑鏉ユ煡璇�
-//        DataGrid<Map<String,String>> dataGrid = boService.queryGridByBo(btmTypeId, conditionMap, pageHelper, selectFieldList);
-//        //鎴戜滑闇�瑕佷娇鐢ㄦā鏉挎潵杞崲
-//        if(!CollectionUtils.isEmpty(dataGrid.getData())){
-//            wrapperData(dataGrid.getData(),templateVO,finalSelectFieldList,false);
-//        }
-//        return dataGrid;
+		//        List<String> selectFieldList = templateVO.getAttributes().stream().map(CodeClassifyTemplateAttrVO::getId).collect(Collectors.toList());
+		//        //鍙傜収璁╁钩鍙扮洿鎺ユ煡璇㈠氨琛�
+		//        List<String> finalSelectFieldList = selectFieldList;
+		//        List<CodeClassifyTemplateAttrVO> referAttrVOs = templateVO.getAttributes().stream().filter(
+		//                s -> StringUtils.isNotBlank(s.getReferbtmid())
+		//                        &&
+		//                        (finalSelectFieldList.size() ==0 || finalSelectFieldList.contains(s.getId().toLowerCase(Locale.ROOT)))
+		//        ).collect(Collectors.toList());
+		//        if(!CollectionUtils.isEmpty(referAttrVOs)){
+		//            for (int i = 0; i < referAttrVOs.size(); i++) {
+		//                selectFieldList.add(referAttrVOs.get(i).getId() + ".name");
+		//            }
+		//        }
+		//        //鎴戜滑浣跨敤鍜屼笟鍔$被鍨嬬殑鏉ユ煡璇�
+		//        DataGrid<Map<String,String>> dataGrid = boService.queryGridByBo(btmTypeId, conditionMap, pageHelper, selectFieldList);
+		//        //鎴戜滑闇�瑕佷娇鐢ㄦā鏉挎潵杞崲
+		//        if(!CollectionUtils.isEmpty(dataGrid.getData())){
+		//            wrapperData(dataGrid.getData(),templateVO,finalSelectFieldList,false);
+		//        }
+		//        return dataGrid;
 	}
 
 	/**
@@ -3424,17 +3493,20 @@
 			cbos.add(data);
 		});
 
-//		List<ClientBusinessObject> cbos = boService.queryByOnlySql(sqlBO.getSqlUnPage());
+		// List<ClientBusinessObject> cbos = boService.queryByOnlySql(sqlBO.getSqlUnPage());
 		if (CollectionUtils.isEmpty(cbos)) {
-			throw new VciBaseException("鏁版嵁鍦ㄧ郴缁熶腑涓嶅瓨鍦紝鏄惁鍥犱负淇敼杩囦笟鍔$被鍨嬶紵");
+			return R.fail("鏁版嵁鍦ㄧ郴缁熶腑涓嶅瓨鍦紝鏄惁鍥犱负淇敼杩囦笟鍔$被鍨嬶紵");
 		}
-//		Map<String, String> data = new HashMap<>();
+		// Map<String, String> data = new HashMap<>();
 		Map<String, String> cbo = cbos.get(0);
-//		WebUtil.copyValueToMapFromCbos(cbo, data);
+		// WebUtil.copyValueToMapFromCbos(cbo, data);
 		List<Map<String, String>> dataList = new ArrayList<>();
 		dataList.add(cbo);
 		wrapperData(dataList, templateVO, sqlBO.getSelectFieldList(), true);
 		R<List<Map<String, String>>> result = R.data(Collections.singletonList(cbo));
+		if(templateVO.getAttributes().isEmpty()){
+			return R.fail(String.format("涓婚敭涓猴細%s鐨勬ā鏉夸笅锛屾ā鏉垮睘鎬ч厤缃负绌猴紒",templateVO.getOid()));
+		}
 		//澶勭悊杩斿洖鏁版嵁涓庢ā鏉挎暟鎹厤缃殑瀛楁涓嶄竴鏍烽棶棰�
 		templateVO.getAttributes().stream().forEach(e -> {
 			for (Map<String, String> datum : result.getData()) {
@@ -3446,42 +3518,42 @@
 		});
 
 		//鎴戜滑瑕佺湅鏄惁涓嶆槸鍗囩増鐨勶紝鍗囩増鐨勮瘽锛岄渶瑕佸姣斾笉鐩哥瓑鐨勫睘鎬�
-/*        String copy = cbo.get("copyfromversion");
-//		if (StringUtils.isBlank(copy)) {
-//			copy = cbo.getAttributeValue("copyfromversion");
-//		}
-        if (StringUtils.isNotBlank(copy)) {
-            //璇存槑鏈夊彉鏇寸殑鍐呭
+		/*        String copy = cbo.get("copyfromversion");
+		//		if (StringUtils.isBlank(copy)) {
+		//			copy = cbo.getAttributeValue("copyfromversion");
+		//		}
+				if (StringUtils.isNotBlank(copy)) {
+					//璇存槑鏈夊彉鏇寸殑鍐呭
 
-            CodeTemplateAttrSqlBO oldSqlBO = getSqlByTemplateVO(btmId, templateVO, WebUtil.getOidQuery(copy), new PageHelper(-1));
-            //鎴戜滑浣跨敤鍜屼笟鍔$被鍨嬬殑鏉ユ煡璇�
-//			List<Map> cbos = commonsMapper.selectBySql(sqlBO.getSqlUnPage());
-            List<Map> oldCbos = commonsMapper.selectBySql(oldSqlBO.getSqlUnPage());
-            if (!CollectionUtils.isEmpty(oldCbos)) {
-//				Map<String, String> newData = new HashMap<>();
-//				WebUtil.copyValueToMapFromCbos(cbo, newData);
-                Map<String, String> oldData = new HashMap<>();
-                oldData = oldCbos.get(0);
-                Map<String, String> difFieldMap = new HashMap<>();
-                Map<String, String> finalOldData = oldData;
-                cbo.forEach((key, value) -> {
-					// 杩欏効oldmap涓殑鍏ㄦ槸澶у啓锛岃�宑bo涓殑鍏ㄦ槸灏忓啓鎵�浠ヤ細鎷夸笉鍒板彧锛岃繖鍎跨洿鎺ュ鐞嗘垚灏忓啓鎷夸笉鍒板氨鐢ㄥぇ鍐欐嬁
-					String oldValue = String.valueOf(finalOldData.getOrDefault(key.toUpperCase(Locale.ROOT), finalOldData.getOrDefault(key, "")));
-					if (value == null || value == "null") {
-                        value = "";
-                    }
-                    if (oldValue == null || oldValue == "null") {
-                        oldValue = "";
-                    }
-                    if (!value.equalsIgnoreCase(oldValue)) {
-                        difFieldMap.put(key, oldValue);
-                    }
-                });
-                List<Map<String, String>> difFieldList = new ArrayList<>();
-                difFieldList.add(difFieldMap);
-                result.setData(difFieldList);
-            }
-        }*/
+					CodeTemplateAttrSqlBO oldSqlBO = getSqlByTemplateVO(btmId, templateVO, WebUtil.getOidQuery(copy), new PageHelper(-1));
+					//鎴戜滑浣跨敤鍜屼笟鍔$被鍨嬬殑鏉ユ煡璇�
+		//			List<Map> cbos = commonsMapper.selectBySql(sqlBO.getSqlUnPage());
+					List<Map> oldCbos = commonsMapper.selectBySql(oldSqlBO.getSqlUnPage());
+					if (!CollectionUtils.isEmpty(oldCbos)) {
+		//				Map<String, String> newData = new HashMap<>();
+		//				WebUtil.copyValueToMapFromCbos(cbo, newData);
+						Map<String, String> oldData = new HashMap<>();
+						oldData = oldCbos.get(0);
+						Map<String, String> difFieldMap = new HashMap<>();
+						Map<String, String> finalOldData = oldData;
+						cbo.forEach((key, value) -> {
+							// 杩欏効oldmap涓殑鍏ㄦ槸澶у啓锛岃�宑bo涓殑鍏ㄦ槸灏忓啓鎵�浠ヤ細鎷夸笉鍒板彧锛岃繖鍎跨洿鎺ュ鐞嗘垚灏忓啓鎷夸笉鍒板氨鐢ㄥぇ鍐欐嬁
+							String oldValue = String.valueOf(finalOldData.getOrDefault(key.toUpperCase(Locale.ROOT), finalOldData.getOrDefault(key, "")));
+							if (value == null || value == "null") {
+								value = "";
+							}
+							if (oldValue == null || oldValue == "null") {
+								oldValue = "";
+							}
+							if (!value.equalsIgnoreCase(oldValue)) {
+								difFieldMap.put(key, oldValue);
+							}
+						});
+						List<Map<String, String>> difFieldList = new ArrayList<>();
+						difFieldList.add(difFieldMap);
+						result.setData(difFieldList);
+					}
+		}*/
 		return result;
 	}
 
@@ -3909,13 +3981,13 @@
 		MdmUIInfoVO uiInfoVO = getTableDefineByTemplateVO(getUsedTemplateByClassifyOid(codeClassifyOid));
 		uiInfoVO.setLeaf(classifyService.countChildrenByClassifyOid(codeClassifyOid) == 0);
 		if (StringUtils.isNotBlank(functionId) && !"~".equalsIgnoreCase(functionId)) {
-			List<Menu> buttonVOS = iSysClient.getMenuButtonByType(codeClassifyOid, uiInfoVO.getTemplateVO().getBtmTypeId(), "data_auth").getData();
-			//			List<SmOperationVO> operationVOS = operationService.listButtonByFunctionId(functionId);
-			//			if (operationVOS == null) {
-			//				operationVOS = new ArrayList<>();
-			//			}
-			//			//鏌ヨ鎵╁睍鎸夐挳
-			//			List<CodeButtonVO> buttonVOS = listButtonInToolbarByClassifyOid(codeClassifyOid);
+			// TODO:2024-1-25 18:42妯℃澘涓婄殑btmtypeid鏈夋椂鍊欎細瀛樺湪澶у皬鍐欑殑闂锛屾寜鐞嗘潵璇磋繖鍎跨洿鎺ョ敤functionId灏辫兘婊¤冻鏌ヨ鑿滃崟鎸夐挳浜唘iInfoVO.getTemplateVO().getBtmTypeId()
+			R<List<Menu>> buttonListR = iSysClient.getMenuButtonByType(codeClassifyOid, functionId, "data_auth");
+			if(!buttonListR.isSuccess()){
+				throw new ServiceException("鑾峰彇鎸夐挳鎺堟潈鍒楄〃澶辫触锛屽師鍥狅細"+buttonListR.getMsg());
+			}
+			List<Menu> buttonVOS = buttonListR.getData();
+
 			List<SmOperationVO> operationVOS = new ArrayList<>();
 			if (!CollectionUtils.isEmpty(buttonVOS)) {
 				for (int i = 0; i < buttonVOS.size(); i++) {
@@ -4352,8 +4424,8 @@
 					if (cboMap.containsKey(oid)) {
 						CodeAllCode codeAllCode = cboMap.get(oid);
 						codeAllCode.setId(baseModel.getId());
-						// codeAllCode.setLastModifier(AuthUtil.getUser().getUserName());
-						codeAllCode.setLastModifier(AuthUtil.getUser().getAccount());
+						// 涓绘暟鎹帹閫佸舰寮忥紝鏄嬁涓嶅埌鐢ㄦ埛淇℃伅鐨�
+						codeAllCode.setLastModifier(Func.isBlank(AuthUtil.getUserAccount()) ? applyCodeUserAccount:AuthUtil.getUserAccount());
 						codeAllCode.setLastModifyTime(new Date());
 						codeAllCode.setLcStatus(baseModel.getLcStatus());
 						newCodeAllCodeList.add(codeAllCode);
@@ -4676,7 +4748,13 @@
 		*/
 		Map<String, Object> nextRevision = commonsMapper.getCurrentRevision(listR.getData().get(0).getTableName(), fromBo.getNameOid());
 		R<RevisionRuleVO> revisionRuleVOR = revisionRuleClient.selectById(listR.getData().get(0).getRevisionRuleId());
-		String revisionval = nextRevision.get("REVISIONVAL").toString();
+		String revisionval = "";
+		try{
+			revisionval = nextRevision.get("REVISIONVAL").toString();
+		}catch (Exception e){
+			throw new ServiceException("涓氬姟鏁版嵁鐗堟鍊艰幏鍙栧嚭閿�,鍘熷洜锛�" + e.getMessage());
+		}
+
 		// 鏈煡璇㈠埌鐗堟湰瑙勫垯锛岄粯璁ょ洿鎺ョ粰澶х増鏈姞涓�
 		if (!revisionRuleVOR.isSuccess() || Func.isEmpty(revisionRuleVOR.getData())) {
 			revisionval = String.valueOf((Integer.parseInt(revisionval) + 1));

--
Gitblit v1.9.3