From a3c7b3f7a4778a777a78a72c968b0e172488df03 Mon Sep 17 00:00:00 2001
From: yuxc <653031404@qq.com>
Date: 星期二, 06 六月 2023 17:13:05 +0800
Subject: [PATCH] 1、对MDM服务的接口测试改动

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java |   99 +++++++++++++++++++++++++++++--------------------
 1 files changed, 59 insertions(+), 40 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 0cf501f..81ab0ca 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
@@ -13,7 +13,6 @@
 import com.vci.ubcs.code.dto.datapush.BaseModelDTO;
 import com.vci.ubcs.code.entity.*;
 import com.vci.ubcs.code.enumpack.*;
-import com.vci.ubcs.code.mapper.CodeOsbtmtypeMapper;
 import com.vci.ubcs.code.mapper.CodeWupinMapper;
 import com.vci.ubcs.code.mapper.CommonsMapper;
 import com.vci.ubcs.code.service.*;
@@ -21,6 +20,7 @@
 import com.vci.ubcs.code.vo.pagemodel.UITableFieldVO;
 import com.vci.ubcs.code.vo.pagemodel.UITablePageVO;
 import com.vci.ubcs.code.vo.pagemodel.*;
+import com.vci.ubcs.omd.feign.IAttributeClient;
 import com.vci.ubcs.omd.feign.IBtmTypeClient;
 import com.vci.ubcs.omd.feign.IEnumClient;
 import com.vci.ubcs.omd.feign.IRevisionRuleClient;
@@ -50,6 +50,7 @@
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.StringPool;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.Cache;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
@@ -90,28 +91,28 @@
 	 */
 	@Resource
 	private CodeClstemplateServiceImpl templateService;
-	/**
-	 * 妯℃澘鐨勬湇鍔�
-	 */
+
 	@Resource
-	private CodeOsbtmtypeMapper codeOsbtmtypeMapper;
-	@Resource
-	private CodeOsattributeServiceImpl attributeService;
+	private IAttributeClient attributeClient;
+
 	/**
 	 * 鐢熸垚缂栫爜鐨勬湇鍔�
 	 */
 	@Resource
 	private MdmProductCodeService productCodeService;
+
 	/**
 	 * 鍙緭鍙�夌殑鏈嶅姟
 	 */
 	@Resource
 	IDictBizClient iDictBizClient;
+
 	/**
 	 * 瀛楀吀鐨勬湇鍔�
 	 */
 	@Resource
 	IEnumClient enumClient;
+
 	/**
 	 * 鍏紡鐨勬湇鍔�
 	 */
@@ -316,10 +317,11 @@
 		List<String> oids = VciBaseUtil.str2List(baseModelDTO.getOid());
 //		List<ClientBusinessObject> cboList = boService.selectCBOByOidCollection(oids, baseModelDTO.getBtmname());
 		//鎻掍釜鐐� 涓氬姟绫诲瀷瀹屾垚鍚庨渶瑕佷慨鏀�
-		QueryWrapper<CodeOsbtmtypeEntity> wrapper = new QueryWrapper<>();
+		QueryWrapper<BtmTypeVO> wrapper = new QueryWrapper<>();
 		wrapper.eq("BTMNAME",baseModelDTO.getBtmname());
 		wrapper.in("OID",oids);
-		List<CodeOsbtmtypeEntity> cboList = codeOsbtmtypeMapper.selectList(wrapper);
+		// 寰呭畬鍠�
+		List<BtmTypeVO> cboList =  null;  // btmTypeClient.selectList(wrapper);
 		//杩橀渶瑕佷慨鏀筧llCode鐨勭敓鍛藉懆鏈�
 //		Map<String, String> conditionMap = new HashMap<>();
 		QueryWrapper<CodeAllCode> allCodeWrapper = new QueryWrapper<>();
@@ -331,16 +333,18 @@
 //		List<ClientBusinessObject> codeCbos = boService.queryCBO(MdmBtmTypeConstant.CODE_ALL_CODE, conditionMap);
 		// 鍥炴敹闇�瑕佷笟鍔℃暟鎹垹闄�
 		if (CodeDefaultLC.TASK_BACK.getValue().equals(baseModelDTO.getLcStatus())) {
-//			BatchCBO batchCBO = new BatchCBO();
-//			batchCBO.getDeleteCbos().addAll(cboList);
-			codeOsbtmtypeMapper.deleteBatchIds(cboList);
-//			boService.persistenceBatch(batchCBO);
-		} else {
-//			lifeCycleService.transCboStatus(cboList, baseModelDTO.getLcStatus());
-		}
-//		lifeCycleService.transCboStatus(codeCbos, baseModelDTO.getLcStatus());
-	}
+			// BatchCBO batchCBO = new BatchCBO();
+			// batchCBO.getDeleteCbos().addAll(cboList);
 
+			// 寰呭畬鍠�
+			//btmTypeClient.deleteBatchIds(cboList);
+
+			//boService.persistenceBatch(batchCBO);
+		} else {
+			// lifeCycleService.transCboStatus(cboList, baseModelDTO.getLcStatus());
+		}
+		// lifeCycleService.transCboStatus(codeCbos, baseModelDTO.getLcStatus());
+	}
 
 	/**
 	 * 鐢宠鍗曚竴缂栫爜
@@ -777,6 +781,11 @@
 			data.put(CODE_TEMPLATE_OID_FIELD,templateVO.getOid());
 			data.put(CODE_FULL_PATH_FILED,fullPath);
 			cbo.setData(data);
+			cbo.setOid(VciBaseUtil.getPk());
+			cbo.setCreateTime(new Date());
+			cbo.setLastModifyTime(new Date());
+			cbo.setCreator(AuthUtil.getUser().getUserName());
+			cbo.setLastModifier(AuthUtil.getUser().getUserName());
 //			cbo.setCodeclsfid(classifyFullInfo.getCurrentClassifyVO().getOid());
 //			cbo.setTemplateOid(templateVO.getOid());
 //			cbo.setCodeclsfpath(fullPath);
@@ -798,7 +807,7 @@
 			}
 
 			int secret = VciBaseUtil.getInt(String.valueOf(cbo.getSecretGrade()));
-			//鎻掍釜鐐癸紝鍚庣画鐪嬪瘑绾ф湇鍔℃槸鍚﹀彲鐢�
+			//鍚庣画鐪嬪瘑绾ф湇鍔℃槸鍚﹀彲鐢�
 //			if (secret == 0 || !secretService.checkDataSecret(secret)) {
 			if (secret == 0 ) {
 				Integer userSecret = VciBaseUtil.getCurrentUserSecret();
@@ -825,12 +834,14 @@
 			btmName = btmName.trim().toLowerCase();
 		}
 		try {
-			String keyPrefix = BTM_NAME.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON);
-			String finalBtmName = btmName;
-			return CacheUtil.get(BTM_INIT_CACHE, keyPrefix, btmName, () -> {
-				BaseModel baseModel = createBaseModel(finalBtmName);
-				return baseModel;
-			});
+			String keyPrefix = BTM_INIT_CACHE.concat(StringPool.COLON).concat(AuthUtil.getTenantId()).concat(StringPool.COLON);
+//			String finalBtmName = btmName;
+			Cache.ValueWrapper valueWrapper = CacheUtil.getCache(keyPrefix).get(keyPrefix.concat(String.valueOf(btmName)));
+			if(valueWrapper == null){
+				CacheUtil.getCache(keyPrefix).put(keyPrefix.concat(String.valueOf(btmName)), createBaseModel(btmName));
+				valueWrapper = CacheUtil.getCache(keyPrefix).get(keyPrefix.concat(String.valueOf(btmName)));
+			}
+			return (BaseModel) valueWrapper.get();
 		} catch (Exception e) {
 			logger.error("鍒涘缓涓氬姟绫诲瀷瀵硅薄",e);
 			throw new VciBaseException("initBtmError",new String[]{btmName});
@@ -1558,8 +1569,11 @@
 					referVO.setTextField("name");
 				}
 				//琛ㄩ渶瑕佹敼
+				//浣跨敤浼犲叆鐨勪笟鍔$被鍨嬫煡璇㈣〃
+				R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(referVO.getReferType()));
 //				String referTable = VciBaseUtil.getTableName(referVO.getReferType());
-				String referTable = "pl_code_wupin";
+				String referTable = listR.getData().get(0).getTableName();
+//				String referTable = "pl_code_classify";
 				String referTableNick = attrVO.getId() + "0";
 				String left = " left join " + referTable + " " + referTableNick + " on " + referTableNick + "." + referVO.getValueField() + " =  t." + attrVO.getId();
 				joinTableList.put(attrVO.getId(), left);
@@ -1575,11 +1589,12 @@
 				selectFieldList.add(referTableNick + "." + showFieldInSource + " as " + referShowField);
 			});
 		}
-		Optional.ofNullable(attributeService.getDefaultAttributeVOMap()).orElseGet(() -> new HashMap<>()).keySet().stream().forEach(attrId -> {
-			if (!selectFieldList.contains(attrId) && !"secretgrade".equalsIgnoreCase(attrId)) {
-				selectFieldList.add(attrId);
-			}
-		});
+		// 寰呭畬鍠�
+//		Optional.ofNullable(attributeService.getDefaultAttributeVOMap()).orElseGet(() -> new HashMap<>()).keySet().stream().forEach(attrId -> {
+//			if (!selectFieldList.contains(attrId) && !"secretgrade".equalsIgnoreCase(attrId)) {
+//				selectFieldList.add(attrId);
+//			}
+//		});
 		if (!selectFieldList.contains(CODE_FIELD)) {
 			selectFieldList.add(CODE_FIELD);
 		}
@@ -1649,7 +1664,10 @@
 		}
 		//瑕佹敼锛岃〃鏄庤幏鍙栨湁闂
 //		String tableName = VciBaseUtil.getTableName(btmType);
-		String tableName = "pl_code_wupin";
+//		String tableName = "pl_code_wupin";
+		R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
+//				String referTable = VciBaseUtil.getTableName(referVO.getReferType());
+		String tableName = listR.getData().get(0).getTableName();
 		String sql = "select " + selectFieldList.stream().map(s -> (s.contains(".") ? s : ("t." + s))).collect(Collectors.joining(","))
 			+ " from " + tableName + SPACE + "t" + SPACE
 			+ joinTableList.values().stream().collect(Collectors.joining(SPACE))
@@ -1782,9 +1800,10 @@
 	 */
 	private String getSqlByValue(String selectKey, String value, Map<String, CodeClassifyTemplateAttrVO> attrVOMap) {
 		StringBuilder sql = new StringBuilder();
-		if (!selectKey.contains(".") && (attrVOMap.containsKey(selectKey.toLowerCase(Locale.ROOT)) || attributeService.isDefaultAttr(selectKey) || selectKey.matches(RegExpConstant.LETTER))) {
-			sql.append("t.");
-		}
+		// 寰呭畬鍠�
+//		if (!selectKey.contains(".") && (attrVOMap.containsKey(selectKey.toLowerCase(Locale.ROOT)) || attributeService.isDefaultAttr(selectKey) || selectKey.matches(RegExpConstant.LETTER))) {
+//			sql.append("t.");
+//		}
 		if (value.startsWith(QueryOptionConstant.IN)) {
 			sql.append(selectKey)
 				.append(SPACE)
@@ -2856,11 +2875,11 @@
 		uiInfoVO.setLeaf(classifyService.countChildrenByClassifyOid(codeClassifyOid) == 0);
 		if (StringUtils.isNotBlank(functionId) && !"~".equalsIgnoreCase(functionId)) {
 			//鍔熻兘鎸夐挳鏈嶅姟杩樻湭瀹炵幇锛岀瓑瀹炵幇浜嗭紝鍦ㄨ繘琛岃皟鐢�
-			//List<SmOperationVO> operationVOS = operationService.listButtonByFunctionId(functionId);
+//			List<SmOperationVO> operationVOS = operationService.listButtonByFunctionId(functionId);
 //			if (operationVOS == null) {
 //				operationVOS = new ArrayList<>();
 //			}
-			//鏌ヨ鎵╁睍鎸夐挳
+//			//鏌ヨ鎵╁睍鎸夐挳
 //			List<CodeButtonVO> buttonVOS = listButtonInToolbarByClassifyOid(codeClassifyOid);
 //			if (!CollectionUtils.isEmpty(buttonVOS)) {
 //				for (int i = 0; i < buttonVOS.size(); i++) {
@@ -2870,8 +2889,8 @@
 //					operationVO.setUniqueFlag(buttonVO.getId());
 //					operationVO.setName(buttonVO.getName());
 //					operationVO.setAlias(operationVO.getName());
-//					operationVO.setExecuteJs(buttonVO.getExecutejs());
-//					operationVO.setIconCls(buttonVO.getIconcls());
+//					operationVO.setExecuteJs(buttonVO.getExecuteJs());
+//					operationVO.setIconCls(buttonVO.getIconCls());
 //					operationVOS.add(operationVO);
 //				}
 //			}
@@ -3008,7 +3027,7 @@
 		R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(boName));
 		String userName = AuthUtil.getUser().getUserName();
 		BaseModel bo = new BaseModel();
-		bo.setOid(VciBaseUtil.getPk());
+//		bo.setOid(VciBaseUtil.getPk());
 //		bo.setRevisionid(VciBaseUtil.getPk());
 //		bo.setNameoid(VciBaseUtil.getPk());
 		bo.setBtmname(boName);

--
Gitblit v1.9.3