From 300c96cbfb9a9cee605749e0b142205f415e17dc Mon Sep 17 00:00:00 2001
From: xiejun <xj@2023>
Date: 星期一, 28 八月 2023 07:46:14 +0800
Subject: [PATCH] 统一接口配置保存bug修复

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java |   45 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java
index b0e21bf..c81e986 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java
@@ -3,6 +3,7 @@
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.nacos.common.utils.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.vci.ubcs.code.applyjtcodeservice.feign.IMdmInterJtClient;
 import com.vci.ubcs.code.bo.AttributeValue;
 import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO;
 import com.vci.ubcs.code.bo.CodeTemplateAttrSqlBO;
@@ -11,6 +12,7 @@
 import com.vci.ubcs.code.entity.CodeAllCode;
 import com.vci.ubcs.code.enumpack.CodeDefaultLC;
 import com.vci.ubcs.code.enumpack.CodeLevelTypeEnum;
+import com.vci.ubcs.code.enumpack.sysIntegrationPushTypeEnum;
 import com.vci.ubcs.code.lifecycle.CodeAllCodeLC;
 import com.vci.ubcs.code.mapper.CommonsMapper;
 import com.vci.ubcs.code.service.*;
@@ -154,7 +156,11 @@
 	 */
 	@Autowired
 	private IBtmTypeClient btmTypeClient;
-
+	/***
+	 * 鐢宠闆嗗洟缂栫爜鏈嶅姟
+	 */
+	@Resource
+	private IMdmInterJtClient mdmInterJtClient;
 	/***
 	 * 瀵嗙骇鏈嶅姟
 	 */
@@ -2131,11 +2137,13 @@
 				allNeedSaveCboList.add(baseModel.getOid());
 			});
 			try {
+				List<String>applyGroupCodeIdList=new ArrayList<>();
 				productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(), dataCBOList);
 				//濡傛灉鏄紪鐮佺敓鎴愬け璐ワ紝鍒欑洿鎺ュ氨澶辫触浜嗭紝鍏朵粬鐨勫垽鏂嚭鏉ユ湁閿欒鐨勬垜浠兘缁熶竴杩斿洖鍒癳xcel閲岄潰
 				engineService.batchSaveSelectChar(templateVO, dataCBOList);
 				// if(!isProcess){
 				dataCBOList.stream().forEach(needSaveCbo->{
+
 					XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO();
 					String code=StringUtils.isBlank(needSaveCbo.getId())?" ":needSaveCbo.getId();
 					String groupCode=needSaveCbo.getData().getOrDefault("GROUPCODE"," ");
@@ -2143,6 +2151,7 @@
 					String msg="鐢宠缂栫爜鎴愬姛";
 					String oid=needSaveCbo.getOid();
 					String sourceOid=oid;
+					applyGroupCodeIdList.add(oid);
 					if(codeOidToSystemOidMap.containsKey(oid)){
 						sourceOid=codeOidToSystemOidMap.get(oid);
 					}
@@ -2178,6 +2187,13 @@
                     });
 
                 }*/
+				//鏄惁璋冪敤闆嗗洟鎺ュ彛鐢宠鎺ュ彛
+				if(isCodeOrGroupCode){
+					if(!CollectionUtils.isEmpty(applyGroupCodeIdList)) {
+						this.sendApplyGroupcode(applyGroupCodeIdList, classifyFullInfo.getTopClassifyVO().getId(), sysIntegrationPushTypeEnum.ACCPET_APPCODE.getValue());
+					}
+				}
+
 			}catch (Throwable e){
 				e.printStackTrace();
 				needSaveCboList.stream().forEach(needSaveCbo->{
@@ -2248,10 +2264,11 @@
 	 * @param codeClassifyVO;
 	 * @param dataObjectVO 鏁版嵁淇℃伅
 	 * @param resultDataObjectDetailDOs 閿欒淇℃伅
+	 * @param isCodeOrGroupCode 鏄惁鏇撮泦鍥㈢郴缁熸暟鎹�
 	 */
 	@Transactional(rollbackFor = VciBaseException.class)
 	@Override
-	public void batchSyncEditDatas(CodeClassifyVO codeClassifyVO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs) {
+	public void batchSyncEditDatas(CodeClassifyVO codeClassifyVO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs,boolean isCodeOrGroupCode) {
 		String errorid="";
 		String msg="";
 		//鏌ヨ鍒嗙被鍜屾ā鏉�
@@ -2276,8 +2293,8 @@
 		List<String> titleRowData = dataObjectVO.getColName();
 		Map<String/**涓枃鍚嶇О**/, String/**鑻辨枃鍚嶇О**/> attrNameIdMap = attrVOS.stream().collect(Collectors.toMap(s -> s.getName(), t -> t.getId().toLowerCase(Locale.ROOT), (o1, o2) -> o2));
 		getFieldIndexMap(titleRowData, attrNameIdMap, fieldIndexMap);
-		Map<String, String> cboOidMap = new HashMap<>();
-		cboOidMap.put("id", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0])) + ")");
+		//Map<String, String> cboOidMap = new HashMap<>();
+		//cboOidMap.put("id", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0])) + ")");
 		String tableName ="";
 		try {
 			R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId());
@@ -2459,6 +2476,13 @@
 				codeAllCodeService.saveBatch(codeAllCodeList);
 				if(deleteList.size()>0) {
 					commonsMapper.deleteByTaleAndOid(tableName, VciBaseUtil.array2String(deleteList.toArray(new String[]{})));
+				}
+				//鏄惁璋冪敤闆嗗洟鎺ュ彛鐢宠鎺ュ彛
+				if(isCodeOrGroupCode){
+					List<String> IdList=resultDataObjectDetailDOs.stream().filter(xMLResultDataObjectDetailDO-> com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(xMLResultDataObjectDetailDO.getId())).map(XMLResultDataObjectDetailDO::getId).distinct().collect(Collectors.toList());
+					if(!CollectionUtils.isEmpty(IdList)) {
+						this.sendApplyGroupcode(IdList, classifyFullInfo.getTopClassifyVO().getBtmTypeId(),sysIntegrationPushTypeEnum.ACCPET_EDITCODE.getValue());
+					}
 				}
 				errorid="0";
 				msg="鏇存柊/鐘舵�佹洿鏀�/鍒犻櫎鎴愬姛锛�";
@@ -4405,4 +4429,17 @@
 		}
 	}
 
+	/***
+	 * 鐢宠闆嗗洟缂栫爜
+	 * @param idList
+	 * @param btmName
+	 */
+	private void sendApplyGroupcode(List<String> idList,String btmName,String operationType){
+		String oids=VciBaseUtil.array2String(idList.toArray(new String[]{}));
+		if(operationType.equals(sysIntegrationPushTypeEnum.ACCPET_APPCODE.getValue())) {
+			mdmInterJtClient.applyGroupCode(oids,btmName);
+		}else if(operationType.equals(sysIntegrationPushTypeEnum.ACCPET_EDITCODE)){
+			mdmInterJtClient.receiveEditApply(oids,btmName);
+		}
+	}
 }

--
Gitblit v1.9.3