Commit 15f65b0f5e685fe51dc0a4c19d4490b4d45023ee
Merge branch 'branch_0808' of http://192.168.1.195:9998/ZTEITS-Developers/zteits…
…-bcp-portal.git into branch_0808
Showing
2 changed files
with
99 additions
and
8 deletions
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/areamanage/AreaManageController.java
| ... | ... | @@ -4,7 +4,9 @@ import java.util.List; |
| 4 | 4 | |
| 5 | 5 | import javax.servlet.http.HttpSession; |
| 6 | 6 | |
| 7 | +import com.clouds.common.utils.ResultUtils; | |
| 7 | 8 | import com.clouds.common.web.vo.BizResultVO; |
| 9 | +import com.clouds.common.web.vo.EasyUIDataGridVO; | |
| 8 | 10 | import com.zteits.clouds.api.apibase.bean.BaseRequest; |
| 9 | 11 | import com.zteits.clouds.api.apibase.bean.BizResult; |
| 10 | 12 | import com.zteits.clouds.api.apibase.constants.ErrorType; |
| ... | ... | @@ -14,6 +16,7 @@ import com.zteits.clouds.api.dto.sys.param.AreaTreeDTO; |
| 14 | 16 | import com.zteits.clouds.api.service.sys.TbAreaService; |
| 15 | 17 | import io.swagger.annotations.Api; |
| 16 | 18 | import io.swagger.annotations.ApiOperation; |
| 19 | +import org.apache.poi.ss.formula.functions.T; | |
| 17 | 20 | import org.slf4j.Logger; |
| 18 | 21 | import org.slf4j.LoggerFactory; |
| 19 | 22 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -47,14 +50,25 @@ public class AreaManageController { |
| 47 | 50 | |
| 48 | 51 | @ApiOperation("根据归属组织ID查询区域与区块树") |
| 49 | 52 | @PostMapping("/queryAreaAndBlockTree") |
| 50 | - public BizResultVO<List<AreaTreeDTO>> queryAreaAndBlockTree(@RequestBody BaseRequest baseRequest){ | |
| 53 | + public BizResultVO<EasyUIDataGridVO<AreaTreeDTO>> queryAreaAndBlockTree(@RequestBody BaseRequest baseRequest){ | |
| 51 | 54 | |
| 55 | + BizResultVO<EasyUIDataGridVO<AreaTreeDTO>> resultVO = new BizResultVO<>(); | |
| 56 | + EasyUIDataGridVO<AreaTreeDTO> easyUIDataGridVO = new EasyUIDataGridVO<>(); | |
| 52 | 57 | AreaBlockByOrgIdQueryRequest request = new AreaBlockByOrgIdQueryRequest(); |
| 53 | 58 | request.setSysCode(baseRequest.getSysCode()); |
| 54 | 59 | // TODO 此处orgId 从当前登录操作人中取,现在先不限制 |
| 55 | 60 | request.setOrgId(1L); |
| 56 | 61 | BizResult<List<AreaTreeDTO>> result= tbAreaService.queryAreaBlockByOrgId(request); |
| 57 | - return new BizResultVO<>(result); | |
| 62 | + if(ResultUtils.isSuccess(result)){ | |
| 63 | + easyUIDataGridVO.setRows(result.getData()); | |
| 64 | + easyUIDataGridVO.setTotal(result.getData().size()); | |
| 65 | + resultVO.setData(easyUIDataGridVO); | |
| 66 | + }else { | |
| 67 | + resultVO.setCode(result.getErrCode().getCode()); | |
| 68 | + resultVO.setMsg(result.getErrMsg()); | |
| 69 | + } | |
| 70 | + | |
| 71 | + return resultVO; | |
| 58 | 72 | } |
| 59 | 73 | |
| 60 | 74 | } | ... | ... |
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/AnalysisController.java
| 1 | 1 | package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; |
| 2 | 2 | |
| 3 | 3 | import java.sql.Timestamp; |
| 4 | +import java.text.DecimalFormat; | |
| 5 | +import java.text.SimpleDateFormat; | |
| 6 | +import java.util.ArrayList; | |
| 4 | 7 | import java.util.Calendar; |
| 5 | 8 | import java.util.Date; |
| 6 | 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 | 15 | import org.slf4j.Logger; |
| 9 | 16 | import org.slf4j.LoggerFactory; |
| 10 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | 18 | import org.springframework.beans.factory.annotation.Value; |
| 12 | 19 | import org.springframework.stereotype.Controller; |
| 20 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 13 | 21 | import org.springframework.web.bind.annotation.PostMapping; |
| 14 | 22 | import org.springframework.web.bind.annotation.RequestBody; |
| 15 | 23 | import org.springframework.web.bind.annotation.RequestMapping; |
| 24 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 16 | 25 | import org.springframework.web.bind.annotation.ResponseBody; |
| 17 | 26 | |
| 27 | +import com.alibaba.dubbo.common.utils.CollectionUtils; | |
| 28 | +import com.clouds.common.constants.TableNameEnum; | |
| 18 | 29 | import com.clouds.common.utils.DateUtil; |
| 30 | +import com.clouds.common.utils.excle.ExcelUtil; | |
| 31 | +import com.clouds.common.utils.excle.ExcleFillDateManager; | |
| 32 | +import com.clouds.common.utils.excle.Layouter; | |
| 19 | 33 | import com.clouds.common.web.BizController; |
| 20 | 34 | import com.clouds.common.web.vo.BizResultVO; |
| 21 | 35 | import com.clouds.common.web.vo.EasyUIDataGridVO; |
| 22 | 36 | import com.google.common.collect.Lists; |
| 37 | +import com.zteits.clouds.api.apibase.bean.BaseInfo; | |
| 23 | 38 | import com.zteits.clouds.api.apibase.bean.BizResult; |
| 24 | 39 | import com.zteits.clouds.api.apibase.bean.PageBean; |
| 25 | 40 | import com.zteits.clouds.api.apibase.constants.ErrorType; |
| ... | ... | @@ -86,9 +101,9 @@ public class AnalysisController extends BizController { |
| 86 | 101 | int endMonth = endc.get(Calendar.MONTH) + 1; |
| 87 | 102 | int endDay = endc.get(Calendar.DAY_OF_MONTH); |
| 88 | 103 | |
| 89 | - String tableName = "tp_p_eqp_log"+endYear+""+endMonth; | |
| 104 | + String tableName = TableNameEnum.TP_P_EQP_LOG.getValue()+endYear+""+endMonth; | |
| 90 | 105 | if(endMonth < 10){ |
| 91 | - tableName = "tp_p_eqp_log"+endYear+"0"+endMonth; | |
| 106 | + tableName = TableNameEnum.TP_P_EQP_LOG.getValue()+endYear+"0"+endMonth; | |
| 92 | 107 | } |
| 93 | 108 | requestObject.setTableName(tableName); |
| 94 | 109 | if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) { |
| ... | ... | @@ -186,11 +201,11 @@ public class AnalysisController extends BizController { |
| 186 | 201 | endc.setTime(requestObject.getEndTime()); |
| 187 | 202 | int endYear = endc.get(Calendar.YEAR); |
| 188 | 203 | int endMonth = endc.get(Calendar.MONTH) + 1; |
| 189 | - int endDay = endc.get(Calendar.DAY_OF_MONTH); | |
| 204 | + //int endDay = endc.get(Calendar.DAY_OF_MONTH); | |
| 190 | 205 | |
| 191 | - String tableName = "tp_p_eqp_log"+endYear+""+endMonth; | |
| 206 | + String tableName = TableNameEnum.TP_P_EQP_LOG.getValue()+endYear+""+endMonth; | |
| 192 | 207 | if(endMonth < 10){ |
| 193 | - tableName = "tp_p_eqp_log"+endYear+"0"+endMonth; | |
| 208 | + tableName = TableNameEnum.TP_P_EQP_LOG.getValue()+endYear+"0"+endMonth; | |
| 194 | 209 | } |
| 195 | 210 | requestObject.setTableName(tableName); |
| 196 | 211 | // 按每天统计 |
| ... | ... | @@ -200,7 +215,69 @@ public class AnalysisController extends BizController { |
| 200 | 215 | return returnJqGridData(respondObject,BerthTurnOverCountDTO.class); |
| 201 | 216 | } |
| 202 | 217 | |
| 203 | - | |
| 218 | + /** | |
| 219 | + * @param beginTime | |
| 220 | + * @param endTime | |
| 221 | + * @param plNos | |
| 222 | + * @param requests | |
| 223 | + * @param response | |
| 224 | + */ | |
| 225 | + @ApiOperation("导出周转率数据统计excel") | |
| 226 | + @GetMapping("exportBerthTurnOverExcel") | |
| 227 | + public void exportBerthTurnOverExcel(@RequestParam String beginTime, @RequestParam String endTime, | |
| 228 | + @RequestParam List<String> plNos, HttpServletRequest requests, HttpServletResponse response) { | |
| 229 | + BerthTurnOverQueryRequest request = new BerthTurnOverQueryRequest(); | |
| 230 | + request.setSysCode(sysCode); | |
| 231 | + request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT)); | |
| 232 | + request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT)); | |
| 233 | + request.setPlNos(plNos); | |
| 234 | + request.setBaseRequest(new BaseInfo(1, 100)); | |
| 235 | + request.setTimeType(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); | |
| 236 | + | |
| 237 | + Calendar endc = Calendar.getInstance(); | |
| 238 | + endc.setTime(request.getEndTime()); | |
| 239 | + int endYear = endc.get(Calendar.YEAR); | |
| 240 | + int endMonth = endc.get(Calendar.MONTH) + 1; | |
| 241 | + //int endDay = endc.get(Calendar.DAY_OF_MONTH); | |
| 242 | + String tableName = TableNameEnum.TP_P_EQP_LOG.getValue()+endYear+""+endMonth; | |
| 243 | + if(endMonth < 10){ | |
| 244 | + tableName = TableNameEnum.TP_P_EQP_LOG.getValue()+endYear+"0"+endMonth; | |
| 245 | + } | |
| 246 | + request.setTableName(tableName); | |
| 247 | + | |
| 248 | + BizResult<PageBean<BerthTurnOverCountDTO>> bizResult = eqpBerthsService.queryBerthTurnOverDetailForHour(request); | |
| 249 | + //SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 250 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
| 251 | + String[] title = new String[] { "时间","停车场名称", "周转率" }; | |
| 252 | + String sheetName = "泊位周转率"; | |
| 253 | + String fileName = "泊位周转率" + sdf.format(new Date()); | |
| 254 | + // 1.创建excel信息 | |
| 255 | + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); | |
| 256 | + // 2.设置excel表头和表体 | |
| 257 | + Layouter.buildReport(workSheet, title, 0, 0); | |
| 258 | + // 3.填充数据 | |
| 259 | + List<Object[]> contentList = new ArrayList<Object[]>(); | |
| 260 | + List<BerthTurnOverCountDTO> list = new ArrayList<>(); | |
| 261 | + if (CollectionUtils.isNotEmpty(bizResult.getData().getDataList())) { | |
| 262 | + list = bizResult.getData().getDataList(); | |
| 263 | + } | |
| 264 | + DecimalFormat df=new DecimalFormat("#.##"); | |
| 265 | + | |
| 266 | + for (BerthTurnOverCountDTO e : list) { | |
| 267 | + Object[] obj = new Object[title.length]; | |
| 268 | + int index = 0; | |
| 269 | + obj[index++] = e.getTurnDayTime()+":00:00"; | |
| 270 | + obj[index++] = e.getParkName(); | |
| 271 | + /*double d=100-e.getTurnOver()* 100; | |
| 272 | + obj[index++] = df.format(d) + "%";*/ | |
| 273 | + obj[index++] = df.format(e.getTurnOver()); | |
| 274 | + contentList.add(obj); | |
| 275 | + } | |
| 276 | + ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); | |
| 277 | + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2); | |
| 278 | + // 4.excel输出配置 | |
| 279 | + ExcelUtil.write(response, workSheet, fileName); | |
| 280 | + } | |
| 204 | 281 | |
| 205 | 282 | |
| 206 | 283 | ... | ... |