diff --git a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/devicemanagement/PdaController.java b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/devicemanagement/PdaController.java index 351b2c7..87e9431 100644 --- a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/devicemanagement/PdaController.java +++ b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/devicemanagement/PdaController.java @@ -2,25 +2,16 @@ package com.zteits.irain.portal.web.parkinglotcloudplatform.devicemanagement; import java.io.IOException; import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.poi.xssf.usermodel.XSSFSheet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; +import com.alibaba.fastjson.JSONObject; import com.clouds.common.utils.DateUtil; +import com.clouds.common.utils.ResultUtils; import com.clouds.common.utils.excle.ExcelReadUtil; import com.clouds.common.utils.excle.ExcelUtil; import com.clouds.common.utils.excle.ExcleFillDateManager; @@ -42,217 +33,291 @@ import com.zteits.clouds.api.dto.park.param.TpPTgsPassedcarRequest; import com.zteits.clouds.api.service.park.TpPPdaService; import com.zteits.clouds.api.service.park.TpPTgsPassedcarService; import com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic.InOutParkStatisticController; - import io.swagger.annotations.ApiOperation; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; /** * PDA管理控制器 - * + * * Copyright: Copyright (c) 2017 ZTE-ITS - * + * * @ClassName: PdaController.java - * @Description: + * @Description: * @version: v1.0.0 * @author: wangbiao - * @date: 2017年8月31日 下午3:05:03 + * @date: 2017年8月31日 下午3:05:03 * Modification History: * Date Author Version Description - *---------------------------------------------------------* + * ---------------------------------------------------------* * 2017年8月31日 wangbiao v1.0.0 创建 */ @RestController @RequestMapping("/padinfo") public class PdaController extends BizController { - - private static final Logger logger = LoggerFactory.getLogger(InOutParkStatisticController.class); - - @Autowired - private TpPPdaService tpPPdaService; - @Autowired - private TpPTgsPassedcarService tpPTgsPassedcarService; - - @Value("${project.syscode}") + + private static final Logger logger = LoggerFactory.getLogger(InOutParkStatisticController.class); + + @Autowired + private TpPPdaService tpPPdaService; + @Autowired + private TpPTgsPassedcarService tpPTgsPassedcarService; + + @Value("${project.syscode}") private String sysCode; - - - - @ApiOperation("过车查询") - @PostMapping("/queryPassedca4pabe") - public BizResultVO> queryPassedca4pabe(@RequestBody TpPTgsPassedcarRequest tpPTgsPassedcarRequest, HttpServletRequest request, - HttpServletResponse response){ - BizResult> bizResult = new BizResult>(); - try { - tpPTgsPassedcarRequest.setSysCode(sysCode); - bizResult = tpPTgsPassedcarService.queryPassedcar4Page(tpPTgsPassedcarRequest); - if(bizResult.isSuccess()){ - return returnJqGridData(bizResult, TpPTgsPassedcarDTO.class); - } - } catch (Exception e) { - logger.debug("分页查询过车信息异常:{}",bizResult.getErrMsg()); - } - return new BizResultVO>(); - } - - @ApiOperation("PDA信息信息") - @PostMapping("/queryPdaInfo4pabe") - public BizResultVO> queryPdaInfo4pabe(@RequestBody TpPPdaRequest tpPPdaRequest, HttpServletRequest request, - HttpServletResponse response){ - BizResult> bizResult = new BizResult>(); - try { - tpPPdaRequest.setSysCode(sysCode); - bizResult = tpPPdaService.queryPdaInfo4pabe(tpPPdaRequest); - if(bizResult.isSuccess()){ - return returnJqGridData(bizResult, TpPPdaDTO.class); - } - } catch (Exception e) { - logger.debug("分页查询pda信息异常:{}",bizResult.getErrMsg()); - } - return new BizResultVO>(); - } - - @ApiOperation("新增PDA信息信息") - @PostMapping("/insertPda") - public BizResultVO insertPda(@RequestBody TpPPdaRequest tpPPdaRequest, HttpServletRequest request, - HttpServletResponse response){ - tpPPdaRequest.setSysCode(sysCode); - BizResult bizResult = tpPPdaService.insertPda(tpPPdaRequest); - if(bizResult.isSuccess()){ - return new BizResultVO(bizResult); - }else{ - logger.debug("新增PDA信息信息异常 :{}",bizResult.getErrMsg()); - } - return new BizResultVO(); - } - - @ApiOperation("删除PDA信息信息") - @PostMapping("/deletePda") - public BizResultVO deletePda(@RequestBody TpPPdaRequest tpPPdaRequest, HttpServletRequest request, - HttpServletResponse response){ - tpPPdaRequest.setSysCode(sysCode); - BizResult bizResult = tpPPdaService.deletetPda(tpPPdaRequest); - if(bizResult.isSuccess()){ - return new BizResultVO(bizResult); - }else{ - logger.debug("删除PDA信息信息异常 :{}",bizResult.getErrMsg()); - } - return new BizResultVO(); - } - - @ApiOperation("删除PDA信息信息") - @PostMapping("/deleteBatchPda") - public BizResultVO deleteBatchPda(@RequestBody TpPPdaSRequest tpPPdaSRequest, HttpServletRequest request, - HttpServletResponse response){ - tpPPdaSRequest.setSysCode(sysCode); - BizResult bizResult = tpPPdaService.deleteBatchPda(tpPPdaSRequest); - if(bizResult.isSuccess()){ - return new BizResultVO(bizResult); - }else{ - logger.debug("删除PDA信息信息异常 :{}",bizResult.getErrMsg()); - } - return new BizResultVO(); - } - - @ApiOperation("根据id查询PDA信息") - @PostMapping("/queryPdaById") - public BizResultVO queryPdaById(@RequestBody TpPPdaRequest tpPPdaRequest, HttpServletRequest request, - HttpServletResponse response){ - tpPPdaRequest.setSysCode(sysCode); - BizResult bizResult = tpPPdaService.queryPdaById(tpPPdaRequest); - if(bizResult.isSuccess()){ - return new BizResultVO(bizResult); - }else{ - logger.debug("根据id查询PDA信息异常 :{}",bizResult.getErrMsg()); - } - return new BizResultVO(); - } - - @ApiOperation("修改PDA信息") - @PostMapping("/updatePda") - public BizResultVO updatePda(@RequestBody TpPPdaRequest tpPPdaRequest, HttpServletRequest request, - HttpServletResponse response){ - tpPPdaRequest.setSysCode(sysCode); - BizResult bizResult = tpPPdaService.updatePda(tpPPdaRequest); - if(bizResult.isSuccess()){ - return new BizResultVO(bizResult); - }else{ - logger.debug("修改PDA信息异常 :{}",bizResult.getErrMsg()); - } - return new BizResultVO(); - } - - @ApiOperation("pda信息导出excel") - @GetMapping("exportBerthInfoExcel") - public void exportBerthInfoExcel(@RequestBody TpPPdaRequest tpPPdaRequest, HttpServletRequest requests, HttpServletResponse response) { - tpPPdaRequest.setSysCode(sysCode); - BizResult> list = tpPPdaService.queryPdaInfo(tpPPdaRequest); - String[] title = new String[] { "序号","设备编号", "设备名称", "设备类型", "状态","持有人","资源描述" }; - String sheetName = "PDA信息"; - String fileName = sheetName+DateUtil.getDate(); - // 1.创建excel信息 - XSSFSheet workSheet = ExcelUtil.createExcel(fileName); - // 2.设置excel表头和表体 - Layouter.buildReport(workSheet, title, 0, 0); - // 3.填充数据 - List contentList = new ArrayList(); - int number = 1; - if(list.isSuccess() && CollectionUtil.isNotEmpty(list.getData())){ - for (TpPPdaDTO b : list.getData()) { - Object[] obj = new Object[title.length]; - int index = 0; - obj[index++] = number++; - obj[index++] = b.getId(); - obj[index++] = b.getPdaNo(); - obj[index++] = b.getPdaName(); - obj[index++] = b.getPdaType(); - obj[index++] = b.getPdaStatus(); - obj[index++] = b.getOwnerName(); - obj[index++] = b.getRemark(); - contentList.add(obj); - } - } - ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); - fillUserManager.fillSalesOrga(workSheet, title, contentList, 2); - // 4.excel输出配置 - ExcelUtil.write(response, workSheet, fileName); - } - - - @ApiOperation("pda信息 导入模板下载") - @GetMapping("exportModelExcel") - public void exportModelExcel(HttpServletRequest requests, HttpServletResponse response) { - String[] title = new String[] { "设备编号", "设备名称", "设备类型","停车场编号","sim卡号","持有人编号","持有人名称","状态","资源描述" }; - String fileName = "PDA信息导入模板"; - // 1.创建excel信息 - XSSFSheet workSheet = ExcelUtil.createExcel(fileName); - // 2.设置excel表头和表体 - Layouter.buildReport(workSheet, title, 0, 0); - // 3.填充数据 - ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); - fillUserManager.fillSalesOrga(workSheet, title, Lists.newArrayList(), 2); - // 4.excel输出配置 - ExcelUtil.write(response, workSheet, fileName); - } - - - @PostMapping("/importPda") - public BizResultVO importPda(@RequestParam(value="excelFile") MultipartFile file,HttpServletRequest request) throws IOException{ - if(file==null){ - throw new BizException(ErrorType.PARAMM_NULL, "导入文件不能为空"); - } + + @ApiOperation("过车查询") + @PostMapping("/queryPassedca4pabe") + public BizResultVO> queryPassedca4pabe( + @RequestBody TpPTgsPassedcarRequest tpPTgsPassedcarRequest, HttpServletRequest request, + HttpServletResponse response) { + BizResult> bizResult = new BizResult>(); + try { + tpPTgsPassedcarRequest.setSysCode(sysCode); + bizResult = tpPTgsPassedcarService.queryPassedcar4Page(tpPTgsPassedcarRequest); + if (bizResult.isSuccess()) { + return returnJqGridData(bizResult, TpPTgsPassedcarDTO.class); + } + } catch (Exception e) { + logger.debug("分页查询过车信息异常:{}", bizResult.getErrMsg()); + } + return new BizResultVO>(); + } + + @ApiOperation("过车信息下载") + @GetMapping("/exportPassCarInfoExcel") + public void exportPassCarInfoExcel(@RequestParam String clicensetype, @RequestParam String ccarnumber, + @RequestParam String s_dcollectiondate, @DateTimeFormat + @RequestParam String e_dcollectiondate, @RequestParam String cdevicecodes, HttpServletRequest request, + HttpServletResponse response) { + TpPTgsPassedcarRequest req = new TpPTgsPassedcarRequest(); + req.setCcarnumber(ccarnumber); + if(null !=cdevicecodes){ + List data = JSONObject.parseArray(cdevicecodes,String.class); + req.setCdevicecodes(data); + } + req.setClicensetype(clicensetype); + if(null != s_dcollectiondate){ + req.setS_dcollectiondate(new Date(Long.parseLong(s_dcollectiondate))); + } + + if(null != e_dcollectiondate){ + req.setE_dcollectiondate(new Date(Long.parseLong(e_dcollectiondate))); + } + + //设置导出信息 + req.getBaseRequest().setPageNum(1); + req.getBaseRequest().setPageSize(0); + req.setSysCode(sysCode); + BizResult> bizResult = tpPTgsPassedcarService.queryPassedcar4Page(req); + if (ResultUtils.isError(bizResult)) { + return; + } + List listData = bizResult.getData().getDataList(); + + String[] title = new String[] {"车牌号", "停车点", "车辆类型", "采集时间", "车道", "车速", "行驶方向"}; + String sheetName = "过车信息"; + String fileName = sheetName + com.xiaoleilu.hutool.date.DateUtil.format(new Date(), + com.xiaoleilu.hutool.date.DateUtil.NORM_DATETIME_PATTERN); + // 1.创建excel信息 + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); + // 2.设置excel表头和表体 + Layouter.buildReport(workSheet, title, 0, 0); + // 3.填充数据 + List contentList = new ArrayList(); + int number = 1; + for (TpPTgsPassedcarDTO b : listData) { + Object[] obj = new Object[title.length]; + int index = 0; + obj[index++] = b.getCcarnumber(); + obj[index++] = b.getCdevicecode(); + obj[index++] = b.getClicensetype(); + obj[index++] = b.getDcollectiondate() == null ? "" : com.xiaoleilu.hutool.date.DateUtil.format( + b.getDcollectiondate(), com.xiaoleilu.hutool.date.DateUtil.NORM_DATETIME_PATTERN); + obj[index++] = b.getClanenumber(); + obj[index++] = b.getNvehiclespeed(); + obj[index++] = b.getNderictrion(); + contentList.add(obj); + } + ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2); + // 4.excel输出配置 + ExcelUtil.write(response, workSheet, fileName); + + } + + @ApiOperation("PDA信息信息") + @PostMapping("/queryPdaInfo4pabe") + public BizResultVO> queryPdaInfo4pabe(@RequestBody TpPPdaRequest tpPPdaRequest, + HttpServletRequest request, + HttpServletResponse response) { + BizResult> bizResult = new BizResult>(); + try { + tpPPdaRequest.setSysCode(sysCode); + bizResult = tpPPdaService.queryPdaInfo4pabe(tpPPdaRequest); + if (bizResult.isSuccess()) { + return returnJqGridData(bizResult, TpPPdaDTO.class); + } + } catch (Exception e) { + logger.debug("分页查询pda信息异常:{}", bizResult.getErrMsg()); + } + return new BizResultVO>(); + } + + @ApiOperation("新增PDA信息信息") + @PostMapping("/insertPda") + public BizResultVO insertPda(@RequestBody TpPPdaRequest tpPPdaRequest, HttpServletRequest request, + HttpServletResponse response) { + tpPPdaRequest.setSysCode(sysCode); + BizResult bizResult = tpPPdaService.insertPda(tpPPdaRequest); + if (bizResult.isSuccess()) { + return new BizResultVO(bizResult); + } else { + logger.debug("新增PDA信息信息异常 :{}", bizResult.getErrMsg()); + } + return new BizResultVO(); + } + + @ApiOperation("删除PDA信息信息") + @PostMapping("/deletePda") + public BizResultVO deletePda(@RequestBody TpPPdaRequest tpPPdaRequest, HttpServletRequest request, + HttpServletResponse response) { + tpPPdaRequest.setSysCode(sysCode); + BizResult bizResult = tpPPdaService.deletetPda(tpPPdaRequest); + if (bizResult.isSuccess()) { + return new BizResultVO(bizResult); + } else { + logger.debug("删除PDA信息信息异常 :{}", bizResult.getErrMsg()); + } + return new BizResultVO(); + } + + @ApiOperation("删除PDA信息信息") + @PostMapping("/deleteBatchPda") + public BizResultVO deleteBatchPda(@RequestBody TpPPdaSRequest tpPPdaSRequest, HttpServletRequest request, + HttpServletResponse response) { + tpPPdaSRequest.setSysCode(sysCode); + BizResult bizResult = tpPPdaService.deleteBatchPda(tpPPdaSRequest); + if (bizResult.isSuccess()) { + return new BizResultVO(bizResult); + } else { + logger.debug("删除PDA信息信息异常 :{}", bizResult.getErrMsg()); + } + return new BizResultVO(); + } + + @ApiOperation("根据id查询PDA信息") + @PostMapping("/queryPdaById") + public BizResultVO queryPdaById(@RequestBody TpPPdaRequest tpPPdaRequest, HttpServletRequest request, + HttpServletResponse response) { + tpPPdaRequest.setSysCode(sysCode); + BizResult bizResult = tpPPdaService.queryPdaById(tpPPdaRequest); + if (bizResult.isSuccess()) { + return new BizResultVO(bizResult); + } else { + logger.debug("根据id查询PDA信息异常 :{}", bizResult.getErrMsg()); + } + return new BizResultVO(); + } + + @ApiOperation("修改PDA信息") + @PostMapping("/updatePda") + public BizResultVO updatePda(@RequestBody TpPPdaRequest tpPPdaRequest, HttpServletRequest request, + HttpServletResponse response) { + tpPPdaRequest.setSysCode(sysCode); + BizResult bizResult = tpPPdaService.updatePda(tpPPdaRequest); + if (bizResult.isSuccess()) { + return new BizResultVO(bizResult); + } else { + logger.debug("修改PDA信息异常 :{}", bizResult.getErrMsg()); + } + return new BizResultVO(); + } + + @ApiOperation("pda信息导出excel") + @GetMapping("exportBerthInfoExcel") + public void exportBerthInfoExcel(@RequestBody TpPPdaRequest tpPPdaRequest, HttpServletRequest requests, + HttpServletResponse response) { + tpPPdaRequest.setSysCode(sysCode); + BizResult> list = tpPPdaService.queryPdaInfo(tpPPdaRequest); + String[] title = new String[] {"序号", "设备编号", "设备名称", "设备类型", "状态", "持有人", "资源描述"}; + String sheetName = "PDA信息"; + String fileName = sheetName + DateUtil.getDate(); + // 1.创建excel信息 + XSSFSheet workSheet = ExcelUtil.createExcel(fileName); + // 2.设置excel表头和表体 + Layouter.buildReport(workSheet, title, 0, 0); + // 3.填充数据 + List contentList = new ArrayList(); + int number = 1; + if (list.isSuccess() && CollectionUtil.isNotEmpty(list.getData())) { + for (TpPPdaDTO b : list.getData()) { + Object[] obj = new Object[title.length]; + int index = 0; + obj[index++] = number++; + obj[index++] = b.getId(); + obj[index++] = b.getPdaNo(); + obj[index++] = b.getPdaName(); + obj[index++] = b.getPdaType(); + obj[index++] = b.getPdaStatus(); + obj[index++] = b.getOwnerName(); + obj[index++] = b.getRemark(); + contentList.add(obj); + } + } + ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2); + // 4.excel输出配置 + ExcelUtil.write(response, workSheet, fileName); + } + + @ApiOperation("pda信息 导入模板下载") + @GetMapping("exportModelExcel") + public void exportModelExcel(HttpServletRequest requests, HttpServletResponse response) { + String[] title = new String[] {"设备编号", "设备名称", "设备类型", "停车场编号", "sim卡号", "持有人编号", "持有人名称", "状态", "资源描述"}; + String fileName = "PDA信息导入模板"; + // 1.创建excel信息 + XSSFSheet workSheet = ExcelUtil.createExcel(fileName); + // 2.设置excel表头和表体 + Layouter.buildReport(workSheet, title, 0, 0); + // 3.填充数据 + ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); + fillUserManager.fillSalesOrga(workSheet, title, Lists.newArrayList(), 2); + // 4.excel输出配置 + ExcelUtil.write(response, workSheet, fileName); + } + + @PostMapping("/importPda") + public BizResultVO importPda(@RequestParam(value = "excelFile") MultipartFile file, + HttpServletRequest request) throws IOException { + if (file == null) { + throw new BizException(ErrorType.PARAMM_NULL, "导入文件不能为空"); + } //读取Excel数据到List中 - List> list = ExcelReadUtil.readExcel(file); + List> list = ExcelReadUtil.readExcel(file); //list中存的就是excel中的数据,可以根据excel中每一列的值转换成你所需要的值(从0开始),如: - TpPPdaRequest tpPPdaRequest = null; - List padList = Lists.newArrayList(); - for(ArrayList arr:list){ - tpPPdaRequest= new TpPPdaRequest(); - tpPPdaRequest.setPdaNo(arr.get(0)); - padList.add(tpPPdaRequest); + TpPPdaRequest tpPPdaRequest = null; + List padList = Lists.newArrayList(); + for (ArrayList arr : list) { + tpPPdaRequest = new TpPPdaRequest(); + tpPPdaRequest.setPdaNo(arr.get(0)); + padList.add(tpPPdaRequest); } - TpPPdaSRequest TpPPdaSRequest = new TpPPdaSRequest(); + TpPPdaSRequest TpPPdaSRequest = new TpPPdaSRequest(); TpPPdaSRequest.setPadList(padList); BizResult rsInteger = tpPPdaService.insertBatchPda(TpPPdaSRequest); return new BizResultVO(rsInteger); } - + }