From 8ef9e366be48dc5e8e52617ea8ed48b37a0e1f74 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期四, 29 二月 2024 14:33:58 +0800 Subject: [PATCH] 在线部署功能上传,标准申请接口bug修改 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmIOServiceImpl.java | 248 +++++++++++++++++++++++++++++++----------------- 1 files changed, 159 insertions(+), 89 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 d06a186..6f42765 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.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.common.utils.StringUtils; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.protobuf.ServiceException; import com.vci.ubcs.code.applyjtcodeservice.feign.IMdmInterJtClient; @@ -13,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; @@ -27,7 +27,6 @@ import com.vci.ubcs.omd.feign.IBtmTypeClient; import com.vci.ubcs.omd.feign.IWebSecretClient; import com.vci.ubcs.omd.vo.BtmTypeVO; -import com.vci.ubcs.omd.vo.RevisionRuleVO; import com.vci.ubcs.starter.bo.WriteExcelData; import com.vci.ubcs.starter.exception.VciBaseException; import com.vci.ubcs.starter.poi.bo.ReadExcelOption; @@ -56,7 +55,6 @@ import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.RichTextString; import org.apache.poi.ss.usermodel.Workbook; -import org.aspectj.apache.bcel.classfile.Code; import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.utils.AuthUtil; @@ -70,7 +68,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; +import javax.xml.bind.ValidationEvent; import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; @@ -87,7 +85,9 @@ 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.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import static com.alibaba.druid.util.FnvHash.Constants.LIMIT; @@ -98,7 +98,6 @@ @Service @Slf4j public class MdmIOServiceImpl implements MdmIOService { - /** * 瀛楁 @@ -144,7 +143,7 @@ * 妯℃澘鐨勬湇鍔� */ @Resource - private CodeClstemplateServiceImpl templateService; + private ICodeClstemplateService templateService; /** * 涓绘暟鎹紩鎿庣殑鏈嶅姟 @@ -167,40 +166,57 @@ 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 */ public static final int EXPORT_LIMIT = 65535; + + /** + * 鑷畾涔夊苟鍙慒orkJoinPool + */ + private static final ForkJoinPool customForkJoinPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors()-1); /** * 鎵归噺鐢宠锛氶�夊彇閫変腑鍒嗙被涓嬬殑鎵�鏈夋ā鏉垮叧閿睘鎬э紝鐩镐技灞炴�э紝蹇呭~灞炴�э紝鍐欏叆execl涓� @@ -956,9 +972,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); @@ -968,6 +982,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)) { @@ -1277,6 +1292,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)) { @@ -1284,6 +1300,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); @@ -1344,8 +1361,6 @@ engineService.batchSaveSelectChar(templateVO, dataCBOIdList); } } - //long end = System.currentTimeMillis(); - //log.info("=============for鎵ц鏃堕棿================="+String.valueOf((end-start)/1000)); String excelFileName=""; if(isExport&&!CollectionUtils.isEmpty(shetNameMap)) { excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + "閿欒淇℃伅.xls"; @@ -1359,14 +1374,17 @@ throw new VciBaseException(LangBaseUtil.getErrorMsg(e)); } ExcelUtil.writeDataToFile(excelFileName, eo); + saveLogUtil.operateLog("鍘嗗彶鏁版嵁瀵煎叆",true, StringUtil.format("閿欒淇℃伅锛歿}",JSON.toJSONString(shetNameMap))); + }else{ + // 鍘嗗彶鏁版嵁瀵煎叆鏃跺嚭鐜颁簡鐩镐技椤硅繑鍥炵粨鏋滄椂涓嶇畻瀵煎叆鎴愬姛 + if(shetNameMap.isEmpty() || !isCreateUUid){ + saveLogUtil.operateLog("鍘嗗彶鏁版嵁瀵煎叆",false, StringUtil.format("瀵煎叆鍒板垎绫粄}涓紝瀵煎叆鎴愬姛鎬绘暟涓猴細{}", JSON.toJSONString(classifyFullInfo), Func.isEmpty(importCount) ? 0:importCount.get(0))); + } } CodeImProtRusultVO codeImProtRusultVO=new CodeImProtRusultVO(); if(StringUtils.isNotBlank(excelFileName)) { codeImProtRusultVO.setFilePath(excelFileName); codeImProtRusultVO.setFileOid(""); - saveLogUtil.operateLog("鍘嗗彶鏁版嵁瀵煎叆",true, StringUtil.format("閿欒淇℃伅锛歿}",JSON.toJSONString(shetNameMap))); - }else{ - saveLogUtil.operateLog("鍘嗗彶鏁版嵁瀵煎叆",false, StringUtil.format("瀵煎叆鍒板垎绫粄}涓紝瀵煎叆鎴愬姛鎬绘暟涓猴細{}", JSON.toJSONString(classifyFullInfo),importCount.get(0))); } if(isCreateUUid){ codeImProtRusultVO.setRedisUuid(uuid); @@ -1755,6 +1773,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; @@ -2113,10 +2132,18 @@ ExcelUtil.writeDataToFile(excelName, excelOption); } + /** + * 鐩镐技椤规煡璇㈠嚭鏉ヤ箣鍚庡啀鐐瑰嚮纭鏃惰皟鐢ㄧ殑 + * @param codeImprotSaveDatVOList + * @param classifyAttr + * @param isImprot + * @return + */ @Override public R batchImportData(List<CodeImprotSaveDatVO> codeImprotSaveDatVOList, String classifyAttr, boolean isImprot) { WriteExcelOption eo = new WriteExcelOption(); AtomicBoolean success= new AtomicBoolean(true); + AtomicReference<CodeClassifyTemplateVO> codeClassifyTemplateVO = new AtomicReference<>(); codeImprotSaveDatVOList.stream().forEach(codeImprotSaveDatVO -> { List<SheetRowData> rowDataList = new ArrayList<>(); List<ClientBusinessObject>cboList=new ArrayList<>(); @@ -2145,16 +2172,16 @@ log.info("鍒嗙被锛�"+classifyFullInfo.getCurrentClassifyVO().getName()+"鏁版嵁:"+codeImprotSaveDatVO.getDataList().size()); // CodeClassifyTemplateVO codeClassifyTemplateVO= engineService.getUsedTemplateByClassifyOid(orderDTO.getCodeClassifyOid()); - CodeClassifyTemplateVO codeClassifyTemplateVO= templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid()); + codeClassifyTemplateVO.set(templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid())); //瑙勫垯鐨勪富閿渶瑕佸幓鑾峰彇 CodeRuleVO ruleVO = engineService.getCodeRuleByClassifyFullInfo(classifyFullInfo); //闄ゅ幓榛樿鐨勫睘鎬�.杩樻湁鍙湁琛ㄥ崟鏄剧ず鐨勫瓧娈垫墠瀵煎叆 - List<CodeClassifyTemplateAttrVO> attrVOS = codeClassifyTemplateVO.getAttributes().stream().filter(s -> + List<CodeClassifyTemplateAttrVO> attrVOS = codeClassifyTemplateVO.get().getAttributes().stream().filter(s -> !DEFAULT_ATTR_LIST.contains(s.getId()) && ((Func.isNotEmpty(s.getClassifyInvokeAttr()) || Func.isNotEmpty(s.getClassifyInvokeAttrName())) || VciBaseUtil.getBoolean(s.getFormDisplayFlag())) ).collect(Collectors.toList()); String fullPath = getFullPath(classifyFullInfo); - excelToCbo(classifyFullInfo,fieldIndexMap,rowDataList, codeClassifyTemplateVO,cboList,fullPath,!isImprot); + excelToCbo(classifyFullInfo,fieldIndexMap,rowDataList, codeClassifyTemplateVO.get(),cboList,fullPath,!isImprot); Map<String,String> errorMap=new ConcurrentHashMap<>(); Map<String/**璺緞**/, CodeClassifyVO> pathMap=new HashMap<>() ; //鏍¢獙缂栫爜瑙勫垯鍜岀爜娈垫槸鍚︽纭� @@ -2200,7 +2227,7 @@ //鏈�鍚庡紕缁勫悎瑙勫垯 batchSwitchComponentAttrOnOrder(attrVOS,cboList); //3.鍒ゆ柇鍏抽敭灞炴�� - CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, codeClassifyTemplateVO, cboList,false,errorMap); + CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, codeClassifyTemplateVO.get(), cboList,false,errorMap); Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList(); Set<String> keyAttrRepeatRowIndexList = keyResultVO.getKeyAttrRepeatRowIndexList(); if(!CollectionUtils.isEmpty(keyAttrRepeatRowIndexList)){ @@ -2231,7 +2258,7 @@ dataCBOList.add(baseModel); }); try { - productCodeService.productCodeAndSaveData(classifyFullInfo, codeClassifyTemplateVO, finalRuleVOMap.get(ruleOid), null, dataCBOList, user); + productCodeService.productCodeAndSaveData(classifyFullInfo, codeClassifyTemplateVO.get(), finalRuleVOMap.get(ruleOid), null, dataCBOList, user); } catch (Throwable e) { //success=false; log.error("鎵归噺浜х敓缂栫爜鐨勬椂鍊欏嚭閿欎簡", e); @@ -2241,7 +2268,7 @@ }); } } - engineService.batchSaveSelectChar(codeClassifyTemplateVO, dataCBOList); + engineService.batchSaveSelectChar(codeClassifyTemplateVO.get(), dataCBOList); }); }else { final BladeUser user = AuthUtil.getUser(); @@ -2258,7 +2285,7 @@ dataCBOList.add(baseModel); }); try { - productCodeService.productCodeAndSaveData(classifyFullInfo, codeClassifyTemplateVO, ruleVO, orderDTO.getSecDTOList(), dataCBOList,user); + productCodeService.productCodeAndSaveData(classifyFullInfo, codeClassifyTemplateVO.get(), ruleVO, orderDTO.getSecDTOList(), dataCBOList,user); } catch (Exception e) { log.error("鎵归噺浜х敓缂栫爜鐨勬椂鍊欏嚭閿欎簡", e); needSaveCboList.stream().forEach(cbo -> { @@ -2267,7 +2294,7 @@ }); } //濡傛灉鏄紪鐮佺敓鎴愬け璐ワ紝鍒欑洿鎺ュ氨澶辫触浜嗭紝鍏朵粬鐨勫垽鏂嚭鏉ユ湁閿欒鐨勬垜浠兘缁熶竴杩斿洖鍒癳xcel閲岄潰 - engineService.batchSaveSelectChar(codeClassifyTemplateVO, dataCBOList); + engineService.batchSaveSelectChar(codeClassifyTemplateVO.get(), dataCBOList); } } if(errorMap.size()>0) { @@ -2278,14 +2305,16 @@ errorMap.forEach((key,v)->{ excelDataList.add(new WriteExcelData(index[0]++, 0, "绗�"+(Integer.parseInt(key)+1)+"琛屾暟鎹細"+v)); }); - eo.addSheetDataList(codeClassifyTemplateVO.getName() + "瀵煎叆妯℃澘", excelDataList); + eo.addSheetDataList(codeClassifyTemplateVO.get().getName() + "瀵煎叆妯℃澘", excelDataList); } }); if(!success.get()){ String excelName = LocalFileUtil.getDefaultTempFolder() + File.separator + (isImprot?"鎵归噺鍘嗗彶閿欒淇℃伅.xls":"鎵归噺鐢宠閿欒淇℃伅.xls"); ExcelUtil.writeDataToFile(excelName,eo); - return R.fail(excelName); + saveLogUtil.operateLog("鍘嗗彶鏁版嵁瀵煎叆",true, StringUtil.format("閿欒淇℃伅锛歿}",JSON.toJSONString(eo.getWriteDataMap()))); + return R.fail(excelName); }else { + saveLogUtil.operateLog("鍘嗗彶鏁版嵁瀵煎叆",false, StringUtil.format("瀵煎叆鍒板垎绫粄}涓紝瀵煎叆鎴愬姛鎬绘暟涓猴細{}", JSON.toJSONString(codeClassifyTemplateVO), Func.isEmpty(codeImprotSaveDatVOList.get(0).getDataList().size()))); return R.success(isImprot ? "鎵归噺鍘嗗彶瀵煎叆鎴愬姛" : "鎵归噺鐢宠鎴愬姛"); } } @@ -2740,7 +2769,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 +2867,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 +2940,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 +2978,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){ @@ -3059,18 +3098,27 @@ //娉ㄦ剰鐨勬槸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)); + // 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); + } Map<String, String> conditionMap = new HashMap<>(); boolean trimAll = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag()); //鍏ㄩ儴鍘荤┖鐨勪紭鍏堢骇澶т簬鍘荤┖ boolean trim = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorespaceflag()); boolean ignoreCase = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorecaseflag()); boolean ignoreWidth = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorewidthflag()); + Map<String, List<CodeSynonym>> finalCodeSynonymMaps = codeSynonymMaps; ketAttrMap.forEach((attrId, attrVO) -> { String value = getValueFromOrderDTO(orderDTO, attrId); if (value == null) { value = ""; } - engineService.wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); + engineService.wrapperKeyAttrConditionMap(value, keyRuleVO, finalCodeSynonymMaps.get(attrId), attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); }); //娌℃湁闄愬埗鍒嗙被锛屼絾鏄竴涓ā鏉垮彧鍙兘鍦ㄤ竴涓笟鍔$被鍨嬮噷闈紝鎵�浠ョ洿鎺ユ煡璇㈣繖涓笟鍔$被鍨嬪嵆鍙� @@ -4346,7 +4394,7 @@ } } /** - * 鏍¢獙鍏抽敭灞炴�� + * 鏍¢獙鍏抽敭灞炴�э紝鍜岃繎涔夎瘝鏌ヨ瑙勫垯 * @param classifyFullInfo 鍒嗙被鐨勫叏閮ㄤ俊鎭� * @param templateVO 妯℃澘鐨勫唴瀹癸紝蹇呴』鍖呭惈妯℃澘灞炴�� * @param cboList 鎵归噺鐨勬暟鎹� @@ -4358,7 +4406,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()); //鍏ㄩ儴鍘荤┖鐨勪紭鍏堢骇澶т簬鍘荤┖ @@ -4370,69 +4427,80 @@ 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,codeSynonymMaps,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()); 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; + Map<String, List<CodeSynonym>> finalCodeSynonymMaps = codeSynonymMaps; + List<ClientBusinessObject> repeatDataMap = (List<ClientBusinessObject>) customForkJoinPool.submit(()->{ + finalCboList.parallelStream().filter(cbo -> { + //姣忚閮藉緱鏌ヨ.濡傛灉鍏朵腑鍑虹幇浜嗛敊璇紝鎴戜滑灏辩洿鎺ユ姏鍑哄紓甯革紝鍏朵綑鐨勬樉绀� + //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); + Map<String, String> conditionMap = new HashMap<>(); + 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, finalCodeSynonymMaps.get(attrId), attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); + }); + + if (!CollectionUtils.isEmpty(keyAttrMap)) { + // 娣诲姞涓嶅弬涓庡叧閿睘鎬ф牎楠岀殑鍒嗙被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())); } @@ -4546,14 +4614,14 @@ } /** - * 鑾峰彇瀵煎叆鐨勫唴瀹逛腑鍏抽敭灞炴�ч噸澶嶇殑琛屽彿 + * 鑾峰彇瀵煎叆鐨勫唴瀹逛腑鍏抽敭灞炴�ц繎涔夎瘝杞崲鍚庨噸澶嶇殑琛屽彿 * @param ketAttrMap 鍏抽敭灞炴�х殑鏄犲皠 * @param dataList 瀵煎叆鐨勬暟鎹� * @param keyRuleVO 鍏抽敭灞炴�ф帶鍒惰鍒� * @return 閲嶅鐨勮鍙� */ private void getSelfRepeatRowIndex(Map<String/**灞炴�х殑缂栧彿**/, CodeClassifyTemplateAttrVO> ketAttrMap, - List<ClientBusinessObject> dataList,CodeKeyAttrRepeatVO keyRuleVO,CodeImportResultVO resultVO){ + List<ClientBusinessObject> dataList,CodeKeyAttrRepeatVO keyRuleVO,/*杩戜箟璇嶆煡璇㈣鍒�*/Map<String,List<CodeSynonym>> codeSynonymMaps, CodeImportResultVO resultVO){ Set<String> selfRepeatRowIndexList = new CopyOnWriteArraySet<>(); Map<String,List<String>> keyAttrOkOidTORepeatOidMap=new HashMap<>(); boolean trimAll =keyRuleVO ==null?false: VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag()); @@ -4569,9 +4637,10 @@ 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); + + // TODO锛� 2024-02-25鏀归�犲疄鐜拌繎涔夎瘝鏌ヨ瑙勫垯鍔熻兘锛涘叧閿睘鎬ч噸澶嶆牎楠屽�煎鐞� + attrVOList.stream().forEach(item->{ + String attrId = item.getId().toLowerCase(Locale.ROOT); String value = cbo.getAttributeValue( attrId); if (value == null) { value = ""; @@ -4588,8 +4657,9 @@ if(ignoreWidth){ value = VciBaseUtil.toDBC(value); } + value = mdmEngineService.getValueToSynony(codeSynonymMaps.get(attrId),value); sb.append(value).append("${ks}"); - } + }); String keyString = sb.toString(); if(rowIndexKeyStringMap.containsValue(keyString) && StringUtils.isNotBlank(keyString)){ selfRepeatRowIndexList.add(rowIndex); @@ -4600,7 +4670,6 @@ if(keyAttrOkOidTORepeatOidMap.containsKey(okOid)){ List<String> oldOidList = keyAttrOkOidTORepeatOidMap.get(okOid); newOidList.addAll(oldOidList); - } keyAttrOkOidTORepeatOidMap.put(okOid,newOidList); } @@ -4639,6 +4708,7 @@ } } } + private List<ClientBusinessObject> ChangeMapTOClientBusinessObjects(List<Map<String,String>> oldDataMap){ List<ClientBusinessObject> clientBusinessObjectList=new ArrayList<>(); DefaultAttrAssimtUtil.mapToLowerCase(oldDataMap,true); -- Gitblit v1.9.3