Commit 35970915983d55d9c67cdc8d50949922797ddf1f

Authored by llw
2 parents 4f4bb6cc a7df42fc

Merge branch 'branch_0808' of

http://192.168.1.195:9998/ZTEITS-Developers/zteits-bcp-portal.git into
branch_0808

Conflicts:
	src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/MonthBillManagementController.java
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/MonthBillManagementController.java
1 /** 1 /**
2 - * 2 + *
3 */ 3 */
4 package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; 4 package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic;
5 5
6 -import java.io.IOException;  
7 -import java.math.BigDecimal;  
8 -import java.net.URLEncoder;  
9 import java.text.SimpleDateFormat; 6 import java.text.SimpleDateFormat;
10 import java.util.ArrayList; 7 import java.util.ArrayList;
11 import java.util.Date; 8 import java.util.Date;
12 import java.util.List; 9 import java.util.List;
13 10
14 -import javax.servlet.ServletOutputStream;  
15 import javax.servlet.http.HttpServletRequest; 11 import javax.servlet.http.HttpServletRequest;
16 import javax.servlet.http.HttpServletResponse; 12 import javax.servlet.http.HttpServletResponse;
17 import javax.servlet.http.HttpSession; 13 import javax.servlet.http.HttpSession;
18 14
19 -import org.apache.poi.xssf.usermodel.XSSFSheet;  
20 -import org.apache.poi.xssf.usermodel.XSSFWorkbook;  
21 -import org.slf4j.Logger;  
22 -import org.slf4j.LoggerFactory;  
23 -import org.springframework.beans.factory.annotation.Autowired;  
24 -import org.springframework.beans.factory.annotation.Value;  
25 -import org.springframework.stereotype.Controller;  
26 -import org.springframework.web.bind.annotation.GetMapping;  
27 -import org.springframework.web.bind.annotation.PostMapping;  
28 -import org.springframework.web.bind.annotation.RequestBody;  
29 -import org.springframework.web.bind.annotation.RequestMapping;  
30 -import org.springframework.web.bind.annotation.RequestParam;  
31 -import org.springframework.web.bind.annotation.ResponseBody;  
32 -import org.springframework.web.bind.annotation.RestController;  
33 -  
34 import com.alibaba.dubbo.common.utils.CollectionUtils; 15 import com.alibaba.dubbo.common.utils.CollectionUtils;
35 import com.alibaba.dubbo.common.utils.StringUtils; 16 import com.alibaba.dubbo.common.utils.StringUtils;
36 import com.alibaba.fastjson.JSONArray; 17 import com.alibaba.fastjson.JSONArray;
37 import com.alibaba.fastjson.JSONObject; 18 import com.alibaba.fastjson.JSONObject;
38 -import com.clouds.common.constants.SessionEnum; 19 +
39 import com.clouds.common.entity.UserInfo; 20 import com.clouds.common.entity.UserInfo;
40 import com.clouds.common.utils.AmountUtils; 21 import com.clouds.common.utils.AmountUtils;
41 import com.clouds.common.utils.DateUtil; 22 import com.clouds.common.utils.DateUtil;
@@ -52,8 +33,6 @@ import com.zteits.clouds.api.apibase.bean.BizResult; @@ -52,8 +33,6 @@ import com.zteits.clouds.api.apibase.bean.BizResult;
52 import com.zteits.clouds.api.apibase.bean.PageBean; 33 import com.zteits.clouds.api.apibase.bean.PageBean;
53 import com.zteits.clouds.api.apibase.constants.ErrorType; 34 import com.zteits.clouds.api.apibase.constants.ErrorType;
54 import com.zteits.clouds.api.apibase.exception.BizException; 35 import com.zteits.clouds.api.apibase.exception.BizException;
55 -import com.zteits.clouds.api.dto.clouds.dto.BillManageDTO;  
56 -import com.zteits.clouds.api.dto.clouds.dto.BillManageDetailDTO;  
57 import com.zteits.clouds.api.dto.clouds.dto.BillManageDetailForMonthDTO; 36 import com.zteits.clouds.api.dto.clouds.dto.BillManageDetailForMonthDTO;
58 import com.zteits.clouds.api.dto.clouds.dto.BillManageForMonthDTO; 37 import com.zteits.clouds.api.dto.clouds.dto.BillManageForMonthDTO;
59 import com.zteits.clouds.api.dto.clouds.dto.BillManageForMonthDetailDTO; 38 import com.zteits.clouds.api.dto.clouds.dto.BillManageForMonthDetailDTO;
@@ -68,515 +47,519 @@ import com.zteits.clouds.api.dto.pay.param.YearMonthCardStatisticRequest; @@ -68,515 +47,519 @@ import com.zteits.clouds.api.dto.pay.param.YearMonthCardStatisticRequest;
68 import com.zteits.clouds.api.service.clouds.MonthBillManagementService; 47 import com.zteits.clouds.api.service.clouds.MonthBillManagementService;
69 import com.zteits.clouds.api.service.clouds.YearMonthCardStatisticService; 48 import com.zteits.clouds.api.service.clouds.YearMonthCardStatisticService;
70 import com.zteits.clouds.api.service.pay.TdCustCompanyService; 49 import com.zteits.clouds.api.service.pay.TdCustCompanyService;
71 -  
72 import io.swagger.annotations.Api; 50 import io.swagger.annotations.Api;
73 import io.swagger.annotations.ApiOperation; 51 import io.swagger.annotations.ApiOperation;
  52 +import org.apache.poi.xssf.usermodel.XSSFSheet;
  53 +import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  54 +import org.slf4j.Logger;
  55 +import org.slf4j.LoggerFactory;
  56 +import org.springframework.beans.factory.annotation.Autowired;
  57 +import org.springframework.beans.factory.annotation.Value;
  58 +import org.springframework.stereotype.Controller;
  59 +import org.springframework.web.bind.annotation.GetMapping;
  60 +import org.springframework.web.bind.annotation.PostMapping;
  61 +import org.springframework.web.bind.annotation.RequestBody;
  62 +import org.springframework.web.bind.annotation.RequestMapping;
  63 +import org.springframework.web.bind.annotation.RequestParam;
  64 +import org.springframework.web.bind.annotation.ResponseBody;
74 65
75 /** 66 /**
76 * @author hxz 67 * @author hxz
77 - *  
78 */ 68 */
79 @Api(value = "结算管理 账单管理 月账单管理", description = "停车场云平台 月账单管理") 69 @Api(value = "结算管理 账单管理 月账单管理", description = "停车场云平台 月账单管理")
80 @Controller 70 @Controller
81 @RequestMapping("/monthbill") 71 @RequestMapping("/monthbill")
82 public class MonthBillManagementController extends BizController { 72 public class MonthBillManagementController extends BizController {
83 - private static final Logger logger = LoggerFactory.getLogger(MonthBillManagementController.class);  
84 -  
85 - @Autowired  
86 - private MonthBillManagementService monthBillManagementService;  
87 - @Autowired  
88 - private YearMonthCardStatisticService yearMonthCardStatisticService;  
89 -  
90 - @Autowired  
91 - private TdCustCompanyService tdCustCompanyService;  
92 - @Autowired  
93 - private HttpSession session;  
94 - @Autowired  
95 - private SessionCommUtil sessionCommUtil;  
96 - @Value("${project.syscode}")  
97 - private String sysCode;  
98 -  
99 - @ApiOperation("月账单查询汇总统计")  
100 - @PostMapping("/summaryStatistic")  
101 - @ResponseBody  
102 - public BizResultVO<MonthBillSummaryStatisticDTO> getMonthBillSummaryStatistic(  
103 - @RequestBody MonthBillRequest request) {  
104 - logger.info("月账单查询汇总统计请求对象 req={}", JSONObject.toJSONString(request));  
105 - BizResult<MonthBillSummaryStatisticDTO> respondResult = monthBillManagementService  
106 - .getMonthBillSummaryStatistic(request);  
107 - logger.info("月账单查询汇总统计响应结果 respondResult={}", JSONObject.toJSONString(respondResult));  
108 - return new BizResultVO<>(respondResult);  
109 - }  
110 -  
111 - /**  
112 - * 临停收费, 按支付方式汇总统计,tp表示临停  
113 - *  
114 - * @param request  
115 - */  
116 - @ApiOperation("临停收费, 按支付方式汇总统计,tp表示临停")  
117 - @PostMapping("/tpStatistic")  
118 - @ResponseBody  
119 - public BizResultVO<MonthBillMngtStatisticDTO> getMonthBillMngtTPStatistic(@RequestBody MonthBillRequest request) {  
120 - logger.info("临停收费, 按支付方式汇总统计 req={}", JSONObject.toJSONString(request));  
121 - BizResult<MonthBillMngtStatisticDTO> respondResult = monthBillManagementService  
122 - .getMonthBillMngtTPStatistic(request);  
123 - logger.info("临停收费, 按支付方式汇总统计 respondResult={}", JSONObject.toJSONString(respondResult));  
124 - return new BizResultVO<>(respondResult);  
125 - }  
126 -  
127 - /**  
128 - * <!-- 临停收费,按照停车场分组后,按支付方式分类统计 TP ByParkinglot-->  
129 - *  
130 - * @param request  
131 - * @return  
132 - */  
133 - @ApiOperation("临停收费, 按照停车场分组后,按支付方式分类统计,tp表示临停,Pklt表示停车场")  
134 - @PostMapping("/tpPkltStatistic")  
135 - @ResponseBody  
136 - BizResultVO<List<MonthBillMngtStatisticByParkinglotDTO>> getMonthBillMngtTPStatisticByParkinglot(  
137 - @RequestBody MonthBillRequest request) {  
138 - logger.info("临停收费, 停车场分组,按支付方式分类 req={}", JSONObject.toJSONString(request));  
139 - BizResult<List<MonthBillMngtStatisticByParkinglotDTO>> respondResult = monthBillManagementService  
140 - .getMonthBillMngtTPStatisticByParkinglot(request);  
141 - logger.info("临停收费, 停车场分组,按支付方式分类respondResult={}", JSONObject.toJSONString(respondResult));  
142 - return new BizResultVO<>(respondResult);  
143 - }  
144 -  
145 - /**  
146 - * <!-- 月卡、年卡, 按支付方式汇总统计 CardMY-->  
147 - *  
148 - * @param request  
149 - * @return  
150 - */  
151 - @ApiOperation("月卡、年卡, 按支付方式汇总统计")  
152 - @PostMapping("/cardStatistic")  
153 - @ResponseBody  
154 - BizResultVO<MonthBillMngtStatisticDTO> getMonthBillMngtCardMYStatistic(@RequestBody MonthBillRequest request) {  
155 - logger.info("月卡、年卡, 按支付方式分类 req={}", JSONObject.toJSONString(request));  
156 - BizResult<MonthBillMngtStatisticDTO> respondResult = monthBillManagementService  
157 - .getMonthBillMngtCardMYStatistic(request);  
158 - logger.info("月卡、年卡, 按支付方式分类respondResult={}", JSONObject.toJSONString(respondResult));  
159 - return new BizResultVO<>(respondResult);  
160 - }  
161 -  
162 - /**  
163 - * <!-- 月卡、年卡,按照停车场分组后,按支付方式分类统计CardMY ByParkinglot-->  
164 - *  
165 - * @param request  
166 - * @return  
167 - */  
168 - @ApiOperation("月卡、年卡, 按支付方式汇总统计,Pklt表示停车场")  
169 - @PostMapping("/cardPkltStatistic")  
170 - @ResponseBody  
171 - BizResultVO<List<MonthBillMngtStatisticByParkinglotDTO>> getMonthBillMngtCardMYStatisticByParkinglot(  
172 - @RequestBody MonthBillRequest request) {  
173 - logger.info("月卡、年卡, 停车场分组,按支付方式分类 req={}", JSONObject.toJSONString(request));  
174 - BizResult<List<MonthBillMngtStatisticByParkinglotDTO>> respondResult = monthBillManagementService  
175 - .getMonthBillMngtCardMYStatisticByParkinglot(request);  
176 - logger.info("月卡、年卡, 停车场分组,按支付方式分类respondResult={}", JSONObject.toJSONString(respondResult));  
177 - return new BizResultVO<>(respondResult);  
178 - }  
179 -  
180 - // ----------------------------------------------------2017-8-1新添加-----------------------------------------------  
181 -  
182 - /**  
183 - *  
184 - * @param request  
185 - * @return  
186 - * @throws Exception  
187 - */  
188 - @ApiOperation("月账单管理统计列表")  
189 - @PostMapping("/queryBillforMonthList")  
190 - @ResponseBody  
191 - public BizResultVO<EasyUIDataGridVO<BillManageForMonthDTO>> queryBillforMonthList(  
192 - @RequestBody BillQueryRequest billQueryRequest, HttpServletRequest request, HttpServletResponse response)  
193 - throws Exception {  
194 - // 2.调用接口查询当前登录人管辖的停车场名称  
195 - UserInfo userInfo = sessionCommUtil.getUserInfo();  
196 - List<String> plNos = new ArrayList<>();  
197 - if (userInfo != null) {  
198 - TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest();  
199 - tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds());  
200 - tdCompanyParkQueryRequest.setSessionId(session.getId());  
201 - tdCompanyParkQueryRequest.setSysCode(sysCode);  
202 - BizResult<List<String>> bizResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest);  
203 - // 拥有的停车场编号  
204 - plNos = ResultUtils.getBizResultData(bizResult);  
205 - }  
206 -// if (CollectionUtils.isEmpty(plNos)) {  
207 -// throw new BizException(ErrorType.PARK_LOT_NOT_EXISTS, "停车场plnos不存在");  
208 -// }  
209 - billQueryRequest.setParkIdList(plNos);  
210 - logger.info("月账单管理统计列表 req={}", JSONObject.toJSONString(billQueryRequest));  
211 - BizResult<List<BillManageForMonthDTO>> respondResult = monthBillManagementService  
212 - .queryBillforMonthList(billQueryRequest);  
213 - logger.info("月账单管理统计列表 respondResult={}", JSONObject.toJSONString(respondResult));  
214 - return returnJqGridDataByList(respondResult, BillManageForMonthDTO.class);  
215 - }  
216 -  
217 - /**  
218 - *  
219 - * @param request  
220 - * @return  
221 - */  
222 - @ApiOperation("月账单管理对账单统计明细")  
223 - @PostMapping("/queryBillforMonthDetail")  
224 - @ResponseBody  
225 - public BizResultVO<EasyUIDataGridVO<BillManageForMonthDetailDTO>> queryBillforMonthDetail(  
226 - @RequestBody BillQueryRequest billQueryRequest, HttpServletRequest request, HttpServletResponse response)  
227 - throws Exception {  
228 - // 2.调用接口查询当前登录人管辖的停车场名称  
229 - UserInfo userInfo = sessionCommUtil.getUserInfo();  
230 - List<String> plNos = new ArrayList<>();  
231 - if (userInfo != null) {  
232 - TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest();  
233 - tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds());  
234 - tdCompanyParkQueryRequest.setSessionId(session.getId());  
235 - tdCompanyParkQueryRequest.setSysCode(sysCode);  
236 - BizResult<List<String>> bizResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest);  
237 - // 拥有的停车场编号  
238 - plNos = ResultUtils.getBizResultData(bizResult);  
239 - }  
240 -// if (CollectionUtils.isEmpty(plNos)) {  
241 -// throw new BizException(ErrorType.PARK_LOT_NOT_EXISTS, "停车场plnos不存在");  
242 -// }  
243 - billQueryRequest.setParkIdList(plNos);  
244 - logger.info("月账单管理对账单统计明细 req={}", JSONObject.toJSONString(billQueryRequest));  
245 - BizResult<PageBean<BillManageForMonthDetailDTO>> respondResult = monthBillManagementService  
246 - .queryBillforMonthDetail(billQueryRequest);  
247 - logger.info("月账单管理对账单统计明细 respondResult={}", JSONObject.toJSONString(respondResult));  
248 - return returnJqGridData(respondResult, BillManageForMonthDetailDTO.class);  
249 - }  
250 -  
251 - /**  
252 - * 月账单临停导出.<br/>  
253 - *  
254 - * @param request  
255 - * @param response  
256 - */  
257 - @ApiOperation("月账单临停导出")  
258 - @GetMapping("/exportToExcleForBillForMonthTmp")  
259 - public void exportToExcleForBillForMonthTmp(@RequestParam List<String> parkIdList,  
260 - @RequestParam List<Integer> orderTypeList,@RequestParam String beginTime,  
261 - @RequestParam String endTime, HttpServletRequest request, HttpServletResponse response) {  
262 - logger.info("---begin--日账单导出调用后场dubbo服务,入参 beginTime={},endTime={}", beginTime, endTime);  
263 - BizResult<PageBean<BillManageDetailForMonthDTO>> result = new BizResult<PageBean<BillManageDetailForMonthDTO>>();  
264 - try {  
265 - BillQueryRequest billQueryRequest = new BillQueryRequest();  
266 - if (null == beginTime || null == endTime) {  
267 - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");  
268 - }  
269 -  
270 - billQueryRequest.setSysCode(sysCode);  
271 - billQueryRequest.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT));  
272 - billQueryRequest.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT));  
273 - billQueryRequest.setParkIdList(parkIdList);  
274 - billQueryRequest.setOrderTypeList(orderTypeList);  
275 - billQueryRequest.setBaseRequest(new BaseInfo(1, 0));  
276 - /** 查询月账单. */  
277 - result = monthBillManagementService.queryBillforMonthDetailForList(billQueryRequest);  
278 - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
279 - SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");  
280 - String[] title = new String[] { "流水号", "时间", "车主车牌号", "进场时间", "出场时间", "停车时长", "收费规则", "支付方式", "应收金额", "优惠券",  
281 - "红包", "实收金额", "共计" };  
282 - String sheetName = "账单";  
283 - String fileName = "账单管理" + format2.format(new Date());  
284 -  
285 - // 1.创建excel信息  
286 - XSSFSheet workSheet = ExcelUtil.createExcel(sheetName);  
287 - // 2.设置excel表头和表体  
288 - Layouter.buildReport(workSheet, title, 0, 0);  
289 - // 3.填充数据  
290 - List<Object[]> contentList = new ArrayList<Object[]>();  
291 -  
292 - List<BillManageDetailForMonthDTO> list = new ArrayList<BillManageDetailForMonthDTO>();  
293 - if (CollectionUtils.isNotEmpty(result.getData().getDataList())) {  
294 - list = result.getData().getDataList();  
295 - }  
296 - for (BillManageDetailForMonthDTO e : list) {  
297 - Object[] obj = new Object[title.length];  
298 - int index = 0;  
299 - obj[index++] = StringUtils.isNotEmpty(e.getPayOrderNo()) ? e.getPayOrderNo() : "";  
300 - obj[index++] = e.getPayFinishTime() != null  
301 - ? DateUtil.getDateString(e.getPayFinishTime(), DateUtil.DATETIME_FORMAT) : "";  
302 - obj[index++] = StringUtils.isNotEmpty(e.getCarNum()) ? e.getCarNum() : "";  
303 - obj[index++] = e.getParkInTime() != null  
304 - ? DateUtil.getDateString(e.getParkInTime(), DateUtil.DATETIME_FORMAT) : "";  
305 - obj[index++] = e.getParkOutTime() != null  
306 - ? DateUtil.getDateString(e.getParkOutTime(), DateUtil.DATETIME_FORMAT) : "";  
307 - obj[index++] = e.getParkingDuration() != null ? e.getParkingDuration() : DateUtil.secondToTime(0);  
308 - obj[index++] = "";  
309 - if (e.getPayType() != null) {  
310 - switch (e.getPayType()) {  
311 - case 1:  
312 - obj[index++] = "支付宝";  
313 - break;  
314 - case 2:  
315 - obj[index++] = "微信";  
316 - break;  
317 - case 3:  
318 - obj[index++] = "银联";  
319 - break;  
320 - case 4:  
321 - obj[index++] = "微信";  
322 - break;  
323 - default:  
324 - obj[index++] = "现金";  
325 - break;  
326 - }  
327 - } else {  
328 - obj[index++] = "";  
329 - }  
330 - obj[index++] = e.getAmountDueTotal() != null ? AmountUtils.changeF2Y(e.getAmountDueTotal().longValue())  
331 - : "0.00";  
332 - obj[index++] = "0.00";  
333 - obj[index++] = "0.00";  
334 - obj[index++] = e.getPayedTotalAmount() != null  
335 - ? AmountUtils.changeF2Y(e.getPayedTotalAmount().longValue()) : "0.00";  
336 - obj[index++] = e.getAmountDueTotal() != null ? AmountUtils.changeF2Y(e.getAmountDueTotal().longValue())  
337 - : "0.00";  
338 - contentList.add(obj);  
339 - }  
340 -  
341 - ExcleFillDateManager fillUserManager = new ExcleFillDateManager();  
342 - fillUserManager.fillSalesOrga(workSheet, title, contentList, 2);  
343 - // 4.excel输出配置  
344 - ExcelUtil.write(response, workSheet, fileName);  
345 - } catch (Exception e) {  
346 - result.setErrorInfo(ErrorType.BIZ_ERROR, "系统错误!");  
347 - e.printStackTrace();  
348 - }  
349 -  
350 - }  
351 -  
352 - /**  
353 - * 月账单年卡月卡导出.<br/>  
354 - *  
355 - * @param request  
356 - * @param response  
357 - */  
358 - @ApiOperation("月账单年卡月卡导出")  
359 - @GetMapping("/exportToExcleForBillForYearOrMonth")  
360 - public void exportToExcleForBillForYearOrMonth(@RequestParam List<String> parkIdList,  
361 - @RequestParam String beginTime,@RequestParam String endTime,  
362 - HttpServletRequest request, HttpServletResponse response) {  
363 - logger.info("---begin--月账单年卡月卡导出调用后场dubbo服务,入参 beginTime={},endTime={}", beginTime, endTime);  
364 - BizResult<PageBean<YearMonthCardStatisticDTO>> result = new BizResult<PageBean<YearMonthCardStatisticDTO>>();  
365 - try {  
366 - YearMonthCardStatisticRequest yearMonthCardStatisticRequest = new YearMonthCardStatisticRequest();  
367 - if (null == beginTime || null == endTime) {  
368 - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");  
369 - }  
370 -  
371 - yearMonthCardStatisticRequest.setSysCode(sysCode);  
372 - yearMonthCardStatisticRequest.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT));  
373 - yearMonthCardStatisticRequest.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT));  
374 - yearMonthCardStatisticRequest.setParkIdList(parkIdList);  
375 - yearMonthCardStatisticRequest.setBaseRequest(new BaseInfo(1, 0));  
376 - /** 查询月账单年卡月卡. */  
377 - result = yearMonthCardStatisticService.queryYearMonthCardStatistic(yearMonthCardStatisticRequest);  
378 -  
379 - SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");  
380 - String[] title = new String[] { "交易单号", "交易时间", "种类", "卡名称", "车牌号", "支付金额", "有效期" };  
381 - String sheetName = "账单";  
382 - String fileName = "账单管理" + format2.format(new Date());  
383 -  
384 - // 1.创建excel信息  
385 - XSSFSheet workSheet = ExcelUtil.createExcel(sheetName);  
386 - // 2.设置excel表头和表体  
387 - Layouter.buildReport(workSheet, title, 0, 0);  
388 - // 3.填充数据  
389 - List<Object[]> contentList = new ArrayList<Object[]>();  
390 -  
391 - List<YearMonthCardStatisticDTO> list = new ArrayList<YearMonthCardStatisticDTO>();  
392 -  
393 - if (CollectionUtils.isNotEmpty(result.getData().getDataList())) {  
394 - list = result.getData().getDataList();  
395 - }  
396 - for (YearMonthCardStatisticDTO e : list) {  
397 - Object[] obj = new Object[title.length];  
398 - int index = 0;  
399 - obj[index++] = StringUtils.isNotEmpty(e.getOrderId()) ? e.getOrderId() : "";  
400 - obj[index++] = e.getPayFinishTime() != null  
401 - ? DateUtil.getDateString(e.getPayFinishTime(), DateUtil.DATETIME_FORMAT) : "";  
402 - String yearOrMonthCard = "";  
403 - if (null != e.getOrderType()) {  
404 - if (2 == e.getOrderType()) {  
405 - yearOrMonthCard = "年卡";  
406 - obj[index++] = yearOrMonthCard;  
407 - } else if (3 == e.getOrderType()) {  
408 - yearOrMonthCard = "月卡";  
409 - obj[index++] = yearOrMonthCard;  
410 - }  
411 - } else {  
412 - obj[index++] = "";  
413 - }  
414 - obj[index++] = StringUtils.isNotEmpty(e.getParkName()) ? e.getParkName() + yearOrMonthCard : "";  
415 -  
416 - obj[index++] = StringUtils.isNotEmpty(e.getCarNumber()) ? e.getCarNumber() : "";  
417 -  
418 - obj[index++] = e.getAmount() != null ? AmountUtils.changeF2Y(e.getAmount().longValue()) : "0.00";  
419 - String effDate = "";  
420 - String expDate = "";  
421 - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");  
422 - if (null != e.getEffDate()) {  
423 - effDate = format.format(e.getEffDate());  
424 - }  
425 - if (null != e.getExpDate()) {  
426 - expDate = format.format(e.getExpDate());  
427 - }  
428 -  
429 - obj[index++] = effDate + " - " + expDate;  
430 -  
431 - contentList.add(obj);  
432 - }  
433 -  
434 - ExcleFillDateManager fillUserManager = new ExcleFillDateManager();  
435 - fillUserManager.fillSalesOrga(workSheet, title, contentList, 2);  
436 - // 4.excel输出配置  
437 - ExcelUtil.write(response, workSheet, fileName);  
438 - } catch (Exception e) {  
439 - result.setErrorInfo(ErrorType.BIZ_ERROR, "系统错误!");  
440 - e.printStackTrace();  
441 - }  
442 -  
443 - }  
444 -  
445 -  
446 -  
447 -  
448 - /**  
449 - * 月账单所有导出.<br/>  
450 - *  
451 - * @param request  
452 - * @param response  
453 - */  
454 - @ApiOperation("月账单所有导出")  
455 - @GetMapping("/exportToExcleForBillForAll")  
456 - public void exportToExcleForBillForAll(  
457 - @RequestParam String beginTime,  
458 - @RequestParam String endTime, HttpServletRequest request, HttpServletResponse response) {  
459 - BizResult<PageBean<BillManageForMonthDetailDTO>> respondResult= new BizResult<PageBean<BillManageForMonthDetailDTO>>();  
460 - try {  
461 - BillQueryRequest billQueryRequest=new BillQueryRequest();  
462 - if (null == beginTime || null == endTime) {  
463 - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");  
464 - }  
465 -  
466 - billQueryRequest.setSysCode(sysCode);  
467 - billQueryRequest.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT));  
468 - billQueryRequest.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT));  
469 - billQueryRequest.setBaseRequest(new BaseInfo(1, 0));  
470 - // 2.调用接口查询当前登录人管辖的停车场名称  
471 - UserInfo userInfo = sessionCommUtil.getUserInfo();  
472 - List<String> plNos = new ArrayList<>();  
473 - if (userInfo != null) {  
474 - TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest();  
475 - tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds());  
476 - tdCompanyParkQueryRequest.setSessionId(session.getId());  
477 - tdCompanyParkQueryRequest.setSysCode(sysCode);  
478 - BizResult<List<String>> bizResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest);  
479 - // 拥有的停车场编号  
480 - plNos = ResultUtils.getBizResultData(bizResult);  
481 - }  
482 - billQueryRequest.setParkIdList(plNos);  
483 - logger.info("月账单导出所有 req={}", JSONObject.toJSONString(billQueryRequest));  
484 - respondResult = monthBillManagementService  
485 - .queryBillforMonthDetail(billQueryRequest);  
486 - logger.info("月账单导出所有 respondResult={}", JSONObject.toJSONString(respondResult));  
487 -  
488 - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
489 - SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");  
490 - String[] title = new String[] { "停车场名称", "现金", "微信", "支付宝", "合计"};  
491 - String[] sheetName = new String[]{"临停收费","年卡月卡收费"};  
492 - String fileName = "账单管理" + format2.format(new Date());  
493 -  
494 - // 1.创建excel信息,多个sheet页  
495 - XSSFWorkbook workbook = new XSSFWorkbook();  
496 - XSSFSheet workSheetTmp = workbook.createSheet(sheetName[0]);  
497 - XSSFSheet workSheetYearOrMonth = workbook.createSheet(sheetName[1]);  
498 - XSSFSheet[] worksheet= new XSSFSheet[]{workSheetTmp,workSheetYearOrMonth};  
499 - // 2.设置excel表头和表体  
500 - Layouter.buildReport(workSheetTmp, title, 0, 0);  
501 - Layouter.buildReport(workSheetYearOrMonth, title, 0, 0);  
502 - // 3.填充数据  
503 - List<Object[]> contentYearOrMonthList = new ArrayList<Object[]>();  
504 - List<Object[]> contentTmpList = new ArrayList<Object[]>();  
505 - List<BillManageForMonthDetailDTO> list = new ArrayList<BillManageForMonthDetailDTO>();  
506 - if (CollectionUtils.isNotEmpty(respondResult.getData().getDataList())) {  
507 - list = respondResult.getData().getDataList();  
508 - }  
509 - for (BillManageForMonthDetailDTO e : list) {  
510 - Object[] obj = new Object[title.length];  
511 - int index = 0;  
512 - obj[index++] = StringUtils.isNotEmpty(e.getParkName()) ? e.getParkName() : "";  
513 - obj[index++] = e.getTmpCashAmount() != null  
514 - ? AmountUtils.changeF2Y(e.getTmpCashAmount().longValue()) : "0.00";  
515 - obj[index++] = e.getTmpWeChatAmount() != null ? AmountUtils.changeF2Y(e.getTmpWeChatAmount().longValue())  
516 - : "0.00";  
517 - obj[index++] = e.getTmpAlipayAmount() != null ? AmountUtils.changeF2Y(e.getTmpAlipayAmount().longValue())  
518 - : "0.00";  
519 - obj[index++] = e.getTmpAll() != null ? AmountUtils.changeF2Y(e.getTmpAll().longValue())  
520 - : "0.00";  
521 - contentTmpList.add(obj);  
522 - }  
523 - for (BillManageForMonthDetailDTO e : list) {  
524 - Object[] obj = new Object[title.length];  
525 - int index = 0;  
526 - obj[index++] = StringUtils.isNotEmpty(e.getParkName()) ? e.getParkName() : "";  
527 - obj[index++] = e.getYearMontCashAmount() != null  
528 - ? AmountUtils.changeF2Y(e.getYearMontCashAmount().longValue()) : "0.00";  
529 - obj[index++] = e.getYearMonthWeChatAmount() != null ? AmountUtils.changeF2Y(e.getYearMonthWeChatAmount().longValue())  
530 - : "0.00";  
531 - obj[index++] = e.getYearMonthAlipayAmount() != null ? AmountUtils.changeF2Y(e.getYearMonthAlipayAmount().longValue())  
532 - : "0.00";  
533 - obj[index++] = e.getYearMonthAll() != null ? AmountUtils.changeF2Y(e.getYearMonthAll().longValue())  
534 - : "0.00";  
535 - contentYearOrMonthList.add(obj);  
536 - }  
537 -  
538 - ExcleFillDateManager fillUserManager = new ExcleFillDateManager();  
539 - fillUserManager.fillSalesOrga(workSheetTmp, title, contentTmpList, 2);  
540 - ExcleFillDateManager fillUserManagerYearOrMonth = new ExcleFillDateManager();  
541 - fillUserManagerYearOrMonth.fillSalesOrga(workSheetYearOrMonth, title, contentYearOrMonthList, 2);  
542 - // 4.excel输出配置  
543 - ExcelUtil.write(response, worksheet, fileName);  
544 -  
545 - } catch (Exception e) {  
546 - respondResult.setErrorInfo(ErrorType.BIZ_ERROR, "系统错误!");  
547 - e.printStackTrace();  
548 - }  
549 -  
550 - }  
551 -  
552 -  
553 -  
554 -  
555 -  
556 -  
557 -  
558 -  
559 - /**  
560 - * 通过session信息获取停车场编码.<br/>  
561 - *  
562 - * @param billQueryRequest  
563 - * @param userInfo  
564 - * @return  
565 - * @throws Exception  
566 - */  
567 - private List<String> queryParkNoByCustIds(TdCompanyParkQueryRequest tdCompanyParkQueryRequest) throws Exception {  
568 - /** 查询停车场编码. */  
569 - BizResult<List<String>> parkNoResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest);  
570 - if (parkNoResult.isSuccess() && parkNoResult != null && parkNoResult.getData() != null) {  
571 - logger.info("根据登录获取到对应的停车场编码=" + JSONArray.toJSONString(parkNoResult.getData()));  
572 - return parkNoResult.getData();  
573 - } else {  
574 - logger.info("根据登录用户没有获取到对应的停车场编码");  
575 - return null;  
576 - }  
577 -  
578 - }  
579 -  
580 -  
581 -  
582 -} 73 + private static final Logger logger = LoggerFactory.getLogger(MonthBillManagementController.class);
  74 +
  75 + @Autowired
  76 + private MonthBillManagementService monthBillManagementService;
  77 + @Autowired
  78 + private YearMonthCardStatisticService yearMonthCardStatisticService;
  79 +
  80 + @Autowired
  81 + private TdCustCompanyService tdCustCompanyService;
  82 + @Autowired
  83 + private HttpSession session;
  84 + @Autowired
  85 + private SessionCommUtil sessionCommUtil;
  86 + @Value("${project.syscode}")
  87 + private String sysCode;
  88 +
  89 + @ApiOperation("月账单查询汇总统计")
  90 + @PostMapping("/summaryStatistic")
  91 + @ResponseBody
  92 + public BizResultVO<MonthBillSummaryStatisticDTO> getMonthBillSummaryStatistic(
  93 + @RequestBody MonthBillRequest request) {
  94 + logger.info("月账单查询汇总统计请求对象 req={}", JSONObject.toJSONString(request));
  95 + BizResult<MonthBillSummaryStatisticDTO> respondResult = monthBillManagementService
  96 + .getMonthBillSummaryStatistic(request);
  97 + logger.info("月账单查询汇总统计响应结果 respondResult={}", JSONObject.toJSONString(respondResult));
  98 + return new BizResultVO<>(respondResult);
  99 + }
  100 +
  101 + /**
  102 + * 临停收费, 按支付方式汇总统计,tp表示临停
  103 + *
  104 + * @param request
  105 + */
  106 + @ApiOperation("临停收费, 按支付方式汇总统计,tp表示临停")
  107 + @PostMapping("/tpStatistic")
  108 + @ResponseBody
  109 + public BizResultVO<MonthBillMngtStatisticDTO> getMonthBillMngtTPStatistic(@RequestBody MonthBillRequest request) {
  110 + logger.info("临停收费, 按支付方式汇总统计 req={}", JSONObject.toJSONString(request));
  111 + BizResult<MonthBillMngtStatisticDTO> respondResult = monthBillManagementService
  112 + .getMonthBillMngtTPStatistic(request);
  113 + logger.info("临停收费, 按支付方式汇总统计 respondResult={}", JSONObject.toJSONString(respondResult));
  114 + return new BizResultVO<>(respondResult);
  115 + }
  116 +
  117 + /**
  118 + * <!-- 临停收费,按照停车场分组后,按支付方式分类统计 TP ByParkinglot-->
  119 + *
  120 + * @param request
  121 + * @return
  122 + */
  123 + @ApiOperation("临停收费, 按照停车场分组后,按支付方式分类统计,tp表示临停,Pklt表示停车场")
  124 + @PostMapping("/tpPkltStatistic")
  125 + @ResponseBody
  126 + BizResultVO<List<MonthBillMngtStatisticByParkinglotDTO>> getMonthBillMngtTPStatisticByParkinglot(
  127 + @RequestBody MonthBillRequest request) {
  128 + logger.info("临停收费, 停车场分组,按支付方式分类 req={}", JSONObject.toJSONString(request));
  129 + BizResult<List<MonthBillMngtStatisticByParkinglotDTO>> respondResult = monthBillManagementService
  130 + .getMonthBillMngtTPStatisticByParkinglot(request);
  131 + logger.info("临停收费, 停车场分组,按支付方式分类respondResult={}", JSONObject.toJSONString(respondResult));
  132 + return new BizResultVO<>(respondResult);
  133 + }
  134 +
  135 + /**
  136 + * <!-- 月卡、年卡, 按支付方式汇总统计 CardMY-->
  137 + *
  138 + * @param request
  139 + * @return
  140 + */
  141 + @ApiOperation("月卡、年卡, 按支付方式汇总统计")
  142 + @PostMapping("/cardStatistic")
  143 + @ResponseBody
  144 + BizResultVO<MonthBillMngtStatisticDTO> getMonthBillMngtCardMYStatistic(@RequestBody MonthBillRequest request) {
  145 + logger.info("月卡、年卡, 按支付方式分类 req={}", JSONObject.toJSONString(request));
  146 + BizResult<MonthBillMngtStatisticDTO> respondResult = monthBillManagementService
  147 + .getMonthBillMngtCardMYStatistic(request);
  148 + logger.info("月卡、年卡, 按支付方式分类respondResult={}", JSONObject.toJSONString(respondResult));
  149 + return new BizResultVO<>(respondResult);
  150 + }
  151 +
  152 + /**
  153 + * <!-- 月卡、年卡,按照停车场分组后,按支付方式分类统计CardMY ByParkinglot-->
  154 + *
  155 + * @param request
  156 + * @return
  157 + */
  158 + @ApiOperation("月卡、年卡, 按支付方式汇总统计,Pklt表示停车场")
  159 + @PostMapping("/cardPkltStatistic")
  160 + @ResponseBody
  161 + BizResultVO<List<MonthBillMngtStatisticByParkinglotDTO>> getMonthBillMngtCardMYStatisticByParkinglot(
  162 + @RequestBody MonthBillRequest request) {
  163 + logger.info("月卡、年卡, 停车场分组,按支付方式分类 req={}", JSONObject.toJSONString(request));
  164 + BizResult<List<MonthBillMngtStatisticByParkinglotDTO>> respondResult = monthBillManagementService
  165 + .getMonthBillMngtCardMYStatisticByParkinglot(request);
  166 + logger.info("月卡、年卡, 停车场分组,按支付方式分类respondResult={}", JSONObject.toJSONString(respondResult));
  167 + return new BizResultVO<>(respondResult);
  168 + }
  169 +
  170 + // ----------------------------------------------------2017-8-1新添加-----------------------------------------------
  171 +
  172 + /**
  173 + * @param request
  174 + * @return
  175 + * @throws Exception
  176 + */
  177 + @ApiOperation("月账单管理统计列表")
  178 + @PostMapping("/queryBillforMonthList")
  179 + @ResponseBody
  180 + public BizResultVO<EasyUIDataGridVO<BillManageForMonthDTO>> queryBillforMonthList(
  181 + @RequestBody BillQueryRequest billQueryRequest, HttpServletRequest request, HttpServletResponse response)
  182 + throws Exception {
  183 + // 2.调用接口查询当前登录人管辖的停车场名称
  184 + UserInfo userInfo = sessionCommUtil.getUserInfo();
  185 + List<String> plNos = new ArrayList<>();
  186 + if (userInfo != null) {
  187 + TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest();
  188 + tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds());
  189 + tdCompanyParkQueryRequest.setSessionId(session.getId());
  190 + tdCompanyParkQueryRequest.setSysCode(sysCode);
  191 + BizResult<List<String>> bizResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest);
  192 + // 拥有的停车场编号
  193 + plNos = ResultUtils.getBizResultData(bizResult);
  194 + }
  195 + // if (CollectionUtils.isEmpty(plNos)) {
  196 + // throw new BizException(ErrorType.PARK_LOT_NOT_EXISTS, "停车场plnos不存在");
  197 + // }
  198 + billQueryRequest.setParkIdList(plNos);
  199 + logger.info("月账单管理统计列表 req={}", JSONObject.toJSONString(billQueryRequest));
  200 + BizResult<List<BillManageForMonthDTO>> respondResult = monthBillManagementService
  201 + .queryBillforMonthList(billQueryRequest);
  202 + logger.info("月账单管理统计列表 respondResult={}", JSONObject.toJSONString(respondResult));
  203 + return returnJqGridDataByList(respondResult, BillManageForMonthDTO.class);
  204 + }
  205 +
  206 + /**
  207 + * @param request
  208 + * @return
  209 + */
  210 + @ApiOperation("月账单管理对账单统计明细")
  211 + @PostMapping("/queryBillforMonthDetail")
  212 + @ResponseBody
  213 + public BizResultVO<EasyUIDataGridVO<BillManageForMonthDetailDTO>> queryBillforMonthDetail(
  214 + @RequestBody BillQueryRequest billQueryRequest, HttpServletRequest request, HttpServletResponse response)
  215 + throws Exception {
  216 + // 2.调用接口查询当前登录人管辖的停车场名称
  217 + UserInfo userInfo = sessionCommUtil.getUserInfo();
  218 + List<String> plNos = new ArrayList<>();
  219 + if (userInfo != null) {
  220 + TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest();
  221 + tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds());
  222 + tdCompanyParkQueryRequest.setSessionId(session.getId());
  223 + tdCompanyParkQueryRequest.setSysCode(sysCode);
  224 + BizResult<List<String>> bizResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest);
  225 + // 拥有的停车场编号
  226 + plNos = ResultUtils.getBizResultData(bizResult);
  227 + }
  228 + // if (CollectionUtils.isEmpty(plNos)) {
  229 + // throw new BizException(ErrorType.PARK_LOT_NOT_EXISTS, "停车场plnos不存在");
  230 + // }
  231 + billQueryRequest.setParkIdList(plNos);
  232 + logger.info("月账单管理对账单统计明细 req={}", JSONObject.toJSONString(billQueryRequest));
  233 + BizResult<PageBean<BillManageForMonthDetailDTO>> respondResult = monthBillManagementService
  234 + .queryBillforMonthDetail(billQueryRequest);
  235 + logger.info("月账单管理对账单统计明细 respondResult={}", JSONObject.toJSONString(respondResult));
  236 + return returnJqGridData(respondResult, BillManageForMonthDetailDTO.class);
  237 + }
  238 +
  239 + /**
  240 + * 月账单临停导出.<br/>
  241 + *
  242 + * @param request
  243 + * @param response
  244 + */
  245 + @ApiOperation("月账单临停导出")
  246 + @GetMapping("/exportToExcleForBillForMonthTmp")
  247 + public void exportToExcleForBillForMonthTmp(@RequestParam List<String> parkIdList,
  248 + @RequestParam List<Integer> orderTypeList, @RequestParam String beginTime,
  249 + @RequestParam String endTime, HttpServletRequest request, HttpServletResponse response) {
  250 + logger.info("---begin--日账单导出调用后场dubbo服务,入参 beginTime={},endTime={}", beginTime, endTime);
  251 + BizResult<PageBean<BillManageDetailForMonthDTO>> result
  252 + = new BizResult<PageBean<BillManageDetailForMonthDTO>>();
  253 + try {
  254 + BillQueryRequest billQueryRequest = new BillQueryRequest();
  255 + if (null == beginTime || null == endTime) {
  256 + throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");
  257 + }
  258 +
  259 + billQueryRequest.setSysCode(sysCode);
  260 + billQueryRequest.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT));
  261 + billQueryRequest.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT));
  262 + billQueryRequest.setParkIdList(parkIdList);
  263 + billQueryRequest.setOrderTypeList(orderTypeList);
  264 + billQueryRequest.setBaseRequest(new BaseInfo(1, 0));
  265 + /** 查询月账单. */
  266 + result = monthBillManagementService.queryBillforMonthDetailForList(billQueryRequest);
  267 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  268 + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
  269 + String[] title = new String[] {"流水号", "时间", "车主车牌号", "进场时间", "出场时间", "停车时长", "收费规则", "支付方式", "应收金额", "优惠券",
  270 + "红包", "实收金额", "共计"};
  271 + String sheetName = "账单";
  272 + String fileName = "账单管理" + format2.format(new Date());
  273 +
  274 + // 1.创建excel信息
  275 + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName);
  276 + // 2.设置excel表头和表体
  277 + Layouter.buildReport(workSheet, title, 0, 0);
  278 + // 3.填充数据
  279 + List<Object[]> contentList = new ArrayList<Object[]>();
  280 +
  281 + List<BillManageDetailForMonthDTO> list = new ArrayList<BillManageDetailForMonthDTO>();
  282 + if (CollectionUtils.isNotEmpty(result.getData().getDataList())) {
  283 + list = result.getData().getDataList();
  284 + }
  285 + for (BillManageDetailForMonthDTO e : list) {
  286 + Object[] obj = new Object[title.length];
  287 + int index = 0;
  288 + obj[index++] = StringUtils.isNotEmpty(e.getPayOrderNo()) ? e.getPayOrderNo() : "";
  289 + obj[index++] = e.getPayFinishTime() != null
  290 + ? DateUtil.getDateString(e.getPayFinishTime(), DateUtil.DATETIME_FORMAT) : "";
  291 + obj[index++] = StringUtils.isNotEmpty(e.getCarNum()) ? e.getCarNum() : "";
  292 + obj[index++] = e.getParkInTime() != null
  293 + ? DateUtil.getDateString(e.getParkInTime(), DateUtil.DATETIME_FORMAT) : "";
  294 + obj[index++] = e.getParkOutTime() != null
  295 + ? DateUtil.getDateString(e.getParkOutTime(), DateUtil.DATETIME_FORMAT) : "";
  296 + obj[index++] = e.getParkingDuration() != null ? e.getParkingDuration() : DateUtil.secondToTime(0);
  297 + obj[index++] = "";
  298 + if (e.getPayType() != null) {
  299 + switch (e.getPayType()) {
  300 + case 1:
  301 + obj[index++] = "支付宝";
  302 + break;
  303 + case 2:
  304 + obj[index++] = "微信";
  305 + break;
  306 + case 3:
  307 + obj[index++] = "银联";
  308 + break;
  309 + case 4:
  310 + obj[index++] = "微信";
  311 + break;
  312 + default:
  313 + obj[index++] = "现金";
  314 + break;
  315 + }
  316 + } else {
  317 + obj[index++] = "";
  318 + }
  319 + obj[index++] = e.getAmountDueTotal() != null ? AmountUtils.changeF2Y(e.getAmountDueTotal().longValue())
  320 + : "0.00";
  321 + obj[index++] = "0.00";
  322 + obj[index++] = "0.00";
  323 + obj[index++] = e.getPayedTotalAmount() != null
  324 + ? AmountUtils.changeF2Y(e.getPayedTotalAmount().longValue()) : "0.00";
  325 + obj[index++] = e.getAmountDueTotal() != null ? AmountUtils.changeF2Y(e.getAmountDueTotal().longValue())
  326 + : "0.00";
  327 + contentList.add(obj);
  328 + }
  329 +
  330 + ExcleFillDateManager fillUserManager = new ExcleFillDateManager();
  331 + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2);
  332 + // 4.excel输出配置
  333 + ExcelUtil.write(response, workSheet, fileName);
  334 + } catch (Exception e) {
  335 + result.setErrorInfo(ErrorType.BIZ_ERROR, "系统错误!");
  336 + e.printStackTrace();
  337 + }
  338 +
  339 + }
  340 +
  341 + /**
  342 + * 月账单年卡月卡导出.<br/>
  343 + *
  344 + * @param request
  345 + * @param response
  346 + */
  347 + @ApiOperation("月账单年卡月卡导出")
  348 + @GetMapping("/exportToExcleForBillForYearOrMonth")
  349 + public void exportToExcleForBillForYearOrMonth(@RequestParam List<String> parkIdList,
  350 + @RequestParam String beginTime, @RequestParam String endTime,
  351 + HttpServletRequest request, HttpServletResponse response) {
  352 + logger.info("---begin--月账单年卡月卡导出调用后场dubbo服务,入参 beginTime={},endTime={}", beginTime, endTime);
  353 + BizResult<PageBean<YearMonthCardStatisticDTO>> result = new BizResult<PageBean<YearMonthCardStatisticDTO>>();
  354 + try {
  355 + YearMonthCardStatisticRequest yearMonthCardStatisticRequest = new YearMonthCardStatisticRequest();
  356 + if (null == beginTime || null == endTime) {
  357 + throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");
  358 + }
  359 +
  360 + yearMonthCardStatisticRequest.setSysCode(sysCode);
  361 + yearMonthCardStatisticRequest.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT));
  362 + yearMonthCardStatisticRequest.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT));
  363 + yearMonthCardStatisticRequest.setParkIdList(parkIdList);
  364 + yearMonthCardStatisticRequest.setBaseRequest(new BaseInfo(1, 0));
  365 + /** 查询月账单年卡月卡. */
  366 + result = yearMonthCardStatisticService.queryYearMonthCardStatistic(yearMonthCardStatisticRequest);
  367 +
  368 + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
  369 + String[] title = new String[] {"交易单号", "交易时间", "种类", "卡名称", "车牌号", "支付金额", "有效期"};
  370 + String sheetName = "账单";
  371 + String fileName = "账单管理" + format2.format(new Date());
  372 +
  373 + // 1.创建excel信息
  374 + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName);
  375 + // 2.设置excel表头和表体
  376 + Layouter.buildReport(workSheet, title, 0, 0);
  377 + // 3.填充数据
  378 + List<Object[]> contentList = new ArrayList<Object[]>();
  379 +
  380 + List<YearMonthCardStatisticDTO> list = new ArrayList<YearMonthCardStatisticDTO>();
  381 +
  382 + if (CollectionUtils.isNotEmpty(result.getData().getDataList())) {
  383 + list = result.getData().getDataList();
  384 + }
  385 + for (YearMonthCardStatisticDTO e : list) {
  386 + Object[] obj = new Object[title.length];
  387 + int index = 0;
  388 + obj[index++] = StringUtils.isNotEmpty(e.getOrderId()) ? e.getOrderId() : "";
  389 + obj[index++] = e.getPayFinishTime() != null
  390 + ? DateUtil.getDateString(e.getPayFinishTime(), DateUtil.DATETIME_FORMAT) : "";
  391 + String yearOrMonthCard = "";
  392 + if (null != e.getOrderType()) {
  393 + if (2 == e.getOrderType()) {
  394 + yearOrMonthCard = "年卡";
  395 + obj[index++] = yearOrMonthCard;
  396 + } else if (3 == e.getOrderType()) {
  397 + yearOrMonthCard = "月卡";
  398 + obj[index++] = yearOrMonthCard;
  399 + }
  400 + } else {
  401 + obj[index++] = "";
  402 + }
  403 + obj[index++] = StringUtils.isNotEmpty(e.getParkName()) ? e.getParkName() + yearOrMonthCard : "";
  404 +
  405 + obj[index++] = StringUtils.isNotEmpty(e.getCarNumber()) ? e.getCarNumber() : "";
  406 +
  407 + obj[index++] = e.getAmount() != null ? AmountUtils.changeF2Y(e.getAmount().longValue()) : "0.00";
  408 + String effDate = "";
  409 + String expDate = "";
  410 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  411 + if (null != e.getEffDate()) {
  412 + effDate = format.format(e.getEffDate());
  413 + }
  414 + if (null != e.getExpDate()) {
  415 + expDate = format.format(e.getExpDate());
  416 + }
  417 +
  418 + obj[index++] = effDate + " - " + expDate;
  419 +
  420 + contentList.add(obj);
  421 + }
  422 +
  423 + ExcleFillDateManager fillUserManager = new ExcleFillDateManager();
  424 + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2);
  425 + // 4.excel输出配置
  426 + ExcelUtil.write(response, workSheet, fileName);
  427 + } catch (Exception e) {
  428 + result.setErrorInfo(ErrorType.BIZ_ERROR, "系统错误!");
  429 + e.printStackTrace();
  430 + }
  431 +
  432 + }
  433 +
  434 + /**
  435 + * 月账单所有导出.<br/>
  436 + *
  437 + * @param request
  438 + * @param response
  439 + */
  440 + @ApiOperation("月账单所有导出")
  441 + @GetMapping("/exportToExcleForBillForAll")
  442 + public void exportToExcleForBillForAll(
  443 + @RequestParam String beginTime,
  444 + @RequestParam String endTime, HttpServletRequest request, HttpServletResponse response) {
  445 + BizResult<PageBean<BillManageForMonthDetailDTO>> respondResult
  446 + = new BizResult<PageBean<BillManageForMonthDetailDTO>>();
  447 + try {
  448 + BillQueryRequest billQueryRequest = new BillQueryRequest();
  449 + if (null == beginTime || null == endTime) {
  450 + throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");
  451 + }
  452 +
  453 + billQueryRequest.setSysCode(sysCode);
  454 + billQueryRequest.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT));
  455 + billQueryRequest.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT));
  456 + billQueryRequest.setBaseRequest(new BaseInfo(1, 0));
  457 + // 2.调用接口查询当前登录人管辖的停车场名称
  458 + UserInfo userInfo = sessionCommUtil.getUserInfo();
  459 + List<String> plNos = new ArrayList<>();
  460 + if (userInfo != null) {
  461 + TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest();
  462 + tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds());
  463 + tdCompanyParkQueryRequest.setSessionId(session.getId());
  464 + tdCompanyParkQueryRequest.setSysCode(sysCode);
  465 + BizResult<List<String>> bizResult = tdCustCompanyService.queryParkNoByCustIds(
  466 + tdCompanyParkQueryRequest);
  467 + // 拥有的停车场编号
  468 + plNos = ResultUtils.getBizResultData(bizResult);
  469 + }
  470 + billQueryRequest.setParkIdList(plNos);
  471 + logger.info("月账单导出所有 req={}", JSONObject.toJSONString(billQueryRequest));
  472 + respondResult = monthBillManagementService
  473 + .queryBillforMonthDetail(billQueryRequest);
  474 + logger.info("月账单导出所有 respondResult={}", JSONObject.toJSONString(respondResult));
  475 +
  476 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  477 + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
  478 + String[] title = new String[] {"停车场名称", "现金", "微信", "支付宝", "合计"};
  479 + String[] sheetName = new String[] {"临停收费", "年卡月卡收费"};
  480 + String fileName = "账单管理" + format2.format(new Date());
  481 +
  482 + // 1.创建excel信息,多个sheet页
  483 + XSSFWorkbook workbook = new XSSFWorkbook();
  484 + XSSFSheet workSheetTmp = workbook.createSheet(sheetName[0]);
  485 + XSSFSheet workSheetYearOrMonth = workbook.createSheet(sheetName[1]);
  486 + XSSFSheet[] worksheet = new XSSFSheet[] {workSheetTmp, workSheetYearOrMonth};
  487 + // 2.设置excel表头和表体
  488 + Layouter.buildReport(workSheetTmp, title, 0, 0);
  489 + Layouter.buildReport(workSheetYearOrMonth, title, 0, 0);
  490 + // 3.填充数据
  491 + List<Object[]> contentYearOrMonthList = new ArrayList<Object[]>();
  492 + List<Object[]> contentTmpList = new ArrayList<Object[]>();
  493 + List<BillManageForMonthDetailDTO> list = new ArrayList<BillManageForMonthDetailDTO>();
  494 + if (CollectionUtils.isNotEmpty(respondResult.getData().getDataList())) {
  495 + list = respondResult.getData().getDataList();
  496 + }
  497 + for (BillManageForMonthDetailDTO e : list) {
  498 + Object[] obj = new Object[title.length];
  499 + int index = 0;
  500 + obj[index++] = StringUtils.isNotEmpty(e.getParkName()) ? e.getParkName() : "";
  501 + obj[index++] = e.getTmpCashAmount() != null
  502 + ? AmountUtils.changeF2Y(e.getTmpCashAmount().longValue()) : "0.00";
  503 + obj[index++] = e.getTmpWeChatAmount() != null ? AmountUtils.changeF2Y(
  504 + e.getTmpWeChatAmount().longValue())
  505 + : "0.00";
  506 + obj[index++] = e.getTmpAlipayAmount() != null ? AmountUtils.changeF2Y(
  507 + e.getTmpAlipayAmount().longValue())
  508 + : "0.00";
  509 + obj[index++] = e.getTmpAll() != null ? AmountUtils.changeF2Y(e.getTmpAll().longValue())
  510 + : "0.00";
  511 + contentTmpList.add(obj);
  512 + }
  513 + for (BillManageForMonthDetailDTO e : list) {
  514 + Object[] obj = new Object[title.length];
  515 + int index = 0;
  516 + obj[index++] = StringUtils.isNotEmpty(e.getParkName()) ? e.getParkName() : "";
  517 + obj[index++] = e.getYearMontCashAmount() != null
  518 + ? AmountUtils.changeF2Y(e.getYearMontCashAmount().longValue()) : "0.00";
  519 + obj[index++] = e.getYearMonthWeChatAmount() != null ? AmountUtils.changeF2Y(
  520 + e.getYearMonthWeChatAmount().longValue())
  521 + : "0.00";
  522 + obj[index++] = e.getYearMonthAlipayAmount() != null ? AmountUtils.changeF2Y(
  523 + e.getYearMonthAlipayAmount().longValue())
  524 + : "0.00";
  525 + obj[index++] = e.getYearMonthAll() != null ? AmountUtils.changeF2Y(e.getYearMonthAll().longValue())
  526 + : "0.00";
  527 + contentYearOrMonthList.add(obj);
  528 + }
  529 +
  530 + ExcleFillDateManager fillUserManager = new ExcleFillDateManager();
  531 + fillUserManager.fillSalesOrga(workSheetTmp, title, contentTmpList, 2);
  532 + ExcleFillDateManager fillUserManagerYearOrMonth = new ExcleFillDateManager();
  533 + fillUserManagerYearOrMonth.fillSalesOrga(workSheetYearOrMonth, title, contentYearOrMonthList, 2);
  534 + // 4.excel输出配置
  535 + ExcelUtil.write(response, worksheet, fileName);
  536 +
  537 + } catch (Exception e) {
  538 + respondResult.setErrorInfo(ErrorType.BIZ_ERROR, "系统错误!");
  539 + e.printStackTrace();
  540 + }
  541 +
  542 + }
  543 +
  544 + /**
  545 + * 通过session信息获取停车场编码.<br/>
  546 + *
  547 + * @param billQueryRequest
  548 + * @param userInfo
  549 + * @return
  550 + * @throws Exception
  551 + */
  552 + private List<String> queryParkNoByCustIds(TdCompanyParkQueryRequest tdCompanyParkQueryRequest) throws Exception {
  553 + /** 查询停车场编码. */
  554 + BizResult<List<String>> parkNoResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest);
  555 + if (parkNoResult.isSuccess() && parkNoResult != null && parkNoResult.getData() != null) {
  556 + logger.info("根据登录获取到对应的停车场编码=" + JSONArray.toJSONString(parkNoResult.getData()));
  557 + return parkNoResult.getData();
  558 + } else {
  559 + logger.info("根据登录用户没有获取到对应的停车场编码");
  560 + return null;
  561 + }
  562 +
  563 + }
  564 +
  565 +}
583 \ No newline at end of file 566 \ No newline at end of file