Commit d4a0303d1e03c74efd1ef337d7abef4d4f208bc2
1 parent
d14d20ef
泊位周转率-导出
Showing
1 changed file
with
79 additions
and
1 deletions
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/AnalysisController.java
| 1 | package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; | 1 | package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; |
| 2 | 2 | ||
| 3 | import java.sql.Timestamp; | 3 | import java.sql.Timestamp; |
| 4 | +import java.text.DecimalFormat; | ||
| 5 | +import java.text.SimpleDateFormat; | ||
| 6 | +import java.util.ArrayList; | ||
| 4 | import java.util.Calendar; | 7 | import java.util.Calendar; |
| 5 | import java.util.Date; | 8 | import java.util.Date; |
| 6 | import java.util.List; | 9 | import java.util.List; |
| 7 | 10 | ||
| 11 | +import javax.servlet.http.HttpServletRequest; | ||
| 12 | +import javax.servlet.http.HttpServletResponse; | ||
| 13 | + | ||
| 14 | +import org.apache.poi.xssf.usermodel.XSSFSheet; | ||
| 8 | import org.slf4j.Logger; | 15 | import org.slf4j.Logger; |
| 9 | import org.slf4j.LoggerFactory; | 16 | import org.slf4j.LoggerFactory; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.beans.factory.annotation.Value; | 18 | import org.springframework.beans.factory.annotation.Value; |
| 12 | import org.springframework.stereotype.Controller; | 19 | import org.springframework.stereotype.Controller; |
| 20 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 13 | import org.springframework.web.bind.annotation.PostMapping; | 21 | import org.springframework.web.bind.annotation.PostMapping; |
| 14 | import org.springframework.web.bind.annotation.RequestBody; | 22 | import org.springframework.web.bind.annotation.RequestBody; |
| 15 | import org.springframework.web.bind.annotation.RequestMapping; | 23 | import org.springframework.web.bind.annotation.RequestMapping; |
| 24 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 16 | import org.springframework.web.bind.annotation.ResponseBody; | 25 | import org.springframework.web.bind.annotation.ResponseBody; |
| 17 | 26 | ||
| 27 | +import com.alibaba.dubbo.common.utils.CollectionUtils; | ||
| 18 | import com.clouds.common.utils.DateUtil; | 28 | import com.clouds.common.utils.DateUtil; |
| 29 | +import com.clouds.common.utils.excle.ExcelUtil; | ||
| 30 | +import com.clouds.common.utils.excle.ExcleFillDateManager; | ||
| 31 | +import com.clouds.common.utils.excle.Layouter; | ||
| 19 | import com.clouds.common.web.BizController; | 32 | import com.clouds.common.web.BizController; |
| 20 | import com.clouds.common.web.vo.BizResultVO; | 33 | import com.clouds.common.web.vo.BizResultVO; |
| 21 | import com.clouds.common.web.vo.EasyUIDataGridVO; | 34 | import com.clouds.common.web.vo.EasyUIDataGridVO; |
| 22 | import com.google.common.collect.Lists; | 35 | import com.google.common.collect.Lists; |
| 36 | +import com.zteits.clouds.api.apibase.bean.BaseInfo; | ||
| 23 | import com.zteits.clouds.api.apibase.bean.BizResult; | 37 | import com.zteits.clouds.api.apibase.bean.BizResult; |
| 24 | import com.zteits.clouds.api.apibase.bean.PageBean; | 38 | import com.zteits.clouds.api.apibase.bean.PageBean; |
| 25 | import com.zteits.clouds.api.apibase.constants.ErrorType; | 39 | import com.zteits.clouds.api.apibase.constants.ErrorType; |
| 26 | import com.zteits.clouds.api.apibase.exception.BizException; | 40 | import com.zteits.clouds.api.apibase.exception.BizException; |
| 27 | import com.zteits.clouds.api.dto.clouds.param.BerthTurnOverQueryRequest; | 41 | import com.zteits.clouds.api.dto.clouds.param.BerthTurnOverQueryRequest; |
| 28 | import com.zteits.clouds.api.dto.park.dto.BerthTurnOverCountDTO; | 42 | import com.zteits.clouds.api.dto.park.dto.BerthTurnOverCountDTO; |
| 43 | +import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO; | ||
| 44 | +import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest; | ||
| 29 | import com.zteits.clouds.api.service.park.EqpBerthsService; | 45 | import com.zteits.clouds.api.service.park.EqpBerthsService; |
| 30 | import com.zteits.irain.portal.constant.ParkConstant; | 46 | import com.zteits.irain.portal.constant.ParkConstant; |
| 31 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO; | 47 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO; |
| @@ -200,7 +216,69 @@ public class AnalysisController extends BizController { | @@ -200,7 +216,69 @@ public class AnalysisController extends BizController { | ||
| 200 | return returnJqGridData(respondObject,BerthTurnOverCountDTO.class); | 216 | return returnJqGridData(respondObject,BerthTurnOverCountDTO.class); |
| 201 | } | 217 | } |
| 202 | 218 | ||
| 203 | - | 219 | + /** |
| 220 | + * @param beginTime | ||
| 221 | + * @param endTime | ||
| 222 | + * @param plNos | ||
| 223 | + * @param requests | ||
| 224 | + * @param response | ||
| 225 | + */ | ||
| 226 | + @ApiOperation("导出周转率数据统计excel") | ||
| 227 | + @GetMapping("exportBerthTurnOverExcel") | ||
| 228 | + public void exportBerthTurnOverExcel(@RequestParam String beginTime, @RequestParam String endTime, | ||
| 229 | + @RequestParam List<String> plNos, HttpServletRequest requests, HttpServletResponse response) { | ||
| 230 | + BerthTurnOverQueryRequest request = new BerthTurnOverQueryRequest(); | ||
| 231 | + request.setSysCode(sysCode); | ||
| 232 | + request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT)); | ||
| 233 | + request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT)); | ||
| 234 | + request.setPlNos(plNos); | ||
| 235 | + request.setBaseRequest(new BaseInfo(1, 100)); | ||
| 236 | + request.setTimeType(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); | ||
| 237 | + | ||
| 238 | + Calendar endc = Calendar.getInstance(); | ||
| 239 | + endc.setTime(request.getEndTime()); | ||
| 240 | + int endYear = endc.get(Calendar.YEAR); | ||
| 241 | + int endMonth = endc.get(Calendar.MONTH) + 1; | ||
| 242 | + int endDay = endc.get(Calendar.DAY_OF_MONTH); | ||
| 243 | + String tableName = "tp_p_eqp_log"+endYear+""+endMonth; | ||
| 244 | + if(endMonth < 10){ | ||
| 245 | + tableName = "tp_p_eqp_log"+endYear+"0"+endMonth; | ||
| 246 | + } | ||
| 247 | + request.setTableName(tableName); | ||
| 248 | + | ||
| 249 | + BizResult<PageBean<BerthTurnOverCountDTO>> bizResult = eqpBerthsService.queryBerthTurnOverDetailForHour(request); | ||
| 250 | + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 251 | + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 252 | + String[] title = new String[] { "时间","停车场名称", "周转率" }; | ||
| 253 | + String sheetName = "泊位周转率"; | ||
| 254 | + String fileName = "泊位周转率" + format2.format(new Date()); | ||
| 255 | + // 1.创建excel信息 | ||
| 256 | + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); | ||
| 257 | + // 2.设置excel表头和表体 | ||
| 258 | + Layouter.buildReport(workSheet, title, 0, 0); | ||
| 259 | + // 3.填充数据 | ||
| 260 | + List<Object[]> contentList = new ArrayList<Object[]>(); | ||
| 261 | + List<BerthTurnOverCountDTO> list = new ArrayList<>(); | ||
| 262 | + if (CollectionUtils.isNotEmpty(bizResult.getData().getDataList())) { | ||
| 263 | + list = bizResult.getData().getDataList(); | ||
| 264 | + } | ||
| 265 | + DecimalFormat df=new DecimalFormat("#.##"); | ||
| 266 | + | ||
| 267 | + for (BerthTurnOverCountDTO e : list) { | ||
| 268 | + Object[] obj = new Object[title.length]; | ||
| 269 | + int index = 0; | ||
| 270 | + obj[index++] = e.getTurnDayTime()+":00:00"; | ||
| 271 | + obj[index++] = e.getParkName(); | ||
| 272 | + /*double d=100-e.getTurnOver()* 100; | ||
| 273 | + obj[index++] = df.format(d) + "%";*/ | ||
| 274 | + obj[index++] = df.format(e.getTurnOver()); | ||
| 275 | + contentList.add(obj); | ||
| 276 | + } | ||
| 277 | + ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); | ||
| 278 | + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2); | ||
| 279 | + // 4.excel输出配置 | ||
| 280 | + ExcelUtil.write(response, workSheet, fileName); | ||
| 281 | + } | ||
| 204 | 282 | ||
| 205 | 283 | ||
| 206 | 284 |