From b28da4c353e50fc2491c733889fef5f79e5926f2 Mon Sep 17 00:00:00 2001
From: xiejun <xj@2023>
Date: 星期四, 24 八月 2023 16:19:00 +0800
Subject: [PATCH] 关于集成配置需求更改

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java |  146 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 99 insertions(+), 47 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 f19ae9b..dd16e4d 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,7 +3,6 @@
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.nacos.common.utils.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.vci.file.util.VciZipUtil;
 import com.vci.ubcs.code.bo.AttributeValue;
 import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO;
 import com.vci.ubcs.code.bo.CodeTemplateAttrSqlBO;
@@ -21,6 +20,7 @@
 import com.vci.ubcs.code.vo.webserviceModel.attrmap.DataObjectVO;
 import com.vci.ubcs.code.vo.webserviceModel.attrmap.RowDatas;
 import com.vci.ubcs.code.vo.webserviceModel.result.xml.XMLResultDataObjectDetailDO;
+import com.vci.ubcs.file.util.VciZipUtil;
 import com.vci.ubcs.omd.feign.IBtmTypeClient;
 import com.vci.ubcs.omd.feign.IWebSecretClient;
 import com.vci.ubcs.omd.vo.BtmTypeVO;
@@ -52,6 +52,7 @@
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springblade.core.redis.cache.BladeRedis;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -187,38 +188,40 @@
 			//鍙傜収鐨勮嚜琛岃緭鍏ュ悕绉�
 			//鍒嗙被娉ㄥ叆鐨勪笉鐢紝閮芥槸瀵煎叆鍚庤嚜鍔ㄥ鐞嗙殑
 			//缂栫爜锛岀姸鎬佺瓑瀛楁涓嶅鍏�
-			List<CodeClassifyTemplateAttrVO> templateAttrVOS = templateVO.getAttributes().stream().filter(s ->
-				!DEFAULT_ATTR_LIST.contains(s.getId())
-					&& StringUtils.isBlank(s.getComponentRule())
-					&& StringUtils.isBlank(s.getClassifyInvokeAttr())
-					&& (VciBaseUtil.getBoolean(s.getFormDisplayFlag()))
-			).collect(Collectors.toList());
-			if(CollectionUtils.isEmpty(templateAttrVOS)){
-				throw new VciBaseException("妯℃澘娌℃湁閰嶇疆浠讳綍銆愯〃鍗曟樉绀恒�戜负銆愭槸銆戠殑灞炴��");
-			}
-			templateAttrVOS.stream().forEach(codetemplateAttr ->{
-				String field=codetemplateAttr.getId();
-				String name=codetemplateAttr.getName();
-				CodeClassifyTemplateAttrVO codeBaseAttributeDTO=new CodeClassifyTemplateAttrVO();
-				boolean res=(StringUtils.isNotBlank(codetemplateAttr.getAttributeGroup())&& codetemplateAttr.getAttributeGroup().equals(BATCHADD_EXCEPORT_ATTR_TYPE))//鍩烘湰灞炴�у瓧娈垫樉绀�
-					||(StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag())&&Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag()))//鍏抽敭灞炴�х殑瀛樺叆
-					||(StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag())&&Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())) //鐩镐技灞炴�х殑瀛樺叆
-					||(StringUtils.isNotBlank(codetemplateAttr.getRequireFlag())&&Boolean.parseBoolean(codetemplateAttr.getRequireFlag()));
-				if(allFieldToOutNameMap.containsKey(name)){//濡傛灉瀛樺湪鐨勮瘽鍒欓渶瑕佹牴鎹叿浣撶殑鍘昏祴鍊�
-					codeBaseAttributeDTO=  allFieldToOutNameMap.get(name);
-					if(StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag())&&Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag())){
-						codeBaseAttributeDTO.setKeyAttrFlag(codetemplateAttr.getKeyAttrFlag());//灞炴�у叧閿睘鎬�
-					}
-					if(StringUtils.isNotBlank(codetemplateAttr.getRequireFlag())&&Boolean.parseBoolean(codetemplateAttr.getRequireFlag())){
-						codeBaseAttributeDTO.setRequireFlag(codetemplateAttr.getRequireFlag());//灞炴�у繀濉」
-					}
-					if(StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag())&&Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())){
-						codeBaseAttributeDTO.setSameRepeatAttrFlag(codetemplateAttr.getSameRepeatAttrFlag());//灞炴�х浉浼煎睘鎬�
-					}
-				}else if(res){
-					allFieldToOutNameMap.put(name,codetemplateAttr);
+			if(!CollectionUtils.isEmpty(templateVO.getAttributes())) {
+				List<CodeClassifyTemplateAttrVO> templateAttrVOS = templateVO.getAttributes().stream().filter(s ->
+					!DEFAULT_ATTR_LIST.contains(s.getId())
+						&& StringUtils.isBlank(s.getComponentRule())
+						&& StringUtils.isBlank(s.getClassifyInvokeAttr())
+						&& (VciBaseUtil.getBoolean(s.getFormDisplayFlag()))
+				).collect(Collectors.toList());
+				if(CollectionUtils.isEmpty(templateAttrVOS)){
+					throw new VciBaseException("妯℃澘娌℃湁閰嶇疆浠讳綍銆愯〃鍗曟樉绀恒�戜负銆愭槸銆戠殑灞炴��");
 				}
-			});
+				templateAttrVOS.stream().forEach(codetemplateAttr -> {
+					String field = codetemplateAttr.getId();
+					String name = codetemplateAttr.getName();
+					CodeClassifyTemplateAttrVO codeBaseAttributeDTO = new CodeClassifyTemplateAttrVO();
+					boolean res = (StringUtils.isNotBlank(codetemplateAttr.getAttributeGroup()) && codetemplateAttr.getAttributeGroup().equals(BATCHADD_EXCEPORT_ATTR_TYPE))//鍩烘湰灞炴�у瓧娈垫樉绀�
+						|| (StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag()))//鍏抽敭灞炴�х殑瀛樺叆
+						|| (StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())) //鐩镐技灞炴�х殑瀛樺叆
+						|| (StringUtils.isNotBlank(codetemplateAttr.getRequireFlag()) && Boolean.parseBoolean(codetemplateAttr.getRequireFlag()));
+					if (allFieldToOutNameMap.containsKey(name)) {//濡傛灉瀛樺湪鐨勮瘽鍒欓渶瑕佹牴鎹叿浣撶殑鍘昏祴鍊�
+						codeBaseAttributeDTO = allFieldToOutNameMap.get(name);
+						if (StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag())) {
+							codeBaseAttributeDTO.setKeyAttrFlag(codetemplateAttr.getKeyAttrFlag());//灞炴�у叧閿睘鎬�
+						}
+						if (StringUtils.isNotBlank(codetemplateAttr.getRequireFlag()) && Boolean.parseBoolean(codetemplateAttr.getRequireFlag())) {
+							codeBaseAttributeDTO.setRequireFlag(codetemplateAttr.getRequireFlag());//灞炴�у繀濉」
+						}
+						if (StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())) {
+							codeBaseAttributeDTO.setSameRepeatAttrFlag(codetemplateAttr.getSameRepeatAttrFlag());//灞炴�х浉浼煎睘鎬�
+						}
+					} else if (res) {
+						allFieldToOutNameMap.put(name, codetemplateAttr);
+					}
+				});
+			}
 		});
 		//鏁寸悊濂芥墍鏈夋ā鏉块渶瑕佸啓鍏xecl鐨勫睘鎬т俊鎭�
 		Workbook workbook = new HSSFWorkbook();
@@ -1489,6 +1492,20 @@
 		conditionMap.put("codeclsfpath","*" + exportAttrDTO.getCodeClassifyOid() + "*");
 		conditionMap.put("lastr", "1");
 		conditionMap.put("lastv", "1");
+
+		R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Arrays.asList(btmTypeId));
+		String tableName = "";
+		if(listR.isSuccess() && !listR.getData().isEmpty()){
+			tableName = Func.isNotBlank(listR.getData().get(0).getTableName()) ? listR.getData().get(0).getTableName():VciBaseUtil.getTableName(btmTypeId);
+		}else{
+			tableName = VciBaseUtil.getTableName(btmTypeId);
+		}
+
+		String countSql = "select count(*) from " + tableName +" where 1=1" +
+			" and lastr = '1'" +
+			" and lastv='1'" +
+			" and codeclsfpath like '%" + exportAttrDTO.getCodeClassifyOid() + "%'";
+
 		//鍏堟煡璇㈡�绘暟
 		int total = 0;
 		if(exportAttrDTO.getEndPage()!=null && exportAttrDTO.getEndPage()>0
@@ -1502,10 +1519,11 @@
 				thisPage.setOrder(exportAttrDTO.getOrder());
 				thisPage.addDefaultDesc("createTime");
 
-				//total += boService.queryCount(btmTypeId, conditionMap);
+				total += commonsMapper.queryCountBySql(countSql);
 			}
 		}else{
-			//total=boService.queryCount(btmTypeId, conditionMap);
+
+			total = commonsMapper.queryCountBySql(countSql);
 		}
 		List<String> selectFieldList = new ArrayList<>();
 		if(!CollectionUtils.isEmpty(exportAttrDTO.getAttrIdIndexMap())){
@@ -1881,7 +1899,7 @@
 	 * @return 鏈夐敊璇俊鎭殑excel
 	 */
 	@Override
-	public void batchSyncApplyCode(CodeOrderDTO orderDTO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs) {
+	public void batchSyncApplyCode(CodeOrderDTO orderDTO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs,boolean isCodeOrGroupCode) {
 		Map<String,String> errorMap=new HashMap<>();
 		VciBaseUtil.alertNotNull(orderDTO,"缂栫爜鐢宠鐩稿叧鐨勬暟鎹�",orderDTO.getCodeClassifyOid(),"涓婚搴撳垎绫讳富閿�");
 		CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
@@ -2001,10 +2019,15 @@
 						sourceOid=codeOidToSystemOidMap.get(oid);
 					}
 					String code="";
+					String groupCode="";
 					String errorid="103";
 					String mes=errorMap.get(rowIndex);
 					XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO();
-					resultDataObjectDetailDO.setCode(code);
+					if(isCodeOrGroupCode){
+						resultDataObjectDetailDO.setCode(groupCode);
+					}else{
+						resultDataObjectDetailDO.setCode(code);
+					}
 					resultDataObjectDetailDO.setId(sourceOid);
 					resultDataObjectDetailDO.setErrorid(errorid);
 					resultDataObjectDetailDO.setMsg(mes);
@@ -2030,6 +2053,7 @@
 						String oid = cbo.getOid();
 						String sourceOid = oid;
 						String code = "";
+						String groupCode="";
 						String errorid = "201";
 						if(codeOidToSystemOidMap.containsKey(oid)){
 							sourceOid=codeOidToSystemOidMap.get(oid);
@@ -2040,22 +2064,35 @@
 							String lcstatus =newCbo.getLcStatus();
 							String newOid =newCbo.getOid();
 							Date ts =newCbo.getTs();
+							groupCode=newCbo.getData().get("GROUPCODE");
 							code=newCbo.getId();
 							String lastmodifier=newCbo.getLastModifier();
-							if (!lcstatus.equals(CodeDefaultLC.RELEASED.getValue())) {
+							if (lcstatus!=null&&!lcstatus.equals(CodeDefaultLC.RELEASED.getValue())) {
 								newCbo.setOid(newOid);
 								newCbo.setLastModifier(lastmodifier);
-								newCbo.setId(code);
+								/*if(isCodeOrGroupCode) {
+									newCbo.setId(code);
+								}else{
+									newCbo.getData().put("groupcode",groupCode);
+								}*/
 								newCbo.setTs(ts);
 								cbo.setLastModifier(cbo.getLastModifier());
 								editBoList.add(newCbo);
 							}
 							String mes = errorKeyMap.get(rowIndex);
 							XMLResultDataObjectDetailDO resultDataObjectDetailDO = new XMLResultDataObjectDetailDO();
-							resultDataObjectDetailDO.setCode(code);
+							if(isCodeOrGroupCode) {
+								if(StringUtils.isBlank(groupCode)){
+									mes+="锛涚敵璇风殑缂栫爜绫诲瀷涓洪泦鍥㈢爜锛岀瓑寰呴泦鍥㈢紪鐮佽祴鍊�";
+								}
+								resultDataObjectDetailDO.setCode(groupCode);
+							}else{
+								resultDataObjectDetailDO.setCode(code);
+							}
 							resultDataObjectDetailDO.setId(sourceOid);
 							resultDataObjectDetailDO.setErrorid(errorid);
 							resultDataObjectDetailDO.setMsg(mes);
+
 							resultDataObjectDetailDOs.add(resultDataObjectDetailDO);
 						}
 					}
@@ -2099,15 +2136,26 @@
 				// if(!isProcess){
 				dataCBOList.stream().forEach(needSaveCbo->{
 					XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO();
-					resultDataObjectDetailDO.setCode(needSaveCbo.getId());
+					String code=needSaveCbo.getId();
+					String groupCode=needSaveCbo.getData().getOrDefault("GROUPCODE","");
+					//resultDataObjectDetailDO.setCode(needSaveCbo.getId());
+					String msg="鐢宠缂栫爜鎴愬姛";
 					String oid=needSaveCbo.getOid();
 					String sourceOid=oid;
 					if(codeOidToSystemOidMap.containsKey(oid)){
 						sourceOid=codeOidToSystemOidMap.get(oid);
 					}
+					if(isCodeOrGroupCode) {
+						if(StringUtils.isBlank(groupCode)){
+							msg="鐢宠鐨勭紪鐮佺被鍨嬩负闆嗗洟鐮侊紝绛夊緟闆嗗洟缂栫爜璧嬪��";
+						}
+						resultDataObjectDetailDO.setCode(groupCode);
+					}else{
+						resultDataObjectDetailDO.setCode(code);
+					}
 					resultDataObjectDetailDO.setId(sourceOid);
 					resultDataObjectDetailDO.setErrorid("0");
-					resultDataObjectDetailDO.setMsg("鐢宠缂栫爜鎴愬姛");
+					resultDataObjectDetailDO.setMsg(msg);
 					resultDataObjectDetailDOs.add(resultDataObjectDetailDO);
 				});
                /* }else{
@@ -2184,7 +2232,7 @@
 		String tableName ="";
 		try {
 			R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId());
-			if(r.getCode()!=200) {
+			if(!r.isSuccess()) {
 				throw new Throwable(r.getMsg());
 			}
 			BtmTypeVO btmTypeVO = r.getData();
@@ -3292,7 +3340,7 @@
 		String tableName ="";
 		try {
 			R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId());
-			if(r.getCode()!=200) {
+			if(!r.isSuccess()) {
 				throw new Throwable(r.getMsg());
 			}
 			BtmTypeVO btmTypeVO = r.getData();
@@ -3626,7 +3674,8 @@
 		CodeImportResultVO resultVO = new CodeImportResultVO();
 		resultVO.setKeyAttrRuleInfo(String.format(keyRuleVO ==null?"":"鏌ヨ瑙勫垯锛氬幓闄ょ┖鏍�--{0},蹇界暐澶у皬鍐�--{1},蹇界暐鍏ㄥ崐瑙�--{2},蹇界暐鍏ㄩ儴绌烘牸--{3}",
 			new String[]{trim?"鏄�":"鍚�",ignoreCase?"鏄�":"鍚�",ignoreWidth?"鏄�":"鍚�",trimAll?"鏄�":"鍚�"}));
-		resultVO.setSelfRepeatRowIndexList(getSelfRepeatRowIndex(ketAttrMap,cboList,keyRuleVO));
+		//resultVO.setSelfRepeatRowIndexList(getSelfRepeatRowIndex(ketAttrMap,cboList,keyRuleVO));
+		getSelfRepeatRowIndex(ketAttrMap,cboList,keyRuleVO,resultVO);
 		if(!CollectionUtils.isEmpty(resultVO.getSelfRepeatRowIndexList())){
 			//鎴戜滑绉婚櫎鏈韩閲嶅鐨勬暟鎹�
 			cboList = cboList.stream().filter(s->!resultVO.getSelfRepeatRowIndexList().contains(s.getAttributeValue(IMPORT_ROW_INDEX))).collect(Collectors.toList());
@@ -3785,9 +3834,10 @@
 	 * @param keyRuleVO 鍏抽敭灞炴�ф帶鍒惰鍒�
 	 * @return 閲嶅鐨勮鍙�
 	 */
-	private Set<String> getSelfRepeatRowIndex(Map<String/**灞炴�х殑缂栧彿**/, CodeClassifyTemplateAttrVO> ketAttrMap,
-											  List<ClientBusinessObject> dataList,CodeKeyAttrRepeatVO keyRuleVO){
+	private void getSelfRepeatRowIndex(Map<String/**灞炴�х殑缂栧彿**/, CodeClassifyTemplateAttrVO> ketAttrMap,
+											  List<ClientBusinessObject> dataList,CodeKeyAttrRepeatVO keyRuleVO,CodeImportResultVO resultVO){
 		Set<String> selfRepeatRowIndexList = new CopyOnWriteArraySet<>();
+		Map<String,List<String>> keyAttrOkOidTORepeatOidMap=new HashMap<>();
 		boolean trimAll =keyRuleVO ==null?false: VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag());
 		//鍏ㄩ儴鍘荤┖鐨勪紭鍏堢骇澶т簬鍘荤┖
 		boolean trim =keyRuleVO ==null?false:  VciBaseUtil.getBoolean(keyRuleVO.getIgnorespaceflag());
@@ -3828,7 +3878,8 @@
 			}
 		});
 		//鍥犱负鍙槸鍏抽敭灞炴�ч噸澶嶏紝鎵�浠ユ垜浠笉鑳介噸澶嶇殑澶氭潯閫変竴鏉℃潵鎶ラ敊
-		return selfRepeatRowIndexList;
+		resultVO.setKeyAttrRepeatRowIndexList(selfRepeatRowIndexList);
+		resultVO.setKeyAttrOkOidTORepeatOidMap(keyAttrOkOidTORepeatOidMap);
 	}
 	/**
 	 * excel鐨勬爣棰樹笂鑾峰彇瀛楁鎵�鍦ㄧ殑浣嶇疆
@@ -4289,4 +4340,5 @@
 			}
 		}
 	}
+
 }

--
Gitblit v1.9.3