Commit db092a1c8704d1c0d6fee977a73bd11569ed2a8c

Authored by llw
1 parent f00ffa91

tijiao

src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/BerthsStatisticController.java
... ... @@ -37,7 +37,6 @@ import com.clouds.common.utils.excle.ExcelUtil;
37 37 import com.clouds.common.utils.excle.ExcleFillDateManager;
38 38 import com.clouds.common.utils.excle.Layouter;
39 39 import com.clouds.common.web.BizController;
40   -import com.clouds.common.web.SessionCommUtil;
41 40 import com.clouds.common.web.vo.BizResultVO;
42 41 import com.clouds.common.web.vo.EasyUIDataGridVO;
43 42 import com.google.common.collect.Lists;
... ... @@ -47,6 +46,7 @@ import com.zteits.clouds.api.apibase.bean.BizResult;
47 46 import com.zteits.clouds.api.apibase.bean.PageBean;
48 47 import com.zteits.clouds.api.apibase.constants.ErrorType;
49 48 import com.zteits.clouds.api.apibase.exception.BizException;
  49 +import com.zteits.clouds.api.dto.park.dto.MonthVehicleFlowAndVacancyRateAndTurnoverDTO;
50 50 import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO;
51 51 import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO;
52 52 import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticMaxAndMinDTO;
... ... @@ -199,7 +199,7 @@ public class BerthsStatisticController extends BizController {
199 199 obj[index++] = e.getPlName();
200 200 double d=100-e.getFreeRatio()* 100;
201 201 obj[index++] = df.format(d) + "%";
202   - obj[index++] = e.getTurnoverRatio();
  202 + obj[index++] = df.format(e.getTurnoverRatio());
203 203 contentList.add(obj);
204 204 }
205 205 ExcleFillDateManager fillUserManager = new ExcleFillDateManager();
... ... @@ -292,6 +292,7 @@ public class BerthsStatisticController extends BizController {
292 292 }
293 293  
294 294 /**
  295 + * langlw 2017-8-25
295 296 * 根据时间获取车位周转率折线图
296 297 *
297 298 * @param request
... ... @@ -378,14 +379,14 @@ public class BerthsStatisticController extends BizController {
378 379 timeAndVal.put(statisEndTime, statisticDTO.getFreeRatio() * 100);
379 380 parkLotMap.put(key, timeAndVal);
380 381 } else if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER == berthRatio) {
381   - timeAndVal.put(statisEndTime, statisticDTO.getTurnoverRatio() * 100);
  382 + timeAndVal.put(statisEndTime, statisticDTO.getTurnoverRatio() );
382 383 parkLotMap.put(key, timeAndVal);
383 384 }
384 385 } else {
385 386 if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE == berthRatio) {
386 387 parkLotMap.get(key).put(statisEndTime, statisticDTO.getFreeRatio() * 100);
387 388 } else if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER == berthRatio) {
388   - parkLotMap.get(key).put(statisEndTime, statisticDTO.getTurnoverRatio() * 100);
  389 + parkLotMap.get(key).put(statisEndTime, statisticDTO.getTurnoverRatio() );
389 390 }
390 391 }
391 392  
... ... @@ -573,6 +574,157 @@ public class BerthsStatisticController extends BizController {
573 574  
574 575  
575 576  
  577 + /**
  578 + * langlw 2017-8-24
  579 + * @param beginTime
  580 + * @param endTime
  581 + * @param plNos
  582 + * @param requests
  583 + * @param response
  584 + */
  585 + @ApiOperation("按月导出车位数据统计excel")
  586 + @GetMapping("exportBerthStatisticExcelForMonth")
  587 + public void exportBerthStatisticExcelForMonth(@RequestParam String beginTime, @RequestParam String endTime,
  588 + @RequestParam List<String> plNos, HttpServletRequest requests, HttpServletResponse response) {
  589 + ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest();
  590 + request.setSysCode(sysCode);
  591 + request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT));
  592 + request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT));
  593 + request.setPlNos(plNos);
  594 + request.setBaseRequest(new BaseInfo(1, 0));
  595 + BizResult<PageBean<MonthVehicleFlowAndVacancyRateAndTurnoverDTO>> bizResult = parkingLotStatisticService
  596 + .queryMonthVehicleFlowAndVacancyRateAndTurnover(request);
  597 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  598 + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
  599 + String[] title = new String[] { "时间","停车场名称", "占用率", "周转率" };
  600 + String sheetName = "车位管理";
  601 + String fileName = "车位管理" + format2.format(new Date());
  602 + // 1.创建excel信息
  603 + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName);
  604 + // 2.设置excel表头和表体
  605 + Layouter.buildReport(workSheet, title, 0, 0);
  606 + // 3.填充数据
  607 + List<Object[]> contentList = new ArrayList<Object[]>();
  608 + List<MonthVehicleFlowAndVacancyRateAndTurnoverDTO> list = new ArrayList<>();
  609 + if (CollectionUtils.isNotEmpty(bizResult.getData().getDataList())) {
  610 + list = bizResult.getData().getDataList();
  611 + }
  612 + DecimalFormat df=new DecimalFormat(".##");
  613 +
  614 + for (MonthVehicleFlowAndVacancyRateAndTurnoverDTO e : list) {
  615 + Object[] obj = new Object[title.length];
  616 + int index = 0;
  617 + obj[index++] = e.getStatisticTime();
  618 + obj[index++] = e.getPlName();
  619 + double d=e.getAvgOccupyRatio()* 100;
  620 + obj[index++] = df.format(d) + "%";
  621 + obj[index++] = df.format(e.getAvgTurnoverRatio());
  622 + contentList.add(obj);
  623 + }
  624 + ExcleFillDateManager fillUserManager = new ExcleFillDateManager();
  625 + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2);
  626 + // 4.excel输出配置
  627 + ExcelUtil.write(response, workSheet, fileName);
  628 + }
  629 +
  630 +
  631 + /**
  632 + * langlw 2017-8-24
  633 + * @param beginTime
  634 + * @param endTime
  635 + * @param plNos
  636 + * @param requests
  637 + * @param response
  638 + */
  639 + @ApiOperation("下载车位数据统计详情excel")
  640 + @GetMapping("downloadBerthStatisticExcelForMonth")
  641 + public void downloadBerthStatisticExcelForMonth(@RequestParam String beginTime, @RequestParam String endTime,
  642 + @RequestParam List<String> plNos, @RequestParam String parkName,
  643 + HttpServletRequest requests, HttpServletResponse response) {
  644 + ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest();
  645 + request.setSysCode(sysCode);
  646 + request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT));
  647 + request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT));
  648 + request.setPlNos(plNos);
  649 + request.setBaseRequest(new BaseInfo(1, 0));
  650 + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY);
  651 +
  652 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  653 + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
  654 +
  655 + Calendar beginTimec = Calendar.getInstance();
  656 + beginTimec.setTime(request.getBeginTime());
  657 +
  658 + Calendar endTimec = Calendar.getInstance();
  659 + endTimec.setTime(request.getEndTime());
  660 +
  661 + Long dayDifference = DateUtil.getTimeDifference(new Timestamp(request.getEndTime().getTime()),
  662 + new Timestamp(request.getBeginTime().getTime()));
  663 +
  664 + List<String> xAxisData = Lists.newArrayList();
  665 + String[] title = new String[dayDifference.intValue()+2];
  666 + title[0]="";
  667 + for (int i = 0; i <= dayDifference.intValue(); i++) {
  668 + Calendar tempDate = Calendar.getInstance();
  669 + tempDate.setTime(request.getBeginTime());
  670 + tempDate.add(Calendar.DAY_OF_MONTH, i);
  671 + int beginMonth = tempDate.get(Calendar.MONTH) + 1;
  672 + int beginDay = tempDate.get(Calendar.DAY_OF_MONTH);
  673 + String month = String.format("%02d", (beginMonth));
  674 + String day = String.format("%02d", (beginDay));
  675 + title[i+1]=month + "-" + day;
  676 + xAxisData.add(month + "-" + day);
  677 +
  678 + }
  679 +
  680 + String dateType ="MM-dd";
  681 + int berthRatio = ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER;
  682 + LineChartVO turnOverBerthRatios = getFreeBerthRatios(request, xAxisData, dateType, berthRatio);
  683 + int berthFreeRatio = ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE;
  684 + LineChartVO freeBerthRatios = getFreeBerthRatios(request, xAxisData, dateType, berthFreeRatio);
  685 +
  686 +
  687 + String sheetName = "月报表车位使用统计";
  688 + String fileName = "月报表车位使用统计" + format2.format(new Date());
  689 + // 1.创建excel信息
  690 + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName);
  691 + // 2.设置excel表头和表体
  692 + Layouter.buildReport(workSheet, title, 0, 0);
  693 + // 3.填充数据
  694 + List<Object[]> contentList = new ArrayList<Object[]>();
  695 +
  696 +
  697 + for (SerieVO e : freeBerthRatios.getSeries()) {
  698 +
  699 + Object[] obj = new Object[title.length];
  700 + obj[0]="占用率";
  701 + int index = 1;
  702 + for (Integer i : e.getData()) {
  703 + obj[index++] = 100-i+"%";
  704 + }
  705 + contentList.add(obj);
  706 + }
  707 +
  708 + for (SerieVO e : turnOverBerthRatios.getSeries()) {
  709 +
  710 + Object[] obj = new Object[title.length];
  711 + obj[0]="周转率率";
  712 + int index = 1;
  713 + for (Integer i : e.getData()) {
  714 + obj[index++] = i ;
  715 + }
  716 +
  717 +
  718 + contentList.add(obj);
  719 + }
  720 +
  721 + ExcleFillDateManager fillUserManager = new ExcleFillDateManager();
  722 + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2);
  723 + // 4.excel输出配置
  724 + ExcelUtil.write(response, workSheet, fileName);
  725 + }
  726 +
  727 +
576 728  
577 729  
578 730 }
... ...
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/VehicleFlowStatisticController.java
... ... @@ -12,17 +12,16 @@ import javax.servlet.http.HttpServletRequest;
12 12 import javax.servlet.http.HttpServletResponse;
13 13  
14 14 import com.alibaba.dubbo.common.utils.CollectionUtils;
  15 +import com.alibaba.dubbo.common.utils.StringUtils;
15 16 import com.alibaba.fastjson.JSON;
16 17 import com.alibaba.fastjson.JSONObject;
17 18  
18   -import com.clouds.common.entity.UserInfo;
19 19 import com.clouds.common.utils.DateUtil;
20 20 import com.clouds.common.utils.ResultUtils;
21 21 import com.clouds.common.utils.excle.ExcelUtil;
22 22 import com.clouds.common.utils.excle.ExcleFillDateManager;
23 23 import com.clouds.common.utils.excle.Layouter;
24 24 import com.clouds.common.web.BizController;
25   -import com.clouds.common.web.SessionCommUtil;
26 25 import com.clouds.common.web.vo.BizResultVO;
27 26 import com.clouds.common.web.vo.EasyUIDataGridVO;
28 27 import com.google.common.collect.Lists;
... ... @@ -32,6 +31,7 @@ import com.zteits.clouds.api.apibase.bean.BizResult;
32 31 import com.zteits.clouds.api.apibase.bean.PageBean;
33 32 import com.zteits.clouds.api.apibase.constants.ErrorType;
34 33 import com.zteits.clouds.api.apibase.exception.BizException;
  34 +import com.zteits.clouds.api.dto.park.dto.MonthVehicleFlowAndVacancyRateAndTurnoverDTO;
35 35 import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO;
36 36 import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticMaxAndMinDTO;
37 37 import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest;
... ... @@ -62,307 +62,476 @@ import org.springframework.web.bind.annotation.ResponseBody;
62 62 * @version: v1.0.0
63 63 * @author: langlw
64 64 * @date: 2017年6月14日 下午3:02:39 Modification History: Date Author Version
65   - * Description ---------------------------------------------------------*
66   - * 2017年6月14日 langlw v1.0.0 创建
  65 + * Description ---------------------------------------------------------*
  66 + * 2017年6月14日 langlw v1.0.0 创建
67 67 */
68 68 @Api(value = "停车场车流量数据统计", description = "停车场车流量数据统计")
69 69 @Controller
70 70 @RequestMapping(value = "/VehicleFlowStatistic")
71 71 public class VehicleFlowStatisticController extends BizController {
72   - private Logger logger = LoggerFactory.getLogger(VehicleFlowStatisticController.class);
73   -
74   - @Value("${project.syscode}")
75   - private String sysCode;
76   -
77   - @Autowired
78   - private ParkingLotUseStatisticService parkingLotStatisticService;
79   - @Autowired
80   - private SessionCommUtil sessionCommUtil;
81   -
82   - @ApiOperation("分页查询车流量数据统计车位总流量")
83   - @PostMapping("getVehicleFlowStatisticForPage")
84   - @ResponseBody
85   - public BizResultVO<EasyUIDataGridVO<ParkingLotUseStatisticDTO>> queryParkingLotUseStatisticForPage(
86   - @RequestBody ParkingLotUseStatisticForPageRequest request) throws Exception {
87   - if (null == request.getBeginTime() || null == request.getEndTime()) {
88   - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");
89   - }
90   - Calendar beginc = Calendar.getInstance();
91   - beginc.setTime(request.getBeginTime());
92   - int beginYear = beginc.get(Calendar.YEAR);
93   - int beginMonth = beginc.get(Calendar.MONTH) + 1;
94   - int beginDay = beginc.get(Calendar.DAY_OF_MONTH);
95   -
96   - Calendar endc = Calendar.getInstance();
97   - endc.setTime(request.getEndTime());
98   - int endYear = endc.get(Calendar.YEAR);
99   - int endMonth = endc.get(Calendar.MONTH) + 1;
100   - int endDay = endc.get(Calendar.DAY_OF_MONTH);
101   -
102   - if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) {
103   - // 2表示按每小时统计
104   - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR);
105   - } else {
106   - // 3表示按每天统计
107   - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY);
108   - }
109   -
110   - BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService
111   - .queryParkingLotUseStatisticForPage(request);
112   - return returnJqGridData(bizResult, ParkingLotUseStatisticDTO.class);
113   - }
114   -
115   - @ApiOperation("查询车流量最大值与最小值")
116   - @PostMapping("getVehicleFlowMaxAndMin")
117   - @ResponseBody
118   - public BizResultVO<ParkingLotUseStatisticMaxAndMinDTO> QueryParkingLotUseStatisticMaxAndMin(
119   - @RequestBody ParkingLotUseStatisticForPageRequest request) {
120   - Calendar beginc = Calendar.getInstance();
121   - beginc.setTime(request.getBeginTime());
122   - int beginYear = beginc.get(Calendar.YEAR);
123   - int beginMonth = beginc.get(Calendar.MONTH) + 1;
124   - int beginDay = beginc.get(Calendar.DAY_OF_MONTH);
125   -
126   - Calendar endc = Calendar.getInstance();
127   - endc.setTime(request.getEndTime());
128   - int endYear = endc.get(Calendar.YEAR);
129   - int endMonth = endc.get(Calendar.MONTH) + 1;
130   - int endDay = endc.get(Calendar.DAY_OF_MONTH);
131   -
132   - if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) {
133   - // 2表示按每小时统计
134   - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR);
135   - } else {
136   - // 3表示按每天统计
137   - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY);
138   - }
139   - BizResult<ParkingLotUseStatisticMaxAndMinDTO> bizResult = parkingLotStatisticService
140   - .QueryVehicleFlowStatisticMaxAndMin(request);
141   - return new BizResultVO<>(bizResult);
142   - }
143   -
144   - @ApiOperation("导出车流量数据统计excel")
145   - @GetMapping("exportVehicleFlowStatisticExcel")
146   - public void excelParkingLotUseStatistic(@RequestParam String beginTime, @RequestParam String endTime,
147   - @RequestParam String plNos, HttpServletRequest requests, HttpServletResponse response) {
148   - ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest();
149   - request.setSysCode(sysCode);
150   - request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT));
151   - request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT));
152   - List<String> plNoslist = new ArrayList<>();
153   - plNoslist.add(plNos);
154   - request.setPlNos(plNoslist);
155   - request.setBaseRequest(new BaseInfo(1, 0));
156   - Calendar beginc = Calendar.getInstance();
157   - beginc.setTime(request.getBeginTime());
158   - int beginYear = beginc.get(Calendar.YEAR);
159   - int beginMonth = beginc.get(Calendar.MONTH) + 1;
160   - int beginDay = beginc.get(Calendar.DAY_OF_MONTH);
161   -
162   - Calendar endc = Calendar.getInstance();
163   - endc.setTime(request.getEndTime());
164   - int endYear = endc.get(Calendar.YEAR);
165   - int endMonth = endc.get(Calendar.MONTH) + 1;
166   - int endDay = endc.get(Calendar.DAY_OF_MONTH);
167   -
168   - if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) {
169   - // 2表示按每小时统计
170   - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR);
171   - } else {
172   - // 3表示按每天统计
173   - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY);
174   - }
175   - BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService
176   - .queryParkingLotUseStatisticForPage(request);
177   - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
178   - SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
179   - String[] title = new String[] {"时间", "总车流量", "临时车流量", "固定车流量"};
180   - String sheetName = "车流量管理";
181   - String fileName = "车流量管理" + format2.format(new Date());
182   - // 1.创建excel信息
183   - XSSFSheet workSheet = ExcelUtil.createExcel(sheetName);
184   - // 2.设置excel表头和表体
185   - Layouter.buildReport(workSheet, title, 0, 0);
186   - // 3.填充数据
187   - List<Object[]> contentList = new ArrayList<Object[]>();
188   - List<ParkingLotUseStatisticDTO> list = new ArrayList<>();
189   - if (CollectionUtils.isNotEmpty(bizResult.getData().getDataList())) {
190   - list = bizResult.getData().getDataList();
191   - }
192   - for (ParkingLotUseStatisticDTO e : list) {
193   - Object[] obj = new Object[title.length];
194   - int index = 0;
195   - obj[index++] = format.format(e.getStatisticBeginTime());
196   - obj[index++] = e.getVehicleFlow();
197   - obj[index++] = e.getTmpVehicleFlow();
198   - obj[index++] = e.getFixVehicleFlow();
199   - contentList.add(obj);
200   - }
201   - ExcleFillDateManager fillUserManager = new ExcleFillDateManager();
202   - fillUserManager.fillSalesOrga(workSheet, title, contentList, 2);
203   - // 4.excel输出配置
204   - ExcelUtil.write(response, workSheet, fileName);
205   - }
206   -
207   - /**
208   - * 根据时间获取车流量折线图
209   - *
210   - * @param request
211   - * @return
212   - * @throws Exception
213   - */
214   - @ApiOperation("根据时间获取车流量折线图")
215   - @PostMapping("getVehicleFlowForLineChart")
216   - @ResponseBody
217   - public BizResultVO<LineChartVO> getVehicleFlowForLineChart(
218   - @RequestBody ParkingLotUseStatisticForPageRequest request) throws Exception {
219   -
220   - if (null == request.getBeginTime() || null == request.getEndTime()) {
221   - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");
222   - }
223   - // 2.调用接口查询当前登录人管辖的停车场名称
224   - UserInfo userInfo = sessionCommUtil.getUserInfo();
225   - List<String> plNos = userInfo.getOrgIds();
226   -// if (CollectionUtils.isEmpty(plNos)) {
227   -// throw new BizException(ErrorType.PARK_LOT_NOT_EXISTS, "停车场plnos不存在");
228   -// }
229   - request.setPlNos(plNos);
230   -
231   - logger.info("根据停车场编号获取该停车场今日车流量和车位折线图");
232   - Calendar beginTime = Calendar.getInstance();
233   - beginTime.setTime(request.getBeginTime());
234   -// int year = beginTime.get(Calendar.YEAR);
235   - Calendar endTime = Calendar.getInstance();
236   - endTime.setTime(request.getEndTime());
237   -
238   - Long dayDifference = DateUtil.getTimeDifference(new Timestamp(request.getEndTime().getTime()),
239   - new Timestamp(request.getBeginTime().getTime()));
240   - List<String> xAxisData = Lists.newArrayList();
241   - request.setBaseRequest(new BaseInfo(1, 0));
242   - String dateType = "";
243   -
244   - if (dayDifference == 0L) {
245   - // 1小时为一个时间戳
246   - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR);
247   - int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY);
248   -
249   - for (int j = 0; j <= totaltimestampCount+1; j++) {
250   - String hour = String.format("%02d", (j));
251   - xAxisData.add(hour+":00");
252   - }
253   - dateType = "HH:mm";
254   - LineChartVO vehicleFlows = getVehicleFlows(request, xAxisData, dateType);
255   - return new BizResultVO<LineChartVO>().setData(vehicleFlows);
256   -
257   - } else {
258   - // 1天为一个时间戳
259   - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY);
260   - for (int i = 0; i <=dayDifference.intValue(); i++) {
261   - Calendar tempDate = Calendar.getInstance();
262   - tempDate .setTime(request.getBeginTime());
263   - tempDate.add(Calendar.DAY_OF_MONTH, i);
264   - int beginMonth = tempDate.get(Calendar.MONTH) + 1;
265   - int beginDay = tempDate.get(Calendar.DAY_OF_MONTH);
266   - String month = String.format("%02d", (beginMonth));
267   - String day = String.format("%02d", (beginDay));
268   - xAxisData.add(month + "-" + day);
269   - }
270   - dateType = "MM-dd";
271   - LineChartVO vehicleFlows = getVehicleFlows(request, xAxisData, dateType);
272   - return new BizResultVO<LineChartVO>().setData(vehicleFlows);
273   -
274   - }
275   -
276   - }
277   -
278   - private LineChartVO getVehicleFlows(ParkingLotUseStatisticForPageRequest request, List<String> xAxisData,
279   - String dateType) {
280   - // 调用后场服务
281   - logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request));
282   - BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService
283   - .queryParkingLotUseStatisticForPage(request);
284   - PageBean<ParkingLotUseStatisticDTO> pageBean = ResultUtils.getBizResultData(bizResult);
285   - List<ParkingLotUseStatisticDTO> useStatisticDTOs = Lists.newArrayList();
286   - if (pageBean != null) {
287   - useStatisticDTOs = pageBean.getDataList();
288   - }
289   -
290   - // 保存固定车流量,时间戳和车流量对应关系
291   - Map<String, Integer> fixVehicleFlowMap = Maps.newHashMap();
292   - // 保存临时车流量,时间戳和车流量对应关系
293   - Map<String, Integer> tmpVehicleFlowMap = Maps.newHashMap();
294   - // 停车场编号和名称对应关系
295   - Map<String, String> parkNameMap = Maps.newHashMap();
296   - // 通过停车场,和统计时间分组
297   - // Map<String, Map<String, Double>> parkLotMap = Maps.newHashMap();
298   - if (!CollectionUtils.isEmpty(useStatisticDTOs)) {
299   - for (ParkingLotUseStatisticDTO statisticDTO : useStatisticDTOs) {
300   - String key = statisticDTO.getPlNo();
301   - parkNameMap.put(key, statisticDTO.getPlName());
302   - String statisBeginTime = DateUtil.getDateString(statisticDTO.getStatisticBeginTime(), dateType);
303   - // 保存固定车流量和临时车流量
304   - fixVehicleFlowMap.put(statisBeginTime,
305   - (fixVehicleFlowMap.get(statisBeginTime) == null ? 0 : fixVehicleFlowMap.get(statisBeginTime))
306   - + statisticDTO.getFixVehicleFlow());
307   - tmpVehicleFlowMap.put(statisBeginTime,
308   - (tmpVehicleFlowMap.get(statisBeginTime) == null ? 0 : tmpVehicleFlowMap.get(statisBeginTime))
309   - + statisticDTO.getTmpVehicleFlow());
310   - }
311   - }
312   -
313   - // 封装车流量统计
314   - LineChartVO vehicleFlows = new LineChartVO();
315   - List<String> vehicleFlows_legendData = Lists.newArrayList();
316   - vehicleFlows_legendData.add("临时车");
317   - vehicleFlows_legendData.add("固定车");
318   - vehicleFlows.setLegendData(vehicleFlows_legendData);
319   - vehicleFlows.setxAxisData(xAxisData);
320   - List<SerieVO> vehicleSeries = Lists.newArrayList();
321   - // 固定车
322   - SerieVO fixSerieVo = new SerieVO();
323   - fixSerieVo.setName("固定车");
324   - List<Integer> fixSerieVoData = Lists.newArrayList();
325   - // 临时车
326   - SerieVO tmpSerieVo = new SerieVO();
327   - tmpSerieVo.setName("临时车");
328   - List<Integer> tmpSerieVoData = Lists.newArrayList();
329   - // 保存上一次的临时车值,当某个时间点没有数据时,则保持和上次一致
330   - Integer lastfixFlow = 0;
331   - Integer lasttmpFlow = 0;
332   - for (String timestamp : xAxisData) {
333   -
334   - if (fixVehicleFlowMap.containsKey(timestamp)) {
335   - lastfixFlow = fixVehicleFlowMap.get(timestamp).intValue();
336   - } else {
337   - lastfixFlow = 0;
338   - }
339   - fixSerieVoData.add(lastfixFlow);
340   -
341   - if (tmpVehicleFlowMap.containsKey(timestamp)) {
342   - lasttmpFlow = tmpVehicleFlowMap.get(timestamp).intValue();
343   - } else {
344   - lasttmpFlow = 0;
345   - }
346   - tmpSerieVoData.add(lasttmpFlow);
347   - }
348   - fixSerieVo.setData(fixSerieVoData);
349   - vehicleSeries.add(fixSerieVo);
350   - tmpSerieVo.setData(tmpSerieVoData);
351   - vehicleSeries.add(tmpSerieVo);
352   -
353   - vehicleFlows.setSeries(vehicleSeries);
354   - return vehicleFlows;
355   - }
356   -
357   - public static void main(String[] args) {
358   - String json
359   - = "{\"id\":\"1\",\"platform\":\"android\",\"parameter\":{\"drid\":\"177277364\",\"sex\":\"1\",\"type\":\"2\",\"creatorname\":\"Mrw\",\"username\":\"jack\",\"pwd\":\"123456\",\"remark\":\"平板用户\",\"createtime\":\"2017-07-24 23:59:59\"}}";
360   - JSONObject object = (JSONObject)JSONObject.parse(json);
361   - System.out.println(object.get("id"));
362   - System.out.println(object.get("platform"));
363   - JSONObject parameter = (JSONObject)object.get("parameter");
364   - System.out.println(parameter.get("drid"));
365   - System.out.println(parameter.get("sex"));
366   - }
  72 + private Logger logger = LoggerFactory.getLogger(VehicleFlowStatisticController.class);
  73 +
  74 + @Value("${project.syscode}")
  75 + private String sysCode;
  76 +
  77 + @Autowired
  78 + private ParkingLotUseStatisticService parkingLotStatisticService;
  79 +
  80 + /**
  81 + * langlw 2017-8-25
  82 + *
  83 + * @param request
  84 + * @return
  85 + * @throws Exception
  86 + */
  87 + @ApiOperation("分页查询车流量数据统计车位总流量")
  88 + @PostMapping("getVehicleFlowStatisticForPage")
  89 + @ResponseBody
  90 + public BizResultVO<EasyUIDataGridVO<ParkingLotUseStatisticDTO>> queryParkingLotUseStatisticForPage(
  91 + @RequestBody ParkingLotUseStatisticForPageRequest request) throws Exception {
  92 + if (null == request.getBeginTime() || null == request.getEndTime()) {
  93 + throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");
  94 + }
  95 + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY);
  96 + BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService
  97 + .queryParkingLotUseStatisticForPage(request);
  98 + return returnJqGridData(bizResult, ParkingLotUseStatisticDTO.class);
  99 + }
  100 +
  101 + @ApiOperation("查询车流量最大值与最小值")
  102 + @PostMapping("getVehicleFlowMaxAndMin")
  103 + @ResponseBody
  104 + public BizResultVO<ParkingLotUseStatisticMaxAndMinDTO> QueryParkingLotUseStatisticMaxAndMin(
  105 + @RequestBody ParkingLotUseStatisticForPageRequest request) {
  106 + Calendar beginc = Calendar.getInstance();
  107 + beginc.setTime(request.getBeginTime());
  108 + int beginYear = beginc.get(Calendar.YEAR);
  109 + int beginMonth = beginc.get(Calendar.MONTH) + 1;
  110 + int beginDay = beginc.get(Calendar.DAY_OF_MONTH);
  111 +
  112 + Calendar endc = Calendar.getInstance();
  113 + endc.setTime(request.getEndTime());
  114 + int endYear = endc.get(Calendar.YEAR);
  115 + int endMonth = endc.get(Calendar.MONTH) + 1;
  116 + int endDay = endc.get(Calendar.DAY_OF_MONTH);
  117 +
  118 + if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) {
  119 + // 2表示按每小时统计
  120 + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR);
  121 + } else {
  122 + // 3表示按每天统计
  123 + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY);
  124 + }
  125 + BizResult<ParkingLotUseStatisticMaxAndMinDTO> bizResult = parkingLotStatisticService
  126 + .QueryVehicleFlowStatisticMaxAndMin(request);
  127 + return new BizResultVO<>(bizResult);
  128 + }
  129 +
  130 + /**
  131 + * langlw 2017-8-24
  132 + *
  133 + * @param beginTime
  134 + * @param endTime
  135 + * @param plNos
  136 + * @param requests
  137 + * @param response
  138 + */
  139 + @ApiOperation("日报表导出车流量数据统计excel")
  140 + @GetMapping("exportVehicleFlowStatisticExcel")
  141 + public void excelParkingLotUseStatistic(@RequestParam String beginTime, @RequestParam String endTime,
  142 + @RequestParam List<String> plNos, HttpServletRequest requests, HttpServletResponse response) {
  143 + ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest();
  144 + request.setSysCode(sysCode);
  145 + request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT));
  146 + request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT));
  147 + request.setPlNos(plNos);
  148 + request.setBaseRequest(new BaseInfo(1, 0));
  149 + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY);
  150 + BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService
  151 + .queryParkingLotUseStatisticForPage(request);
  152 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  153 + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
  154 + String[] title = new String[] { "时间", "停车场", "进场车流量", "出场车流量" };
  155 + String sheetName = "日报表车流量管理";
  156 + String fileName = "日报表车流量管理" + format2.format(new Date());
  157 + // 1.创建excel信息
  158 + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName);
  159 + // 2.设置excel表头和表体
  160 + Layouter.buildReport(workSheet, title, 0, 0);
  161 + // 3.填充数据
  162 + List<Object[]> contentList = new ArrayList<Object[]>();
  163 + List<ParkingLotUseStatisticDTO> list = new ArrayList<>();
  164 + if (CollectionUtils.isNotEmpty(bizResult.getData().getDataList())) {
  165 + list = bizResult.getData().getDataList();
  166 + }
  167 + for (ParkingLotUseStatisticDTO e : list) {
  168 + Object[] obj = new Object[title.length];
  169 + int index = 0;
  170 + obj[index++] = format.format(e.getStatisticBeginTime());
  171 + obj[index++] = StringUtils.isEmpty(e.getPlName()) ? "" : e.getPlName();
  172 + obj[index++] = e.getTmpVehicleFlow();
  173 + obj[index++] = e.getOutParkCount();
  174 + contentList.add(obj);
  175 + }
  176 + ExcleFillDateManager fillUserManager = new ExcleFillDateManager();
  177 + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2);
  178 + // 4.excel输出配置
  179 + ExcelUtil.write(response, workSheet, fileName);
  180 + }
  181 +
  182 + /**
  183 + * 根据时间获取车流量折线图 langlw 2017-8-25
  184 + *
  185 + * @param request
  186 + * @return
  187 + * @throws Exception
  188 + */
  189 + @ApiOperation("根据时间获取车流量折线图")
  190 + @PostMapping("getVehicleFlowForLineChart")
  191 + @ResponseBody
  192 + public BizResultVO<LineChartVO> getVehicleFlowForLineChart(
  193 + @RequestBody ParkingLotUseStatisticForPageRequest request) throws Exception {
  194 +
  195 + if (null == request.getBeginTime() || null == request.getEndTime()) {
  196 + throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");
  197 + }
  198 + logger.info("根据停车场编号获取该停车场今日车流量和车位折线图");
  199 + Calendar beginTime = Calendar.getInstance();
  200 + beginTime.setTime(request.getBeginTime());
  201 + Calendar endTime = Calendar.getInstance();
  202 + endTime.setTime(request.getEndTime());
  203 +
  204 + Long dayDifference = DateUtil.getTimeDifference(new Timestamp(request.getEndTime().getTime()),
  205 + new Timestamp(request.getBeginTime().getTime()));
  206 + List<String> xAxisData = Lists.newArrayList();
  207 + request.setBaseRequest(new BaseInfo(1, 0));
  208 + String dateType = "";
  209 +
  210 + if (dayDifference == 0L) {
  211 + // 1小时为一个时间戳
  212 + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR);
  213 + int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY);
  214 +
  215 + for (int j = 0; j <= totaltimestampCount + 1; j++) {
  216 + String hour = String.format("%02d", (j));
  217 + xAxisData.add(hour + ":00");
  218 + }
  219 + dateType = "HH:mm";
  220 + LineChartVO vehicleFlows = getVehicleFlows(request, xAxisData, dateType);
  221 + return new BizResultVO<LineChartVO>().setData(vehicleFlows);
  222 +
  223 + } else {
  224 + // 1天为一个时间戳
  225 + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY);
  226 + for (int i = 0; i <= dayDifference.intValue(); i++) {
  227 + Calendar tempDate = Calendar.getInstance();
  228 + tempDate.setTime(request.getBeginTime());
  229 + tempDate.add(Calendar.DAY_OF_MONTH, i);
  230 + int beginMonth = tempDate.get(Calendar.MONTH) + 1;
  231 + int beginDay = tempDate.get(Calendar.DAY_OF_MONTH);
  232 + String month = String.format("%02d", (beginMonth));
  233 + String day = String.format("%02d", (beginDay));
  234 + xAxisData.add(month + "-" + day);
  235 + }
  236 + dateType = "MM-dd";
  237 + LineChartVO vehicleFlows = getVehicleFlows(request, xAxisData, dateType);
  238 + return new BizResultVO<LineChartVO>().setData(vehicleFlows);
  239 +
  240 + }
  241 +
  242 + }
  243 +
  244 + private LineChartVO getVehicleFlows(ParkingLotUseStatisticForPageRequest request, List<String> xAxisData,
  245 + String dateType) {
  246 + // 调用后场服务
  247 + logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request));
  248 + BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService
  249 + .queryParkingLotUseStatisticForPage(request);
  250 + PageBean<ParkingLotUseStatisticDTO> pageBean = ResultUtils.getBizResultData(bizResult);
  251 + List<ParkingLotUseStatisticDTO> useStatisticDTOs = Lists.newArrayList();
  252 + if (pageBean != null) {
  253 + useStatisticDTOs = pageBean.getDataList();
  254 + }
  255 +
  256 + // 保存固定车流量,时间戳和车流量对应关系
  257 + Map<String, Integer> fixVehicleFlowMap = Maps.newHashMap();
  258 + // 保存临时车流量,时间戳和车流量对应关系
  259 + Map<String, Integer> tmpVehicleFlowMap = Maps.newHashMap();
  260 + // 停车场编号和名称对应关系
  261 + Map<String, String> parkNameMap = Maps.newHashMap();
  262 + // 通过停车场,和统计时间分组
  263 + // Map<String, Map<String, Double>> parkLotMap = Maps.newHashMap();
  264 + if (!CollectionUtils.isEmpty(useStatisticDTOs)) {
  265 + for (ParkingLotUseStatisticDTO statisticDTO : useStatisticDTOs) {
  266 + String key = statisticDTO.getPlNo();
  267 + parkNameMap.put(key, statisticDTO.getPlName());
  268 + String statisEndTime = DateUtil.getDateString(statisticDTO.getStatisticEndTime(), dateType);
  269 + // 保存固定车流量和临时车流量
  270 + fixVehicleFlowMap.put(statisEndTime,
  271 + (fixVehicleFlowMap.get(statisEndTime) == null ? 0 : fixVehicleFlowMap.get(statisEndTime))
  272 + + statisticDTO.getOutParkCount());
  273 + tmpVehicleFlowMap.put(statisEndTime,
  274 + (tmpVehicleFlowMap.get(statisEndTime) == null ? 0 : tmpVehicleFlowMap.get(statisEndTime))
  275 + + statisticDTO.getTmpVehicleFlow());
  276 + }
  277 + }
  278 +
  279 + // 封装车流量统计
  280 + LineChartVO vehicleFlows = new LineChartVO();
  281 + List<String> vehicleFlows_legendData = Lists.newArrayList();
  282 + vehicleFlows_legendData.add("入车");
  283 + vehicleFlows_legendData.add("出车");
  284 + vehicleFlows.setLegendData(vehicleFlows_legendData);
  285 + vehicleFlows.setxAxisData(xAxisData);
  286 + List<SerieVO> vehicleSeries = Lists.newArrayList();
  287 + // 固定车
  288 + SerieVO fixSerieVo = new SerieVO();
  289 + fixSerieVo.setName("出车");
  290 + List<Integer> fixSerieVoData = Lists.newArrayList();
  291 + // 临时车
  292 + SerieVO tmpSerieVo = new SerieVO();
  293 + tmpSerieVo.setName("入车");
  294 + List<Integer> tmpSerieVoData = Lists.newArrayList();
  295 + // 保存上一次的临时车值,当某个时间点没有数据时,则保持和上次一致
  296 + Integer lastfixFlow = 0;
  297 + Integer lasttmpFlow = 0;
  298 + for (String timestamp : xAxisData) {
  299 +
  300 + if (fixVehicleFlowMap.containsKey(timestamp)) {
  301 + lastfixFlow = fixVehicleFlowMap.get(timestamp).intValue();
  302 + } else {
  303 + lastfixFlow = 0;
  304 + }
  305 + fixSerieVoData.add(lastfixFlow);
  306 +
  307 + if (tmpVehicleFlowMap.containsKey(timestamp)) {
  308 + lasttmpFlow = tmpVehicleFlowMap.get(timestamp).intValue();
  309 + } else {
  310 + lasttmpFlow = 0;
  311 + }
  312 + tmpSerieVoData.add(lasttmpFlow);
  313 + }
  314 + fixSerieVo.setData(fixSerieVoData);
  315 + vehicleSeries.add(fixSerieVo);
  316 + tmpSerieVo.setData(tmpSerieVoData);
  317 + vehicleSeries.add(tmpSerieVo);
  318 +
  319 + vehicleFlows.setSeries(vehicleSeries);
  320 + return vehicleFlows;
  321 + }
  322 +
  323 + /**
  324 + * langlw 2017-8-25 Monthly parking volume, vacancy rate and turnover rate
  325 + * are examined 按月统计进出场车流量和占用率和周转率
  326 + *
  327 + * @param request
  328 + * @return
  329 + * @throws Exception
  330 + */
  331 + @ApiOperation("按月统计进出场车流量和占用率和周转率")
  332 + @PostMapping("queryMonthVehicleFlowAndVacancyRateAndTurnover")
  333 + @ResponseBody
  334 + public BizResultVO<EasyUIDataGridVO<MonthVehicleFlowAndVacancyRateAndTurnoverDTO>> queryMonthVehicleFlowAndVacancyRateAndTurnover(
  335 + @RequestBody ParkingLotUseStatisticForPageRequest request) throws Exception {
  336 + if (null == request.getBeginTime() || null == request.getEndTime()) {
  337 + throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");
  338 + }
  339 + BizResult<PageBean<MonthVehicleFlowAndVacancyRateAndTurnoverDTO>> bizResult = parkingLotStatisticService
  340 + .queryMonthVehicleFlowAndVacancyRateAndTurnover(request);
  341 + return returnJqGridData(bizResult, MonthVehicleFlowAndVacancyRateAndTurnoverDTO.class);
  342 + }
  343 +
  344 + @ApiOperation("按月导出车流量数据统计excel")
  345 + @GetMapping("exportVehicleFlowStatisticExcelForMonth")
  346 + public void excelParkingLotUseStatisticForMonth(@RequestParam String beginTime, @RequestParam String endTime,
  347 + @RequestParam List<String> plNos, HttpServletRequest requests, HttpServletResponse response) {
  348 + ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest();
  349 + request.setSysCode(sysCode);
  350 + request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT));
  351 + request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT));
  352 + request.setPlNos(plNos);
  353 + request.setBaseRequest(new BaseInfo(1, 0));
  354 + BizResult<PageBean<MonthVehicleFlowAndVacancyRateAndTurnoverDTO>> bizResult = parkingLotStatisticService
  355 + .queryMonthVehicleFlowAndVacancyRateAndTurnover(request);
  356 +
  357 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  358 + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
  359 + String[] title = new String[] { "时间", "停车场", "进场车流量", "出场车流量" };
  360 + String sheetName = "月报表车流量管理";
  361 + String fileName = "月报表车流量管理" + format2.format(new Date());
  362 + // 1.创建excel信息
  363 + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName);
  364 + // 2.设置excel表头和表体
  365 + Layouter.buildReport(workSheet, title, 0, 0);
  366 + // 3.填充数据
  367 + List<Object[]> contentList = new ArrayList<Object[]>();
  368 + List<MonthVehicleFlowAndVacancyRateAndTurnoverDTO> list = new ArrayList<>();
  369 + if (CollectionUtils.isNotEmpty(bizResult.getData().getDataList())) {
  370 + list = bizResult.getData().getDataList();
  371 + }
  372 + for (MonthVehicleFlowAndVacancyRateAndTurnoverDTO e : list) {
  373 + Object[] obj = new Object[title.length];
  374 + int index = 0;
  375 + obj[index++] = e.getStatisticTime();
  376 + obj[index++] = StringUtils.isEmpty(e.getPlName()) ? "" : e.getPlName();
  377 + obj[index++] = e.getSumInVehicleflow();
  378 + obj[index++] = e.getSumOutVehicleflow();
  379 + contentList.add(obj);
  380 + }
  381 + ExcleFillDateManager fillUserManager = new ExcleFillDateManager();
  382 + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2);
  383 + // 4.excel输出配置
  384 + ExcelUtil.write(response, workSheet, fileName);
  385 + }
  386 +
  387 + /**
  388 + * langlw 2017-8-24
  389 + *
  390 + * @param beginTime
  391 + * @param endTime
  392 + * @param plNos
  393 + * @param requests
  394 + * @param response
  395 + */
  396 + @ApiOperation("下载车流量数据统计详情excel")
  397 + @GetMapping("downloadVehicleFlowStatisticExcel")
  398 + public void downloadVehicleFlowStatisticExcel(@RequestParam String beginTime, @RequestParam String endTime,
  399 + @RequestParam List<String> plNos, @RequestParam String parkName, HttpServletRequest requests,
  400 + HttpServletResponse response) {
  401 + ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest();
  402 + request.setSysCode(sysCode);
  403 + request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT));
  404 + request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT));
  405 + request.setPlNos(plNos);
  406 + request.setBaseRequest(new BaseInfo(1, 0));
  407 + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR);
  408 +
  409 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  410 + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
  411 +
  412 + List<String> xAxisData = Lists.newArrayList();
  413 + String[] title = new String[26];
  414 + title[0] = "";
  415 + for (int j = 0; j <= 24; j++) {
  416 + String hour = String.format("%02d", (j));
  417 + title[j + 1] = hour + ":00";
  418 + xAxisData.add(hour + ":00");
  419 + }
  420 +
  421 + String dateType = "HH:mm";
  422 + LineChartVO VehicleFlows = getVehicleFlows(request, xAxisData, dateType);
  423 +
  424 + String sheetName = "日报表车流量使用统计";
  425 + String fileName = "日报表车流量使用统计" + format2.format(new Date());
  426 + // 1.创建excel信息
  427 + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName);
  428 + // 2.设置excel表头和表体
  429 + Layouter.buildReport(workSheet, title, 0, 0);
  430 + // 3.填充数据
  431 + List<Object[]> contentList = new ArrayList<Object[]>();
  432 +
  433 + for (SerieVO e : VehicleFlows.getSeries()) {
  434 + Object[] obj = new Object[title.length];
  435 + obj[0] = e.getName();
  436 + int index = 1;
  437 + for (Integer i : e.getData()) {
  438 + obj[index++] = i;
  439 + }
  440 + contentList.add(obj);
  441 + }
  442 +
  443 + ExcleFillDateManager fillUserManager = new ExcleFillDateManager();
  444 + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2);
  445 + // 4.excel输出配置
  446 + ExcelUtil.write(response, workSheet, fileName);
  447 + }
  448 +
  449 + /**
  450 + * langlw 2017-8-24
  451 + *
  452 + * @param beginTime
  453 + * @param endTime
  454 + * @param plNos
  455 + * @param requests
  456 + * @param response
  457 + */
  458 + @ApiOperation("按月下载车流量数据统计详情excel")
  459 + @GetMapping("downloadVehicleFlowStatisticExcelForMonth")
  460 + public void downloadVehicleFlowStatisticExcelForMonth(@RequestParam String beginTime, @RequestParam String endTime,
  461 + @RequestParam List<String> plNos, @RequestParam String parkName, HttpServletRequest requests,
  462 + HttpServletResponse response) {
  463 + ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest();
  464 + request.setSysCode(sysCode);
  465 + request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT));
  466 + request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT));
  467 + request.setPlNos(plNos);
  468 + request.setBaseRequest(new BaseInfo(1, 0));
  469 + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY);
  470 +
  471 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  472 + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
  473 +
  474 + Calendar beginTimec = Calendar.getInstance();
  475 + beginTimec.setTime(request.getBeginTime());
  476 +
  477 + Calendar endTimec = Calendar.getInstance();
  478 + endTimec.setTime(request.getEndTime());
  479 +
  480 + Long dayDifference = DateUtil.getTimeDifference(new Timestamp(request.getEndTime().getTime()),
  481 + new Timestamp(request.getBeginTime().getTime()));
  482 +
  483 + List<String> xAxisData = Lists.newArrayList();
  484 + String[] title = new String[dayDifference.intValue() + 2];
  485 + title[0] = "";
  486 + for (int i = 0; i <= dayDifference.intValue(); i++) {
  487 + Calendar tempDate = Calendar.getInstance();
  488 + tempDate.setTime(request.getBeginTime());
  489 + tempDate.add(Calendar.DAY_OF_MONTH, i);
  490 + int beginMonth = tempDate.get(Calendar.MONTH) + 1;
  491 + int beginDay = tempDate.get(Calendar.DAY_OF_MONTH);
  492 + String month = String.format("%02d", (beginMonth));
  493 + String day = String.format("%02d", (beginDay));
  494 + title[i + 1] = month + "-" + day;
  495 + xAxisData.add(month + "-" + day);
  496 +
  497 + }
  498 +
  499 + String dateType = "MM-dd";
  500 + LineChartVO VehicleFlows = getVehicleFlows(request, xAxisData, dateType);
  501 +
  502 + String sheetName = "月报表车流量使用统计";
  503 + String fileName = "月报表车流量使用统计" + format2.format(new Date());
  504 + // 1.创建excel信息
  505 + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName);
  506 + // 2.设置excel表头和表体
  507 + Layouter.buildReport(workSheet, title, 0, 0);
  508 + // 3.填充数据
  509 + List<Object[]> contentList = new ArrayList<Object[]>();
  510 +
  511 + for (SerieVO e : VehicleFlows.getSeries()) {
  512 + Object[] obj = new Object[title.length];
  513 + obj[0] = e.getName();
  514 + int index = 1;
  515 + for (Integer i : e.getData()) {
  516 + obj[index++] = i;
  517 + }
  518 + contentList.add(obj);
  519 + }
  520 +
  521 + ExcleFillDateManager fillUserManager = new ExcleFillDateManager();
  522 + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2);
  523 + // 4.excel输出配置
  524 + ExcelUtil.write(response, workSheet, fileName);
  525 + }
  526 +
  527 + public static void main(String[] args) {
  528 + String json = "{\"id\":\"1\",\"platform\":\"android\",\"parameter\":{\"drid\":\"177277364\",\"sex\":\"1\",\"type\":\"2\",\"creatorname\":\"Mrw\",\"username\":\"jack\",\"pwd\":\"123456\",\"remark\":\"平板用户\",\"createtime\":\"2017-07-24 23:59:59\"}}";
  529 + JSONObject object = (JSONObject) JSONObject.parse(json);
  530 + System.out.println(object.get("id"));
  531 + System.out.println(object.get("platform"));
  532 + JSONObject parameter = (JSONObject) object.get("parameter");
  533 + System.out.println(parameter.get("drid"));
  534 + System.out.println(parameter.get("sex"));
  535 + }
367 536  
368 537 }
... ...