dangsn
2024-12-03 d0ae279ff3b83358d1c07f4481a041c4ad335026
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLinkTypeController.java
@@ -5,7 +5,7 @@
import com.vci.pagemodel.OsBtmTypeAttributeVO;
import com.vci.pagemodel.OsLinkTypeAttributeVO;
import com.vci.pagemodel.OsLinkTypeVO;
import com.vci.starter.web.annotation.controller.VciUnCheckRight;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.BaseQueryObject;
import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.starter.web.pagemodel.DataGrid;
@@ -17,12 +17,13 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@@ -85,7 +86,15 @@
        String attrId = baseQueryObject.getConditionMap().containsKey("name")?baseQueryObject.getConditionMap().get("name").replace("*",""):"";
        String attrName = baseQueryObject.getConditionMap().containsKey("label") ? baseQueryObject.getConditionMap().get("label").replace("*","") : "";
        OsLinkTypeVO linkTypeVO = linkTypeService.selectByOid(linkTypeOid);
        List<OsLinkTypeAttributeVO> boAttrs = linkTypeService.listAttributeByLinkId(linkTypeVO.getId());
        List<OsLinkTypeAttributeVO> boAttrs = null;
        try {
            boAttrs = linkTypeService.listAttributeByLinkId(linkTypeVO.getId());
        }catch (Exception e){
            e.printStackTrace();
            String errorLog = "查询链接类型关联的属性时出现错误,原因:"+VciBaseUtil.getExceptionMessage(e);
            logger.error(errorLog);
            throw new VciBaseException(errorLog);
        }
        List<OsLinkTypeAttributeVO> attrList = boAttrs.stream().filter(s->{
            boolean usedFlag = true;
            if(StringUtils.isNotBlank(attrId) && !s.getId().contains(attrId)){
@@ -100,6 +109,27 @@
        dataGrid.setTotal(attrList.size());;
        dataGrid.setData(attrList);
        return dataGrid;
    }
    /**
     * 获取链接类型包含的属性
     * @param name 链接类型的编号
     * @return 属性的信息
     */
    @GetMapping("/getAllAttributeByLink")
    public BaseResult<List<OsLinkTypeAttributeVO>> getAllAttributeByLink(String name){
        try {
            List<OsLinkTypeAttributeVO> osLinkTypeAttributeVOS = linkTypeService.getAllAttributeByLink(name);
            return BaseResult.dataList(osLinkTypeAttributeVOS);
        } catch (PLException e) {
            BaseResult objectBaseResult = new BaseResult<>();
            objectBaseResult.setCode(Integer.parseInt(e.code));
            objectBaseResult.setMsg(Arrays.toString(e.messages));
            return objectBaseResult;
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }
    /**
@@ -146,7 +176,7 @@
     * addFlag 是否为新增 true新增,false修改
     * @return 保存结果
     */
    @GetMapping("/addAndEditLink")
    @PostMapping("/addAndEditLink")
    public BaseResult addAndEditLink(@RequestBody LinkType linkType, Boolean addFlag){
        try {
            return linkTypeService.addAndEditLink(linkType, addFlag);
@@ -227,4 +257,52 @@
            return objectBaseResult;
        }
    }
    /**
     * 导出链接类型
     * name 链接类型名称
     * @return
     */
    @GetMapping("/expData")
    public void expData(String name,HttpServletResponse response) throws PLException, IOException {
        linkTypeService.expData(name, response);
    }
    /**
     * 导入链接类型
     * @param file 上传的文件
     * @return
     */
    @PostMapping("/impData")
    public BaseResult impData(MultipartFile file){
        try {
             return linkTypeService.impData(file);
        }catch (Throwable e) {
            throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e);
        }
    }
    /**
     * 获取设置排序字段的排序字段
     * @param linkType 链接类型的编号
     * @param btmType 业务类型的编号
     * @param direction 正/反向
     * @return 属性的信息
     */
    @GetMapping("/getAllOrderbyAttributeByLink")
    public BaseResult<List<String>> getAllOrderbyAttributeByLink(String linkType, String btmType, String direction){
        try {
            List<String> osLinkTypeAttributes = linkTypeService.getAllOrderbyAttributeByLink(linkType, btmType, direction);
            return BaseResult.dataList(osLinkTypeAttributes);
        } catch (PLException e) {
            BaseResult objectBaseResult = new BaseResult<>();
            objectBaseResult.setCode(Integer.parseInt(e.code));
            objectBaseResult.setMsg(Arrays.toString(e.messages));
            return objectBaseResult;
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }
}