From 156e136377680ac2dd5ad89735b7273db6f6d1d5 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期六, 24 二月 2024 20:27:02 +0800 Subject: [PATCH] 远程部署功能完善 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java | 124 +++++++++++++++++++++++++++++++++++++---- 1 files changed, 112 insertions(+), 12 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 525198e..b967ab5 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 @@ -12,6 +12,7 @@ import com.vci.ubcs.code.bo.CodeTemplateAttrSqlBO; import com.vci.ubcs.code.dto.*; import com.vci.ubcs.code.entity.CodeAllCode; +import com.vci.ubcs.code.entity.CodeSynonym; import com.vci.ubcs.code.enumpack.*; import com.vci.ubcs.code.lifecycle.CodeAllCodeLC; import com.vci.ubcs.code.mapper.CommonsMapper; @@ -67,6 +68,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; +import javax.xml.bind.ValidationEvent; import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; @@ -96,7 +98,6 @@ @Service @Slf4j public class MdmIOServiceImpl implements MdmIOService { - /** * 瀛楁 @@ -164,36 +165,45 @@ @Autowired private ICodeKeyAttrRepeatService keyRuleService; + @Autowired ICodeSynonymService codeSynonymService; + /** * 鍏紡鐨勬湇鍔� */ @Autowired private FormulaServiceImpl formulaService; + /** * 瑙勫垯鐨勬湇鍔� */ @Autowired private ICodeRuleService ruleService; + /** * 涓氬姟绫诲瀷鐨勬湇鍔� */ @Autowired private IBtmTypeClient btmTypeClient; + /*** * 鐢宠闆嗗洟缂栫爜鏈嶅姟 */ @Resource private IMdmInterJtClient mdmInterJtClient; + /*** * 瀵嗙骇鏈嶅姟 */ @Resource private IWebSecretClient secretService; + /** * 鏃ュ織淇濆瓨宸ュ叿绫� */ @Autowired private SaveLogUtil saveLogUtil; + + /** * 瀹㈡埛鐜板満excel涓鸿�佺増鏈紝瀵煎嚭鐨勬�绘暟闄愬埗涓�65535 @@ -959,9 +969,7 @@ //鏈�鍚庡紕缁勫悎瑙勫垯 batchSwitchComponentAttrOnOrder(attrVOS,allCboList); - Map<String, ClientBusinessObject> rowIndexCboMap = allCboList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getAttributeValue((IMPORT_ROW_INDEX)), t -> t)); - List<ClientBusinessObject> needSaveCboList = allCboList.stream().filter(cbo -> { String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); @@ -971,6 +979,7 @@ Map<String,String>resembleMap=new HashMap<>(); List<DataResembleVO> dataResembleVOS=new ArrayList<>(); String btmtypeid= classifyFullInfo.getTopClassifyVO().getBtmTypeId(); + //鐩镐技椤规煡璇㈣鍒� bathcResembleQuery(codeClassifyOid,templateVO,needSaveCboList,resembleMap,btmtypeid,dataResembleVOS); if(resembleMap.size()>0) { if(!CollectionUtils.isEmpty(dataResembleVOS)) { @@ -1280,6 +1289,7 @@ Map<String, String> resembleMap = new HashMap<>(); List<DataResembleVO> dataResembleVOS = new ArrayList<>(); String btmtypeid = classifyFullInfo.getTopClassifyVO().getBtmTypeId(); + // 鐩镐技椤规煡璇� bathcResembleQuery(templateVO.getCodeclassifyoid(), templateVO, needSaveCboList, resembleMap, btmtypeid, dataResembleVOS); if (resembleMap.size() > 0) { if (!CollectionUtils.isEmpty(dataResembleVOS)) { @@ -1287,6 +1297,7 @@ createRedisDatas(uuid + "-resemble", templateVO, rowIndexCboMap, dataSet, fieldIndexMap, resembleMap, false); } } + //鐢熸垚class缂撳瓨 Map<String, String> rowIndexClsOidMap = cboList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getAttributeValue((IMPORT_ROW_INDEX)), t -> t.getAttributeValue(CODE_CLASSIFY_OID_FIELD))); createRedisByCodeClassify(uuid + "-class",templateVO,dataSet,fieldIndexMap,true); @@ -1759,6 +1770,7 @@ Map<String,String>resembleMap=new HashMap<>(); List<DataResembleVO> dataResembleVOS=new ArrayList<>(); String btmtypeid= classifyFullInfo.getTopClassifyVO().getBtmTypeId(); + //鐩镐技椤规煡璇� bathcResembleQuery(orderDTO.getCodeClassifyOid(),templateVO,needSaveCboList,resembleMap,btmtypeid,dataResembleVOS); if(resembleMap.size()>0) { isCreateUUid=true; @@ -4370,7 +4382,7 @@ } } /** - * 鏍¢獙鍏抽敭灞炴�� + * 鏍¢獙鍏抽敭灞炴�э紝鍜岃繎涔夎瘝鏌ヨ瑙勫垯 * @param classifyFullInfo 鍒嗙被鐨勫叏閮ㄤ俊鎭� * @param templateVO 妯℃澘鐨勫唴瀹癸紝蹇呴』鍖呭惈妯℃澘灞炴�� * @param cboList 鎵归噺鐨勬暟鎹� @@ -4382,7 +4394,16 @@ CodeKeyAttrRepeatVO keyRuleVO = keyRuleService.getRuleByClassifyFullInfo(classifyFullInfo); //娉ㄦ剰鐨勬槸keyRuleVO鍙兘涓虹┖锛岃〃绀轰笉浣跨敤瑙勫垯鎺у埗 //鑾峰彇鎵�鏈夌殑鍏抽敭灞炴�� - Map<String/**灞炴�х殑缂栧彿**/, CodeClassifyTemplateAttrVO> ketAttrMap = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getKeyAttrFlag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); + Map<String/**灞炴�х殑缂栧彿**/, CodeClassifyTemplateAttrVO> keyAttrMap = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getKeyAttrFlag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); + + // TODO:2024-02-01 鍏堣幏鍙栭厤缃簡杩戜箟璇嶆煡璇㈣鍒欑殑灞炴�э紝涓嶅悓浜庡叧閿睘鎬э紝璁剧疆浜嗚繎涔夎瘝鏌ヨ瑙勫垯鐨勫睘鎬у彲鑳芥槸澶氭潯涓嶅悓鐨勮繎涔夎瘝鏌ヨ瑙勫垯 + Map<String, CodeClassifyTemplateAttrVO> sysonymAttrMaps = templateVO.getAttributes().stream().filter(item -> Func.isNotBlank(item.getSysonymRuleOids())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); + // 鏈夐厤缃繎涔夎瘝鏌ヨ瑙勫垯灞炴�� + Map<String, List<CodeSynonym>> codeSynonymMaps = new HashMap<>(); + if(!sysonymAttrMaps.isEmpty()){ + // 鏌ヨ杩戜箟璇嶈鍒欙紝瀛樺偍鏂瑰紡key锛氬睘鎬d锛寁alue杩戜箟璇嶆煡璇㈣鍒欏垪琛� + codeSynonymMaps = codeSynonymService.getCodeSynonymByOids(sysonymAttrMaps); + } boolean trimAll =keyRuleVO ==null?false: VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag()); //鍏ㄩ儴鍘荤┖鐨勪紭鍏堢骇澶т簬鍘荤┖ @@ -4394,15 +4415,18 @@ 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)); - getSelfRepeatRowIndex(ketAttrMap,cboList,keyRuleVO,resultVO); + //resultVO.setSelfRepeatRowIndexList(getSelfRepeatRowIndex(keyAttrMap,cboList,keyRuleVO)); + + // 鍏堝湪琛ㄦ牸涓煡璇㈠叧閿睘鎬ч噸澶嶇殑鍒� + getSelfRepeatRowIndex(keyAttrMap,cboList,keyRuleVO,resultVO); + // 鍐嶅湪琛ㄦ牸涓煡璇㈣繎涔夎瘝鏌ヨ瑙勫垯鐨勫垪 + //getSelfRepeatSysnomRowIndex(sysonymAttrMaps,cboList,codeSynonymMaps,resultVO); + if(!CollectionUtils.isEmpty(resultVO.getSelfRepeatRowIndexList())){ //鎴戜滑绉婚櫎鏈韩閲嶅鐨勬暟鎹� cboList = cboList.stream().filter(s->!resultVO.getSelfRepeatRowIndexList().contains(s.getAttributeValue(IMPORT_ROW_INDEX))).collect(Collectors.toList()); } //2.鍒ゆ柇鍏抽敭灞炴�у湪绯荤粺閲屾槸鍚﹂噸澶� - //鍥犱负鏁版嵁閲忓緢澶э紝鎵�浠ュ緱鎯冲姙娉曞苟琛� - //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); Map<String,List<BaseModel>> indexTODataMap=new ConcurrentHashMap<>(); // 鏌ヨ涓嶉渶瑕佸弬涓庡叧閿睘鎬ф牎楠岀殑闄よ嚜宸变互澶栫殑鎵�鏈夊垎绫籵id final String isParticipateCheckOids = classifyService.selectLeafByParentClassifyOid(classifyFullInfo.getTopClassifyVO().getOid(), classifyFullInfo.getCurrentClassifyVO().getOid()); @@ -4416,20 +4440,25 @@ //姣忚閮藉緱鏌ヨ.濡傛灉鍏朵腑鍑虹幇浜嗛敊璇紝鎴戜滑灏辩洿鎺ユ姏鍑哄紓甯革紝鍏朵綑鐨勬樉绀� //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); Map<String, String> conditionMap = new HashMap<>(); - ketAttrMap.forEach((attrId, attrVO) -> { + keyAttrMap.forEach((attrId, attrVO) -> { String value =cbo.getAttributeValue(attrId.toLowerCase(Locale.ROOT)); if (value == null) { value = ""; } value= value.replace(REQUIRED_CHAR,SPECIAL_CHAR); + // 鍏抽敭灞炴�ф煡璇㈡潯浠秏ap鑾峰彇 engineService.wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); + // 杩戜箟璇嶆煡璇㈣鍒欐潯浠秏ap鑾峰彇 + //engineService.wrapperSynonymAttrConditionMap(value); }); - if (!CollectionUtils.isEmpty(ketAttrMap)) { + + if (!CollectionUtils.isEmpty(keyAttrMap)) { // 娣诲姞涓嶅弬涓庡叧閿睘鎬ф牎楠岀殑鍒嗙被oid鍒ゆ柇 if(Func.isNotBlank(isParticipateCheckOids)){ conditionMap.put("t.codeclsfid",QueryOptionConstant.NOTIN+isParticipateCheckOids); } - if(isEdit){//濡傛灉鏄洿鏀瑰垯闇�鎺掗櫎绯荤粺鏈韩 + //濡傛灉鏄洿鏀瑰垯闇�鎺掗櫎绯荤粺鏈韩 + if(isEdit){ conditionMap.put("t.id",QueryOptionConstant.NOTEQUAL+cbo.getId()); } conditionMap.put("t.lastr", "1"); @@ -4597,6 +4626,7 @@ String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); String oid=cbo.getOid(); StringBuilder sb = new StringBuilder(); + // 鍏抽敭灞炴�ч噸澶嶆牎楠屽�煎鐞� for (int i = 0; i < attrVOList.size(); i++) { CodeClassifyTemplateAttrVO attrVO = attrVOList.get(i); String attrId = attrVO.getId().toLowerCase(Locale.ROOT); @@ -4643,6 +4673,75 @@ } /** + * 鑾峰彇杩戜箟璇嶆煡璇㈠瓨鍦ㄧ浉鍚岀殑琛屽彿 + * @param sysonymAttr + * @param dataList + * @param CodeSynonymMaps + * @param resultVO + */ + private void getSelfRepeatSysnomRowIndex(Map<String/**灞炴�х殑缂栧彿**/, CodeClassifyTemplateAttrVO> sysonymAttr, + List<ClientBusinessObject> dataList, Map<String, List<CodeSynonym>> CodeSynonymMaps,CodeImportResultVO resultVO) { + Set<String> selfRepeatRowIndexList = new CopyOnWriteArraySet<>(); + Map<String,List<String>> keyAttrOkOidTORepeatOidMap=new HashMap<>(); + //蹇呴』灏嗗睘鎬ф寜鐓ч『搴忔帓搴忓ソ + List<CodeClassifyTemplateAttrVO> attrVOList = sysonymAttr.values().stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).collect(Collectors.toList()); + Map<String/**琛屽彿**/,String/**鍏抽敭灞炴�х殑缁勫悎鍐呭**/> rowIndexKeyStringMap = new HashMap<>(); + Map<String/**鍏抽敭灞炴�х殑缁勫悎鍐呭**/,String/**绗竴涓叧閿睘鎬х殑鏁版嵁oid**/> okOidKeyStringMap = new HashMap<>(); + dataList.parallelStream().forEach(cbo-> { + String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); + String oid = cbo.getOid(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < attrVOList.size(); i++) { + CodeClassifyTemplateAttrVO attrVO = attrVOList.get(i); + String attrId = attrVO.getId().toLowerCase(Locale.ROOT); + String value = cbo.getAttributeValue(attrId); + List<CodeSynonym> codeSynonyms = CodeSynonymMaps.get(attrId); + // 瀵硅繎涔夎瘝鏌ヨ鍊艰繘琛岃浆鎹� + value = synonymConversion(codeSynonyms,value); + // 濡傛灉codeSynonyms鏄涓氨闇�瑕佽�冭檻缁勫悎闂 + sb.append(value).append("${sys}"); + } + String keyString = sb.toString(); + if(rowIndexKeyStringMap.containsValue(keyString) && StringUtils.isNotBlank(keyString)){ + selfRepeatRowIndexList.add(rowIndex); + String okOid=okOidKeyStringMap.getOrDefault(keyString,""); + if(StringUtils.isNotBlank(okOid)){ + List<String>newOidList=new ArrayList<>(); + newOidList.add(oid); + if(keyAttrOkOidTORepeatOidMap.containsKey(okOid)){ + List<String> oldOidList = keyAttrOkOidTORepeatOidMap.get(okOid); + newOidList.addAll(oldOidList); + } + keyAttrOkOidTORepeatOidMap.put(okOid,newOidList); + } + }else { + okOidKeyStringMap.put(sb.toString(),oid); + rowIndexKeyStringMap.put(rowIndex, sb.toString()); + } + }); + //鍥犱负鍙槸鍏抽敭灞炴�ч噸澶嶏紝鎵�浠ユ垜浠笉鑳介噸澶嶇殑澶氭潯閫変竴鏉℃潵鎶ラ敊 + resultVO.setKeyAttrRepeatRowIndexList(selfRepeatRowIndexList); + resultVO.setKeyAttrOkOidTORepeatOidMap(keyAttrOkOidTORepeatOidMap); + } + + /** + * 杩戜箟璇嶄笌婧愬�肩浉浜掕浆鎹� + * @param codeSynonyms + * @param value + * @return + */ + private String synonymConversion(List<CodeSynonym> codeSynonyms,String value){ + // 鍙湁涓�鏉¤繎涔夎瘝鏌ヨ瑙勫垯鏃� + if(codeSynonyms.isEmpty() || codeSynonyms.size() == 1){ + return value.replace(codeSynonyms.get(0).getSourceValue(),codeSynonyms.get(0).getSynonymValue()); + } + // 杩戜箟璇嶈鍒欏彲鑳藉嚭鐜扮殑鎯呭喌鏄竴涓簮鍊煎搴斿涓繎涔夎瘝锛岃�屽弽鏌ユ椂鍚屾牱浼氬嚭鐜颁竴涓繎涔夎瘝瀵瑰簲澶氫釜婧愬�� +// codeSynonyms.stream().map() + + return value; + } + + /** * excel鐨勬爣棰樹笂鑾峰彇瀛楁鎵�鍦ㄧ殑浣嶇疆 * @param titleRowData 鏍囬鐨勫唴瀹� * @param attrNameIdMap 妯℃澘涓睘鎬у悕绉板拰鑻辨枃鐨勬槧灏� @@ -4667,6 +4766,7 @@ } } } + private List<ClientBusinessObject> ChangeMapTOClientBusinessObjects(List<Map<String,String>> oldDataMap){ List<ClientBusinessObject> clientBusinessObjectList=new ArrayList<>(); DefaultAttrAssimtUtil.mapToLowerCase(oldDataMap,true); -- Gitblit v1.9.3