From f879ddd80a2bd267a0a575ef03f76d3ec2ae1504 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期四, 04 一月 2024 11:42:22 +0800 Subject: [PATCH] bug列表269:集成日志查询bug修改。 270:关键属性校验,去掉多线程之后请求响应非常慢(之前报错线程阻塞的bug改成单线程导致非常慢,现在又改回ForJoinPool方式限制线程生成数量实现多线程并行,提升执行效率)。 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java | 106 +++++++++++++++++++++++++++++------------------------ 1 files changed, 58 insertions(+), 48 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 e910019..67fe60b 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 @@ -87,6 +87,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArraySet; +import java.util.concurrent.ForkJoinPool; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; @@ -201,6 +202,11 @@ * 瀹㈡埛鐜板満excel涓鸿�佺増鏈紝瀵煎嚭鐨勬�绘暟闄愬埗涓�65535 */ public static final int EXPORT_LIMIT = 65535; + + /** + * 鑷畾涔夊苟鍙慒orkJoinPool + */ + private static final ForkJoinPool customForkJoinPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors()-1); /** * 鎵归噺鐢宠锛氶�夊彇閫変腑鍒嗙被涓嬬殑鎵�鏈夋ā鏉垮叧閿睘鎬э紝鐩镐技灞炴�э紝蹇呭~灞炴�э紝鍐欏叆execl涓� @@ -4393,56 +4399,60 @@ // 鏌ヨ涓嶉渶瑕佸弬涓庡叧閿睘鎬ф牎楠岀殑闄よ嚜宸变互澶栫殑鎵�鏈夊垎绫籵id final String isParticipateCheckOids = classifyService.selectLeafByParentClassifyOid(classifyFullInfo.getTopClassifyVO().getOid(), classifyFullInfo.getCurrentClassifyVO().getOid()); final BladeUser user = AuthUtil.getUser(); - //cboList = new CopyOnWriteArrayList<>(cboList); - // TODO:Thread limit exceeded replacing blocked 寮傚父鏄繖閮ㄥ垎浠g爜鎶涘嚭鐨�,鎵�浠ユ殏鏃跺皢parallelStream鏀规垚浜唖tream - List<ClientBusinessObject> repeatDataMap = cboList.stream().filter(cbo -> { - //姣忚閮藉緱鏌ヨ.濡傛灉鍏朵腑鍑虹幇浜嗛敊璇紝鎴戜滑灏辩洿鎺ユ姏鍑哄紓甯革紝鍏朵綑鐨勬樉绀� - //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); - Map<String, String> conditionMap = new HashMap<>(); - ketAttrMap.forEach((attrId, attrVO) -> { - String value =cbo.getAttributeValue(attrId.toLowerCase(Locale.ROOT)); - if (value == null) { - value = ""; - } - value= value.replace(REQUIRED_CHAR,SPECIAL_CHAR); - engineService.wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); - }); - if (!CollectionUtils.isEmpty(ketAttrMap)) { - // 娣诲姞涓嶅弬涓庡叧閿睘鎬ф牎楠岀殑鍒嗙被oid鍒ゆ柇 - if(Func.isNotBlank(isParticipateCheckOids)){ - conditionMap.put("t.codeclsfid",QueryOptionConstant.NOTIN+isParticipateCheckOids); - } - if(isEdit){//濡傛灉鏄洿鏀瑰垯闇�鎺掗櫎绯荤粺鏈韩 - conditionMap.put("t.id",QueryOptionConstant.NOTEQUAL+cbo.getId()); - } - conditionMap.put("t.lastr", "1"); - conditionMap.put("t.lastv", "1"); - - CodeTemplateAttrSqlBO sqlBO = engineService.getSqlByTemplateVO(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), templateVO, conditionMap, null); - List<String> repeatData = commonsMapper.selectList(sqlBO.getSqlId()); - if(!repeatData.isEmpty()){ - final List<Map<String,String>> newDataList = commonsMapper.queryByOnlySqlForMap(sqlBO.getSqlUnPage()); - DefaultAttrAssimtUtil.mapToLowerCase(newDataList,true); - //List<ClientBusinessObject> newCboList=ChangeMapTOClientBusinessObjects(newDataList); - List<BaseModel> newCboList = new ArrayList<>(); - newDataList.stream().forEach(stringStringMap -> { - BaseModel baseModel=new BaseModel(); - DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(stringStringMap,baseModel,false,user); - baseModel.setData(stringStringMap); - newCboList.add(baseModel); - }); - // 娣诲姞閿欒鍊� - String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); - errorMap.put(rowIndex, "閲嶅鐨勮褰曠紪鍙蜂负:"+repeatData.stream().collect(Collectors.joining(","))); - if(!CollectionUtils.isEmpty(newCboList)) { - indexTODataMap.put(cbo.getAttributeValue(IMPORT_ROW_INDEX), newCboList); + // TODO:Thread limit exceeded replacing blocked 寮傚父鏄繖閮ㄥ垎浠g爜鎶涘嚭鐨� + // ,鎵�浠ユ殏鏃跺皢parallelStream鏀规垚浜唖tream锛屾敼鎴愪簡stream涔嬪悗鍙戠幇宸ㄦ參 + // customForkJoinPool鎺у埗骞跺彂搴� + List<ClientBusinessObject> finalCboList = cboList; + List<ClientBusinessObject> repeatDataMap = (List<ClientBusinessObject>) customForkJoinPool.submit(()->{ + finalCboList.parallelStream().filter(cbo -> { + //姣忚閮藉緱鏌ヨ.濡傛灉鍏朵腑鍑虹幇浜嗛敊璇紝鎴戜滑灏辩洿鎺ユ姏鍑哄紓甯革紝鍏朵綑鐨勬樉绀� + //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); + Map<String, String> conditionMap = new HashMap<>(); + ketAttrMap.forEach((attrId, attrVO) -> { + String value =cbo.getAttributeValue(attrId.toLowerCase(Locale.ROOT)); + if (value == null) { + value = ""; } + value= value.replace(REQUIRED_CHAR,SPECIAL_CHAR); + engineService.wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); + }); + if (!CollectionUtils.isEmpty(ketAttrMap)) { + // 娣诲姞涓嶅弬涓庡叧閿睘鎬ф牎楠岀殑鍒嗙被oid鍒ゆ柇 + if(Func.isNotBlank(isParticipateCheckOids)){ + conditionMap.put("t.codeclsfid",QueryOptionConstant.NOTIN+isParticipateCheckOids); + } + if(isEdit){//濡傛灉鏄洿鏀瑰垯闇�鎺掗櫎绯荤粺鏈韩 + conditionMap.put("t.id",QueryOptionConstant.NOTEQUAL+cbo.getId()); + } + conditionMap.put("t.lastr", "1"); + conditionMap.put("t.lastv", "1"); + + CodeTemplateAttrSqlBO sqlBO = engineService.getSqlByTemplateVO(classifyFullInfo.getTopClassifyVO().getBtmTypeId(), templateVO, conditionMap, null); + List<String> repeatData = commonsMapper.selectList(sqlBO.getSqlId()); + if(!repeatData.isEmpty()){ + final List<Map<String,String>> newDataList = commonsMapper.queryByOnlySqlForMap(sqlBO.getSqlUnPage()); + DefaultAttrAssimtUtil.mapToLowerCase(newDataList,true); + //List<ClientBusinessObject> newCboList=ChangeMapTOClientBusinessObjects(newDataList); + List<BaseModel> newCboList = new ArrayList<>(); + newDataList.stream().forEach(stringStringMap -> { + BaseModel baseModel=new BaseModel(); + DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(stringStringMap,baseModel,false,user); + baseModel.setData(stringStringMap); + newCboList.add(baseModel); + }); + // 娣诲姞閿欒鍊� + String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); + errorMap.put(rowIndex, "閲嶅鐨勮褰曠紪鍙蜂负:"+repeatData.stream().collect(Collectors.joining(","))); + if(!CollectionUtils.isEmpty(newCboList)) { + indexTODataMap.put(cbo.getAttributeValue(IMPORT_ROW_INDEX), newCboList); + } + } + return !repeatData.isEmpty(); + }else{ + return false; } - return !repeatData.isEmpty(); - }else{ - return false; - } - }).collect(Collectors.toList()); + }).collect(Collectors.toList()); + }).join(); if(!CollectionUtils.isEmpty(repeatDataMap)){ resultVO.setKeyAttrRepeatRowIndexList(repeatDataMap.stream().map(s->s.getAttributeValue(IMPORT_ROW_INDEX)).collect(Collectors.toSet())); } -- Gitblit v1.9.3