xiejun
2024-08-27 ca3880ac5dde98928d6ae0d0c66a0e53c4cbc6c7
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();