diff --git a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/BillManageController.java b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/BillManageController.java deleted file mode 100644 index 00a349b..0000000 --- a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/BillManageController.java +++ /dev/null @@ -1,274 +0,0 @@ -package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; - -import java.math.BigDecimal; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; - -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.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -import com.alibaba.dubbo.common.utils.StringUtils; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.clouds.common.constants.SessionEnum; -import com.clouds.common.entity.UserInfo; -import com.clouds.common.utils.excle.ExcelUtil; -import com.clouds.common.utils.excle.ExcleFillDateManager; -import com.clouds.common.utils.excle.Layouter; -import com.clouds.common.web.BizController; -import com.clouds.common.web.SessionCommUtil; -import com.zteits.clouds.api.apibase.bean.BizResult; -import com.zteits.clouds.api.apibase.bean.PageBean; -import com.zteits.clouds.api.dto.clouds.dto.BillManageDTO; -import com.zteits.clouds.api.dto.clouds.param.BillQueryRequest; -import com.zteits.clouds.api.dto.pay.param.TdCompanyParkQueryRequest; -import com.zteits.clouds.api.service.clouds.BillManageForDayService; -import com.zteits.clouds.api.service.pay.TdCustCompanyService; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; - -/** - * 日账单controller类.
- * - * Copyright: Copyright (c) 2017 zteits - * - * @ClassName: BillManageController.java - * @Description: - * @version: v1.0.0 - * @author: wangfs - * @date: 2017年6月30日 下午1:14:16 - * Modification History: - * Date Author Version Description - *---------------------------------------------------------* - * 2017年6月30日 wangfs v1.0.0 创建 - */ - -@Api(value = "停车场云平台 日账单", description = "停车场云平台 日账单") -@Controller -@RequestMapping("/bill") -public class BillManageController extends BizController { - private Logger logger = LoggerFactory.getLogger(BillManageController.class); - @Autowired - private BillManageForDayService billManageForDayService; - - @Autowired - private TdCustCompanyService tdCustCompanyService; - - @Autowired - private SessionCommUtil sessionCommUtil; - - @Autowired - private Map map; - - private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - @ApiOperation("日账汇总单查询") - @RequestMapping("/queryBillforDayForPage") - @ResponseBody - public void queryBillforDayTotalForPage(@RequestBody BillQueryRequest billQueryRequest, HttpServletRequest request, - HttpServletResponse response) throws Exception { - TdCustCompanyService sert = map.get("tdCustCompanyService"); - logger.info("---begin--日账汇总单查询调用后场dubbo服务,入参={}", JSONObject.toJSON(billQueryRequest)); - System.out.println("seesionId="+request.getSession().getId()); - UserInfo userInfo = sessionCommUtil.getUserInfo(); - logger.info("从session中获取的用户信息={}" + JSONObject.toJSONString(userInfo)); - TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest(); - if (userInfo != null) { - - tdCompanyParkQueryRequest.setSysCode(billQueryRequest.getSysCode()); - tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds()); - tdCompanyParkQueryRequest.setSessionId(request.getSession().getId()); - billQueryRequest.setParkIdList(this.queryParkNoByCustIds(tdCompanyParkQueryRequest)); - } - - BizResult> result = billManageForDayService.queryBillforDayTotalForPage(billQueryRequest); - result.setErrMsg(billQueryRequest.getParkIdList().toString()); - logger.info("---end--日账汇总单查询调用后场dubbo服务,结果={}", JSONObject.toJSONString(result)); - this.returnJsonDataGrid(response, result); - } - - /** - * 查询日账单.
- * - * @param request - * @param response - * @throws Exception - */ - @ApiOperation("日账单查看") - @RequestMapping(value = "/queryBillForDay", method = RequestMethod.POST) - @ResponseBody - public void queryBillForDay(@RequestBody BillQueryRequest billQueryRequest, HttpServletRequest request, - HttpServletResponse response) throws Exception { - BizResult> result = new BizResult>(); - logger.info("---begin---日账单查看调用后场dubbo服务,入参={}", JSONObject.toJSONString(billQueryRequest)); - TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest(); - UserInfo userInfo = (UserInfo) request.getSession().getAttribute(SessionEnum.USER_INFO.key()); - logger.info("从session中获取的用户信息={}" + JSONObject.toJSONString(userInfo)); - if (userInfo != null) { - - tdCompanyParkQueryRequest.setSysCode(billQueryRequest.getSysCode()); - tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds()); - tdCompanyParkQueryRequest.setSessionId(request.getSession().getId()); - billQueryRequest.setUserName(userInfo.getName()); - billQueryRequest.setParkIdList(this.queryParkNoByCustIds(tdCompanyParkQueryRequest)); - - } - result = billManageForDayService.queryBillforDayDeatilPage(billQueryRequest); - logger.info("---end---日账单查看调用后场dubbo服务,结果={}", JSONObject.toJSON(result)); - - this.returnJsonDataGrid(response, result); - } - - /** - * 获取登录用户信息.
- * @param request - * @param response - * @throws Exception - */ - @RequestMapping(value = "/queryUserInfoForName", method = RequestMethod.POST) - public void queryUserInfoForName( HttpServletRequest request, - HttpServletResponse response) throws Exception { - UserInfo userInfo = (UserInfo) request.getSession().getAttribute(SessionEnum.USER_INFO.key()); - this.returnJson(response, userInfo); - } - - - - - - /** - * 日账单导出.
- * - * @param request - * @param response - * @throws Exception - */ - @RequestMapping("/exportToExcleForBillForDay") - public void exportToExcleForBillForDay(String sysCode, String beginTime, String endTime, String aliTotalFee , - String aliDealCount,String wxTotalFee,String wxDealCount,String cashTotalFee,String cashDealCount, - String orderTotalFee,String orderDealCount, - HttpServletRequest request,String parkIds,String userName, - HttpServletResponse response) throws Exception { - - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - //获取session中的用户信息 - UserInfo userInfo = sessionCommUtil.getUserInfo(); - BillQueryRequest billQueryRequest = new BillQueryRequest(); - - billQueryRequest.setBeginTime(format.parse(beginTime)); - billQueryRequest.setEndTime(format.parse(endTime)); - billQueryRequest.setSysCode(sysCode); - billQueryRequest.getBaseRequest().setPageSize(0); - List parkList= new ArrayList(); - if(StringUtils.isNotEmpty(parkIds)){ - for(String str :parkIds.split(",")){ - if(StringUtils.isNotEmpty(str)){ - parkList.add(str.trim()); - } - } - } - billQueryRequest.setParkIdList(parkList); - /**查询日账单汇总信息.*/ - BizResult> result = billManageForDayService.queryBillforDayDeatilPage(billQueryRequest); - String[] titleOne = new String[2]; - titleOne[0] = "用户: " + (StringUtils.isNotEmpty(userName) ? userName : ""); - titleOne[1] = "时间: "+beginTime+" "+endTime; - String[] titleTwo = new String[] {"","现金", "微信", "支付宝", "合计"}; - String[] titleThree = new String[] { "停车场名称", "现金", "微信", "支付宝", "合计"}; - String sheetName = "日账单"; - String fileName = "日账单管理" + format.format(new Date()); - - - // 1.创建excel信息 - XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); - // 2.设置excel表头和表体 - Layouter.buildBillForDay(workSheet, titleOne, 0, 0);//创建第一行标题 - Layouter.buildHeaders(workSheet, titleTwo, 0, 0);//创建第2行标题 - Layouter.buildHeaders(workSheet, titleThree, 3, 0);//创建第3行标题 - // 3.填充数据 - List contentListTwo = new ArrayList(); - for(int i = 0;i<2;i++){ - Object[] str = new Object[titleTwo.length]; - if(i == 0){ - str[0] = "交易笔数"; - str[1] = (cashDealCount == null ? "0" : cashDealCount); - str[2] = (wxDealCount== null ? "0" : wxDealCount); - str[3] = (aliDealCount== null ? "0" : aliDealCount); - str[4] = (orderDealCount== null ? "0" : orderDealCount); - }else{ - str[0] = "总收入(元)"; - str[1] = (cashTotalFee == null ? "0" : new BigDecimal(cashTotalFee).divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; - str[2] = (wxTotalFee== null ? "0" : new BigDecimal(wxTotalFee).divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; - str[3] = (aliTotalFee== null ? "0" : new BigDecimal(aliTotalFee).divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; - str[4] = (orderTotalFee== null ? "0" : new BigDecimal(orderTotalFee).divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; - } - contentListTwo.add(str); - } - ExcleFillDateManager fillUserManagerTwo = new ExcleFillDateManager(); - fillUserManagerTwo.fillSalesOrga(workSheet, titleTwo, contentListTwo, 2); //第2行标题 - - // - List contentList = new ArrayList(); - if(result != null && result.getData() != null){ - List list = result.getData().getDataList(); - if(list != null && list.size()>0){ - for (int i = 0; i < list.size(); i++) { - BillManageDTO e = list.get(i); - Object[] obj = new Object[titleThree.length]; - int index = 0; - obj[index++] = e.getParkName(); - obj[index++] = (e.getCashTotalFee()== null ? "0" : e.getCashTotalFee().divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; - obj[index++] = (e.getWxTotalFee()== null ? "0" : e.getWxTotalFee().divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; - obj[index++] = (e.getAliTotalFee()== null ? "0" : e.getAliTotalFee().divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; - obj[index++] = (e.getAliTotalFee()== null ? "0" : e.getAliTotalFee().divide(new BigDecimal("100"),2, BigDecimal.ROUND_HALF_UP)) ; - contentList.add(obj); - } - } - } - - ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); - fillUserManager.fillSalesOrga(workSheet, titleThree, contentList, 5); - // 4.excel输出配置 - ExcelUtil.write(response, workSheet, fileName); - - - } - - /** - * 通过session信息获取停车场编码.
- * - * @param billQueryRequest - * @param userInfo - * @return - * @throws Exception - */ - private List queryParkNoByCustIds(TdCompanyParkQueryRequest tdCompanyParkQueryRequest) throws Exception { - /** 查询停车场编码. */ - BizResult> parkNoResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest); - if (parkNoResult.isSuccess() && parkNoResult != null && parkNoResult.getData() != null) { - logger.info("根据登录获取到对应的停车场编码=" + JSONArray.toJSONString(parkNoResult.getData())); - return parkNoResult.getData(); - } else { - logger.info("根据登录用户没有获取到对应的停车场编码"); - return null; - } - - } - - - -} diff --git a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/ParkLotStatisticController.java b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/ParkLotStatisticController.java deleted file mode 100644 index 1eba049..0000000 --- a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/ParkLotStatisticController.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; - -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpSession; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.alibaba.dubbo.common.utils.CollectionUtils; -import com.clouds.common.cache.park.ParkingLotCacheUtil; -import com.clouds.common.entity.UserInfo; -import com.clouds.common.utils.ResultUtils; -import com.clouds.common.web.SessionCommUtil; -import com.clouds.common.web.vo.BizResultVO; -import com.google.common.collect.Lists; -import com.zteits.clouds.api.apibase.bean.BizResult; -import com.zteits.clouds.api.apibase.constants.ErrorType; -import com.zteits.clouds.api.apibase.exception.BizException; -import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; -import com.zteits.clouds.api.dto.park.param.ParkFreeBerthGetByPlnoRequest; -import com.zteits.clouds.api.dto.park.param.QueryParkLotInfoByPkNoRequest; -import com.zteits.clouds.api.dto.pay.param.TdCompanyParkQueryRequest; -import com.zteits.clouds.api.service.park.ParkFreeBerthService; -import com.zteits.clouds.api.service.park.ParkingLotQueryService; -import com.zteits.clouds.api.service.pay.TdCustCompanyService; -import com.zteits.irain.portal.vo.govclouds.ParkLotStatisticVO; -import com.zteits.irain.portal.web.parkinglotcloudplatform.parklotmanage.ParkLotManageController; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -/** - * - * Copyright: Copyright (c) 2017 zteits - * - * @ClassName: ParkLotStatisticController.java - * @Description: - * @version: v1.0.0 - * @author: zhaowg - * @date: 2017年8月7日 下午5:21:16 - * Modification History: - * Date Author Version Description - *---------------------------------------------------------* - * 2017年8月7日 zhaowg v1.0.0 创建 - */ - -@Api("停车场信息统计") -@RestController -@RequestMapping("parklotstatistic") -public class ParkLotStatisticController { - private Logger logger = LoggerFactory.getLogger(ParkLotManageController.class); - @Autowired - private HttpSession session; - @Autowired - private SessionCommUtil sessionCommUtil; - @Autowired - private TdCustCompanyService tdCustCompanyService; - @Autowired - private ParkingLotQueryService parkingLotQueryService; - @Autowired - private ParkFreeBerthService parkFreeBerthService; - - @ApiOperation("获取停车场信息统计") - @PostMapping("getParkLotStatistic") - public BizResultVO> getParkLotStatistic(@RequestParam String sysCode) throws Exception{ - List result = Lists.newArrayList(); - //拥有的停车场编号 - List plNos = this.GetParkLotNosByCurrUser(sysCode); - //查询对应的停车场信息 - if(CollectionUtils.isEmpty(plNos)){ - return new BizResultVO>().setData(result); - } - //空闲车位数 - ParkFreeBerthGetByPlnoRequest request = new ParkFreeBerthGetByPlnoRequest(); - request.setPlNos(plNos); - request.setSysCode(sysCode); - BizResult> freeBerthsNumBizResult = parkFreeBerthService.getParkFreeBerthByPlno(request ); - Map freeBerthsNumMap = ResultUtils.getBizResultData(freeBerthsNumBizResult); - for (String plNo : plNos) { - //先查询缓存 - ParkingLotDTO lotDTO = ParkingLotCacheUtil.getParkLotByPlNo(plNo); - if(lotDTO == null){ - //查询数据库 - QueryParkLotInfoByPkNoRequest request1 = new QueryParkLotInfoByPkNoRequest(); - request1.setSysCode(sysCode); - request1.setPklNo(plNo); - BizResult bizResult2 = parkingLotQueryService.QueryParkingLotByPkNo(request1); - lotDTO = ResultUtils.getBizResultData(bizResult2); - } - if(lotDTO == null || StringUtils.isBlank(lotDTO.getPlName()) || lotDTO.getPlName().equals("null")){ - continue; - } - ParkLotStatisticVO lotStatisticVO = new ParkLotStatisticVO(); - lotStatisticVO.setPlNo(plNo); - lotStatisticVO.setPlName(lotDTO.getPlName()); - lotStatisticVO.setFreeBerthsNum(freeBerthsNumMap.get(plNo)); - lotStatisticVO.setTotalBerthsNum(lotDTO.getPlBerthNum()); - lotStatisticVO.setUseingBerthsNum(lotDTO.getPlBerthNum()-freeBerthsNumMap.get(plNo)); - //设置地磁在线离线数量 - //TODO 临时方案,只有红山区有数据 - result.add(lotStatisticVO); - } - return new BizResultVO>().setData(result); - } - - private List GetParkLotNosByCurrUser(String sysCode) throws Exception { - logger.info("根据登录人权限获取停车场列表"); - List plNos = Lists.newArrayList(); - //2.调用接口查询当前登录人管辖的停车场名称 - plNos.add("A320211000"); - plNos.add("B1504020C7"); - /*UserInfo userInfo = sessionCommUtil.getUserInfo(); - if(userInfo!=null){ - TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest(); - tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds()); - tdCompanyParkQueryRequest.setSysCode(sysCode); - tdCompanyParkQueryRequest.setSessionId(session.getId()); - BizResult> bizResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest ); - plNos = ResultUtils.getBizResultData(bizResult); - }else{ - throw new BizException(ErrorType.AUTH_TOKEN_NOT_EXISTS); - }*/ - return plNos; - } -} diff --git a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/VehicleFlowStatisticController.java b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/VehicleFlowStatisticController.java deleted file mode 100644 index d4597e7..0000000 --- a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/VehicleFlowStatisticController.java +++ /dev/null @@ -1,405 +0,0 @@ -package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; - -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -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.stereotype.Controller; -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.ResponseBody; - -import com.alibaba.dubbo.common.utils.CollectionUtils; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.clouds.common.entity.UserInfo; -import com.clouds.common.utils.DateUtil; -import com.clouds.common.utils.ResultUtils; -import com.clouds.common.utils.excle.ExcelUtil; -import com.clouds.common.utils.excle.ExcleFillDateManager; -import com.clouds.common.utils.excle.Layouter; -import com.clouds.common.web.BizController; -import com.clouds.common.web.SessionCommUtil; -import com.clouds.common.web.vo.BizResultVO; -import com.clouds.common.web.vo.EasyUIDataGridVO; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.zteits.clouds.api.apibase.bean.BaseInfo; -import com.zteits.clouds.api.apibase.bean.BizResult; -import com.zteits.clouds.api.apibase.bean.PageBean; -import com.zteits.clouds.api.apibase.constants.ErrorType; -import com.zteits.clouds.api.apibase.exception.BizException; -import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO; -import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticMaxAndMinDTO; -import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest; -import com.zteits.clouds.api.dto.pay.param.TdCompanyParkQueryRequest; -import com.zteits.clouds.api.service.park.ParkingLotUseStatisticService; -import com.zteits.clouds.api.service.pay.TdCustCompanyService; -import com.zteits.irain.portal.constant.ParkConstant; -import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.BerthsAndFlowLineChartVO; -import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO; -import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO.SerieVO; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; - -/** - * - * 停车场车流量数据统计 Copyright: Copyright (c) 2017 zteits - * - * @ClassName: ParkingLotUseStatisticController.java - * @Description: - * @version: v1.0.0 - * @author: langlw - * @date: 2017年6月14日 下午3:02:39 Modification History: Date Author Version - * Description ---------------------------------------------------------* - * 2017年6月14日 langlw v1.0.0 创建 - */ -@Api(value = "停车场车流量数据统计", description = "停车场车流量数据统计") -@Controller -@RequestMapping(value = "/VehicleFlowStatistic") -public class VehicleFlowStatisticController extends BizController { - private Logger logger = LoggerFactory.getLogger(VehicleFlowStatisticController.class); - - @Value("${project.syscode}") - private String sysCode; - - @Autowired - private ParkingLotUseStatisticService parkingLotStatisticService; - @Autowired - private HttpSession session; - @Autowired - private SessionCommUtil sessionCommUtil; - @Autowired - private TdCustCompanyService tdCustCompanyService; - - @ApiOperation("分页查询车流量数据统计车位总流量") - @PostMapping("getVehicleFlowStatisticForPage") - @ResponseBody - public BizResultVO> queryParkingLotUseStatisticForPage( - @RequestBody ParkingLotUseStatisticForPageRequest request) throws Exception { - if (null == request.getBeginTime() || null==request.getEndTime()) { - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); - } - Calendar beginc = Calendar.getInstance(); - beginc.setTime(request.getBeginTime()); - int beginYear = beginc.get(Calendar.YEAR); - int beginMonth = beginc.get(Calendar.MONTH) + 1; - int beginDay = beginc.get(Calendar.DAY_OF_MONTH); - - Calendar endc = Calendar.getInstance(); - endc.setTime(request.getEndTime()); - int endYear = endc.get(Calendar.YEAR); - int endMonth = endc.get(Calendar.MONTH) + 1; - int endDay = endc.get(Calendar.DAY_OF_MONTH); - - if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) { - // 2表示按每小时统计 - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); - } else { - // 3表示按每天统计 - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); - } - - BizResult> bizResult = parkingLotStatisticService - .queryParkingLotUseStatisticForPage(request); - return returnJqGridData(bizResult, ParkingLotUseStatisticDTO.class); - } - - @ApiOperation("查询车流量最大值与最小值") - @PostMapping("getVehicleFlowMaxAndMin") - @ResponseBody - public BizResultVO QueryParkingLotUseStatisticMaxAndMin( - @RequestBody ParkingLotUseStatisticForPageRequest request) { - Calendar beginc = Calendar.getInstance(); - beginc.setTime(request.getBeginTime()); - int beginYear = beginc.get(Calendar.YEAR); - int beginMonth = beginc.get(Calendar.MONTH) + 1; - int beginDay = beginc.get(Calendar.DAY_OF_MONTH); - - Calendar endc = Calendar.getInstance(); - endc.setTime(request.getEndTime()); - int endYear = endc.get(Calendar.YEAR); - int endMonth = endc.get(Calendar.MONTH) + 1; - int endDay = endc.get(Calendar.DAY_OF_MONTH); - - if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) { - // 2表示按每小时统计 - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); - } else { - // 3表示按每天统计 - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); - } - BizResult bizResult = parkingLotStatisticService - .QueryVehicleFlowStatisticMaxAndMin(request); - return new BizResultVO<>(bizResult); - } - - @ApiOperation("导出车流量数据统计excel") - @GetMapping("exportVehicleFlowStatisticExcel") - public void excelParkingLotUseStatistic(@RequestParam String beginTime, @RequestParam String endTime, - @RequestParam String plNos, HttpServletRequest requests, HttpServletResponse response) { - ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest(); - request.setSysCode(sysCode); - request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT)); - request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT)); - List plNoslist = new ArrayList<>(); - plNoslist.add(plNos); - request.setPlNos(plNoslist); - request.setBaseRequest(new BaseInfo(1, 0)); - Calendar beginc = Calendar.getInstance(); - beginc.setTime(request.getBeginTime()); - int beginYear = beginc.get(Calendar.YEAR); - int beginMonth = beginc.get(Calendar.MONTH) + 1; - int beginDay = beginc.get(Calendar.DAY_OF_MONTH); - - Calendar endc = Calendar.getInstance(); - endc.setTime(request.getEndTime()); - int endYear = endc.get(Calendar.YEAR); - int endMonth = endc.get(Calendar.MONTH) + 1; - int endDay = endc.get(Calendar.DAY_OF_MONTH); - - if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) { - // 2表示按每小时统计 - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); - } else { - // 3表示按每天统计 - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); - } - BizResult> bizResult = parkingLotStatisticService - .queryParkingLotUseStatisticForPage(request); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); - String[] title = new String[] { "时间", "总车流量", "临时车流量", "固定车流量" }; - String sheetName = "车流量管理"; - String fileName = "车流量管理" + format2.format(new Date()); - // 1.创建excel信息 - XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); - // 2.设置excel表头和表体 - Layouter.buildReport(workSheet, title, 0, 0); - // 3.填充数据 - List contentList = new ArrayList(); - List list = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(bizResult.getData().getDataList())) { - list = bizResult.getData().getDataList(); - } - for (ParkingLotUseStatisticDTO e : list) { - Object[] obj = new Object[title.length]; - int index = 0; - obj[index++] = format.format(e.getStatisticBeginTime()); - obj[index++] = e.getVehicleFlow(); - obj[index++] = e.getTmpVehicleFlow(); - obj[index++] = e.getFixVehicleFlow(); - contentList.add(obj); - } - ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); - fillUserManager.fillSalesOrga(workSheet, title, contentList, 2); - // 4.excel输出配置 - ExcelUtil.write(response, workSheet, fileName); - } - - /** - * 根据时间获取车流量折线图 - * - * @param request - * @return - * @throws Exception - */ - @ApiOperation("根据时间获取车流量折线图") - @PostMapping("getVehicleFlowForLineChart") - @ResponseBody - public BizResultVO getVehicleFlowForLineChart( - @RequestBody ParkingLotUseStatisticForPageRequest request) throws Exception { - - if (null == request.getBeginTime() || null==request.getEndTime()) { - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); - } - //2.调用接口查询当前登录人管辖的停车场名称 - UserInfo userInfo = sessionCommUtil.getUserInfo(); - List plNos = new ArrayList<>(); - if(userInfo!=null){ - TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest(); - tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds()); - tdCompanyParkQueryRequest.setSessionId(session.getId()); - tdCompanyParkQueryRequest.setSysCode(sysCode); - BizResult> bizResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest); - //拥有的停车场编号 - plNos = ResultUtils.getBizResultData(bizResult); - } - if(CollectionUtils.isEmpty(plNos)){ - throw new BizException(ErrorType.PARK_LOT_NOT_EXISTS, "停车场plnos不存在"); - } - request.setPlNos(plNos); - - logger.info("根据停车场编号获取该停车场今日车流量和车位折线图"); - Calendar beginTime = Calendar.getInstance(); - beginTime.setTime(request.getBeginTime()); - - Calendar endTime = Calendar.getInstance(); - endTime.setTime(request.getEndTime()); - - Long dayDifference = DateUtil.getTimeDifference(new Timestamp(request.getEndTime().getTime()), - new Timestamp(request.getBeginTime().getTime())); - List xAxisData = Lists.newArrayList(); - request.setBaseRequest(new BaseInfo(1, 0)); - String dateType=""; - - if (dayDifference == 0L) { - // 20分钟为一个时间戳 - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER20MINUTE); - int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY) * 3; - for (int i = 0; i < totaltimestampCount; i++) { - String hour = String.format("%02d", (i / 3)); - String minute = String.format("%02d", (i % 3) * 20); - xAxisData.add(hour + ":" + minute); - } - dateType="HH:mm"; - LineChartVO vehicleFlows=getVehicleFlows(request, xAxisData, dateType); - return new BizResultVO().setData(vehicleFlows); - - } else if (dayDifference <= 3L) { - // 1小时为一个时间戳 - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); - int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY); - String day = ""; - String month = ""; - for (int i = 0; i < dayDifference.intValue(); i++) { - beginTime.add(Calendar.DAY_OF_MONTH, 1); - int beginMonth = beginTime.get(Calendar.MONTH) + 1; - int beginDay = beginTime.get(Calendar.DAY_OF_MONTH); - month = String.format("%02d", (beginMonth)); - day = String.format("%02d", (beginDay)); - for (int j = 0; j < totaltimestampCount; j++) { - String hour = String.format("%02d", (j)); - xAxisData.add(month + "-" + day + " " + hour); - } - } - dateType="MM-dd HH"; - LineChartVO vehicleFlows=getVehicleFlows(request, xAxisData, dateType); - return new BizResultVO().setData(vehicleFlows); - - } else { - // 1天为一个时间戳 - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); - for (int i = 0; i < dayDifference.intValue(); i++) { - beginTime.add(Calendar.DAY_OF_MONTH, 1); - int beginMonth = beginTime.get(Calendar.MONTH) + 1; - int beginDay = beginTime.get(Calendar.DAY_OF_MONTH); - String month = String.format("%02d", (beginMonth)); - String day = String.format("%02d", (beginDay)); - xAxisData.add(month + "-" + day); - - } - dateType="MM-dd"; - LineChartVO vehicleFlows=getVehicleFlows(request, xAxisData, dateType); - return new BizResultVO().setData(vehicleFlows); - - } - - } - - - private LineChartVO getVehicleFlows(ParkingLotUseStatisticForPageRequest request, - List xAxisData,String dateType){ - // 调用后场服务 - logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request)); - BizResult> bizResult = parkingLotStatisticService - .queryParkingLotUseStatisticForPage(request); - PageBean pageBean = ResultUtils.getBizResultData(bizResult); - List useStatisticDTOs = Lists.newArrayList(); - if (pageBean != null) { - useStatisticDTOs = pageBean.getDataList(); - } - - // 保存固定车流量,时间戳和车流量对应关系 - Map fixVehicleFlowMap = Maps.newHashMap(); - // 保存临时车流量,时间戳和车流量对应关系 - Map tmpVehicleFlowMap = Maps.newHashMap(); - // 停车场编号和名称对应关系 - Map parkNameMap = Maps.newHashMap(); - // 通过停车场,和统计时间分组 - // Map> parkLotMap = Maps.newHashMap(); - if (!CollectionUtils.isEmpty(useStatisticDTOs)) { - for (ParkingLotUseStatisticDTO statisticDTO : useStatisticDTOs) { - String key = statisticDTO.getPlNo(); - parkNameMap.put(key, statisticDTO.getPlName()); - String statisBeginTime = DateUtil.getDateString(statisticDTO.getStatisticBeginTime(), dateType); - //保存固定车流量和临时车流量 - fixVehicleFlowMap.put(statisBeginTime, (fixVehicleFlowMap.get(statisBeginTime)==null?0:fixVehicleFlowMap.get(statisBeginTime))+statisticDTO.getFixVehicleFlow()); - tmpVehicleFlowMap.put(statisBeginTime, (tmpVehicleFlowMap.get(statisBeginTime)==null?0:tmpVehicleFlowMap.get(statisBeginTime))+statisticDTO.getTmpVehicleFlow()); - } - } - - // 封装车流量统计 - LineChartVO vehicleFlows = new LineChartVO(); - List vehicleFlows_legendData = Lists.newArrayList(); - vehicleFlows_legendData.add("临时车"); - vehicleFlows_legendData.add("固定车"); - vehicleFlows.setLegendData(vehicleFlows_legendData); - vehicleFlows.setxAxisData(xAxisData); - List vehicleSeries = Lists.newArrayList(); - // 固定车 - SerieVO fixSerieVo = new SerieVO(); - fixSerieVo.setName("固定车"); - List fixSerieVoData = Lists.newArrayList(); - // 临时车 - SerieVO tmpSerieVo = new SerieVO(); - tmpSerieVo.setName("临时车"); - List tmpSerieVoData = Lists.newArrayList(); - // 保存上一次的临时车值,当某个时间点没有数据时,则保持和上次一致 - Integer lastfixFlow = 0; - Integer lasttmpFlow = 0; - for (String timestamp : xAxisData) { - - if (fixVehicleFlowMap.containsKey(timestamp)) { - lastfixFlow = fixVehicleFlowMap.get(timestamp).intValue(); - }else{ - lastfixFlow =0; - } - fixSerieVoData.add(lastfixFlow); - - if (tmpVehicleFlowMap.containsKey(timestamp)) { - lasttmpFlow = tmpVehicleFlowMap.get(timestamp).intValue(); - }else{ - lasttmpFlow = 0; - } - tmpSerieVoData.add(lasttmpFlow); - } - fixSerieVo.setData(fixSerieVoData); - vehicleSeries.add(fixSerieVo); - tmpSerieVo.setData(tmpSerieVoData); - vehicleSeries.add(tmpSerieVo); - - vehicleFlows.setSeries(vehicleSeries); - return vehicleFlows; - } - - public static void main(String[] args) { - String json="{\"id\":\"1\",\"platform\":\"android\",\"parameter\":{\"drid\":\"177277364\",\"sex\":\"1\",\"type\":\"2\",\"creatorname\":\"Mrw\",\"username\":\"jack\",\"pwd\":\"123456\",\"remark\":\"平板用户\",\"createtime\":\"2017-07-24 23:59:59\"}}"; - JSONObject object =(JSONObject)JSONObject.parse(json); - System.out.println(object.get("id")); - System.out.println(object.get("platform")); - JSONObject parameter =(JSONObject)object.get("parameter"); - System.out.println(parameter.get("drid")); - System.out.println(parameter.get("sex")); - } - - -} diff --git a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/YearMonthCardStatisticController.java b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/YearMonthCardStatisticController.java deleted file mode 100644 index 6e5b2ec..0000000 --- a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/YearMonthCardStatisticController.java +++ /dev/null @@ -1,243 +0,0 @@ -package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.alibaba.dubbo.common.utils.CollectionUtils; -import com.alibaba.fastjson.JSON; - -import com.clouds.common.utils.excle.ExcelUtil; -import com.clouds.common.utils.excle.ExcleFillDateManager; -import com.clouds.common.utils.excle.Layouter; -import com.clouds.common.web.BizController; -import com.clouds.common.web.vo.BizResultVO; -import com.clouds.common.web.vo.EasyUIDataGridVO; -import com.zteits.clouds.api.apibase.bean.BaseInfo; -import com.zteits.clouds.api.apibase.bean.BizResult; -import com.zteits.clouds.api.apibase.bean.PageBean; -import com.zteits.clouds.api.apibase.constants.ErrorType; -import com.zteits.clouds.api.apibase.exception.BizException; -import com.zteits.clouds.api.dto.clouds.dto.YearMonthCardStatisticDTO; -import com.zteits.clouds.api.dto.clouds.dto.YearMonthCardStatisticSumDTO; -import com.zteits.clouds.api.dto.pay.param.YearMonthCardStatisticRequest; -import com.zteits.clouds.api.service.clouds.YearMonthCardStatisticService; -import io.swagger.annotations.Api; -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.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.ResponseBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * 企业云平台->数据统计->年卡月卡统计。 - * - * Copyright: Copyright (c) 2017 zteits - * - * @ClassName: InOutParkStatisticController.java - * @Description: - * @version: v1.0.0 - * @author: langlw - * @date: 2017年7月26日 上午11:30:04 - * Modification History: - * Date Author Version Description - * ---------------------------------------------------------* - * 2017年7月26日 langlw v1.0.0 创建 - */ -@Api(value = "企业云平台->数据统计->年卡月卡统计", description = "企业云平台->数据统计->年卡月卡统计") -@RestController -@RequestMapping(value = "/yearMonthCardStatistic") -public class YearMonthCardStatisticController extends BizController { - - private static final Logger logger = LoggerFactory.getLogger(InOutParkStatisticController.class); - - @Value("${project.syscode}") - private String sysCode; - @Autowired - private YearMonthCardStatisticService yearMonthCardStatisticService; - - @ApiOperation("年卡月卡统计") - @PostMapping("queryYearMonthCardStatistic") - @ResponseBody - public BizResultVO> queryYearMonthCardStatistic( - @RequestBody YearMonthCardStatisticRequest request) throws Exception { - logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request)); - if (null == request.getBeginTime() || null == request.getEndTime()) { - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); - } - BizResult> bizResult = yearMonthCardStatisticService - .queryYearMonthCardStatistic(request); - return returnJqGridData(bizResult, YearMonthCardStatisticDTO.class); - } - - @ApiOperation("年卡月卡统计折线图") - @PostMapping("queryYearMonthCardStatisticForChart") - @ResponseBody - public BizResultVO> queryYearMonthCardStatisticForChart( - @RequestBody YearMonthCardStatisticRequest request) throws Exception { - logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request)); - if (null == request.getBeginTime() || null == request.getEndTime()) { - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); - } - BizResult> bizResult = yearMonthCardStatisticService - .queryYearMonthCardStatisticSum(request); - logger.info("调用DUBBO服务返回结果:" + JSON.toJSONString(bizResult)); - return new BizResultVO<>(bizResult); - } - - @ApiOperation("导出年卡月卡统计excel") - @GetMapping("exportYearMonthStatisticExcel") - public void exportYearMonthStatisticExcel(@RequestParam Long beginTime, @RequestParam Long endTime, - @RequestParam List parkIdList, @RequestParam String parkNames, - Integer orderType, Integer payType, Integer dataState, - HttpServletRequest requests, HttpServletResponse response) throws Exception { - - YearMonthCardStatisticRequest request = new YearMonthCardStatisticRequest(); - request.setSysCode(sysCode); - request.setBeginTime(new Date(beginTime)); - request.setEndTime(new Date(endTime)); - - request.setParkIdList(parkIdList); - request.setBaseRequest(new BaseInfo(1, 0)); - request.setOrderType(orderType); - request.setPayType(payType); - request.setDataState(dataState); - - BizResult> bizResult = yearMonthCardStatisticService - .queryYearMonthCardStatistic(request); - BizResult> bizResultSum = yearMonthCardStatisticService - .queryYearMonthCardStatisticSum(request); - - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); - String[] title = new String[] {"交易时间", "停车场", "类型", "车牌号", "支付方式", "支付金额", "有效期", "状态"}; - String sheetName = "年卡月卡统计"; - String fileName = "年卡月卡统计" + format2.format(new Date()); - - String[] billTitle = new String[9]; - billTitle = new String[2]; - //if (!org.springframework.util.CollectionUtils.isEmpty(bizResultSum.getData())) { - // List dtoList = bizResultSum.getData(); - // String amountsum = ""; - // String sum = ""; - // for (YearMonthCardStatisticSumDTO dto : dtoList) { - // amountsum = dto.getAmountSum() == null ? " " : dto.getAmountSum() + "," + amountsum; - // sum = dto.getOrderSum() + "," + sum; - // } - // String ordertype = ""; - // if (null != orderType) { - // if (2 == orderType) { - // ordertype = "年卡"; - // } else if (3 == orderType) { - // ordertype = "月卡"; - // } - // } - // String datastate = ""; - // if (null != dataState) { - // if (1 == dataState) { - // datastate = "有效"; - // } else if (0 == dataState) { - // datastate = "无效"; - // } - // } - // - billTitle[0] = "年卡月卡统计"; - // billTitle[1] = "汇总"; - // billTitle[2] = "停车场: " + parkNames; - // billTitle[3] = "时间: " + endTime; - // billTitle[4] = "类型:" + (orderType != null ? ordertype : ""); - // billTitle[5] = "状态: " + (dataState != null ? datastate : ""); - // billTitle[6] = "支付方式: " + (payType != null ? payType : ""); - // billTitle[7] = "每个月的总笔数" + sum; - // billTitle[8] = "每个月的总金额数" + amountsum; - //} else { - // billTitle[0] = "年卡月卡统计"; - // billTitle[1] = "汇总"; - // billTitle[2] = "停车场: "; - // billTitle[3] = "时间: "; - // billTitle[4] = "类型:"; - // billTitle[5] = "状态: "; - // billTitle[6] = "支付方式: "; - // billTitle[7] = "每个月的总车数"; - // billTitle[8] = "每个月的总金额数"; - //} - - // 1.创建excel信息 - XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); - // 2.设置excel表头和表体 - Layouter.buildReport(workSheet, title,0,0); - // 3.填充数据 - List contentList = new ArrayList(); - List list = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(bizResult.getData().getDataList())) { - list = bizResult.getData().getDataList(); - } - for (YearMonthCardStatisticDTO e : list) { - Object[] obj = new Object[title.length]; - int index = 0; - obj[index++] = e.getPayFinishTime() != null ? format.format(e.getPayFinishTime()) : ""; - obj[index++] = e.getParkName(); - String cardType=""; - if (null != e.getOrderType()) { - if (2 == e.getOrderType()) { - cardType = "年卡"; - }else{ - cardType = "月卡"; - } - } - obj[index++]=cardType; - obj[index++] = e.getCarNumber(); - if (e.getPayType() != null) { - switch (e.getPayType()) { - case 1: - obj[index++] = "支付宝"; - break; - case 2: - obj[index++] = "微信"; - break; - case 3: - obj[index++] = "银联"; - break; - case 4: - obj[index++] = "微信"; - break; - default: - obj[index++] = "现金"; - break; - } - } else { - obj[index++] = ""; - } - obj[index++] = e.getAmount() != null ? e.getAmount() : "0.00"; - obj[index++] = e.getEffDate() != null ? format.format(e.getEffDate()) - : "" + "-" + e.getExpDate() != null ? format.format(e.getExpDate()) : ""; - //有效、无效 - Date d = new Date(); - String state = ""; - if ((d.getTime() <= e.getExpDate().getTime()) && (d.getTime() >= e.getEffDate().getTime())) { - state = "有效"; - } else { - state = "无效"; - } - obj[index++] = state; - contentList.add(obj); - } - ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); - fillUserManager.fillSalesOrga(workSheet, title, contentList, 2); - // 4.excel输出配置 - ExcelUtil.write(response, workSheet, fileName); - } - -} diff --git a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/parklotmanage/ParkLotManageController.java b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/parklotmanage/ParkLotManageController.java deleted file mode 100644 index da98071..0000000 --- a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/parklotmanage/ParkLotManageController.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.zteits.irain.portal.web.parkinglotcloudplatform.parklotmanage; - -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpSession; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.alibaba.dubbo.common.utils.CollectionUtils; -import com.clouds.common.cache.park.ParkingLotCacheUtil; -import com.clouds.common.entity.UserInfo; -import com.clouds.common.utils.ResultUtils; -import com.clouds.common.web.SessionCommUtil; -import com.clouds.common.web.vo.BizResultVO; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.zteits.clouds.api.apibase.bean.BizResult; -import com.zteits.clouds.api.apibase.constants.ErrorType; -import com.zteits.clouds.api.apibase.exception.BizException; -import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; -import com.zteits.clouds.api.dto.park.param.QueryParkLotInfoByPkNoRequest; -import com.zteits.clouds.api.dto.pay.param.TdCompanyParkQueryRequest; -import com.zteits.clouds.api.service.park.ParkingLotQueryService; -import com.zteits.clouds.api.service.pay.TdCustCompanyService; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; - -/** - * 停车场管理 - * - * Copyright: Copyright (c) 2017 zteits - * - * @ClassName: ParkingLotController.java - * @Description: - * @version: v1.0.0 - * @author: zhaowg - * @date: 2017年6月16日 下午5:27:21 - * Modification History: - * Date Author Version Description - *---------------------------------------------------------* - * 2017年6月16日 zhaowg v1.0.0 创建 - */ -@Api(value="停车场管理",description="停车场管理") -@RestController -@RequestMapping("parkLotManage") -public class ParkLotManageController{ - private Logger logger = LoggerFactory.getLogger(ParkLotManageController.class); - @Autowired - private HttpSession session; - @Autowired - private SessionCommUtil sessionCommUtil; - @Autowired - private TdCustCompanyService tdCustCompanyService; - @Autowired - private ParkingLotQueryService parkingLotQueryService; - /** - * 根据登录人权限获取停车场名称列表 - * @return - * 2017年6月16日 zhaowg - * @throws Exception - */ - @ApiOperation("根据登录人权限获取停车场名称列表") - @GetMapping("getParkLotNamesByUserId") - public BizResultVO>> GetParkLotNameListByUserId(@RequestParam String sysCode) throws Exception { - List> result = Lists.newArrayList(); - //拥有的停车场编号 - List plNos = this.GetParkLotNosByCurrUser(sysCode); - //查询对应的停车场信息 - if(CollectionUtils.isEmpty(plNos)){ - return new BizResultVO>>().setData(result); - } - for (String plNo : plNos) { - Map plNoMap = Maps.newHashMap(); - //先查询缓存 - ParkingLotDTO lotDTO = ParkingLotCacheUtil.getParkLotByPlNo(plNo); - if(lotDTO == null){ - //查询数据库 - QueryParkLotInfoByPkNoRequest request = new QueryParkLotInfoByPkNoRequest(); - request.setSysCode(sysCode); - request.setPklNo(plNo); - BizResult bizResult2 = parkingLotQueryService.QueryParkingLotByPkNo(request); - lotDTO = ResultUtils.getBizResultData(bizResult2); - } - if(lotDTO == null || StringUtils.isBlank(lotDTO.getPlName()) || lotDTO.getPlName().equals("null")){ - continue; - } - plNoMap.put("code",plNo ); - plNoMap.put("name",lotDTO.getPlName()); - result.add(plNoMap); - } - - return new BizResultVO>>().setData(result); - } - - private List GetParkLotNosByCurrUser(String sysCode) throws Exception { - logger.info("根据登录人权限获取停车场列表"); - List plNos = Lists.newArrayList(); - //2.调用接口查询当前登录人管辖的停车场名称 - UserInfo userInfo = sessionCommUtil.getUserInfo(); - if(userInfo!=null){ - TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest(); - tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds()); - tdCompanyParkQueryRequest.setSysCode(sysCode); - tdCompanyParkQueryRequest.setSessionId(session.getId()); - BizResult> bizResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest ); - plNos = ResultUtils.getBizResultData(bizResult); - }else{ - throw new BizException(ErrorType.AUTH_TOKEN_NOT_EXISTS); - } - return plNos; - } -}