From 73d19e9c15962b0897740c62ba67aa1a01d44968 Mon Sep 17 00:00:00 2001
From: xiejun <xj@2023>
Date: 星期五, 25 八月 2023 09:09:26 +0800
Subject: [PATCH] 统一接口编码申请同时多条关键属性一样的数据申请编码返回值的处理

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 53 insertions(+), 5 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 672fade..b0e21bf 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
@@ -1962,6 +1962,7 @@
 		CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList);
 		Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList();
 		Set<String> keyAttrRepeatRowIndexList = keyResultVO.getKeyAttrRepeatRowIndexList();
+		Map<String,List<String>>keyAttrOkOidTORepeatOidMap= keyResultVO.getKeyAttrOkOidTORepeatOidMap();
 		if(!CollectionUtils.isEmpty(selfRepeatRowIndexList)){
 			selfRepeatRowIndexList.stream().forEach(rowIndex->{
                /* //浼犲叆鏁版嵁涔嬮棿鍏抽敭灞炴�х殑鏍¢獙
@@ -2064,8 +2065,8 @@
 							String lcstatus =newCbo.getLcStatus();
 							String newOid =newCbo.getOid();
 							Date ts =newCbo.getTs();
-							groupCode=newCbo.getData().get("GROUPCODE");
-							code=newCbo.getId();
+							code = StringUtils.isBlank(newCbo.getId())?"":newCbo.getId();
+							groupCode=newCbo.getData().getOrDefault("GROUPCODE","");
 							String lastmodifier=newCbo.getLastModifier();
 							if (lcstatus!=null&&!lcstatus.equals(CodeDefaultLC.RELEASED.getValue())) {
 								newCbo.setOid(newOid);
@@ -2136,8 +2137,8 @@
 				// if(!isProcess){
 				dataCBOList.stream().forEach(needSaveCbo->{
 					XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO();
-					String code=needSaveCbo.getId();
-					String groupCode=needSaveCbo.getData().getOrDefault("GROUPCODE","");
+					String code=StringUtils.isBlank(needSaveCbo.getId())?" ":needSaveCbo.getId();
+					String groupCode=needSaveCbo.getData().getOrDefault("GROUPCODE"," ");
 					//resultDataObjectDetailDO.setCode(needSaveCbo.getId());
 					String msg="鐢宠缂栫爜鎴愬姛";
 					String oid=needSaveCbo.getOid();
@@ -2157,6 +2158,9 @@
 					resultDataObjectDetailDO.setErrorid("0");
 					resultDataObjectDetailDO.setMsg(msg);
 					resultDataObjectDetailDOs.add(resultDataObjectDetailDO);
+					//澶勭悊浼犻�佺殑鏁版嵁涓叧閿睘鎬ч噸澶嶇殑锛岀洿鎺ユ嬁鍒板凡缁忕敵璇峰埌缂栫爜鐨勬暟鎹紪鐮佺洿鎺ュ皢璧嬬粰鍏抽敭灞炴�ч噸澶嶇殑鏁版嵁
+					LinkedList<XMLResultDataObjectDetailDO> repeatDataObjectDetailDOS=handleApplyDataKeyAttrRepeat(keyAttrOkOidTORepeatOidMap,codeOidToSystemOidMap,needSaveCbo,isCodeOrGroupCode);
+					resultDataObjectDetailDOs.addAll(repeatDataObjectDetailDOS);
 				});
                /* }else{
                     needSaveCboList.stream().forEach(needSaveCbo->{
@@ -2195,6 +2199,50 @@
 
 	}
 
+	/***
+	 *缁欏悓涓�鎵圭敵璇风紪鐮佸瓨鍦ㄥ叧閿睘鎬х殑鏁版嵁璧嬩笂涓�鑷寸紪鐮�
+	 * @param keyAttrOkOidTORepeatOidMap 涓�鎵圭敵璇锋暟鎹叧閿睘鎬т竴鑷寸殑閲嶅鏁版嵁鏄犲皠鍏崇郴
+	 * @param codeOidToSystemOidMap
+	 * @param needSaveCbo
+	 * @param isCodeOrGroupCode
+	 */
+	private LinkedList<XMLResultDataObjectDetailDO> handleApplyDataKeyAttrRepeat(Map<String,List<String>>keyAttrOkOidTORepeatOidMap,Map<String,String> codeOidToSystemOidMap,BaseModel needSaveCbo,boolean isCodeOrGroupCode){
+		LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs=new LinkedList<>();
+		String oid=needSaveCbo.getOid();
+		if(keyAttrOkOidTORepeatOidMap.containsKey(oid)){
+			List<String> repeatOidList= keyAttrOkOidTORepeatOidMap.get(oid);
+			if(!CollectionUtils.isEmpty(repeatOidList)){
+				String sourceNewOid=needSaveCbo.getOid();
+				String sourceOid=sourceNewOid;
+				if(codeOidToSystemOidMap.containsKey(oid)){
+					sourceOid=codeOidToSystemOidMap.get(oid);
+				}
+				String code=StringUtils.isBlank(needSaveCbo.getId())?" ":needSaveCbo.getId();
+				String groupCode=needSaveCbo.getData().getOrDefault("GROUPCODE"," ");
+				String finalSourceOid = sourceOid;
+				repeatOidList.stream().forEach(repeatOid->{
+					if(codeOidToSystemOidMap.containsKey(repeatOid)){
+						XMLResultDataObjectDetailDO repeatresultDataObjectDetailDO=new XMLResultDataObjectDetailDO();
+						String repeatSourceOid=codeOidToSystemOidMap.get(repeatOid);
+						String repeatMsg="姝ゆ暟鎹笌鐢宠鐨勭紪鐮佹暟鎹甶d涓恒��"+ finalSourceOid +"銆戠殑鍏抽敭灞炴�т竴鑷达紝鍒欏彇鐩稿悓缂栫爜";
+						if(isCodeOrGroupCode) {
+							if(StringUtils.isBlank(groupCode)){
+								repeatMsg="鐢宠鐨勭紪鐮佺被鍨嬩负闆嗗洟鐮侊紝绛夊緟闆嗗洟缂栫爜璧嬪��";
+							}
+							repeatresultDataObjectDetailDO.setCode(groupCode);
+						}else{
+							repeatresultDataObjectDetailDO.setCode(code);
+						}
+						repeatresultDataObjectDetailDO.setId(repeatSourceOid);
+						repeatresultDataObjectDetailDO.setErrorid("0");
+						repeatresultDataObjectDetailDO.setMsg(repeatMsg);
+						resultDataObjectDetailDOs.add(repeatresultDataObjectDetailDO);
+					}
+				});
+			}
+		}
+		return  resultDataObjectDetailDOs;
+	}
 	/***
 	 * 闆嗘垚鎵归噺鍚屾鏇存柊鎺ュ彛
 	 * @param codeClassifyVO;
@@ -3878,7 +3926,7 @@
 			if(rowIndexKeyStringMap.containsValue(keyString) && StringUtils.isNotBlank(keyString)){
 				selfRepeatRowIndexList.add(rowIndex);
 				String okOid=okOidKeyStringMap.getOrDefault(keyString,"");
-				if(StringUtils.isBlank(okOid)){
+				if(StringUtils.isNotBlank(okOid)){
 					List<String>newOidList=new ArrayList<>();
 					newOidList.add(oid);
 					if(keyAttrOkOidTORepeatOidMap.containsKey(okOid)){

--
Gitblit v1.9.3