¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | 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.CodeExportAttrDTO; |
| | | import com.vci.ubcs.code.dto.CodeOrderDTO; |
| | | import com.vci.ubcs.code.entity.CodeAllCode; |
| | | import com.vci.ubcs.code.enumpack.CodeDefaultLC; |
| | | import com.vci.ubcs.code.enumpack.CodeLevelTypeEnum; |
| | | import com.vci.ubcs.code.lifecycle.CodeAllCodeLC; |
| | | 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.code.vo.webserviceModel.result.xml.XMLResultDataObjectDetailDO; |
| | | import com.vci.ubcs.file.util.VciZipUtil; |
| | | 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.starter.bo.WriteExcelData; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.poi.bo.ReadExcelOption; |
| | | import com.vci.ubcs.starter.poi.bo.SheetDataSet; |
| | | 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.constant.QueryOptionConstant; |
| | | import com.vci.ubcs.starter.web.enumpck.BooleanEnum; |
| | | import com.vci.ubcs.starter.web.enumpck.UserSecretEnum; |
| | | import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum; |
| | | import com.vci.ubcs.starter.web.pagemodel.*; |
| | | import com.vci.ubcs.starter.web.toolmodel.DateConverter; |
| | | import com.vci.ubcs.starter.web.util.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.map.HashedMap; |
| | | 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.Font; |
| | | import org.apache.poi.ss.usermodel.RichTextString; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.MessageFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.concurrent.CopyOnWriteArraySet; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | 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.*; |
| | | |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | @Slf4j |
| | | public class MdmIOServiceImpl implements MdmIOService { |
| | | |
| | | |
| | | /** |
| | | * åæ®µ |
| | | */ |
| | | public static final String ROW_INDEX = "LAY_TABLE_INDEX"; |
| | | |
| | | /** |
| | | * é误信æ¯çåæ®µ |
| | | */ |
| | | public static final String ERROR_MSG = "errorMsg"; |
| | | |
| | | @Value("${batchadd.exportattr.type:åºæ¬ä¿¡æ¯}") |
| | | public String BATCHADD_EXCEPORT_ATTR_TYPE; |
| | | |
| | | @Value("${batchadd.redis.time:6000000}") |
| | | public int BATCHADD_REDIS_TIME; |
| | | /** |
| | | * 主é¢åºåç±»çæå¡ |
| | | */ |
| | | @Resource |
| | | private ICodeClassifyService classifyService; |
| | | |
| | | |
| | | /** |
| | | * éç¨æ¥è¯¢ |
| | | */ |
| | | @Resource |
| | | private CommonsMapper commonsMapper; |
| | | /**** |
| | | * ç å¼æå¡ |
| | | */ |
| | | @Resource |
| | | ICodeAllCodeService codeAllCodeService; |
| | | |
| | | /** |
| | | * 模æ¿çæå¡ |
| | | */ |
| | | @Resource |
| | | private CodeClstemplateServiceImpl templateService; |
| | | |
| | | /** |
| | | * ä¸»æ°æ®å¼æçæå¡ |
| | | */ |
| | | @Resource |
| | | private MdmEngineService engineService; |
| | | /*** |
| | | * resdisç¼åæå¡ |
| | | */ |
| | | private final BladeRedis bladeRedis; |
| | | /** |
| | | * çæç¼ç çæå¡ |
| | | */ |
| | | @Resource |
| | | private MdmProductCodeService productCodeService; |
| | | /** |
| | | * å
³é®å±æ§çé
ç½® |
| | | */ |
| | | @Autowired |
| | | private ICodeKeyAttrRepeatService keyRuleService; |
| | | |
| | | /** |
| | | * å
¬å¼çæå¡ |
| | | */ |
| | | @Autowired |
| | | private FormulaServiceImpl formulaService; |
| | | /** |
| | | * è§åçæå¡ |
| | | */ |
| | | @Autowired |
| | | private ICodeRuleService ruleService; |
| | | /** |
| | | * ä¸å¡ç±»åçæå¡ |
| | | */ |
| | | @Autowired |
| | | private IBtmTypeClient btmTypeClient; |
| | | |
| | | /*** |
| | | * å¯çº§æå¡ |
| | | */ |
| | | @Resource |
| | | private IWebSecretClient secretService; |
| | | |
| | | /** |
| | | * 导åºçå䏿¡ |
| | | */ |
| | | public static final int EXPORT_LIMIT = 100000; |
| | | |
| | | /** |
| | | * æ¹éç³è¯·ï¼éåéä¸åç±»ä¸çæææ¨¡æ¿å
³é®å±æ§ï¼ç¸ä¼¼å±æ§ï¼å¿
填屿§ï¼åå
¥execlä¸ |
| | | * |
| | | * @param codeClassifyOid åç±»çä¸»é® |
| | | * @return excelçæä»¶å°å |
| | | */ |
| | | @Override |
| | | public String downloadTopImportExcel(String codeClassifyOid){ |
| | | List<CodeClassifyTemplateVO> templateVOList=new ArrayList<>(); |
| | | VciBaseUtil.alertNotNull("å¯¼åºæ¨¡æ¿","导åºçé
ç½®",codeClassifyOid,"主é¢åºåç±»ç主é®"); |
| | | CodeClassifyVO codeClassifyVO = classifyService.getObjectByOid(codeClassifyOid); |
| | | templateVOList= templateService.childTemplates(codeClassifyOid); |
| | | List<CodeClassifyVO> codeClassifyVOS=classifyService.getIdPathToNamePathByParentId(codeClassifyOid,true); |
| | | WriteExcelOption eo = new WriteExcelOption(); |
| | | LinkedHashMap<String,CodeClassifyTemplateAttrVO> allFieldToOutNameMap=new LinkedHashMap<>(); |
| | | templateVOList.stream().forEach(templateVO -> { |
| | | //ç»åæ ¼å¼çä¸å¯¼å
¥ï¼ |
| | | // æä¸¾çæä¾åºåçéæ© |
| | | //æ¶é´å
¨é¨ç»ä¸ä¸ºyyyy-MM-dd HH:mm:ss |
| | | //åç
§çèªè¡è¾å
¥åç§° |
| | | //å类注å
¥çä¸ç¨ï¼é½æ¯å¯¼å
¥åèªå¨å¤çç |
| | | //ç¼ç ï¼ç¶æçåæ®µä¸å¯¼å
¥ |
| | | if(!CollectionUtils.isEmpty(templateVO.getAttributes())) { |
| | | List<CodeClassifyTemplateAttrVO> templateAttrVOS = templateVO.getAttributes().stream().filter(s -> |
| | | !DEFAULT_ATTR_LIST.contains(s.getId()) |
| | | && StringUtils.isBlank(s.getComponentRule()) |
| | | && StringUtils.isBlank(s.getClassifyInvokeAttr()) |
| | | && (VciBaseUtil.getBoolean(s.getFormDisplayFlag())) |
| | | ).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(templateAttrVOS)){ |
| | | throw new VciBaseException("æ¨¡æ¿æ²¡æé
置任ä½ãè¡¨åæ¾ç¤ºãä¸ºãæ¯ãç屿§"); |
| | | } |
| | | templateAttrVOS.stream().forEach(codetemplateAttr -> { |
| | | String field = codetemplateAttr.getId(); |
| | | String name = codetemplateAttr.getName(); |
| | | CodeClassifyTemplateAttrVO codeBaseAttributeDTO = new CodeClassifyTemplateAttrVO(); |
| | | boolean res = (StringUtils.isNotBlank(codetemplateAttr.getAttributeGroup()) && codetemplateAttr.getAttributeGroup().equals(BATCHADD_EXCEPORT_ATTR_TYPE))//åºæ¬å±æ§å段æ¾ç¤º |
| | | || (StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag()))//å
³é®å±æ§çåå
¥ |
| | | || (StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())) //ç¸ä¼¼å±æ§çåå
¥ |
| | | || (StringUtils.isNotBlank(codetemplateAttr.getRequireFlag()) && Boolean.parseBoolean(codetemplateAttr.getRequireFlag())); |
| | | if (allFieldToOutNameMap.containsKey(name)) {//妿åå¨çè¯åéè¦æ ¹æ®å
·ä½çå»èµå¼ |
| | | codeBaseAttributeDTO = allFieldToOutNameMap.get(name); |
| | | if (StringUtils.isNotBlank(codetemplateAttr.getKeyAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getKeyAttrFlag())) { |
| | | codeBaseAttributeDTO.setKeyAttrFlag(codetemplateAttr.getKeyAttrFlag());//屿§å
³é®å±æ§ |
| | | } |
| | | if (StringUtils.isNotBlank(codetemplateAttr.getRequireFlag()) && Boolean.parseBoolean(codetemplateAttr.getRequireFlag())) { |
| | | codeBaseAttributeDTO.setRequireFlag(codetemplateAttr.getRequireFlag());//屿§å¿
填项 |
| | | } |
| | | if (StringUtils.isNotBlank(codetemplateAttr.getSameRepeatAttrFlag()) && Boolean.parseBoolean(codetemplateAttr.getSameRepeatAttrFlag())) { |
| | | codeBaseAttributeDTO.setSameRepeatAttrFlag(codetemplateAttr.getSameRepeatAttrFlag());//屿§ç¸ä¼¼å±æ§ |
| | | } |
| | | } else if (res) { |
| | | allFieldToOutNameMap.put(name, codetemplateAttr); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | //æ´çå¥½æææ¨¡æ¿éè¦åå
¥execlç屿§ä¿¡æ¯ |
| | | Workbook workbook = new HSSFWorkbook(); |
| | | LinkedList<WriteExcelData> excelDataList = new LinkedList<>(); |
| | | if(!CollectionUtils.isEmpty(allFieldToOutNameMap)){ |
| | | excelDataList.add(new WriteExcelData(0,0,"å类路å¾")); |
| | | final int[] index = {0}; |
| | | allFieldToOutNameMap.values().stream().forEach(attrVO -> { |
| | | Object text = attrVO.getName(); |
| | | text = exportKeyAndRequired(workbook,attrVO,text); |
| | | int colIndex = 1 + index[0]++; |
| | | WriteExcelData excelData = new WriteExcelData(0, colIndex, text); |
| | | if(StringUtils.isNotBlank(attrVO.getCodeDateFormat()) |
| | | || VciFieldTypeEnum.VTDateTime.name().equalsIgnoreCase(attrVO.getAttributeDataType()) |
| | | || VciFieldTypeEnum.VTDate.name().equalsIgnoreCase(attrVO.getAttributeDataType()) |
| | | ||VciFieldTypeEnum.VTTime.name().equalsIgnoreCase(attrVO.getAttributeDataType())){ |
| | | excelData.setDateFormat(VciDateUtil.DateTimeFormat); |
| | | } |
| | | if(text instanceof RichTextString){ |
| | | excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex())); |
| | | } |
| | | excelDataList.add(excelData); |
| | | if(StringUtils.isNotBlank(attrVO.getEnumString()) || StringUtils.isNotBlank(attrVO.getEnumId())){ |
| | | //æ·»å æ°æ®æææ§ |
| | | List<String> enumValueList = new ArrayList<>(); |
| | | enumValueList.add(""); |
| | | List<KeyValue> valueList = engineService.listComboboxItems(attrVO); |
| | | if(!CollectionUtils.isEmpty(valueList)){ |
| | | valueList.stream().forEach(kv->{ |
| | | enumValueList.add(kv.getValue()); |
| | | }); |
| | | } |
| | | //é»è®¤å 1䏿¡ |
| | | WriteExcelData ed = new WriteExcelData(1,colIndex,""); |
| | | ed.setRowTo(100); |
| | | ed.setColTo(colIndex); |
| | | ed.setValidation(true); |
| | | ed.setValidationDataList(enumValueList); |
| | | ed.setValidationErrorMsg("请å¨åºåä¸éæ©æ£ç¡®çå¼"); |
| | | excelDataList.add(ed); |
| | | } |
| | | if(VciFieldTypeEnum.VTBoolean.name().equalsIgnoreCase(attrVO.getAttributeDataType())){ |
| | | List<String> booleanList = new ArrayList<>(); |
| | | booleanList.add("æ¯"); |
| | | booleanList.add("å¦"); |
| | | //é»è®¤å 1䏿¡ |
| | | WriteExcelData ed = new WriteExcelData(1,colIndex,""); |
| | | ed.setRowTo(100); |
| | | ed.setColTo(colIndex); |
| | | ed.setValidation(true); |
| | | ed.setValidationDataList(booleanList); |
| | | ed.setValidationErrorMsg("请å¨åºåä¸éæ©æ£ç¡®çå¼"); |
| | | excelDataList.add(ed); |
| | | } |
| | | }); |
| | | eo.addSheetDataList(codeClassifyVO.getName()+"导å
¥æ¨¡æ¿",excelDataList); |
| | | } |
| | | LinkedList<WriteExcelData> classPathList = new LinkedList<>(); |
| | | classPathList.add(new WriteExcelData(0,0,"åç±»å±çº§")); |
| | | |
| | | WriteExcelData idPathWriteExcelTitle=new WriteExcelData(0,1,"åç±»IDè·¯å¾"); |
| | | idPathWriteExcelTitle.setWidth(20); |
| | | idPathWriteExcelTitle.setCenter(false); |
| | | classPathList.add(idPathWriteExcelTitle); |
| | | WriteExcelData namePathWriteExcelTitle=new WriteExcelData(0,2,"åç±»åç§°è·¯å¾"); |
| | | namePathWriteExcelTitle.setWidth(20); |
| | | namePathWriteExcelTitle.setCenter(false); |
| | | classPathList.add(namePathWriteExcelTitle); |
| | | |
| | | |
| | | final int[] rowIndex = {1}; |
| | | codeClassifyVOS.stream().forEach(codeClassifyVO1 -> { |
| | | classPathList.add(new WriteExcelData(rowIndex[0],0,codeClassifyVO1.getDataLevel())); |
| | | |
| | | String idPath=codeClassifyVO1.getIdPath().startsWith("#")?codeClassifyVO1.getIdPath().substring(1):codeClassifyVO1.getIdPath(); |
| | | WriteExcelData idPathWriteExcelData=new WriteExcelData(rowIndex[0],1,idPath); |
| | | idPathWriteExcelData.setWidth(30); |
| | | idPathWriteExcelData.setCenter(false); |
| | | classPathList.add(idPathWriteExcelData); |
| | | |
| | | String namePath=codeClassifyVO1.getNamePath().startsWith("#")?codeClassifyVO1.getNamePath().substring(1):codeClassifyVO1.getNamePath(); |
| | | WriteExcelData namePathWriteExcelData= new WriteExcelData(rowIndex[0],2,namePath); |
| | | namePathWriteExcelData.setWidth(40); |
| | | namePathWriteExcelData.setCenter(false); |
| | | classPathList.add(namePathWriteExcelData); |
| | | rowIndex[0]++; |
| | | }); |
| | | |
| | | WriteExcelData excelData=new WriteExcelData(); |
| | | excelData.setMerged(true); |
| | | excelData.setRow(1); |
| | | excelData.setRowTo(2); |
| | | excelData.setCol(4); |
| | | excelData.setColTo(9); |
| | | excelData.setCenter(false); |
| | | excelData.setReadOnly(true); |
| | | excelData.setObj("导å
¥æ°æ®æ¶ï¼å类路å¾å¿
须填åå¶åèç¹è·¯å¾\n(éæ©å¶åèç¹å¯¼å
¥åä¸éè¦å¡«åå类路å¾)"); |
| | | excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex())); |
| | | classPathList.add(excelData); |
| | | |
| | | eo.addSheetDataList(codeClassifyVO.getName()+"å类对ç
§è¡¨",classPathList); |
| | | |
| | | String excelName = LocalFileUtil.getDefaultTempFolder() + File.separator + codeClassifyVO.getName() + "_导å
¥æ¨¡æ¿.xls"; |
| | | // eo.addSheetDataList(templateVOList.size()+"模æ¿ä¿¡æ¯ã请å¿å é¤æç§»å¨ã",tempEDList); |
| | | ExcelUtil.writeDataToFile(excelName,eo); |
| | | return excelName; |
| | | } |
| | | |
| | | /** |
| | | * çæå¯¼å
¥çæä»¶ |
| | | * |
| | | * @param codeClassifyOid åç±»çä¸»é® |
| | | * @param isHistory æ¯å¦å岿°æ®å¯¼å
¥ |
| | | * @return excelçæä»¶å°å |
| | | */ |
| | | @Override |
| | | public String createImportExcel(String codeClassifyOid, boolean isHistory) { |
| | | List<CodeClassifyTemplateVO> templateVOList=new ArrayList<>(); |
| | | |
| | | VciBaseUtil.alertNotNull("å¯¼åºæ¨¡æ¿","导åºçé
ç½®",codeClassifyOid,"主é¢åºåç±»ç主é®"); |
| | | |
| | | CodeClassifyVO codeClassifyVO = classifyService.getObjectByOid(codeClassifyOid); |
| | | |
| | | if(isHistory){ |
| | | templateVOList= templateService.childTemplates(codeClassifyOid); |
| | | }else{ |
| | | //æ¾æ¨¡æ¿ |
| | | CodeClassifyTemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(codeClassifyOid); |
| | | templateVOList.add(templateVO); |
| | | } |
| | | |
| | | WriteExcelOption eo = new WriteExcelOption(); |
| | | eo.setAppend(true); |
| | | //å¢å 模æ¿çä¿¡æ¯å¯¼å
¥ |
| | | LinkedList<WriteExcelData> tempEDList = new LinkedList<>(); |
| | | tempEDList.add(new WriteExcelData(0,0,"模æ¿ä¸»é®")); |
| | | tempEDList.add(new WriteExcelData(0,1,"模æ¿ä»£å·")); |
| | | tempEDList.add(new WriteExcelData(0,2,"模æ¿åç§°")); |
| | | for(int j=0;j<templateVOList.size();j++){ |
| | | CodeClassifyTemplateVO templateVO=templateVOList.get(j); |
| | | CodeClassifyTemplateVO codeClassifyTemplateVO = new CodeClassifyTemplateVO(); |
| | | BeanUtils.copyProperties(templateVO,codeClassifyTemplateVO); |
| | | //ç»åæ ¼å¼çä¸å¯¼å
¥ï¼ |
| | | // æä¸¾çæä¾åºåçéæ© |
| | | //æ¶é´å
¨é¨ç»ä¸ä¸ºyyyy-MM-dd HH:mm:ss |
| | | //åç
§çèªè¡è¾å
¥åç§° |
| | | //å类注å
¥çä¸ç¨ï¼é½æ¯å¯¼å
¥åèªå¨å¤çç |
| | | //ç¼ç ï¼ç¶æçåæ®µä¸å¯¼å
¥ |
| | | List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrVOList=codeClassifyTemplateVO.getAttributes(); |
| | | if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrVOList)) { |
| | | if (CollectionUtils.isEmpty(codeClassifyTemplateAttrVOList)) { |
| | | throw new VciBaseException("æ¨¡æ¿æ²¡æé
ç½®å±æ§"); |
| | | } |
| | | } |
| | | List<CodeClassifyTemplateAttrVO> templateAttrVOS = codeClassifyTemplateAttrVOList.stream().filter(s -> |
| | | !DEFAULT_ATTR_LIST.contains(s.getId()) |
| | | && StringUtils.isBlank(s.getComponentRule()) |
| | | && StringUtils.isBlank(s.getClassifyInvokeAttr()) |
| | | && (isHistory || VciBaseUtil.getBoolean(s.getFormDisplayFlag())) |
| | | ).collect(Collectors.toList()); |
| | | |
| | | if (CollectionUtils.isEmpty(templateAttrVOS)) { |
| | | throw new VciBaseException("æ¨¡æ¿æ²¡æé
置任ä½ãè¡¨åæ¾ç¤ºãä¸ºãæ¯ãç屿§"); |
| | | } |
| | | |
| | | List<CodeClassifyTemplateAttrVO> idAttrVOList = codeClassifyTemplateVO.getAttributes().stream().filter(s -> s.getId().equalsIgnoreCase(CODE_FIELD)).collect(Collectors.toList()); |
| | | LinkedList<WriteExcelData> excelDataList = new LinkedList<>(); |
| | | Workbook workbook = new HSSFWorkbook(); |
| | | if(isHistory){ |
| | | excelDataList.add(new WriteExcelData(0,0,"å类路å¾")); |
| | | excelDataList.add(new WriteExcelData(0,1,"ç æ®µå®½åº¦")); |
| | | excelDataList.add(new WriteExcelData(0,2,!CollectionUtils.isEmpty(idAttrVOList)?idAttrVOList.get(0).getName():"ä¼ä¸ç¼ç ")); |
| | | } |
| | | for (int i = 0; i < templateAttrVOS.size(); i++) { |
| | | CodeClassifyTemplateAttrVO attrVO = templateAttrVOS.get(i); |
| | | |
| | | Object text = attrVO.getName(); |
| | | text = exportKeyAndRequired(workbook,attrVO,text); |
| | | int colIndex = (isHistory?3:0) + i; |
| | | WriteExcelData excelData = new WriteExcelData(0, colIndex, text); |
| | | if(StringUtils.isNotBlank(attrVO.getCodeDateFormat()) |
| | | || VciFieldTypeEnum.VTDateTime.name().equalsIgnoreCase(attrVO.getAttributeDataType()) |
| | | || VciFieldTypeEnum.VTDate.name().equalsIgnoreCase(attrVO.getAttributeDataType()) |
| | | ||VciFieldTypeEnum.VTTime.name().equalsIgnoreCase(attrVO.getAttributeDataType())){ |
| | | excelData.setDateFormat(VciDateUtil.DateTimeFormat); |
| | | } |
| | | if(text instanceof RichTextString){ |
| | | excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex())); |
| | | } |
| | | excelDataList.add(excelData); |
| | | if(StringUtils.isNotBlank(attrVO.getEnumString()) || StringUtils.isNotBlank(attrVO.getEnumId())){ |
| | | //æ·»å æ°æ®æææ§ |
| | | List<String> enumValueList = new ArrayList<>(); |
| | | enumValueList.add(""); |
| | | List<KeyValue> valueList = engineService.listComboboxItems(attrVO); |
| | | if(!CollectionUtils.isEmpty(valueList)){ |
| | | valueList.stream().forEach(kv->{ |
| | | enumValueList.add(kv.getValue()); |
| | | }); |
| | | } |
| | | //é»è®¤å 1䏿¡ |
| | | WriteExcelData ed = new WriteExcelData(1,colIndex,""); |
| | | ed.setRowTo(100); |
| | | ed.setColTo(colIndex); |
| | | ed.setValidation(true); |
| | | ed.setValidationDataList(enumValueList); |
| | | ed.setValidationErrorMsg("请å¨åºåä¸éæ©æ£ç¡®çå¼"); |
| | | excelDataList.add(ed); |
| | | } |
| | | if(VciFieldTypeEnum.VTBoolean.name().equalsIgnoreCase(attrVO.getAttributeDataType())){ |
| | | List<String> booleanList = new ArrayList<>(); |
| | | |
| | | booleanList.add("æ¯"); |
| | | booleanList.add("å¦"); |
| | | //é»è®¤å 1䏿¡ |
| | | WriteExcelData ed = new WriteExcelData(1,colIndex,""); |
| | | ed.setRowTo(100); |
| | | ed.setColTo(colIndex); |
| | | ed.setValidation(true); |
| | | ed.setValidationDataList(booleanList); |
| | | ed.setValidationErrorMsg("请å¨åºåä¸éæ©æ£ç¡®çå¼"); |
| | | excelDataList.add(ed); |
| | | } |
| | | } |
| | | eo.addSheetDataList(j+templateVO.getName(),excelDataList); |
| | | tempEDList.add(new WriteExcelData(j+1,0,templateVO.getOid())); |
| | | tempEDList.add(new WriteExcelData(j+1,1,templateVO.getId())); |
| | | tempEDList.add(new WriteExcelData(j+1,2,templateVO.getName())); |
| | | } |
| | | String excelName = LocalFileUtil.getDefaultTempFolder() + File.separator + codeClassifyVO.getName() + (isHistory?"_å岿°æ®å¯¼å
¥æ¨¡æ¿.xls": "_导å
¥æ¨¡æ¿.xls"); |
| | | eo.addSheetDataList(templateVOList.size()+"模æ¿ä¿¡æ¯ã请å¿å é¤æç§»å¨ã",tempEDList); |
| | | ExcelUtil.writeDataToFile(excelName,eo); |
| | | return excelName; |
| | | } |
| | | |
| | | /** |
| | | * 导åºçæ¶åå°è£
å¿
è¾åå
³é®å±æ§ |
| | | * @param attrVO 屿§çæ¾ç¤ºå¯¹è±¡ |
| | | * @param text åå
æ ¼çå¼ |
| | | */ |
| | | private Object exportKeyAndRequired(Workbook workbook,CodeClassifyTemplateAttrVO attrVO,Object text){ |
| | | //å¿
è¾å *ï¼å
³é®å±æ§ä¸ºèè² |
| | | if (VciBaseUtil.getBoolean(attrVO.getRequireFlag()) || VciBaseUtil.getBoolean(attrVO.getKeyAttrFlag())) { |
| | | String value = text.toString(); |
| | | if(VciBaseUtil.getBoolean(attrVO.getRequireFlag())) { |
| | | value += REQUIRED_CHAR; |
| | | } |
| | | if(VciBaseUtil.getBoolean(attrVO.getKeyAttrFlag())){ |
| | | value += KEY_ATTR_CHAR; |
| | | } |
| | | RichTextString ts = new HSSFRichTextString(value); |
| | | if(VciBaseUtil.getBoolean(attrVO.getRequireFlag())){ |
| | | Font font = workbook.createFont(); |
| | | font.setColor(HSSFColor.HSSFColorPredefined.RED.getIndex()); |
| | | ts.applyFont(font); |
| | | } |
| | | |
| | | if(VciBaseUtil.getBoolean(attrVO.getKeyAttrFlag())){ |
| | | Font font = workbook.createFont(); |
| | | font.setColor(HSSFColor.HSSFColorPredefined.BLUE.getIndex()); |
| | | ts.applyFont(font); |
| | | } |
| | | return ts; |
| | | } |
| | | return text; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ¹éç³è¯·ç¼ç æ°æ® |
| | | * |
| | | * @param orderDTO ç¼ç ç³è¯·ä¿¡æ¯ï¼å¿
é¡»å
å«å类主é®åç æ®µçä¿¡æ¯ |
| | | * @param file excelæä»¶çä¿¡æ¯ |
| | | * @return æé误信æ¯çexcelçæä»¶ |
| | | */ |
| | | @Override |
| | | public CodeImProtRusultVO batchImportCode(CodeOrderDTO orderDTO, File file) { |
| | | VciBaseUtil.alertNotNull(orderDTO,"ç¼ç ç³è¯·ç¸å
³çæ°æ®",orderDTO.getCodeClassifyOid(),"主é¢åºå类主é®"); |
| | | ReadExcelOption reo = new ReadExcelOption(); |
| | | reo.setReadAllSheet(true); |
| | | List<SheetDataSet> sheetDataSetList = ExcelUtil.readDataObjectFromExcel(file,null,reo); |
| | | if(CollectionUtils.isEmpty(sheetDataSetList) || CollectionUtils.isEmpty(sheetDataSetList.get(0).getRowData()) |
| | | ||sheetDataSetList.get(0).getRowData().size()<1){ |
| | | throw new VciBaseException("没æè¯»åå°ä»»ä½çæ°æ®"); |
| | | } |
| | | if(sheetDataSetList.size()>LIMIT+1){ |
| | | throw new VciBaseException("为äºä¿è¯ç³»ç»çç¨³å®æ§ï¼è¯·ä¸æ¬¡ä¸è¦å¯¼å
¥è¶
è¿1䏿¡çæ°æ®"); |
| | | } |
| | | //å
æ¾å°æ¯ä¸è¡çæ é¢ï¼ç¶åæ ¹æ®æ 颿¥è·å对åºç屿§ |
| | | SheetDataSet dataSet = sheetDataSetList.get(0); |
| | | //æ¾ç¬¬ä¸è¡ï¼ä¸ºäºæ¾æ é¢ |
| | | CodeClassifyTemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(orderDTO.getCodeClassifyOid()); |
| | | |
| | | //æ ¡éªæ¨¡æ¿æ¯ä¸æ¯ææ°ç |
| | | checkTemplateSync(sheetDataSetList,templateVO,0); |
| | | //å
ä¸ç¨ç®¡å±æ§æ¯å¦é½åå¨ï¼å
转æ¢ä¸ä¸æ°æ® |
| | | Map<String,String> errorMap = new HashMap<>(); |
| | | String redisUUid=batchImportCodes(orderDTO,templateVO,dataSet,errorMap,true); |
| | | CodeImProtRusultVO codeImProtRusultVO = new CodeImProtRusultVO(); |
| | | List<String> needRowIndexList = new ArrayList<>(); |
| | | String filePath = returnErrorToExcel(dataSet.getRowData(), errorMap, needRowIndexList, dataSet.getColName()); |
| | | if(StringUtils.isNotBlank(filePath)) { |
| | | codeImProtRusultVO.setFilePath(filePath); |
| | | } |
| | | if(StringUtils.isNotBlank(redisUUid)){ |
| | | codeImProtRusultVO.setRedisUuid(redisUUid); |
| | | } |
| | | // return null; |
| | | return codeImProtRusultVO; |
| | | } |
| | | |
| | | |
| | | /*** |
| | | * ä»é¡¶å±æ¹éç³è¯·å¯¼å
¥æ¹æ³ |
| | | * @param codeClassifyOid åç±»çä¸»é® |
| | | * @param classifyAttr å类路å¾ä½¿ç¨ç屿§ |
| | | * @param file excelæä»¶çä¿¡æ¯ |
| | | * @return |
| | | */ |
| | | @Override |
| | | public CodeImProtRusultVO batchTopImportCode(String codeClassifyOid, String classifyAttr, File file) { |
| | | VciBaseUtil.alertNotNull(codeClassifyOid,"åç±»ç主é®"); |
| | | ReadExcelOption reo = new ReadExcelOption(); |
| | | reo.setReadAllSheet(true); |
| | | List<SheetDataSet> sheetDataSetList = ExcelUtil.readDataObjectFromExcel(file,null,reo); |
| | | if(CollectionUtils.isEmpty(sheetDataSetList) || CollectionUtils.isEmpty(sheetDataSetList.get(0).getRowData()) |
| | | ||sheetDataSetList.get(0).getRowData().size()<1){ |
| | | throw new VciBaseException("没æè¯»åå°ä»»ä½çæ°æ®"); |
| | | } |
| | | if(sheetDataSetList.size()>LIMIT+1){ |
| | | throw new VciBaseException("为äºä¿è¯ç³»ç»çç¨³å®æ§ï¼è¯·ä¸æ¬¡ä¸è¦å¯¼å
¥è¶
è¿1䏿¡çæ°æ®"); |
| | | } |
| | | //å
æ¾å°æ¯ä¸è¡çæ é¢ï¼ç¶åæ ¹æ®æ 颿¥è·å对åºç屿§ |
| | | SheetDataSet dataSet = sheetDataSetList.get(0); |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyOid); |
| | | //è·åå½åæ¨¡æ¿ |
| | | CodeClassifyTemplateVO selectCodeClassifyTemplateVO =engineService.getUsedTemplateByClassifyOid(codeClassifyOid); |
| | | Map<String,List<ColumnVO>> templateColumnVOMap=new HashMap<>(); |
| | | createTemplate(selectCodeClassifyTemplateVO,templateColumnVOMap); |
| | | |
| | | List<CodeClassifyVO> childClassifyVOs = classifyService.listChildrenClassify(codeClassifyOid, true, classifyAttr, true); |
| | | Map<String/**è·¯å¾**/, CodeClassifyVO> pathMap = Optional.ofNullable(childClassifyVOs).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getPath().startsWith("#") ? s.getPath().substring(1) : s.getPath(), t -> t)); |
| | | pathMap.put("#current#", classifyFullInfo.getCurrentClassifyVO()); |
| | | List<String> titleRowData = dataSet.getColName(); |
| | | Map<String, String> errorMap = new ConcurrentHashMap<>(); |
| | | //é¦å
å°æ°æ®ä»¥æ¨¡æ¿çå½¢å¼åå¼ |
| | | LinkedHashMap<String,List<CodeImprotDataVO>> codeclassifyDataMap=new LinkedHashMap<>(); |
| | | List<CodeImprotDataVO> codeClassifyDatas=new ArrayList<>(); |
| | | createExeclClassData(dataSet,pathMap,errorMap,codeClassifyDatas); |
| | | |
| | | //æ ¹æ®æ¨¡æ¿å°æ°æ®æ´åå¨ä¸èµ·ï¼å»æ ¡éª |
| | | Map<String/**模æ¿oid**/, List<CodeImprotDataVO>/**æ°æ®å¯¹è±¡**/> templateDatasMap =codeClassifyDatas.stream().collect(Collectors.toMap(CodeImprotDataVO::getTemplateOid,s->{ |
| | | List<CodeImprotDataVO> l=new ArrayList<>(); |
| | | l.add(s); |
| | | return l; |
| | | },(List<CodeImprotDataVO> s1,List<CodeImprotDataVO> s2)->{ |
| | | s1.addAll(s2); |
| | | return s1; |
| | | })); |
| | | String uuid=VciBaseUtil.getPk(); |
| | | List<CodeImportTemplateVO> codeImportTemplateVOS=new ArrayList<>(); |
| | | Map<String,CodeImportTemplateVO> codeRuleMap=new HashMap<>(); |
| | | |
| | | //ç¸ä¼¼æ°æ® |
| | | // Map<String,String>wpResembleMap=new HashMap<>(); |
| | | // List<CodeImprotDataVO> wpCodeImprotDataVOList=new ArrayList<>(); |
| | | //æç
§æ¨¡æ¿å»æ´çæ°æ® |
| | | templateDatasMap.keySet().stream().forEach(templateVOOid->{ |
| | | List<CodeImprotDataVO> codeImprotDataVOS= templateDatasMap.get(templateVOOid); |
| | | CodeClassifyTemplateVO templateVO= templateService.getObjectHasAttrByOid(templateVOOid); |
| | | |
| | | //é¤å»é»è®¤ç屿§.è¿æåªæè¡¨åæ¾ç¤ºçåæ®µæå¯¼å
¥ |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> |
| | | !DEFAULT_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag()) |
| | | ).collect(Collectors.toList()); |
| | | |
| | | Map<String/**模æ¿å±æ§å段oid**/, String /**模æ¿å±æ§å¤é¨åç§°**/> fieldNameMap =attrVOS.stream().collect(Collectors.toMap(CodeClassifyTemplateAttrVO::getId,s->s.getName())); |
| | | |
| | | List<ClientBusinessObject> allCboList=new ArrayList<>(); |
| | | codeImprotDataVOS.stream().forEach(codeImprotDataVO -> { |
| | | List<ColumnVO>columnVOList =new ArrayList(); |
| | | String templateOid=selectCodeClassifyTemplateVO.getOid(); |
| | | if(templateColumnVOMap.containsKey(templateOid)){ |
| | | columnVOList= columnVOList=templateColumnVOMap.get(templateOid); |
| | | }else{ |
| | | createTemplate(templateVO,templateColumnVOMap); |
| | | columnVOList= columnVOList=templateColumnVOMap.get(templateOid); |
| | | } |
| | | String codeRuleOid=codeImprotDataVO.getCodeRuleOid(); |
| | | if(!codeRuleMap.containsKey(codeRuleOid)){ |
| | | CodeImportTemplateVO codeImportTemplateVO=new CodeImportTemplateVO(); |
| | | codeImportTemplateVO.setRoot(false); |
| | | codeImportTemplateVO.setCodeClassifyOid(codeImprotDataVO.getCodeClassifyOid()); |
| | | codeImportTemplateVO.setCodeRuleOid(codeImprotDataVO.getCodeRuleOid()); |
| | | codeImportTemplateVO.setCodeTemplateOid (codeImprotDataVO.getTemplateOid()); |
| | | codeImportTemplateVO.setCodeClassifyVO( codeImprotDataVO.getCodeClassifyVO()); |
| | | codeImportTemplateVO.setCodeClassifyTemplateVO( codeImprotDataVO.getCodeClassifyTemplateVO()); |
| | | codeImportTemplateVO.setCodeRuleVO(codeImprotDataVO.getCodeRuleVO()); |
| | | List<String> colNames=codeImprotDataVO.getColNames(); |
| | | codeImportTemplateVO.setCloNamesList(columnVOList); |
| | | codeImportTemplateVOS.add(codeImportTemplateVO); |
| | | codeRuleMap.put(codeRuleOid,codeImportTemplateVO); |
| | | } |
| | | List<ClientBusinessObject> cboList=new ArrayList<>(); |
| | | excelToCbo(classifyFullInfo,codeImprotDataVO,cboList,true); |
| | | allCboList.addAll(cboList); |
| | | //å¾éæ©çèç¹éé¢å æ°æ® |
| | | // CodeImprotDataVO wpcodeImprotDataVO=new CodeImprotDataVO(); |
| | | // BeanUtilForVCI.copyPropertiesIgnoreCase(codeImprotDataVO,wpcodeImprotDataVO); |
| | | /* wpcodeImprotDataVO.setCodeClassifyOid(codeClassifyOid); |
| | | wpcodeImprotDataVO.setCodeClassifyVO(classifyFullInfo.getCurrentClassifyVO()); |
| | | wpcodeImprotDataVO.setCodeClassifyTemplateVO(selectCodeClassifyTemplateVO); |
| | | wpcodeImprotDataVO.setCodeRuleOid(classifyFullInfo.getCurrentClassifyVO().getCoderuleoid());*/ |
| | | // wpCodeImprotDataVOList.add(wpcodeImprotDataVO);//å¾ç©åå¯¹è±¡éæ·»å |
| | | |
| | | }); |
| | | |
| | | |
| | | //é½è½¬æ¢å®äºãéè¦æ¹éæ£æ¥ |
| | | //妿åºéäºï¼æä»¬ä¾ç¶æ§è¡ææçæ°æ®ï¼æ æçæ°æ®ååå°excelä¸ |
| | | //2.夿å¿
è¾é¡¹ããéè¦å
¨é¨ç屿§ï¼å¦ææ¯å¿
è¾ï¼ä½æ¯è¡¨åéé¢ä¸æ¾ç¤ºçï¼åªè½æ¯å类注å
¥æè
ç»åè§å |
| | | batchCheckRequiredAttrOnOrder(templateVO,allCboList,errorMap); |
| | | //3.夿å
³é®å±æ§ |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, templateVO, allCboList); |
| | | 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,allCboList,classifyFullInfo,false); |
| | | //boolean |
| | | reSwitchBooleanAttrOnOrder(attrVOS,allCboList); |
| | | //4.æ ¡éªè§å |
| | | batchCheckVerifyOnOrder(attrVOS, allCboList,errorMap); |
| | | //æ¯å¦éè¦æ ¡éªæä¸¾/åç
§ |
| | | //5.æ ¡éªæä¸¾æ¯å¦æ£ç¡® |
| | | batchSwitchEnumAttrOnOrder(attrVOS, allCboList, errorMap); |
| | | //7.å¤çåç
§çæ
åµ |
| | | batchSwitchReferAttrOnOrder(attrVOS,allCboList,errorMap); |
| | | |
| | | //6.æ¶é´æ ¼å¼çéªè¯ |
| | | //6.æ¶é´çï¼å¿
é¡»ç»ä¸ä¸ºyyyy-MM-dd HH:mm:ss |
| | | batchSwitchDateAttrOnOrder(attrVOS,allCboList,errorMap); |
| | | //设置é»è®¤å¼ |
| | | batchSwitchAttrDefault(attrVOS, allCboList); |
| | | //æåå¼ç»åè§å |
| | | 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); |
| | | return !errorMap.containsKey(rowIndex); |
| | | }).collect(Collectors.toList()); |
| | | //ç¸ä¼¼æ ¡éª |
| | | 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)) { |
| | | bladeRedis.set(uuid + "-resemble-data", dataResembleVOS); |
| | | bladeRedis.expire(uuid + "-resemble-data",BATCHADD_REDIS_TIME);//redisè¿ææ¶é´ |
| | | // createRedisDatas(uuid + "-resemble", codeImprotDataVOS, resembleMap, false); |
| | | // wpResembleMap.putAll(resembleMap); |
| | | } |
| | | } |
| | | //æé¤é误çï¼å©ä¸æ£ç¡®ç |
| | | Map<String,String> newErrorMap=new HashMap<>(); |
| | | newErrorMap.putAll(resembleMap); |
| | | newErrorMap.putAll(errorMap); |
| | | needSaveCboList = allCboList.stream().filter(cbo -> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | return !newErrorMap.containsKey(rowIndex); |
| | | }).collect(Collectors.toList()); |
| | | if(newErrorMap.size()>0) { |
| | | createRedisDatas(uuid + "-resemble",codeImprotDataVOS, newErrorMap,false); |
| | | } |
| | | createRedisDatas(uuid + "-ok",codeImprotDataVOS, newErrorMap,true); |
| | | |
| | | }); |
| | | //å¾ç©åèç¹ä¸å æ¨¡æ¿ |
| | | |
| | | |
| | | |
| | | List<String> needRowIndexList=new ArrayList<>(); |
| | | CodeImProtRusultVO codeImProtRusultVO = new CodeImProtRusultVO(); |
| | | if(errorMap.size()>0) { |
| | | String filePath = returnErrorToExcel(dataSet.getRowData(), errorMap, needRowIndexList, dataSet.getColName()); |
| | | if (StringUtils.isNotBlank(filePath)) { |
| | | codeImProtRusultVO.setFilePath(filePath); |
| | | } |
| | | } |
| | | if(StringUtils.isNotBlank(uuid)){ |
| | | //å°ææçåç±»åå
¥ç¼åä¹ä¸ |
| | | codeImProtRusultVO.setRedisUuid(uuid); |
| | | /** List<ColumnVO>columnVOList=new ArrayList<>(); |
| | | CodeImportTemplateVO wpCodeImportTemplateVO=new CodeImportTemplateVO(); |
| | | wpCodeImportTemplateVO.setRoot(true); |
| | | wpCodeImportTemplateVO.setCodeClassifyTemplateVO(selectCodeClassifyTemplateVO); |
| | | wpCodeImportTemplateVO.setCodeClassifyVO(classifyFullInfo.getCurrentClassifyVO()); |
| | | String templateOid=selectCodeClassifyTemplateVO.getOid(); |
| | | if(templateColumnVOMap.containsKey(templateOid)){ |
| | | columnVOList= columnVOList=templateColumnVOMap.get(templateOid); |
| | | }else{ |
| | | createTemplate(selectCodeClassifyTemplateVO,templateColumnVOMap); |
| | | columnVOList= columnVOList=templateColumnVOMap.get(templateOid); |
| | | } |
| | | wpCodeImportTemplateVO.setCloNamesList(columnVOList); |
| | | codeImportTemplateVOS.add(wpCodeImportTemplateVO); |
| | | |
| | | if(wpResembleMap.size()>0){ |
| | | // redisService.setCacheList(uuid + "-resemble-data", wpDataResembleVOList); |
| | | createRedisDatas(uuid + "-resemble",selectCodeClassifyTemplateVO, wpCodeImprotDataVOList, wpResembleMap, false,codeClassifyOid); |
| | | } |
| | | //æé¤é误çï¼å©ä¸æ£ç¡®ç |
| | | Map<String,String> newErrorMap=new HashMap<>(); |
| | | newErrorMap.putAll(wpResembleMap); |
| | | newErrorMap.putAll(errorMap); |
| | | List<CodeImprotDataVO> needSaveCboList = wpCodeImprotDataVOList.stream().filter(cbo -> { |
| | | String rowIndex = cbo.getRowIndex(); |
| | | return !newErrorMap.containsKey(rowIndex); |
| | | }).collect(Collectors.toList()); |
| | | createRedisDatas(uuid + "-ok",selectCodeClassifyTemplateVO,wpCodeImprotDataVOList, newErrorMap,true,codeClassifyOid);****/ |
| | | if(codeImportTemplateVOS.size()>0){ |
| | | bladeRedis.set(uuid + "-class",codeImportTemplateVOS); |
| | | bladeRedis.expire(uuid + "-class",BATCHADD_REDIS_TIME); |
| | | } |
| | | } |
| | | return codeImProtRusultVO; |
| | | } |
| | | |
| | | /** |
| | | * 导å
¥å岿°æ® |
| | | * |
| | | * @param codeClassifyOid åç±»çä¸»é® |
| | | * @param classifyAttr å类路å¾ä½¿ç¨ç屿§ |
| | | * @param file excelæä»¶çä¿¡æ¯ |
| | | * @return æé误信æ¯çexcel |
| | | */ |
| | | @Override |
| | | public CodeImProtRusultVO batchImportHistoryData(String codeClassifyOid, String classifyAttr,File file) throws Throwable{ |
| | | VciBaseUtil.alertNotNull(codeClassifyOid,"åç±»ç主é®"); |
| | | ReadExcelOption reo = new ReadExcelOption(); |
| | | reo.setReadAllSheet(true); |
| | | List<SheetDataSet> sheetDataSetList = ExcelUtil.readDataObjectFromExcel(file,null,reo); |
| | | if (sheetDataSetList.size() > LIMIT + 1) { |
| | | throw new VciBaseException("为äºä¿è¯ç³»ç»çç¨³å®æ§ï¼è¯·ä¸æ¬¡ä¸è¦å¯¼å
¥è¶
è¿1䏿¡çæ°æ®"); |
| | | } |
| | | Map<String,List<WriteExcelData>> shetNameMap=new HashMap<>(); |
| | | //ç¸ä¼¼é¡¹ç®æ¥é |
| | | String uuid=VciBaseUtil.getPk(); |
| | | boolean isCreateUUid=false; |
| | | boolean isExport=false; |
| | | for(int i=0;i<sheetDataSetList.size()-1;i++) { |
| | | if (CollectionUtils.isEmpty(sheetDataSetList) || CollectionUtils.isEmpty(sheetDataSetList.get(i).getRowData()) |
| | | || sheetDataSetList.get(i).getRowData().size() < 1) { |
| | | continue; |
| | | } |
| | | //åå²å¯¼å
¥çæ¶åä¸å¤çç¼ç |
| | | //----é»è¾å
容---- |
| | | //1. åç±»çè·¯å¾å¯ä»¥å¨é¡µé¢ä¸éæ©æ¯åç±»ç¼å·è¿æ¯åç±»çåç§° |
| | | //2. åç±»çè·¯å¾ï¼å¿
é¡»æ¯å½å导å
¥éæ©çåç±»çèç¹ï¼ä»¥åå
¶ä¸çº§èç¹ |
| | | //3. éè¿æ°æ®è¦å¯¼å
¥çåç±»å»æ¥æ¾å¯¹åºçç¼ç è§å |
| | | //4. æ°æ®åå¨åæ¹éç³è¯·ä¸æ ·ï¼ |
| | | //5. éè¦åç¬å¤çä¼ä¸ç¼ç çå
å®¹ï¼ |
| | | // 5.1 ä¼ä¸ç¼ç å¨å½åexceléä¸è½éå¤ |
| | | // 5.2 ä¼ä¸ç¼ç å¨ç³»ç»ä¸ä¸è½éå¤ï¼å¯ä»¥æ¯å·²ç»åæ¶çï¼ |
| | | // 5.3 ä¼ä¸ç¼ç çé¿åº¦ï¼åç¼ç è§åçé¿åº¦è¦å¯¹åºä¸ |
| | | // 5.4 è·åæµæ°´ç 段çå¼ï¼å»é¤å¡«å
çå符ï¼çæµæ°´å·æ¯å¤å°ï¼ç¶åå°æµæ°´å·åç°å¨çæå¤§æµæ°´å·å¤æï¼å°äºå°±ç´æ¥å½å
¥ï¼å¤§äºåä¿®æ¹æå¤§æµæ°´å· |
| | | // 5.5 åå¨ä¼ä¸ç¼ç å°allcodeä¸ |
| | | |
| | | //æ¥è¯¢åç±»åæ¨¡æ¿ |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyOid); |
| | | |
| | | //å
æ¾å°æ¯ä¸è¡çæ é¢ï¼ç¶åæ ¹æ®æ 颿¥è·å对åºç屿§ |
| | | SheetDataSet dataSet = sheetDataSetList.get(i); |
| | | List<SheetRowData> rowDataList = dataSet.getRowData(); |
| | | |
| | | //æ¾ç¬¬ä¸è¡ï¼ä¸ºäºæ¾æ é¢ |
| | | CodeClassifyTemplateVO templateVO = new CodeClassifyTemplateVO(); |
| | | /** if (!templateService.checkChildHasSameTemplate(classifyFullInfo.getCurrentClassifyVO().getOid())) { |
| | | throw new VciBaseException("å½åçå类以åä¸çº§åç±»çæ¨¡æ¿ä¸ç¸å"); |
| | | }***/ |
| | | //é½è½¬æ¢å®äºãéè¦æ¹éæ£æ¥ |
| | | //æ¾ææçå类路å¾,éè¦æ ¡éªè·¯å¾æ¯å¦æ£ç¡®ï¼æ¯å¦é½å¨å½åçåç±»çä¸çº§ |
| | | List<CodeClassifyVO> childClassifyVOs = classifyService.listChildrenClassify(codeClassifyOid, true, classifyAttr, true); |
| | | Map<String/**è·¯å¾**/, CodeClassifyVO> pathMap = Optional.ofNullable(childClassifyVOs).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getPath().startsWith("#") ? s.getPath().substring(1) : s.getPath(), t -> t)); |
| | | List<String> titleRowData = dataSet.getColName(); |
| | | Map<String, String> errorMap = new ConcurrentHashMap<>(); |
| | | pathMap.put("#current#",classifyFullInfo.getCurrentClassifyVO()); |
| | | |
| | | try { |
| | | List<CodeClassifyTemplateVO> templateVOList= checkSamesTemplate(titleRowData,sheetDataSetList,i,pathMap,errorMap); |
| | | templateVO= templateVOList.get(0); |
| | | }catch (Throwable e){ |
| | | throw new VciBaseException(e.getMessage()); |
| | | } |
| | | |
| | | List<SheetRowData> needowDataList = rowDataList.stream().filter(cbo -> { |
| | | String rowIndex = cbo.getRowIndex(); |
| | | return !errorMap.containsKey(rowIndex); |
| | | }).collect(Collectors.toList()); |
| | | |
| | | //checkTemplateSync(sheetDataSetList, templateVO,i); |
| | | //è¿éä¸é¤å»é»è®¤ç屿§ |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes(); |
| | | Map<Integer/**åå·**/, String/**åæ®µçåç§°**/> fieldIndexMap = new HashMap<>(); |
| | | |
| | | Map<String/**䏿åç§°**/, String/**è±æåç§°**/> attrNameIdMap = attrVOS.stream().collect(Collectors.toMap(s -> s.getName(), t -> t.getId())); |
| | | String idFieldName = attrVOS.stream().filter(s -> VciQueryWrapperForDO.ID_FIELD.equalsIgnoreCase(s.getId())).findFirst().orElseGet(() -> new CodeClassifyTemplateAttrVO()).getName(); |
| | | getFieldIndexMap(titleRowData, attrNameIdMap, fieldIndexMap); |
| | | //å
ä¸ç¨ç®¡å±æ§æ¯å¦é½åå¨ï¼å
转æ¢ä¸ä¸æ°æ® |
| | | List<ClientBusinessObject> cboList = new ArrayList<>(); |
| | | String fullPath = getFullPath(classifyFullInfo); |
| | | //æä»¬éè¦è·åå°ææçä¸çº§åç±»çoidçè·¯å¾ï¼å 为åé¢éè¦ |
| | | Map<String/**主é®**/, String/**è·¯å¾**/> childOidPathMap = getChildClassifyPathMap(classifyFullInfo, fullPath); |
| | | excelToCbo(classifyFullInfo, fieldIndexMap, needowDataList, templateVO, cboList, fullPath, false); |
| | | |
| | | |
| | | Map<String/**主é®**/, CodeClassifyVO> classifyVOMap = Optional.ofNullable(childClassifyVOs).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | classifyVOMap.put(classifyFullInfo.getCurrentClassifyVO().getOid(), classifyFullInfo.getCurrentClassifyVO()); |
| | | pathMap.put("#current#", classifyFullInfo.getCurrentClassifyVO()); |
| | | |
| | | //夿ç¼å·å¨exceléæ¬èº«å°±éå¤ç |
| | | Map<String, Long> idCountMap = cboList.stream().collect(Collectors.groupingBy(ClientBusinessObject::getId, Collectors.counting())); |
| | | List<String> repeatIdList = new ArrayList<>(); |
| | | idCountMap.forEach((id, count) -> { |
| | | if (count > 1) { |
| | | repeatIdList.add(id); |
| | | } |
| | | }); |
| | | if (!CollectionUtils.isEmpty(repeatIdList)) { |
| | | cboList.stream().filter(s -> repeatIdList.contains(s.getId())).map(s -> s.getAttributeValue(IMPORT_ROW_INDEX)).forEach(rowIndex -> { |
| | | errorMap.put(rowIndex, "ç¼å·å¨å½åexcelä¸éå¤;"); |
| | | }); |
| | | } |
| | | //æä»¬éè¦å¤æè¿äºåç±»çæ¨¡æ¿æ¯ä¸æ¯ä¸æ ·çï¼åªéè¦æ ¡éªï¼ä¸ç¨è·å |
| | | //æ£æ¥åç±»çè·¯å¾ |
| | | checkClassifyPathInHistory(cboList, errorMap, pathMap, childOidPathMap); |
| | | |
| | | //æ£æ¥è§å |
| | | Map<String/**å类主é®**/, String/**è§å主é®**/> ruleOidMap = new ConcurrentHashMap<String, String>(); |
| | | List<String> unExistRuleClassifyOidList = new CopyOnWriteArrayList<>(); |
| | | checkRuleOidInHistory(classifyVOMap, ruleOidMap, unExistRuleClassifyOidList); |
| | | //妿åºéäºï¼æä»¬ä¾ç¶æ§è¡ææçæ°æ®ï¼æ æçæ°æ®ååå°excelä¸ |
| | | |
| | | //æä»¬æ ¹æ®åºéçåç±»ç主é®ï¼å»æ¾è¡å· |
| | | if (!CollectionUtils.isEmpty(unExistRuleClassifyOidList)) { |
| | | cboList.stream().forEach(cbo -> { |
| | | if (unExistRuleClassifyOidList.contains(cbo.getAttributeValue(CODE_CLASSIFY_OID_FIELD))) { |
| | | String row_index = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | errorMap.put(row_index, errorMap.getOrDefault(row_index, "") + ";æ ¹æ®å类路å¾å¯¹åºçåç±»ï¼æ²¡æè®¾ç½®ç¼ç è§å"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //夿å¿
è¾é¡¹ |
| | | batchCheckRequiredAttrOnOrder(templateVO, cboList, errorMap); |
| | | |
| | | //æéæ ¡éªç¼ç æ¯å¦åå¨ |
| | | batchCheckIdExistOnOrder(templateVO, cboList, errorMap); |
| | | |
| | | //boolean |
| | | reSwitchBooleanAttrOnOrder(attrVOS, cboList); |
| | | |
| | | // æä¸¾çå
容éè¦æ ¹æ®å称转æ¢ä¸ºæä¸¾çå¼ |
| | | batchSwitchEnumAttrOnOrder(attrVOS, cboList, errorMap); |
| | | |
| | | batchSwitchReferAttrOnOrder(attrVOS, cboList, errorMap); |
| | | //6.å¤çå类注å
¥ |
| | | batchSwitchClassifyAttrOnOrder(attrVOS, cboList, classifyFullInfo,true); |
| | | |
| | | //设置é»è®¤å¼ |
| | | batchSwitchAttrDefault(attrVOS, cboList); |
| | | //7.å¤çç»åè§å |
| | | batchSwitchComponentAttrOnOrder(attrVOS, cboList); |
| | | //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, "") + ";å¨å½åexcelæä»¶ä¸å
³é®å±æ§éå¤"); |
| | | }); |
| | | } |
| | | if (!CollectionUtils.isEmpty(keyAttrRepeatRowIndexList)) { |
| | | keyAttrRepeatRowIndexList.stream().forEach(rowIndex -> { |
| | | errorMap.put(rowIndex, errorMap.getOrDefault(rowIndex, "") + ";å
³é®å±æ§ä¸ç³»ç»ä¸çéå¤"); |
| | | }); |
| | | } |
| | | //4.æ ¡éªè§å |
| | | batchCheckVerifyOnOrder(attrVOS, cboList, errorMap); |
| | | |
| | | //6.æ¶é´çï¼å¿
é¡»ç»ä¸ä¸ºyyyy-MM-dd HH:mm:ss |
| | | batchSwitchDateAttrOnOrder(attrVOS, cboList, errorMap); |
| | | if (CollectionUtils.isEmpty(ruleOidMap.values())) { |
| | | throw new VciBaseException("导å
¥çæ°æ®æéæ©çåç±»é½æ²¡æè®¾ç½®ç¼ç è§å"); |
| | | } |
| | | Map<String, CodeRuleVO> ruleVOMap = ruleService.listCodeRuleByIds(ruleOidMap.values(), true).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | //æ ¡éªç¼ç è§ååç æ®µæ¯å¦æ£ç¡® |
| | | Map<String, List<String>> ruleRowIndexMap = new ConcurrentHashMap<>(); |
| | | checkSecLengthInHistory(cboList, classifyVOMap, ruleVOMap, ruleOidMap, errorMap, ruleRowIndexMap); |
| | | ruleRowIndexMap.keySet().parallelStream().forEach(ruleOid -> { |
| | | List<String> rowIndexList = ruleRowIndexMap.get(ruleOid); |
| | | List<ClientBusinessObject> thisCbos = cboList.stream().filter(cbo -> rowIndexList.contains(cbo.getAttributeValue(IMPORT_ROW_INDEX)) && !errorMap.containsKey(cbo.getAttributeValue(IMPORT_ROW_INDEX))).collect(Collectors.toList()); |
| | | //æä»¬éè¦å
æ¥è¯¢ä¸ä¸ï¼å
容æ¯å¦å·²ç»åå¨ |
| | | if(!CollectionUtils.isEmpty(thisCbos)){ |
| | | List<String> existIds = new ArrayList<>(); |
| | | VciBaseUtil.switchCollectionForOracleIn(thisCbos).stream().forEach(cbos -> { |
| | | List<CodeAllCode> codeAllCodeList= codeAllCodeService.selectByWrapper(Wrappers.<CodeAllCode>query().lambda().eq(CodeAllCode::getCodeRuleOid, ruleOid) |
| | | .notIn(CodeAllCode::getId,cbos.stream().map(s -> s.getId()).collect(Collectors.toSet()).toArray(new String[0])) |
| | | .notIn(CodeAllCode::getLcStatus,CodeAllCodeLC.TASK_BACK.getValue() + "','" + CodeAllCodeLC.OBSOLETED.getValue()) |
| | | ); |
| | | existIds.addAll(Optional.ofNullable(codeAllCodeList).orElseGet(() -> new ArrayList<>()).stream().map(s -> { |
| | | String id = s.getId(); |
| | | if (StringUtils.isBlank(id)) { |
| | | id = s.getId(); |
| | | } |
| | | return id; |
| | | }).collect(Collectors.toList())); |
| | | }); |
| | | List<String> existIdCbos = thisCbos.stream().filter(s -> { |
| | | String id = s.getId(); |
| | | if (StringUtils.isBlank(id)) { |
| | | id = s.getAttributeValue("id"); |
| | | } |
| | | return existIds.contains(id); |
| | | }).map(s -> s.getAttributeValue(IMPORT_ROW_INDEX)).collect(Collectors.toList()); |
| | | if (!CollectionUtils.isEmpty(existIdCbos)) { |
| | | thisCbos = thisCbos.stream().filter(s -> { |
| | | String id = s.getId(); |
| | | if (StringUtils.isBlank(id)) { |
| | | id = s.getAttributeValue("id"); |
| | | } |
| | | return !existIdCbos.contains(id); |
| | | }).collect(Collectors.toList()); |
| | | existIdCbos.stream().forEach(rowIndex -> { |
| | | errorMap.put(rowIndex, errorMap.getOrDefault(rowIndex, "") + ";ã" + idFieldName + "ãå¨ç³»ç»ä¸å·²ç»è¢«å ç¨"); |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | 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) { |
| | | isExport=true; |
| | | createRedisDatas(uuid + "-error", templateVO, rowIndexCboMap, dataSet, fieldIndexMap, errorMap, false); |
| | | } |
| | | createWriteExcelData(rowDataList, errorMap, new ArrayList<>(), titleRowData, shetNameMap, templateVO); |
| | | 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(templateVO.getCodeclassifyoid(), templateVO, needSaveCboList, resembleMap, btmtypeid, dataResembleVOS); |
| | | if (resembleMap.size() > 0) { |
| | | if (!CollectionUtils.isEmpty(dataResembleVOS)) { |
| | | bladeRedis.set(uuid + "-resemble-data", dataResembleVOS); |
| | | 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); |
| | | //è·åç¼ç ï¼æ¥è¯¢å¨ç³»ç»ä¸æ¯å¦è¢«å
¶ä»çå¼ç¨äº |
| | | //æé¤é误çï¼å©ä¸æ£ç¡®ç |
| | | 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; |
| | | } |
| | | |
| | | List<String> needRowIndexList = needSaveCboList.stream().filter(s -> errorMap.containsKey(s.getAttributeValue(IMPORT_ROW_INDEX))).map(s -> s.getAttributeValue(IMPORT_ROW_INDEX)).collect(Collectors.toList()); |
| | | if (isExport||newErrorMap.size() > 0) { |
| | | createRedisDatas(uuid + "-ok", templateVO, rowIndexCboMap, dataSet, fieldIndexMap, newErrorMap, true); |
| | | } else { |
| | | List<BaseModel> dataCBOIdList=new ArrayList<>(); |
| | | //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | List<ClientBusinessObject> finalNeedSaveCboList = needSaveCboList; |
| | | CodeClassifyTemplateVO finalTemplateVO = templateVO; |
| | | ruleRowIndexMap.keySet().parallelStream().forEach(ruleOid -> { |
| | | //VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | List<String> rowIndexList = ruleRowIndexMap.get(ruleOid); |
| | | List<ClientBusinessObject> thisCbos = finalNeedSaveCboList.stream().filter(cbo -> rowIndexList.contains(cbo.getAttributeValue(IMPORT_ROW_INDEX)) && !errorMap.containsKey(cbo.getAttributeValue(IMPORT_ROW_INDEX))).collect(Collectors.toList()); |
| | | List<BaseModel> dataCBOList=new ArrayList<>(); |
| | | thisCbos.stream().forEach(clientBusinessObject -> { |
| | | BaseModel baseModel=new BaseModel(); |
| | | BeanUtil.convert(clientBusinessObject,baseModel); |
| | | //baseModel.setData(VciBaseUtil.objectToMapString(clientBusinessObject)); |
| | | dataCBOList.add(baseModel); |
| | | dataCBOIdList.add(baseModel); |
| | | }); |
| | | |
| | | if (!CollectionUtils.isEmpty(thisCbos)) { |
| | | try { |
| | | productCodeService.productCodeAndSaveData(classifyFullInfo, finalTemplateVO, ruleVOMap.get(ruleOid), null, dataCBOList); |
| | | } catch (Throwable e) { |
| | | log.error("æ¹é产çç¼ç çæ¶ååºéäº", e); |
| | | thisCbos.stream().forEach(cbo -> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | errorMap.put(rowIndex, errorMap.getOrDefault(rowIndex, "") + ";ç³»ç»é误ï¼å卿°æ®çæ¶ååºéäº"); |
| | | }); |
| | | |
| | | } |
| | | } |
| | | }); |
| | | if (errorMap.size() > 0) { |
| | | isExport = true; |
| | | } |
| | | createWriteExcelData(rowDataList, errorMap, new ArrayList<>(), titleRowData, shetNameMap, finalTemplateVO); |
| | | engineService.batchSaveSelectChar(templateVO, dataCBOIdList); |
| | | } |
| | | } |
| | | String excelFileName=""; |
| | | if(isExport&&!CollectionUtils.isEmpty(shetNameMap)) { |
| | | excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + "é误信æ¯.xls"; |
| | | WriteExcelOption eo = new WriteExcelOption(); |
| | | shetNameMap.forEach((shetName, errorDataList) -> { |
| | | eo.addSheetDataList(shetName, errorDataList); |
| | | }); |
| | | try { |
| | | new File(excelFileName).createNewFile(); |
| | | } catch (IOException e) { |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e)); |
| | | } |
| | | ExcelUtil.writeDataToFile(excelFileName, eo); |
| | | } |
| | | CodeImProtRusultVO codeImProtRusultVO=new CodeImProtRusultVO(); |
| | | if(StringUtils.isNotBlank(excelFileName)) { |
| | | codeImProtRusultVO.setFilePath(excelFileName); |
| | | codeImProtRusultVO.setFileOid(""); |
| | | } |
| | | if(isCreateUUid){ |
| | | codeImProtRusultVO.setRedisUuid(uuid); |
| | | } |
| | | |
| | | return codeImProtRusultVO; |
| | | } |
| | | /*private void converBaseModels(List<ClientBusinessObject> clientBusinessObjects,List<BaseModel>dataCBOList){ |
| | | clientBusinessObjects.stream().forEach(clientBusinessObject -> { |
| | | BaseModel baseModel=new BaseModel(); |
| | | BeanUtil.convert(clientBusinessObject,baseModel); |
| | | Map<String,String> dataMap=new HashMap<>(); |
| | | clientBusinessObject.getHisAttrValList() |
| | | baseModel.setData(VciBaseUtil.objectToMapString(baseModel)); |
| | | |
| | | AttributeValue[] newAttributeValue= clientBusinessObject.getNewAttrValList(); |
| | | dataCBOList.add(baseModel); |
| | | }); |
| | | |
| | | }*/ |
| | | /*** |
| | | * ä»execléæå»ºå¯¹è±¡ |
| | | * @param rowDataList |
| | | * @param errorMap |
| | | * @param needRowIndexList |
| | | * @param titleRowData |
| | | * @param shetNameMap |
| | | * @param templateVO |
| | | */ |
| | | private void createWriteExcelData(Collection<SheetRowData> rowDataList, Map<String,String> errorMap, |
| | | List<String> needRowIndexList, List<String> titleRowData, Map<String,List<WriteExcelData>> shetNameMap, CodeClassifyTemplateVO templateVO){ |
| | | List<WriteExcelData> errorDataList=new ArrayList<>(); |
| | | Map<String, SheetRowData> rowIndexDataMap = rowDataList.stream().filter(s -> !needRowIndexList.contains(s.getRowIndex())).collect(Collectors.toMap(s -> s.getRowIndex(), t -> t)); |
| | | errorDataList.add(new WriteExcelData(0,0,"é误信æ¯")); |
| | | for (int i = 0; i < titleRowData.size(); i++) { |
| | | //é误信æ¯å¨æå |
| | | errorDataList.add(new WriteExcelData(0,i+1,titleRowData.get(i))); |
| | | } |
| | | Integer[] newRowIndex = new Integer[]{1}; |
| | | errorMap.forEach((index,error)->{ |
| | | //é误信æ¯å
¨é¨ç»åå°ä¸èµ· |
| | | SheetRowData rowData = rowIndexDataMap.getOrDefault(index, null); |
| | | if(rowData!=null){ |
| | | errorDataList.add(new WriteExcelData(newRowIndex[0],0,error)); |
| | | rowData.getData().forEach((colIndex,value)->{ |
| | | errorDataList.add(new WriteExcelData(newRowIndex[0],colIndex+1,value)); |
| | | }); |
| | | newRowIndex[0]++; |
| | | } |
| | | }); |
| | | |
| | | shetNameMap.put(templateVO.getName(),errorDataList); |
| | | } |
| | | |
| | | /*** |
| | | * |
| | | * @param currentTemplateVO |
| | | * @param templateColumnVOMap |
| | | */ |
| | | |
| | | private void createTemplate(CodeClassifyTemplateVO currentTemplateVO,Map<String,List<ColumnVO>>templateColumnVOMap){ |
| | | |
| | | List<CodeClassifyTemplateAttrVO> templateAttrVOS = currentTemplateVO.getAttributes().stream().filter(s -> |
| | | !DEFAULT_ATTR_LIST.contains(s.getId()) |
| | | && StringUtils.isBlank(s.getComponentRule()) |
| | | && StringUtils.isBlank(s.getClassifyInvokeAttr()) |
| | | && (VciBaseUtil.getBoolean(s.getFormDisplayFlag())) |
| | | ).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(templateAttrVOS)){ |
| | | throw new VciBaseException("æ¨¡æ¿æ²¡æé
置任ä½ãè¡¨åæ¾ç¤ºãä¸ºãæ¯ãç屿§"); |
| | | } |
| | | List<ColumnVO> columnVOList=new ArrayList<>(); |
| | | |
| | | ColumnVO errorMsgColumnVO=new ColumnVO(); |
| | | errorMsgColumnVO.setTitle("é误信æ¯"); |
| | | errorMsgColumnVO.setField("errorMsg"); |
| | | columnVOList.add(errorMsgColumnVO); |
| | | |
| | | |
| | | |
| | | ColumnVO pathColumnVO=new ColumnVO(); |
| | | pathColumnVO.setTitle("å类路å¾"); |
| | | pathColumnVO.setField("codeclsfid"); |
| | | columnVOList.add(pathColumnVO); |
| | | templateAttrVOS.stream().forEach(codetemplateAttr ->{ |
| | | String field=codetemplateAttr.getId(); |
| | | String name=codetemplateAttr.getName(); |
| | | ColumnVO columnVO=new ColumnVO(); |
| | | columnVO.setTitle(name); |
| | | columnVO.setField(field); |
| | | columnVO.setWidth(codetemplateAttr.getAttrTableWidth()==0?columnVO.getWidth():codetemplateAttr.getAttrTableWidth()); |
| | | columnVOList.add(columnVO); |
| | | }); |
| | | |
| | | templateColumnVOMap.put(currentTemplateVO.getOid(),columnVOList); |
| | | log.info("模æ¿"+currentTemplateVO.getName()+"对åºç屿§"+columnVOList.size()); |
| | | } |
| | | |
| | | /** |
| | | * é误信æ¯è¿åexcel |
| | | * @param rowDataList ææç导å
¥æ°æ® |
| | | * @param errorMap é误çä¿¡æ¯ |
| | | * @param needRowIndexList éè¦åå
¥çæ°æ®çè¡å· |
| | | * @param titleRowData æ é¢è¡ |
| | | * |
| | | * @return é误çexcelæä»¶ï¼æ²¡æé误ä¼è¿å空 |
| | | */ |
| | | private String returnErrorToExcel(Collection<SheetRowData> rowDataList, |
| | | Map<String,String> errorMap, |
| | | List<String> needRowIndexList,List<String> titleRowData){ |
| | | if(CollectionUtils.isEmpty(errorMap)){ |
| | | return ""; |
| | | } |
| | | Map<String, SheetRowData> rowIndexDataMap = rowDataList.stream().filter(s -> !needRowIndexList.contains(s.getRowIndex())).collect(Collectors.toMap(s -> s.getRowIndex(), t -> t)); |
| | | List<WriteExcelData> errorDataList = new ArrayList<>(); |
| | | errorDataList.add(new WriteExcelData(0,0,"é误信æ¯")); |
| | | for (int i = 0; i < titleRowData.size(); i++) { |
| | | //é误信æ¯å¨æå |
| | | errorDataList.add(new WriteExcelData(0,i+1,titleRowData.get(i))); |
| | | } |
| | | Integer[] newRowIndex = new Integer[]{1}; |
| | | errorMap.forEach((index,error)->{ |
| | | //é误信æ¯å
¨é¨ç»åå°ä¸èµ· |
| | | SheetRowData rowData = rowIndexDataMap.getOrDefault(index, null); |
| | | if(rowData!=null){ |
| | | errorDataList.add(new WriteExcelData(newRowIndex[0],0,error)); |
| | | rowData.getData().forEach((colIndex,value)->{ |
| | | errorDataList.add(new WriteExcelData(newRowIndex[0],colIndex+1,value)); |
| | | }); |
| | | newRowIndex[0]++; |
| | | } |
| | | }); |
| | | String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + "é误信æ¯.xls"; |
| | | WriteExcelOption eo = new WriteExcelOption(errorDataList); |
| | | try { |
| | | new File(excelFileName).createNewFile(); |
| | | } catch (IOException e) { |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e)); |
| | | } |
| | | ExcelUtil.writeDataToFile(excelFileName,eo); |
| | | return excelFileName; |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªæ¨¡æ¿æ¯å¦ä¸ºåæ¥ç |
| | | * @param sheetDataSetList exceléçå
容 |
| | | * @param templateVO 模æ¿çä¿¡æ¯ |
| | | */ |
| | | private void checkTemplateSync(List<SheetDataSet> sheetDataSetList,CodeClassifyTemplateVO templateVO,int i){ |
| | | String templateOidInExcel = ""; |
| | | String templateName=""; |
| | | if(!CollectionUtils.isEmpty(sheetDataSetList) |
| | | && sheetDataSetList.size()>1 && !CollectionUtils.isEmpty(sheetDataSetList.get(sheetDataSetList.size()-1).getColName())){ |
| | | List<SheetRowData> rowData= sheetDataSetList.get(sheetDataSetList.size()-1).getRowData(); |
| | | templateName=rowData.get(i).getData().get(2); |
| | | templateOidInExcel=rowData.get(i).getData().get(0); |
| | | //templateOidInExcel = sheetDataSetList.get(sheetDataSetList.size()-1).getColName().get(sheetDataSetList.size()-i); |
| | | } |
| | | /* if(!CollectionUtils.isEmpty(sheetDataSetList) |
| | | && sheetDataSetList.size()>1 && !CollectionUtils.isEmpty(sheetDataSetList.get(sheetDataSetList.size()-1).getColName())){ |
| | | List<SheetRowData> rowData= sheetDataSetList.get(sheetDataSetList.size()-1).getRowData(); |
| | | templateOidInExcel=rowData.get(i).getData().get(0); |
| | | //templateOidInExcel = sheetDataSetList.get(sheetDataSetList.size()-1).getColName().get(sheetDataSetList.size()-i); |
| | | }*/ |
| | | if(StringUtils.isBlank(templateOidInExcel) || !templateOidInExcel.equalsIgnoreCase(templateVO.getOid())){ |
| | | throw new VciBaseException("模æ¿ã"+templateName+"ãä¸çæ°æ®è·åçæ¨¡çä¿¡æ¯ä¸å½å模æ¿ä¸å¹é
ï¼è¯·ç¡®ä¿excelæä»¶éæã模æ¿ä¿¡æ¯-请å¿ç§»å¨æå é¤ãçå·¥ä½è¡¨ï¼ä¸ç¡®ä¿æ¯æ¬¡å¯¼å
¥é½æ¯å
ä¸è½½ç导å
¥æ¨¡æ¿åæ·»å çæ°æ®"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /*** |
| | | * æ¹éå¤çç³è¯·æ°æ® |
| | | * @param orderDTO |
| | | * @param templateVO |
| | | * @param dataSet |
| | | * @return |
| | | */ |
| | | 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()); |
| | | //è§åç主é®éè¦å»è·å |
| | | 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=""; |
| | | |
| | | //è¦æä»¥ä¸çé误ç齿åºåï¼åç»§ç»å¤çæ¶é´åç»åè§å |
| | | needSaveCboList = cboList.stream().filter(cbo -> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | return !newErrorMap.containsKey(rowIndex); |
| | | }).collect(Collectors.toList()); |
| | | |
| | | if (!CollectionUtils.isEmpty(needSaveCboList)) { |
| | | //9.æä»¬å¤çä¸å¡æ°æ® |
| | | //çæç¼ç çå
容 |
| | | 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()); |
| | | }); |
| | | try { |
| | | codeList = productCodeService.productCodeAndSaveData(classifyFullInfo,templateVO,ruleVO, orderDTO.getSecDTOList(),dataCBOList); |
| | | //妿æ¯ç¼ç çæå¤±è´¥ï¼åç´æ¥å°±å¤±è´¥äºï¼å
¶ä»çå¤æåºæ¥æé误çæä»¬é½ç»ä¸è¿åå°exceléé¢ |
| | | engineService.batchSaveSelectChar(templateVO, dataCBOList); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("æ¹äºç³è¯·æ¶å¤±è´¥"); |
| | | } |
| | | } |
| | | } |
| | | if(!isCreateUUid){ |
| | | return uuid=""; |
| | | } |
| | | return uuid; |
| | | } |
| | | |
| | | @Override |
| | | public List<CodeImportTemplateVO> gridclassifys(String redisOid) { |
| | | List<CodeImportTemplateVO> codeImportTemplateVOs=new ArrayList<>(); |
| | | VciBaseUtil.alertNotNull(redisOid,"åç±»",redisOid,"åç±»ç¼å主é®"); |
| | | List<CodeImportTemplateVO> redisServiceCacheObjects=bladeRedis.get(redisOid); |
| | | if(redisServiceCacheObjects!=null){ |
| | | codeImportTemplateVOs= redisServiceCacheObjects; |
| | | } |
| | | return codeImportTemplateVOs; |
| | | } |
| | | |
| | | /*** |
| | | * ä»ç¼åéè·åå°éè¦å¯¼å
¥çç¸å
³æ°æ® |
| | | * @param codeClssifyOid |
| | | * @param redisOid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public DataGrid<Map<String, String>> gridDatas(String codeClssifyOid, String redisOid) { |
| | | VciBaseUtil.alertNotNull(redisOid,"导å
¥ç¸ä¼¼æ°æ®",redisOid,"æ°æ®ç¼å主é®"); |
| | | List<CodeImprotDataVO> codeImprotDataVOs = bladeRedis.get(redisOid+"-"+codeClssifyOid); |
| | | // redisService.getCacheList(redisOid+"-"+codeClssifyOid); |
| | | CodeImprotDataVO codeImprotDataVO=new CodeImprotDataVO(); |
| | | if(!CollectionUtils.isEmpty(codeImprotDataVOs)){ |
| | | if(StringUtils.isNotBlank(codeClssifyOid)){ |
| | | Map<String/**åç±»åç§°**/, CodeImprotDataVO/**è±æåç§°**/> codeClassifyDatasMap = codeImprotDataVOs.stream().collect(Collectors.toMap(s -> s.getCodeClassifyOid(), t -> t,(o1, o2)->o2)); |
| | | if(codeClassifyDatasMap.containsKey(codeClssifyOid)){ |
| | | codeImprotDataVO= codeClassifyDatasMap.get(codeClssifyOid); |
| | | }else{ |
| | | codeImprotDataVO= codeImprotDataVOs.get(0); |
| | | } |
| | | } |
| | | } |
| | | DataGrid<Map<String, String>> dataGrid = new DataGrid<>(); |
| | | List<Map<String, String>> dataList = new ArrayList<>(); |
| | | if(codeImprotDataVO!=null){ |
| | | dataList= codeImprotDataVO.getDatas(); |
| | | } |
| | | dataGrid.setData(dataList); |
| | | if (!CollectionUtils.isEmpty(dataList)) { |
| | | dataGrid.setTotal(dataList.size()); |
| | | } |
| | | return dataGrid; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param oid |
| | | * @param redisOid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public DataGrid<Map<String,String>> gridRowResemble(String oid,String redisOid){ |
| | | VciBaseUtil.alertNotNull(redisOid,"导å
¥ç¸ä¼¼æ°æ®",redisOid,"æ°æ®ç¼å主é®"); |
| | | List<DataResembleVO> codeImprotDataVOs = bladeRedis.get(redisOid);; |
| | | DataGrid<Map<String, String>> dataGrid = new DataGrid<>(); |
| | | List<Map<String, String>> dataList = new ArrayList<>(); |
| | | |
| | | if(!CollectionUtils.isEmpty(codeImprotDataVOs)){ |
| | | Map<String/**åç±»åç§°**/, DataResembleVO/**æ°æ®å¯¹è±¡**/> rowResembleDataMap = codeImprotDataVOs.stream().collect(Collectors.toMap(s -> s.getOid(), t -> t,(o1, o2)->o2)); |
| | | if(rowResembleDataMap.containsKey(oid)){ |
| | | DataResembleVO dataResembleVO= rowResembleDataMap.get(oid); |
| | | dataList= dataResembleVO.getDataList(); |
| | | } |
| | | } |
| | | |
| | | dataGrid.setData(dataList); |
| | | if (!CollectionUtils.isEmpty(dataList)) { |
| | | dataGrid.setTotal(dataList.size()); |
| | | } |
| | | return dataGrid; |
| | | } |
| | | |
| | | /** |
| | | * 导åºä¸»é¢åºçæ°æ® |
| | | * |
| | | * @param exportAttrDTO 导åºç¸å
³çé
ç½®ï¼å¿
é¡»è¦æä¸»é¢åºåç±»çä¸»é® |
| | | * @return 导åºçexcelçæä»¶ |
| | | */ |
| | | @Override |
| | | public String exportCode(CodeExportAttrDTO exportAttrDTO) { |
| | | VciBaseUtil.alertNotNull(exportAttrDTO,"导åºçé
ç½®",exportAttrDTO.getCodeClassifyOid(),"主é¢åºåç±»ç主é®"); |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(exportAttrDTO.getCodeClassifyOid()); |
| | | //è·åææ°çæ¨¡æ¿ |
| | | CodeClassifyTemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(exportAttrDTO.getCodeClassifyOid()); |
| | | //å
æ¥è¯¢æ°æ® |
| | | String btmTypeId = classifyFullInfo.getTopClassifyVO().getBtmTypeId(); |
| | | Map<String, String> conditionMap = exportAttrDTO.getConditionMap(); |
| | | if(conditionMap == null){ |
| | | conditionMap = new HashMap<>(); |
| | | } |
| | | if(conditionMap.containsKey(VciQueryWrapperForDO.OID_FIELD)){ |
| | | conditionMap.put(VciQueryWrapperForDO.OID_FIELD,QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(conditionMap.get(VciQueryWrapperForDO.OID_FIELD)) + ")"); |
| | | } |
| | | PageHelper pageHelper = new PageHelper(exportAttrDTO.getLimit()==null?-1:exportAttrDTO.getLimit()); |
| | | pageHelper.setPage(exportAttrDTO.getPage()==null?1:exportAttrDTO.getPage()); |
| | | pageHelper.setSort(exportAttrDTO.getSort()); |
| | | pageHelper.setOrder(exportAttrDTO.getOrder()); |
| | | |
| | | pageHelper.addDefaultDesc("createTime"); |
| | | conditionMap.put("codeclsfpath","*" + exportAttrDTO.getCodeClassifyOid() + "*"); |
| | | conditionMap.put("lastr", "1"); |
| | | conditionMap.put("lastv", "1"); |
| | | |
| | | String countSql = "select count(*) from " + VciBaseUtil.getTableName(btmTypeId) +" where 1=1" + |
| | | " and lastr = '1'" + |
| | | " and lastv='1'" + |
| | | " and codeclsfpath like '%" + exportAttrDTO.getCodeClassifyOid() + "%'"; |
| | | |
| | | //å
æ¥è¯¢æ»æ° |
| | | int total = 0; |
| | | if(exportAttrDTO.getEndPage()!=null && exportAttrDTO.getEndPage()>0 |
| | | &&exportAttrDTO.getPage() !=null && exportAttrDTO.getPage() >0 |
| | | &&exportAttrDTO.getEndPage()>exportAttrDTO.getPage()){ |
| | | //ä»å¤å°é¡µå°å¤å°é¡µçæ¥è¯¢æ¹å¼ï¼ |
| | | for(int i = exportAttrDTO.getPage() ;i <= exportAttrDTO.getEndPage();i++){ |
| | | PageHelper thisPage = new PageHelper(exportAttrDTO.getLimit()==null?-1:exportAttrDTO.getLimit()); |
| | | thisPage.setPage(exportAttrDTO.getPage()==null?1:exportAttrDTO.getPage()); |
| | | thisPage.setSort(exportAttrDTO.getSort()); |
| | | thisPage.setOrder(exportAttrDTO.getOrder()); |
| | | thisPage.addDefaultDesc("createTime"); |
| | | |
| | | total += commonsMapper.queryCountBySql(countSql); |
| | | } |
| | | }else{ |
| | | |
| | | total = commonsMapper.queryCountBySql(countSql); |
| | | } |
| | | List<String> selectFieldList = new ArrayList<>(); |
| | | if(!CollectionUtils.isEmpty(exportAttrDTO.getAttrIdIndexMap())){ |
| | | selectFieldList = exportAttrDTO.getAttrIdIndexMap().values().stream().map(s->s.toLowerCase(Locale.ROOT)).collect(Collectors.toList()); |
| | | }else{ |
| | | selectFieldList = templateVO.getAttributes().stream().filter(s->VciBaseUtil.getBoolean(s.getFormDisplayFlag()) |
| | | ||VciBaseUtil.getBoolean(s.getTableDisplayFlag())).map(s->s.getId().toLowerCase(Locale.ROOT)).collect(Collectors.toList()); |
| | | } |
| | | //åç
§è®©å¹³å°ç´æ¥æ¥è¯¢å°±è¡ |
| | | List<String> finalSelectFieldList = selectFieldList; |
| | | List<CodeClassifyTemplateAttrVO> referAttrVOs = templateVO.getAttributes().stream().filter( |
| | | s -> StringUtils.isNotBlank(s.getReferBtmId()) |
| | | && |
| | | (finalSelectFieldList.size() ==0 || finalSelectFieldList.contains(s.getId().toLowerCase(Locale.ROOT))) |
| | | ).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(referAttrVOs)){ |
| | | for (int i = 0; i < referAttrVOs.size(); i++) { |
| | | selectFieldList.add(referAttrVOs.get(i).getId() + ".name"); |
| | | } |
| | | } |
| | | List<String> excelNameList = new CopyOnWriteArrayList<>(); |
| | | String tempFolder = LocalFileUtil.getDefaultTempFolder(); |
| | | if(total>EXPORT_LIMIT){ |
| | | //åç»æ¥æ§è¡ |
| | | int queryCount = (total-total%EXPORT_LIMIT)/EXPORT_LIMIT; |
| | | if(total%EXPORT_LIMIT>0){ |
| | | queryCount = queryCount + 1; |
| | | } |
| | | List<Integer> indexList = new ArrayList<>(); |
| | | for (int i = 0; i <queryCount ; i++) { |
| | | indexList.add(i); |
| | | } |
| | | Map<String, String> finalConditionMap = conditionMap; |
| | | //å¹¶è¡æ¥è¯¢çç |
| | | SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo(); |
| | | indexList.stream().forEach(index->{ |
| | | //线ç¨çæ¹å¼ï¼æä»¥éè¦è®¾ç½®å½åç¨æ· |
| | | VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | PageHelper thisPage = new PageHelper(EXPORT_LIMIT); |
| | | thisPage.setPage(index+1); |
| | | thisPage.setSort(exportAttrDTO.getSort()); |
| | | thisPage.setOrder(exportAttrDTO.getOrder()); |
| | | thisPage.addDefaultDesc("createTime"); |
| | | selectDataAndExportExcelName(btmTypeId, finalConditionMap,thisPage,finalSelectFieldList, |
| | | classifyFullInfo,templateVO,exportAttrDTO, |
| | | excelNameList,tempFolder,index); |
| | | }); |
| | | }else{ |
| | | pageHelper.setLimit(total); |
| | | pageHelper.setPage(1); |
| | | selectDataAndExportExcelName(btmTypeId,conditionMap,pageHelper,finalSelectFieldList, |
| | | classifyFullInfo,templateVO,exportAttrDTO, |
| | | excelNameList,tempFolder,1); |
| | | } |
| | | if(excelNameList.size() ==0){ |
| | | throw new VciBaseException("æ²¡ææ°æ®å¯ä»¥è¢«å¯¼åº"); |
| | | } |
| | | if(excelNameList.size() == 1){ |
| | | return excelNameList.get(0); |
| | | } |
| | | //æ¯å¤ä¸ªï¼æä»¬éè¦ææå缩å
|
| | | String zipFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + classifyFullInfo.getCurrentClassifyVO().getId() + "_" + classifyFullInfo.getCurrentClassifyVO().getName() + "_导åº_" + excelNameList.size()+".zip"; |
| | | VciZipUtil zipUtil = new VciZipUtil(); |
| | | File file = new File(tempFolder); |
| | | zipUtil.addFileToZip(file,zipFileName); |
| | | File[] files = file.listFiles(); |
| | | for (int i = 0; i < files.length; i++) { |
| | | LocalFileUtil.deleteTempFile(files[i],false); |
| | | } |
| | | LocalFileUtil.deleteTempFile(file,true); |
| | | return zipFileName; |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢æ°æ®å¹¶å¯¼åºå°excel |
| | | * @param btmTypeId ä¸å¡ç±»å |
| | | * @param conditionMap æ¥è¯¢æ¡ä»¶ |
| | | * @param pageHelper å页 |
| | | * @param selectFieldList æ¥è¯¢çåæ®µ |
| | | * @param classifyFullInfo åç±»çå
¨é¨ä¿¡æ¯ |
| | | * @param templateVO 模æ¿çä¿¡æ¯ |
| | | * @param exportAttrDTO 导åºç屿§ |
| | | * @param excelNameList excelçæä»¶åç§° |
| | | * @param tempFolder ä¸´æ¶æä»¶å¤¹ |
| | | * @param excelIndex excelçé¡ºåº |
| | | */ |
| | | private void selectDataAndExportExcelName(String btmTypeId, Map<String, String> conditionMap, PageHelper pageHelper, List<String> selectFieldList, |
| | | CodeClassifyFullInfoBO classifyFullInfo, CodeClassifyTemplateVO templateVO, CodeExportAttrDTO exportAttrDTO, |
| | | List<String> excelNameList, String tempFolder, |
| | | Integer excelIndex) { |
| | | DataGrid<Map<String, String>> dataGrid = engineService.queryGrid(btmTypeId, templateVO, conditionMap, pageHelper); |
| | | if(dataGrid == null || CollectionUtils.isEmpty(dataGrid.getData())){ |
| | | return; |
| | | } |
| | | //è½¬æ¢æ°æ® |
| | | List<Map<String, String>> dataMap = dataGrid.getData(); |
| | | //å°è£
æ¥è¯¢åºæ¥çæ°æ® |
| | | engineService.wrapperData(dataMap, templateVO, selectFieldList,false); |
| | | //modify by weidy@2022-09-27 |
| | | //å 为å¨å表å表åçæ¾ç¤ºçæ¶åï¼æä»¬çå¼å
³ç±»å页é¢ä¼å¤çï¼ä½æ¯å¨å¯¼åºçæ¶åï¼æä»¬éè¦å°trueåfalse齿¿æ¢æä¸æ |
| | | engineService.wrapperBoolean(dataMap,templateVO); |
| | | Map<String, CodeClassifyTemplateAttrVO> attrVOMap = templateVO.getAttributes().stream().filter(s->selectFieldList.contains(s.getId().toLowerCase(Locale.ROOT))).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | Map<Integer, String> attrIdIndexMap = exportAttrDTO.getAttrIdIndexMap(); |
| | | if (CollectionUtils.isEmpty(attrIdIndexMap)) { |
| | | attrIdIndexMap = templateVO.getAttributes().stream().filter(s->selectFieldList.contains(s.getId().toLowerCase(Locale.ROOT))).collect(Collectors.toMap(s -> s.getOrderNum(), t -> t.getId())); |
| | | } |
| | | List<Integer> indexList = attrIdIndexMap.keySet().stream().sorted().collect(Collectors.toList()); |
| | | |
| | | String excelName = tempFolder + File.separator + |
| | | classifyFullInfo.getCurrentClassifyVO().getId() + "_" + classifyFullInfo.getCurrentClassifyVO().getName() + "_导åº_" + excelIndex + ".xls"; |
| | | try { |
| | | new File(excelName).createNewFile(); |
| | | } catch (Throwable e) { |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelName}, e); |
| | | } |
| | | excelNameList.add(excelName); |
| | | List<WriteExcelData> excelDataList = new ArrayList<>(); |
| | | Workbook workbook = new HSSFWorkbook(); |
| | | for (int i = 0; i < indexList.size(); i++) { |
| | | String attrId = attrIdIndexMap.get(indexList.get(i)).toLowerCase(Locale.ROOT); |
| | | if (attrVOMap.containsKey(attrId)) { |
| | | CodeClassifyTemplateAttrVO attrVO = attrVOMap.get(attrId); |
| | | Object text = attrVO.getName(); |
| | | text = exportKeyAndRequired(workbook,attrVO,text); |
| | | WriteExcelData excelData = new WriteExcelData(0, i, text); |
| | | if(text instanceof RichTextString){ |
| | | excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex())); |
| | | } |
| | | excelDataList.add(excelData); |
| | | } |
| | | } |
| | | final Integer[] rowIndex = {0}; |
| | | Map<Integer, String> finalAttrIdIndexMap = attrIdIndexMap; |
| | | dataMap.stream().forEach(data -> { |
| | | rowIndex[0]++; |
| | | for (int i = 0; i < indexList.size(); i++) { |
| | | Integer index = indexList.get(i); |
| | | String attrId = finalAttrIdIndexMap.get(index).toLowerCase(Locale.ROOT); |
| | | if (attrVOMap.containsKey(attrId)) { |
| | | CodeClassifyTemplateAttrVO attrVO = attrVOMap.get(attrId); |
| | | if (StringUtils.isNotBlank(attrVO.getEnumId()) || StringUtils.isNotBlank(attrVO.getEnumString())) { |
| | | attrId = attrId + "Text"; |
| | | } |
| | | if (StringUtils.isNotBlank(attrVO.getReferBtmId()) || StringUtils.isNotBlank(attrVO.getReferConfig())) { |
| | | attrId = attrId + "name"; |
| | | } |
| | | if(VciQueryWrapperForDO.LC_STATUS_FIELD.equalsIgnoreCase(attrId)){ |
| | | attrId = VciQueryWrapperForDO.LC_STATUS_FIELD_TEXT.toLowerCase(Locale.ROOT); |
| | | } |
| | | excelDataList.add(new WriteExcelData(rowIndex[0], i, data.getOrDefault(attrId, ""))); |
| | | } |
| | | } |
| | | }); |
| | | WriteExcelOption excelOption = new WriteExcelOption(excelDataList); |
| | | ExcelUtil.writeDataToFile(excelName, excelOption); |
| | | } |
| | | |
| | | @Override |
| | | public R batchImportData(List<CodeImprotSaveDatVO> codeImprotSaveDatVOList, String classifyAttr, boolean isImprot) { |
| | | WriteExcelOption eo = new WriteExcelOption(); |
| | | AtomicBoolean success= new AtomicBoolean(true); |
| | | codeImprotSaveDatVOList.stream().forEach(codeImprotSaveDatVO -> { |
| | | List<SheetRowData> rowDataList = new ArrayList<>(); |
| | | List<ClientBusinessObject>cboList=new ArrayList<>(); |
| | | List<String> colList=codeImprotSaveDatVO.getClos(); |
| | | CodeOrderDTO orderDTO= codeImprotSaveDatVO.getOrderDTO(); |
| | | List<Map<String, String>> dataList= codeImprotSaveDatVO.getDataList(); |
| | | Map<Integer, String> fieldIndexMap = new HashMap(); |
| | | for (int i=0;i<dataList.size();i++){ |
| | | SheetRowData sheetRowData=new SheetRowData(); |
| | | Map<String,String> dataMap= dataList.get(i); |
| | | Map<Integer, String> data = new HashMap(); |
| | | final int[] colIndex = {0}; |
| | | Map<Integer, String> finalFieldIndexMap = new HashMap<>(); |
| | | dataMap.forEach((field, value)->{ |
| | | if(!ROW_INDEX.equalsIgnoreCase(field) && !ERROR_MSG.equalsIgnoreCase(field)){ |
| | | data.put(colIndex[0],value); |
| | | finalFieldIndexMap.put(colIndex[0]++,field); |
| | | } |
| | | }); |
| | | fieldIndexMap=finalFieldIndexMap; |
| | | sheetRowData.setData(data); |
| | | sheetRowData.setRowIndex(i+""); |
| | | rowDataList.add(sheetRowData); |
| | | } |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid()); |
| | | log.info("åç±»ï¼"+classifyFullInfo.getCurrentClassifyVO().getName()+"æ°æ®:"+codeImprotSaveDatVO.getDataList().size()); |
| | | |
| | | // CodeClassifyTemplateVO codeClassifyTemplateVO= engineService.getUsedTemplateByClassifyOid(orderDTO.getCodeClassifyOid()); |
| | | CodeClassifyTemplateVO codeClassifyTemplateVO= templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid()); |
| | | //è§åç主é®éè¦å»è·å |
| | | CodeRuleVO ruleVO = engineService.getCodeRuleByClassifyFullInfo(classifyFullInfo); |
| | | //é¤å»é»è®¤ç屿§.è¿æåªæè¡¨åæ¾ç¤ºçåæ®µæå¯¼å
¥ |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = codeClassifyTemplateVO.getAttributes().stream().filter(s -> |
| | | !DEFAULT_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag()) |
| | | ).collect(Collectors.toList()); |
| | | String fullPath = getFullPath(classifyFullInfo); |
| | | excelToCbo(classifyFullInfo,fieldIndexMap,rowDataList, codeClassifyTemplateVO,cboList,fullPath,!isImprot); |
| | | Map<String,String> errorMap=new HashMap<>(); |
| | | Map<String/**è·¯å¾**/, CodeClassifyVO> pathMap=new HashMap<>() ; |
| | | //æ ¡éªç¼ç è§ååç æ®µæ¯å¦æ£ç¡® |
| | | Map<String, List<String>> ruleRowIndexMap = new ConcurrentHashMap<>(); |
| | | Map<String, CodeRuleVO> ruleVOMap =new ConcurrentHashMap<>(); |
| | | if(isImprot) { |
| | | Map<String/**主é®**/, String/**è·¯å¾**/> childOidPathMap = getChildClassifyPathMap(classifyFullInfo, fullPath); |
| | | //é½è½¬æ¢å®äºãéè¦æ¹éæ£æ¥ |
| | | //æ¾ææçå类路å¾,éè¦æ ¡éªè·¯å¾æ¯å¦æ£ç¡®ï¼æ¯å¦é½å¨å½åçåç±»çä¸çº§ |
| | | List<CodeClassifyVO> childClassifyVOs = classifyService.listChildrenClassify(orderDTO.getCodeClassifyOid(), true, classifyAttr, true); |
| | | pathMap = Optional.ofNullable(childClassifyVOs).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getPath().startsWith("#") ? s.getPath().substring(1) : s.getPath(), t -> t)); |
| | | Map<String/**主é®**/, CodeClassifyVO> classifyVOMap = Optional.ofNullable(childClassifyVOs).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | classifyVOMap.put(classifyFullInfo.getCurrentClassifyVO().getOid(), classifyFullInfo.getCurrentClassifyVO()); |
| | | pathMap.put("#current#", classifyFullInfo.getCurrentClassifyVO()); |
| | | //æä»¬éè¦å¤æè¿äºåç±»çæ¨¡æ¿æ¯ä¸æ¯ä¸æ ·çï¼åªéè¦æ ¡éªï¼ä¸ç¨è·å |
| | | //æ£æ¥åç±»çè·¯å¾ |
| | | checkClassifyPathInHistory(cboList, errorMap, pathMap, childOidPathMap); |
| | | //æ£æ¥è§å |
| | | Map<String/**å类主é®**/, String/**è§å主é®**/> ruleOidMap = new ConcurrentHashMap<String, String>(); |
| | | List<String> unExistRuleClassifyOidList = new CopyOnWriteArrayList<>(); |
| | | checkRuleOidInHistory(classifyVOMap, ruleOidMap, unExistRuleClassifyOidList); |
| | | ruleVOMap = ruleService.listCodeRuleByIds(ruleOidMap.values(), true).stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | |
| | | checkSecLengthInHistory(cboList, classifyVOMap, ruleVOMap, ruleOidMap, errorMap, ruleRowIndexMap); |
| | | } |
| | | |
| | | //å类注å
¥ |
| | | batchSwitchClassifyAttrOnOrder(attrVOS,cboList,classifyFullInfo,isImprot); |
| | | //boolean |
| | | reSwitchBooleanAttrOnOrder(attrVOS,cboList); |
| | | //4.æ ¡éªè§å |
| | | batchCheckVerifyOnOrder(attrVOS, cboList,errorMap); |
| | | //5.æ ¡éªæä¸¾æ¯å¦æ£ç¡® |
| | | batchSwitchEnumAttrOnOrder(attrVOS, cboList, errorMap); |
| | | //7.å¤çåç
§çæ
åµ |
| | | batchSwitchReferAttrOnOrder(attrVOS,cboList,errorMap); |
| | | //6.æ¶é´æ ¼å¼çéªè¯ |
| | | //6.æ¶é´çï¼å¿
é¡»ç»ä¸ä¸ºyyyy-MM-dd HH:mm:ss |
| | | batchSwitchDateAttrOnOrder(attrVOS,cboList,errorMap); |
| | | //设置é»è®¤å¼ |
| | | batchSwitchAttrDefault(attrVOS, cboList); |
| | | //æåå¼ç»åè§å |
| | | batchSwitchComponentAttrOnOrder(attrVOS,cboList); |
| | | //3.夿å
³é®å±æ§ |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, codeClassifyTemplateVO, cboList); |
| | | Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList(); |
| | | Set<String> keyAttrRepeatRowIndexList = keyResultVO.getKeyAttrRepeatRowIndexList(); |
| | | if(!CollectionUtils.isEmpty(keyAttrRepeatRowIndexList)){ |
| | | keyAttrRepeatRowIndexList.stream().forEach(rowIndex->{ |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";å
³é®å±æ§ä¸ç³»ç»ä¸çéå¤" ); |
| | | }); |
| | | } |
| | | //4.æ ¡éªè§å |
| | | batchCheckVerifyOnOrder(attrVOS, cboList,errorMap); |
| | | |
| | | if(isImprot){ |
| | | List<ClientBusinessObject> needSaveCboList = cboList.stream().filter(cbo -> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | return !errorMap.containsKey(rowIndex); |
| | | }).collect(Collectors.toList()); |
| | | List<ClientBusinessObject> finalNeedSaveCboList = needSaveCboList; |
| | | Map<String, CodeRuleVO> finalRuleVOMap = ruleVOMap; |
| | | ruleRowIndexMap.keySet().parallelStream().forEach(ruleOid -> { |
| | | List <BaseModel>dataCBOList=new CopyOnWriteArrayList<>(); |
| | | List<String> rowIndexList = ruleRowIndexMap.get(ruleOid); |
| | | List<ClientBusinessObject> thisCbos = needSaveCboList.stream().filter(cbo -> rowIndexList.contains(cbo.getAttributeValue(IMPORT_ROW_INDEX)) && !errorMap.containsKey(cbo.getAttributeValue(IMPORT_ROW_INDEX))).collect(Collectors.toList()); |
| | | if (!CollectionUtils.isEmpty(thisCbos)) { |
| | | thisCbos.stream().forEach(clientBusinessObject -> { |
| | | BaseModel baseModel = new BaseModel(); |
| | | BeanUtil.convert(clientBusinessObject, baseModel); |
| | | dataCBOList.add(baseModel); |
| | | }); |
| | | try { |
| | | productCodeService.productCodeAndSaveData(classifyFullInfo, codeClassifyTemplateVO, finalRuleVOMap.get(ruleOid), null, dataCBOList); |
| | | } catch (Throwable e) { |
| | | //success=false; |
| | | log.error("æ¹é产çç¼ç çæ¶ååºéäº", e); |
| | | thisCbos.stream().forEach(cbo -> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | errorMap.put(rowIndex, errorMap.getOrDefault(rowIndex, "") + ";ç³»ç»é误ï¼å卿°æ®çæ¶ååºéäº:"+e.getMessage()); |
| | | }); |
| | | } |
| | | } |
| | | engineService.batchSaveSelectChar(codeClassifyTemplateVO, dataCBOList); |
| | | }); |
| | | }else { |
| | | List<BaseModel> dataCBOList=new ArrayList<>(); |
| | | List<ClientBusinessObject> needSaveCboList = cboList.stream().filter(cbo -> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | return !errorMap.containsKey(rowIndex); |
| | | }).collect(Collectors.toList()); |
| | | log.info("åç±»ï¼" + classifyFullInfo.getCurrentClassifyVO().getName() + "æ°æ®:" + needSaveCboList.size()); |
| | | if (!CollectionUtils.isEmpty(needSaveCboList)) { |
| | | needSaveCboList.stream().forEach(clientBusinessObject -> { |
| | | BaseModel baseModel = new BaseModel(); |
| | | BeanUtil.convert(clientBusinessObject, baseModel); |
| | | dataCBOList.add(baseModel); |
| | | }); |
| | | try { |
| | | productCodeService.productCodeAndSaveData(classifyFullInfo, codeClassifyTemplateVO, ruleVO, orderDTO.getSecDTOList(), dataCBOList); |
| | | } catch (Exception e) { |
| | | log.error("æ¹é产çç¼ç çæ¶ååºéäº", e); |
| | | needSaveCboList.stream().forEach(cbo -> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | errorMap.put(rowIndex, errorMap.getOrDefault(rowIndex, "") + ";ç³»ç»é误ï¼å卿°æ®çæ¶ååºéäº:"+e.getMessage()); |
| | | }); |
| | | } |
| | | //妿æ¯ç¼ç çæå¤±è´¥ï¼åç´æ¥å°±å¤±è´¥äºï¼å
¶ä»çå¤æåºæ¥æé误çæä»¬é½ç»ä¸è¿åå°exceléé¢ |
| | | engineService.batchSaveSelectChar(codeClassifyTemplateVO, dataCBOList); |
| | | } |
| | | } |
| | | if(errorMap.size()>0) { |
| | | success.set(false); |
| | | LinkedList<WriteExcelData> excelDataList = new LinkedList<>(); |
| | | excelDataList.add(new WriteExcelData(0, 0, "é误信æ¯")); |
| | | final int[] index = {1}; |
| | | errorMap.forEach((key,v)->{ |
| | | excelDataList.add(new WriteExcelData(index[0]++, 0, "第"+(Integer.parseInt(key)+1)+"è¡æ°æ®ï¼"+v)); |
| | | }); |
| | | eo.addSheetDataList(codeClassifyTemplateVO.getName() + "导å
¥æ¨¡æ¿", excelDataList); |
| | | } |
| | | }); |
| | | if(!success.get()){ |
| | | String excelName = LocalFileUtil.getDefaultTempFolder() + File.separator + (isImprot?"æ¹éåå²é误信æ¯.xls":"æ¹éç³è¯·é误信æ¯.xls"); |
| | | ExcelUtil.writeDataToFile(excelName,eo); |
| | | return R.fail(excelName); |
| | | }else { |
| | | return R.success(isImprot ? "æ¹éåå²å¯¼å
¥æå" : "æ¹éç³è¯·æå"); |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | *æ ¹æ®æ°æ®oidä»ç¼åä¸ç§»é¤æ°æ® |
| | | * @param redisOid redisid |
| | | * @param codeClssifyOid åå¨è§åçoid |
| | | * @param dataOids æéå é¤çæ°æ® |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R deleteDatas(String redisOid,String codeClssifyOid,String dataOids) { |
| | | VciBaseUtil.alertNotNull(redisOid, "æ°æ®å é¤", redisOid, "æ°æ®ç¼å主é®"); |
| | | VciBaseUtil.alertNotNull(codeClssifyOid, "æ°æ®å é¤", codeClssifyOid, "ç¼ç è§åç¼å主é®"); |
| | | VciBaseUtil.alertNotNull(dataOids, "æ°æ®å é¤", dataOids, "æéå é¤çæ°æ®ä¸»é®"); |
| | | try { |
| | | List<CodeImprotDataVO> codeImprotDataVOs = bladeRedis.lRange(redisOid + "-" + codeClssifyOid,0,-1); |
| | | List<String> dataOidList = new ArrayList<>(); |
| | | codeImprotDataVOs.stream().forEach(codeImprotDataVO -> { |
| | | List<Map<String, String>> newDataList = new ArrayList<>(); |
| | | List<Map<String, String>> dataList = codeImprotDataVO.getDatas(); |
| | | dataList.stream().forEach(dataMap -> { |
| | | String oid = dataMap.get("oid"); |
| | | if (!dataOidList.contains(oid)) { |
| | | newDataList.add(dataMap); |
| | | } |
| | | |
| | | }); |
| | | codeImprotDataVO.setDatas(newDataList); |
| | | |
| | | }); |
| | | //éæ°ç¼å |
| | | bladeRedis.del(redisOid + "-" + codeClssifyOid); |
| | | bladeRedis.set(redisOid + "-" + codeClssifyOid, codeImprotDataVOs); |
| | | bladeRedis.expire(redisOid + "-" + codeClssifyOid, BATCHADD_REDIS_TIME); |
| | | return R.success("å é¤ç¼åæ°æ®æå"); |
| | | }catch (Throwable e){ |
| | | return R.fail("å é¤ç¼åæ°æ®å¤±è´¥!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * éææ¹éç³è¯·æ°æ® |
| | | * @param orderDTO åç±»çä¸»é® |
| | | * @param dataObjectVO æ°æ®ä¿¡æ¯ |
| | | * @param resultDataObjectDetailDOs éè¯¯ä¿¡æ¯ |
| | | * @return æé误信æ¯çexcel |
| | | */ |
| | | @Override |
| | | public void batchSyncApplyCode(CodeOrderDTO orderDTO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs) { |
| | | Map<String,String> errorMap=new HashMap<>(); |
| | | VciBaseUtil.alertNotNull(orderDTO,"ç¼ç ç³è¯·ç¸å
³çæ°æ®",orderDTO.getCodeClassifyOid(),"主é¢åºå类主é®"); |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid()); |
| | | //è§åç主é®éè¦å»è·å |
| | | CodeRuleVO ruleVO = engineService.getCodeRuleByClassifyFullInfo(classifyFullInfo); |
| | | //1.夿è§åä¸é¤äºæµæ°´ç æ®µï¼æ¯å¦æå
¶ä»ç 段 |
| | | //engineService.checkSecValueOnOrder(ruleVO,orderDTO); |
| | | //æ¥è¯¢åç±»åæ¨¡æ¿ |
| | | //å
æ¾å°æ¯ä¸è¡çæ é¢ï¼ç¶åæ ¹æ®æ 颿¥è·å对åºç屿§ |
| | | List<RowDatas> rowDataList = dataObjectVO.getRowData(); |
| | | Map<String , RowDatas>rowDataMap=new LinkedHashMap<>(); |
| | | rowDataList.stream().forEach(rowData->{ |
| | | rowDataMap.put(rowData.getRowIndex(),rowData); |
| | | }); |
| | | //æ¾ç¬¬ä¸è¡ï¼ä¸ºäºæ¾æ é¢ |
| | | CodeClassifyTemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(orderDTO.getCodeClassifyOid()); |
| | | |
| | | //æ ¡éªæ¨¡æ¿æ¯ä¸æ¯ææ°ç |
| | | //checkTemplateSync(sheetDataSetList,templateVO); |
| | | //é¤å»é»è®¤ç屿§.è¿æåªæè¡¨åæ¾ç¤ºçåæ®µæå¯¼å
¥ |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s ->!DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag()) |
| | | ).collect(Collectors.toList()); |
| | | Map<Integer/**åå·**/,String/**åæ®µçåç§°**/> fieldIndexMap = new HashMap<>(); |
| | | List<String> titleRowData = dataObjectVO.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)) |
| | | && com.alibaba.cloud.commons.lang.StringUtils.isBlank(s.getComponentRule()) && com.alibaba.cloud.commons.lang.StringUtils.isBlank(s.getClassifyInvokeAttr())//ç»åè§ååå类注å
¥ç¡®å®æ²¡ç»ç¨æ·å¯¼åºå» |
| | | ).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(unExistAttrVOs)){ |
| | | throw new VciBaseException("ã" + unExistAttrVOs.stream().map(CodeClassifyTemplateAttrVO::getName) + "ãè¿äºå±æ§å¨excel䏿²¡ææ¾å°"); |
| | | } |
| | | List<ClientBusinessObject> cboList = new ArrayList<>(); |
| | | String fullPath = getFullPath(classifyFullInfo); |
| | | |
| | | // List<CodeClassifyProcessTempVO> codeClassifyProcessTempVOS=codeClassifyProcessTempService.listProcessTemplate(templateVO.getOid(),"code_cls_flow_use_order"); |
| | | boolean isProcess=false; |
| | | //æ³¨éææ¤å¤ä¸é¢ææé½æç
§ä¸å¤ææµç¨åå¨ç¶æäº |
| | | /** if(!CollectionUtils.isEmpty(codeClassifyProcessTempVOS)){ |
| | | isProcess=true; |
| | | }***/ |
| | | Map<String,String> codeOidToSystemOidMap=new HashMap<>();//åå¨ç¼ç æ°æ®åéæç³»ç»æ°æ®oid对ç
§æ å° |
| | | excelToCbo(classifyFullInfo,titleRowData,fieldIndexMap,rowDataList,templateVO,cboList,fullPath,isProcess,"create",errorMap,codeOidToSystemOidMap); |
| | | |
| | | //é½è½¬æ¢å®äºãéè¦æ¹éæ£æ¥ |
| | | //妿åºéäºï¼æä»¬ä¾ç¶æ§è¡ææçæ°æ®ï¼æ æçæ°æ®ååå°excelä¸ |
| | | //2.夿å¿
è¾é¡¹ããéè¦å
¨é¨ç屿§ï¼å¦ææ¯å¿
è¾ï¼ä½æ¯è¡¨åéé¢ä¸æ¾ç¤ºçï¼åªè½æ¯å类注å
¥æè
ç»åè§å |
| | | batchCheckRequiredAttrOnOrder(templateVO,cboList,errorMap); |
| | | |
| | | |
| | | /** |
| | | * å
³é®çæé误æç¤º |
| | | */ |
| | | Map<String,String> errorKeyMap=new HashMap<>(); |
| | | |
| | | |
| | | //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->{ |
| | | /* //ä¼ å
¥æ°æ®ä¹é´å
³é®å±æ§çæ ¡éª |
| | | RowDatas rowData= rowDataMap.get(rowIndex); |
| | | XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | resultDataObjectDetailDO.setCode(""); |
| | | resultDataObjectDetailDO.setId(rowData.getOid()); |
| | | resultDataObjectDetailDO.setErrorid("1"); |
| | | resultDataObjectDetailDO.setMsg(errorMap.getOrDefault(rowIndex,"") + ";å
³é®å±æ§éå¤"); |
| | | resultDataObjectDetailDOs.add(resultDataObjectDetailDO); |
| | | */ |
| | | errorKeyMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";ä¼ å
¥çæ°æ®ä¸å
³é®å±æ§éå¤"); |
| | | }); |
| | | } |
| | | /**** |
| | | * å
³é®å±æ§ä¸ç³»ç»ä¸éå¤ç夿 |
| | | */ |
| | | if(!CollectionUtils.isEmpty(keyAttrRepeatRowIndexList)){ |
| | | keyAttrRepeatRowIndexList.stream().forEach(rowIndex->{ |
| | | //ä¼ å
¥æ°æ®ä¹é´å
³é®å±æ§çæ ¡éª |
| | | /* RowDatas rowData= rowDataMap.get(rowIndex); |
| | | XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | resultDataObjectDetailDO.setCode(""); |
| | | resultDataObjectDetailDO.setId(rowData.getOid()); |
| | | resultDataObjectDetailDO.setErrorid("1"); |
| | | resultDataObjectDetailDO.setMsg(errorMap.getOrDefault(rowIndex,"") + ";å
³é®å±æ§ä¸ç³»ç»ä¸çéå¤" ); |
| | | resultDataObjectDetailDOs.add(resultDataObjectDetailDO); |
| | | */ |
| | | errorKeyMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";å
³é®å±æ§ä¸ç³»ç»ä¸çéå¤" ); |
| | | }); |
| | | } |
| | | //å类注å
¥ |
| | | batchSwitchClassifyAttrOnOrder(attrVOS,cboList,classifyFullInfo,false); |
| | | //boolean |
| | | reSwitchBooleanAttrOnOrder(attrVOS,cboList); |
| | | // cboList.stream().forEach(cbo->{ |
| | | //4.æ ¡éªè§å |
| | | batchCheckVerifyOnOrder(attrVOS, cboList,errorMap); |
| | | //5.æ ¡éªæä¸¾æ¯å¦æ£ç¡® |
| | | batchSwitchEnumAttrOnOrder(attrVOS,cboList,errorMap); |
| | | //6.æ¶é´æ ¼å¼çéªè¯ |
| | | //6.æ¶é´çï¼å¿
é¡»ç»ä¸ä¸ºyyyy-MM-dd HH:mm:ss |
| | | batchSwitchDateAttrOnOrder(attrVOS,cboList,errorMap); |
| | | //7.å¤çåç
§çæ
åµ |
| | | batchSwitchReferAttrOnOrder(attrVOS,cboList,errorMap); |
| | | //æ ¡éªå±æ§æ¯å¦æ£ç¡®éè¯¯ä¿¡æ¯ |
| | | if(errorMap.size()>0){ |
| | | String[] newMsg = {""}; |
| | | cboList.stream().forEach(cbo -> { |
| | | String rowIndex =cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | if(errorMap.containsKey(rowIndex)){ |
| | | String oid=cbo.getOid(); |
| | | String sourceOid=oid; |
| | | if(codeOidToSystemOidMap.containsKey(oid)){ |
| | | sourceOid=codeOidToSystemOidMap.get(oid); |
| | | } |
| | | String code=""; |
| | | String errorid="103"; |
| | | String mes=errorMap.get(rowIndex); |
| | | XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | resultDataObjectDetailDO.setCode(code); |
| | | resultDataObjectDetailDO.setId(sourceOid); |
| | | resultDataObjectDetailDO.setErrorid(errorid); |
| | | resultDataObjectDetailDO.setMsg(mes); |
| | | resultDataObjectDetailDOs.add(resultDataObjectDetailDO); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | Map<String,String> newKeyMap=new HashedMap(); |
| | | if(errorKeyMap.size()>0 ) { |
| | | errorKeyMap.keySet().forEach(key->{ |
| | | if(!errorMap.containsKey(key)){ |
| | | newKeyMap.put(key,errorKeyMap.get(key)); |
| | | } |
| | | }); |
| | | if(newKeyMap.size()>0) { |
| | | List<BaseModel> editBoList = new ArrayList<>(); |
| | | Map<String, List<BaseModel>> indexTodataMap = keyResultVO.getIndexTODataMap(); |
| | | cboList.stream().forEach(cbo -> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | if (indexTodataMap.containsKey(rowIndex)) { |
| | | String oid = cbo.getOid(); |
| | | String sourceOid = oid; |
| | | String code = ""; |
| | | String errorid = "201"; |
| | | if(codeOidToSystemOidMap.containsKey(oid)){ |
| | | sourceOid=codeOidToSystemOidMap.get(oid); |
| | | } |
| | | List<BaseModel> newCboList = indexTodataMap.get(rowIndex); |
| | | if (!CollectionUtils.isEmpty(newCboList)) { |
| | | BaseModel newCbo= newCboList.get(0); |
| | | String lcstatus =newCbo.getLcStatus(); |
| | | String newOid =newCbo.getOid(); |
| | | Date ts =newCbo.getTs(); |
| | | code=newCbo.getId(); |
| | | String lastmodifier=newCbo.getLastModifier(); |
| | | if (!lcstatus.equals(CodeDefaultLC.RELEASED.getValue())) { |
| | | newCbo.setOid(newOid); |
| | | newCbo.setLastModifier(lastmodifier); |
| | | newCbo.setId(code); |
| | | newCbo.setTs(ts); |
| | | cbo.setLastModifier(cbo.getLastModifier()); |
| | | editBoList.add(newCbo); |
| | | } |
| | | String mes = errorKeyMap.get(rowIndex); |
| | | XMLResultDataObjectDetailDO resultDataObjectDetailDO = new XMLResultDataObjectDetailDO(); |
| | | resultDataObjectDetailDO.setCode(code); |
| | | resultDataObjectDetailDO.setId(sourceOid); |
| | | resultDataObjectDetailDO.setErrorid(errorid); |
| | | resultDataObjectDetailDO.setMsg(mes); |
| | | resultDataObjectDetailDOs.add(resultDataObjectDetailDO); |
| | | } |
| | | } |
| | | }); |
| | | //å
³é®çææ´æ¹ |
| | | if (!CollectionUtils.isEmpty(editBoList)) { |
| | | engineService.updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(),editBoList);//ä¿åæ°æ® |
| | | } |
| | | errorMap.putAll(errorKeyMap); |
| | | } |
| | | } |
| | | |
| | | // }); |
| | | //设置é»è®¤å¼ |
| | | batchSwitchAttrDefault(attrVOS, cboList); |
| | | //æåå¼ç»åè§å |
| | | batchSwitchComponentAttrOnOrder(attrVOS,cboList); |
| | | //è¦æä»¥ä¸çé误ç齿åºåï¼åç»§ç»å¤çæ¶é´åç»åè§å |
| | | List<ClientBusinessObject> needSaveCboList = cboList.stream().filter(cbo -> { |
| | | String rowIndex =cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | return !errorMap.containsKey(rowIndex); |
| | | }).collect(Collectors.toList()); |
| | | List<String> needRowIndexList = new ArrayList<>(); |
| | | if(!CollectionUtils.isEmpty(needSaveCboList)) { |
| | | //9.æä»¬å¤çä¸å¡æ°æ® |
| | | //çæç¼ç çå
容 |
| | | |
| | | List<String>allNeedSaveCboList=new ArrayList<>(); |
| | | List<BaseModel> dataCBOList=new ArrayList<>(); |
| | | needSaveCboList.stream().forEach(clientBusinessObject -> { |
| | | BaseModel baseModel=new BaseModel(); |
| | | BeanUtil.convert(clientBusinessObject,baseModel); |
| | | //(VciBaseUtil.objectToMapString(clientBusinessObject)); |
| | | dataCBOList.add(baseModel); |
| | | allNeedSaveCboList.add(baseModel.getOid()); |
| | | }); |
| | | try { |
| | | productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(), dataCBOList); |
| | | //妿æ¯ç¼ç çæå¤±è´¥ï¼åç´æ¥å°±å¤±è´¥äºï¼å
¶ä»çå¤æåºæ¥æé误çæä»¬é½ç»ä¸è¿åå°exceléé¢ |
| | | engineService.batchSaveSelectChar(templateVO, dataCBOList); |
| | | // if(!isProcess){ |
| | | dataCBOList.stream().forEach(needSaveCbo->{ |
| | | XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | resultDataObjectDetailDO.setCode(needSaveCbo.getId()); |
| | | String oid=needSaveCbo.getOid(); |
| | | String sourceOid=oid; |
| | | if(codeOidToSystemOidMap.containsKey(oid)){ |
| | | sourceOid=codeOidToSystemOidMap.get(oid); |
| | | } |
| | | resultDataObjectDetailDO.setId(sourceOid); |
| | | resultDataObjectDetailDO.setErrorid("0"); |
| | | resultDataObjectDetailDO.setMsg("ç³è¯·ç¼ç æå"); |
| | | resultDataObjectDetailDOs.add(resultDataObjectDetailDO); |
| | | }); |
| | | /* }else{ |
| | | needSaveCboList.stream().forEach(needSaveCbo->{ |
| | | XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | // resultDataObjectDetailDO.setCode(needSaveCbo.getId());//ä¸ç¨è¿åç¼ç |
| | | String oid=needSaveCbo.getOid(); |
| | | String sourceOid=oid; |
| | | if(codeOidToSystemOidMap.containsKey(oid)){ |
| | | sourceOid=codeOidToSystemOidMap.get(oid); |
| | | } |
| | | resultDataObjectDetailDO.setId(sourceOid); |
| | | resultDataObjectDetailDO.setErrorid("204"); |
| | | resultDataObjectDetailDO.setMsg("ç³è¯·ç¼ç æåï¼çå¾
ç¼ç ç³»ç»åå¸ï¼"); |
| | | resultDataObjectDetailDOs.add(resultDataObjectDetailDO); |
| | | }); |
| | | |
| | | }*/ |
| | | }catch (Throwable e){ |
| | | e.printStackTrace(); |
| | | needSaveCboList.stream().forEach(needSaveCbo->{ |
| | | XMLResultDataObjectDetailDO resultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | resultDataObjectDetailDO.setCode(""); |
| | | String oid=needSaveCbo.getOid(); |
| | | String sourceOid=oid; |
| | | if(codeOidToSystemOidMap.containsKey(oid)){ |
| | | sourceOid=codeOidToSystemOidMap.get(oid); |
| | | } |
| | | resultDataObjectDetailDO.setId(sourceOid); |
| | | resultDataObjectDetailDO.setErrorid("1"); |
| | | resultDataObjectDetailDO.setMsg("ä¿ååºç°é®é¢:"+e.getMessage()); |
| | | resultDataObjectDetailDOs.add(resultDataObjectDetailDO); |
| | | }); |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | /*** |
| | | * éææ¹éåæ¥æ´æ°æ¥å£ |
| | | * @param codeClassifyVO; |
| | | * @param dataObjectVO æ°æ®ä¿¡æ¯ |
| | | * @param resultDataObjectDetailDOs éè¯¯ä¿¡æ¯ |
| | | */ |
| | | @Transactional(rollbackFor = VciBaseException.class) |
| | | @Override |
| | | public void batchSyncEditDatas(CodeClassifyVO codeClassifyVO, DataObjectVO dataObjectVO, LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs) { |
| | | String errorid=""; |
| | | String msg=""; |
| | | //æ¥è¯¢åç±»åæ¨¡æ¿ |
| | | //å
æ¾å°æ¯ä¸è¡çæ é¢ï¼ç¶åæ ¹æ®æ 颿¥è·å对åºç屿§ |
| | | List<RowDatas> rowDataList = dataObjectVO.getRowData(); |
| | | Map<String, RowDatas> rowDataMap = new LinkedHashMap<>(); |
| | | Map<String, RowDatas> codeDataMap = new LinkedHashMap<>(); |
| | | rowDataList.stream().forEach(rowData -> { |
| | | rowDataMap.put(rowData.getRowIndex(), rowData); |
| | | codeDataMap.put(rowData.getCode(), rowData); |
| | | }); |
| | | //æ¾ç¬¬ä¸è¡ï¼ä¸ºäºæ¾æ é¢ |
| | | CodeClassifyTemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(codeClassifyVO.getOid()); |
| | | // åºè¯¥é½æ¯ä¸ä¸ªåç±»ä¸çä¸å¡æ°æ®ï¼æ¾ç¬¬ä¸æ¡çå°±è¡ |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyVO.getOid()); |
| | | //æ ¡éªæ¨¡æ¿æ¯ä¸æ¯ææ°ç |
| | | //checkTemplateSync(sheetDataSetList,templateVO); |
| | | //é¤å»é»è®¤ç屿§.è¿æåªæè¡¨åæ¾ç¤ºçåæ®µæå¯¼å
¥ |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag()) |
| | | ).collect(Collectors.toList()); |
| | | Map<Integer/**åå·**/, String/**åæ®µçåç§°**/> fieldIndexMap = new HashMap<>(); |
| | | List<String> titleRowData = dataObjectVO.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); |
| | | Map<String, String> cboOidMap = new HashMap<>(); |
| | | cboOidMap.put("id", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0])) + ")"); |
| | | String tableName =""; |
| | | try { |
| | | R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId()); |
| | | if(!r.isSuccess()) { |
| | | throw new Throwable(r.getMsg()); |
| | | } |
| | | BtmTypeVO btmTypeVO = r.getData(); |
| | | if (btmTypeVO == null) { |
| | | throw new Throwable("æ ¹æ®ä¸å¡ç±»åæªæ¥è¯¢å°ä¸å¡ç±»å对象ï¼"); |
| | | } |
| | | tableName = btmTypeVO.getTableName(); |
| | | if (StringUtils.isBlank(tableName)) { |
| | | throw new Throwable("æ ¹æ®ä¸å¡ç±»åæªæ¥è¯¢å°ä¸å¡ç±»åç¸å
³èç表"); |
| | | } |
| | | }catch (Throwable e){ |
| | | log.error("æ¥è¯¢ä¸å¡å¯¹è±¡è¡¨"+e); |
| | | XMLResultDataObjectDetailDO xmlResultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | xmlResultDataObjectDetailDO.setErrorid("103"); |
| | | xmlResultDataObjectDetailDO.setMsg("æ¥è¯¢ä¸å¡å¯¹è±¡è¡¨"+e); |
| | | xmlResultDataObjectDetailDO.setId(""); |
| | | xmlResultDataObjectDetailDO.setCode(""); |
| | | resultDataObjectDetailDOs.add(xmlResultDataObjectDetailDO); |
| | | return; |
| | | } |
| | | |
| | | StringBuffer sb=new StringBuffer(); |
| | | sb.append(" select * from "); |
| | | sb.append(tableName); |
| | | sb.append(" where 1=1 "); |
| | | sb.append(" id in ("); |
| | | sb.append(VciBaseUtil.toInSql(codeDataMap.keySet().toArray(new String[0]))); |
| | | sb.append(")"); |
| | | List<Map<String,String>> dataMapList=commonsMapper.queryByOnlySqlForMap(sb.toString()); |
| | | List<ClientBusinessObject> cboList= ChangeMapTOClientBusinessObjects(dataMapList); |
| | | Map<String, ClientBusinessObject> codeSystemObjectMap = cboList.stream().filter(systeDataObject -> systeDataObject != null && StringUtils.isNotBlank(systeDataObject.getId())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getId(), t -> t)); |
| | | Map<String, String> errorMap = new HashMap<>(); |
| | | List<CodeOrderDTO> codeOrderDTOList = new ArrayList<>(); |
| | | this.getCodeOrderDTOs(codeClassifyVO, templateVO, codeDataMap, codeSystemObjectMap, codeOrderDTOList, errorMap); |
| | | // List<CodeClassifyProcessTempVO> codeClassifyProcessTempVOS=codeClassifyProcessTempService.listProcessTemplate(templateVO.getOid(),"code_cls_flow_use_order"); |
| | | boolean isProcess=false; |
| | | /** if(!CollectionUtils.isEmpty(codeClassifyProcessTempVOS)){ |
| | | isProcess=true; |
| | | }**/ |
| | | |
| | | Map<String, CodeOrderDTO> orderDTOMap = codeOrderDTOList.stream().filter(orderDTO -> orderDTO != null && StringUtils.isNotBlank(orderDTO.getId())).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getId(), t -> t)); |
| | | List<BaseModel> updateList = new ArrayList<>(); |
| | | List<CodeAllCode> codeAllCodeList = new ArrayList<>(); |
| | | List<String> deleteList = new ArrayList<>(); |
| | | |
| | | CodeClassifyTemplateVO firstTemplateVO = templateService.getObjectHasAttrByOid(orderDTOMap.values().stream().findFirst().get().getTemplateOid()); |
| | | Map<String, ClientBusinessObject> cboMap = cboList.stream().filter(cbo -> cbo != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(s -> s.getId(), t -> t)); |
| | | // boolean finalIsProcess = isProcess; |
| | | orderDTOMap.keySet().stream().forEach(code -> { |
| | | CodeOrderDTO orderDTO = orderDTOMap.get(code); |
| | | ClientBusinessObject cbo = cboMap.get(code); |
| | | String dataStatus=cbo.getLcStatus(); |
| | | RowDatas rowData=codeDataMap.get(code); |
| | | String status=rowData.getStatus(); |
| | | String operation=rowData.getOperation(); |
| | | if (cbo.getTs().compareTo(orderDTO.getTs())==0?true:false) { |
| | | // throw new VciBaseException("æ°æ®ä¸æ¯ææ°çï¼å¯è½ä»äººå·²ç»ä¿®æ¹ï¼è¯·å·æ°ååè¯"); |
| | | errorMap.put(orderDTO.getId(),errorMap.getOrDefault(orderDTO.getId(),"")+";æ°æ®ä¸æ¯ææ°çï¼å¯è½ä»äººå·²ç»ä¿®æ¹ï¼è¯·å·æ°ååè¯"); |
| | | } |
| | | /* if (!CodeDefaultLC.EDITING.getValue().equalsIgnoreCase(cbo.getLcStatus()) && !orderDTO.isEditInProcess()) { |
| | | throw new VciBaseException("æ°æ®ä¸æ¯{0}çç¶æï¼ä¸å
许修æ¹", new String[]{CodeDefaultLC.EDITING.getText()}); |
| | | }*/ |
| | | if(operation.equals("update")) { |
| | | //1. 夿å¿
è¾é¡¹ |
| | | checkRequiredAttrOnOrder(templateVO, orderDTO, errorMap); |
| | | //2.å
注å
¥ï¼åç»åï¼æåæ ¡éª |
| | | switchClassifyLevelOnOrder(templateVO, classifyFullInfo, orderDTO, errorMap); |
| | | //3.å¤çç»åè§åãç»åè§åä¸è½ä½¿ç¨ç¼ç ç屿§ï¼å 为ç¼ç ççæå¯è½æ¯éè¦å±æ§ç |
| | | switchComponentAttrOnOrder(templateVO, orderDTO); |
| | | //4.æ ¡éªè§å |
| | | checkVerifyOnOrder(templateVO, orderDTO, errorMap); |
| | | //5.夿å
³é®å±æ§ |
| | | checkKeyAttrOnOrder(classifyFullInfo, templateVO, orderDTO, errorMap); |
| | | //6.æ ¡éªæä¸¾çå
容æ¯å¦æ£ç¡® |
| | | checkEnumOnOrder(templateVO, orderDTO, errorMap); |
| | | //7.å¤çæ¶é´æ ¼å¼ï¼å¨æ°æ®åºéé¢ä¸è®ºæ¯åç¬¦ä¸²è¿æ¯æ¥ææ ¼å¼ï¼é½ä½¿ç¨ç¸åçæ ¼å¼åå¨ |
| | | switchDateAttrOnOrder(templateVO, orderDTO); |
| | | //é»è®¤çå
容ä¸è½åï¼æä»¥åªéè¦æ·è´èªå®ä¹çç¸å
³å±æ§å³å¯ |
| | | copyValueToCBO(classifyFullInfo, cbo, orderDTO, templateVO, true, errorMap); |
| | | //ä¼ä¸ç åéå¢ç çä¸ä¿®æ¹ |
| | | cbo.setDescription(StringUtils.isBlank(orderDTO.getDescription())?"":orderDTO.getDescription()); |
| | | cbo.setName(orderDTO.getName()); |
| | | try { |
| | | cbo.setAttributeValueWithNoCheck("description", orderDTO.getDescription()); |
| | | cbo.setAttributeValue("name", orderDTO.getName()); |
| | | // if(finalIsProcess){//卿µç¨ä¸ä¸å
è®¸æ´æ¹ |
| | | // errorMap.put(code,errorMap.getOrDefault(code, errorMap.getOrDefault(code,"")+";æ°æ®"+code+"卿µç¨ä¸ï¼ä¸å
è®¸æ´æ¹!")); |
| | | // }else{ |
| | | cbo.setLcStatus(status); |
| | | cbo.setAttributeValue("lcstatus",status); |
| | | // } |
| | | } catch (VciBaseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | List<CodeAllCode>newCodeAllCodeList= codeAllCodeService.selectByWrapper(Wrappers.<CodeAllCode>query().lambda().eq(CodeAllCode::getCreateCodeOid, cbo.getOid())); |
| | | if (!CollectionUtils.isEmpty(newCodeAllCodeList)) { |
| | | CodeAllCode codeCbo = codeAllCodeList.get(0); |
| | | log.info("codeCbos code:" + codeCbo.getId()); |
| | | codeCbo.setLcStatus(status); |
| | | codeAllCodeList.add(codeCbo); |
| | | } |
| | | |
| | | BaseModel baseModel=new BaseModel(); |
| | | BeanUtil.convert(cbo,baseModel); |
| | | //baseModel.setData(VciBaseUtil.objectToMapString(cbo)); |
| | | updateList.add(baseModel); |
| | | }else if(operation.equals("delete")){//妿卿µç¨ä¸ä¸å
许å é¤ï¼ä¸å¨æµç¨ä¸ç¶æä¸ºå叿è
åç¨çæ°æ®ä¸å
许å é¤ï¼å°å
¶æ´æ¹ä¸ºåç¨ï¼å
¶ä»çæ
åµç´æ¥å é¤ |
| | | // if(finalIsProcess){ |
| | | // errorMap.put(code,errorMap.getOrDefault(code, errorMap.getOrDefault(code,"")+";æ°æ®"+code+"卿µç¨ä¸ï¼ä¸å
许å é¤!")); |
| | | //}else { |
| | | try { |
| | | log.info("oid:" + cbo.getOid()); |
| | | List<CodeAllCode>newCodeAllCodeList= codeAllCodeService.selectByWrapper(Wrappers.<CodeAllCode>query().lambda().eq(CodeAllCode::getCreateCodeOid, cbo.getOid())); |
| | | log.info("codeCbos size:" + newCodeAllCodeList.size()); |
| | | if (!CollectionUtils.isEmpty(newCodeAllCodeList)) { |
| | | CodeAllCode codeCbo = codeAllCodeList.get(0); |
| | | log.info("codeCbos code:" + codeCbo.getId()); |
| | | codeCbo.setLcStatus(CodeDefaultLC.TASK_BACK.getValue()); |
| | | codeAllCodeList.add(codeCbo); |
| | | } |
| | | deleteList.add(cbo.getOid()); |
| | | }catch (VciBaseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // } |
| | | }else if(operation.equals("editstatus")){ |
| | | try { |
| | | // if (finalIsProcess) { |
| | | // errorMap.put(code, errorMap.getOrDefault(code, errorMap.getOrDefault(code, "") + ";æ°æ®" + code + "卿µç¨ä¸ï¼ä¸å
è®¸æ´æ¹ç¶æ!")); |
| | | // } else { |
| | | cbo.setLcStatus(status); |
| | | cbo.setAttributeValue("lcstatus", status); |
| | | |
| | | // } |
| | | |
| | | List<CodeAllCode>newCodeAllCodeList= codeAllCodeService.selectByWrapper(Wrappers.<CodeAllCode>query().lambda().eq(CodeAllCode::getCreateCodeOid, cbo.getOid())); |
| | | if (!CollectionUtils.isEmpty(newCodeAllCodeList)) { |
| | | CodeAllCode codeCbo = codeAllCodeList.get(0); |
| | | log.info("codeCbos code:" + codeCbo.getId()); |
| | | codeCbo.setLcStatus(status); |
| | | codeAllCodeList.add(codeCbo); |
| | | } |
| | | |
| | | BaseModel baseModel=new BaseModel(); |
| | | BeanUtil.convert(cbo,baseModel); |
| | | //baseModel.setData(VciBaseUtil.objectToMapString(cbo)); |
| | | updateList.add(baseModel); |
| | | }catch (VciBaseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | /** |
| | | * é误信æ¯è¾åº |
| | | */ |
| | | if(errorMap.size()>0){ |
| | | errorMap.keySet().forEach(code->{ |
| | | if(codeDataMap.containsKey(code)){ |
| | | RowDatas rowDatas= codeDataMap.get(code); |
| | | String dataMsg=errorMap.get(code); |
| | | String oid=rowDatas.getOid(); |
| | | XMLResultDataObjectDetailDO xmlResultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | xmlResultDataObjectDetailDO.setErrorid("103"); |
| | | xmlResultDataObjectDetailDO.setMsg(dataMsg); |
| | | xmlResultDataObjectDetailDO.setId(oid); |
| | | xmlResultDataObjectDetailDO.setCode(code); |
| | | resultDataObjectDetailDOs.add(xmlResultDataObjectDetailDO); |
| | | } |
| | | }); |
| | | }else { |
| | | //å卿°æ® |
| | | try { |
| | | engineService.updateBatchByBaseModel(classifyFullInfo.getTopClassifyVO().getBtmTypeId(),updateList); |
| | | codeAllCodeService.saveBatch(codeAllCodeList); |
| | | if(deleteList.size()>0) { |
| | | commonsMapper.deleteByTaleAndOid(tableName, VciBaseUtil.array2String(deleteList.toArray(new String[]{}))); |
| | | } |
| | | errorid="0"; |
| | | msg="æ´æ°/ç¶ææ´æ¹/å 餿åï¼"; |
| | | }catch (Throwable e){ |
| | | errorid="1"; |
| | | msg="ä¿å失败ï¼"+e; |
| | | }finally { |
| | | String finalMsg = msg; |
| | | String finalErrorid = errorid; |
| | | cboList.stream().forEach(cbo->{ |
| | | String code =cbo.getId(); |
| | | if(codeDataMap.containsKey(code)) { |
| | | RowDatas rowDatas=codeDataMap.get(code); |
| | | String oid=rowDatas.getOid(); |
| | | XMLResultDataObjectDetailDO xmlResultDataObjectDetailDO = new XMLResultDataObjectDetailDO(); |
| | | xmlResultDataObjectDetailDO.setErrorid(finalErrorid); |
| | | xmlResultDataObjectDetailDO.setMsg(finalMsg); |
| | | xmlResultDataObjectDetailDO.setId(oid); |
| | | xmlResultDataObjectDetailDO.setCode(code); |
| | | resultDataObjectDetailDOs.add(xmlResultDataObjectDetailDO); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * æ ¡éªå±æ§æ¯å¦ä¸ºå¿
è¾ |
| | | * |
| | | * @param templateVO 模æ¿çæ¾ç¤ºå¯¹è±¡ï¼éè¦å
嫿¨¡æ¿å±æ§ |
| | | * @param orderDTO ç¼ç ç³è¯·çä¿¡æ¯ |
| | | */ |
| | | private void checkRequiredAttrOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO,Map<String,String> errorMap) { |
| | | Map<String, CodeClassifyTemplateAttrVO> requiredAttrMap = templateVO.getAttributes().stream().filter( |
| | | s -> VciBaseUtil.getBoolean(s.getRequireFlag()) && StringUtils.isBlank(s.getComponentRule()) |
| | | && StringUtils.isBlank(s.getClassifyInvokeAttr())) |
| | | .collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | if (!CollectionUtils.isEmpty(requiredAttrMap)) { |
| | | requiredAttrMap.forEach((attrId, attrVO) -> { |
| | | //åªæä¼ä¸ç¼ç ï¼ç¶æï¼å¤æ³¨ï¼æ¨¡æ¿ä¸»é®ï¼å类主é®è¿å 个æ¯åºå®çï¼å
¶ä½é½æ¯èªè¡é
ç½®ç |
| | | if (StringUtils.isBlank(getValueFromOrderDTO(orderDTO, attrId))) { |
| | | errorMap.put(orderDTO.getId(),errorMap.getOrDefault(orderDTO.getId(),"") + ";屿§ã{"+attrVO.getName()+"}ãå¿
é¡»è¦è¾å
¥(éæ©)å
容" ); |
| | | // throw new VciBaseException("屿§ã{0}ãå¿
é¡»è¦è¾å
¥(éæ©)å
容", new String[]{attrVO.getName()}); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | /** |
| | | * 转æ¢ç»åè§åçå¼ |
| | | * |
| | | * @param templateVO 模æ¿çæ¾ç¤ºå¯¹è±¡ï¼éè¦å
嫿¨¡æ¿å±æ§ |
| | | * @param orderDTO ç¼ç ç³è¯·çä¿¡æ¯ |
| | | */ |
| | | private void switchComponentAttrOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) { |
| | | Map<String, CodeClassifyTemplateAttrVO> compAttrVOMap = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getComponentRule())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | if (!CollectionUtils.isEmpty(compAttrVOMap)) { |
| | | Map<String, String> dataMap = WebUtil.objectToMapString(orderDTO); |
| | | |
| | | Map<String, String> dataLowMap = new HashMap<>(); |
| | | if (!CollectionUtils.isEmpty(dataMap)) { |
| | | dataMap.forEach((key, value) -> { |
| | | dataLowMap.put(key.toLowerCase(Locale.ROOT), value); |
| | | }); |
| | | } |
| | | dataLowMap.putAll(orderDTO.getData()); |
| | | compAttrVOMap.forEach((attrId, attrVO) -> { |
| | | dataLowMap.put(attrId, formulaService.getValueByFormula(dataLowMap, attrVO.getComponentRule())); |
| | | }); |
| | | dataLowMap.forEach((key, value) -> { |
| | | setValueToOrderDTO(orderDTO, key, value); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªæ£åè¡¨è¾¾å¼æ¯å¦æ£ç¡® |
| | | * |
| | | * @param templateVO 模æ¿çä¿¡æ¯ï¼å¿
é¡»å
å«å±æ§çå
容 |
| | | * @param orderDTO ç¼ç ç³è¯·çç¸å
³çä¿¡æ¯ |
| | | */ |
| | | private void checkVerifyOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO,Map<String,String> errorMap) { |
| | | Map<String, CodeClassifyTemplateAttrVO> verifyAttrVOMap = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getVerifyRule())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | if (!CollectionUtils.isEmpty(verifyAttrVOMap)) { |
| | | verifyAttrVOMap.forEach((attrId, attrVO) -> { |
| | | String value = getValueFromOrderDTO(orderDTO, attrId); |
| | | if (StringUtils.isNotBlank(value) && !value.matches(attrVO.getVerifyRule())) { |
| | | errorMap.put(orderDTO.getId(),errorMap.getOrDefault(orderDTO.getId(),"")+";屿§["+attrVO.getName()+"]çå¼ä¸ç¬¦åæ ¡éªè§åçè¦æ±"); |
| | | //æ ¡éªæ£åè¡¨è¾¾å¼ |
| | | // throw new VciBaseException("屿§[{0}]çå¼ä¸ç¬¦åæ ¡éªè§åçè¦æ±", new String[]{attrVO.getName()}); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | /** |
| | | * æ ¡éªå
³é®å±æ§ |
| | | * |
| | | * @param classifyFullInfo åç±»çå
¨é¨ä¿¡æ¯ |
| | | * @param templateVO 模æ¿çå
容ï¼å¿
é¡»å
嫿¨¡æ¿å±æ§ |
| | | * @param orderDTO ç¼ç ç³è¯·çç¸å
³çä¿¡æ¯ |
| | | */ |
| | | private void checkKeyAttrOnOrder(CodeClassifyFullInfoBO classifyFullInfo, CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO,Map<String,String> errorMap) { |
| | | //å
è·åå
³é®å±æ§çè§åï¼ä¹å©ç¨ç»§æ¿çæ¹å¼ |
| | | 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, 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()); |
| | | ketAttrMap.forEach((attrId, attrVO) -> { |
| | | String value = getValueFromOrderDTO(orderDTO, attrId); |
| | | if (value == null) { |
| | | value = ""; |
| | | } |
| | | engineService.wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap); |
| | | }); |
| | | |
| | | //没æéå¶åç±»ï¼ä½æ¯ä¸ä¸ªæ¨¡æ¿åªå¯è½å¨ä¸ä¸ªä¸å¡ç±»åéé¢ï¼æä»¥ç´æ¥æ¥è¯¢è¿ä¸ªä¸å¡ç±»åå³å¯ |
| | | |
| | | if (!CollectionUtils.isEmpty(conditionMap)) { |
| | | final String[] sql = {"select count(*) from " + VciBaseUtil.getTableName(classifyFullInfo.getTopClassifyVO().getBtmTypeId()) + " where 1 = 1 "}; |
| | | conditionMap.forEach((key, value) -> { |
| | | sql[0] += " and " + key + " = " + value; |
| | | }); |
| | | if (StringUtils.isNotBlank(orderDTO.getOid())) { |
| | | //ä¿®æ¹çæ¶åï¼éè¦æé¤èªå·± |
| | | sql[0] += " and oid != '" + orderDTO.getOid() + "'"; |
| | | } else if (StringUtils.isNotBlank(orderDTO.getCopyFromVersion())) { |
| | | sql[0] += " and oid != '" + orderDTO.getCopyFromVersion() + "'"; |
| | | } |
| | | sql[0] += " and lastR = '1' and lastV = '1' "; |
| | | if (commonsMapper.queryCountBySql(sql[0]) > 0) { |
| | | String ruleInfoMsg = keyRuleVO == null ? "" : "æ¥è¯¢è§åï¼å»é¤ç©ºæ ¼--{0},忽ç¥å¤§å°å--{1},忽ç¥å
¨åè§--{2},忽ç¥å
¨é¨ç©ºæ ¼--{3}"; |
| | | String[] objs = new String[]{trim ? "æ¯" : "å¦", ignoreCase ? "æ¯" : "å¦", ignoreWidth ? "æ¯" : "å¦", trimAll ? "æ¯" : "å¦"}; |
| | | String defaultValue=";æ ¹æ®æ¨å¡«åçå
³é®å±æ§çå
容ï¼ç»åå
³é®å±æ§æ¥è¯¢è§åï¼åç°è¿ä¸ªæ°æ®å·²ç»å¨ç³»ç»ä¸åå¨äºã请修æ£!ã"; |
| | | String errormsg=defaultValue+ MessageFormat.format(ruleInfoMsg, objs); |
| | | errorMap.put(orderDTO.getId(),errorMap.getOrDefault(orderDTO.getId(),"")+errormsg); |
| | | // throw new VciBaseException("æ ¹æ®æ¨å¡«åçå
³é®å±æ§çå
容ï¼ç»åå
³é®å±æ§æ¥è¯¢è§åï¼åç°è¿ä¸ªæ°æ®å·²ç»å¨ç³»ç»ä¸åå¨äºã请修æ£!ã" + ruleInfoMsg, objs); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * æ ¡éªæä¸¾çå
容 |
| | | * |
| | | * @param templateVO 模æ¿çæ¾ç¤ºå¯¹è±¡ï¼éè¦å
å«å±æ§ |
| | | * @param orderDTO ç¼ç ç³è¯·çä¿¡æ¯ |
| | | */ |
| | | private void checkEnumOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO,Map<String,String> errorMap) { |
| | | //妿æä¸¾å¯ä»¥ä¿®æ¹ï¼åä¸éè¦æ ¡éªæ¯å¦ç¬¦åæä¸¾çé项 |
| | | Map<String, CodeClassifyTemplateAttrVO> enumAttrVOMap = templateVO.getAttributes().stream().filter(s -> (StringUtils.isNotBlank(s.getEnumString()) || StringUtils.isNotBlank(s.getEnumId())) && !VciBaseUtil.getBoolean(s.getEnumEditFlag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | if (!CollectionUtils.isEmpty(enumAttrVOMap)) { |
| | | enumAttrVOMap.forEach((attrId, attrVO) -> { |
| | | String value = getValueFromOrderDTO(orderDTO, attrId); |
| | | if (StringUtils.isNotBlank(value)) { |
| | | //æå¼æè½æ ¡éª |
| | | List<KeyValue> comboboxKVs = this.engineService.listComboboxItems(attrVO); |
| | | if (!comboboxKVs.stream().anyMatch(s -> value.equalsIgnoreCase(s.getKey()))) { |
| | | errorMap.put(orderDTO.getId(),errorMap.getOrDefault(orderDTO.getId(),"")+";屿§ã"+attrVO.getName()+"ãçå¼ä¸ç¬¦åæä¸¾çè¦æ±"); |
| | | //throw new VciBaseException("屿§ã{0}ãçå¼ä¸ç¬¦åæä¸¾çè¦æ±", new String[]{attrVO.getName()}); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | /** |
| | | * è½¬æ¢æ¶é´çæ ¼å¼ |
| | | * |
| | | * @param templateVO 模æ¿çæ¾ç¤ºå¯¹è±¡ï¼éè¦å
å«å±æ§ |
| | | * @param orderDTO ç¼ç ç³è¯·çä¿¡æ¯ |
| | | */ |
| | | private void switchDateAttrOnOrder(CodeClassifyTemplateVO templateVO, CodeOrderDTO orderDTO) { |
| | | Map<String, CodeClassifyTemplateAttrVO> dateAttrVOMap = templateVO.getAttributes().stream().filter(s -> StringUtils.isNotBlank(s.getCodeDateFormat())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | if (!CollectionUtils.isEmpty(dateAttrVOMap)) { |
| | | dateAttrVOMap.forEach((attrId, attrVO) -> { |
| | | String value = getValueFromOrderDTO(orderDTO, attrId); |
| | | if (StringUtils.isNotBlank(value)) { |
| | | DateConverter dateConverter = new DateConverter(); |
| | | dateConverter.setAsText(value); |
| | | value = VciDateUtil.date2Str(dateConverter.getValue(), VciDateUtil.DateTimeMillFormat); |
| | | setValueToOrderDTO(orderDTO, attrId, value); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ·è´æ°æ®å°cboå¯¹è±¡ä¸ |
| | | * |
| | | * @param classifyFullInfo åç±»çå
¨é¨ä¿¡æ¯ |
| | | * @param cbo ä¸å¡æ°æ® |
| | | * @param orderDTO ç¼ç ç³è¯·çä¿¡æ¯ |
| | | * @param templateVO 模æ¿çæ¾ç¤ºå¯¹è±¡ |
| | | * @param edit æ¯å¦ä¸ºä¿®æ¹ |
| | | */ |
| | | private void copyValueToCBO(CodeClassifyFullInfoBO classifyFullInfo, ClientBusinessObject cbo, |
| | | CodeOrderDTO orderDTO, CodeClassifyTemplateVO templateVO, |
| | | boolean edit,Map<String,String> errorMap) { |
| | | String fullPath = ""; |
| | | if (!CollectionUtils.isEmpty(classifyFullInfo.getParentClassifyVOs())) { |
| | | fullPath = classifyFullInfo.getParentClassifyVOs().stream().sorted(((o1, o2) -> o2.getDataLevel().compareTo(o1.getDataLevel()))) |
| | | .map(CodeClassifyVO::getOid).collect(Collectors.joining("##")); |
| | | } else { |
| | | fullPath = classifyFullInfo.getCurrentClassifyVO().getOid(); |
| | | } |
| | | orderDTO.getData().forEach((key, value) -> { |
| | | if (!edit || (!engineService.checkUnAttrUnEdit(key) && |
| | | !VciQueryWrapperForDO.LC_STATUS_FIELD.equalsIgnoreCase(key))) { |
| | | try { |
| | | cbo.setAttributeValue(key, value); |
| | | } catch (VciBaseException e) { |
| | | log.error("è®¾ç½®å±æ§çå¼é误", e); |
| | | } |
| | | } |
| | | }); |
| | | try { |
| | | cbo.setAttributeValue(CODE_CLASSIFY_OID_FIELD, classifyFullInfo.getCurrentClassifyVO().getOid()); |
| | | cbo.setAttributeValue(CODE_TEMPLATE_OID_FIELD, templateVO.getOid()); |
| | | cbo.setAttributeValue(CODE_FULL_PATH_FILED, fullPath); |
| | | if (!edit && StringUtils.isBlank(orderDTO.getLcStatus())) { |
| | | //æ¾çå½å¨æçèµ·å§ç¶æï¼ |
| | | if (StringUtils.isNotBlank(cbo.getLctid())) { |
| | | //OsLifeCycleVO lifeCycleVO = lifeCycleService.getLifeCycleById(cbo.getLctid()); |
| | | // if (lifeCycleVO != null) { |
| | | // cbo.setLcStatus(lifeCycleVO.getStartStatus()); |
| | | // } else { |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | // } |
| | | } else { |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | } |
| | | |
| | | } |
| | | int secret = VciBaseUtil.getInt(cbo.getAttributeValue(SECRET_FIELD)); |
| | | if (secret == 0 || !secretService.checkDataSecret(secret).getData()) { |
| | | Integer userSecret = VciBaseUtil.getCurrentUserSecret(); |
| | | cbo.setAttributeValue(SECRET_FIELD, String.valueOf((userSecret == null || userSecret == 0) ? UserSecretEnum.NONE.getValue() : userSecret)); |
| | | } |
| | | } catch (Throwable e) { |
| | | log.error("设置é»è®¤ç屿§çå¼é误", e); |
| | | } |
| | | } |
| | | /** |
| | | * 设置æ°çå¼å°ç³è¯·å¯¹è±¡ä¸ |
| | | * |
| | | * @param orderDTO ç¼ç ç³è¯·å¯¹è±¡ |
| | | * @param attrId 屿§çç¼å· |
| | | * @param value å¼ |
| | | */ |
| | | private void setValueToOrderDTO(CodeOrderDTO orderDTO, String attrId, String value) { |
| | | attrId = attrId.toLowerCase(Locale.ROOT); |
| | | if (VciQueryWrapperForDO.BASIC_FIELD_MAP.containsKey(attrId)) { |
| | | WebUtil.setValueToField(WebUtil.getFieldForObject(attrId, orderDTO.getClass()).getName(), orderDTO, value); |
| | | } else { |
| | | orderDTO.getData().put(attrId, value); |
| | | } |
| | | } |
| | | /** |
| | | * ä»ç¼ç ç³è¯·ä¿¡æ¯å¯¹è±¡ä¸è·åæä¸ªå±æ§çå¼ |
| | | * |
| | | * @param orderDTO ç¼ç ç³è¯·å¯¹è±¡ |
| | | * @param attrId 屿§çç¼å· |
| | | * @return å¼ |
| | | */ |
| | | private String getValueFromOrderDTO(CodeOrderDTO orderDTO, String attrId) { |
| | | attrId = attrId.toLowerCase(Locale.ROOT); |
| | | String value = null; |
| | | if (VciQueryWrapperForDO.BASIC_FIELD_MAP.containsKey(attrId)) { |
| | | value = WebUtil.getStringValueFromObject(WebUtil.getValueFromField(WebUtil.getFieldForObject(attrId, orderDTO.getClass()).getName(), orderDTO)); |
| | | } else { |
| | | //è¯´ææ¯èªè¡é
ç½®ç |
| | | //å端å¿
é¡»è¦ä¼ éå°åç屿§ |
| | | value = orderDTO.getData().getOrDefault(attrId, ""); |
| | | } |
| | | return value; |
| | | } |
| | | /** |
| | | * å¤çå类注å
¥çä¿¡æ¯ |
| | | * |
| | | * @param templateVO 模æ¿çæ¾ç¤ºå¯¹è±¡ï¼å¿
é¡»è¦å模æ¿ç屿§ |
| | | * @param classifyFullInfoBO åç±»çå
¨è·¯å¾ |
| | | * @param orderDTO ç¼ç ç³è¯·çä¿¡æ¯ |
| | | */ |
| | | private void switchClassifyLevelOnOrder(CodeClassifyTemplateVO templateVO, CodeClassifyFullInfoBO classifyFullInfoBO, CodeOrderDTO orderDTO,Map<String,String> errorMap) { |
| | | Map<String, CodeClassifyTemplateAttrVO> classifyAttrVOMap = templateVO.getAttributes().stream().filter( |
| | | s -> StringUtils.isNotBlank(s.getClassifyInvokeAttr()) && StringUtils.isNotBlank(s.getClassifyInvokeLevel()) |
| | | ).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | if (classifyFullInfoBO.getTopClassifyVO() == null) { |
| | | //éè¦éæ°æ¥è¯¢ä¸ä¸ï¼å 为è¿ä¸ªæ¯æå®çåç±»è¿æ¥ç |
| | | |
| | | } |
| | | if (!CollectionUtils.isEmpty(classifyAttrVOMap)) { |
| | | classifyAttrVOMap.forEach((attrId, attrVO) -> { |
| | | //å类注å
¥çç¼å·æè
åç§°ï¼ |
| | | //å±çº§å
嫿å®å±åæå°å± |
| | | CodeClassifyVO classifyVO = null; |
| | | if (!CodeLevelTypeEnum.MIN.getValue().equalsIgnoreCase(attrVO.getClassifyInvokeLevel()) && !"min".equalsIgnoreCase(attrVO.getClassifyInvokeLevel())) { |
| | | //æå®äºå±çº§ç |
| | | //注æï¼å 为æ¥è¯¢ä¸çº§åç±»åºæ¥çå±çº§æ¯ååºçï¼å³é¡¶å±èç¹æ¯æå¤§çå¼ |
| | | List<CodeClassifyVO> classifyVOS = classifyFullInfoBO.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 = classifyFullInfoBO.getCurrentClassifyVO(); |
| | | } |
| | | if (classifyVO == null) { |
| | | //说æå±çº§æè¯¯ |
| | | errorMap.put(orderDTO.getId(),errorMap.getOrDefault(orderDTO.getId(),"")+";åç±»æ 䏿²¡æå±çº§[" + attrVO.getClassifyInvokeLevel() + "]"); |
| | | //orderDTO.getData().put(attrId, "åç±»æ 䏿²¡æå±çº§[" + attrVO.getClassifyinvokelevel() + "]"); |
| | | // classifyVO = classifyFullInfoBO.getCurrentClassifyVO(); |
| | | } else { |
| | | Map<String, String> classifyDataMap = VciBaseUtil.objectToMapString(classifyVO); |
| | | String value = classifyDataMap.getOrDefault(attrVO.getClassifyInvokeAttr(), ""); |
| | | orderDTO.getData().put(attrId, value); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | /*** |
| | | * |
| | | * @param codeClassifyVO |
| | | * @param templateVO |
| | | * @param codeDataMap |
| | | * @param codeSystemObjectMap |
| | | * @param codeOrderDTOList |
| | | * @param errorMap |
| | | * @return |
| | | */ |
| | | private void getCodeOrderDTOs(CodeClassifyVO codeClassifyVO,CodeClassifyTemplateVO templateVO,Map<String ,RowDatas>codeDataMap,Map<String, ClientBusinessObject> codeSystemObjectMap,List<CodeOrderDTO> codeOrderDTOList,Map<String,String> errorMap){ |
| | | codeDataMap.keySet().forEach(code->{ |
| | | RowDatas rowDatas=codeDataMap.get(code); |
| | | Map<String, String> data= rowDatas.getFiledValue(); |
| | | CodeOrderDTO orderDTO = new CodeOrderDTO(); |
| | | if(codeSystemObjectMap.containsKey(code)){ |
| | | ClientBusinessObject sysDataObject= codeSystemObjectMap.get(code); |
| | | orderDTO.setCodeClassifyOid(codeClassifyVO.getOid());//åç±»ä¸»é® |
| | | orderDTO.setOid(sysDataObject.getOid());//æ°æ®oid |
| | | orderDTO.setLcStatus(rowDatas.getStatus());//ç¶æ |
| | | orderDTO.setId(code); |
| | | orderDTO.setTs(sysDataObject.getTs()); |
| | | orderDTO.setBtmname(codeClassifyVO.getBtmname());//ä¸å¡ç±»å |
| | | orderDTO.setDescription("éæè°ç¨:æ´æ°");//æ°æ®æè¿° |
| | | if(data.containsKey("name")){ |
| | | String name=data.get("name"); |
| | | orderDTO.setName(name);//åç§°å±æ§å¼ |
| | | } |
| | | orderDTO.setData(data);//è®¾ç½®æ°æ® |
| | | orderDTO.setSecDTOList(null);//åç±»ç æ®µ |
| | | orderDTO.setEditInProcess(false);//æ¯å¦å¨æµç¨ä¸ |
| | | orderDTO.setTemplateOid(templateVO.getOid()); |
| | | }else{ |
| | | errorMap.put("code","ç¼ç 为ï¼ã"+code+"ãçæ°æ®å¨ç³»ç»ä¸ä¸åå¨"); |
| | | } |
| | | codeOrderDTOList.add(orderDTO); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * è·ååç±»çå
¨è·¯å¾ |
| | | * @param classifyFullInfo åç±»çå
¨é¨ä¿¡æ¯ |
| | | * @return å
¨è·¯å¾ |
| | | */ |
| | | private String getFullPath(CodeClassifyFullInfoBO classifyFullInfo){ |
| | | String fullPath = ""; |
| | | if(!CollectionUtils.isEmpty(classifyFullInfo.getParentClassifyVOs())){ |
| | | fullPath = classifyFullInfo.getParentClassifyVOs().stream().sorted(((o1, o2) -> o1.getDataLevel().compareTo(o2.getDataLevel()))) |
| | | .map(CodeClassifyVO::getOid).collect(Collectors.joining("##")); |
| | | }else{ |
| | | fullPath = classifyFullInfo.getCurrentClassifyVO().getOid(); |
| | | } |
| | | return fullPath; |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥ç 段çé¿åº¦æ¯å¦ç¬¦åè¦æ± |
| | | * @param cboList æ°æ® |
| | | * @param classifyVOMap åç±»æ å° |
| | | * @param ruleVOMap è§å对象 |
| | | * @param ruleOidMap åç±»å
å«è§å |
| | | * @param errorMap é误çä¿¡æ¯ |
| | | * @param ruleRowIndexMap è§åå
å«çè¡å·ï¼keyæ¯è§å主é®ï¼valueæ¯å
å«çå
¨é¨è¡å· |
| | | */ |
| | | private void checkSecLengthInHistory(List<ClientBusinessObject> cboList,Map<String,CodeClassifyVO> classifyVOMap,Map<String,CodeRuleVO> ruleVOMap, |
| | | Map<String/**å类主é®**/,String/**è§å主é®**/> ruleOidMap,Map<String,String> errorMap,Map<String,List<String>> ruleRowIndexMap){ |
| | | |
| | | cboList.stream().forEach(cbo-> { |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | String secLength = cbo.getAttributeValue(CODE_SEC_LENGTH_FIELD); |
| | | //æ¾åç±» |
| | | String classifyOid = cbo.getAttributeValue(CODE_CLASSIFY_OID_FIELD); |
| | | CodeClassifyVO classifyVO = classifyVOMap.get(classifyOid); |
| | | if (classifyVO != null) { |
| | | //2#2#4#1è¿æ ·çæ¹å¼ |
| | | CodeRuleVO ruleVO = ruleVOMap.getOrDefault(ruleOidMap.get(classifyVO.getOid()), null); |
| | | if(ruleVO!=null){ |
| | | String[] secValues = secLength.split("#"); |
| | | //æ»é¿åº¦åç¼ç çé¿åº¦ |
| | | String code = cbo.getAttributeValue(CODE_FIELD); |
| | | if(code.length() != Arrays.stream(secValues).mapToInt(s->VciBaseUtil.getInt(s)).sum()){ |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";ç æ®µå®½åº¦ä¸ç³»ç»ä¸çç¼ç è§åä¸å" ); |
| | | }else if(secValues.length != ruleVO.getSecVOList().size()){ |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";ç æ®µå®½åº¦ä¸ç³»ç»ä¸çç¼ç è§åä¸å" ); |
| | | } else { |
| | | //æ¯ä¸ä¸ªé¿åº¦é½ä¸è½è¶
è¿ç 段ç |
| | | boolean fined = false; |
| | | for (int j = 0; j < ruleVO.getSecVOList().size(); j++) { |
| | | CodeBasicSecVO secVO = ruleVO.getSecVOList().get(j); |
| | | String length= secValues[j]; |
| | | if(StringUtils.isNotBlank(secVO.getCodeSecLength())&&VciBaseUtil.getInt(length)>VciBaseUtil.getInt(secVO.getCodeSecLength())){ |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";ç æ®µå®½åº¦ä¸ç³»ç»ä¸çç¼ç è§åä¸å" ); |
| | | fined = true; |
| | | break; |
| | | } |
| | | } |
| | | /**for (int i = 0; i < secValues.length; i++) { |
| | | for (int j = 0; j < ruleVO.getSecVOList().size(); j++) { |
| | | CodeBasicSecVO secVO = ruleVO.getSecVOList().get(j); |
| | | if (VciBaseUtil.getInt(secValues[i]) > VciBaseUtil.getInt(secVO.getCodeSecLength())) { |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";ç æ®µå®½åº¦ä¸ç³»ç»ä¸çç¼ç è§åä¸å" ); |
| | | fined = true; |
| | | break; |
| | | } |
| | | } |
| | | if(fined){ |
| | | break; |
| | | } |
| | | }***/ |
| | | if(!fined){ |
| | | //ææ¶ä¸åæµæ°´çå
容ï¼å 为è°ç¨produceCodeçæ¶åå»å¤ç |
| | | List<String> rowIndexList = ruleRowIndexMap.getOrDefault(ruleVO.getOid(), new ArrayList<>()); |
| | | rowIndexList.add(rowIndex); |
| | | ruleRowIndexMap.put(ruleVO.getOid(),rowIndexList); |
| | | } |
| | | } |
| | | }else{ |
| | | errorMap.put(rowIndex,errorMap.getOrDefault(rowIndex,"") + ";å类没æè®¾ç½®ç¼ç è§å" ); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | /** |
| | | * excel转æ¢ä¸ºcboç对象 |
| | | * @param classifyFullInfo åç±»çå
¨é¨ä¿¡æ¯ |
| | | * @param fieldIndexMap åæ®µçä½ç½® |
| | | * @param rowDataList exceléçè¡æ°æ® |
| | | * @param templateVO 模æ¿çæ¾ç¤ºå¯¹è±¡ |
| | | * @param cboList æ°æ®çå表 |
| | | * @param fullPath å
¨è·¯å¾ |
| | | * @param operation æä½ç±»å |
| | | * @param errorMap é误信æ¯è®°å½ |
| | | */ |
| | | private void excelToCbo(CodeClassifyFullInfoBO classifyFullInfo,List<String> titleRowData,Map<Integer,String> fieldIndexMap,List<RowDatas> rowDataList, |
| | | CodeClassifyTemplateVO templateVO,List<ClientBusinessObject> cboList, |
| | | String fullPath,boolean isProcess,String operation,Map<String,String> errorMap,Map<String,String> codeOidToSystemOidMap){ |
| | | rowDataList.stream().forEach(rowData -> { |
| | | String oid=rowData.getOid(); |
| | | String rowNumber=rowData.getRowIndex(); |
| | | ClientBusinessObject cbo = new ClientBusinessObject(); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(cbo, classifyFullInfo.getTopClassifyVO().getBtmTypeId()); |
| | | rowData.getData().forEach((index,value)->{ |
| | | String field = fieldIndexMap.get(index); |
| | | if(StringUtils.isBlank(field)){ |
| | | errorMap.put(rowNumber,"屿§ï¼ã" +titleRowData.get(index)+ "ãå¨ç³»ç»ä¸ä¸åå¨"); |
| | | } |
| | | try { |
| | | cbo.setAttributeValueWithNoCheck(field,value); |
| | | if(WebUtil.isDefaultField(field)){ |
| | | WebUtil.setValueToField(field, cbo, value); |
| | | } |
| | | } catch (VciBaseException e) { |
| | | log.error("è®¾ç½®å±æ§çå¼é误",e); |
| | | errorMap.put(rowNumber,"屿§ï¼ã" +titleRowData.get(index)+ "ãå¨ç³»ç»ä¸ä¸åå¨"); |
| | | } |
| | | }); |
| | | try { |
| | | cbo.setAttributeValue(IMPORT_ROW_INDEX,rowData.getRowIndex()); |
| | | cbo.setAttributeValue(CODE_TEMPLATE_OID_FIELD,templateVO.getOid()); |
| | | if(operation.equals("create")){ |
| | | log.info("å类对象ï¼"+classifyFullInfo.getCurrentClassifyVO()); |
| | | log.info("codeClassoid:"+classifyFullInfo.getCurrentClassifyVO().getOid()); |
| | | cbo.setAttributeValue(CODE_CLASSIFY_OID_FIELD,classifyFullInfo.getCurrentClassifyVO().getOid()); |
| | | cbo.setAttributeValue(CODE_FULL_PATH_FILED,fullPath); |
| | | int secret = VciBaseUtil.getInt(cbo.getAttributeValue(SECRET_FIELD)); |
| | | if(secret == 0 || !secretService.checkDataSecret(secret).getData() ){ |
| | | Integer userSecret = VciBaseUtil.getCurrentUserSecret(); |
| | | String secretValue= String.valueOf((userSecret==null || userSecret ==0)? UserSecretEnum.NONE.getValue():userSecret); |
| | | cbo.setAttributeValue(SECRET_FIELD,secretValue); |
| | | } |
| | | if(rowData.getStatus().equals(CodeDefaultLC.DISABLE.getValue())){//åç¨ |
| | | cbo.setLcStatus(CodeDefaultLC.DISABLE.getValue()); |
| | | }else if(rowData.getStatus().equals(CodeDefaultLC.EDITING.getValue())){//ç¼è¾ |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | }else if(rowData.getStatus().equals(CodeDefaultLC.AUDITING.getValue())) {//审æ¹ä¸ |
| | | cbo.setLcStatus(CodeDefaultLC.AUDITING.getValue()); |
| | | }else if(rowData.getStatus().equals(CodeDefaultLC.TASK_BACK.getValue())){//åæ¶ |
| | | cbo.setLcStatus(CodeDefaultLC.TASK_BACK.getValue()); |
| | | }else{ |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue());//åå¸ |
| | | } |
| | | /** if(!isProcess){ |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | }else { |
| | | if(rowData.getStatus().equals(CodeDefaultLC.DISABLE.getValue())){//åç¨ |
| | | cbo.setLcStatus(CodeDefaultLC.DISABLE.getValue()); |
| | | }else if(rowData.getStatus().equals(CodeDefaultLC.EDITING.getValue())){//ç¼è¾ |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | }else {//åå¸ |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | } |
| | | }***/ |
| | | cbo.setCreator(rowData.getCreator()); |
| | | cbo.setLastModifier(rowData.getEditor()==null?"":rowData.getEditor()); |
| | | }else if(operation.equals("update")){ |
| | | //æ¤æ¶è¿æ²¡æè½¬æ¢è·¯å¾ |
| | | //cbo.setAttributeValue(CODE_FULL_PATH_FILED, childOidPathMap.getOrDefault(rowData.getData().getOrDefault(CODE_CLASSIFY_OID_FIELD,""),fullPath)); |
| | | if(rowData.getStatus().equals(CodeDefaultLC.DISABLE.getValue())){//åç¨ |
| | | cbo.setLcStatus(CodeDefaultLC.DISABLE.getValue()); |
| | | }else if(rowData.getStatus().equals(CodeDefaultLC.RELEASED.getValue())){//åå¸ |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | }else if(rowData.getStatus().equals(CodeDefaultLC.EDITING.getValue())){//ç¼è¾ |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | }else if(rowData.getStatus().equals(CodeDefaultLC.AUDITING.getValue())) {//审æ¹ä¸ |
| | | cbo.setLcStatus(CodeDefaultLC.AUDITING.getValue()); |
| | | }else if(rowData.getStatus().equals(CodeDefaultLC.TASK_BACK.getValue())){//åæ¶ |
| | | cbo.setLcStatus(CodeDefaultLC.TASK_BACK.getValue()); |
| | | } |
| | | cbo.setLastModifier(rowData.getEditor() == null ? "" : rowData.getEditor());//ä¿®æ¹è
|
| | | }else if(operation.equals("delete")){ |
| | | if(rowData.getStatus().equals(CodeDefaultLC.TASK_BACK.getValue())){//åæ¶ |
| | | cbo.setLcStatus(CodeDefaultLC.TASK_BACK.getValue()); |
| | | }else{ |
| | | cbo.setLcStatus(CodeDefaultLC.DISABLE.getValue());//åç¨ |
| | | } |
| | | } |
| | | |
| | | |
| | | }catch (Throwable e){ |
| | | log.error("设置é»è®¤ç屿§çå¼é误",e); |
| | | if(e instanceof VciBaseException){ |
| | | errorMap.put(rowNumber,"设置é»è®¤ç屿§çå¼é误"+((VciBaseException) e).getMessage()); |
| | | }else{ |
| | | errorMap.put(rowNumber,"设置é»è®¤ç屿§çå¼é误"+e.getMessage()); |
| | | } |
| | | |
| | | }finally { |
| | | codeOidToSystemOidMap.put(cbo.getOid(),oid); |
| | | } |
| | | cbo.setDescription(""); |
| | | cboList.add(cbo); |
| | | }); |
| | | |
| | | } |
| | | /** |
| | | * excel转æ¢ä¸ºcboç对象 |
| | | * @param classifyFullInfo åç±»çå
¨é¨ä¿¡æ¯ |
| | | * @param codeImprotDataVO: å类对åºçæ°æ® |
| | | * @param cboList æ°æ®çå表 |
| | | * @param newCode æ¯å¦ä¸ºæ¹éç³è¯· |
| | | */ |
| | | private void excelToCbo(CodeClassifyFullInfoBO classifyFullInfo,CodeImprotDataVO codeImprotDataVO,List<ClientBusinessObject> cboList, boolean newCode){ |
| | | String fullPath = getFullPath(classifyFullInfo); |
| | | codeImprotDataVO.getDatas().stream().forEach(rowData -> { |
| | | ClientBusinessObject cbo=new ClientBusinessObject(); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(cbo, classifyFullInfo.getTopClassifyVO().getBtmTypeId()); |
| | | rowData.forEach((field,value)->{ |
| | | 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,codeImprotDataVO.getTemplateOid()); |
| | | cbo.setAttributeValue(IMPORT_ROW_INDEX,rowData.get(IMPORT_ROW_INDEX)); |
| | | 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).getData() ){ |
| | | Integer userSecret = VciBaseUtil.getCurrentUserSecret(); |
| | | cbo.setAttributeValue(SECRET_FIELD,String.valueOf((userSecret==null || userSecret ==0)? UserSecretEnum.NONE.getValue():userSecret)); |
| | | } |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | }else{ |
| | | //æ¤æ¶è¿æ²¡æè½¬æ¢è·¯å¾ |
| | | //cbo.setAttributeValue(CODE_FULL_PATH_FILED, childOidPathMap.getOrDefault(rowData.getData().getOrDefault(CODE_CLASSIFY_OID_FIELD,""),fullPath)); |
| | | cbo.setLcStatus(CodeDefaultLC.RELEASED.getValue()); |
| | | } |
| | | rowData.put("oid",cbo.getOid()); |
| | | |
| | | }catch (Throwable e){ |
| | | log.error("设置é»è®¤ç屿§çå¼é误",e); |
| | | } |
| | | cboList.add(cbo); |
| | | }); |
| | | |
| | | } |
| | | /** |
| | | * 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).getData() ){ |
| | | Integer userSecret = VciBaseUtil.getCurrentUserSecret(); |
| | | cbo.setAttributeValue(SECRET_FIELD,String.valueOf((userSecret==null || userSecret ==0)? UserSecretEnum.NONE.getValue():userSecret)); |
| | | } |
| | | cbo.setLcStatus(CodeDefaultLC.EDITING.getValue()); |
| | | }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() + "]æ¶é´æ ¼å¼ä¸æ£ç¡®" ); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ç³»ç»æ¨¡æ¿ä¸é»è®¤å¼è®¾ç½® |
| | | * @param attrVOS 模æ¿å±æ§ |
| | | * @param dataList excelçæ°æ®å
容 |
| | | */ |
| | | private void batchSwitchAttrDefault(Collection<CodeClassifyTemplateAttrVO> attrVOS,List<ClientBusinessObject> dataList) { |
| | | Map<String, CodeClassifyTemplateAttrVO> dateAttrVOMap = attrVOS.stream().filter(s -> StringUtils.isNotBlank(s.getDefaultValue())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t)); |
| | | if(!CollectionUtils.isEmpty(dateAttrVOMap)) { |
| | | dateAttrVOMap.forEach((attrId, attrVO) -> { |
| | | String defaultValue = attrVO.getDefaultValue(); |
| | | dataList.stream().forEach(cbo -> { |
| | | String dataValue= cbo.getAttributeValue(attrId); |
| | | if(StringUtils.isBlank(dataValue)){ |
| | | dataValue=defaultValue; |
| | | } |
| | | try { |
| | | cbo.setAttributeValue(attrId, dataValue); |
| | | }catch (Throwable e){ |
| | | log.error("è®¾ç½®å±æ§çé误",e); |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转移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 templateVO 模æ¿çæ¾ç¤ºå¯¹è±¡ |
| | | * @param cboList æ°æ®çå表 |
| | | * @param errorMap é误çä¿¡æ¯ |
| | | */ |
| | | private void batchCheckIdExistOnOrder(CodeClassifyTemplateVO templateVO,List<ClientBusinessObject> cboList,Map<String ,String> errorMap) throws Throwable{ |
| | | List<String> existIds = new ArrayList<>(); |
| | | String tableName =""; |
| | | try { |
| | | R<BtmTypeVO> r = btmTypeClient.getAllAttributeByBtmId(templateVO.getBtmTypeId()); |
| | | if(!r.isSuccess()) { |
| | | throw new Throwable(r.getMsg()); |
| | | } |
| | | BtmTypeVO btmTypeVO = r.getData(); |
| | | if (btmTypeVO == null) { |
| | | throw new Throwable("æ ¹æ®ä¸å¡ç±»åæªæ¥è¯¢å°ä¸å¡ç±»å对象ï¼"); |
| | | } |
| | | tableName = btmTypeVO.getTableName(); |
| | | if (StringUtils.isBlank(tableName)) { |
| | | throw new Throwable("æ ¹æ®ä¸å¡ç±»åæªæ¥è¯¢å°ä¸å¡ç±»åç¸å
³èç表"); |
| | | } |
| | | }catch (Throwable e){ |
| | | throw e; |
| | | } |
| | | String finalTableName = tableName; |
| | | VciBaseUtil.switchCollectionForOracleIn(cboList).stream().forEach(cbos -> { |
| | | Map<String, String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("id", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(cbos.stream().map(s -> s.getId()).collect(Collectors.toSet()).toArray(new String[0])) + ")"); |
| | | |
| | | StringBuffer sb=new StringBuffer(); |
| | | sb.append(" select id from "); |
| | | sb.append(finalTableName); |
| | | sb.append(" where 1=1 "); |
| | | sb.append(" and id in ("); |
| | | sb.append(VciBaseUtil.toInSql(cbos.stream().map(s -> s.getId()).collect(Collectors.toSet()).toArray(new String[0]))); |
| | | sb.append(")"); |
| | | List<String> idList= commonsMapper.selectById(sb.toString()); |
| | | //ä¸å¡æ°æ®å¦æç å¼åæ¶ä¼ç´æ¥å 餿°æ®ï¼æä»¥è¿éç´æ¥å¤ææ¯å¦åå¨å³å¯ |
| | | existIds.addAll(Optional.ofNullable(idList).orElseGet(() -> new ArrayList<>()).stream().map(s -> s.toLowerCase(Locale.ROOT)).collect(Collectors.toList())); |
| | | }); |
| | | if(!CollectionUtils.isEmpty(existIds)){ |
| | | String idFieldName = templateVO.getAttributes().stream().filter(s -> VciQueryWrapperForDO.ID_FIELD.equalsIgnoreCase(s.getId())).findFirst().orElseGet(() -> new CodeClassifyTemplateAttrVO()).getName(); |
| | | if(StringUtils.isBlank(idFieldName)){ |
| | | idFieldName = "ä¼ä¸ç¼ç "; |
| | | } |
| | | String finalIdFieldName = idFieldName; |
| | | cboList.stream().forEach(cbo->{ |
| | | String id = cbo.getId(); |
| | | if(StringUtils.isBlank(id)){ |
| | | id = cbo.getAttributeValue("id"); |
| | | } |
| | | if(existIds.contains(id)){ |
| | | String rowIndex = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | String msg = errorMap.getOrDefault(rowIndex, ""); |
| | | msg+=";" + finalIdFieldName + "çå¼å¨ç³»ç»ä¸å·²ç»åå¨"; |
| | | errorMap.put(rowIndex,msg); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | /*** |
| | | * æ ¡éªå类对åºç模æ¿ä¿¡æ¯ |
| | | * @param titleRowData |
| | | * @param sheetDataSetList |
| | | * @param shetNumber |
| | | * @param pathMap |
| | | * @param errorMap |
| | | * @return |
| | | * @throws Throwable |
| | | */ |
| | | private LinkedList<CodeClassifyTemplateVO> checkSamesTemplate(List<String> titleRowData, List<SheetDataSet> sheetDataSetList,int shetNumber,Map<String/**è·¯å¾**/, CodeClassifyVO> pathMap,Map<String,String>errorMap) throws Throwable { |
| | | Map<String,String>pathOidMap =new HashMap<>(); |
| | | Map<String,String> templateIdRowIndex=new HashedMap(); |
| | | SheetDataSet dataSet= sheetDataSetList.get(shetNumber); |
| | | LinkedHashMap<String,CodeClassifyTemplateVO> codeClassifyTemplateVOMap=new LinkedHashMap <String,CodeClassifyTemplateVO>(); |
| | | for (int i=0; i<titleRowData.size();i++){ |
| | | String title= titleRowData.get(i); |
| | | if(title.equals("å类路å¾")) { |
| | | int finalI = i; |
| | | dataSet.getRowData().stream().forEach(sheetRowData -> { |
| | | String Path = sheetRowData.getData().get(finalI); |
| | | String rowIndex=sheetRowData.getRowIndex(); |
| | | if(StringUtils.isBlank(Path)){ |
| | | Path= "#current#"; |
| | | } |
| | | CodeClassifyTemplateVO newTemplateVO=new CodeClassifyTemplateVO(); |
| | | String templateOid=""; |
| | | if(pathOidMap.containsKey(Path)){ |
| | | templateOid= pathOidMap.get(Path) ; |
| | | newTemplateVO=codeClassifyTemplateVOMap.get(templateOid); |
| | | }else{ |
| | | if (pathMap.containsKey(Path)) { |
| | | CodeClassifyVO codeClassifyVO = pathMap.get(Path); |
| | | newTemplateVO = engineService.getUsedTemplateByClassifyOid(codeClassifyVO.getOid()); |
| | | if (newTemplateVO != null) { |
| | | templateOid = newTemplateVO.getOid(); |
| | | } else { |
| | | errorMap.put(rowIndex, "第" + rowIndex + "è¡ï¼åç±»è·¯å¾æªæ¥è¯¢å°ç¸åºçå类模æ¿"); |
| | | } |
| | | } else { |
| | | errorMap.put(rowIndex, "第" + rowIndex + "è¡ï¼åç±»è·¯å¾æªæ¥è¯¢å°ç¸åºçåç±»"); |
| | | } |
| | | |
| | | } |
| | | pathOidMap.put(Path, templateOid); |
| | | codeClassifyTemplateVOMap.put(templateOid, newTemplateVO); |
| | | templateIdRowIndex.put(templateOid, templateIdRowIndex.getOrDefault(templateOid, "") + "ï¼" +rowIndex ); |
| | | }); |
| | | break; |
| | | } |
| | | } |
| | | LinkedList<CodeClassifyTemplateVO> codeClassifyTemplateVOList=new LinkedList<>(); |
| | | StringBuffer sb=new StringBuffer(); |
| | | codeClassifyTemplateVOMap.keySet().forEach(tempateOid->{ |
| | | String templateOidInExcel=""; |
| | | String tempateName=""; |
| | | CodeClassifyTemplateVO t= codeClassifyTemplateVOMap.get(tempateOid); |
| | | codeClassifyTemplateVOList.add(t); |
| | | if(!CollectionUtils.isEmpty(sheetDataSetList) |
| | | && sheetDataSetList.size()>1 && !CollectionUtils.isEmpty(sheetDataSetList.get(sheetDataSetList.size()-1).getColName())){ |
| | | List<SheetRowData> rowData= sheetDataSetList.get(sheetDataSetList.size()-1).getRowData(); |
| | | templateOidInExcel=rowData.get(shetNumber).getData().get(0); |
| | | tempateName=rowData.get(shetNumber).getData().get(2); |
| | | //templateOidInExcel = sheetDataSetList.get(sheetDataSetList.size()-1).getColName().get(sheetDataSetList.size()-i); |
| | | } |
| | | if(StringUtils.isBlank(templateOidInExcel) || !templateOidInExcel.equalsIgnoreCase(tempateOid)){ |
| | | sb.append("模æ¿ã"+tempateName+"ãä¸ç¬¬"+templateIdRowIndex.get(tempateOid)+"è¡æ°æ®ä¸å±äºå½å模æ¿çæ°æ®ï¼è¯·æ ¸å¯¹!"); |
| | | } |
| | | }); |
| | | if(StringUtils.isNotBlank(sb.toString())){ |
| | | throw new Throwable(sb.toString()); |
| | | } |
| | | if(codeClassifyTemplateVOList.size()>1){ |
| | | String message="模æ¿ã"+dataSet.getSheetName()+"ãæ ¹æ®å类路å¾å¤æï¼åç±»åå¨å¤ä¸ªæ¨¡æ¿"; |
| | | |
| | | throw new Throwable(message); |
| | | } |
| | | if(codeClassifyTemplateVOList.size()==0){ |
| | | String message="模æ¿ã"+dataSet.getSheetName()+"ãæ ¹æ®æ°æ®å类路å¾å¤æï¼æªå¹é
å°å¯¹åºæ¨¡æ¿"; |
| | | throw new Throwable(message); |
| | | } |
| | | return codeClassifyTemplateVOList ; |
| | | } |
| | | /** |
| | | * ä»å±æ§ä¸è·ååç
§çå
容 |
| | | * @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<BaseModel>> 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); |
| | | List<BaseModel> newCboList=new ArrayList<>(); |
| | | newDataList.stream().forEach(stringStringMap -> { |
| | | BaseModel baseModel=new BaseModel(); |
| | | DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(stringStringMap,baseModel); |
| | | newCboList.add(baseModel); |
| | | }); |
| | | if(!CollectionUtils.isEmpty(newCboList)) { |
| | | 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 cboList ä¸å¡æ°æ® |
| | | * @param errorMap éè¯¯ä¿¡æ¯ |
| | | * @param pathMap è·¯å¾ååç±»çæ å° |
| | | */ |
| | | private void checkClassifyPathInHistory(List<ClientBusinessObject> cboList, |
| | | Map<String,String> errorMap, Map<String/**è·¯å¾**/,CodeClassifyVO> pathMap, |
| | | Map<String/**主é®**/, String/**è·¯å¾**/> childOidPathMap) { |
| | | cboList.parallelStream().forEach(cbo -> { |
| | | String classifyPath = cbo.getAttributeValue(CODE_CLASSIFY_OID_FIELD); |
| | | //妿path为空ï¼å表示æ¯å¯¼å
¥å½ååç±» |
| | | if(StringUtils.isBlank(classifyPath)){ |
| | | classifyPath = "#current#"; |
| | | } |
| | | if ( !pathMap.containsKey(classifyPath)) { |
| | | String row_index = cbo.getAttributeValue(IMPORT_ROW_INDEX); |
| | | errorMap.put(row_index,errorMap.getOrDefault(row_index,"") + ";å类路å¾ä¸åå¨"); |
| | | } else { |
| | | //转ä¸ä¸åç±»çä¸»é® |
| | | try { |
| | | String classifyOid = pathMap.get(classifyPath).getOid(); |
| | | cbo.setAttributeValueWithNoCheck(CODE_CLASSIFY_OID_FIELD, classifyOid); |
| | | cbo.setAttributeValue(CODE_FULL_PATH_FILED, childOidPathMap.getOrDefault(classifyOid,classifyPath)); |
| | | } catch (VciBaseException e) { |
| | | log.error("è®¾ç½®å±æ§çé误", e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥å类以åååç±»æ¯å¦é½æç¼ç è§å |
| | | * @param classifyVOMap åç±»çæ¾ç¤ºå¯¹è±¡æ å° |
| | | * @param ruleOidMap è§åç䏻鮿 å° |
| | | * @param unExistRuleClassifyOidList ä¸åå¨ç¼ç è§åçåç±»çä¸»é® |
| | | */ |
| | | private void checkRuleOidInHistory( Map<String/**主é®**/,CodeClassifyVO> classifyVOMap, Map<String/**å类主é®**/,String/**è§å主é®**/> ruleOidMap, |
| | | List<String> unExistRuleClassifyOidList ){ |
| | | if(!CollectionUtils.isEmpty(classifyVOMap)){ |
| | | classifyVOMap.values().parallelStream().forEach(classifyVO->{ |
| | | if(StringUtils.isNotBlank(classifyVO.getCodeRuleOid())){ |
| | | ruleOidMap.put(classifyVO.getOid(),classifyVO.getCodeRuleOid()); |
| | | }else{ |
| | | //é彿¾ä¸çº§ |
| | | List<String> ruleOidList = new ArrayList<>(); |
| | | recursionRule(classifyVOMap,classifyVO.getParentCodeClassifyOid(),ruleOidList); |
| | | if(!CollectionUtils.isEmpty(ruleOidList)){ |
| | | ruleOidMap.put(classifyVO.getOid(),ruleOidList.get(0)); |
| | | }else{ |
| | | unExistRuleClassifyOidList.add(classifyVO.getOid()); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | log.info(";;;;"); |
| | | } |
| | | /** |
| | | * é彿¾ç¼ç è§å |
| | | * @param classifyVOMap åç±»çæ¾ç¤ºå¯¹è±¡æ å° |
| | | * @param classifyOid åç±»çä¸»é® |
| | | * @param ruleOidList è§åç主é®list |
| | | */ |
| | | private void recursionRule(Map<String, CodeClassifyVO> classifyVOMap,String classifyOid,List<String> ruleOidList){ |
| | | if(classifyVOMap.containsKey(classifyOid)){ |
| | | CodeClassifyVO classifyVO = classifyVOMap.get(classifyOid); |
| | | if(StringUtils.isNotBlank(classifyVO.getCodeRuleOid())){ |
| | | ruleOidList.add(classifyVO.getCodeRuleOid()); |
| | | return; |
| | | }else{ |
| | | recursionRule(classifyVOMap,classifyVO.getParentCodeClassifyOid(),ruleOidList); |
| | | } |
| | | }else{ |
| | | Map<String, CodeClassifyVO> parentClassifyVOMap=new HashMap<>(); |
| | | CodeClassifyVO codeClassifyVO= this.classifyService.getObjectByOid(classifyOid); |
| | | parentClassifyVOMap.put(codeClassifyVO.getOid(),codeClassifyVO); |
| | | recursionRule(parentClassifyVOMap,codeClassifyVO.getOid(),ruleOidList); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åååç±»çè·¯å¾ |
| | | * @param classifyFullInfo åç±»å
¨é¨ä¿¡æ¯ |
| | | * @param fullPath åç±»çå
¨è·¯å¾ |
| | | * @return ååç±»çè·¯å¾ï¼keyæ¯åç±»çä¸»é® |
| | | */ |
| | | private Map<String/**åç±»ç主é®**/,String/**å类路å¾**/> getChildClassifyPathMap(CodeClassifyFullInfoBO classifyFullInfo,String fullPath){ |
| | | List<CodeClassifyVO> childPathVOs = classifyService.listChildrenClassify(classifyFullInfo.getCurrentClassifyVO().getOid(), true, VciQueryWrapperForDO.OID_FIELD, true); |
| | | Map<String/**åç±»ç主é®**/,String/**åç±»ç主é®**/> childOidPathMap = new ConcurrentHashMap<>(); |
| | | if(!CollectionUtils.isEmpty(childPathVOs)){ |
| | | childPathVOs.parallelStream().forEach(childPath->{ |
| | | // String thisClassifyPath = fullPath + "##" + childPath.getPath().replace("#" + classifyFullInfo.getCurrentClassifyVO().getOid() + "#","").replace("#","##"); |
| | | List<String> list=Arrays.asList(childPath.getPath().split("#")); |
| | | List<String> newPahtList= list.stream().sorted(Comparator.comparing(s -> s,Comparator.reverseOrder())).collect(Collectors.toList()); |
| | | String thisClassifyPath=StringUtils.join(newPahtList,"##")+fullPath; |
| | | childOidPathMap.put(childPath.getOid(),thisClassifyPath); |
| | | }); |
| | | } |
| | | return childOidPathMap; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * è·å导å
¥çå
容ä¸å
³é®å±æ§éå¤çè¡å· |
| | | * @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 模æ¿ä¸å±æ§åç§°åè±æçæ å° |
| | | * @param fieldIndexMap ä½ç½®åè±æåæ®µçæ å° |
| | | */ |
| | | private void getFieldIndexMap(List<String> titleRowData,Map<String/**åç§°**/,String/**åæ®µå**/> attrNameIdMap,Map<Integer/**ä½ç½®**/,String/**è±æåå**/> fieldIndexMap){ |
| | | for (int i = 0; i < titleRowData.size(); i++) { |
| | | String title = titleRowData.get(i); |
| | | String id = attrNameIdMap.getOrDefault(title.replace(KEY_ATTR_CHAR,"").replace(REQUIRED_CHAR |
| | | ,""),""); |
| | | if(com.alibaba.cloud.commons.lang.StringUtils.isBlank(id) && "å类路å¾".equalsIgnoreCase(title)){ |
| | | id = CODE_CLASSIFY_OID_FIELD; |
| | | } |
| | | if(com.alibaba.cloud.commons.lang.StringUtils.isBlank(id) && "ç æ®µå®½åº¦".equalsIgnoreCase(title)){ |
| | | id = CODE_SEC_LENGTH_FIELD; |
| | | } |
| | | if(com.alibaba.cloud.commons.lang.StringUtils.isBlank(id) && "ä¼ä¸ç¼ç ".equalsIgnoreCase(title)){ |
| | | id = CODE_FIELD; |
| | | } |
| | | if(com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(id)){ |
| | | fieldIndexMap.put(i,id); |
| | | } |
| | | } |
| | | } |
| | | private List<ClientBusinessObject> ChangeMapTOClientBusinessObjects(List<Map<String,String>> oldDataMap){ |
| | | List<ClientBusinessObject> clientBusinessObjectList=new ArrayList<>(); |
| | | oldDataMap.stream().forEach(dataMap->{ |
| | | ClientBusinessObject clientBusinessObject=new ClientBusinessObject(); |
| | | DefaultAttrAssimtUtil.copplyDefaultAttrAssimt(dataMap,clientBusinessObject); |
| | | for (String key:dataMap.keySet()){ |
| | | Object value= dataMap.getOrDefault(key,""); |
| | | clientBusinessObject.setAttributeValue(key,value.toString()); |
| | | } |
| | | clientBusinessObjectList.add(clientBusinessObject); |
| | | }); |
| | | return clientBusinessObjectList; |
| | | } |
| | | |
| | | /*** |
| | | * æ ¹æ®ä¸å模æ¿ç»ç»execlæ°æ® |
| | | * @param dataSet |
| | | * @param pathMap |
| | | * @param errorMap |
| | | */ |
| | | private void createExeclClassData(SheetDataSet dataSet,Map<String/**è·¯å¾**/, CodeClassifyVO> pathMap,Map<String,String>errorMap,List<CodeImprotDataVO> codeClassifyDatas){ |
| | | |
| | | Map<String,CodeImprotDataVO> pathDatas=new HashMap<>(); |
| | | List<String> titleRowData= dataSet.getColName(); |
| | | List<SheetRowData> rowDataList= dataSet.getRowData(); |
| | | LinkedHashMap<String,CodeClassifyTemplateVO> codeClassifyTemplateVOMap=new LinkedHashMap <String,CodeClassifyTemplateVO>(); |
| | | LinkedHashMap<String,CodeRuleVO> codeRuleVOVOMap=new LinkedHashMap <String,CodeRuleVO>(); |
| | | |
| | | for (int i=0;i<titleRowData.size();i++){ |
| | | String title= titleRowData.get(i); |
| | | if(title.equals("å类路å¾")) { |
| | | int finalI = i; |
| | | rowDataList.stream().forEach(sheetRowData -> { |
| | | CodeImprotDataVO dataVO=new CodeImprotDataVO(); |
| | | String Path = sheetRowData.getData().get(finalI); |
| | | String rowIndex=sheetRowData.getRowIndex(); |
| | | Map<Integer, String> execlData= sheetRowData.getData(); |
| | | CodeClassifyTemplateVO newTemplateVO=new CodeClassifyTemplateVO(); |
| | | CodeRuleVO codeRuleVO=new CodeRuleVO(); |
| | | if(StringUtils.isEmpty(Path)){ |
| | | Path="#current#"; |
| | | } |
| | | |
| | | if(pathMap.containsKey(Path)){ |
| | | CodeClassifyVO codeClassifyVO=pathMap.get(Path); |
| | | if(codeClassifyTemplateVOMap.containsKey(Path)){ |
| | | newTemplateVO= codeClassifyTemplateVOMap.get(Path); |
| | | codeRuleVO= codeRuleVOVOMap.get(Path); |
| | | if(newTemplateVO==null||StringUtils.isBlank(newTemplateVO.getOid())){ |
| | | errorMap.put(rowIndex,"第"+rowIndex+"è¡ï¼åç±»è·¯å¾æªæ¥è¯¢å°ç¸åºçå类模æ¿"); |
| | | } |
| | | if(codeRuleVO==null||StringUtils.isBlank(codeRuleVO.getOid())){ |
| | | errorMap.put(rowIndex,"第"+rowIndex+"è¡ï¼åç±»è·¯å¾æªæ¥è¯¢å°ç¸åºçåç±»è§å"); |
| | | } |
| | | }else{ |
| | | newTemplateVO =engineService.getUsedTemplateByClassifyOid(codeClassifyVO.getOid()); |
| | | if(newTemplateVO==null||StringUtils.isBlank(newTemplateVO.getOid())){ |
| | | errorMap.put(rowIndex,"第"+rowIndex+"è¡ï¼åç±»è·¯å¾æªæ¥è¯¢å°ç¸åºçå类模æ¿"); |
| | | } |
| | | codeRuleVO=engineService.getCodeRuleByClassifyOid(codeClassifyVO.getOid()); |
| | | if(codeRuleVO==null||StringUtils.isBlank(codeRuleVO.getOid())){ |
| | | errorMap.put(rowIndex,"第"+rowIndex+"è¡ï¼åç±»è·¯å¾æªæ¥è¯¢å°ç¸åºçåç±»è§å"); |
| | | } |
| | | } |
| | | if(pathMap.containsKey(Path)){ |
| | | dataVO=pathDatas.getOrDefault(Path,dataVO); |
| | | } |
| | | dataVO.setTemplateOid(newTemplateVO==null?"":newTemplateVO.getOid()); |
| | | dataVO.setCodeClassifyTemplateVO(newTemplateVO); |
| | | dataVO.setCodeClassifyVO(codeClassifyVO); |
| | | dataVO.setCodeRuleVO(codeRuleVO); |
| | | dataVO.setRowIndex(rowIndex); |
| | | dataVO.setCodeClassifyOid(codeClassifyVO.getOid());//设置åç±»oid |
| | | dataVO.setCodeRuleOid(codeRuleVO==null?"":codeRuleVO.getOid()); |
| | | createExeclClassData(titleRowData,newTemplateVO,execlData,dataVO); |
| | | pathDatas.put(Path,dataVO); |
| | | codeClassifyTemplateVOMap.put(Path, newTemplateVO); |
| | | codeRuleVOVOMap.put(Path,codeRuleVO); |
| | | }else{ |
| | | errorMap.put(rowIndex,"第"+rowIndex+"è¡ï¼åç±»è·¯å¾æªæ¥è¯¢å°ç¸åºçåç±»"); |
| | | } |
| | | }); |
| | | break; |
| | | } |
| | | } |
| | | List <CodeImprotDataVO> newCodeImprotDataVO= pathDatas.values().stream().collect(Collectors.toList()); |
| | | codeClassifyDatas.addAll(newCodeImprotDataVO); |
| | | log.info("222"); |
| | | } |
| | | /*** |
| | | * @param titleRowData |
| | | * @param newTemplateVO |
| | | * @param execlData |
| | | * @param codeImprotDataVO |
| | | */ |
| | | private void createExeclClassData(List<String> titleRowData, CodeClassifyTemplateVO newTemplateVO, Map<Integer, String> execlData, CodeImprotDataVO codeImprotDataVO){ |
| | | //é¤å»é»è®¤ç屿§.è¿æåªæè¡¨åæ¾ç¤ºçåæ®µæå¯¼å
¥ |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = newTemplateVO.getAttributes().stream().filter(s -> |
| | | !DEFAULT_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag()) |
| | | ).collect(Collectors.toList()); |
| | | Map<String/**䏿åç§°**/, String/**è±æåç§°**/> attrNameIdMap = attrVOS.stream().collect(Collectors.toMap(s -> s.getName(), t -> t.getId())); |
| | | List<String> fields=new ArrayList<>(); |
| | | Map<String,String> filedValueMap=new HashMap<>(); |
| | | List<String> colNames=new ArrayList<>(); |
| | | for (int i = 0; i < titleRowData.size(); i++) { |
| | | String title = titleRowData.get(i); |
| | | title=title.replace(KEY_ATTR_CHAR,"").replace(REQUIRED_CHAR,""); |
| | | String id = attrNameIdMap.getOrDefault(title,""); |
| | | if(StringUtils.isBlank(id) && "å类路å¾".equalsIgnoreCase(title)){ |
| | | id = CODE_CLASSIFY_OID_FIELD; |
| | | } |
| | | if(StringUtils.isBlank(id) && "ç æ®µå®½åº¦".equalsIgnoreCase(title)){ |
| | | id = CODE_SEC_LENGTH_FIELD; |
| | | } |
| | | if(StringUtils.isBlank(id) && "ä¼ä¸ç¼ç ".equalsIgnoreCase(title)){ |
| | | id = CODE_FIELD; |
| | | } |
| | | if(StringUtils.isNotBlank(id)){ |
| | | // fieldIndexMap.put(i,id);id |
| | | fields.add(id); |
| | | colNames.add(title); |
| | | String value= StringUtils.isNotBlank(execlData.get(i))?execlData.get(i):""; |
| | | filedValueMap.put(id,value); |
| | | |
| | | } |
| | | } |
| | | // filedValueMap.put(CODE_CLASSIFY_OID_FIELD,codeImprotDataVO.getCodeClassifyOid());//å°å½ååç±»oidåå
¥åæ®µä¸ |
| | | filedValueMap.put("codeclassifyid",codeImprotDataVO.getCodeClassifyOid()); |
| | | filedValueMap.put(IMPORT_ROW_INDEX,codeImprotDataVO.getRowIndex()); |
| | | filedValueMap.put("codetemplateoid",newTemplateVO.getOid()); |
| | | codeImprotDataVO.setFields(fields); |
| | | codeImprotDataVO.setColNames(colNames); |
| | | codeImprotDataVO.getDatas().add(filedValueMap); |
| | | } |
| | | /*** |
| | | * æ£ç¡®éè¯¯æ°æ®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è¿ææ¶é´ |
| | | } |
| | | } |
| | | |
| | | /****** |
| | | * æ ¹æ®ç¼ç è§åç¼åæ°æ® |
| | | * @param uuid |
| | | * @param codeImprotDataVOs |
| | | * @param errorMap |
| | | * @param isok |
| | | */ |
| | | private void createRedisDatas(String uuid, List<CodeImprotDataVO> codeImprotDataVOs, Map<String, String> errorMap, boolean isok){ |
| | | codeImprotDataVOs.stream().forEach(codeImprotDataVO -> { |
| | | List<Map<String, String>> dataLists=new ArrayList<>(); |
| | | CodeImprotDataVO newCodeImprotDataVO=new CodeImprotDataVO(); |
| | | if(errorMap.size()>0) { |
| | | //è¦æä»¥ä¸çé误ç齿åºåï¼åç»§ç»å¤çæ¶é´åç»åè§å |
| | | dataLists = codeImprotDataVO.getDatas().stream().filter(cbo -> { |
| | | String rowIndex=cbo.get(IMPORT_ROW_INDEX); |
| | | String msg=StringUtils.isBlank(errorMap.get(rowIndex))?"":errorMap.get(rowIndex); |
| | | cbo.put("errorMsg",msg); |
| | | return isok? !errorMap.containsKey(rowIndex):errorMap.containsKey(rowIndex); |
| | | }).collect(Collectors.toList()); |
| | | |
| | | }else{ |
| | | dataLists= codeImprotDataVO.getDatas(); |
| | | } |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeImprotDataVO,newCodeImprotDataVO); |
| | | newCodeImprotDataVO.setDatas(dataLists); |
| | | List<CodeImprotDataVO> codeImprotDataVOList=new ArrayList<>(); |
| | | codeImprotDataVOList.add(newCodeImprotDataVO); |
| | | /***update æ´æ¹æä»¥è§ååç»*****/ |
| | | String codeRuleOid=codeImprotDataVO.getCodeRuleOid(); |
| | | log.info(uuid+"-"+codeRuleOid+":æ¡ç®æ°"+codeImprotDataVOList.size()); |
| | | if(codeImprotDataVOList.size()>0) { |
| | | bladeRedis.set(uuid + "-" + codeRuleOid, codeImprotDataVOList); |
| | | bladeRedis.expire(uuid + "-" + codeRuleOid, BATCHADD_REDIS_TIME);//redisè¿ææ¶é´ |
| | | |
| | | } |
| | | |
| | | /*** String codeClassifyOid=codeImprotDataVO.getCodeClassifyOid(); |
| | | |
| | | redisService.setCacheList(uuid+"-"+codeClassifyOid,codeImprotDataVOList); |
| | | logger.info(uuid+"-"+codeClassifyOid+":æ¡ç®æ°"+codeImprotDataVOList.size()); |
| | | redisService.expire(uuid+"-"+codeClassifyOid,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("lastr", "1"); |
| | | andConditionMap.put("lastv", "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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |