刘光辉
15 小时以前 34981c30a78e8bbd7791131059a9210f9928b62c
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
package jnpf.base.util;
 
import com.alibaba.fastjson.JSONObject;
import jnpf.config.ConfigValueUtil;
import jnpf.util.UserProvider;
import jnpf.util.wxutil.HttpUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.ArrayList;
import java.util.List;
 
@Slf4j
@Component
@RequiredArgsConstructor
public class ReportExportUtil {
 
    private final ConfigValueUtil configValueUtil;
 
    private String getFlowAbleUrl(boolean isOld) {
        return isOld ? configValueUtil.getOldReportDomain() : configValueUtil.getReportDomain();
    }
 
    public List<Object> getExportList(String systemId) {
        List<Object> list = new ArrayList<>();
        try {
            String url = getFlowAbleUrl(false) + "/api/Report/getExportList?systemId=" + systemId;
            JSONObject jsonObject = HttpUtil.httpRequest(url, "GET", null, UserProvider.getToken());
            if (jsonObject == null || jsonObject.getInteger("code") == 200) {
                list = (List<Object>) jsonObject.get("data");
            }
        } catch (Exception e) {
            log.error(e.getMessage());
        }
        return list;
    }
 
    public boolean importCopy(List<Object> list, String systemId) {
        try {
            String url = getFlowAbleUrl(false) + "/api/Report/importCopy";
            JSONObject body = new JSONObject();
            body.put("list", list);
            body.put("systemId", systemId);
            JSONObject jsonObject = HttpUtil.httpRequest(url, "POST", body.toJSONString(), UserProvider.getToken());
            if (jsonObject == null || jsonObject.getInteger("code") == 200) {
                return true;
            }
        } catch (Exception e) {
            log.error(e.getMessage());
        }
        return false;
    }
 
    public void deleteBySystemId(String systemId) {
        String url = getFlowAbleUrl(false) + "/api/Report/deleteBySystemId?systemId=" + systemId;
        HttpUtil.httpRequest(url, "GET", null, UserProvider.getToken());
    }
 
    //++++++++++++++++++++++++++++++++旧报表接口++++++++++++++++++++++++++++++++
 
    public List<Object> getExportListOld(String systemId) {
        List<Object> list = new ArrayList<>();
        try {
            String url = getFlowAbleUrl(true) + "/Data/getExportList?systemId=" + systemId;
            JSONObject jsonObject = HttpUtil.httpRequest(url, "GET", null, UserProvider.getToken());
            if (jsonObject == null || jsonObject.getInteger("code") == 200) {
                list = (List<Object>) jsonObject.get("data");
            }
        } catch (Exception e) {
            log.error(e.getMessage());
        }
        return list;
    }
 
    public boolean importCopyOld(List<Object> list, String systemId) {
        try {
            String url = getFlowAbleUrl(true) + "/Data/importCopy";
            JSONObject body = new JSONObject();
            body.put("list", list);
            body.put("systemId", systemId);
            JSONObject jsonObject = HttpUtil.httpRequest(url, "POST", body.toJSONString(), UserProvider.getToken());
            if (jsonObject == null || jsonObject.getInteger("code") == 200) {
                return true;
            }
        } catch (Exception e) {
            log.error(e.getMessage());
        }
        return false;
    }
 
    public void deleteBySystemIdOld(String systemId) {
        String url = getFlowAbleUrl(true) + "/Data/deleteBySystemId?systemId=" + systemId;
        HttpUtil.httpRequest(url, "GET", null, UserProvider.getToken());
    }
}