Commit 51decd366881a4dd1af502b7724608c3f92daf76
1 parent
22a58301
Exists in
master
导出汇总表
Showing
1 changed file
with
96 additions
and
97 deletions
Show diff stats
backend/chkpower/src/main/java/com/hotent/chkpower/controller/WCurrentController.java
... | ... | @@ -27,113 +27,112 @@ import java.util.*; |
27 | 27 | /** |
28 | 28 | * 活期账户 前端控制器 |
29 | 29 | * |
30 | - * @company 广州宏天软件股份有限公司 | |
31 | 30 | * @author cw |
31 | + * @company 广州宏天软件股份有限公司 | |
32 | 32 | * @since 2024-07-05 |
33 | 33 | */ |
34 | 34 | @RestController |
35 | 35 | @RequestMapping("/wCurrent/v1/") |
36 | 36 | public class WCurrentController extends BaseController<WCurrentManager, WCurrent> { |
37 | 37 | |
38 | - /** | |
39 | - * 根据id获取活期账户数据详情 | |
40 | - * @param id | |
41 | - * @return | |
42 | - * @throws Exception | |
43 | - * ModelAndView | |
44 | - */ | |
45 | - @GetMapping(value="/getDetail") | |
46 | - @ApiOperation(value="根据id获取活期账户数据详情",httpMethod = "GET",notes = "根据id获取活期账户数据详情") | |
47 | - public CommonResult<WCurrent> getDetail(@ApiParam(name="id",value="业务对象主键", required = true)@RequestParam(required=true) String id) throws Exception{ | |
48 | - return CommonResult.<WCurrent>ok().value(baseService.getDetail(id)); | |
49 | - } | |
50 | - /** | |
51 | - * 新增,更新活期账户 | |
52 | - * @param wCurrent | |
53 | - * @throws Exception | |
54 | - * @return | |
55 | - * @exception | |
56 | - */ | |
57 | - @PostMapping(value="/save") | |
58 | - @ApiOperation(value = "新增,更新活期账户数据", httpMethod = "POST", notes = "新增,更新活期账户数据") | |
59 | - public CommonResult<String> save(@ApiParam(name="WCurrent",value="活期账户对象", required = true)@RequestBody WCurrent wCurrent) throws Exception{ | |
60 | - String msg = StringUtil.isEmpty(wCurrent.getId()) ? "添加活期账户成功" : "更新活期账户成功"; | |
61 | - baseService.createOrUpdate(wCurrent); | |
62 | - return CommonResult.<String>ok().message(msg); | |
63 | - } | |
64 | - | |
65 | - @GetMapping(value="/getHistoricalDetail") | |
66 | - public CommonResult getHistoricalDetail() throws Exception{ | |
67 | - List<WCurrent> data = baseService.getHistoricalDetail(); | |
68 | - return new CommonResult(true, "成功", data); | |
69 | - } | |
70 | - | |
71 | - /** | |
72 | - * 导出 | |
73 | - * @param response | |
74 | - * @throws Exception | |
75 | - */ | |
76 | - @GetMapping("exportYchzb") | |
77 | - public void exportYchzb(HttpServletResponse response) throws Exception { | |
78 | - String date="2024-07-04"; | |
79 | - HashMap map=new HashMap(); | |
80 | - map.put("date",date); | |
81 | - List<String> gslxList = baseService.getCurrentOrgTypeList(); | |
82 | - List<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>(); | |
83 | - BigDecimal hz = new BigDecimal(0.00); | |
84 | - for (String orgType : gslxList) { | |
85 | - List<HashMap<String,String>> listData = baseService.getCurrentAccountBalanceList(orgType,date+" 00:00:00"); | |
86 | - | |
87 | - BigDecimal totalBalance = listData.stream() | |
88 | - .filter(d -> d.containsKey("F_account_balance")) // 确保键存在 | |
89 | - .map(d -> { | |
90 | - Object value = d.get("F_account_balance"); | |
91 | - if (value instanceof Number) { | |
92 | - return new BigDecimal(value.toString()); | |
93 | - } | |
94 | - return new BigDecimal(0.00); | |
95 | - }) | |
96 | - .filter(Objects::nonNull) // 确保值非空 | |
97 | - .reduce(BigDecimal.ZERO, BigDecimal::add); // 计算总和 | |
38 | + /** | |
39 | + * 根据id获取活期账户数据详情 | |
40 | + * | |
41 | + * @param id | |
42 | + * @return | |
43 | + * @throws Exception ModelAndView | |
44 | + */ | |
45 | + @GetMapping(value = "/getDetail") | |
46 | + @ApiOperation(value = "根据id获取活期账户数据详情", httpMethod = "GET", notes = "根据id获取活期账户数据详情") | |
47 | + public CommonResult<WCurrent> getDetail(@ApiParam(name = "id", value = "业务对象主键", required = true) @RequestParam(required = true) String id) throws Exception { | |
48 | + return CommonResult.<WCurrent>ok().value(baseService.getDetail(id)); | |
49 | + } | |
98 | 50 | |
51 | + /** | |
52 | + * 新增,更新活期账户 | |
53 | + * | |
54 | + * @param wCurrent | |
55 | + * @return | |
56 | + * @throws Exception | |
57 | + * @throws | |
58 | + */ | |
59 | + @PostMapping(value = "/save") | |
60 | + @ApiOperation(value = "新增,更新活期账户数据", httpMethod = "POST", notes = "新增,更新活期账户数据") | |
61 | + public CommonResult<String> save(@ApiParam(name = "WCurrent", value = "活期账户对象", required = true) @RequestBody WCurrent wCurrent) throws Exception { | |
62 | + String msg = StringUtil.isEmpty(wCurrent.getId()) ? "添加活期账户成功" : "更新活期账户成功"; | |
63 | + baseService.createOrUpdate(wCurrent); | |
64 | + return CommonResult.<String>ok().message(msg); | |
65 | + } | |
99 | 66 | |
100 | - if (listData!=null && listData.size()>0){ | |
67 | + @GetMapping(value = "/getHistoricalDetail") | |
68 | + public CommonResult getHistoricalDetail() throws Exception { | |
69 | + List<WCurrent> data = baseService.getHistoricalDetail(); | |
70 | + return new CommonResult(true, "成功", data); | |
71 | + } | |
101 | 72 | |
102 | - HashMap<String, String> hzMap = new HashMap<>(); | |
103 | - hzMap.put("F_org_type","小计"); | |
104 | - hzMap.put("F_org_name",""); | |
105 | - hzMap.put("F_account_balance",String.valueOf(totalBalance)); | |
106 | - hz=hz.add(totalBalance); | |
107 | - listData.add(hzMap); | |
108 | - } | |
109 | - list.addAll(listData); | |
110 | - } | |
111 | - HashMap<String, String> hzMap = new HashMap<>(); | |
112 | - hzMap.put("F_org_type","汇总"); | |
113 | - hzMap.put("F_org_name",""); | |
114 | - hzMap.put("F_account_balance",String.valueOf(hz)); | |
115 | - list.add(hzMap); | |
73 | + /** | |
74 | + * 导出 | |
75 | + * | |
76 | + * @param response | |
77 | + * @throws Exception | |
78 | + */ | |
79 | + @GetMapping("exportYchzb") | |
80 | + public void exportYchzb(HttpServletResponse response, String date) throws Exception { | |
81 | +// date="2024-07-04"; | |
82 | + HashMap map = new HashMap(); | |
83 | + map.put("date", date); | |
84 | + List<String> gslxList = baseService.getCurrentOrgTypeList(); | |
85 | + List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); | |
86 | + BigDecimal hz = new BigDecimal(0.00); | |
87 | + for (String orgType : gslxList) { | |
88 | + List<HashMap<String, String>> listData = baseService.getCurrentAccountBalanceList(orgType, date + " 00:00:00"); | |
89 | + BigDecimal totalBalance = listData.stream() | |
90 | + .filter(d -> d.containsKey("F_account_balance")) // 确保键存在 | |
91 | + .map(d -> { | |
92 | + Object value = d.get("F_account_balance"); | |
93 | + if (value instanceof Number) { | |
94 | + return new BigDecimal(value.toString()); | |
95 | + } | |
96 | + return new BigDecimal(0.00); | |
97 | + }) | |
98 | + .filter(Objects::nonNull) // 确保值非空 | |
99 | + .reduce(BigDecimal.ZERO, BigDecimal::add); // 计算总和 | |
100 | + if (listData != null && listData.size() > 0) { | |
101 | + HashMap<String, String> hzMap = new HashMap<>(); | |
102 | + hzMap.put("F_org_type", "小计"); | |
103 | + hzMap.put("F_org_name", ""); | |
104 | + hzMap.put("F_account_balance", String.valueOf(totalBalance)); | |
105 | + hz = hz.add(totalBalance); | |
106 | + listData.add(hzMap); | |
107 | + } | |
108 | + list.addAll(listData); | |
109 | + } | |
110 | + HashMap<String, String> hzMap = new HashMap<>(); | |
111 | + hzMap.put("F_org_type", "汇总"); | |
112 | + hzMap.put("F_org_name", ""); | |
113 | + hzMap.put("F_account_balance", String.valueOf(hz)); | |
114 | + list.add(hzMap); | |
116 | 115 | |
117 | - map.put("list",list); | |
118 | - TemplateExportParams params = new TemplateExportParams("doc/hqzhAll.xls"); | |
119 | - params.setColForEach(true); | |
120 | - Workbook workbook = ExcelExportUtil.exportExcel(params, map); | |
121 | - String filedisplay="正常账户可用余额.xls"; | |
122 | - response.setContentType("APPLICATION/OCTET-STREAM"); | |
123 | - response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); | |
124 | - response.addHeader("Content-Disposition", "attachment;filename="+ URLEncoder.encode(filedisplay, "utf-8") ); | |
125 | - OutputStream os = null; | |
126 | - try { | |
127 | - os = response.getOutputStream(); | |
128 | - workbook.write(os); | |
129 | - os.flush(); | |
130 | - os.close(); | |
131 | - } catch (Exception e) { | |
132 | - e.printStackTrace(); | |
133 | - } finally { | |
134 | - if (os != null) | |
135 | - os.close(); | |
136 | - } | |
137 | - } | |
116 | + map.put("list", list); | |
117 | + TemplateExportParams params = new TemplateExportParams("doc/hqzhAll.xls"); | |
118 | + params.setColForEach(true); | |
119 | + Workbook workbook = ExcelExportUtil.exportExcel(params, map); | |
120 | + String filedisplay = "正常账户可用余额.xls"; | |
121 | + response.setContentType("APPLICATION/OCTET-STREAM"); | |
122 | + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); | |
123 | + response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filedisplay, "utf-8")); | |
124 | + OutputStream os = null; | |
125 | + try { | |
126 | + os = response.getOutputStream(); | |
127 | + workbook.write(os); | |
128 | + os.flush(); | |
129 | + os.close(); | |
130 | + } catch (Exception e) { | |
131 | + e.printStackTrace(); | |
132 | + } finally { | |
133 | + if (os != null) | |
134 | + os.close(); | |
135 | + } | |
136 | + } | |
138 | 137 | |
139 | 138 | } | ... | ... |