| | |
| | | package com.vci.web.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.common.data.UserEntityInfo; |
| | | import com.vci.corba.omd.data.BusinessObject; |
| | | import com.vci.corba.omd.etm.EnumItem; |
| | | import com.vci.corba.omd.etm.EnumType; |
| | | import com.vci.dto.OsEnumDTO; |
| | | import com.vci.dto.OsEnumItemDTO; |
| | | import com.vci.dto.SmUserDTO; |
| | | import com.vci.omd.utils.ObjectTool; |
| | | import com.vci.pagemodel.*; |
| | | import com.vci.po.OsEnumPO; |
| | | import com.vci.po.SmUserPO; |
| | | import com.vci.starter.poi.bo.ReadExcelOption; |
| | | import com.vci.starter.poi.bo.WriteExcelData; |
| | | import com.vci.starter.poi.bo.WriteExcelOption; |
| | | import com.vci.starter.poi.constant.ExcelLangCodeConstant; |
| | | import com.vci.starter.poi.util.ExcelUtil; |
| | | import com.vci.starter.web.annotation.log.VciUnLog; |
| | | import com.vci.starter.web.enumpck.UserSecretEnum; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.BaseResult; |
| | | import com.vci.starter.web.pagemodel.DataGrid; |
| | | import com.vci.starter.web.pagemodel.PageHelper; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.starter.web.util.VciDateUtil; |
| | | import com.vci.starter.web.util.*; |
| | | import com.vci.constant.EnumIdConstant; |
| | | import com.vci.pagemodel.KeyValue; |
| | | import com.vci.pagemodel.OsEnumItemVO; |
| | | import com.vci.pagemodel.OsEnumVO; |
| | | import com.vci.pagemodel.OsStatusVO; |
| | | import com.vci.starter.web.util.WebThreadLocalUtil; |
| | | import com.vci.web.service.OsEnumServiceI; |
| | | import com.vci.web.service.OsLifeCycleServiceI; |
| | | import com.vci.web.service.WebBoServiceI; |
| | |
| | | import com.vci.web.util.PlatformClientUtil; |
| | | import com.vci.web.util.WebUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.hssf.util.HSSFColor; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.util.HtmlUtils; |
| | | |
| | | import java.io.File; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private WebBoServiceI boService; |
| | | |
| | | /** |
| | | * æ¥å¿ |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | /** |
| | | * å è½½èªèº« |
| | | */ |
| | | @Autowired(required = false) |
| | | @Lazy |
| | | private OsEnumServiceI self; |
| | | |
| | | /** |
| | | * å¿
å¡«å |
| | | */ |
| | | private ArrayList<Integer> ColumnNameisRed = new ArrayList<Integer>(); |
| | | |
| | | /** |
| | | * æ¥å¿ |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | /** |
| | | * 使ç¨ç¼å·è·åæä¸¾æç» |
| | |
| | | |
| | | /** |
| | | * æ¥çæä¸¾ç使ç¨èå´ |
| | | * @param enumName |
| | | * @param enumName æä¸¾åç§° |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public List<OsEnumVO> getUsedEnumList(String enumName) throws PLException { |
| | | return null; |
| | | public List<Map<String,String>> getUsedEnumList(String enumName) throws PLException { |
| | | if(Func.isBlank(enumName)){ |
| | | throw new PLException("500",new String[]{"è¯·éæ©è¦æ¥è¯¢åºç¨èå´çæä¸¾!"}); |
| | | } |
| | | String[] attrubyteNames = platformClientUtil.getAttributeService().getAttrubyteNamesByEMName(enumName); |
| | | if(Func.isEmpty(attrubyteNames)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | List<Map<String,String>> attrubyteMapList = new ArrayList<>(); |
| | | Arrays.stream(attrubyteNames).forEach(attrName->{ |
| | | Map<String, String> itemMap = new HashMap<>(); |
| | | itemMap.put("enumName",enumName); |
| | | itemMap.put("source",attrName); |
| | | attrubyteMapList.add(itemMap); |
| | | }); |
| | | return attrubyteMapList; |
| | | } |
| | | |
| | | /** |
| | |
| | | //æä¸¾é¡¹åç§°å¤éçæä½ |
| | | checkOsEnumItem(osEnumDTO); |
| | | //é»è®¤å¼å¤ç |
| | | String userId = "developer";//WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); |
| | | String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); |
| | | osEnumDTO.setCreator(userId); |
| | | //æå¨è®¾ç½®ä¸»é®ï¼å¦åå¹³å°ç´æ¥ç¨æ²¡æä¸»é®çæä¸¾æ¾è¿äºç¼åä¸ï¼å¯¼è´åç»æ¥è¯¢çæ°æ®æ²¡æoid |
| | | osEnumDTO.setOid(VciBaseUtil.getPk().toUpperCase(Locale.ROOT)); |
| | | osEnumDTO.setLastModifier(userId); |
| | | return platformClientUtil.getEnumService().addEnumType(this.osEnumDTO2EnumType(osEnumDTO)); |
| | | } |
| | |
| | | //3ãæä¸¾é¡¹å¤éï¼åé¿åº¦çæ ¡éª |
| | | checkOsEnumItem(osEnumDTO); |
| | | //å°osEnumVOä¸çé»è®¤å¼èµå¼ç»osEnumDTO对象 |
| | | String userId = "developer";//WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); |
| | | String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); |
| | | osEnumDTO.setLastModifier(userId); |
| | | osEnumDTO.setCreator(osEnumVO.getCreator()); |
| | | osEnumDTO.setCreateTime(osEnumVO.getCreateTime()); |
| | |
| | | if(Func.isBlank(oid) || Func.isBlank(name) || Func.isEmpty(ts)){ |
| | | throw new PLException("500",new String[]{"å¾
å é¤çæä¸¾å表ä¸ä¸»é®ãoidãåè°æ´æ¶é´ãtsãä¸è½ä¸ºç©ºï¼"}); |
| | | } |
| | | //夿æä¸¾æ¯å¦æè¢«å¼ç¨ |
| | | List<Map<String, String>> usedEnumList = this.getUsedEnumList(name); |
| | | if(Func.isNotEmpty(usedEnumList)){ |
| | | throw new PLException("500",new String[]{"å é¤çæä¸¾ä¸ã" + name + "ã,已被å¼ç¨ï¼"}); |
| | | } |
| | | EnumType enumType = new EnumType(); |
| | | enumType.oid = oid; |
| | | enumType.name = name; |
| | |
| | | } |
| | | |
| | | /** |
| | | * å¯¼åºæä¸¾ç±»å |
| | | * @param exportFileName 导åºçæä»¶å |
| | | * @param enumNames éè¦å¯¼åºçæä¸¾åç§° |
| | | * @return |
| | | */ |
| | | @Override |
| | | public String exportEnumTypes(String exportFileName,String enumNames) throws PLException { |
| | | if(Func.isBlank(enumNames)){ |
| | | throw new PLException("500",new String[]{"请å¾éè¦å¯¼åºçæä¸¾!"}); |
| | | } |
| | | //ç颿²¡ä¼ åç§°ï¼ä½¿ç¨é»è®¤å¯¼åºåç§° |
| | | exportFileName = Func.isBlank(exportFileName) ? "æä¸¾ç±»å导åº_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss"):exportFileName; |
| | | //设置åå |
| | | List<String> columns = new ArrayList<>(Arrays.asList("æä¸¾åç§°", "æ ç¾", "è¿åç±»å", "é¿åº¦", "æä¸¾é¡¹åç§°", "æä¸¾å¼", "æè¿°")); |
| | | |
| | | //åexcel |
| | | String excelPath = LocalFileUtil.getDefaultTempFolder() + File.separator + exportFileName + ".xls"; |
| | | try { |
| | | new File(excelPath).createNewFile(); |
| | | } catch (Throwable e) { |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelPath}, e); |
| | | } |
| | | //设置å |
| | | List<WriteExcelData> excelDataList = new ArrayList<>(); |
| | | //设置å头 |
| | | for (int index = 0; index < columns.size(); index++) { |
| | | excelDataList.add(new WriteExcelData(0,index, columns.get(index))); |
| | | } |
| | | //æç
§æä¸¾åæ¥è¯¢æä¸¾ï¼ç¶åå¤çæä¸¾å¯¼åº |
| | | List<String> enumNameList = Func.toStrList(enumNames); |
| | | int startRow = 1; |
| | | for (int i = 0; i < enumNameList.size(); i++) { |
| | | //æ ¹æ®æä¸¾åç§°æ¥è¯¢æä¸¾åæä¸¾é¡¹ |
| | | OsEnumVO osEnumVO = this.getEnumTypeById(enumNameList.get(i)); |
| | | //OsEnumVO osEnumVO = getTestJson(i); |
| | | //æ¥è¯¢ç»æä¸åºè¯¥ä¸ºç©º |
| | | if(Func.isEmpty(osEnumVO) && Func.isBlank(osEnumVO.getOid())){ |
| | | throw new PLException("500",new String[]{"æªæ¥è¯¢å°æä¸¾å为ã" + enumNameList.get(i) + "ãçæä¸¾ï¼è¯·å·æ°å鿰坼åº!"}); |
| | | } |
| | | //æä¸¾é¡¹ä¸ä¸ºç©ºæ¶éè¦èèåå¹¶è¡é®é¢ |
| | | List<OsEnumItemVO> enumVOItems = osEnumVO.getItems(); |
| | | //æä¸¾é¡¹ä¸ä¸ºç©ºæ¶éè¦è¿è¡åå¹¶è¡å¤ç |
| | | if(Func.isNotEmpty(enumVOItems) || enumVOItems.size() > 1){ |
| | | //excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,0, osEnumVO.getOid())); |
| | | excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,0, osEnumVO.getId())); |
| | | excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,1, osEnumVO.getName())); |
| | | excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,2, osEnumVO.getEnumValueDataType()+"("+osEnumVO.getEnumValueDataTypeText()+")")); |
| | | excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,3, osEnumVO.getLength())); |
| | | //excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,5, osEnumVO.getCreator())); |
| | | excelDataList.add(new WriteExcelData(startRow,(enumVOItems.size()+startRow)-1,true,true,4, Func.format(osEnumVO.getCreateTime(),"yyyyå¹´MMæddæ¥ hh:mm:ss"))); |
| | | |
| | | //å¤çæä¸¾é¡¹åå
¥ |
| | | for (int j = 0; j < enumVOItems.size(); j++) { |
| | | OsEnumItemVO osEnumItemVO = enumVOItems.get(j); |
| | | excelDataList.add(new WriteExcelData(startRow+j,7, true,osEnumItemVO.getName())); |
| | | excelDataList.add(new WriteExcelData(startRow+j,8, true, osEnumItemVO.getValue())); |
| | | excelDataList.add(new WriteExcelData(startRow+j,9, true, osEnumItemVO.getDescription())); |
| | | } |
| | | |
| | | startRow += enumVOItems.size(); |
| | | }else{ |
| | | //æä¸¾é¡¹ä¸ºç©ºæ¶å°±ä¸éè¦åå¹¶è¡ |
| | | //excelDataList.add(new WriteExcelData(startRow,0, true,osEnumVO.getOid())); |
| | | excelDataList.add(new WriteExcelData(startRow,0, true, osEnumVO.getId())); |
| | | excelDataList.add(new WriteExcelData(startRow,1, true, osEnumVO.getName())); |
| | | excelDataList.add(new WriteExcelData(startRow,1, true, osEnumVO.getEnumValueDataType()+"("+osEnumVO.getEnumValueDataTypeText()+")")); |
| | | excelDataList.add(new WriteExcelData(startRow,3, true, osEnumVO.getLength())); |
| | | //excelDataList.add(new WriteExcelData(startRow,5, true, osEnumVO.getCreator())); |
| | | excelDataList.add(new WriteExcelData(startRow,4, true, Func.format(osEnumVO.getCreateTime(),"yyyyå¹´MMæddæ¥ hh:mm:ss"))); |
| | | } |
| | | //è®°å½ä¸ä¸ä¸ç»æ°æ®ç»ææ¶çè¡å·ï¼æ¹ä¾¿ç¨ååå¹¶è¡çèµ·å§è¡ |
| | | startRow += 1; |
| | | } |
| | | WriteExcelOption excelOption = new WriteExcelOption(excelDataList); |
| | | ExcelUtil.writeDataToFile(excelPath, excelOption); |
| | | return excelPath; |
| | | } |
| | | |
| | | /** |
| | | * ä¸è½½å¯¼å
¥æ¨¡æ¿ |
| | | * @param exportFileName |
| | | * @return |
| | | */ |
| | | @Override |
| | | public String downloadEnumTemplate(String exportFileName) { |
| | | //ç颿²¡ä¼ åç§°ï¼ä½¿ç¨é»è®¤å¯¼åºåç§° |
| | | exportFileName = Func.isBlank(exportFileName) ? "æä¸¾å¯¼å
¥æ¨¡æ¿_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss"):exportFileName; |
| | | //设置åå |
| | | List<String> columns = new ArrayList<>(Arrays.asList("æä¸¾åç§°", "æ ç¾", "è¿åç±»å", "é¿åº¦", "æä¸¾é¡¹åç§°(å½åæä¸¾ä¸ææä¸¾é¡¹æ¶å¿
å¡«)", "æä¸¾å¼(å½åæä¸¾ä¸ææä¸¾é¡¹æ¶å¿
å¡«)", "æè¿°","*注æ*:第äºè¡å¼å§çæ°æ®ä¸ºç¤ºä¾æ°æ®ï¼å¯¼å
¥å请å°å
¶å é¤ï¼å½å¯¼å
¥çæä¸¾ä¸å
·å¤å¤ä¸ªæä¸¾é¡¹æ¶ï¼åºæç
§ç¤ºä¾enum2çåæ³")); |
| | | //åexcel |
| | | String excelPath = LocalFileUtil.getDefaultTempFolder() + File.separator + exportFileName + ".xls"; |
| | | //设置å¿
å¡«å |
| | | ColumnNameisRed.clear(); |
| | | ColumnNameisRed.add(0); |
| | | ColumnNameisRed.add(2); |
| | | ColumnNameisRed.add(3); |
| | | ColumnNameisRed.add(4); |
| | | ColumnNameisRed.add(5); |
| | | try { |
| | | new File(excelPath).createNewFile(); |
| | | } catch (Throwable e) { |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelPath}, e); |
| | | } |
| | | //设置å |
| | | List<WriteExcelData> excelDataList = new ArrayList<>(); |
| | | //设置å头 |
| | | for (int index = 0; index < columns.size(); index++) { |
| | | //夿æ¯å¦ä¸ºå¿
å¡«åï¼ç»å¿
å¡«å设置é¢è² |
| | | if(ColumnNameisRed.contains(index)){ |
| | | WriteExcelData excelData = new WriteExcelData(0, index, columns.get(index)); |
| | | excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex())); |
| | | excelDataList.add(excelData); |
| | | }else{ |
| | | excelDataList.add(new WriteExcelData(0,index, columns.get(index))); |
| | | } |
| | | } |
| | | List<OsEnumVO> exportEnumTempExample = this.getExportEnumTempExample(); |
| | | for (int i = 0; i < exportEnumTempExample.size(); i++) { |
| | | OsEnumVO osEnumVO = exportEnumTempExample.get(i); |
| | | List<OsEnumItemVO> enumVOItems = osEnumVO.getItems(); |
| | | for (int j = 0; j < enumVOItems.size(); j++) { |
| | | OsEnumItemVO osEnumItemVO = enumVOItems.get(j); |
| | | excelDataList.add(new WriteExcelData(i+j+1,0, osEnumVO.getId())); |
| | | excelDataList.add(new WriteExcelData(i+j+1,1, osEnumVO.getName())); |
| | | excelDataList.add(new WriteExcelData(i+j+1,2, osEnumVO.getEnumValueDataType())); |
| | | excelDataList.add(new WriteExcelData(i+j+1,3, osEnumVO.getLength())); |
| | | |
| | | excelDataList.add(new WriteExcelData(i+j+1,4,osEnumItemVO.getName())); |
| | | excelDataList.add(new WriteExcelData(i+j+1,5, osEnumItemVO.getValue())); |
| | | excelDataList.add(new WriteExcelData(i+j+1,6, osEnumItemVO.getDescription())); |
| | | } |
| | | } |
| | | WriteExcelOption excelOption = new WriteExcelOption(excelDataList); |
| | | ExcelUtil.writeDataToFile(excelPath, excelOption); |
| | | return excelPath; |
| | | } |
| | | |
| | | /** |
| | | * 导å
¥æä¸¾ |
| | | * @param file |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public BaseResult importEnumTypes(File file) throws Exception { |
| | | VciBaseUtil.alertNotNull(file,"excelæä»¶"); |
| | | if(!file.exists()){ |
| | | throw new VciBaseException("导å
¥çexcelæä»¶ä¸åå¨,{0}",new String[]{file.getPath()}); |
| | | } |
| | | try{ |
| | | //1ã读åexcelä¸çæ°æ®ï¼ç»æå¯¹è±¡ |
| | | ReadExcelOption excelOption = new ReadExcelOption(); |
| | | List<OsEnumPO> poList = ExcelUtil.readDataObjectFromExcel(file, OsEnumPO.class,excelOption,(value, po, fieldName)->{}); |
| | | //å»é¤é½æ¯ç©ºçæ
åµ |
| | | if(CollectionUtils.isEmpty(poList)){ |
| | | return BaseResult.fail(ExcelLangCodeConstant.IMPORT_CONTENT_NULL,new String[]{}); |
| | | } |
| | | //尿䏾åæä¸¾é¡¹å¤çæä¸å¯¹å¤å
³ç³»ç对象 |
| | | Map<String, OsEnumPO> groupPOMap = new HashMap<>(); |
| | | for (OsEnumPO po : poList) { |
| | | //æ¼æ¥ç¨æ¥ä½ä¸ºåç»çkey |
| | | String key = po.getId() + "_" + po.getName() + "_" + po.getEnumValueDataType() + "_" + po.getLength(); |
| | | OsEnumPO group = groupPOMap.get(key); |
| | | if (group == null) { |
| | | group = new OsEnumPO(); |
| | | //æ¿åºç°çé¦è¡ååç»çæç¤ºè¡ |
| | | group.setRowIndex(po.getRowIndex()); |
| | | group.setId(po.getId()); |
| | | group.setName(po.getName()); |
| | | group.setEnumValueDataType(po.getEnumValueDataType()); |
| | | group.setLength(po.getLength()); |
| | | groupPOMap.put(key, group); |
| | | } |
| | | |
| | | OsEnumItemDTO itemDTO = new OsEnumItemDTO(); |
| | | itemDTO.setName(po.getEnumItemName()); |
| | | itemDTO.setValue(po.getValue()); |
| | | itemDTO.setDescription(po.getDescription()); |
| | | |
| | | group.getItems().add(itemDTO); |
| | | } |
| | | Collection<OsEnumPO> newPOList = groupPOMap.values(); |
| | | //æ°æ®åºæ¥è¯¢æ¯å¦æå·²åå¨çæä¸¾åï¼æ¹ä¾¿åç»åå¤éå¤ç |
| | | List<OsEnumVO> osEnumVOList = this.listEnumByIdCollection(poList.stream().map(OsEnumPO::getId).collect(Collectors.toSet())); |
| | | List<String> repeatEnumId = new ArrayList<>(); |
| | | if(Func.isNotEmpty(osEnumVOList)){ |
| | | repeatEnumId = osEnumVOList.stream().map(OsEnumVO::getId).collect(Collectors.toList()); |
| | | } |
| | | //å½åexcel䏿¯å¦éå¤ç¨çå¤éMap:ï¼keyï¼è´¦å·ï¼valueï¼è¡å·ï¼ |
| | | Map<String, String> excelReapeat = new HashMap<>(); |
| | | //夿å¿
填屿§æ¯å¦ä¸ºç©ºï¼ç¨æ·æ¯å¦å·²åå¨ï¼ä»¥åé¨é¨æ¯å¦å¡«éçæ ¡éªé»è¾ |
| | | List<String> finalRepeatEnumId = repeatEnumId; |
| | | newPOList.stream().forEach(osEnumPO -> { |
| | | if(Func.isBlank(osEnumPO.getId())){//æä¸¾å |
| | | throw new VciBaseException("第ã"+osEnumPO.getRowIndex()+"ãè¡ï¼enumnameerror"); |
| | | }else if(Func.isBlank(osEnumPO.getEnumValueDataType())){ |
| | | throw new VciBaseException("第ã"+osEnumPO.getRowIndex()+"ãè¡ï¼typeerror"); |
| | | }else if(Func.isEmpty(osEnumPO.getLength())){ |
| | | throw new VciBaseException("第ã"+osEnumPO.getRowIndex()+"ãè¡ï¼lengtherror"); |
| | | }else if(!osEnumPO.getId().matches("^[A-Za-z]+$")){ |
| | | throw new VciBaseException("第ã"+osEnumPO.getRowIndex()+"ãè¡æ°æ®ï¼æä¸¾åç§°åªè½ä¸ºè±æåæ¯"); |
| | | }else if(excelReapeat.containsKey(osEnumPO.getId())){//æä¸¾åè¡¨æ ¼ä¸å¤é |
| | | throw new VciBaseException("第ã"+excelReapeat.get(osEnumPO.getId())+"ãè¡å第ã"+osEnumPO.getRowIndex()+"ãè¡æ°æ®ï¼æä¸¾åéå¤"); |
| | | }else if (Func.isNotEmpty(osEnumVOList) && finalRepeatEnumId.contains(osEnumPO.getId())){//2ã夿æä¸¾åæ¯å¦ä¸ç³»ç»ä¸éå¤ |
| | | throw new VciBaseException("第ã"+osEnumPO.getRowIndex()+"ãè¡ï¼æä¸¾åå¨ç³»ç»ä¸å·²ç»åå¨,请修æ¹!"); |
| | | } |
| | | //å
对å¿
填屿§å¤ç©ºå¤ç |
| | | excelReapeat.put(osEnumPO.getId(),osEnumPO.getRowIndex()); |
| | | }); |
| | | //ä¿åé»è¾ |
| | | for (OsEnumPO osEnumPO : newPOList) { |
| | | OsEnumDTO osEnumDTO = new OsEnumDTO(); |
| | | //çæåå¨çDTO对象 |
| | | osEnumDTO.setId(osEnumPO.getId()); |
| | | osEnumDTO.setName(osEnumPO.getName()); |
| | | osEnumDTO.setEnumValueDataType(osEnumPO.getEnumValueDataType()); |
| | | osEnumDTO.setLength(osEnumPO.getLength()); |
| | | osEnumDTO.setItems(osEnumPO.getItems()); |
| | | |
| | | //è°ç¨æ°å¢æä¸¾æ¹æ³ |
| | | boolean addBoolean = this.addEnumType(osEnumDTO); |
| | | if(!addBoolean){ |
| | | throw new PLException("500",new String[]{"ä¿åæä¸¾å为ã" + osEnumDTO.getId() + "ãçæ°æ®æ¶åºç°é误!"}); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | if(logger.isErrorEnabled()){ |
| | | logger.error("读åexcelå
å®¹æ¶æä¿åç¨æ·ä¿¡æ¯æ¶åºç°äºé误ï¼å
·ä½åå ï¼",VciBaseUtil.getExceptionMessage(e)); |
| | | } |
| | | e.printStackTrace(); |
| | | return BaseResult.fail(VciBaseUtil.getExceptionMessage(e),new String[]{},e); |
| | | } |
| | | return BaseResult.success("æä¸¾å¯¼å
¥æåï¼"); |
| | | } |
| | | |
| | | /* private OsEnumVO getTestJson(int i){ |
| | | String testJosn = "[{\"createTime\":\"2024-07-17 17:06:30.170\",\"creator\":\"developer\",\"enumValueDataType\":\"String\",\"enumValueDataTypeText\":\"å符串\",\"id\":\"test\",\"items\":[{\"description\":\"\",\"name\":\"1\",\"value\":\"11\"},{\"description\":\"\",\"name\":\"1\",\"value\":\"11\"}],\"lastModifier\":\"developer\",\"lastModifyTime\":\"2024-07-17 17:06:30.170\",\"length\":2,\"name\":\"test1\",\"oid\":\"4F9B4094-A4F5-E3CD-AC7C-1F33AA65F1E7\",\"ts\":\"2024-07-18 09:40:52.512\"},{\"createTime\":\"2024-07-17 09:49:31.592\",\"creator\":\"developer\",\"description\":null,\"enumValueDataType\":\"String\",\"enumValueDataTypeText\":\"å符串\",\"id\":\"testString\",\"items\":[{\"description\":\"11\",\"name\":\"11\",\"value\":\"11\"},{\"description\":\"\",\"name\":\"test1\",\"value\":\"1\"},,{\"description\":\"\",\"name\":\"test1\",\"value\":\"1\"}],\"lastModifier\":\"developer\",\"lastModifyTime\":\"2024-07-17 09:49:31.592\",\"length\":6,\"name\":\"testString\",\"oid\":\"AB3A7718-55C6-555E-A1FD-934763ACA3F2\",\"ts\":\"2024-07-17 16:47:33.038\"}]"; |
| | | List<OsEnumVO> OsEnumVOs = JSON.parseArray(testJosn,OsEnumVO.class); |
| | | return OsEnumVOs.get(i); |
| | | }*/ |
| | | |
| | | /** |
| | | * è·å导å
¥æ¨¡æ¿çç¤ºä¾æ°æ® |
| | | * @return |
| | | */ |
| | | private List<OsEnumVO> getExportEnumTempExample(){ |
| | | String testJosn = "[{\"enumValueDataType\":\"String\",\"id\":\"enum1\",\"items\":[{\"description\":\"enumitem1.1\",\"name\":\"enumitem1.1\",\"value\":\"1\"},{\"description\":\"enumitem1.2\",\"name\":\"enumitem1.2\",\"value\":\"2\"}],\"length\":2,\"name\":\"enum1\"},{\"enumValueDataType\":\"String\",\"id\":\"enum2\",\"items\":[{\"description\":\"enumitem2.1\",\"name\":\"enumitem2.1\",\"value\":\"1\"},{\"description\":\"enumitem2.2\",\"name\":\"enumitem2.2\",\"value\":\"2\"},{\"description\":\"enumitem2.3\",\"name\":\"enumitem2.3\",\"value\":\"3\"}],\"length\":6,\"name\":\"enum2\"}]"; |
| | | List<OsEnumVO> OsEnumVOs = JSON.parseArray(testJosn,OsEnumVO.class); |
| | | return OsEnumVOs; |
| | | } |
| | | |
| | | /** |
| | | * æä¸¾é¡¹æ ¡éª |
| | | * @param osEnumDTO |
| | | * @return æ ¡éªå¤±è´¥ç´æ¥æåºå¼å¸¸ï¼å¦åä¸ä¼åä»»ä½è¿å |
| | |
| | | List<OsEnumItemDTO> items = osEnumDTO.getItems(); |
| | | if (Func.isNotEmpty(items)) { |
| | | //è·åæ£åï¼ä¸»è¦æ¯é对Integerç±»åçæ¶å |
| | | String regular = "Integer".equals(osEnumDTO.getEnumValueDataType()) ? "^[0-9]+$" : ""; |
| | | String regular = "Integer".equals(osEnumDTO.getEnumValueDataType()) ? "^-?\\d+$" : ""; |
| | | //å©ç¨setçaddè¿åå¼è¿è¡nameå¤é |
| | | Set<String> uniqueNames = new HashSet<>(); |
| | | for (OsEnumItemDTO item : items) { |