ludc
2024-12-04 e405b861b9521f5ea38c5402203a5b05988f9de2
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebBtmIOServiceImpl.java
@@ -21,7 +21,8 @@
import com.vci.starter.web.constant.FrameWorkLcStatusConstant;
import com.vci.starter.web.enumpck.VciFieldTypeEnum;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.util.BeanUtil;
import com.vci.starter.web.util.BeanUtilForVCI;
import com.vci.starter.web.util.Lcm.Func;
import com.vci.starter.web.util.LocalFileUtil;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.starter.web.util.VciDateUtil;
@@ -29,7 +30,6 @@
import com.vci.starter.word.util.WordUtil;
import com.vci.web.properties.OsDDLExportWordFieldProperties;
import com.vci.web.service.*;
import com.vci.web.util.Func;
import com.vci.web.util.PlatformClientUtil;
import com.vci.web.util.WebUtil;
import org.apache.commons.lang3.StringUtils;
@@ -201,7 +201,7 @@
     * @param statusDTOList 要导入的状态的数据传输对象列表
     * @throws VciBaseException 查询或者执行出错的时候会抛出异常
     */
    private void importStatus( Collection<OsStatusDTO> statusDTOList) throws VciBaseException{
    private void importStatus( Collection<OsStatusDTO> statusDTOList) throws Exception {
        //要导入的状态的所有英文名称
        List<String> statusIdList = new ArrayList<String>();
        Iterator<OsStatusDTO> iterator = statusDTOList.iterator();
@@ -243,7 +243,7 @@
     * @param lifeCycleDTOList 要导入的生命周期数据传输对象列表
     * @throws VciBaseException 查询或者保存出错的时候,会抛出异常
     */
    private void importLifeCycles(Collection<OsLifeCycleDTO> lifeCycleDTOList) throws VciBaseException{
    private void importLifeCycles(Collection<OsLifeCycleDTO> lifeCycleDTOList) throws VciBaseException, PLException {
        Set<String> existLifeCycleIds = lifeCycleService.selectAllLifeCycleMap().keySet();
        //生命周期的名称没有转为小写,但是平台又区分大小写
        List<String> existLifeCycleLowIds = existLifeCycleIds.stream().map(s->s.toLowerCase(Locale.ROOT)).collect(Collectors.toList());
@@ -271,7 +271,7 @@
                lifeCyle.ts = VciDateUtil.getNowString(VciDateUtil.DateTimeMillFormat);
                lifeCyle.name = lifeCycleDTO.getId();
            }else {
                lifeCyle = lifeCycleService.lifeCycleVO2DO( allLifeCycleLowMap.get(lifeCycleId));
                lifeCyle = lifeCycleService.lifeCycleVO2DO(allLifeCycleLowMap.get(lifeCycleId));
                edit = true;
            }
            lifeCyle.tag = lifeCycleDTO.getName();
@@ -735,7 +735,7 @@
                OsBtmTypeAttributeVO idAttrVO = new OsBtmTypeAttributeVO();
                idAttrVO.setId("id");
                idAttrVO.setName("编号");
                idAttrVO.setAttrDataType(VciFieldTypeEnum.VTString.name());
                idAttrVO.setAttributeDataType(VciFieldTypeEnum.VTString.name());
                idAttrVO.setAttributeLength(50);
                idAttrVO.setNullableFlag(true);
                attributes.add(idAttrVO);
@@ -743,7 +743,7 @@
                OsBtmTypeAttributeVO nameAttrVO = new OsBtmTypeAttributeVO();
                nameAttrVO.setId("name");
                nameAttrVO.setName("名称");
                nameAttrVO.setAttrDataType(VciFieldTypeEnum.VTString.name());
                nameAttrVO.setAttributeDataType(VciFieldTypeEnum.VTString.name());
                nameAttrVO.setAttributeLength(50);
                nameAttrVO.setNullableFlag(true);
                attributes.add(nameAttrVO);
@@ -751,7 +751,7 @@
                OsBtmTypeAttributeVO descAttrVO = new OsBtmTypeAttributeVO();
                descAttrVO.setId("description");
                descAttrVO.setName("描述");
                descAttrVO.setAttrDataType(VciFieldTypeEnum.VTString.name());
                descAttrVO.setAttributeDataType(VciFieldTypeEnum.VTString.name());
                descAttrVO.setAttributeLength(150);
                descAttrVO.setNullableFlag(true);
                attributes.add(descAttrVO);
@@ -762,7 +762,14 @@
                    attributes.stream().forEach( t -> {
                        int index = indexMap.get("index");
                        Map<String,Object> columnData = attributeToWordMap(t,index);
                        Map<String,Object> columnData = null;
                        try {
                            columnData = attributeToWordMap(t,index);
                        } catch (PLException e) {
                            e.printStackTrace();
                            String exceptionMessage = "将属性对象拷贝到word数据对象中时出现错误,原因:"+VciBaseUtil.getExceptionMessage(e);
                            logger.error(exceptionMessage);
                        }
                        indexMap.put("index",index+1);
                        columnDataList.add(columnData);
                    });
@@ -794,7 +801,7 @@
                List<OsBtmTypeAttributeVO> attributes = new ArrayList<>();
                linkAttributes.stream().forEach(t -> {
                    OsBtmTypeAttributeVO attributeVO = new OsBtmTypeAttributeVO();
                    BeanUtil.convert(t,attributeVO);
                    BeanUtilForVCI.convert(t,attributeVO);
                    attributeVO.setPkBtmType(t.getPkLinkType());
                    attributes.add(attributeVO);
                });
@@ -804,7 +811,14 @@
                    indexMap.put("index",1);
                    attributes.stream().forEach( t -> {
                        int index = indexMap.get("index");
                        Map<String,Object> columnData = attributeToWordMap(t,index);
                        Map<String,Object> columnData = null;
                        try {
                            columnData = attributeToWordMap(t,index);
                        } catch (PLException e) {
                            e.printStackTrace();
                            String exceptionMessage = "将属性对象拷贝到word数据对象中时出现错误,原因:"+VciBaseUtil.getExceptionMessage(e);
                            logger.error(exceptionMessage);
                        }
                        indexMap.put("index",index+1);
                        columnDataList.add(columnData);
                    });
@@ -851,7 +865,13 @@
        if(!CollectionUtils.isEmpty(btmTypeVOList)) {
            btmTypeVOList.stream().forEach(btmTypeVO -> {
                String btmId = btmTypeVO.getId();
                List<OsBtmTypeAttributeVO> attributeVOS = btmService.listAttributeByBtmId(btmId);
                List<OsBtmTypeAttributeVO> attributeVOS = null;
                try {
                    attributeVOS = btmService.listAttributeByBtmId(btmId);
                } catch (PLException e) {
                    e.printStackTrace();
                    throw new VciBaseException(VciBaseUtil.getExceptionMessage(e));
                }
                //先是名称
                int rowIndex = index[0];
                WriteExcelData idED = new WriteExcelData(rowIndex, 0, btmId);
@@ -894,7 +914,7 @@
                    //然后属性的中文名称
                    rowDataList.add(new WriteExcelData(rowIndex, 3, attributeVO.getName()));
                    //属性的类型
                    rowDataList.add(new WriteExcelData(rowIndex, 4, VciFieldTypeEnum.getTextByValue(attributeVO.getAttrDataType())));
                    rowDataList.add(new WriteExcelData(rowIndex, 4, VciFieldTypeEnum.getTextByValue(attributeVO.getAttributeDataType())));
                    //是否可以为空
                    rowDataList.add(new WriteExcelData(rowIndex, 5, attributeVO.isNullableFlag() ? "是" : "否"));
                    //属性长度
@@ -914,7 +934,15 @@
        if(!CollectionUtils.isEmpty(linkTypeVOList)){
            linkTypeVOList.stream().forEach(linkTypeVO->{
                String linkTypeId = linkTypeVO.getId();
                List<OsLinkTypeAttributeVO> attributeVOS = linkTypeService.listAttributeByLinkId(linkTypeId);
                List<OsLinkTypeAttributeVO> attributeVOS = null;
                try {
                    attributeVOS = linkTypeService.listAttributeByLinkId(linkTypeId);
                } catch (PLException e) {
                    e.printStackTrace();
                    String errorLog = "查询链接类型时出现错误,原因:"+VciBaseUtil.getExceptionMessage(e);
                    logger.error(errorLog);
                    throw new VciBaseException(errorLog);
                }
                //先是名称
                int rowIndex = index[0];
                WriteExcelData idED = new WriteExcelData(rowIndex, 0, linkTypeId);
@@ -1057,14 +1085,14 @@
     * @param index 索引
     * @return 数据映射,key 是word里的域字段,value是对应的值
     */
    private  Map<String,Object> attributeToWordMap(OsBtmTypeAttributeVO btmTypeAttributeVO,int index){
    private  Map<String,Object> attributeToWordMap(OsBtmTypeAttributeVO btmTypeAttributeVO,int index) throws PLException {
        Map<String,Object> columnData = new HashMap<>();
        if(StringUtils.isNotBlank(wordFieldProperties.getColumnIndex())) {
            columnData.put(wordFieldProperties.getColumnIndex(), index);
        }
        columnData.put(wordFieldProperties.getColumnId(),btmTypeAttributeVO.getId().toLowerCase());
        columnData.put(wordFieldProperties.getColumnName(),btmTypeAttributeVO.getName());
        String attrDataType = btmTypeAttributeVO.getAttrDataType();
        String attrDataType = btmTypeAttributeVO.getAttributeDataType();
        String columnType = VciFieldTypeEnum.getTextByValue(attrDataType);
        if(StringUtils.isBlank(columnType)){
            columnType = "字符串";
@@ -1194,15 +1222,8 @@
        } else {
            btmItem.verRuleName = 0;
        }
        //包含的属性的数组
        List<OsBtmTypeLinkAttributesDTO> attributesDTOList = btmTypeDTO.getAttributesDTOList();
        List<String> attrIdList = new ArrayList<String>();
        if (!CollectionUtils.isEmpty(attributesDTOList)) {
            for (OsBtmTypeLinkAttributesDTO attr : attributesDTOList) {
                attrIdList.add(attr.getId().toLowerCase());
            }
        }
        btmItem.apNameArray = attrIdList.toArray(new String[0]);
        //包含的属性名称
        btmItem.apNameArray = btmTypeDTO.getApNameArray().split(",");
    }
    /**