Commit 7d3ac82b93f469cfcbea0bbe1701066e68abbe9b
Merge branch 'branch_0808' of http://192.168.1.195:9998/ZTEITS-Developers/zteits…
…-bcp-portal.git into branch_0808
Showing
5 changed files
with
799 additions
and
506 deletions
src/main/java/com/zteits/irain/portal/vo/fangle/BerthStateRequest.java deleted
| 1 | -package com.zteits.irain.portal.vo.fangle; | ||
| 2 | - | ||
| 3 | -import com.zteits.clouds.api.apibase.bean.BaseRequest; | ||
| 4 | - | ||
| 5 | -public class BerthStateRequest extends BaseRequest{ | ||
| 6 | - | ||
| 7 | - private static final long serialVersionUID = 1L; | ||
| 8 | - | ||
| 9 | - /**记录编号*/ | ||
| 10 | - private String log_id; | ||
| 11 | - | ||
| 12 | - /**泊位编码*/ | ||
| 13 | - private String berthcode; | ||
| 14 | - | ||
| 15 | - /**状态变更时间*/ | ||
| 16 | - private String changetime; | ||
| 17 | - | ||
| 18 | - /**泊位状态*/ | ||
| 19 | - private String berthstatus; | ||
| 20 | - | ||
| 21 | - /**电量*/ | ||
| 22 | - private String electricity; | ||
| 23 | - | ||
| 24 | - /**电压值*/ | ||
| 25 | - private String voltage; | ||
| 26 | - | ||
| 27 | - public String getLog_id() { | ||
| 28 | - return log_id; | ||
| 29 | - } | ||
| 30 | - | ||
| 31 | - public void setLog_id(String log_id) { | ||
| 32 | - this.log_id = log_id; | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - public String getBerthcode() { | ||
| 36 | - return berthcode; | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - public void setBerthcode(String berthcode) { | ||
| 40 | - this.berthcode = berthcode; | ||
| 41 | - } | ||
| 42 | - | ||
| 43 | - public String getChangetime() { | ||
| 44 | - return changetime; | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - public void setChangetime(String changetime) { | ||
| 48 | - this.changetime = changetime; | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - public String getBerthstatus() { | ||
| 52 | - return berthstatus; | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - public void setBerthstatus(String berthstatus) { | ||
| 56 | - this.berthstatus = berthstatus; | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - public String getElectricity() { | ||
| 60 | - return electricity; | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - public void setElectricity(String electricity) { | ||
| 64 | - this.electricity = electricity; | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - public String getVoltage() { | ||
| 68 | - return voltage; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - public void setVoltage(String voltage) { | ||
| 72 | - this.voltage = voltage; | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | - @Override | ||
| 76 | - public String toString() { | ||
| 77 | - return "BerthStateRequest [log_id=" + log_id + ", berthcode=" + berthcode + ", changetime=" + changetime | ||
| 78 | - + ", berthstatus=" + berthstatus + ", electricity=" + electricity + ", voltage=" + voltage + "]"; | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - | ||
| 82 | -} |
src/main/java/com/zteits/irain/portal/vo/fangle/EqpHeartBeatRequest.java deleted
| 1 | -package com.zteits.irain.portal.vo.fangle; | ||
| 2 | - | ||
| 3 | -import com.zteits.clouds.api.apibase.bean.BaseRequest; | ||
| 4 | - | ||
| 5 | -public class EqpHeartBeatRequest extends BaseRequest{ | ||
| 6 | - | ||
| 7 | - private static final long serialVersionUID = 1L; | ||
| 8 | - | ||
| 9 | - /**设备类型*/ | ||
| 10 | - private String EquipmentType; | ||
| 11 | - | ||
| 12 | - /**设备编号*/ | ||
| 13 | - private String EquipmentCode; | ||
| 14 | - | ||
| 15 | - /**设备状态*/ | ||
| 16 | - private String EquipmentStatus; | ||
| 17 | - | ||
| 18 | - /**推送时间*/ | ||
| 19 | - private String PushTime; | ||
| 20 | - | ||
| 21 | - public String getEquipmentType() { | ||
| 22 | - return EquipmentType; | ||
| 23 | - } | ||
| 24 | - | ||
| 25 | - public void setEquipmentType(String equipmentType) { | ||
| 26 | - EquipmentType = equipmentType; | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | - public String getEquipmentCode() { | ||
| 30 | - return EquipmentCode; | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - public void setEquipmentCode(String equipmentCode) { | ||
| 34 | - EquipmentCode = equipmentCode; | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | - public String getEquipmentStatus() { | ||
| 38 | - return EquipmentStatus; | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - public void setEquipmentStatus(String equipmentStatus) { | ||
| 42 | - EquipmentStatus = equipmentStatus; | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - public String getPushTime() { | ||
| 46 | - return PushTime; | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - public void setPushTime(String pushTime) { | ||
| 50 | - PushTime = pushTime; | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | - @Override | ||
| 54 | - public String toString() { | ||
| 55 | - return "EqpHeartBeatRequest [EquipmentType=" + EquipmentType + ", EquipmentCode=" + EquipmentCode | ||
| 56 | - + ", EquipmentStatus=" + EquipmentStatus + ", PushTime=" + PushTime + "]"; | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - | ||
| 60 | -} |
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/BerthsStatisticController.java
| @@ -2,6 +2,7 @@ package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; | @@ -2,6 +2,7 @@ package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; | ||
| 2 | 2 | ||
| 3 | import java.math.BigDecimal; | 3 | import java.math.BigDecimal; |
| 4 | import java.sql.Timestamp; | 4 | import java.sql.Timestamp; |
| 5 | +import java.text.DecimalFormat; | ||
| 5 | import java.text.SimpleDateFormat; | 6 | import java.text.SimpleDateFormat; |
| 6 | import java.util.ArrayList; | 7 | import java.util.ArrayList; |
| 7 | import java.util.Calendar; | 8 | import java.util.Calendar; |
| @@ -30,15 +31,12 @@ import org.springframework.web.bind.annotation.ResponseBody; | @@ -30,15 +31,12 @@ import org.springframework.web.bind.annotation.ResponseBody; | ||
| 30 | import com.alibaba.dubbo.common.utils.CollectionUtils; | 31 | import com.alibaba.dubbo.common.utils.CollectionUtils; |
| 31 | import com.alibaba.fastjson.JSON; | 32 | import com.alibaba.fastjson.JSON; |
| 32 | import com.clouds.common.cache.park.ParkingLotCacheUtil; | 33 | import com.clouds.common.cache.park.ParkingLotCacheUtil; |
| 33 | -import com.clouds.common.entity.UserInfo; | ||
| 34 | -import com.clouds.common.redis.RedisCacheUtil; | ||
| 35 | import com.clouds.common.utils.DateUtil; | 34 | import com.clouds.common.utils.DateUtil; |
| 36 | import com.clouds.common.utils.ResultUtils; | 35 | import com.clouds.common.utils.ResultUtils; |
| 37 | import com.clouds.common.utils.excle.ExcelUtil; | 36 | import com.clouds.common.utils.excle.ExcelUtil; |
| 38 | import com.clouds.common.utils.excle.ExcleFillDateManager; | 37 | import com.clouds.common.utils.excle.ExcleFillDateManager; |
| 39 | import com.clouds.common.utils.excle.Layouter; | 38 | import com.clouds.common.utils.excle.Layouter; |
| 40 | import com.clouds.common.web.BizController; | 39 | import com.clouds.common.web.BizController; |
| 41 | -import com.clouds.common.web.SessionCommUtil; | ||
| 42 | import com.clouds.common.web.vo.BizResultVO; | 40 | import com.clouds.common.web.vo.BizResultVO; |
| 43 | import com.clouds.common.web.vo.EasyUIDataGridVO; | 41 | import com.clouds.common.web.vo.EasyUIDataGridVO; |
| 44 | import com.google.common.collect.Lists; | 42 | import com.google.common.collect.Lists; |
| @@ -48,20 +46,19 @@ import com.zteits.clouds.api.apibase.bean.BizResult; | @@ -48,20 +46,19 @@ import com.zteits.clouds.api.apibase.bean.BizResult; | ||
| 48 | import com.zteits.clouds.api.apibase.bean.PageBean; | 46 | import com.zteits.clouds.api.apibase.bean.PageBean; |
| 49 | import com.zteits.clouds.api.apibase.constants.ErrorType; | 47 | import com.zteits.clouds.api.apibase.constants.ErrorType; |
| 50 | import com.zteits.clouds.api.apibase.exception.BizException; | 48 | import com.zteits.clouds.api.apibase.exception.BizException; |
| 49 | +import com.zteits.clouds.api.dto.park.dto.MonthVehicleFlowAndVacancyRateAndTurnoverDTO; | ||
| 51 | import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; | 50 | import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; |
| 52 | import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO; | 51 | import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO; |
| 53 | import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticMaxAndMinDTO; | 52 | import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticMaxAndMinDTO; |
| 54 | import com.zteits.clouds.api.dto.park.param.ParkFreeBerthGetByPlnoRequest; | 53 | import com.zteits.clouds.api.dto.park.param.ParkFreeBerthGetByPlnoRequest; |
| 55 | import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest; | 54 | import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest; |
| 56 | import com.zteits.clouds.api.dto.park.param.QueryParkLotInfoByPkNoRequest; | 55 | import com.zteits.clouds.api.dto.park.param.QueryParkLotInfoByPkNoRequest; |
| 57 | -import com.zteits.clouds.api.dto.pay.TdBOrderDTO; | ||
| 58 | import com.zteits.clouds.api.dto.pay.param.QueryTodayOrderRequest; | 56 | import com.zteits.clouds.api.dto.pay.param.QueryTodayOrderRequest; |
| 59 | import com.zteits.clouds.api.service.park.ParkFreeBerthService; | 57 | import com.zteits.clouds.api.service.park.ParkFreeBerthService; |
| 60 | import com.zteits.clouds.api.service.park.ParkingLotQueryService; | 58 | import com.zteits.clouds.api.service.park.ParkingLotQueryService; |
| 61 | import com.zteits.clouds.api.service.park.ParkingLotUseStatisticService; | 59 | import com.zteits.clouds.api.service.park.ParkingLotUseStatisticService; |
| 62 | import com.zteits.clouds.api.service.pay.TdBOrderService; | 60 | import com.zteits.clouds.api.service.pay.TdBOrderService; |
| 63 | import com.zteits.irain.portal.constant.ParkConstant; | 61 | import com.zteits.irain.portal.constant.ParkConstant; |
| 64 | -import com.zteits.irain.portal.vo.govclouds.ParkLotStatisticVO; | ||
| 65 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO; | 62 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO; |
| 66 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO.SerieVO; | 63 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO.SerieVO; |
| 67 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.ParkStaticsticAndTodayAmountVO; | 64 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.ParkStaticsticAndTodayAmountVO; |
| @@ -94,8 +91,6 @@ public class BerthsStatisticController extends BizController { | @@ -94,8 +91,6 @@ public class BerthsStatisticController extends BizController { | ||
| 94 | @Autowired | 91 | @Autowired |
| 95 | private ParkingLotUseStatisticService parkingLotStatisticService; | 92 | private ParkingLotUseStatisticService parkingLotStatisticService; |
| 96 | @Autowired | 93 | @Autowired |
| 97 | - private SessionCommUtil sessionCommUtil; | ||
| 98 | - @Autowired | ||
| 99 | private TdBOrderService tdBOrderService; | 94 | private TdBOrderService tdBOrderService; |
| 100 | @Autowired | 95 | @Autowired |
| 101 | private ParkFreeBerthService parkFreeBerthService; | 96 | private ParkFreeBerthService parkFreeBerthService; |
| @@ -137,6 +132,13 @@ public class BerthsStatisticController extends BizController { | @@ -137,6 +132,13 @@ public class BerthsStatisticController extends BizController { | ||
| 137 | return new BizResultVO<>(respondObject); | 132 | return new BizResultVO<>(respondObject); |
| 138 | } | 133 | } |
| 139 | 134 | ||
| 135 | + /** | ||
| 136 | + * langlw 2017-8-24 | ||
| 137 | + * @param requestObject | ||
| 138 | + * @return | ||
| 139 | + * @throws InstantiationException | ||
| 140 | + * @throws IllegalAccessException | ||
| 141 | + */ | ||
| 140 | @ApiOperation("获取车位使用情况统计列表") | 142 | @ApiOperation("获取车位使用情况统计列表") |
| 141 | @PostMapping("getstatisticlist") | 143 | @PostMapping("getstatisticlist") |
| 142 | @ResponseBody | 144 | @ResponseBody |
| @@ -146,68 +148,36 @@ public class BerthsStatisticController extends BizController { | @@ -146,68 +148,36 @@ public class BerthsStatisticController extends BizController { | ||
| 146 | if (null == requestObject.getBeginTime() || null == requestObject.getEndTime()) { | 148 | if (null == requestObject.getBeginTime() || null == requestObject.getEndTime()) { |
| 147 | throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); | 149 | throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); |
| 148 | } | 150 | } |
| 149 | - | ||
| 150 | - Calendar beginc = Calendar.getInstance(); | ||
| 151 | - beginc.setTime(requestObject.getBeginTime()); | ||
| 152 | - int beginYear = beginc.get(Calendar.YEAR); | ||
| 153 | - int beginMonth = beginc.get(Calendar.MONTH) + 1; | ||
| 154 | - int beginDay = beginc.get(Calendar.DAY_OF_MONTH); | ||
| 155 | - | ||
| 156 | - Calendar endc = Calendar.getInstance(); | ||
| 157 | - endc.setTime(requestObject.getEndTime()); | ||
| 158 | - int endYear = endc.get(Calendar.YEAR); | ||
| 159 | - int endMonth = endc.get(Calendar.MONTH) + 1; | ||
| 160 | - int endDay = endc.get(Calendar.DAY_OF_MONTH); | ||
| 161 | - | ||
| 162 | - if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) { | ||
| 163 | - // 2表示按每小时统计 | ||
| 164 | - requestObject.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); | ||
| 165 | - } else { | ||
| 166 | - // 3表示按每天统计 | ||
| 167 | - requestObject.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); | ||
| 168 | - } | 151 | + requestObject.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); |
| 169 | BizResult<PageBean<ParkingLotUseStatisticDTO>> respondObject = parkingLotStatisticService | 152 | BizResult<PageBean<ParkingLotUseStatisticDTO>> respondObject = parkingLotStatisticService |
| 170 | .queryParkingLotUseStatisticForPage(requestObject); | 153 | .queryParkingLotUseStatisticForPage(requestObject); |
| 171 | return returnJqGridData(respondObject, ParkingLotUseStatisticDTO.class); | 154 | return returnJqGridData(respondObject, ParkingLotUseStatisticDTO.class); |
| 172 | } | 155 | } |
| 173 | 156 | ||
| 174 | - @ApiOperation("导出车流量数据统计excel") | 157 | + /** |
| 158 | + * langlw 2017-8-24 | ||
| 159 | + * @param beginTime | ||
| 160 | + * @param endTime | ||
| 161 | + * @param plNos | ||
| 162 | + * @param requests | ||
| 163 | + * @param response | ||
| 164 | + */ | ||
| 165 | + @ApiOperation("导出车位数据统计excel") | ||
| 175 | @GetMapping("exportBerthStatisticExcel") | 166 | @GetMapping("exportBerthStatisticExcel") |
| 176 | public void excelParkingLotUseStatistic(@RequestParam String beginTime, @RequestParam String endTime, | 167 | public void excelParkingLotUseStatistic(@RequestParam String beginTime, @RequestParam String endTime, |
| 177 | - @RequestParam String plNos, HttpServletRequest requests, HttpServletResponse response) { | 168 | + @RequestParam List<String> plNos, HttpServletRequest requests, HttpServletResponse response) { |
| 178 | ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest(); | 169 | ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest(); |
| 179 | request.setSysCode(sysCode); | 170 | request.setSysCode(sysCode); |
| 180 | request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT)); | 171 | request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT)); |
| 181 | request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT)); | 172 | request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT)); |
| 182 | - List<String> plNoslist = new ArrayList<>(); | ||
| 183 | - plNoslist.add(plNos); | ||
| 184 | - request.setPlNos(plNoslist); | 173 | + request.setPlNos(plNos); |
| 185 | request.setBaseRequest(new BaseInfo(1, 0)); | 174 | request.setBaseRequest(new BaseInfo(1, 0)); |
| 186 | - | ||
| 187 | - Calendar beginc = Calendar.getInstance(); | ||
| 188 | - beginc.setTime(request.getBeginTime()); | ||
| 189 | - int beginYear = beginc.get(Calendar.YEAR); | ||
| 190 | - int beginMonth = beginc.get(Calendar.MONTH) + 1; | ||
| 191 | - int beginDay = beginc.get(Calendar.DAY_OF_MONTH); | ||
| 192 | - | ||
| 193 | - Calendar endc = Calendar.getInstance(); | ||
| 194 | - endc.setTime(request.getEndTime()); | ||
| 195 | - int endYear = endc.get(Calendar.YEAR); | ||
| 196 | - int endMonth = endc.get(Calendar.MONTH) + 1; | ||
| 197 | - int endDay = endc.get(Calendar.DAY_OF_MONTH); | ||
| 198 | - | ||
| 199 | - if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) { | ||
| 200 | - // 2表示按每小时统计 | ||
| 201 | - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); | ||
| 202 | - } else { | ||
| 203 | - // 3表示按每天统计 | ||
| 204 | - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); | ||
| 205 | - } | 175 | + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); |
| 206 | BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService | 176 | BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService |
| 207 | .queryParkingLotUseStatisticForPage(request); | 177 | .queryParkingLotUseStatisticForPage(request); |
| 208 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 178 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 209 | SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); | 179 | SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); |
| 210 | - String[] title = new String[] { "时间", "空置率", "周转率" }; | 180 | + String[] title = new String[] { "时间","停车场名称", "占用率", "周转率" }; |
| 211 | String sheetName = "车位管理"; | 181 | String sheetName = "车位管理"; |
| 212 | String fileName = "车位管理" + format2.format(new Date()); | 182 | String fileName = "车位管理" + format2.format(new Date()); |
| 213 | // 1.创建excel信息 | 183 | // 1.创建excel信息 |
| @@ -220,12 +190,16 @@ public class BerthsStatisticController extends BizController { | @@ -220,12 +190,16 @@ public class BerthsStatisticController extends BizController { | ||
| 220 | if (CollectionUtils.isNotEmpty(bizResult.getData().getDataList())) { | 190 | if (CollectionUtils.isNotEmpty(bizResult.getData().getDataList())) { |
| 221 | list = bizResult.getData().getDataList(); | 191 | list = bizResult.getData().getDataList(); |
| 222 | } | 192 | } |
| 193 | + DecimalFormat df=new DecimalFormat(".##"); | ||
| 194 | + | ||
| 223 | for (ParkingLotUseStatisticDTO e : list) { | 195 | for (ParkingLotUseStatisticDTO e : list) { |
| 224 | Object[] obj = new Object[title.length]; | 196 | Object[] obj = new Object[title.length]; |
| 225 | int index = 0; | 197 | int index = 0; |
| 226 | obj[index++] = format.format(e.getStatisticBeginTime()); | 198 | obj[index++] = format.format(e.getStatisticBeginTime()); |
| 227 | - obj[index++] = e.getFreeRatio() * 100 + "%"; | ||
| 228 | - obj[index++] = e.getTurnoverRatio(); | 199 | + obj[index++] = e.getPlName(); |
| 200 | + double d=100-e.getFreeRatio()* 100; | ||
| 201 | + obj[index++] = df.format(d) + "%"; | ||
| 202 | + obj[index++] = df.format(e.getTurnoverRatio()); | ||
| 229 | contentList.add(obj); | 203 | contentList.add(obj); |
| 230 | } | 204 | } |
| 231 | ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); | 205 | ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); |
| @@ -236,7 +210,7 @@ public class BerthsStatisticController extends BizController { | @@ -236,7 +210,7 @@ public class BerthsStatisticController extends BizController { | ||
| 236 | 210 | ||
| 237 | /** | 211 | /** |
| 238 | * 根据时间获取车位空置率折线图 | 212 | * 根据时间获取车位空置率折线图 |
| 239 | - * | 213 | + * langlw 2017-8-24 |
| 240 | * @param request | 214 | * @param request |
| 241 | * @return | 215 | * @return |
| 242 | */ | 216 | */ |
| @@ -252,7 +226,6 @@ public class BerthsStatisticController extends BizController { | @@ -252,7 +226,6 @@ public class BerthsStatisticController extends BizController { | ||
| 252 | logger.info("根据停车场编号获取该停车场车位空置率折线图"); | 226 | logger.info("根据停车场编号获取该停车场车位空置率折线图"); |
| 253 | Calendar beginTime = Calendar.getInstance(); | 227 | Calendar beginTime = Calendar.getInstance(); |
| 254 | beginTime.setTime(request.getBeginTime()); | 228 | beginTime.setTime(request.getBeginTime()); |
| 255 | -// int year = beginTime.get(Calendar.YEAR); | ||
| 256 | 229 | ||
| 257 | Calendar endTime = Calendar.getInstance(); | 230 | Calendar endTime = Calendar.getInstance(); |
| 258 | endTime.setTime(request.getEndTime()); | 231 | endTime.setTime(request.getEndTime()); |
| @@ -319,6 +292,7 @@ public class BerthsStatisticController extends BizController { | @@ -319,6 +292,7 @@ public class BerthsStatisticController extends BizController { | ||
| 319 | } | 292 | } |
| 320 | 293 | ||
| 321 | /** | 294 | /** |
| 295 | + * langlw 2017-8-25 | ||
| 322 | * 根据时间获取车位周转率折线图 | 296 | * 根据时间获取车位周转率折线图 |
| 323 | * | 297 | * |
| 324 | * @param request | 298 | * @param request |
| @@ -335,7 +309,6 @@ public class BerthsStatisticController extends BizController { | @@ -335,7 +309,6 @@ public class BerthsStatisticController extends BizController { | ||
| 335 | throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); | 309 | throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); |
| 336 | } | 310 | } |
| 337 | Calendar beginTime = Calendar.getInstance(); | 311 | Calendar beginTime = Calendar.getInstance(); |
| 338 | -// int year = beginTime.get(Calendar.YEAR); | ||
| 339 | beginTime.setTime(request.getBeginTime()); | 312 | beginTime.setTime(request.getBeginTime()); |
| 340 | 313 | ||
| 341 | Calendar endTime = Calendar.getInstance(); | 314 | Calendar endTime = Calendar.getInstance(); |
| @@ -398,22 +371,22 @@ public class BerthsStatisticController extends BizController { | @@ -398,22 +371,22 @@ public class BerthsStatisticController extends BizController { | ||
| 398 | for (ParkingLotUseStatisticDTO statisticDTO : useStatisticDTOs) { | 371 | for (ParkingLotUseStatisticDTO statisticDTO : useStatisticDTOs) { |
| 399 | String key = statisticDTO.getPlNo(); | 372 | String key = statisticDTO.getPlNo(); |
| 400 | parkNameMap.put(key, statisticDTO.getPlName()); | 373 | parkNameMap.put(key, statisticDTO.getPlName()); |
| 401 | - String statisBeginTime = DateUtil.getDateString(statisticDTO.getStatisticBeginTime(), dateType); | ||
| 402 | - // 保存空置率 | 374 | + String statisEndTime = DateUtil.getDateString(statisticDTO.getStatisticEndTime(), dateType); |
| 375 | + // 保存占用率 | ||
| 403 | if (!parkLotMap.containsKey(key)) { | 376 | if (!parkLotMap.containsKey(key)) { |
| 404 | Map<String, Double> timeAndVal = Maps.newHashMap(); | 377 | Map<String, Double> timeAndVal = Maps.newHashMap(); |
| 405 | if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE == berthRatio) { | 378 | if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE == berthRatio) { |
| 406 | - timeAndVal.put(statisBeginTime, statisticDTO.getFreeRatio() * 100); | 379 | + timeAndVal.put(statisEndTime, statisticDTO.getFreeRatio() * 100); |
| 407 | parkLotMap.put(key, timeAndVal); | 380 | parkLotMap.put(key, timeAndVal); |
| 408 | } else if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER == berthRatio) { | 381 | } else if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER == berthRatio) { |
| 409 | - timeAndVal.put(statisBeginTime, statisticDTO.getTurnoverRatio() * 100); | 382 | + timeAndVal.put(statisEndTime, statisticDTO.getTurnoverRatio() ); |
| 410 | parkLotMap.put(key, timeAndVal); | 383 | parkLotMap.put(key, timeAndVal); |
| 411 | } | 384 | } |
| 412 | } else { | 385 | } else { |
| 413 | if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE == berthRatio) { | 386 | if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE == berthRatio) { |
| 414 | - parkLotMap.get(key).put(statisBeginTime, statisticDTO.getFreeRatio() * 100); | 387 | + parkLotMap.get(key).put(statisEndTime, statisticDTO.getFreeRatio() * 100); |
| 415 | } else if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER == berthRatio) { | 388 | } else if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER == berthRatio) { |
| 416 | - parkLotMap.get(key).put(statisBeginTime, statisticDTO.getTurnoverRatio() * 100); | 389 | + parkLotMap.get(key).put(statisEndTime, statisticDTO.getTurnoverRatio() ); |
| 417 | } | 390 | } |
| 418 | } | 391 | } |
| 419 | 392 | ||
| @@ -466,7 +439,12 @@ public class BerthsStatisticController extends BizController { | @@ -466,7 +439,12 @@ public class BerthsStatisticController extends BizController { | ||
| 466 | } | 439 | } |
| 467 | 440 | ||
| 468 | 441 | ||
| 469 | - | 442 | + /** |
| 443 | + * langlw 2017-8-23 | ||
| 444 | + * @param request | ||
| 445 | + * @return | ||
| 446 | + * @throws Exception | ||
| 447 | + */ | ||
| 470 | @ApiOperation("获取停车场信息统计和今日收益") | 448 | @ApiOperation("获取停车场信息统计和今日收益") |
| 471 | @PostMapping("getParkStaticsticAndTodayAmount") | 449 | @PostMapping("getParkStaticsticAndTodayAmount") |
| 472 | @ResponseBody | 450 | @ResponseBody |
| @@ -512,5 +490,236 @@ public class BerthsStatisticController extends BizController { | @@ -512,5 +490,236 @@ public class BerthsStatisticController extends BizController { | ||
| 512 | 490 | ||
| 513 | 491 | ||
| 514 | 492 | ||
| 493 | + /** | ||
| 494 | + * langlw 2017-8-24 | ||
| 495 | + * @param beginTime | ||
| 496 | + * @param endTime | ||
| 497 | + * @param plNos | ||
| 498 | + * @param requests | ||
| 499 | + * @param response | ||
| 500 | + */ | ||
| 501 | + @ApiOperation("下载车位数据统计详情excel") | ||
| 502 | + @GetMapping("downloadBerthStatisticExcel") | ||
| 503 | + public void downloadBerthStatisticExcel(@RequestParam String beginTime, @RequestParam String endTime, | ||
| 504 | + @RequestParam List<String> plNos, @RequestParam String parkName, | ||
| 505 | + HttpServletRequest requests, HttpServletResponse response) { | ||
| 506 | + ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest(); | ||
| 507 | + request.setSysCode(sysCode); | ||
| 508 | + request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT)); | ||
| 509 | + request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT)); | ||
| 510 | + request.setPlNos(plNos); | ||
| 511 | + request.setBaseRequest(new BaseInfo(1, 0)); | ||
| 512 | + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); | ||
| 513 | + | ||
| 514 | + //SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 515 | + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 516 | + | ||
| 517 | + List<String> xAxisData = Lists.newArrayList(); | ||
| 518 | + String[] title = new String[26]; | ||
| 519 | + title[0]=""; | ||
| 520 | + for (int j = 0; j <= 24; j++) { | ||
| 521 | + String hour = String.format("%02d", (j)); | ||
| 522 | + title[j+1]=hour+":00"; | ||
| 523 | + xAxisData.add(hour+":00"); | ||
| 524 | + } | ||
| 525 | + | ||
| 526 | + | ||
| 527 | + String dateType ="HH:mm"; | ||
| 528 | + int berthRatio = ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER; | ||
| 529 | + LineChartVO turnOverBerthRatios = getFreeBerthRatios(request, xAxisData, dateType, berthRatio); | ||
| 530 | + int berthFreeRatio = ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE; | ||
| 531 | + LineChartVO freeBerthRatios = getFreeBerthRatios(request, xAxisData, dateType, berthFreeRatio); | ||
| 532 | + | ||
| 533 | + | ||
| 534 | + | ||
| 535 | + String sheetName = "日报表车位使用统计"; | ||
| 536 | + String fileName = "日报表车位使用统计" + format2.format(new Date()); | ||
| 537 | + // 1.创建excel信息 | ||
| 538 | + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); | ||
| 539 | + // 2.设置excel表头和表体 | ||
| 540 | + Layouter.buildReport(workSheet, title, 0, 0); | ||
| 541 | + // 3.填充数据 | ||
| 542 | + List<Object[]> contentList = new ArrayList<Object[]>(); | ||
| 543 | + | ||
| 544 | + | ||
| 545 | + for (SerieVO e : freeBerthRatios.getSeries()) { | ||
| 546 | + | ||
| 547 | + Object[] obj = new Object[title.length]; | ||
| 548 | + obj[0]="占用率"; | ||
| 549 | + int index = 1; | ||
| 550 | + for (Integer i : e.getData()) { | ||
| 551 | + obj[index++] = 100-i+"%"; | ||
| 552 | + } | ||
| 553 | + contentList.add(obj); | ||
| 554 | + } | ||
| 555 | + | ||
| 556 | + for (SerieVO e : turnOverBerthRatios.getSeries()) { | ||
| 557 | + | ||
| 558 | + Object[] obj = new Object[title.length]; | ||
| 559 | + obj[0]="周转率率"; | ||
| 560 | + int index = 1; | ||
| 561 | + for (Integer i : e.getData()) { | ||
| 562 | + obj[index++] = i ; | ||
| 563 | + } | ||
| 564 | + | ||
| 565 | + | ||
| 566 | + contentList.add(obj); | ||
| 567 | + } | ||
| 568 | + | ||
| 569 | + ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); | ||
| 570 | + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2); | ||
| 571 | + // 4.excel输出配置 | ||
| 572 | + ExcelUtil.write(response, workSheet, fileName); | ||
| 573 | + } | ||
| 574 | + | ||
| 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 | + | ||
| 656 | + Long dayDifference = DateUtil.getTimeDifference(new Timestamp(request.getEndTime().getTime()), | ||
| 657 | + new Timestamp(request.getBeginTime().getTime())); | ||
| 658 | + | ||
| 659 | + List<String> xAxisData = Lists.newArrayList(); | ||
| 660 | + String[] title = new String[dayDifference.intValue()+2]; | ||
| 661 | + title[0]=""; | ||
| 662 | + for (int i = 0; i < dayDifference.intValue(); i++) { | ||
| 663 | + Calendar tempDate = Calendar.getInstance(); | ||
| 664 | + tempDate.setTime(request.getBeginTime()); | ||
| 665 | + tempDate.add(Calendar.DAY_OF_MONTH, i); | ||
| 666 | + int beginMonth = tempDate.get(Calendar.MONTH) + 1; | ||
| 667 | + int beginDay = tempDate.get(Calendar.DAY_OF_MONTH); | ||
| 668 | + String month = String.format("%02d", (beginMonth)); | ||
| 669 | + String day = String.format("%02d", (beginDay)); | ||
| 670 | + title[i+1]=month + "-" + day; | ||
| 671 | + xAxisData.add(month + "-" + day); | ||
| 672 | + | ||
| 673 | + } | ||
| 674 | + | ||
| 675 | + String dateType ="MM-dd"; | ||
| 676 | + int berthRatio = ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER; | ||
| 677 | + LineChartVO turnOverBerthRatios = getFreeBerthRatios(request, xAxisData, dateType, berthRatio); | ||
| 678 | + int berthFreeRatio = ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE; | ||
| 679 | + LineChartVO freeBerthRatios = getFreeBerthRatios(request, xAxisData, dateType, berthFreeRatio); | ||
| 680 | + | ||
| 681 | + | ||
| 682 | + String sheetName = "月报表车位使用统计"; | ||
| 683 | + String fileName = "月报表车位使用统计" + format2.format(new Date()); | ||
| 684 | + // 1.创建excel信息 | ||
| 685 | + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); | ||
| 686 | + // 2.设置excel表头和表体 | ||
| 687 | + Layouter.buildReport(workSheet, title, 0, 0); | ||
| 688 | + // 3.填充数据 | ||
| 689 | + List<Object[]> contentList = new ArrayList<Object[]>(); | ||
| 690 | + | ||
| 691 | + | ||
| 692 | + for (SerieVO e : freeBerthRatios.getSeries()) { | ||
| 693 | + | ||
| 694 | + Object[] obj = new Object[title.length]; | ||
| 695 | + obj[0]="占用率"; | ||
| 696 | + int index = 1; | ||
| 697 | + for (Integer i : e.getData()) { | ||
| 698 | + obj[index++] = 100-i+"%"; | ||
| 699 | + } | ||
| 700 | + contentList.add(obj); | ||
| 701 | + } | ||
| 702 | + | ||
| 703 | + for (SerieVO e : turnOverBerthRatios.getSeries()) { | ||
| 704 | + | ||
| 705 | + Object[] obj = new Object[title.length]; | ||
| 706 | + obj[0]="周转率率"; | ||
| 707 | + int index = 1; | ||
| 708 | + for (Integer i : e.getData()) { | ||
| 709 | + obj[index++] = i ; | ||
| 710 | + } | ||
| 711 | + | ||
| 712 | + | ||
| 713 | + contentList.add(obj); | ||
| 714 | + } | ||
| 715 | + | ||
| 716 | + ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); | ||
| 717 | + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2); | ||
| 718 | + // 4.excel输出配置 | ||
| 719 | + ExcelUtil.write(response, workSheet, fileName); | ||
| 720 | + } | ||
| 721 | + | ||
| 722 | + | ||
| 723 | + | ||
| 515 | 724 | ||
| 516 | } | 725 | } |
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/OrderManageController.java
0 → 100644
| 1 | +package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; | ||
| 2 | + | ||
| 3 | +import com.alibaba.dubbo.common.utils.CollectionUtils; | ||
| 4 | + | ||
| 5 | +import com.clouds.common.web.BizController; | ||
| 6 | +import com.clouds.common.web.vo.BizResultVO; | ||
| 7 | +import com.clouds.common.web.vo.EasyUIDataGridVO; | ||
| 8 | +import com.zteits.clouds.api.apibase.bean.BizResult; | ||
| 9 | +import com.zteits.clouds.api.apibase.bean.PageBean; | ||
| 10 | +import com.zteits.clouds.api.apibase.constants.ErrorType; | ||
| 11 | +import com.zteits.clouds.api.apibase.exception.BizException; | ||
| 12 | +import com.zteits.clouds.api.dto.pay.ParkOrderDTO; | ||
| 13 | +import com.zteits.clouds.api.dto.pay.param.ParkOrderByConditionQueryRequest; | ||
| 14 | +import com.zteits.clouds.api.service.pay.TdBOrderService; | ||
| 15 | +import io.swagger.annotations.Api; | ||
| 16 | +import io.swagger.annotations.ApiOperation; | ||
| 17 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 18 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 19 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 20 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 21 | +import org.springframework.web.bind.annotation.RestController; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * Copyright: Copyright (c) 2017 zteits | ||
| 25 | + * | ||
| 26 | + * @ClassName: com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic | ||
| 27 | + * @Description: | ||
| 28 | + * @version: v1.0.0 | ||
| 29 | + * @author: atao | ||
| 30 | + * @date: 2017/8/24 上午9:18 | ||
| 31 | + * Modification History: | ||
| 32 | + * Date Author Version Description | ||
| 33 | + * ---------------------------------------------------------* | ||
| 34 | + * 2017/8/24 atao v1.0.0 创建 | ||
| 35 | + */ | ||
| 36 | +@Api(value = "订单管理",description = "订单管理") | ||
| 37 | +@RestController | ||
| 38 | +@RequestMapping("/order") | ||
| 39 | +public class OrderManageController extends BizController { | ||
| 40 | + | ||
| 41 | + @Autowired | ||
| 42 | + private TdBOrderService tdBOrderService; | ||
| 43 | + | ||
| 44 | + @ApiOperation("根据查询条件查询停车订单") | ||
| 45 | + @PostMapping("/queryParkOrderByCondition") | ||
| 46 | + public BizResultVO<EasyUIDataGridVO<ParkOrderDTO>> queryParkOrderByCondition( | ||
| 47 | + @RequestBody ParkOrderByConditionQueryRequest request) throws Exception{ | ||
| 48 | + if (CollectionUtils.isEmpty(request.getPlNos())) { | ||
| 49 | + throw new BizException(ErrorType.PARAMM_NULL, "停车场编码"); | ||
| 50 | + } | ||
| 51 | + if (0 == request.getBaseRequest().getPageNum()) { | ||
| 52 | + request.getBaseRequest().setPageNum(1); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + if (0 == request.getBaseRequest().getPageSize()) { | ||
| 56 | + request.getBaseRequest().setPageSize(10); | ||
| 57 | + } | ||
| 58 | + BizResult<PageBean<ParkOrderDTO>> bizResult = tdBOrderService.queryParkOrderByCondition(request); | ||
| 59 | + return returnJqGridData(bizResult,ParkOrderDTO.class); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | +} |
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/VehicleFlowStatisticController.java
| @@ -12,17 +12,16 @@ import javax.servlet.http.HttpServletRequest; | @@ -12,17 +12,16 @@ import javax.servlet.http.HttpServletRequest; | ||
| 12 | import javax.servlet.http.HttpServletResponse; | 12 | import javax.servlet.http.HttpServletResponse; |
| 13 | 13 | ||
| 14 | import com.alibaba.dubbo.common.utils.CollectionUtils; | 14 | import com.alibaba.dubbo.common.utils.CollectionUtils; |
| 15 | +import com.alibaba.dubbo.common.utils.StringUtils; | ||
| 15 | import com.alibaba.fastjson.JSON; | 16 | import com.alibaba.fastjson.JSON; |
| 16 | import com.alibaba.fastjson.JSONObject; | 17 | import com.alibaba.fastjson.JSONObject; |
| 17 | 18 | ||
| 18 | -import com.clouds.common.entity.UserInfo; | ||
| 19 | import com.clouds.common.utils.DateUtil; | 19 | import com.clouds.common.utils.DateUtil; |
| 20 | import com.clouds.common.utils.ResultUtils; | 20 | import com.clouds.common.utils.ResultUtils; |
| 21 | import com.clouds.common.utils.excle.ExcelUtil; | 21 | import com.clouds.common.utils.excle.ExcelUtil; |
| 22 | import com.clouds.common.utils.excle.ExcleFillDateManager; | 22 | import com.clouds.common.utils.excle.ExcleFillDateManager; |
| 23 | import com.clouds.common.utils.excle.Layouter; | 23 | import com.clouds.common.utils.excle.Layouter; |
| 24 | import com.clouds.common.web.BizController; | 24 | import com.clouds.common.web.BizController; |
| 25 | -import com.clouds.common.web.SessionCommUtil; | ||
| 26 | import com.clouds.common.web.vo.BizResultVO; | 25 | import com.clouds.common.web.vo.BizResultVO; |
| 27 | import com.clouds.common.web.vo.EasyUIDataGridVO; | 26 | import com.clouds.common.web.vo.EasyUIDataGridVO; |
| 28 | import com.google.common.collect.Lists; | 27 | import com.google.common.collect.Lists; |
| @@ -32,6 +31,7 @@ import com.zteits.clouds.api.apibase.bean.BizResult; | @@ -32,6 +31,7 @@ import com.zteits.clouds.api.apibase.bean.BizResult; | ||
| 32 | import com.zteits.clouds.api.apibase.bean.PageBean; | 31 | import com.zteits.clouds.api.apibase.bean.PageBean; |
| 33 | import com.zteits.clouds.api.apibase.constants.ErrorType; | 32 | import com.zteits.clouds.api.apibase.constants.ErrorType; |
| 34 | import com.zteits.clouds.api.apibase.exception.BizException; | 33 | import com.zteits.clouds.api.apibase.exception.BizException; |
| 34 | +import com.zteits.clouds.api.dto.park.dto.MonthVehicleFlowAndVacancyRateAndTurnoverDTO; | ||
| 35 | import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO; | 35 | import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO; |
| 36 | import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticMaxAndMinDTO; | 36 | import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticMaxAndMinDTO; |
| 37 | import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest; | 37 | import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest; |
| @@ -62,307 +62,471 @@ import org.springframework.web.bind.annotation.ResponseBody; | @@ -62,307 +62,471 @@ import org.springframework.web.bind.annotation.ResponseBody; | ||
| 62 | * @version: v1.0.0 | 62 | * @version: v1.0.0 |
| 63 | * @author: langlw | 63 | * @author: langlw |
| 64 | * @date: 2017年6月14日 下午3:02:39 Modification History: Date Author Version | 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 | @Api(value = "停车场车流量数据统计", description = "停车场车流量数据统计") | 68 | @Api(value = "停车场车流量数据统计", description = "停车场车流量数据统计") |
| 69 | @Controller | 69 | @Controller |
| 70 | @RequestMapping(value = "/VehicleFlowStatistic") | 70 | @RequestMapping(value = "/VehicleFlowStatistic") |
| 71 | public class VehicleFlowStatisticController extends BizController { | 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 | + | ||
| 475 | + Long dayDifference = DateUtil.getTimeDifference(new Timestamp(request.getEndTime().getTime()), | ||
| 476 | + new Timestamp(request.getBeginTime().getTime())); | ||
| 477 | + | ||
| 478 | + List<String> xAxisData = Lists.newArrayList(); | ||
| 479 | + String[] title = new String[dayDifference.intValue() + 2]; | ||
| 480 | + title[0] = ""; | ||
| 481 | + for (int i = 0; i < dayDifference.intValue(); i++) { | ||
| 482 | + Calendar tempDate = Calendar.getInstance(); | ||
| 483 | + tempDate.setTime(request.getBeginTime()); | ||
| 484 | + tempDate.add(Calendar.DAY_OF_MONTH, i); | ||
| 485 | + int beginMonth = tempDate.get(Calendar.MONTH) + 1; | ||
| 486 | + int beginDay = tempDate.get(Calendar.DAY_OF_MONTH); | ||
| 487 | + String month = String.format("%02d", (beginMonth)); | ||
| 488 | + String day = String.format("%02d", (beginDay)); | ||
| 489 | + title[i + 1] = month + "-" + day; | ||
| 490 | + xAxisData.add(month + "-" + day); | ||
| 491 | + | ||
| 492 | + } | ||
| 493 | + | ||
| 494 | + String dateType = "MM-dd"; | ||
| 495 | + LineChartVO VehicleFlows = getVehicleFlows(request, xAxisData, dateType); | ||
| 496 | + | ||
| 497 | + String sheetName = "月报表车流量使用统计"; | ||
| 498 | + String fileName = "月报表车流量使用统计" + format2.format(new Date()); | ||
| 499 | + // 1.创建excel信息 | ||
| 500 | + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); | ||
| 501 | + // 2.设置excel表头和表体 | ||
| 502 | + Layouter.buildReport(workSheet, title, 0, 0); | ||
| 503 | + // 3.填充数据 | ||
| 504 | + List<Object[]> contentList = new ArrayList<Object[]>(); | ||
| 505 | + | ||
| 506 | + for (SerieVO e : VehicleFlows.getSeries()) { | ||
| 507 | + Object[] obj = new Object[title.length]; | ||
| 508 | + obj[0] = e.getName(); | ||
| 509 | + int index = 1; | ||
| 510 | + for (Integer i : e.getData()) { | ||
| 511 | + obj[index++] = i; | ||
| 512 | + } | ||
| 513 | + contentList.add(obj); | ||
| 514 | + } | ||
| 515 | + | ||
| 516 | + ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); | ||
| 517 | + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2); | ||
| 518 | + // 4.excel输出配置 | ||
| 519 | + ExcelUtil.write(response, workSheet, fileName); | ||
| 520 | + } | ||
| 521 | + | ||
| 522 | + public static void main(String[] args) { | ||
| 523 | + 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\"}}"; | ||
| 524 | + JSONObject object = (JSONObject) JSONObject.parse(json); | ||
| 525 | + System.out.println(object.get("id")); | ||
| 526 | + System.out.println(object.get("platform")); | ||
| 527 | + JSONObject parameter = (JSONObject) object.get("parameter"); | ||
| 528 | + System.out.println(parameter.get("drid")); | ||
| 529 | + System.out.println(parameter.get("sex")); | ||
| 530 | + } | ||
| 367 | 531 | ||
| 368 | } | 532 | } |