From ca3880ac5dde98928d6ae0d0c66a0e53c4cbc6c7 Mon Sep 17 00:00:00 2001 From: xiejun <xiejun@vci-tech.com> Date: 星期二, 27 八月 2024 15:45:15 +0800 Subject: [PATCH] 表单表格功能测试完善 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsPortalVIServiceImpl.java | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 115 insertions(+), 5 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsPortalVIServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsPortalVIServiceImpl.java index 76e4cc3..486c5bc 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsPortalVIServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsPortalVIServiceImpl.java @@ -8,6 +8,8 @@ import com.vci.dto.*; import com.vci.model.*; import com.vci.pagemodel.*; +import com.vci.starter.poi.bo.WriteExcelData; +import com.vci.starter.web.enumpck.VciFieldTypeEnum; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.BaseQueryObject; import com.vci.starter.web.pagemodel.BaseResult; @@ -29,6 +31,7 @@ import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Function; import java.util.stream.Collectors; /* @@ -218,13 +221,23 @@ throw new VciBaseException("璇烽�夋嫨瑕佸厠闅嗙殑瀵硅薄!"); } try { + String typeName=clonePortalVIDTOList.getClonePortalVIDTOList().get(0).getTypeName(); + PortalVI[] portalVIS= platformClientUtil.getPortalService().getPortalVIArrayByTypeName(typeName); + Map<String, PortalVIVO> PortalVIMap=new HashMap<>(); + if(!CollectionUtils.isEmpty(Arrays.asList(portalVIS))) { + List<PortalVIVO> portalVIVOS = portalVIDOO2VOS(Arrays.asList(portalVIS)); + PortalVIMap =portalVIVOS.stream().collect(Collectors.toMap(PortalVIVO::getViName, Function.identity())); + } + List<PortalVI> portalVIList=new ArrayList<>(); for (ClonePortalVIDTO clonedestObject : clonePortalVIDTOList.getClonePortalVIDTOList()) { String viName = clonedestObject.getViName(); PortalVIDTO portalVIDTO = clonedestObject.getOldPortalVIDTO(); - String typeName = clonedestObject.getTypeName(); short typeFlag = clonedestObject.getTypeFlag(); if (viName != null) { VciBaseUtil.alertNotNull(viName, "鍏嬮殕鍚嶇О涓嶅厑璁镐负绌�"); + if( PortalVIMap.containsKey(viName)){ + throw new VciBaseException("鍏嬮殕鍚嶇О"+viName+"宸插瓨鍦紝璇锋牳瀵癸紒"); + } PortalVI portalVI = UITools.getService().getPortalVIById(portalVIDTO.getId()); portalVI.id = ObjectUtility.getNewObjectID36(); portalVI.viName = viName; @@ -235,7 +248,8 @@ if (typeFlag == PortalVITypeFlag.BtmType.getIntVal() || typeFlag == PortalVITypeFlag.LinkType.getIntVal()) { portalVI.typeFlag = typeFlag; } - UITools.getService().savePortalVI(portalVI); + platformClientUtil.getPortalService().savePortalVI(portalVI); + portalVIList.add(portalVI); } } }catch (PLException e){ @@ -244,7 +258,94 @@ return true; } + @Override + public String exportToExcel(Collection<String> idList) { + /*List<PortalVIVO> portalVIVOList= listByIds(idList); + List<WriteExcelData> rowDataList = new ArrayList<>(); + final int[] index = {0}; + if(!CollectionUtils.isEmpty(portalVIVOList)) { + portalVIVOList.stream().forEach(PortalVIVO -> { + //鍏堟槸鍚嶇О + int rowIndex = index[0]; + WriteExcelData idED = new WriteExcelData(rowIndex, 0, btmId); + idED.setMerged(true); + if (attributeVOS.size() > 0) { + idED.setRowTo(rowIndex + attributeVOS.size() - 1 + 3); + } + rowDataList.add(idED); + WriteExcelData nameED = new WriteExcelData(rowIndex, 1, btmTypeVO.getName()); + nameED.setMerged(true); + if (attributeVOS.size() > 0) { + nameED.setRowTo(rowIndex + attributeVOS.size() - 1 + 3); + } + rowDataList.add(nameED); + + rowDataList.add(new WriteExcelData(rowIndex, 2, "id")); + rowDataList.add(new WriteExcelData(rowIndex, 3, "缂栧彿")); + rowDataList.add(new WriteExcelData(rowIndex, 4, "瀛楃涓�")); + rowDataList.add(new WriteExcelData(rowIndex, 5, "鏄�")); + rowDataList.add(new WriteExcelData(rowIndex, 6, "50")); + rowIndex++; + rowDataList.add(new WriteExcelData(rowIndex, 2, "name")); + rowDataList.add(new WriteExcelData(rowIndex, 3, "鍚嶇О")); + rowDataList.add(new WriteExcelData(rowIndex, 4, "瀛楃涓�")); + rowDataList.add(new WriteExcelData(rowIndex, 5, "鏄�")); + rowDataList.add(new WriteExcelData(rowIndex, 6, "50")); + rowIndex++; + rowDataList.add(new WriteExcelData(rowIndex, 2, "description")); + rowDataList.add(new WriteExcelData(rowIndex, 3, "鎻忚堪")); + rowDataList.add(new WriteExcelData(rowIndex, 4, "瀛楃涓�")); + rowDataList.add(new WriteExcelData(rowIndex, 5, "鏄�")); + rowDataList.add(new WriteExcelData(rowIndex, 6, "150")); + //澶勭悊灞炴�� + rowIndex++; + for (int i = 0; i < attributeVOS.size(); i++) { + OsBtmTypeAttributeVO attributeVO = attributeVOS.get(i); + //鍏堟槸灞炴�х殑鑻辨枃鍚嶇О + rowDataList.add(new WriteExcelData(rowIndex, 2, attributeVO.getId())); + //鐒跺悗灞炴�х殑涓枃鍚嶇О + rowDataList.add(new WriteExcelData(rowIndex, 3, attributeVO.getName())); + //灞炴�х殑绫诲瀷 + rowDataList.add(new WriteExcelData(rowIndex, 4, VciFieldTypeEnum.getTextByValue(attributeVO.getAttributeDataType()))); + //鏄惁鍙互涓虹┖ + rowDataList.add(new WriteExcelData(rowIndex, 5, attributeVO.isNullableFlag() ? "鏄�" : "鍚�")); + //灞炴�ч暱搴� + String length = attributeVO.getAttributeLength()==null?"":attributeVO.getAttributeLength() + "" ; + if (attributeVO.getPrecisionLength() != null) { + length = length + "(" + attributeVO.getPrecisionLength() + "," + attributeVO.getScaleLength() == null ? "2" : (attributeVO.getScaleLength() + "") + ")" ; + } + rowDataList.add(new WriteExcelData(rowIndex, 6, length)); + //澶囨敞 + rowDataList.add(new WriteExcelData(rowIndex, 7, attributeVO.getDescription() == null ? "" : attributeVO.getDescription())); + rowIndex++; + } + + index[0] = rowIndex; + }); + } +*/ + + return null; + } + + public List<PortalVIVO> listByIds(Collection idList){ + List<PortalVIVO> portalVIVOList=new ArrayList<>(); + if(CollectionUtils.isEmpty(idList)){ + throw new VciBaseException("璇烽�夋嫨闇�瑕佸鍑虹殑鏁版嵁"); + } + List<PortalVI> portalVIList=new ArrayList<>(); + idList.stream().forEach(id->{ + try { + PortalVI portalVI= platformClientUtil.getPortalService().getPortalVIById(id.toString()); + portalVIList.add(portalVI); + } catch (PLException e) { + e.printStackTrace(); + } + }); + portalVIVOList= portalVIDOO2VOS(portalVIList); + return portalVIVOList; + } private BaseResult savePortalVIDTO(PortalVIDTO portalVIDTO,boolean isEdit) { boolean _isBtm=false; @@ -486,10 +587,13 @@ public PortalVIVO portalVIDOO2VO(PortalVI portalVI) { PortalVIVO portalVIVO=new PortalVIVO(); portalVIVO.setId(portalVI.id); + portalVIVO.setTypeFlagText(PortalVITypeFlag.getByIntVal(portalVI.typeFlag).getLabel()); portalVIVO.setTypeFlag(portalVI.typeFlag); portalVIVO.setTypeName(portalVI.typeName); portalVIVO.setViName(portalVI.viName); portalVIVO.setViType(portalVI.viType); + portalVIVO.setViTypeText(PortalVIType.getByIntVal(portalVI.viType).getLabel()); + String prm= portalVI.prm; if(StringUtils.isNotBlank(prm)) { PRMDO prmdo = UITools.getPRM(prm); @@ -742,7 +846,13 @@ List<String> itemSelectoutFieldList= allKeyList.stream().filter(s ->!itemOutFieldList.stream().map(s1 -> s1).collect(Collectors.toList()).contains(s) ).collect(Collectors.toList()); prmItemVO.setItemSelectoutFieldList(itemSelectoutFieldList);//寰呴�夋嫨鐨勫睘鎬у瓧娈� prmItemVO.setItemOutFieldList(itemOutFieldList);//闇�瑕佷娇鐢ㄧ殑闆嗗悎 - List<String> itemSearchFieldList= itemOutFieldList.stream().filter(s ->!itemKeyFieldList.stream().map(s1 -> s1).collect(Collectors.toList()).contains(s) ).collect(Collectors.toList()); + // List<String> itemSearchFieldList= itemOutFieldList.stream().filter(s ->!CollectionUtils.isEmpty(itemKeyFieldList).stream().map(s1 -> s1).collect(Collectors.toList()).contains(s) ).collect(Collectors.toList()); + List<String> itemSearchFieldList=new ArrayList<>(); + if(!CollectionUtils.isEmpty(itemKeyFieldList)){ + itemSearchFieldList= itemOutFieldList.stream().filter(s ->!itemKeyFieldList.contains(s)).collect(Collectors.toList()); + }else{ + itemSearchFieldList=itemOutFieldList; + } prmItemVO.setItemSearchFieldList(itemSearchFieldList);//寰呮悳绱㈠瓧娈� prmItemVO.setItemKeyFieldList(itemKeyFieldList);//鎼滅储瀛楁 } @@ -772,7 +882,7 @@ private void initTableConfigDTOO2DOData(PRMItemDO prmItemDO,PRMItemDTO prmItemDTO){ prmItemDO.setItemOutFields(VciBaseUtil.array2String(prmItemDTO.getItemOutFieldList().toArray(new String[]{})));//闇�瑕佷娇鐢ㄧ殑瀛楁 - prmItemDO.setItemKeyFields(VciBaseUtil.array2String(prmItemDTO.getItemKeyFieldList().toArray(new String[]{})));//闇�瑕佹悳绱㈢殑瀛楁 + prmItemDO.setItemKeyFields(CollectionUtils.isEmpty(prmItemDTO.getItemKeyFieldList())?"":VciBaseUtil.array2String(prmItemDTO.getItemKeyFieldList().toArray(new String[]{})));//闇�瑕佹悳绱㈢殑瀛楁 List<String> newItemFieldWidthList=prmItemDTO.getItemFieldWidthList().stream().map(KeyValue::getValue).distinct().collect(Collectors.toList()); prmItemDO.setItemFieldWidth(VciBaseUtil.array2String(newItemFieldWidthList.toArray(new String[]{}),":"));//瀛楁瀹藉害 List<ItemSeniorQueryBO> itemSeniorQueryBOS= prmItemDTO.getItemSeniorQueryBOS(); @@ -805,7 +915,7 @@ private List<KeyValue> initItemFieldWidthList(String itemOutFields,String itemFieldWidth){ List<KeyValue> keyValueList=new ArrayList<>(); List<String>itemOutFieldList= VciBaseUtil.str2List(itemOutFields); - List<String>itemFieldWidthList= VciBaseUtil.str2List(itemFieldWidth); + List<String>itemFieldWidthList= VciBaseUtil.str2List(itemFieldWidth,":"); if(itemOutFieldList.size()>0) { for (int i = 0; i < itemOutFieldList.size(); i++) { KeyValue keyValue = new KeyValue(); -- Gitblit v1.9.3