Commit 50a320b3e0b73e47a04e405c99615e7fd7dbd96a
1 parent
ed3b7683
地磁
Showing
1 changed file
with
84 additions
and
35 deletions
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/devicemanagement/GeomagneticManagementController.java
... | ... | @@ -3,6 +3,14 @@ |
3 | 3 | */ |
4 | 4 | package com.zteits.irain.portal.web.parkinglotcloudplatform.devicemanagement; |
5 | 5 | |
6 | +import java.text.SimpleDateFormat; | |
7 | +import java.util.ArrayList; | |
8 | +import java.util.List; | |
9 | + | |
10 | +import javax.servlet.http.HttpServletRequest; | |
11 | +import javax.servlet.http.HttpServletResponse; | |
12 | + | |
13 | +import org.apache.poi.xssf.usermodel.XSSFSheet; | |
6 | 14 | import org.slf4j.Logger; |
7 | 15 | import org.slf4j.LoggerFactory; |
8 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
... | ... | @@ -10,8 +18,13 @@ import org.springframework.beans.factory.annotation.Value; |
10 | 18 | import org.springframework.web.bind.annotation.PostMapping; |
11 | 19 | import org.springframework.web.bind.annotation.RequestBody; |
12 | 20 | import org.springframework.web.bind.annotation.RequestMapping; |
21 | +import org.springframework.web.bind.annotation.RequestParam; | |
13 | 22 | import org.springframework.web.bind.annotation.RestController; |
14 | 23 | |
24 | +import com.alibaba.dubbo.common.utils.CollectionUtils; | |
25 | +import com.clouds.common.utils.excle.ExcelUtil; | |
26 | +import com.clouds.common.utils.excle.ExcleFillDateManager; | |
27 | +import com.clouds.common.utils.excle.Layouter; | |
15 | 28 | import com.clouds.common.web.BizController; |
16 | 29 | import com.clouds.common.web.vo.BizResultVO; |
17 | 30 | import com.clouds.common.web.vo.EasyUIDataGridVO; |
... | ... | @@ -20,8 +33,12 @@ import com.zteits.clouds.api.apibase.bean.PageBean; |
20 | 33 | import com.zteits.clouds.api.apibase.constants.ErrorType; |
21 | 34 | import com.zteits.clouds.api.apibase.exception.BizException; |
22 | 35 | import com.zteits.clouds.api.dto.park.dto.GeomagneticManagementDTO; |
36 | +import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; | |
23 | 37 | import com.zteits.clouds.api.dto.park.param.GeomagneticManagementRequest; |
24 | 38 | import com.zteits.clouds.api.dto.park.param.NewGeomagneticRecRequest; |
39 | +import com.zteits.clouds.api.dto.park.param.QueryParkLotInfoByPkNoRequest; | |
40 | +import com.zteits.clouds.api.dto.park.param.QueryParkingLotByParkRequest; | |
41 | +import com.zteits.clouds.api.service.park.BerthManageService; | |
25 | 42 | import com.zteits.clouds.api.service.park.GeomagneticManagementService; |
26 | 43 | |
27 | 44 | import io.swagger.annotations.ApiOperation; |
... | ... | @@ -41,6 +58,9 @@ public class GeomagneticManagementController extends BizController { |
41 | 58 | @Autowired |
42 | 59 | private GeomagneticManagementService geoMngtSrvc; |
43 | 60 | |
61 | + @Autowired | |
62 | + private BerthManageService berthManageService; | |
63 | + | |
44 | 64 | @ApiOperation("查询地磁管理记录") |
45 | 65 | @PostMapping("records") |
46 | 66 | public BizResultVO<EasyUIDataGridVO<GeomagneticManagementDTO>> queryGeomaneticManagementRecs ( |
... | ... | @@ -62,53 +82,82 @@ public class GeomagneticManagementController extends BizController { |
62 | 82 | @PostMapping("deleteall") |
63 | 83 | public BizResultVO<Boolean> deleteAllQueryedRecs (@RequestBody GeomagneticManagementRequest requestObject) { |
64 | 84 | BizResultVO<Boolean> bizResultVO = new BizResultVO<>(); |
65 | - BizResult<Boolean> bizResult = null; | |
66 | - | |
67 | - requestObject.setSysCode(sysCode); | |
68 | - try { | |
69 | - bizResult = geoMngtSrvc.deleteAllQueryedRecs(requestObject); | |
70 | - } catch (Exception e) { | |
71 | - e.printStackTrace(); | |
72 | - logger.error(e.toString()); | |
73 | - return bizResultVO.setData(false); | |
74 | - } | |
75 | - | |
85 | + BizResult<Boolean> bizResult = geoMngtSrvc.deleteAllQueryedRecs(requestObject); | |
76 | 86 | return bizResultVO.setData(bizResult.getData()); |
77 | 87 | } |
78 | 88 | |
79 | 89 | @ApiOperation("插入一条地磁场记录") |
80 | 90 | @PostMapping("insertone") |
81 | 91 | public BizResultVO<Long> insertGeomagneticRecord (@RequestBody NewGeomagneticRecRequest requestObject) { |
82 | - BizResultVO<Long> bizResultVO = new BizResultVO<>(); | |
83 | - BizResult<Long> bizResult = null; | |
84 | - | |
85 | - requestObject.setSysCode(sysCode); | |
86 | - | |
87 | - try { | |
88 | - bizResult = geoMngtSrvc.insertGeomagneticRecord(requestObject); | |
89 | - } catch (Exception e) { | |
90 | - logger.error(e.toString()); | |
91 | - e.printStackTrace(); | |
92 | - bizResultVO.setData(new Long(-1)); | |
93 | - } | |
94 | - return bizResultVO.setData(bizResult.getData()); | |
92 | + BizResult<Long> bizResult = geoMngtSrvc.insertGeomagneticRecord(requestObject); | |
93 | + return new BizResultVO<Long>(bizResult); | |
95 | 94 | } |
96 | 95 | |
97 | 96 | @ApiOperation("更新一条地磁场记录") |
98 | 97 | @PostMapping("updateone") |
99 | 98 | public BizResultVO<Boolean> updateGeomagneticRecord (@RequestBody NewGeomagneticRecRequest requestObject) { |
100 | 99 | BizResultVO<Boolean> bizResultVO = new BizResultVO<>(); |
101 | - BizResult<Boolean> bizResult = null; | |
102 | - | |
103 | - requestObject.setSysCode(sysCode); | |
104 | - try { | |
105 | - bizResult = geoMngtSrvc.updateGeomagneticRecord(requestObject); | |
106 | - } catch (Exception e) { | |
107 | - e.printStackTrace(); | |
108 | - logger.error(e.toString()); | |
109 | - return bizResultVO.setData(false); | |
110 | - } | |
111 | - | |
100 | + BizResult<Boolean> bizResult = geoMngtSrvc.updateGeomagneticRecord(requestObject); | |
101 | + return new BizResultVO<Boolean>(bizResult); | |
102 | + } | |
103 | + @ApiOperation("查询泊位编码") | |
104 | + @PostMapping("getBerthMsgByPlNo") | |
105 | + public BizResultVO<List<String>> getBerthMsgByPlNo (@RequestBody QueryParkLotInfoByPkNoRequest request) { | |
106 | + BizResultVO<List<String>> bizResultVO = new BizResultVO<>(); | |
107 | + BizResult<List<String>> bizResult = berthManageService.getBerthMsgByPlNo(request); | |
112 | 108 | return bizResultVO.setData(bizResult.getData()); |
113 | 109 | } |
110 | + | |
111 | + /** | |
112 | + * 导出 | |
113 | + * @param request | |
114 | + * @param response | |
115 | + * @throws Exception | |
116 | + */ | |
117 | + @ApiOperation("导出地磁信息") | |
118 | + @RequestMapping("/eqpMsgToExcleForPage") | |
119 | + public void eqpMsgToExcleForPage(@RequestParam List<String> plNos,@RequestParam String geomagneticNo | |
120 | + ,@RequestParam String isOnline | |
121 | + ,HttpServletRequest request,HttpServletResponse response) throws Exception{ | |
122 | + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
123 | + GeomagneticManagementRequest requestObject = new GeomagneticManagementRequest(); | |
124 | + requestObject.setSysCode(sysCode); | |
125 | + requestObject.getBaseRequest().setPageSize(0); | |
126 | + requestObject.setGeomagneticNo(geomagneticNo); | |
127 | + requestObject.setPlNos(plNos); | |
128 | + requestObject.setIsOnline(isOnline); | |
129 | + BizResult<PageBean<GeomagneticManagementDTO>> respondObject = geoMngtSrvc.queryGeomagneticManagementRecs(requestObject); | |
130 | + String[] title = new String[]{"停车场编号","停车场名称","泊位编号","地磁编号","地磁名称" | |
131 | + ,"设备型号","心跳时间","是否在线"}; | |
132 | + String sheetName="地磁"; | |
133 | + String fileName = "地磁基本信息"; | |
134 | + // 1.创建excel信息 | |
135 | + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); | |
136 | + // 2.设置excel表头和表体 | |
137 | + Layouter.buildReport(workSheet,title,0, 0); | |
138 | + //3.填充数据 | |
139 | + List<Object[]> contentList=new ArrayList<Object[]>(); | |
140 | + List<GeomagneticManagementDTO> list = respondObject.getData().getDataList(); | |
141 | + if(!CollectionUtils.isEmpty(list)){ | |
142 | + for (GeomagneticManagementDTO e: list) { | |
143 | + Object[] obj=new Object[title.length]; | |
144 | + int index=0; | |
145 | + obj[index++]=e.getPlNo(); | |
146 | + obj[index++]=e.getPlName(); | |
147 | + obj[index++]=e.getBerthNo(); | |
148 | + obj[index++]=e.getEqpNo(); | |
149 | + obj[index++]=e.getEqpName(); | |
150 | + obj[index++]=e.getEqpModel(); | |
151 | + obj[index++]=e.getHeartbeatInterval(); | |
152 | + obj[index++]=e.getEqpIsOnline(); | |
153 | + | |
154 | + contentList.add(obj); | |
155 | + } | |
156 | + } | |
157 | + ExcleFillDateManager fillUserManager=new ExcleFillDateManager(); | |
158 | + fillUserManager.fillSalesOrga(workSheet,title,contentList,2); | |
159 | + // 4.excel输出配置 | |
160 | + ExcelUtil.write(response, workSheet, fileName); | |
161 | + } | |
162 | + | |
114 | 163 | } | ... | ... |