zj
2024-06-03 3603ecb207f7e712c635f19531e05fac4d19e53f
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package project.web.admin.controller.report;
 
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
 
import kernel.exception.BusinessException;
import kernel.util.DateUtils;
import kernel.util.JsonUtils;
import kernel.util.StringUtils;
import kernel.web.Page;
import kernel.web.PageActionSupport;
import project.Constants;
import project.web.admin.service.report.AdminAgentAllStatisticsService;
 
/**
 * 交易所_代理商报表
 */
@RestController
public class ExchangeAdminAgentAllStatisticsController extends PageActionSupport {
 
    private Logger logger = LoggerFactory.getLogger(ExchangeAdminAgentAllStatisticsController.class);
 
    @Autowired
    private AdminAgentAllStatisticsService adminAgentAllStatisticsService;
    
    private final String action = "normal/exchangeAdminAgentAllStatisticsAction!";
 
    @RequestMapping(action + "list.action")
    public ModelAndView list(HttpServletRequest request) {
        String para_party_id = request.getParameter("para_party_id");
        String start_time = request.getParameter("start_time");
        String end_time = request.getParameter("end_time");
        String para_username = request.getParameter("para_username");
 
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("statistics_agent_all_list");
        
        int pageNo = 1;
        int pageSize = 30;
        Page page = null;
        try {
            
            pageNo = this.checkAndSetPageNo(request.getParameter("pageNo"));
 
            // start_time,end_time都为空时开始初始化
            if (null == start_time && null == end_time) {
                end_time = DateUtils.format(new Date(), DateUtils.DF_yyyyMMdd);
                start_time = DateUtils.format(DateUtils.getMonthStart(new Date()), DateUtils.DF_yyyyMMdd);
            }
 
            // 如果知道某个代理商的id,进入后也不可查
            if (!StringUtils.isNotEmpty(para_party_id)) {
                para_party_id = this.getLoginPartyId();
            }
 
            page = this.adminAgentAllStatisticsService.pagedQuery(pageNo, pageSize, start_time, end_time,
                    this.getLoginPartyId(), para_username, Constants.SECURITY_ROLE_AGENT, para_party_id);
 
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            return modelAndView;
        } catch (Throwable t) {
            logger.error(" error ", t);
            modelAndView.addObject("error", "[ERROR] " + t.getMessage());
            return modelAndView;
        }
        
        modelAndView.addObject("pageNo", pageNo);
        modelAndView.addObject("pageSize", pageSize);
        modelAndView.addObject("page", page);
        modelAndView.addObject("para_party_id", para_party_id);
        modelAndView.addObject("start_time", start_time);
        modelAndView.addObject("end_time", end_time);
        modelAndView.addObject("para_username", para_username);
        return modelAndView;
    }
 
    /**
     * 导出数据到文件
     */
    @RequestMapping(action + "exportData.action")
    public ModelAndView exportData(HttpServletRequest request) {
        String pageNo = request.getParameter("pageNo");
        String start_time = request.getParameter("start_time");
        String end_time = request.getParameter("end_time");
        String para_username = request.getParameter("para_username");
        String para_party_id = request.getParameter("para_party_id");
 
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("statistics_agent_all_list");
 
        try {
            
            this.checkAndSetPageNo(pageNo);
 
            // start_time,end_time都为空时开始初始化
            if (null == start_time && null == end_time) {
                end_time = DateUtils.format(new Date(), DateUtils.DF_yyyyMMdd);
                start_time = DateUtils.format(DateUtils.getMonthStart(new Date()), DateUtils.DF_yyyyMMdd);
            }
 
            String error = this.adminAgentAllStatisticsService.loadExportData(this.getResponse(), 30,
                    start_time, end_time, this.getLoginPartyId(), para_username, Constants.SECURITY_ROLE_AGENT,
                    para_party_id);
            if (!StringUtils.isNullOrEmpty(error)) {
                throw new BusinessException(error);
            }
 
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            return modelAndView;
        } catch (IOException e) {
            logger.error("export fail:{}", e);
            modelAndView.addObject("error", "程序错误,导出异常");
            return modelAndView;
        } catch (Throwable t) {
            logger.error(" error ", t);
            modelAndView.addObject("error", "[ERROR] " + t.getMessage());
            return modelAndView;
        }
 
        return modelAndView;
    }
 
    /**
     * 获取推荐网络
     */
    @RequestMapping(action + "getReconNumNet.action")
    public String getReconNumNet(HttpServletRequest request) {
        String net_party_id = request.getParameter("net_party_id");
        
        Map<String, Object> resultMap = new HashMap<String, Object>();
        
        try {
            
            resultMap.put("code", 200);
            resultMap.put("user_reco_net", this.adminAgentAllStatisticsService.getRecoNumNetList(net_party_id));
            
        } catch (BusinessException e) {
            resultMap.put("code", 500);
            resultMap.put("message", e.getMessage());
        } catch (Throwable t) {
            logger.error(" error ", t);
            resultMap.put("code", 500);
            resultMap.put("message", "程序错误");
        }
 
        return JsonUtils.getJsonString(resultMap);
    }
 
}