diff --git a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/CloudsParDurationController.java b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/CloudsParDurationController.java index c9f5ade..1ad05bd 100644 --- a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/CloudsParDurationController.java +++ b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/CloudsParDurationController.java @@ -1,21 +1,34 @@ package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.poi.xssf.usermodel.XSSFSheet; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import com.alibaba.dubbo.common.utils.StringUtils; +import com.clouds.common.utils.excle.ExcelUtil; +import com.clouds.common.utils.excle.ExcleFillDateManager; +import com.clouds.common.utils.excle.Layouter; import com.clouds.common.web.BizController; import com.clouds.common.web.vo.BizResultVO; import com.zteits.clouds.api.apibase.bean.BizResult; import com.zteits.clouds.api.apibase.bean.PageBean; +import com.zteits.clouds.api.dto.clouds.dto.BillManageDTO; import com.zteits.clouds.api.dto.clouds.dto.ParkDurationDTO; +import com.zteits.clouds.api.dto.clouds.dto.ParkDurationForHourDTO; +import com.zteits.clouds.api.dto.clouds.param.BillQueryRequest; import com.zteits.clouds.api.dto.clouds.param.ParkDurationRequest; import com.zteits.clouds.api.service.clouds.CloudsParDurationService; @@ -51,5 +64,238 @@ public class CloudsParDurationController extends BizController{ this.returnJsonDataGrid(response, result); } + /** + * 停车时长-日.
+ * + * @param request + * @param response + * @throws Exception + */ + @RequestMapping("/exportToExcleForParkDurationForDay") + public void exportToExcleForParkDurationForDay(@RequestParam String parkOutBeginTime,@RequestParam String parkOutEndTime,@RequestParam List parkIds, + HttpServletRequest request,HttpServletResponse response) throws Exception { + SimpleDateFormat format_yyy = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + ParkDurationRequest billQueryRequest = new ParkDurationRequest(); + billQueryRequest.setSysCode("1001"); + billQueryRequest.getBaseRequest().setPageSize(0); + billQueryRequest.setParkIds(parkIds); + billQueryRequest.setParkOutBeginTime(format_yyy.parse(parkOutBeginTime)); + billQueryRequest.setParkOutEndTime(format_yyy.parse(parkOutEndTime)); + BizResult> result = cloudsParDurationService.queryEchartsForParkDurationDayForPage(billQueryRequest); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + String[] title = new String[]{"时间","停车场名称","平均时长(小时)"}; + String sheetName="停车时长统计"; + String fileName = "停车时长统计(日)"; + // 1.创建excel信息 + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); + // 2.设置excel表头和表体 + Layouter.buildReport(workSheet,title,0, 0); + //3.填充数据 + List contentList=new ArrayList(); + if(result != null && !CollectionUtils.isEmpty(result.getData().getDataList())){ + List list = result.getData().getDataList(); + for (ParkDurationDTO e: list) { + if(e != null){ + Object[] obj=new Object[title.length]; + int index=0; + obj[index++]=(e.getParkOutTime() != null ? format.format(e.getParkOutTime()) : ""); + obj[index++]=e.getParkName(); + obj[index++]=e.getParkingDuration(); + contentList.add(obj); + } + } + } + ExcleFillDateManager fillUserManager=new ExcleFillDateManager(); + fillUserManager.fillSalesOrga(workSheet,title,contentList,2); + // 4.excel输出配置 + ExcelUtil.write(response, workSheet, fileName); + + } + + /** + * 停车时长-日-下载详情.
+ * + * @param request + * @param response + * @throws Exception + */ + @RequestMapping("/exportExcleForParkDurationDetail") + public void exportExcleForParkDurationDetail(@RequestParam String parkOutBeginTime,@RequestParam String parkOutEndTime,@RequestParam List parkIds, + HttpServletRequest request,HttpServletResponse response) throws Exception { + SimpleDateFormat format_yyy = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + ParkDurationRequest billQueryRequest = new ParkDurationRequest(); + billQueryRequest.setSysCode("1001"); + billQueryRequest.getBaseRequest().setPageSize(0); + billQueryRequest.setParkIds(parkIds); + billQueryRequest.setParkOutBeginTime(format_yyy.parse(parkOutBeginTime)); + billQueryRequest.setParkOutEndTime(format_yyy.parse(parkOutEndTime)); + BizResult> result = cloudsParDurationService.queryEchartsForParkDurationDayDetail(billQueryRequest); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + String[] title = new String[]{"日期","车辆类型","停车场名称","1小时", + "2小时", + "3小时", + "4小时", + "5小时", + "6小时", + "7小时", + "8小时", + "9小时", + "10小时", + "11小时", + "12小时", + "13小时", + "14小时", + "15小时", + "16小时", + "17小时", + "18小时", + "19小时", + "20小时", + "21小时", + "22小时", + "23小时", + "24小时","平均时长(小时)"}; + String sheetName="停车时长统计详情"; + String fileName = "停车时长统计详情(日)"; + // 1.创建excel信息 + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); + // 2.设置excel表头和表体 + Layouter.buildReport(workSheet,title,0, 0); + //3.填充数据 + List contentList=new ArrayList(); + if(result != null && !CollectionUtils.isEmpty(result.getData())){ + List list = result.getData(); + for (ParkDurationForHourDTO e: list) { + if(e != null){ + Object[] obj=new Object[title.length]; + int index=0; + obj[index++]=(e.getParkOutTime() != null ? format.format(e.getParkOutTime()) : ""); + if(1 ==e.getParkType()){ + obj[index++]="临时车"; + }else if(2 ==e.getParkType()){ + obj[index++]="年包车停车"; + }else if(3 ==e.getParkType()){ + obj[index++]="月包车停车"; + }else if(5 ==e.getParkType()){ + obj[index++]="免费停车"; + }else if(99 ==e.getParkType()){ + obj[index++]="合计"; + } + obj[index++]=e.getParkName(); + obj[index++]=e.getH1(); + obj[index++]=e.getH2(); + obj[index++]=e.getH3(); + obj[index++]=e.getH4(); + obj[index++]=e.getH5(); + obj[index++]=e.getH6(); + obj[index++]=e.getH7(); + obj[index++]=e.getH8(); + obj[index++]=e.getH9(); + obj[index++]=e.getH10(); + obj[index++]=e.getH11(); + obj[index++]=e.getH12(); + obj[index++]=e.getH13(); + obj[index++]=e.getH14(); + obj[index++]=e.getH15(); + obj[index++]=e.getH16(); + obj[index++]=e.getH17(); + obj[index++]=e.getH18(); + obj[index++]=e.getH19(); + obj[index++]=e.getH20(); + obj[index++]=e.getH21(); + obj[index++]=e.getH22(); + obj[index++]=e.getH23(); + obj[index++]=e.getH24(); + if(StringUtils.isNotEmpty(e.getDuration())){ + obj[index++]=e.getDuration(); + }else{ + obj[index++]=""; + } + + contentList.add(obj); + } + } + } + ExcleFillDateManager fillUserManager=new ExcleFillDateManager(); + fillUserManager.fillSalesOrga(workSheet,title,contentList,2); + // 4.excel输出配置 + ExcelUtil.write(response, workSheet, fileName); + + } + + /****************************************************停车时长按月************************************************************************/ + + /** + * 企业云平台->停车时长折线图->按日.
+ * @return + */ + @ApiOperation("企业云平台->停车时长折线图->按月") + @PostMapping("/queryEchartsForParkDurationForMonth") + public BizResultVO> queryEchartsForParkDurationForMonth(@RequestBody ParkDurationRequest parkDurationRequest){ + BizResult> result = cloudsParDurationService.queryEchartsForParkDurationForMonth(parkDurationRequest); + return new BizResultVO>(result); + } + + /** + * 企业云平台->停车时长->分页.
+ * @return + */ + @ApiOperation("企业云平台->停车时长->分页-按月") + @PostMapping("/queryEchartsForParkDurationMonthForPage") + public void queryEchartsForParkDurationMonthForPage(@RequestBody ParkDurationRequest parkDurationRequest,HttpServletRequest request, + HttpServletResponse response){ + BizResult> result = cloudsParDurationService.queryEchartsForParkDurationMonthForPage(parkDurationRequest); + this.returnJsonDataGrid(response, result); + } + + /** + * 停车时长-日.
+ * + * @param request + * @param response + * @throws Exception + */ + @RequestMapping("/exportToExcleForParkDurationForMonth") + public void exportToExcleForParkDurationForMonth(@RequestParam String parkOutBeginTime,@RequestParam String parkOutEndTime,@RequestParam List parkIds, + HttpServletRequest request,HttpServletResponse response) throws Exception { + SimpleDateFormat format_yyy = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + ParkDurationRequest billQueryRequest = new ParkDurationRequest(); + billQueryRequest.setSysCode("1001"); + billQueryRequest.getBaseRequest().setPageSize(0); + billQueryRequest.setParkIds(parkIds); + billQueryRequest.setParkOutBeginTime(format_yyy.parse(parkOutBeginTime)); + billQueryRequest.setParkOutEndTime(format_yyy.parse(parkOutEndTime)); + BizResult> result = cloudsParDurationService.queryEchartsForParkDurationMonthForPage(billQueryRequest); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); + String[] title = new String[]{"时间","停车场名称","平均时长(小时)"}; + String sheetName="停车时长统计"; + String fileName = "停车时长统计(月)"; + // 1.创建excel信息 + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); + // 2.设置excel表头和表体 + Layouter.buildReport(workSheet,title,0, 0); + //3.填充数据 + List contentList=new ArrayList(); + if(result != null && !CollectionUtils.isEmpty(result.getData().getDataList())){ + List list = result.getData().getDataList(); + for (ParkDurationDTO e: list) { + if(e != null){ + Object[] obj=new Object[title.length]; + int index=0; + obj[index++]=(e.getParkOutTime() != null ? format.format(e.getParkOutTime()) : ""); + obj[index++]=e.getParkName(); + obj[index++]=e.getParkingDuration(); + contentList.add(obj); + } + } + } + ExcleFillDateManager fillUserManager=new ExcleFillDateManager(); + fillUserManager.fillSalesOrga(workSheet,title,contentList,2); + // 4.excel输出配置 + ExcelUtil.write(response, workSheet, fileName); + + } + + }