Commit 5453f6ac23dcced6050fd8a406c290ad417ef825
1 parent
3539f7d2
提交
Showing
1 changed file
with
122 additions
and
2 deletions
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/parklotmanage/ParkLotManageController.java
| 1 | package com.zteits.irain.portal.web.parkinglotcloudplatform.parklotmanage; | 1 | package com.zteits.irain.portal.web.parkinglotcloudplatform.parklotmanage; |
| 2 | 2 | ||
| 3 | +import java.text.SimpleDateFormat; | ||
| 3 | import java.util.ArrayList; | 4 | import java.util.ArrayList; |
| 4 | import java.util.List; | 5 | import java.util.List; |
| 5 | import java.util.Map; | 6 | import java.util.Map; |
| 6 | 7 | ||
| 8 | +import javax.servlet.http.HttpServletResponse; | ||
| 7 | import javax.servlet.http.HttpSession; | 9 | import javax.servlet.http.HttpSession; |
| 8 | 10 | ||
| 9 | import org.apache.commons.lang3.StringUtils; | 11 | import org.apache.commons.lang3.StringUtils; |
| 12 | +import org.apache.poi.util.StringUtil; | ||
| 13 | +import org.apache.poi.xssf.usermodel.XSSFSheet; | ||
| 10 | import org.slf4j.Logger; | 14 | import org.slf4j.Logger; |
| 11 | import org.slf4j.LoggerFactory; | 15 | import org.slf4j.LoggerFactory; |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.web.bind.annotation.GetMapping; | 17 | import org.springframework.web.bind.annotation.GetMapping; |
| 18 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 19 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 14 | import org.springframework.web.bind.annotation.RequestMapping; | 20 | import org.springframework.web.bind.annotation.RequestMapping; |
| 15 | import org.springframework.web.bind.annotation.RequestParam; | 21 | import org.springframework.web.bind.annotation.RequestParam; |
| 16 | import org.springframework.web.bind.annotation.RestController; | 22 | import org.springframework.web.bind.annotation.RestController; |
| 17 | 23 | ||
| 18 | import com.alibaba.dubbo.common.utils.CollectionUtils; | 24 | import com.alibaba.dubbo.common.utils.CollectionUtils; |
| 25 | +import com.alibaba.fastjson.JSONObject; | ||
| 19 | import com.clouds.common.cache.park.ParkingLotCacheUtil; | 26 | import com.clouds.common.cache.park.ParkingLotCacheUtil; |
| 20 | import com.clouds.common.entity.UserInfo; | 27 | import com.clouds.common.entity.UserInfo; |
| 21 | import com.clouds.common.utils.ResultUtils; | 28 | import com.clouds.common.utils.ResultUtils; |
| 29 | +import com.clouds.common.utils.excle.ExcelUtil; | ||
| 30 | +import com.clouds.common.utils.excle.ExcleFillDateManager; | ||
| 31 | +import com.clouds.common.utils.excle.Layouter; | ||
| 32 | +import com.clouds.common.web.BizController; | ||
| 22 | import com.clouds.common.web.SessionCommUtil; | 33 | import com.clouds.common.web.SessionCommUtil; |
| 23 | import com.clouds.common.web.vo.BizResultVO; | 34 | import com.clouds.common.web.vo.BizResultVO; |
| 35 | +import com.clouds.common.web.vo.EasyUIDataGridVO; | ||
| 24 | import com.google.common.collect.Lists; | 36 | import com.google.common.collect.Lists; |
| 25 | import com.google.common.collect.Maps; | 37 | import com.google.common.collect.Maps; |
| 26 | import com.zteits.clouds.api.apibase.bean.BizResult; | 38 | import com.zteits.clouds.api.apibase.bean.BizResult; |
| 39 | +import com.zteits.clouds.api.apibase.bean.PageBean; | ||
| 27 | import com.zteits.clouds.api.apibase.constants.ErrorType; | 40 | import com.zteits.clouds.api.apibase.constants.ErrorType; |
| 28 | import com.zteits.clouds.api.apibase.exception.BizException; | 41 | import com.zteits.clouds.api.apibase.exception.BizException; |
| 29 | import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; | 42 | import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; |
| 43 | +import com.zteits.clouds.api.dto.park.param.ParkingLotInfoDeleteRequest; | ||
| 44 | +import com.zteits.clouds.api.dto.park.param.ParkingLotInfoSaveRequest; | ||
| 45 | +import com.zteits.clouds.api.dto.park.param.ParkingLotInfoUpdateRequest; | ||
| 30 | import com.zteits.clouds.api.dto.park.param.QueryParkLotInfoByPkNoRequest; | 46 | import com.zteits.clouds.api.dto.park.param.QueryParkLotInfoByPkNoRequest; |
| 31 | -import com.zteits.clouds.api.dto.pay.param.TdCompanyParkQueryRequest; | 47 | +import com.zteits.clouds.api.dto.park.param.QueryParkingLotByParkRequest; |
| 32 | import com.zteits.clouds.api.service.park.ParkingLotQueryService; | 48 | import com.zteits.clouds.api.service.park.ParkingLotQueryService; |
| 49 | +import com.zteits.clouds.api.service.park.ParkingLotService; | ||
| 33 | import com.zteits.clouds.api.service.pay.TdCustCompanyService; | 50 | import com.zteits.clouds.api.service.pay.TdCustCompanyService; |
| 34 | 51 | ||
| 35 | import io.swagger.annotations.Api; | 52 | import io.swagger.annotations.Api; |
| @@ -53,7 +70,7 @@ import io.swagger.annotations.ApiOperation; | @@ -53,7 +70,7 @@ import io.swagger.annotations.ApiOperation; | ||
| 53 | @Api(value="停车场管理",description="停车场管理") | 70 | @Api(value="停车场管理",description="停车场管理") |
| 54 | @RestController | 71 | @RestController |
| 55 | @RequestMapping("parkLotManage") | 72 | @RequestMapping("parkLotManage") |
| 56 | -public class ParkLotManageController{ | 73 | +public class ParkLotManageController extends BizController{ |
| 57 | private Logger logger = LoggerFactory.getLogger(ParkLotManageController.class); | 74 | private Logger logger = LoggerFactory.getLogger(ParkLotManageController.class); |
| 58 | @Autowired | 75 | @Autowired |
| 59 | private HttpSession session; | 76 | private HttpSession session; |
| @@ -63,6 +80,8 @@ public class ParkLotManageController{ | @@ -63,6 +80,8 @@ public class ParkLotManageController{ | ||
| 63 | private TdCustCompanyService tdCustCompanyService; | 80 | private TdCustCompanyService tdCustCompanyService; |
| 64 | @Autowired | 81 | @Autowired |
| 65 | private ParkingLotQueryService parkingLotQueryService; | 82 | private ParkingLotQueryService parkingLotQueryService; |
| 83 | + @Autowired | ||
| 84 | + private ParkingLotService parkingLotService; | ||
| 66 | /** | 85 | /** |
| 67 | * 根据登录人权限获取停车场名称列表 | 86 | * 根据登录人权限获取停车场名称列表 |
| 68 | * @return | 87 | * @return |
| @@ -111,4 +130,105 @@ public class ParkLotManageController{ | @@ -111,4 +130,105 @@ public class ParkLotManageController{ | ||
| 111 | } | 130 | } |
| 112 | return plNos; | 131 | return plNos; |
| 113 | } | 132 | } |
| 133 | + /** | ||
| 134 | + * xiejp 2017-08-30 | ||
| 135 | + * @param request | ||
| 136 | + * @return | ||
| 137 | + * @throws Exception | ||
| 138 | + */ | ||
| 139 | + @ApiOperation("分页查询停车场列表") | ||
| 140 | + @PostMapping("/queryParkingLotPageByPark") | ||
| 141 | + public BizResultVO<EasyUIDataGridVO<ParkingLotDTO>> queryParkingLotByPark(@RequestBody QueryParkingLotByParkRequest request) throws Exception { | ||
| 142 | + logger.info("调用分页获取停车场列表dubbo服务入参:request={}"+JSONObject.toJSONString(request)); | ||
| 143 | + if (request == null) { | ||
| 144 | + throw new BizException(ErrorType.PARAMM_NULL, "请求对象"); | ||
| 145 | + } | ||
| 146 | + BizResult<PageBean<ParkingLotDTO>> bizResult = parkingLotQueryService.queryParkingLotByPark(request,request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize()); | ||
| 147 | + return returnJqGridData(bizResult, ParkingLotDTO.class); | ||
| 148 | + } | ||
| 149 | + /** | ||
| 150 | + * 添加停车场信息 | ||
| 151 | + * @param request | ||
| 152 | + * @return | ||
| 153 | + */ | ||
| 154 | + @ApiOperation("添加停车场信息") | ||
| 155 | + @PostMapping("/saveParkingLotInfo") | ||
| 156 | + public BizResultVO<Boolean> SaveParkingLotInfo(@RequestBody ParkingLotInfoSaveRequest request){ | ||
| 157 | + logger.info("调用添加停车场信息dubbo服务入参:request={}"+JSONObject.toJSONString(request)); | ||
| 158 | + BizResult<Boolean> bizResult = parkingLotService.SaveParkingLotInfo(request); | ||
| 159 | + return new BizResultVO<Boolean>(bizResult); | ||
| 160 | + } | ||
| 161 | + /** | ||
| 162 | + * 修改停车场信息 | ||
| 163 | + * @param request | ||
| 164 | + * @return | ||
| 165 | + */ | ||
| 166 | + @ApiOperation("修改停车场信息") | ||
| 167 | + @PostMapping("/updateParkingLotInfo") | ||
| 168 | + public BizResultVO<Boolean> UpdateParkingLotInfo(@RequestBody ParkingLotInfoUpdateRequest request){ | ||
| 169 | + logger.info("调用修改停车场信息dubbo服务入参:request={}"+JSONObject.toJSONString(request)); | ||
| 170 | + BizResult<Boolean> bizResult = parkingLotService.UpdateParkingLotInfo(request); | ||
| 171 | + return new BizResultVO<Boolean>(bizResult); | ||
| 172 | + } | ||
| 173 | + /** | ||
| 174 | + * 根据停车场编号查询停车场信息 | ||
| 175 | + * @param request | ||
| 176 | + * @return | ||
| 177 | + */ | ||
| 178 | + @ApiOperation("根据停车场编号查询停车场信息") | ||
| 179 | + @PostMapping("/queryParkingLotByPkNo") | ||
| 180 | + public BizResultVO<ParkingLotDTO> QueryParkingLotByPkNo(@RequestBody QueryParkLotInfoByPkNoRequest request){ | ||
| 181 | + logger.info("调用根据停车场编号查询停车场信息dubbo服务入参:request={}"+JSONObject.toJSONString(request)); | ||
| 182 | + BizResult<ParkingLotDTO> bizResult = parkingLotQueryService.QueryParkingLotByPkNo(request); | ||
| 183 | + return new BizResultVO<ParkingLotDTO>(bizResult); | ||
| 184 | + } | ||
| 185 | + /** | ||
| 186 | + * 删除停车场信息 | ||
| 187 | + * @param request | ||
| 188 | + * @return | ||
| 189 | + */ | ||
| 190 | + @ApiOperation("删除停车场信息") | ||
| 191 | + @PostMapping("/deleteParkingLotInfoByPlIds") | ||
| 192 | + public BizResultVO<Boolean> DeleteParkingLotInfoByPlIds(@RequestBody ParkingLotInfoDeleteRequest request){ | ||
| 193 | + logger.info("调用删除停车场信息dubbo服务入参:request={}"+JSONObject.toJSONString(request)); | ||
| 194 | + BizResult<Boolean> bizResult = parkingLotService.DeleteParkingLotInfoByPlIds(request); | ||
| 195 | + return new BizResultVO<Boolean>(bizResult); | ||
| 196 | + } | ||
| 197 | + /** | ||
| 198 | + * 导出 | ||
| 199 | + * @param request | ||
| 200 | + * @param response | ||
| 201 | + * @throws Exception | ||
| 202 | + */ | ||
| 203 | + @ApiOperation("导出停车场信息") | ||
| 204 | + @PostMapping("/parkingToExcleForPage") | ||
| 205 | + public void parkingToExcleForPage(@RequestBody QueryParkingLotByParkRequest request,HttpServletResponse response) throws Exception{ | ||
| 206 | + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 207 | + | ||
| 208 | + BizResult<PageBean<ParkingLotDTO>> bizResult = parkingLotQueryService.queryParkingLotByPark(request,0,0); | ||
| 209 | + | ||
| 210 | + String[] title = new String[]{"停车场编号","停车场名称"}; | ||
| 211 | + String sheetName="停车场"; | ||
| 212 | + String fileName = "停车场信息"; | ||
| 213 | + // 1.创建excel信息 | ||
| 214 | + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); | ||
| 215 | + // 2.设置excel表头和表体 | ||
| 216 | + Layouter.buildReport(workSheet,title,0, 0); | ||
| 217 | + //3.填充数据 | ||
| 218 | + List<Object[]> contentList=new ArrayList<Object[]>(); | ||
| 219 | + List<ParkingLotDTO> list = bizResult.getData().getDataList(); | ||
| 220 | + for (ParkingLotDTO e: list) { | ||
| 221 | + Object[] obj=new Object[title.length]; | ||
| 222 | + int index=0; | ||
| 223 | + obj[index++]=e.getPlNo(); | ||
| 224 | + obj[index++]=e.getPlName(); | ||
| 225 | + | ||
| 226 | + contentList.add(obj); | ||
| 227 | + } | ||
| 228 | + ExcleFillDateManager fillUserManager=new ExcleFillDateManager(); | ||
| 229 | + fillUserManager.fillSalesOrga(workSheet,title,contentList,2); | ||
| 230 | + // 4.excel输出配置 | ||
| 231 | + ExcelUtil.write(response, workSheet, fileName); | ||
| 232 | + } | ||
| 233 | + | ||
| 114 | } | 234 | } |