From 2ff8dd1f7d2f71944c25c9e116d12d9fb418ac0a Mon Sep 17 00:00:00 2001 From: ludc Date: 星期三, 17 一月 2024 17:00:08 +0800 Subject: [PATCH] 分类授权数据授权界面编写与接口修改,分类数据查询接口修改 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java | 131 ++++++++++++++++++++++++++----------------- 1 files changed, 78 insertions(+), 53 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 ef3bc27..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涓� @@ -2740,7 +2746,7 @@ //cboOidMap.put("id", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0])) + ")"); String tableName =""; try { - R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId()); + R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(classifyFullInfo.getTopClassifyVO().getBtmTypeId()); if(!r.isSuccess()) { throw new Throwable(r.getMsg()); } @@ -2838,7 +2844,17 @@ cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription())?"":orderDTO.getDescription()); cbo.setName(orderDTO.getName()); try { - cbo.setAttributeValueWithNoCheck("description", orderDTO.getDescription()); + //涓昏澶勭悊澶у皬鍐欓棶棰橈紝灏哾ata閲岄潰鐨勬暟鎹殑key閮借浆涓哄皬鍐� + HashMap<String,String> lowerData = new HashMap<>(); + Iterator<Map.Entry<String, String>> iterator = cbo.getData().entrySet().iterator(); + while (iterator.hasNext()){ + Map.Entry<String, String> next = iterator.next(); + lowerData.put(next.getKey().toLowerCase(Locale.ROOT),next.getValue()); + } + cbo.getData().clear(); + cbo.getData().putAll(lowerData); + cbo.setAttributeValueWithNoCheck("description", (StringUtil.isNotBlank(orderDTO.getData() + .get("description")) ? orderDTO.getData().get("description") : orderDTO.getDescription() )); // cbo.setAttributeValue("name", orderDTO.getName()); // if(finalIsProcess){//鍦ㄦ祦绋嬩腑涓嶅厑璁告洿鏀� // errorMap.put(code,errorMap.getOrDefault(code, errorMap.getOrDefault(code,"")+";鏁版嵁"+code+"鍦ㄦ祦绋嬩腑锛屼笉鍏佽鏇存敼!")); @@ -2901,7 +2917,7 @@ List<CodeAllCode>newCodeAllCodeList= codeAllCodeService.selectByWrapper(Wrappers.<CodeAllCode>query().lambda().eq(CodeAllCode::getCreateCodeOid, cbo.getOid())); if (!CollectionUtils.isEmpty(newCodeAllCodeList)) { - CodeAllCode codeCbo = codeAllCodeList.get(0); + CodeAllCode codeCbo = newCodeAllCodeList.get(0); log.info("codeCbos code:" + codeCbo.getId()); codeCbo.setLcStatus(status); codeAllCodeList.add(codeCbo); @@ -2939,7 +2955,7 @@ engineService.updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(),updateList); codeAllCodeService.saveOrUpdateBatch(codeAllCodeList); if(deleteList.size()>0) { - commonsMapper.deleteByTaleAndOid(tableName, VciBaseUtil.array2String(deleteList.toArray(new String[]{}))); + commonsMapper.deleteByTaleAndOid(tableName, VciBaseUtil.toInSql(deleteList.toArray(new String[]{}))); } //鏄惁璋冪敤闆嗗洟鎺ュ彛鐢宠鎺ュ彛 if(isCodeOrGroupCode){ @@ -3614,6 +3630,11 @@ rowDataList.stream().forEach(rowData -> { ClientBusinessObject cbo=new ClientBusinessObject(); DefaultAttrAssimtUtil.addDefaultAttrAssimt(cbo, classifyFullInfo.getTopClassifyVO().getBtmTypeId()); + R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(classifyFullInfo.getTopClassifyVO().getBtmTypeId())); + if(!listR.isSuccess() || listR.getData().size() == 0){ + throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒"); + } + cbo.setRevisionRule("".equals(listR.getData().get(0).getVersionRule())?"1":listR.getData().get(0).getVersionRule()); rowData.getData().forEach((index,value)->{ String field = fieldIndexMap.get(index); if (StringUtils.isBlank(field)) { @@ -4330,7 +4351,7 @@ } else { Map<String, String> classifyDataMap = VciBaseUtil.objectToMapString(classifyVO); String value = classifyDataMap.getOrDefault(attrVO.getClassifyInvokeAttr(), ""); - log.error("================================褰撳墠鍒嗙被娉ㄥ叆鐨剉alue鍊间负锛�==========================",value); +// log.error("================================褰撳墠鍒嗙被娉ㄥ叆鐨剉alue鍊间负锛�==========================",value); cbo.setAttributeValue(attrId, value); } } catch (Throwable e) { @@ -4378,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