wangting
2024-11-14 c162f50f97a418ec10f0dd48d9e4c34e392c4281
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package com.vci.test;
 
import com.vci.starter.web.annotation.controller.VciUnCheckRight;
import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.starter.web.pagemodel.Tree;
import com.vci.web.service.WebBoServiceI;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * @Description 测试控制器
 * @Author dangsn
 * @Date 2024/11/14 10:08
 */
@RestController
@RequestMapping("/dataTestController")
public class DataTestController {
 
    @Resource
    private WebBoServiceI boServiceI;
 
    /**
     * 获取产品
     * @return
     */
    @VciUnCheckRight
    @GetMapping("/getProduct")
    public BaseResult getProduct(){
        String sql = "select * from platformbtm_workcontext where workcontexttype = 'product'";
        List<Map> productList = boServiceI.queryByOnlySqlForMap(sql);
        BaseResult baseResult = new BaseResult();
        baseResult.setSuccess(true);
        baseResult.setCode(200);
        baseResult.setData(productList);
        return baseResult;
    }
 
    /**
     * 获取ebom信息
     * @param parentOid 上级信息
     * @return
     */
    @VciUnCheckRight
    @GetMapping("/getEbomInfo")
    public BaseResult getEbomInfo(String productNo, String productOid, String parentOid){
        if(StringUtils.isBlank(productNo)){
            return BaseResult.fail("产品编号为空!");
        }
        if(StringUtils.isBlank(productOid)){
            return BaseResult.fail("产品主键为空!");
        }
        BaseResult baseResult = new BaseResult();
        List<Map> ebomList;
        if(StringUtils.isBlank(parentOid)){
            String sql = "select * from platformbtm_part t where t.ownproduct = '"+productOid+"' and t.code = '"+productNo+"'";
            ebomList = boServiceI.queryByOnlySqlForMap(sql);
 
        }else{
            String sql = "select p.*,e.oid as eoid from platformbtm_part p left join platformlt_ebom e on p.oid = e.t_oid \n" +
                    "where e.f_oid = '"+parentOid+"' and e.workcontextoid = '"+productOid+"' \n" +
                    "and p.islastr = '1' and p.islastv = '1' order by p.code asc";
            ebomList = boServiceI.queryByOnlySqlForMap(sql);
        }
        List<Tree> treeList = new ArrayList<>();
        if(!CollectionUtils.isEmpty(ebomList)){
            for(Map ebom : ebomList){
                String oid = ebom.get("OID").toString();
                String id = ebom.get("CODE").toString();
                String name = ebom.get("NAME").toString();
                String revisionvalue = ebom.get("REVISIONVALUE").toString();
                String versionrule = ebom.get("VERSIONRULE").toString();
                String versionvalue = ebom.get("VERSIONVALUE").toString();
                String parttype = ebom.get("PARTTYPE").toString();
                String lcStatus = ebom.get("LCSTATUS").toString();
                String parttypetext = "";
                String lcStatusText = "";
                if(parttype.equals("20")){
                    parttypetext = "产品";
                }
                if(parttype.equals("6")){
                    parttypetext = "装配件";
                }
                if(parttype.equals("7")){
                    parttypetext = "零件";
                }
                if(parttype.equals("8")){
                    parttypetext = "标准件";
                }
                if(lcStatus.equals("Editing")){
                    lcStatusText = "编辑中";
                }
                if(lcStatus.equals("Published")){
                    lcStatusText = "已发布";
                }
                Tree tree = new Tree();
                tree.setLeaf(false);
                tree.setExpanded(false);
                tree.setOid(oid);
                tree.setId(id);
                tree.setText(id+" "+name+"["+parttypetext+"]["+revisionvalue+versionrule+versionvalue+"]【"+lcStatusText+"】");
                if(StringUtils.isNotBlank(parentOid)){
                    tree.setParentId(parentOid);
                }
                if(ebom.containsKey("EOID")){
                    Map<String, String> atrrMap = new HashMap<>();
                    atrrMap.put("eoid", ebom.get("EOID").toString());
                    tree.setAttributes(atrrMap);
                }
                treeList.add(tree);
            }
        }
        baseResult.setData(treeList);
        baseResult.setSuccess(true);
        baseResult.setCode(200);
        return baseResult;
    }
}