From de9b95a2f14d42bcde076aeb32f1e1c4396b67f4 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期一, 18 九月 2023 10:35:02 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java |  102 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 93 insertions(+), 9 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 3c693e1..aa73ec6 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
@@ -16,6 +16,7 @@
 import com.vci.ubcs.code.enumpack.*;
 import com.vci.ubcs.code.mapper.CommonsMapper;
 import com.vci.ubcs.code.service.*;
+import com.vci.ubcs.code.util.ClientBusinessObject;
 import com.vci.ubcs.code.vo.CodeKeyAttrRepeatVO;
 import com.vci.ubcs.code.vo.CodeReferConfigVO;
 import com.vci.ubcs.code.vo.pagemodel.UITableFieldVO;
@@ -56,6 +57,7 @@
 import com.vci.ubcs.system.user.feign.IUserClient;
 import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
 import oracle.sql.TIMESTAMP;
+import org.aspectj.apache.bcel.classfile.Code;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springblade.core.cache.utils.CacheUtil;
@@ -466,7 +468,7 @@
                 if (!CodeLevelTypeEnum.MIN.getValue().equalsIgnoreCase(attrVO.getClassifyInvokeLevel()) && !"min".equalsIgnoreCase(attrVO.getClassifyInvokeLevel())) {
                     //鎸囧畾浜嗗眰绾х殑
                     //娉ㄦ剰锛屽洜涓烘煡璇笂绾у垎绫诲嚭鏉ョ殑灞傜骇鏄�掑簭鐨勶紝鍗抽《灞傝妭鐐规槸鏈�澶х殑鍊�
-                    List<CodeClassifyVO> classifyVOS = classifyFullInfoBO.getParentClassifyVOs().stream().sorted(((o1, o2) -> o2.getDataLevel().compareTo(o1.getDataLevel()))).collect(Collectors.toList());
+                    List<CodeClassifyVO> classifyVOS = classifyFullInfoBO.getParentClassifyVOs().stream().sorted(((o1, o2) -> -o2.getDataLevel().compareTo(o1.getDataLevel()))).collect(Collectors.toList());
                     int level = VciBaseUtil.getInt(attrVO.getClassifyInvokeLevel());
                     if (classifyVOS.size() >= level && level > 0) {
                         classifyVO = classifyVOS.get(level - 1);
@@ -746,7 +748,29 @@
 		return dataList;
 	}
 
-    /**
+	/**
+	 * 鏍规嵁褰撳墠鐢宠缂栫爜鐨勫垎绫伙紝閫愬眰寰�涓婃牎楠屾槸鍚︾鍚堝睘浜庨厤缃殑涓殑鍒嗙被瀛愯妭鐐圭殑鍒�
+	 * 绫伙紝濡傛灉绗﹀悎锛屽垯璇ュ垎绫荤敵璇风殑缂栫爜涓洪泦鍥㈢爜杩斿洖true锛屽弽涔嬪垯涓轰紒涓氱紪鐮佽繑鍥瀎alse
+	 * @param parameter 浼犲叆鏁版嵁,classifyGroupCode:閰嶇疆鐨勪腑鐨勫垎绫婚《鑺傜偣锛宱id锛氶�夋嫨鑺傜偣鐨刼id
+	 */
+	@Override
+	public R checkGroupCode(Map<String, String> parameter) {
+		List<CodeClassify> codeClassifyList = classifyService.selectAllLevelParentByOid(parameter.get("oid"));
+		Set<String> configGroupCode = Arrays.stream(parameter.get("classifyGroupCode").split("#")).collect(Collectors.toSet());
+//		Boolean checkGroupFlag = false;//鏄惁鏌ヨ鍒伴厤缃殑椤跺眰鍒嗙被涓�
+		for (int i = codeClassifyList.size()-1; i >= 0; i--) {
+			if(configGroupCode.contains(codeClassifyList.get(i).getId())){
+//				checkGroupFlag = true;
+				return R.data("true");
+			}
+//			if(checkGroupFlag && parameter.get("nowApplyCode").equals(codeClassifyList.get(i).getId())){
+//				return R.data(true);
+//			}
+		}
+		return R.data("false");
+	}
+
+	/**
      * 灏佽鍏抽敭灞炴�х殑鏌ヨ璇彞
      *
      * @param value        褰撳墠鐨勫��
@@ -2778,7 +2802,7 @@
 				// 鏃ユ湡鐮佹璁剧疆榛樿鍊�
 				if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) {
 					try {
-						secVO.setCodeDateFormatStr(Func.format(new Date(),secVO.getCodeDateFormatStr()));
+						secVO.setCodeDateValue(Func.format(new Date(),secVO.getCodeDateFormatStr()));
 					}catch (Exception e){
 						throw new ServiceException("鏃ユ湡鐮佹鏃ユ湡鏍煎紡閰嶇疆鏈夎锛屽鑷磋浆鎹㈠嚭閿欙細"+e.getMessage());
 					}
@@ -2796,7 +2820,7 @@
 				// 鏃ユ湡鐮佹璁剧疆榛樿鍊�
 				if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) {
 					try {
-						secVO.setCodeDateFormatStr(Func.format(new Date(),secVO.getCodeDateFormatStr()));
+						secVO.setCodeDateValue(Func.format(new Date(),secVO.getCodeDateFormatStr()));
 					}catch (Exception e){
 						throw new ServiceException("鏃ユ湡鐮佹鏃ユ湡鏍煎紡閰嶇疆鏈夎锛屽鑷磋浆鎹㈠嚭閿欙細"+e.getMessage());
 					}
@@ -2818,7 +2842,7 @@
 			// 鏃ユ湡鐮佹璁剧疆榛樿鍊�
 			if (secVO.getSecType().equals(CodeSecTypeEnum.CODE_DATE_SEC.getValue())) {
 				try {
-					secVO.setCodeDateFormatStr(Func.format(new Date(),secVO.getCodeDateFormatStr()));
+					secVO.setCodeDateValue(Func.format(new Date(),secVO.getCodeDateFormatStr()));
 				}catch (Exception e){
 					throw new ServiceException("鏃ユ湡鐮佹鏃ユ湡鏍煎紡閰嶇疆鏈夎锛屽鑷磋浆鎹㈠嚭閿欙細"+e.getMessage());
 				}
@@ -2845,7 +2869,7 @@
         } else {
             if (CollectionUtils.isEmpty(fullInfoBO.getParentClassifyVOs())) {
                 //璇存槑宸茬粡鏄渶楂樺眰绾�,
-                throw new VciBaseException("褰撳墠涓婚搴撳垎绫伙紝浠ュ強瀹冪殑鎵�鏈夌殑涓婄骇鍒嗙被閮芥病鏈夎缃紪鐮佽鍒�");
+                throw new ServiceException("褰撳墠涓婚搴撳垎绫伙紝浠ュ強瀹冪殑鎵�鏈夌殑涓婄骇鍒嗙被閮芥病鏈夎缃紪鐮佽鍒�");
             }
             List<CodeClassifyVO> parentClassifyVOList = fullInfoBO.getParentClassifyVOs().stream().sorted((o1, o2) -> o1.getDataLevel().compareTo(o2.getDataLevel())).collect(Collectors.toList());
             //浠庢渶楂樼殑level寮�濮嬭幏鍙�
@@ -2857,7 +2881,7 @@
                 }
             }
             if (StringUtils.isBlank(codeRuleOid)) {
-                throw new VciBaseException("褰撳墠涓婚搴撳垎绫伙紝浠ュ強瀹冪殑鎵�鏈夌殑涓婄骇鍒嗙被閮芥病鏈夎缃紪鐮佽鍒�");
+                throw new ServiceException("褰撳墠涓婚搴撳垎绫伙紝浠ュ強瀹冪殑鎵�鏈夌殑涓婄骇鍒嗙被閮芥病鏈夎缃紪鐮佽鍒�");
             }
         }
         return ruleService.getObjectHasSecByOid(codeRuleOid);
@@ -3662,8 +3686,67 @@
 
         return R.success("鏇存柊鎴愬姛锛�");
     }
+	/**
+	 * 鏇存柊涓氬姟鏁版嵁鍚屾椂瀵圭爜鍊艰〃鏁版嵁鎿嶄綔鎺ュ彛
+	 *
+	 * @param btmType 涓氬姟绫诲瀷
+	 * @param baseModels      澶勭悊鏁版嵁
+	 * @return 澶勭悊鐘舵��
+	 */
+	@Transactional(rollbackFor = VciBaseException.class)
+	@Override
+	public R<Integer> updateBatchBtypeDatas(String btmType, List<BaseModel> baseModels) {
 
-    /**
+		//浣跨敤浼犲叆鐨勪笟鍔$被鍨嬫煡璇㈣〃
+		R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
+		if (!listR.isSuccess() || listR.getData().size() == 0) {
+			throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
+		}
+		//鑾峰彇褰撳墠涓氬姟绫诲瀷鎵�鏈夊瓧娈电敤鏉ュ仛瀵规瘮
+		R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getAllAttributeByBtmId(btmType);
+		if (!allAttributeByBtmId.isSuccess() || allAttributeByBtmId.getData().getAttributes().size() == 0) {
+			throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲瀛楁淇℃伅锛岃妫�鏌ワ紒");
+		}
+		Set<String> existFild = allAttributeByBtmId.getData().getAttributes().stream().map(btmTypeAttributeVO -> {
+			return btmTypeAttributeVO.getId();
+		}).collect(Collectors.toSet());
+		if(!CollectionUtils.isEmpty(baseModels)){
+			List<String> oidList=baseModels.stream().filter(data-> com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(data.getOid())).map(BaseModel::getOid).distinct().collect(Collectors.toList());
+			LambdaQueryWrapper<CodeAllCode> lqw = new LambdaQueryWrapper<>();
+			lqw.in(CodeAllCode::getCreateCodeOid,oidList);
+			List<CodeAllCode> codeAllCodeList= codeAllCodeService.selectByWrapper(lqw);
+			Map<String, CodeAllCode> cboMap = codeAllCodeList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getCreateCodeOid(), t -> t));
+			List<CodeAllCode> newCodeAllCodeList=new ArrayList<>();
+			//灏哹ean杞负map,mybatis缁熶竴澶勭悊
+			List<Map<String, String>> maps = new ArrayList<>();
+			try {
+				baseModels.stream().forEach(baseModel->{
+					String oid=baseModel.getOid();
+					try {
+						maps.add(VciBaseUtil.convertBean2Map(baseModel,existFild));
+					} catch (Exception e) {
+						throw new VciBaseException("绫诲瀷杞崲閿欒锛�" + e.getMessage());
+					}
+					if(cboMap.containsKey(oid)){
+						CodeAllCode codeAllCode=	cboMap.get(oid);
+						codeAllCode.setId(baseModel.getId());
+						codeAllCode.setLastModifier(AuthUtil.getUser().getUserName());
+						codeAllCode.setLastModifyTime(new Date());
+						codeAllCode.setLcStatus(baseModel.getLcStatus());
+						newCodeAllCodeList.add(codeAllCode);
+					}
+				});
+				commonsMapper.updateBatchByBaseModel(listR.getData().get(0).getTableName(), maps);
+				codeAllCodeService.saveOrUpdateBatch(newCodeAllCodeList);
+			} catch (Exception e) {
+				throw new VciBaseException("绫诲瀷杞崲閿欒锛�" + e.getMessage());
+			}
+
+		}
+		return R.success("鏇存柊鎴愬姛锛�");
+	}
+
+	/**
      * 鑾峰彇鍙傜収鐨勪俊鎭�
      *
      * @param referConfigVO 鍙傜収鐨勯厤缃�
@@ -3675,7 +3758,7 @@
         //浣跨敤涓氬姟绫诲瀷鏌ヨ
         R<BtmTypeVO> allAttributeByBtmId = btmTypeClient.getAllAttributeByBtmId(referConfigVO.getReferType());
         if (!allAttributeByBtmId.isSuccess()) {
-            throw new ServiceException("涓氬姟绫诲瀷feign鎺ュ彛璋冪敤閿欒锛�");
+            throw new ServiceException("涓氬姟绫诲瀷feign鎺ュ彛璋冪敤閿欒;"+allAttributeByBtmId.getMsg());
         }
         if (Func.isEmpty(allAttributeByBtmId.getData())) {
             throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
@@ -3702,6 +3785,7 @@
         if (listR.getData().isEmpty()) {
             throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
         }
+		// TODO:鍙傜収閰嶇疆鐨勬ā绯婃煡璇㈣繃婊ゆ潯浠舵殏鏈鐞�
         String namesql = "";
         if (StringUtils.isNotBlank(baseQueryObject.getConditionMap().get("name"))) {
             String s = baseQueryObject.getConditionMap().get("name");

--
Gitblit v1.9.3