| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.vci.ubcs.code.bo.AttributeValue; |
| | | import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO; |
| | | import com.vci.ubcs.code.bo.CodeTemplateAttrSqlBO; |
| | | import com.vci.ubcs.code.dto.CodeOrderDTO; |
| | | import com.vci.ubcs.code.service.ICodeClassifyService; |
| | | import com.vci.ubcs.code.service.MdmEngineService; |
| | | import com.vci.ubcs.code.service.MdmIOService; |
| | | import com.vci.ubcs.code.enumpack.CodeDefaultLC; |
| | | import com.vci.ubcs.code.enumpack.CodeLevelTypeEnum; |
| | | import com.vci.ubcs.code.mapper.CommonsMapper; |
| | | import com.vci.ubcs.code.service.*; |
| | | import com.vci.ubcs.code.util.ClientBusinessObject; |
| | | import com.vci.ubcs.code.vo.CodeKeyAttrRepeatVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.attrmap.DataObjectVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.attrmap.RowDatas; |
| | |
| | | import com.vci.ubcs.starter.poi.bo.SheetRowData; |
| | | import com.vci.ubcs.starter.poi.bo.WriteExcelOption; |
| | | import com.vci.ubcs.starter.poi.util.ExcelUtil; |
| | | import com.vci.ubcs.starter.revision.model.BaseModel; |
| | | import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; |
| | | import com.vci.ubcs.starter.util.LocalFileUtil; |
| | | import com.vci.ubcs.starter.web.enumpck.BooleanEnum; |
| | | import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum; |
| | | import com.vci.ubcs.starter.web.pagemodel.DataGrid; |
| | | import com.vci.ubcs.starter.web.pagemodel.KeyValue; |
| | | import com.vci.ubcs.starter.web.util.LangBaseUtil; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.starter.web.util.VciDateUtil; |
| | | import com.vci.ubcs.starter.web.pagemodel.PageHelper; |
| | | import com.vci.ubcs.starter.web.pagemodel.UIFormReferVO; |
| | | import com.vci.ubcs.starter.web.toolmodel.DateConverter; |
| | | import com.vci.ubcs.starter.web.util.*; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.hssf.usermodel.HSSFRichTextString; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.poi.hssf.util.HSSFColor; |
| | |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.concurrent.CopyOnWriteArraySet; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.alibaba.druid.util.FnvHash.Constants.LIMIT; |
| | | import static com.vci.ubcs.code.constant.MdmEngineConstant.*; |
| | | import static com.vci.ubcs.starter.poi.util.ExcelUtil.KEY_ATTR_CHAR; |
| | | import static com.vci.ubcs.starter.poi.util.ExcelUtil.REQUIRED_CHAR; |
| | | import static com.vci.ubcs.starter.poi.util.ExcelUtil.*; |
| | | |
| | | @AllArgsConstructor |
| | | @Service |
| | | @Slf4j |
| | | public class MdmIOServiceImpl implements MdmIOService { |
| | | |
| | | |
| | | @Value("${batchadd.redis.time:6000000}") |
| | | public int BATCHADD_REDIS_TIME; |
| | | /** |
| | | * 主é¢åºåç±»çæå¡ |
| | | */ |
| | | @Resource |
| | | private ICodeClassifyService classifyService; |
| | | |
| | | /** |
| | | * éç¨æ¥è¯¢ |
| | | */ |
| | | @Resource |
| | | CommonsMapper commonsMapper; |
| | | |
| | | /** |
| | | * 模æ¿çæå¡ |
| | |
| | | */ |
| | | @Resource |
| | | private MdmEngineService engineService; |
| | | |
| | | /*** |
| | | * resdisç¼åæå¡ |
| | | */ |
| | | private final BladeRedis bladeRedis; |
| | | /** |
| | | * çæç¼ç çæå¡ |
| | | */ |
| | | @Resource |
| | | private MdmProductCodeService productCodeService; |
| | | /** |
| | | * å
³é®å±æ§çé
ç½® |
| | | */ |
| | | @Autowired |
| | | private ICodeKeyAttrRepeatService keyRuleService; |
| | | |
| | | /** |
| | | * å
¬å¼çæå¡ |
| | | */ |
| | | @Autowired |
| | | private FormulaServiceImpl formulaService; |
| | | /** |
| | | * çæå¯¼å
¥çæä»¶ |
| | | * |
| | |
| | | */ |
| | | private String batchImportCodes(CodeOrderDTO orderDTO,CodeClassifyTemplateVO templateVO,SheetDataSet dataSet,Map<String,String> errorMap,boolean isEnumType){ |
| | | List<String> codeList=new ArrayList<>(); |
| | | // CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid()); |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid()); |
| | | //è§åç主é®éè¦å»è·å |
| | | // CodeRuleVO ruleVO = engineService.getCodeRuleByClassifyFullInfo(classifyFullInfo); |
| | | // //1.夿è§åä¸é¤äºæµæ°´ç æ®µï¼æ¯å¦æå
¶ä»ç 段 |
| | | // engineService.checkSecValueOnOrder(ruleVO,orderDTO); |
| | | // List<SheetRowData> rowDataList = dataSet.getRowData(); |
| | | // |
| | | // //é¤å»é»è®¤ç屿§.è¿æåªæè¡¨åæ¾ç¤ºçåæ®µæå¯¼å
¥ |
| | | // List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> |
| | | // !DEFAULT_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormdisplayflag()) |
| | | // ).collect(Collectors.toList()); |
| | | // Map<Integer/**åå·**/,String/**åæ®µçåç§°**/> fieldIndexMap = new HashMap<>(); |
| | | // List<String> titleRowData = dataSet.getColName(); |
| | | // Map<String/**䏿åç§°**/, String/**è±æåç§°**/> attrNameIdMap = attrVOS.stream().collect(Collectors.toMap(s -> s.getName(), t -> t.getId().toLowerCase(Locale.ROOT),(o1, o2)->o2)); |
| | | // getFieldIndexMap(titleRowData,attrNameIdMap,fieldIndexMap); |
| | | // |
| | | // //éè¦å¤ææ¯å¦ææç屿§é½å¨æ¨¡æ¿ä¸äº |
| | | // List<CodeClassifyTemplateAttrVO> unExistAttrVOs = attrVOS.stream().filter(s -> !fieldIndexMap.containsValue(s.getId().toLowerCase(Locale.ROOT)) |
| | | // && StringUtils.isBlank(s.getComponentrule()) && StringUtils.isBlank(s.getClassifyinvokeattr())//ç»åè§ååå类注å
¥ç¡®å®æ²¡ç»ç¨æ·å¯¼åºå» |
| | | // ).collect(Collectors.toList()); |
| | | // if(!CollectionUtils.isEmpty(unExistAttrVOs)){ |
| | | // throw new VciBaseException("ã" + unExistAttrVOs.stream().map(CodeClassifyTemplateAttrVO::getName) + "ãè¿äºå±æ§å¨åè¡¨ä¸æ²¡ææ¾å°"); |
| | | // } |
| | | // List<ClientBusinessObject> cboList = new ArrayList<>(); |
| | | // String fullPath = getFullPath(classifyFullInfo); |
| | | // excelToCbo(classifyFullInfo,fieldIndexMap,rowDataList,templateVO,cboList,fullPath,true); |
| | | // |
| | | // //é½è½¬æ¢å®äºãéè¦æ¹éæ£æ¥ |
| | | // //妿åºéäºï¼æä»¬ä¾ç¶æ§è¡ææçæ°æ®ï¼æ æçæ°æ®ååå°excelä¸ |
| | | // //2.夿å¿
è¾é¡¹ããéè¦å
¨é¨ç屿§ï¼å¦ææ¯å¿
è¾ï¼ä½æ¯è¡¨åéé¢ä¸æ¾ç¤ºçï¼åªè½æ¯å类注å
¥æè
ç»åè§å |
| | | // batchCheckRequiredAttrOnOrder(templateVO,cboList,errorMap); |
| | | // //3.夿å
³é®å±æ§ |
| | | // CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList); |
| | | // Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList(); |
| | | // Set<String> keyAttrRepeatRowIndexList = keyResultVO.getKeyAttrRepeatRowIndexList(); |
| | | // if(!CollectionUtils.isEmpty(selfRepeatRowIndexList)){ |
| | | // selfRepeatRowIndexList.stream().forEach(rowIndex->{ |
| | | // errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";å¨å½åå¤ççæ°æ®æä»¶ä¸å
³é®å±æ§éå¤" ); |
| | | // }); |
| | | // } |
| | | // if(!CollectionUtils.isEmpty(keyAttrRepeatRowIndexList)){ |
| | | // keyAttrRepeatRowIndexList.stream().forEach(rowIndex->{ |
| | | // errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";å
³é®å±æ§ä¸ç³»ç»ä¸çéå¤" ); |
| | | // }); |
| | | // } |
| | | // //å类注å
¥ |
| | | // batchSwitchClassifyAttrOnOrder(attrVOS,cboList,classifyFullInfo,false); |
| | | // //boolean |
| | | // reSwitchBooleanAttrOnOrder(attrVOS,cboList); |
| | | // //4.æ ¡éªè§å |
| | | // batchCheckVerifyOnOrder(attrVOS, cboList,errorMap); |
| | | // if(isEnumType) {//æ¯å¦éè¦æ ¡éªæä¸¾/åç
§ |
| | | // //5.æ ¡éªæä¸¾æ¯å¦æ£ç¡® |
| | | // batchSwitchEnumAttrOnOrder(attrVOS, cboList, errorMap); |
| | | // //7.å¤çåç
§çæ
åµ |
| | | // batchSwitchReferAttrOnOrder(attrVOS,cboList,errorMap); |
| | | // } |
| | | // //6.æ¶é´æ ¼å¼çéªè¯ |
| | | // //6.æ¶é´çï¼å¿
é¡»ç»ä¸ä¸ºyyyy-MM-dd HH:mm:ss |
| | | // batchSwitchDateAttrOnOrder(attrVOS,cboList,errorMap); |
| | | // //æåå¼ç»åè§å |
| | | // batchSwitchComponentAttrOnOrder(attrVOS,cboList); |
| | | // String uuid=redisService.getUUIDEveryDay(); |
| | | // Map<String, ClientBusinessObject> rowIndexCboMap = cboList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getAttributeValue((IMPORT_ROW_INDEX)), t -> t)); |
| | | // |
| | | // if(errorMap.size()>0) { |
| | | // createRedisDatas(uuid + "-error",templateVO, rowIndexCboMap, dataSet, fieldIndexMap, errorMap,false); |
| | | // } |
| | | // boolean isCreateUUid=false; |
| | | // List<ClientBusinessObject> needSaveCboList = cboList.stream().filter(cbo -> { |
| | | // String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | // return !errorMap.containsKey(rowIndex); |
| | | // }).collect(Collectors.toList()); |
| | | // //ç¸ä¼¼æ ¡éª |
| | | // 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; |
| | | // if(!CollectionUtils.isEmpty(dataResembleVOS)) { |
| | | // redisService.setCacheList(uuid + "-resemble-data", dataResembleVOS); |
| | | // createRedisDatas(uuid + "-resemble",templateVO, rowIndexCboMap, dataSet, fieldIndexMap, resembleMap, false); |
| | | // } |
| | | // } |
| | | // //æé¤é误çï¼å©ä¸æ£ç¡®ç |
| | | // Map<String,String> newErrorMap=new HashMap<>(); |
| | | // newErrorMap.putAll(resembleMap); |
| | | // newErrorMap.putAll(errorMap); |
| | | // needSaveCboList = cboList.stream().filter(cbo -> { |
| | | // String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | // return !newErrorMap.containsKey(rowIndex); |
| | | // }).collect(Collectors.toList()); |
| | | // if((errorMap.size()>0&&needSaveCboList.size()>0)||resembleMap.size()>0){ |
| | | // isCreateUUid=true; |
| | | // } |
| | | // createRedisByCodeClassify(uuid + "-class",templateVO,dataSet,fieldIndexMap,false); |
| | | // if(newErrorMap.size()>0) { |
| | | // createRedisDatas(uuid + "-ok",templateVO, rowIndexCboMap, dataSet, fieldIndexMap, newErrorMap,true); |
| | | // }else { |
| | | // uuid=""; |
| | | // //è¦æä»¥ä¸çé误ç齿åºåï¼åç»§ç»å¤çæ¶é´åç»åè§å |
| | | // needSaveCboList = cboList.stream().filter(cbo -> { |
| | | // String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | // return !newErrorMap.containsKey(rowIndex); |
| | | // }).collect(Collectors.toList()); |
| | | // if (!CollectionUtils.isEmpty(needSaveCboList)) { |
| | | // //9.æä»¬å¤çä¸å¡æ°æ® |
| | | // //çæç¼ç çå
容 |
| | | // codeList = productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(), needSaveCboList); |
| | | // //妿æ¯ç¼ç çæå¤±è´¥ï¼åç´æ¥å°±å¤±è´¥äºï¼å
¶ä»çå¤æåºæ¥æé误çæä»¬é½ç»ä¸è¿åå°exceléé¢ |
| | | // engineService.batchSaveSelectChar(templateVO, needSaveCboList); |
| | | // } |
| | | // } |
| | | // if(!isCreateUUid){ |
| | | // return uuid=""; |
| | | // } |
| | | // return uuid; |
| | | return null; |
| | | CodeRuleVO ruleVO = engineService.getCodeRuleByClassifyFullInfo(classifyFullInfo); |
| | | //1.夿è§åä¸é¤äºæµæ°´ç æ®µï¼æ¯å¦æå
¶ä»ç 段 |
| | | engineService.checkSecValueOnOrder(ruleVO,orderDTO); |
| | | List<SheetRowData> rowDataList = dataSet.getRowData(); |
| | | |
| | | //é¤å»é»è®¤ç屿§.è¿æåªæè¡¨åæ¾ç¤ºçåæ®µæå¯¼å
¥ |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> |
| | | !DEFAULT_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag()) |
| | | ).collect(Collectors.toList()); |
| | | Map<Integer/**åå·**/,String/**åæ®µçåç§°**/> fieldIndexMap = new HashMap<>(); |
| | | List<String> titleRowData = dataSet.getColName(); |
| | | Map<String/**䏿åç§°**/, String/**è±æåç§°**/> attrNameIdMap = attrVOS.stream().collect(Collectors.toMap(s -> s.getName(), t -> t.getId().toLowerCase(Locale.ROOT),(o1, o2)->o2)); |
| | | getFieldIndexMap(titleRowData,attrNameIdMap,fieldIndexMap); |
| | | |
| | | //éè¦å¤ææ¯å¦ææç屿§é½å¨æ¨¡æ¿ä¸äº |
| | | List<CodeClassifyTemplateAttrVO> unExistAttrVOs = attrVOS.stream().filter(s -> !fieldIndexMap.containsValue(s.getId().toLowerCase(Locale.ROOT)) |
| | | && StringUtils.isBlank(s.getComponentRule()) && StringUtils.isBlank(s.getClassifyInvokeAttr())//ç»åè§ååå类注å
¥ç¡®å®æ²¡ç»ç¨æ·å¯¼åºå» |
| | | ).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(unExistAttrVOs)){ |
| | | throw new VciBaseException("ã" + unExistAttrVOs.stream().map(CodeClassifyTemplateAttrVO::getName) + "ãè¿äºå±æ§å¨åè¡¨ä¸æ²¡ææ¾å°"); |
| | | } |
| | | List<ClientBusinessObject> cboList = new ArrayList<>(); |
| | | String fullPath = getFullPath(classifyFullInfo); |
| | | excelToCbo(classifyFullInfo,fieldIndexMap,rowDataList,templateVO,cboList,fullPath,true); |
| | | |
| | | //é½è½¬æ¢å®äºãéè¦æ¹éæ£æ¥ |
| | | //妿åºéäºï¼æä»¬ä¾ç¶æ§è¡ææçæ°æ®ï¼æ æçæ°æ®ååå°excelä¸ |
| | | //2.夿å¿
è¾é¡¹ããéè¦å
¨é¨ç屿§ï¼å¦ææ¯å¿
è¾ï¼ä½æ¯è¡¨åéé¢ä¸æ¾ç¤ºçï¼åªè½æ¯å类注å
¥æè
ç»åè§å |
| | | batchCheckRequiredAttrOnOrder(templateVO,cboList,errorMap); |
| | | //3.夿å
³é®å±æ§ |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, cboList); |
| | | Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList(); |
| | | Set<String> keyAttrRepeatRowIndexList = keyResultVO.getKeyAttrRepeatRowIndexList(); |
| | | if(!CollectionUtils.isEmpty(selfRepeatRowIndexList)){ |
| | | selfRepeatRowIndexList.stream().forEach(rowIndex->{ |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";å¨å½åå¤ççæ°æ®æä»¶ä¸å
³é®å±æ§éå¤" ); |
| | | }); |
| | | } |
| | | if(!CollectionUtils.isEmpty(keyAttrRepeatRowIndexList)){ |
| | | keyAttrRepeatRowIndexList.stream().forEach(rowIndex->{ |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";å
³é®å±æ§ä¸ç³»ç»ä¸çéå¤" ); |
| | | }); |
| | | } |
| | | //å类注å
¥ |
| | | batchSwitchClassifyAttrOnOrder(attrVOS,cboList,classifyFullInfo,false); |
| | | //boolean |
| | | reSwitchBooleanAttrOnOrder(attrVOS,cboList); |
| | | //4.æ ¡éªè§å |
| | | batchCheckVerifyOnOrder(attrVOS, cboList,errorMap); |
| | | if(isEnumType) {//æ¯å¦éè¦æ ¡éªæä¸¾/åç
§ |
| | | //5.æ ¡éªæä¸¾æ¯å¦æ£ç¡® |
| | | batchSwitchEnumAttrOnOrder(attrVOS, cboList, errorMap); |
| | | //7.å¤çåç
§çæ
åµ |
| | | batchSwitchReferAttrOnOrder(attrVOS,cboList,errorMap); |
| | | } |
| | | //6.æ¶é´æ ¼å¼çéªè¯ |
| | | //6.æ¶é´çï¼å¿
é¡»ç»ä¸ä¸ºyyyy-MM-dd HH:mm:ss |
| | | batchSwitchDateAttrOnOrder(attrVOS,cboList,errorMap); |
| | | //æåå¼ç»åè§å |
| | | batchSwitchComponentAttrOnOrder(attrVOS,cboList); |
| | | String uuid=VciBaseUtil.getPk(); |
| | | Map<String, ClientBusinessObject> rowIndexCboMap = cboList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getAttributeValue((IMPORT_ROW_INDEX)), t -> t)); |
| | | |
| | | if(errorMap.size()>0) { |
| | | createRedisDatas(uuid + "-error",templateVO, rowIndexCboMap, dataSet, fieldIndexMap, errorMap,false); |
| | | } |
| | | boolean isCreateUUid=false; |
| | | List<ClientBusinessObject> needSaveCboList = cboList.stream().filter(cbo -> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | return !errorMap.containsKey(rowIndex); |
| | | }).collect(Collectors.toList()); |
| | | //ç¸ä¼¼æ ¡éª |
| | | 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; |
| | | if(!CollectionUtils.isEmpty(dataResembleVOS)) { |
| | | bladeRedis.set(uuid + "-resemble-data", dataResembleVOS); |
| | | createRedisDatas(uuid + "-resemble",templateVO, rowIndexCboMap, dataSet, fieldIndexMap, resembleMap, false); |
| | | } |
| | | } |
| | | //æé¤é误çï¼å©ä¸æ£ç¡®ç |
| | | Map<String,String> newErrorMap=new HashMap<>(); |
| | | newErrorMap.putAll(resembleMap); |
| | | newErrorMap.putAll(errorMap); |
| | | needSaveCboList = cboList.stream().filter(cbo -> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | return !newErrorMap.containsKey(rowIndex); |
| | | }).collect(Collectors.toList()); |
| | | if((errorMap.size()>0&&needSaveCboList.size()>0)||resembleMap.size()>0){ |
| | | isCreateUUid=true; |
| | | } |
| | | createRedisByCodeClassify(uuid + "-class",templateVO,dataSet,fieldIndexMap,false); |
| | | if(newErrorMap.size()>0) { |
| | | createRedisDatas(uuid + "-ok",templateVO, rowIndexCboMap, dataSet, fieldIndexMap, newErrorMap,true); |
| | | }else { |
| | | uuid=""; |
| | | |
| | | //è¦æä»¥ä¸çé误ç齿åºåï¼åç»§ç»å¤çæ¶é´åç»åè§å |
| | | /*dataCBOList = cboList.stream().filter(cbo -> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | return !newErrorMap.containsKey(rowIndex); |
| | | }).collect(Collectors.toList()); |
| | | */ List<String> dataCBOIdList=new ArrayList<>(); |
| | | List<BaseModel> dataCBOList=new ArrayList<>(); |
| | | cboList.stream().forEach(clientBusinessObject -> { |
| | | BaseModel baseModel=new BaseModel(); |
| | | BeanUtil.convert(clientBusinessObject,baseModel); |
| | | baseModel.setData(VciBaseUtil.objectToMapString(clientBusinessObject)); |
| | | dataCBOList.add(baseModel); |
| | | dataCBOIdList.add(baseModel.getOid()); |
| | | }); |
| | | |
| | | if (!CollectionUtils.isEmpty(needSaveCboList)) { |
| | | //9.æä»¬å¤çä¸å¡æ°æ® |
| | | //çæç¼ç çå
容 |
| | | try { |
| | | codeList = productCodeService.productCodeAndSaveData(classifyFullInfo,templateVO,ruleVO, orderDTO.getSecDTOList(),dataCBOList); |
| | | //妿æ¯ç¼ç çæå¤±è´¥ï¼åç´æ¥å°±å¤±è´¥äºï¼å
¶ä»çå¤æåºæ¥æé误çæä»¬é½ç»ä¸è¿åå°exceléé¢ |
| | | engineService.batchSaveSelectChar(templateVO, dataCBOIdList); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("æ¹äºç³è¯·æ¶å¤±è´¥"); |
| | | } |
| | | } |
| | | } |
| | | if(!isCreateUUid){ |
| | | return uuid=""; |
| | | } |
| | | return uuid; |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | /** |
| | | * excel转æ¢ä¸ºcboç对象 |
| | | * @param classifyFullInfo åç±»çå
¨é¨ä¿¡æ¯ |
| | | * @param fieldIndexMap åæ®µçä½ç½® |
| | | * @param rowDataList exceléçè¡æ°æ® |
| | | * @param templateVO 模æ¿çæ¾ç¤ºå¯¹è±¡ |
| | | * @param cboList æ°æ®çå表 |
| | | * @param fullPath å
¨è·¯å¾ |
| | | * @param newCode æ¯å¦ä¸ºæ¹éç³è¯· |
| | | */ |
| | | private void excelToCbo(CodeClassifyFullInfoBO classifyFullInfo,Map<Integer,String> fieldIndexMap,List<SheetRowData> rowDataList, |
| | | CodeClassifyTemplateVO templateVO,List<ClientBusinessObject> cboList, |
| | | String fullPath,boolean newCode){ |
| | | rowDataList.stream().forEach(rowData -> { |
| | | ClientBusinessObject cbo=new ClientBusinessObject(); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(cbo, classifyFullInfo.getTopClassifyVO().getBtmtypeid()); |
| | | rowData.getData().forEach((index,value)->{ |
| | | String field = fieldIndexMap.get(index); |
| | | if (StringUtils.isBlank(field)) { |
| | | throw new VciBaseException("第" + (index + 1) + "åçæ é¢å¨ç³»ç»ä¸ä¸åå¨"); |
| | | } |
| | | try { |
| | | cbo.setAttributeValueWithNoCheck(field, value); |
| | | if (WebUtil.isDefaultField(field)) { |
| | | WebUtil.setValueToField(field, cbo, value); |
| | | } |
| | | } catch (VciBaseException e) { |
| | | log.error("è®¾ç½®å±æ§çå¼é误", e); |
| | | } |
| | | }); |
| | | try { |
| | | cbo.setAttributeValue(CODE_TEMPLATE_OID_FIELD,templateVO.getOid()); |
| | | cbo.setAttributeValue(IMPORT_ROW_INDEX,rowData.getRowIndex()); |
| | | if(newCode){ |
| | | cbo.setAttributeValue(CODE_CLASSIFY_OID_FIELD,classifyFullInfo.getCurrentClassifyVO().getOid()); |
| | | cbo.setAttributeValue(CODE_FULL_PATH_FILED,fullPath); |
| | | //cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | int secret = VciBaseUtil.getInt(cbo.getAttributeValue(SECRET_FIELD)); |
| | | /*if(secret == 0 || !secretService.checkDataSecret(secret) ){ |
| | | Integer userSecret = VciBaseUtil.getCurrentUserSecret(); |
| | | cbo.setAttributeValue(SECRET_FIELD,String.valueOf((userSecret==null || userSecret ==0)? UserSecretEnum.NONE.getValue():userSecret)); |
| | | }*/ |
| | | }else{ |
| | | //æ¤æ¶è¿æ²¡æè½¬æ¢è·¯å¾ |
| | | //cbo.setAttributeValue(CODE_FULL_PATH_FILED, childOidPathMap.getOrDefault(rowData.getData().getOrDefault(CODE_CLASSIFY_OID_FIELD,""),fullPath)); |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | } |
| | | |
| | | }catch (Throwable e){ |
| | | log.error("设置é»è®¤ç屿§çå¼é误",e); |
| | | } |
| | | cboList.add(cbo); |
| | | }); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥æ ¡éªè§å没æéè¿çå
容 |
| | | * @param attrVOS éè¦æ ¡éªç屿§ |
| | | * @param dataList æ°æ®çå表 |
| | | * @param errorMap é误çä¿¡æ¯æ å° |
| | | * @return æ ¡éªä¸éè¿çè¡æ° |
| | | */ |
| | | private void batchCheckVerifyOnOrder(Collection<CodeClassifyTemplateAttrVO> attrVOS, List<ClientBusinessObject> dataList,Map<String,String> errorMap) { |
| | | Map<String, CodeClassifyTemplateAttrVO> verifyAttrVOMap = attrVOS.stream().filter(s -> StringUtils.isNotBlank(s.getVerifyRule()) && StringUtils.isBlank(s.getComponentRule()) |
| | | &&StringUtils.isBlank(s.getClassifyInvokeAttr()) |
| | | ).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | if(!CollectionUtils.isEmpty(verifyAttrVOMap)){ |
| | | Map<String/**è¡å·**/,List<String>/**æ ¡éªä¸éè¿ç屿§**/> unPassCheckMap = new HashMap<>(); |
| | | verifyAttrVOMap.forEach((attrId,attrVO)->{ |
| | | dataList.stream().forEach(cbo -> { |
| | | String value = cbo.getAttributeValue(attrId); |
| | | if(StringUtils.isNotBlank(value) && !value.matches(attrVO.getVerifyRule())){ |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | List<String> unPassAttrs = unPassCheckMap.getOrDefault(rowIndex, new ArrayList<>()); |
| | | unPassAttrs.add(attrVO.getName()); |
| | | unPassCheckMap.put(rowIndex,unPassAttrs); |
| | | } |
| | | }); |
| | | }); |
| | | if(!CollectionUtils.isEmpty(unPassCheckMap)){ |
| | | unPassCheckMap.forEach((rowIndex,unPassAttrs)->{ |
| | | errorMap.put(rowIndex,";屿§[" + unPassAttrs.stream().collect(Collectors.joining(",")) + "]å
容ä¸ç¬¦åæ ¡éªè§åçè¦æ±"); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * æ¹éè½¬æ¢æ¶é´é½ä¸ºæå®çæ ¼å¼ |
| | | * @param attrVOS 模æ¿å±æ§ |
| | | * @param cboList æ°æ®çå表 |
| | | * @param errorMap é误çä¿¡æ¯ |
| | | */ |
| | | private void batchSwitchDateAttrOnOrder(Collection<CodeClassifyTemplateAttrVO> attrVOS,List<ClientBusinessObject> cboList,Map<String,String> errorMap){ |
| | | Map<String, CodeClassifyTemplateAttrVO> dateAttrVOMap =attrVOS.stream().filter(s -> |
| | | StringUtils.isNotBlank(s.getCodeDateFormat()) && VciBaseUtil.getBoolean(s.getCodeDateFormat()) && StringUtils.isBlank(s.getComponentRule()) |
| | | && StringUtils.isBlank(s.getClassifyInvokeAttr()) |
| | | ).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | if(!CollectionUtils.isEmpty(dateAttrVOMap)) { |
| | | dateAttrVOMap.forEach((attrId, attrVO) -> { |
| | | cboList.stream().forEach(cbo -> { |
| | | String value = cbo.getAttributeValue(attrId); |
| | | if (value == null) { |
| | | value = ""; |
| | | } |
| | | if (StringUtils.isNotBlank(value)) { |
| | | boolean formated = false; |
| | | if(StringUtils.isNotBlank(attrVO.getCodeDateFormat())){ |
| | | try { |
| | | Date date = VciDateUtil.str2Date(value, attrVO.getCodeDateFormat()); |
| | | if(date!=null){ |
| | | cbo.setAttributeValue(attrId,value); |
| | | formated = true; |
| | | } |
| | | } catch (Exception e) { |
| | | //说æä¸æ¯è¿ä¸ªæ ¼å¼ |
| | | } |
| | | } |
| | | if(!formated) { |
| | | try { |
| | | DateConverter dateConverter = new DateConverter(); |
| | | dateConverter.setAsText(value); |
| | | value = VciDateUtil.date2Str(dateConverter.getValue(), VciDateUtil.DateTimeMillFormat); |
| | | cbo.setAttributeValue(attrId,value); |
| | | }catch (Throwable e){ |
| | | //转æ¢ä¸äº |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";屿§[" + attrVO.getName() + "]æ¶é´æ ¼å¼ä¸æ£ç¡®" ); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | /** |
| | | * 转移booleanåç屿§ |
| | | * @param attrVOS 屿§ç对象 |
| | | * @param dataList æ°æ® |
| | | */ |
| | | private void reSwitchBooleanAttrOnOrder(Collection<CodeClassifyTemplateAttrVO> attrVOS,List<ClientBusinessObject> dataList){ |
| | | Map<String, CodeClassifyTemplateAttrVO> booleanAttrMap = attrVOS.stream().filter( |
| | | s -> VciFieldTypeEnum.VTBoolean.name().equalsIgnoreCase(s.getAttributeDataType()) |
| | | ).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | if (!CollectionUtils.isEmpty(booleanAttrMap)) { |
| | | booleanAttrMap.forEach((attrId, attrVO) -> { |
| | | dataList.stream().forEach(cbo -> { |
| | | String text = cbo.getAttributeValue(attrId); |
| | | try { |
| | | if (BooleanEnum.TRUE.getValue().equalsIgnoreCase(text) || "æ¯".equalsIgnoreCase(text)) { |
| | | cbo.setAttributeValue(attrId, BooleanEnum.TRUE.getValue()); |
| | | } else { |
| | | cbo.setAttributeValue(attrId, BooleanEnum.FASLE.getValue()); |
| | | } |
| | | }catch (Throwable e){ |
| | | |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¤çç»åè§å |
| | | * @param attrVOS 模æ¿å±æ§ |
| | | * @param dataList excelçæ°æ®å
容 |
| | | */ |
| | | private void batchSwitchComponentAttrOnOrder(Collection<CodeClassifyTemplateAttrVO> attrVOS,List<ClientBusinessObject> dataList) { |
| | | Map<String, CodeClassifyTemplateAttrVO> dateAttrVOMap = attrVOS.stream().filter(s -> StringUtils.isNotBlank(s.getComponentRule())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | if(!CollectionUtils.isEmpty(dateAttrVOMap)) { |
| | | dateAttrVOMap.forEach((attrId, attrVO) -> { |
| | | dataList.stream().forEach(cbo -> { |
| | | //ä»excel䏿屿§è½¬æ¢ä¸ºmap |
| | | Map<String,String> thisRowDataMap = new HashMap<>(); |
| | | copyValueToMapFromCbos(cbo,thisRowDataMap); |
| | | //ç»åå
容 |
| | | String value = formulaService.getValueByFormula(thisRowDataMap,attrVO.getComponentRule()); |
| | | if(value == null){ |
| | | value = ""; |
| | | } |
| | | try { |
| | | cbo.setAttributeValue(attrId, value); |
| | | }catch (Throwable e){ |
| | | log.error("è®¾ç½®å±æ§çé误",e); |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转æ¢åç
§çå¼ |
| | | * @param attrVOS 屿§çæ¾ç¤ºå¯¹è±¡ |
| | | * @param dataList æ°æ®å表 |
| | | * @param errorMap é误çä¿¡æ¯ |
| | | */ |
| | | private void batchSwitchReferAttrOnOrder(Collection<CodeClassifyTemplateAttrVO> attrVOS,List<ClientBusinessObject> dataList,Map<String,String> errorMap){ |
| | | Map<String, CodeClassifyTemplateAttrVO> referAttrVOMap = attrVOS.stream().filter( |
| | | s -> (StringUtils.isNotBlank(s.getReferBtmId()) || StringUtils.isNotBlank(s.getReferConfig())) |
| | | ).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | if(!CollectionUtils.isEmpty(referAttrVOMap)){ |
| | | Map<String/**è¡¨æ ¼åå¼ç屿§**/,Map<String/**æ¾ç¤ºå±æ§çå¼**/,List<String>/**è¡¨æ ¼éçå¼**/>> linkValueMap = new HashMap<>(); |
| | | referAttrVOMap.forEach((attrId,attrVO)->{ |
| | | dataList.stream().forEach(cbo -> { |
| | | String text = cbo.getAttributeValue(attrId); |
| | | if(StringUtils.isNotBlank(text)){ |
| | | UIFormReferVO referVO = getReferVO(attrVO); |
| | | String valueField = getValueField(referVO); |
| | | String showText = getTextField(referVO); |
| | | String tableAndAttr = VciBaseUtil.getTableName(referVO.getReferType()) + "#" + valueField; |
| | | Map<String, List<String>> showTextMap = linkValueMap.getOrDefault(tableAndAttr, new HashMap<>()); |
| | | List<String> textList = showTextMap.getOrDefault(showText, new ArrayList<>()); |
| | | if(!textList.contains(text)) { |
| | | textList.add(text); |
| | | } |
| | | showTextMap.put(showText,textList); |
| | | linkValueMap.put(tableAndAttr,showTextMap); |
| | | } |
| | | }); |
| | | }); |
| | | if(!CollectionUtils.isEmpty(linkValueMap)){ |
| | | //éè¦é个表çå¼å段ï¼é个æ¥è¯¢ |
| | | Map<String/**è¡¨æ ¼åå¼å±æ§**/,Map<String/**æ¾ç¤ºå±æ§**/, Map<String/**å¼**/,String/**æ¾ç¤ºçå¼**/>>> linkCboMap = new HashMap<>(); |
| | | linkValueMap.forEach((tableAndAttr,showValueMap)->{ |
| | | String[] split = tableAndAttr.split("#"); |
| | | String table = split[0]; |
| | | String valueField = split[1].toLowerCase(Locale.ROOT); |
| | | Map<String,Map<String,String>> dataMap = new HashMap<>(); |
| | | showValueMap.forEach((showText,valueList)->{ |
| | | Map<String,String> valueOidTextMap = new HashMap<>(); |
| | | List<List<String>> valueCollections = VciBaseUtil.switchListForOracleIn(valueList); |
| | | String sql = "select " + valueField + "," + showText.toLowerCase(Locale.ROOT) +" from " + table + " where " + showText + " in (%s)"; |
| | | valueCollections.stream().forEach(values->{ |
| | | List<Map<String,String>> dataMapList = commonsMapper.queryByOnlySqlForMap(String.format(sql, VciBaseUtil.toInSql(values.toArray(new String[0])))); |
| | | List<ClientBusinessObject> cbos= ChangeMapTOClientBusinessObjects(dataMapList); |
| | | if(!CollectionUtils.isEmpty(cbos)){ |
| | | valueOidTextMap.putAll(cbos.stream().collect(Collectors.toMap(s->s.getAttributeValue(valueField),t->t.getAttributeValue(showText)))); |
| | | } |
| | | }); |
| | | dataMap.put(showText,valueOidTextMap); |
| | | }); |
| | | linkCboMap.put(tableAndAttr,dataMap); |
| | | }); |
| | | referAttrVOMap.forEach((attrId,attrVO)->{ |
| | | dataList.stream().forEach(cbo -> { |
| | | String text = cbo.getAttributeValue(attrId); |
| | | if (StringUtils.isNotBlank(text)) { |
| | | UIFormReferVO referVO = getReferVO(attrVO); |
| | | String valueField = getValueField(referVO); |
| | | String showText = getTextField(referVO); |
| | | String tableAndAttr = VciBaseUtil.getTableName(referVO.getReferType()) + "#" + valueField; |
| | | if(!linkCboMap.containsKey(tableAndAttr)){ |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";忰屿§[" + attrVO.getName() + "]çå¼å¨ç³»ç»ä¸ä¸åå¨" ); |
| | | |
| | | }else{ |
| | | Map<String, Map<String, String>> dataMap = linkCboMap.get(tableAndAttr); |
| | | if(!dataMap.containsKey(showText)){ |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";忰屿§[" + attrVO.getName() + "]çå¼å¨ç³»ç»ä¸ä¸åå¨" ); |
| | | }else{ |
| | | Map<String, String> data = dataMap.get(showText); |
| | | final boolean[] fined = {false}; |
| | | data.forEach((key,value)->{ |
| | | if(value.equalsIgnoreCase(text)){ |
| | | fined[0] = true; |
| | | try { |
| | | cbo.setAttributeValue(attrId, key); |
| | | }catch (Throwable e){ |
| | | |
| | | } |
| | | } |
| | | }); |
| | | if(!fined[0]){ |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";忰屿§[" + attrVO.getName() + "]çå¼å¨ç³»ç»ä¸ä¸åå¨" ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * ä»å±æ§ä¸è·ååç
§çå
容 |
| | | * @param attrVO 屿§çä¿¡æ¯ |
| | | * @return åç
§çå
容 |
| | | */ |
| | | private UIFormReferVO getReferVO(CodeClassifyTemplateAttrVO attrVO){ |
| | | UIFormReferVO referVO = null; |
| | | if(StringUtils.isNotBlank(attrVO.getReferConfig())){ |
| | | referVO = JSONObject.parseObject(attrVO.getReferConfig(),UIFormReferVO.class); |
| | | }else{ |
| | | referVO = new UIFormReferVO(); |
| | | referVO.setReferType(attrVO.getReferBtmId()); |
| | | referVO.setValueField(VciQueryWrapperForDO.OID_FIELD); |
| | | referVO.setTextField("name"); |
| | | } |
| | | return referVO; |
| | | } |
| | | |
| | | /** |
| | | * è·ååç
§ä¸çå¼çåæ®µ |
| | | * @param referVO åç
§ç对象 |
| | | * @return é»è®¤ä¸ºOidï¼æå¤ä¸ªçæ¶åï¼è·å第ä¸ä¸ª |
| | | */ |
| | | private String getValueField(UIFormReferVO referVO){ |
| | | String showText = referVO.getValueField(); |
| | | if(StringUtils.isBlank(showText)){ |
| | | return "oid"; |
| | | } |
| | | if(showText.contains(",")){ |
| | | //鲿¢ä¸ä¸æå¤ä¸ªï¼ççææ²¡æoid |
| | | List<String> strings = VciBaseUtil.str2List(showText); |
| | | if(strings.contains("oid")){ |
| | | showText = "oid"; |
| | | }else{ |
| | | showText = strings.get(0); |
| | | } |
| | | } |
| | | return showText; |
| | | } |
| | | |
| | | /** |
| | | * è·ååç
§ä¸çæ¾ç¤ºå
容çåæ®µ |
| | | * @param referVO åç
§ç对象 |
| | | * @return é»è®¤ä¸ºnameï¼æå¤ä¸ªçæ¶åï¼è·å第ä¸ä¸ª |
| | | */ |
| | | private String getTextField(UIFormReferVO referVO){ |
| | | String showText = referVO.getTextField(); |
| | | if(StringUtils.isBlank(showText)){ |
| | | return "name"; |
| | | } |
| | | if(showText.contains(",")){ |
| | | //鲿¢ä¸ä¸æå¤ä¸ªï¼ççææ²¡æname |
| | | List<String> strings = VciBaseUtil.str2List(showText); |
| | | if(strings.contains("name")){ |
| | | showText = "name"; |
| | | }else{ |
| | | showText = strings.get(0); |
| | | } |
| | | } |
| | | return showText; |
| | | } |
| | | /** |
| | | * å¤çæä¸¾çæ¾ç¤ºå¯¹è±¡ |
| | | * @param attrVOS 模æ¿å±æ§ |
| | | * @param dataList excelçæ°æ®å
容 |
| | | * @param errorMap é误信æ¯çæ å° |
| | | */ |
| | | private void batchSwitchEnumAttrOnOrder(Collection<CodeClassifyTemplateAttrVO> attrVOS,List<ClientBusinessObject> dataList, |
| | | Map<String,String> errorMap ) { |
| | | Map<String, CodeClassifyTemplateAttrVO> dateAttrVOMap = attrVOS.stream().filter( |
| | | s -> (StringUtils.isNotBlank(s.getEnumString()) || StringUtils.isNotBlank(s.getEnumId())) |
| | | ).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | if (!CollectionUtils.isEmpty(dateAttrVOMap)) { |
| | | dateAttrVOMap.forEach((attrId, attrVO) -> { |
| | | dataList.stream().forEach(cbo -> { |
| | | String text = cbo.getAttributeValue(attrId); |
| | | if(StringUtils.isNotBlank(text)){ |
| | | List<KeyValue> valueList = engineService.listComboboxItems(attrVO); |
| | | boolean fined = false; |
| | | for (int i = 0; i < valueList.size(); i++) { |
| | | KeyValue keyValue = valueList.get(i); |
| | | //if(keyValue.getValue().equalsIgnoreCase(text)){ |
| | | if(keyValue.getValue().equalsIgnoreCase(text)||keyValue.getKey().equalsIgnoreCase(text)){ |
| | | try { |
| | | cbo.setAttributeValue(attrId, keyValue.getKey()); |
| | | }catch (Throwable e){ |
| | | log.error("è®¾ç½®å±æ§åºé"); |
| | | } |
| | | fined = true; |
| | | break; |
| | | } |
| | | } |
| | | if(!fined){ |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";屿§[" + attrVO.getName() + "]çå¼ä¸ç¬¦å䏿çè¦æ±"); |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¹éæ ¡éªæ°æ®çä¿¡æ¯ |
| | | * @param templateVO 模æ¿çæ¾ç¤ºå¯¹è±¡ |
| | | * @param cboList æ°æ®çå
容 |
| | | */ |
| | | private void batchCheckRequiredAttrOnOrder(CodeClassifyTemplateVO templateVO,List<ClientBusinessObject> cboList,Map<String,String> errorMap){ |
| | | Map<String, CodeClassifyTemplateAttrVO> requiredAttrMap = templateVO.getAttributes().stream().filter(s -> |
| | | VciBaseUtil.getBoolean(s.getRequireFlag()) && StringUtils.isBlank(s.getComponentRule()) && StringUtils.isBlank(s.getClassifyInvokeLevel())//ä¸è½æ¯ç»åçåå类注å
¥ç |
| | | ).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | //ä¸MdmEngineServiceImpléé¢çcheckRequiredAttrOnOrder é»è¾åºè¯¥ç¸ä¼¼ |
| | | if(!CollectionUtils.isEmpty(requiredAttrMap)) { |
| | | Set<String> nullRowIndex = cboList.stream().filter(cbo -> requiredAttrMap.keySet().stream().anyMatch(attrId -> StringUtils.isBlank(cbo.getAttributeValue(attrId)))).map(cbo -> cbo.getAttributeValue(IMPORT_ROW_INDEX)).collect(Collectors.toSet()); |
| | | if(!CollectionUtils.isEmpty(nullRowIndex)){ |
| | | String checkAttr = requiredAttrMap.values().stream().map(CodeClassifyTemplateAttrVO::getName).collect(Collectors.joining(",")); |
| | | nullRowIndex.stream().forEach(rowIndex->{ |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";æ ¡éªè§åä¸éè¿ï¼ææ ¡éªç屿§ä¸º" + checkAttr); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * å¤çå类注å
¥ |
| | | * @param attrVOS 模æ¿å±æ§ |
| | | * @param dataList excelçæ°æ®å
容 |
| | | * @param classifyFullInfo åç±»çå
¨è·¯å¾ |
| | | */ |
| | | private void batchSwitchClassifyAttrOnOrder(Collection<CodeClassifyTemplateAttrVO> attrVOS,List<ClientBusinessObject> dataList, |
| | | CodeClassifyFullInfoBO classifyFullInfo,boolean isImPort) { |
| | | Map<String, CodeClassifyTemplateAttrVO> dateAttrVOMap = attrVOS.stream().filter( |
| | | s -> StringUtils.isNotBlank(s.getClassifyInvokeAttr()) && StringUtils.isNotBlank(s.getClassifyInvokeAttr()) |
| | | ).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | Map<String,CodeClassifyFullInfoBO> classifyFullInfoMap=new HashMap<>(); |
| | | classifyFullInfoMap.put(classifyFullInfo.getCurrentClassifyVO().getOid(),classifyFullInfo); |
| | | if (!CollectionUtils.isEmpty(dateAttrVOMap)) { |
| | | dataList.stream().forEach(cbo -> { |
| | | dateAttrVOMap.forEach((attrId, attrVO) -> { |
| | | //å类注å
¥çç¼å·æè
åç§°ï¼ |
| | | //å±çº§å
嫿å®å±åæå°å± |
| | | CodeClassifyVO classifyVO = null; |
| | | if(!CodeLevelTypeEnum.MIN.getValue().equalsIgnoreCase(attrVO.getClassifyInvokeLevel()) && !"min".equalsIgnoreCase(attrVO.getClassifyInvokeLevel())) { |
| | | //æå®äºå±çº§ç |
| | | //注æï¼å 为æ¥è¯¢ä¸çº§åç±»åºæ¥çå±çº§æ¯ååºçï¼å³é¡¶å±èç¹æ¯æå¤§çå¼ |
| | | if(isImPort){ |
| | | if(!classifyFullInfoMap.containsKey(cbo.getAttributeValue(CODE_CLASSIFY_OID_FIELD))) { |
| | | CodeClassifyFullInfoBO currentClassifyFullInfo = classifyService.getClassifyFullInfo(cbo.getAttributeValue(CODE_CLASSIFY_OID_FIELD)); |
| | | classifyFullInfoMap.put(currentClassifyFullInfo.getCurrentClassifyVO().getOid(), currentClassifyFullInfo); |
| | | } |
| | | } |
| | | CodeClassifyFullInfoBO newClassifyFullInfo= classifyFullInfoMap.get(cbo.getAttributeValue(CODE_CLASSIFY_OID_FIELD)); |
| | | List<CodeClassifyVO> classifyVOS = newClassifyFullInfo.getParentClassifyVOs().stream().sorted(((o1, o2) -> o2.getDataLevel().compareTo(o1.getDataLevel()))).collect(Collectors.toList()); |
| | | int level = VciBaseUtil.getInt(attrVO.getClassifyInvokeLevel()); |
| | | if (classifyVOS.size()>=level && level > 0 ) { |
| | | classifyVO = classifyVOS.get(level-1); |
| | | } |
| | | }else{ |
| | | //å½åçåç±» |
| | | classifyVO = classifyFullInfo.getCurrentClassifyVO(); |
| | | } |
| | | try { |
| | | if (classifyVO == null) { |
| | | //说æå±çº§æè¯¯ |
| | | cbo.setAttributeValue(attrId, "åç±»æ 䏿²¡æå±çº§[" + attrVO.getClassifyInvokeLevel() + "]"); |
| | | } else { |
| | | Map<String, String> classifyDataMap = VciBaseUtil.objectToMapString(classifyVO); |
| | | String value = classifyDataMap.getOrDefault(attrVO.getClassifyInvokeAttr(), ""); |
| | | cbo.setAttributeValue(attrId, value); |
| | | } |
| | | } catch (Throwable e) { |
| | | log.error("è®¾ç½®å±æ§é误", e); |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | /** |
| | | * æ ¡éªå
³é®å±æ§ |
| | | * @param classifyFullInfo åç±»çå
¨é¨ä¿¡æ¯ |
| | | * @param templateVO 模æ¿çå
容ï¼å¿
é¡»å
嫿¨¡æ¿å±æ§ |
| | | * @param cboList æ¹éçæ°æ® |
| | | */ |
| | | private CodeImportResultVO batchCheckKeyAttrOnOrder(CodeClassifyFullInfoBO classifyFullInfo, CodeClassifyTemplateVO templateVO, |
| | | List<ClientBusinessObject> cboList) { |
| | | //ä¸MdmEngineServiceImpléçcheckKeyAttrOnOrderç¸ä¼¼ |
| | | //å
è·åå
³é®å±æ§çè§åï¼ä¹å©ç¨ç»§æ¿çæ¹å¼ |
| | | 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)); |
| | | |
| | | 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()); |
| | | |
| | | //1. æä»¬éè¦å
夿excel导å
¥çå
容æ¯å¦æ£ç¡® |
| | | 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)); |
| | | 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<ClientBusinessObject>> indexTODataMap=new HashMap<>(); |
| | | List<ClientBusinessObject> repeatDataMap = cboList.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)) { |
| | | CodeTemplateAttrSqlBO sqlBO = engineService.getSqlByTemplateVO(classifyFullInfo.getTopClassifyVO().getBtmtypeid(), templateVO, conditionMap, null); |
| | | boolean isKeyCheck= commonsMapper.queryCountBySql(sqlBO.getSqlCount()) > 0; |
| | | if(isKeyCheck){ |
| | | List<Map<String,String>> newDataList= commonsMapper.queryByOnlySqlForMap(sqlBO.getSqlUnPage()); |
| | | List<ClientBusinessObject> newCboList= ChangeMapTOClientBusinessObjects(newDataList); |
| | | indexTODataMap.put(cbo.getAttributeValue(IMPORT_ROW_INDEX),newCboList); |
| | | } |
| | | return isKeyCheck; |
| | | }else{ |
| | | return false; |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(repeatDataMap)){ |
| | | resultVO.setKeyAttrRepeatRowIndexList(repeatDataMap.stream().map(s->s.getAttributeValue(IMPORT_ROW_INDEX)).collect(Collectors.toSet())); |
| | | } |
| | | //resultVO.setIndexTODataMap(indexTODataMap); |
| | | //resultVO.setSuccess(true); |
| | | return resultVO; |
| | | } |
| | | /** |
| | | * è·å导å
¥çå
容ä¸å
³é®å±æ§éå¤çè¡å· |
| | | * @param ketAttrMap å
³é®å±æ§çæ å° |
| | | * @param dataList 导å
¥çæ°æ® |
| | | * @param keyRuleVO å
³é®å±æ§æ§å¶è§å |
| | | * @return éå¤çè¡å· |
| | | */ |
| | | private Set<String> getSelfRepeatRowIndex(Map<String/**屿§çç¼å·**/, CodeClassifyTemplateAttrVO> ketAttrMap, |
| | | List<ClientBusinessObject> dataList,CodeKeyAttrRepeatVO keyRuleVO){ |
| | | Set<String> selfRepeatRowIndexList = new CopyOnWriteArraySet<>(); |
| | | 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()); |
| | | //å¿
é¡»å°å±æ§æç
§é¡ºåºæåºå¥½ |
| | | List<CodeClassifyTemplateAttrVO> attrVOList = ketAttrMap.values().stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).collect(Collectors.toList()); |
| | | Map<String/**è¡å·**/,String/**å
³é®å±æ§çç»åå
容**/> rowIndexKeyStringMap = new HashMap<>(); |
| | | dataList.parallelStream().forEach(cbo-> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | 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); |
| | | if (value == null) { |
| | | value = ""; |
| | | } |
| | | if(trim){ |
| | | value = value.trim(); |
| | | } |
| | | if(trimAll){ |
| | | value = value.replace(" ",""); |
| | | } |
| | | if(ignoreCase){ |
| | | value = value.toLowerCase(Locale.ROOT); |
| | | } |
| | | if(ignoreWidth){ |
| | | value = VciBaseUtil.toDBC(value); |
| | | } |
| | | sb.append(value).append("${ks}"); |
| | | } |
| | | String keyString = sb.toString(); |
| | | if(rowIndexKeyStringMap.containsValue(keyString) && StringUtils.isNotBlank(keyString)){ |
| | | selfRepeatRowIndexList.add(rowIndex); |
| | | }else { |
| | | rowIndexKeyStringMap.put(rowIndex, sb.toString()); |
| | | } |
| | | }); |
| | | //å ä¸ºåªæ¯å
³é®å±æ§éå¤ï¼æä»¥æä»¬ä¸è½éå¤ç夿¡é䏿¡æ¥æ¥é |
| | | return selfRepeatRowIndexList; |
| | | } |
| | | /** |
| | | * excelçæ é¢ä¸è·ååæ®µæå¨çä½ç½® |
| | | * @param titleRowData æ é¢çå
容 |
| | | * @param attrNameIdMap 模æ¿ä¸å±æ§åç§°åè±æçæ å° |
| | |
| | | } |
| | | } |
| | | } |
| | | private List<ClientBusinessObject> ChangeMapTOClientBusinessObjects(List<Map<String,String>> oldDataMap){ |
| | | List<ClientBusinessObject> clientBusinessObjectList=new CopyOnWriteArrayList<>(); |
| | | oldDataMap.parallelStream().forEach(dataMap->{ |
| | | ClientBusinessObject clientBusinessObject=new ClientBusinessObject(); |
| | | DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(dataMap,clientBusinessObject); |
| | | dataMap.forEach((key,value)->{ |
| | | clientBusinessObject.setAttributeValue(key,value); |
| | | }); |
| | | }); |
| | | return clientBusinessObjectList; |
| | | } |
| | | |
| | | /*** |
| | | * æ£ç¡®éè¯¯æ°æ®redisç¼å |
| | | * @param uuid |
| | | * @param templateVO |
| | | * @param rowIndexCbo |
| | | * @param dataSet |
| | | * @param fieldIndexMap |
| | | * @param errorMap |
| | | * @param isok |
| | | */ |
| | | private void createRedisDatas(String uuid,CodeClassifyTemplateVO templateVO,Map<String,ClientBusinessObject> rowIndexCbo, SheetDataSet dataSet, Map<Integer/**åå·**/,String/**åæ®µçåç§°**/> fieldIndexMap,Map<String,String> errorMap,boolean isok){ |
| | | List<SheetRowData> needsheetRowDataList =new ArrayList<>(); |
| | | if(errorMap.size()>0) { |
| | | //è¦æä»¥ä¸çé误ç齿åºåï¼åç»§ç»å¤çæ¶é´åç»åè§å |
| | | needsheetRowDataList = dataSet.getRowData().stream().filter(cbo -> { |
| | | String rowIndex=cbo.getRowIndex(); |
| | | return isok? !errorMap.containsKey(rowIndex):errorMap.containsKey(rowIndex); |
| | | }).collect(Collectors.toList()); |
| | | |
| | | }else{ |
| | | needsheetRowDataList= dataSet.getRowData(); |
| | | } |
| | | Map<String/**䏿åç§°**/, SheetRowData/**è±æåç§°**/> rowIdexDataMap = needsheetRowDataList.stream().collect(Collectors.toMap(s -> s.getRowIndex(), t -> t,(o1, o2)->o2)); |
| | | Map<String,CodeImprotDataVO> clsfDataMap=new HashMap<>(); |
| | | rowIndexCbo .forEach((rowIndex, cbo) -> { |
| | | CodeImprotDataVO codeImprotDataVO = new CodeImprotDataVO(); |
| | | codeImprotDataVO.setTemplateOid(templateVO.getOid()); |
| | | List<Map<String, String>> dataList = new ArrayList<>(); |
| | | if(rowIdexDataMap.containsKey(rowIndex)){ |
| | | SheetRowData sheetRowData=rowIdexDataMap.get(rowIndex); |
| | | Map<String, String> dataMap = new HashMap<>(); |
| | | Map<Integer, String> data = sheetRowData.getData(); |
| | | fieldIndexMap.forEach((integer, s) -> { |
| | | String field = fieldIndexMap.get(integer); |
| | | if (data.containsKey(integer)) { |
| | | String vlues = data.get(integer); |
| | | dataMap.put(field, vlues); |
| | | } |
| | | }); |
| | | dataMap.put("oid",cbo.getOid()); |
| | | dataList.add(dataMap); |
| | | } |
| | | if(clsfDataMap.containsKey(templateVO.getOid())){ |
| | | codeImprotDataVO=clsfDataMap.get(templateVO.getOid()); |
| | | dataList.addAll(codeImprotDataVO.getDatas()); |
| | | } |
| | | codeImprotDataVO.setColNames(dataSet.getColName()); |
| | | codeImprotDataVO.setDatas(dataList); |
| | | clsfDataMap.put(templateVO.getOid(),codeImprotDataVO); |
| | | }); |
| | | if(!CollectionUtils.isEmpty(clsfDataMap)) { |
| | | Collection codeImprotDataVOS=clsfDataMap.values(); |
| | | List<CodeImprotDataVO> codeImprotDataVOList=new ArrayList<>(); |
| | | codeImprotDataVOList.addAll(codeImprotDataVOS); |
| | | bladeRedis.set(uuid+"-"+templateVO.getOid(), codeImprotDataVOList); |
| | | bladeRedis.expire(uuid+"-"+templateVO.getOid(),BATCHADD_REDIS_TIME);//redisè¿ææ¶é´ |
| | | } |
| | | } |
| | | |
| | | /**** |
| | | * æ°æ®ç¸ä¼¼é¡¹æ°æ®æ ¡éªredisç¼å |
| | | * @param codeClassifyOid |
| | | * @param templateVO |
| | | * @param cboList |
| | | * @param resembleMap |
| | | * @param btmtypeid |
| | | * @param dataResembleVOS |
| | | */ |
| | | private void bathcResembleQuery(String codeClassifyOid, CodeClassifyTemplateVO templateVO, List<ClientBusinessObject> cboList,Map<String,String>resembleMap,String btmtypeid,List<DataResembleVO> dataResembleVOS){ |
| | | CodeClassifyFullInfoBO fullInfoBO = classifyService.getClassifyFullInfo(codeClassifyOid); |
| | | Map<String, String> conditionMap = new HashMap<>(); |
| | | CodeResembleRuleVO resembleRuleVO = Optional.ofNullable(engineService.getUseResembleRule(fullInfoBO, fullInfoBO.getCurrentClassifyVO())).orElseGet(() -> new CodeResembleRuleVO()); |
| | | //éè¦è·åæ¯å¦æç¸ä¼¼æ¥è¯¢å±æ§ |
| | | Map<String, CodeClassifyTemplateAttrVO> attrVOs = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getSameRepeatAttrFlag())).collect(Collectors.toMap(s -> s.getId(), t -> t)); |
| | | if (CollectionUtils.isEmpty(attrVOs)) { |
| | | return; |
| | | } |
| | | Map<String,CodeImprotResembleVO> codeImprotResembleVOMap=new HashMap<>(); |
| | | List<CodeImprotResembleVO> codeImprotResembleVOList=new ArrayList<>(); |
| | | Map<String,String> rowIndePathMap=new HashMap<>(); |
| | | cboList.stream().forEach(clientBusinessObject -> { |
| | | CodeImprotResembleVO codeImprotResembleVO=new CodeImprotResembleVO(); |
| | | final String[] path = {""}; |
| | | List<String> fieldList=new ArrayList<>(); |
| | | List<String> rowIndeList=new ArrayList<>(); |
| | | String rowIndex = clientBusinessObject.getAttributeValue(IMPORT_ROW_INDEX); |
| | | attrVOs.forEach((attrId, attrVO) -> { |
| | | String value=""; |
| | | /*if (VciQueryWrapperForDO.BASIC_FIELD_MAP.containsKey(attrId)) { |
| | | value = WebUtil.getStringValueFromObject(WebUtil.getValueFromField(WebUtil.getFieldForObject(attrId, orderDTO.getClass()).getName(), orderDTO)); |
| | | }else {*/ |
| | | value= clientBusinessObject.getAttributeValue(attrId); |
| | | // } |
| | | fieldList.add(attrId); |
| | | value=StringUtils.isBlank(value)?"":value; |
| | | path[0] +=value+"#"; |
| | | engineService.wrapperResembleConditionMap(value, resembleRuleVO, attrId, conditionMap); |
| | | }); |
| | | List<Map<String,String>> dataMap=new ArrayList<>(); |
| | | if(codeImprotResembleVOMap.containsKey(path[0])) { |
| | | codeImprotResembleVO=codeImprotResembleVOMap.get(path[0]); |
| | | rowIndeList=codeImprotResembleVO.getRownIndex(); |
| | | dataMap= codeImprotResembleVO.getDataList(); |
| | | resembleMap.put(rowIndex, "åå¨ç¸ä¼¼æ°æ®"); |
| | | }else{ |
| | | if (!CollectionUtils.isEmpty(conditionMap)) { |
| | | Map<String, String> andConditionMap = new HashMap<>(); |
| | | andConditionMap.put("islastr", "1"); |
| | | andConditionMap.put("islastv", "1"); |
| | | conditionMap.putAll(andConditionMap); |
| | | PageHelper pageHelper = new PageHelper(-1); |
| | | pageHelper.addDefaultDesc("id"); |
| | | CodeTemplateAttrSqlBO sqlBO = engineService.getSqlByTemplateVO(btmtypeid, templateVO, conditionMap, pageHelper); |
| | | List<Map<String,String>> dataMapList=commonsMapper.queryByOnlySqlForMap(sqlBO.getSqlUnPage()); |
| | | List<ClientBusinessObject> resembleCboList= ChangeMapTOClientBusinessObjects(dataMapList); |
| | | if(!CollectionUtils.isEmpty(resembleCboList)) { |
| | | List<Map<String, String>> finalDataMap = dataMap; |
| | | resembleCboList.stream().forEach(cbo->{ |
| | | Map<String,String> resembDataMap=new HashMap<>(); |
| | | fieldList.stream().forEach(field->{ |
| | | String value=cbo.getAttributeValue(field); |
| | | value=StringUtils.isBlank(value)?"":value; |
| | | resembDataMap.put(field,value); |
| | | }); |
| | | resembDataMap.put("codetemplateoid",templateVO.getOid()); |
| | | resembDataMap.put("id",StringUtils.isBlank(cbo.getAttributeValue("id"))?"":cbo.getAttributeValue("id")); |
| | | resembDataMap.put("rowIndex",""); |
| | | resembDataMap.put("oid",cbo.getOid()); |
| | | finalDataMap.add(resembDataMap); |
| | | }); |
| | | resembleMap.put(rowIndex, "åå¨ç¸ä¼¼æ°æ®"); |
| | | |
| | | } |
| | | } |
| | | } |
| | | rowIndePathMap.put(rowIndex,path[0]); |
| | | rowIndeList.add(rowIndex); |
| | | codeImprotResembleVO.setPath(path[0]); |
| | | codeImprotResembleVO.setRownIndex(rowIndeList); |
| | | codeImprotResembleVO.setConditionMap(conditionMap); |
| | | codeImprotResembleVO.setFields(fieldList); |
| | | codeImprotResembleVO.setDataList(dataMap); |
| | | codeImprotResembleVOMap.put(path[0],codeImprotResembleVO); |
| | | }); |
| | | Map<String, ClientBusinessObject> cboMap = cboList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getAttributeValue((IMPORT_ROW_INDEX)), t -> t)); |
| | | if(!CollectionUtils.isEmpty(rowIndePathMap)){ |
| | | rowIndePathMap.forEach((rowIndex, path) -> { |
| | | if(codeImprotResembleVOMap.containsKey(path)){ |
| | | CodeImprotResembleVO codeImprotResembleVO= codeImprotResembleVOMap.get(path); |
| | | List<String> fieldList=codeImprotResembleVO.getFields(); |
| | | List<String> rownIndexList= codeImprotResembleVO.getRownIndex(); |
| | | List<String> newRownIndexList = rownIndexList.stream().filter(cbo -> { |
| | | return rowIndex!=cbo; |
| | | }).collect(Collectors.toList()); |
| | | newRownIndexList.stream().forEach(s -> { |
| | | resembleMap.put(s, "åå¨ç¸ä¼¼æ°æ®"); |
| | | }); |
| | | List<Map<String, String>>newDataList=new ArrayList<>(); |
| | | DataResembleVO dataResembleVO=new DataResembleVO(); |
| | | dataResembleVO.setOid(cboMap.get(rowIndex).getOid()); |
| | | List<ClientBusinessObject> needSaveCboList = cboList.stream().filter(cbo -> { |
| | | String newRowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | return rownIndexList.contains(newRowIndex)&&(!newRowIndex.equalsIgnoreCase(rowIndex)); |
| | | }).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(needSaveCboList)) { |
| | | needSaveCboList.stream().forEach(cbo -> { |
| | | String newRowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | Map<String, String> resembDataMap = new HashMap<>(); |
| | | fieldList.stream().forEach(field -> { |
| | | String value = cbo.getAttributeValue(field); |
| | | value = StringUtils.isBlank(value) ? "" : value; |
| | | resembDataMap.put(field, value); |
| | | }); |
| | | resembDataMap.put("codetemplateoid",templateVO.getOid()); |
| | | resembDataMap.put("id",StringUtils.isBlank(cbo.getAttributeValue("id"))?"":cbo.getAttributeValue("id")); |
| | | resembDataMap.put("rowIndex", newRowIndex); |
| | | resembDataMap.put("oid",cbo.getOid()); |
| | | newDataList.add(resembDataMap); |
| | | }); |
| | | } |
| | | List<Map<String, String>>dataList=codeImprotResembleVO.getDataList(); |
| | | newDataList.addAll(dataList); |
| | | dataResembleVO.setDataList(newDataList); |
| | | dataResembleVOS.add(dataResembleVO); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | * åå¨å类对象åå
¶åå |
| | | * @param uuid |
| | | * @param templateVOList |
| | | * @param dataSet |
| | | * @param fieldIndexMap |
| | | * @param iscContain |
| | | */ |
| | | private void createRedisByCodeClassify(String uuid,CodeClassifyTemplateVO templateVOList,SheetDataSet dataSet, Map<Integer/**åå·**/,String/**åæ®µçåç§°**/> fieldIndexMap,boolean iscContain){ |
| | | List<ColumnVO> columnVOList = new ArrayList<>(); |
| | | List<String> outNameList = dataSet.getColName(); |
| | | fieldIndexMap.forEach((integer, s) -> { |
| | | ColumnVO columnVOS = new ColumnVO(); |
| | | String field = fieldIndexMap.get(integer); |
| | | String outName = outNameList.get(integer); |
| | | columnVOS.setField(field); |
| | | columnVOS.setTitle(outName); |
| | | columnVOList.add(columnVOS); |
| | | }); |
| | | CodeImportTemplateVO codeImportTemplateVO=new CodeImportTemplateVO(); |
| | | codeImportTemplateVO.setCodeClassifyTemplateVO(templateVOList); |
| | | codeImportTemplateVO.setCloNamesList(columnVOList); |
| | | List<CodeImportTemplateVO> codeImportTemplateVOs= new ArrayList<>(); |
| | | |
| | | codeImportTemplateVOs.add(codeImportTemplateVO); |
| | | if(codeImportTemplateVOs.size()>0) { |
| | | bladeRedis.set(uuid, codeImportTemplateVOs); |
| | | bladeRedis.expire(uuid, BATCHADD_REDIS_TIME);//redisè¿ææ¶é´ |
| | | } |
| | | } |
| | | /** |
| | | * æ·è´ä¸å¡ç±»åå°map |
| | | * @param cbo ä¸å¡æ°æ® |
| | | * @param map map |
| | | */ |
| | | public static void copyValueToMapFromCbos(ClientBusinessObject cbo,Map<String,String> map){ |
| | | if(cbo!=null){ |
| | | copyValueToMapFromBos(cbo,map); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ·è´ä¸å¡ç±»åå°map |
| | | * @param bo ä¸å¡æ°æ® |
| | | * @param map map |
| | | */ |
| | | public static void copyValueToMapFromBos(ClientBusinessObject bo,Map<String,String> map){ |
| | | if(bo!=null ){ |
| | | //å
æææçåæ®µæ å°æ¾å° |
| | | AttributeValue[] newAList = bo.newAttrValList; |
| | | AttributeValue[] hisAList = bo.hisAttrValList; |
| | | if(hisAList!=null&&hisAList.length>0){// |
| | | for(int i = 0 ; i < hisAList.length;i++){ |
| | | AttributeValue av = hisAList[i]; |
| | | String attrName = av.attrName.toLowerCase(); |
| | | map.put(attrName, av.attrVal); |
| | | } |
| | | } |
| | | if(newAList!=null&&newAList.length>0){//NEWçä¼å
级é«äº |
| | | for(int i = 0 ; i < newAList.length;i++){ |
| | | AttributeValue av = newAList[i]; |
| | | String attrName = av.attrName.toLowerCase(); |
| | | map.put(attrName, av.attrVal); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |