Ldc
2024-04-07 0652600959e5e3b5796fb6e8da129704ca95347a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.vci.web.controller;
 
import com.vci.starter.web.pagemodel.BaseQueryObject;
import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.starter.web.pagemodel.DataGrid;
import com.vci.web.pageModel.*;
import com.vci.web.service.OsLinkTypeServiceI;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * 链接类型的控制器
 * @author weidy
 * @date 2022-3-26
 */
@RequestMapping("/linkTypeController")
@RestController
public class OsLinkTypeController {
 
    /**
     * 链接类型
     */
    @Autowired
    private OsLinkTypeServiceI linkTypeService;
 
    /**
     * 链接类型的列表
     * @param baseQueryObject 查询对象
     * @return 链接类型的显示对象
     */
    @GetMapping("/gridLinkType")
    public DataGrid<OsLinkTypeVO> gridLinkType(BaseQueryObject baseQueryObject){
        return linkTypeService.gridLinkType(baseQueryObject);
    }
 
    /**
     * 获取链接类型包含的属性
     * @param linkTypeOid 链接类型的主键
     * @param baseQueryObject 查询对象
     * @return 属性的信息
     */
    @GetMapping("/gridAttributeByLinkTypeOid")
    public DataGrid<OsLinkTypeAttributeVO> gridAttributeByLinkTypeOid(String linkTypeOid, BaseQueryObject baseQueryObject){
        if(StringUtils.isBlank(linkTypeOid)){
            return new DataGrid<OsLinkTypeAttributeVO>();
        }
        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> attrList = boAttrs.stream().filter(s->{
            boolean usedFlag = true;
            if(StringUtils.isNotBlank(attrId) && !s.getId().contains(attrId)){
                usedFlag = false;
            }
            if(StringUtils.isNotBlank(attrName) && !s.getName().contains(attrName)){
                usedFlag = false;
            }
            return usedFlag;
        }).collect(Collectors.toList());
        DataGrid<OsLinkTypeAttributeVO> dataGrid = new DataGrid<OsLinkTypeAttributeVO>();
        dataGrid.setTotal(attrList.size());;
        dataGrid.setData(attrList);
        return dataGrid;
    }
 
    /**
     * 检查链接类型中关联的业务类型的属性有不同的内容
     * @param linkTypeOid 链接类型的主键
     * @return 差异的属性
     */
    @PostMapping("/checkAttributeTypeDifferent")
    public BaseResult<OsBtmTypeAttributeVO> checkAttributeTypeDifferent(String linkTypeOid){
        if(StringUtils.isBlank(linkTypeOid)){
            return BaseResult.success();
        }
        List<OsBtmTypeAttributeVO> attributeVOList = linkTypeService.checkAttributeTypeDifferent(linkTypeOid);
        if(!CollectionUtils.isEmpty(attributeVOList)) {
            BaseResult result = BaseResult.fail("有不同");
            result.setData(attributeVOList);
            return result;
        }else{
            return BaseResult.success();
        }
    }
}