diff --git a/src/main/java/com/zteits/irain/portal/vo/parkinglotcloudplatform/datastatistic/ParkLotEqpTypeCountVO.java b/src/main/java/com/zteits/irain/portal/vo/parkinglotcloudplatform/datastatistic/ParkLotEqpTypeCountVO.java new file mode 100644 index 0000000..d690f6f --- /dev/null +++ b/src/main/java/com/zteits/irain/portal/vo/parkinglotcloudplatform/datastatistic/ParkLotEqpTypeCountVO.java @@ -0,0 +1,48 @@ +package com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic; + +/** + * 通过停车场编号统计设备类型数量 + * + * Copyright: Copyright (c) 2017 zteits + * + * @ClassName: ParkLotEqpTypeCountVO.java + * @Description: + * @version: v1.0.0 + * @author: wangfei + * @date: 2017年8月18日 下午2:31:24 + * Modification History: + * Date Author Version Description + *---------------------------------------------------------* + * 2017年6月29日 wangfei v1.0.0 创建 + */ +public class ParkLotEqpTypeCountVO { + + + /**设备类型:1-地磁*/ + private Integer eqpType; + /**设备状态:1-未安装,2-使用中,3-损坏*/ + private Integer eqpState; + /**个数*/ + private Integer eqpNum; + + public Integer getEqpState() { + return eqpState; + } + public void setEqpState(Integer eqpState) { + this.eqpState = eqpState; + } + + public Integer getEqpType() { + return eqpType; + } + public void setEqpType(Integer eqpType) { + this.eqpType = eqpType; + } + public Integer getEqpNum() { + return eqpNum; + } + public void setEqpNum(Integer eqpNum) { + this.eqpNum = eqpNum; + } + +} diff --git a/src/main/java/com/zteits/irain/portal/vo/parkinglotcloudplatform/datastatistic/ParkStaticsticAndTodayAmountVO.java b/src/main/java/com/zteits/irain/portal/vo/parkinglotcloudplatform/datastatistic/ParkStaticsticAndTodayAmountVO.java new file mode 100644 index 0000000..f0582f6 --- /dev/null +++ b/src/main/java/com/zteits/irain/portal/vo/parkinglotcloudplatform/datastatistic/ParkStaticsticAndTodayAmountVO.java @@ -0,0 +1,66 @@ +package com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic; + +import java.math.BigDecimal; + +/** + * 企业云平台->车位使用统计、 + * 停车场基本信息和今日收入统计信息 + * + * Copyright: Copyright (c) 2017 zteits + * + * @ClassName: ParkStaticsticAndTodayAmountVO.java + * @Description: + * @version: v1.0.0 + * @author: langlw + * @date: 2017年8月18日 下午5:50:43 + * Modification History: + * Date Author Version Description + *---------------------------------------------------------* + * 2017年8月18日 langlw v1.0.0 创建 + */ +public class ParkStaticsticAndTodayAmountVO { + + /** 停车场id. */ + private String parkId; + /** 订单总金额=未支付费用+已支付费用. */ + private BigDecimal orderTotalFee; + /** 停车场名称. */ + private String parkName; + /** 总车位数*/ + private Integer totalBerthsNum; + /** 使用中的车位数*/ + private Integer useingBerthsNum; + + public Integer getTotalBerthsNum() { + return totalBerthsNum; + } + public void setTotalBerthsNum(Integer totalBerthsNum) { + this.totalBerthsNum = totalBerthsNum; + } + public Integer getUseingBerthsNum() { + return useingBerthsNum; + } + public void setUseingBerthsNum(Integer useingBerthsNum) { + this.useingBerthsNum = useingBerthsNum; + } + public String getParkId() { + return parkId; + } + public void setParkId(String parkId) { + this.parkId = parkId; + } + public BigDecimal getOrderTotalFee() { + return orderTotalFee; + } + public void setOrderTotalFee(BigDecimal orderTotalFee) { + this.orderTotalFee = orderTotalFee; + } + public String getParkName() { + return parkName; + } + public void setParkName(String parkName) { + this.parkName = parkName; + } + + +} diff --git a/src/main/java/com/zteits/irain/portal/web/ebochong/receive/EBoChongReceiveController.java b/src/main/java/com/zteits/irain/portal/web/ebochong/receive/EBoChongReceiveController.java index 16c330e..3bf1ef2 100644 --- a/src/main/java/com/zteits/irain/portal/web/ebochong/receive/EBoChongReceiveController.java +++ b/src/main/java/com/zteits/irain/portal/web/ebochong/receive/EBoChongReceiveController.java @@ -2,6 +2,7 @@ package com.zteits.irain.portal.web.ebochong.receive; import java.io.BufferedReader; import java.io.IOException; +import java.math.BigDecimal; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -10,6 +11,7 @@ import com.alibaba.fastjson.JSONObject; import com.clouds.common.utils.EBoChongAESUtil; import com.clouds.common.utils.ResultUtils; +import com.xiaoleilu.hutool.date.DateUnit; import com.xiaoleilu.hutool.date.DateUtil; import com.zteits.clouds.api.apibase.bean.BaseInfo; import com.zteits.clouds.api.apibase.bean.BizResult; @@ -23,6 +25,7 @@ import com.zteits.clouds.api.service.park.IInOutParkingService; import com.zteits.clouds.api.service.park.InterfaceLogService; import com.zteits.clouds.api.service.park.ParkFreeBerthService; import com.zteits.clouds.api.service.park.ParkingLotQueryService; +import com.zteits.clouds.api.service.pay.ParkOrderService; import com.zteits.irain.portal.constant.ParkConstant.InterfaceLog; import com.zteits.irain.portal.constant.ParkConstant.InterfaceLog.Type; import com.zteits.irain.portal.vo.ebochong.EBoChongEnum; @@ -79,6 +82,12 @@ public class EBoChongReceiveController { @Autowired private InterfaceLogService interfaceLogService; + /** + * 停车场订单service + */ + @Autowired + private ParkOrderService parkOrderService; + @Value("${ebochong.key}") private String key; @@ -145,6 +154,18 @@ public class EBoChongReceiveController { logger.info("===调用dubbo服务停车记录保存 dubboReq={}", JSONObject.toJSONString(inParkingRequest)); BizResult bizResult = iInOutParkingService.SaveIRainInParking(inParkingRequest); logger.info("===调用dubbo服务停车记录保存 dubboRes={}", JSONObject.toJSONString(bizResult)); + + try { + logger.info("插入停车订单--begin----"); + inParkingRequest.setSourceType(3); + inParkingRequest.setFromType(2); + BizResult orderResult = parkOrderService.insertParkingOrder(inParkingRequest); + logger.info("插入停车订单--end----结果=[errorMsg={},orderId={}]", orderResult.getErrMsg(), + orderResult.getData()); + } catch (Exception e) { + logger.info("插入停车订单捕获异常:", e); + } + } else { logSaveRequest.setType(Type.TYPE_OUT_PARKING); //出场 @@ -154,6 +175,7 @@ public class EBoChongReceiveController { outParkingRequest.setFreeBerths(req.getRemaining()); outParkingRequest.setFromType(4); outParkingRequest.setInTime(DateUtil.parse(req.getInTime())); + outParkingRequest.setOutTime(DateUtil.parse(req.getPassTime())); outParkingRequest.setParkCode(req.getParkIndex()); outParkingRequest.setRecordId(req.getUuid()); outParkingRequest.setPlNo(req.getParkIndex()); @@ -162,6 +184,23 @@ public class EBoChongReceiveController { logger.info("===调用dubbo服务停车记录保存 dubboReq={}", JSONObject.toJSONString(outParkingRequest)); BizResult bizResult = iInOutParkingService.SaveIRainOutParking(outParkingRequest); logger.info("===调用dubbo服务停车记录保存 dubboRes={}", JSONObject.toJSONString(bizResult)); + + try { + logger.info("更新停车订单--begin----"); + outParkingRequest.setSourceType(3); + outParkingRequest.setFromType(2); + outParkingRequest.setPayType("1"); + outParkingRequest.setCalcCharge(new BigDecimal(req.getReceivable())); + outParkingRequest.setTotalCharge(new BigDecimal(req.getReceivable())); + outParkingRequest.setParkingDuration( + DateUtil.between(outParkingRequest.getInTime(), outParkingRequest.getOutTime(), + DateUnit.SECOND)); + BizResult orderResult = parkOrderService.updateParkingOrder(outParkingRequest); + logger.info("更新停车订单--end----结果=[errorMsg={},orderId={}]", orderResult.getErrMsg(), + orderResult.getData()); + } catch (Exception e) { + logger.info("更新停车订单捕获异常:", e); + } } HandledVehicleInfoRes res = new HandledVehicleInfoRes(); diff --git a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/BerthsStatisticController.java b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/BerthsStatisticController.java index 45b30d4..fc8921c 100644 --- a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/BerthsStatisticController.java +++ b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/BerthsStatisticController.java @@ -1,8 +1,6 @@ -/** - * - */ package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; +import java.math.BigDecimal; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -15,6 +13,7 @@ import java.util.Map.Entry; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang3.StringUtils; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,6 +30,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import com.alibaba.dubbo.common.utils.CollectionUtils; import com.alibaba.fastjson.JSON; import com.clouds.common.cache.park.ParkingLotCacheUtil; +import com.clouds.common.entity.UserInfo; import com.clouds.common.redis.RedisCacheUtil; import com.clouds.common.utils.DateUtil; import com.clouds.common.utils.ResultUtils; @@ -38,6 +38,7 @@ 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; @@ -50,18 +51,38 @@ import com.zteits.clouds.api.apibase.exception.BizException; import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; 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.ParkFreeBerthGetByPlnoRequest; import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest; +import com.zteits.clouds.api.dto.park.param.QueryParkLotInfoByPkNoRequest; +import com.zteits.clouds.api.dto.pay.TdBOrderDTO; +import com.zteits.clouds.api.dto.pay.param.QueryTodayOrderRequest; +import com.zteits.clouds.api.service.park.ParkFreeBerthService; +import com.zteits.clouds.api.service.park.ParkingLotQueryService; import com.zteits.clouds.api.service.park.ParkingLotUseStatisticService; +import com.zteits.clouds.api.service.pay.TdBOrderService; import com.zteits.irain.portal.constant.ParkConstant; +import com.zteits.irain.portal.vo.govclouds.ParkLotStatisticVO; import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO; import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO.SerieVO; +import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.ParkStaticsticAndTodayAmountVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; /** - * @author hxz - * + * + * + * Copyright: Copyright (c) 2017 zteits + * + * @ClassName: BerthsStatisticController.java + * @Description: + * @version: v1.0.0 + * @author: langlw + * @date: 2017年8月18日 下午5:45:21 + * Modification History: + * Date Author Version Description + *---------------------------------------------------------* + * 2017年8月18日 langlw v1.0.0 创建 */ @Api("停车场云平台 数据统计 车位使用管理") @Controller @@ -72,6 +93,15 @@ public class BerthsStatisticController extends BizController { private String sysCode; @Autowired private ParkingLotUseStatisticService parkingLotStatisticService; + @Autowired + private SessionCommUtil sessionCommUtil; + @Autowired + private TdBOrderService tdBOrderService; + @Autowired + private ParkFreeBerthService parkFreeBerthService; + @Autowired + private ParkingLotQueryService parkingLotQueryService; + /** * @@ -113,10 +143,10 @@ public class BerthsStatisticController extends BizController { public BizResultVO> GetParkingPlaceStatistic( @RequestBody ParkingLotUseStatisticForPageRequest requestObject) throws InstantiationException, IllegalAccessException { - if (null == requestObject.getBeginTime() || null==requestObject.getEndTime()) { - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); - } - + if (null == requestObject.getBeginTime() || null == requestObject.getEndTime()) { + throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); + } + Calendar beginc = Calendar.getInstance(); beginc.setTime(requestObject.getBeginTime()); int beginYear = beginc.get(Calendar.YEAR); @@ -153,7 +183,7 @@ public class BerthsStatisticController extends BizController { 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); @@ -194,7 +224,7 @@ public class BerthsStatisticController extends BizController { Object[] obj = new Object[title.length]; int index = 0; obj[index++] = format.format(e.getStatisticBeginTime()); - obj[index++] = e.getFreeRatio() *100 +"%"; + obj[index++] = e.getFreeRatio() * 100 + "%"; obj[index++] = e.getTurnoverRatio(); contentList.add(obj); } @@ -215,13 +245,14 @@ public class BerthsStatisticController extends BizController { @ResponseBody public BizResultVO getFreeRatioBerthForLineChart( @RequestBody ParkingLotUseStatisticForPageRequest request) { - //根据权限获取停车场列表 - if (null == request.getBeginTime() || null==request.getEndTime()) { - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); - } + // 根据权限获取停车场列表 + if (null == request.getBeginTime() || null == request.getEndTime()) { + throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); + } logger.info("根据停车场编号获取该停车场车位空置率折线图"); Calendar beginTime = Calendar.getInstance(); beginTime.setTime(request.getBeginTime()); +// int year = beginTime.get(Calendar.YEAR); Calendar endTime = Calendar.getInstance(); endTime.setTime(request.getEndTime()); @@ -229,58 +260,62 @@ public class BerthsStatisticController extends BizController { Long dayDifference = DateUtil.getTimeDifference(new Timestamp(request.getEndTime().getTime()), new Timestamp(request.getBeginTime().getTime())); List xAxisData = Lists.newArrayList(); - String dateType=""; - int berthRatio=ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE; + String dateType = ""; + int berthRatio = ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE; + request.setBaseRequest(new BaseInfo(1, 0)); if (dayDifference == 0L) { // 1个小时为一个时间戳 request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY); - for (int i = 0; i <= totaltimestampCount; i++) { - String hour = String.format("%02d", i); - xAxisData.add(hour + ":" + "00"); - } - request.setBaseRequest(new BaseInfo(1, 0)); - dateType="HH:mm"; - LineChartVO freeBerthRatios=getFreeBerthRatios(request, xAxisData, dateType,berthRatio); - return new BizResultVO().setData(freeBerthRatios); - } 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); - } + for (int j = 0; j <= totaltimestampCount+1; j++) { + String hour = String.format("%02d", (j)); + xAxisData.add(hour+":00"); } - request.setBaseRequest(new BaseInfo(1, 0)); - dateType="MM-dd HH"; - LineChartVO freeBerthRatios=getFreeBerthRatios(request, xAxisData, dateType,berthRatio); + dateType = "HH:mm"; + LineChartVO freeBerthRatios = getFreeBerthRatios(request, xAxisData, dateType, berthRatio); return new BizResultVO().setData(freeBerthRatios); - } else { + } +// 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++) { +// Calendar tempDate = Calendar.getInstance(); +// tempDate.setTime(request.getBeginTime()); +// tempDate.add(Calendar.DAY_OF_MONTH, i); +// int beginMonth = tempDate.get(Calendar.MONTH) + 1; +// int beginDay = tempDate.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(year + "-" + month + "-" + day + " " + hour); +// } +// } +// dateType = "yyyy-MM-dd HH"; +// LineChartVO freeBerthRatios = getFreeBerthRatios(request, xAxisData, dateType, berthRatio); +// return new BizResultVO().setData(freeBerthRatios); +// } + 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); + for (int i = 0; i <= dayDifference.intValue(); i++) { + Calendar tempDate = Calendar.getInstance(); + tempDate.setTime(request.getBeginTime()); + tempDate.add(Calendar.DAY_OF_MONTH, i); + int beginMonth = tempDate.get(Calendar.MONTH) + 1; + int beginDay = tempDate.get(Calendar.DAY_OF_MONTH); String month = String.format("%02d", (beginMonth)); String day = String.format("%02d", (beginDay)); xAxisData.add(month + "-" + day); } - } - request.setBaseRequest(new BaseInfo(1, 0)); - dateType="MM-dd"; - LineChartVO freeBerthRatios=getFreeBerthRatios(request, xAxisData, dateType,berthRatio); - return new BizResultVO().setData(freeBerthRatios); + dateType = "MM-dd"; + LineChartVO freeBerthRatios = getFreeBerthRatios(request, xAxisData, dateType, berthRatio); + return new BizResultVO().setData(freeBerthRatios); + } } /** @@ -296,10 +331,11 @@ public class BerthsStatisticController extends BizController { @RequestBody ParkingLotUseStatisticForPageRequest request) { logger.info("根据停车场编号获取该停车场车位周转率折线图"); - if (null == request.getBeginTime() || null==request.getEndTime()) { - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); - } + if (null == request.getBeginTime() || null == request.getEndTime()) { + throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); + } Calendar beginTime = Calendar.getInstance(); +// int year = beginTime.get(Calendar.YEAR); beginTime.setTime(request.getBeginTime()); Calendar endTime = Calendar.getInstance(); @@ -308,64 +344,43 @@ public class BerthsStatisticController extends BizController { Long dayDifference = DateUtil.getTimeDifference(new Timestamp(request.getEndTime().getTime()), new Timestamp(request.getBeginTime().getTime())); List xAxisData = Lists.newArrayList(); - String dateType=""; - int berthRatio=ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER; + String dateType = ""; + request.setBaseRequest(new BaseInfo(1, 0)); + int berthRatio = ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER; if (dayDifference == 0L) { - //1个小时为一个时间戳 + // 1个小时为一个时间戳 request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY); - for (int j = 0; j <= totaltimestampCount; j++) { + for (int j = 0; j <= totaltimestampCount+1; j++) { String hour = String.format("%02d", (j)); - xAxisData.add(hour + ":" + "00"); - } - - request.setBaseRequest(new BaseInfo(1, 0)); - dateType="HH:mm"; - LineChartVO freeBerthRatios=getFreeBerthRatios(request, xAxisData, dateType,berthRatio); - return new BizResultVO().setData(freeBerthRatios); - } 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); - } + xAxisData.add(hour+":00"); } - request.setBaseRequest(new BaseInfo(1, 0)); - dateType="MM-dd HH"; - LineChartVO freeBerthRatios=getFreeBerthRatios(request, xAxisData, dateType,berthRatio); + dateType = "HH:mm"; + LineChartVO freeBerthRatios = getFreeBerthRatios(request, xAxisData, dateType, berthRatio); return new BizResultVO().setData(freeBerthRatios); - } else { + }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); + for (int i = 0; i <= dayDifference.intValue(); i++) { + Calendar tempDate = Calendar.getInstance(); + tempDate.setTime(request.getBeginTime()); + tempDate.add(Calendar.DAY_OF_MONTH, i); + int beginMonth = tempDate.get(Calendar.MONTH) + 1; + int beginDay = tempDate.get(Calendar.DAY_OF_MONTH); String month = String.format("%02d", (beginMonth)); String day = String.format("%02d", (beginDay)); xAxisData.add(month + "-" + day); + } - request.setBaseRequest(new BaseInfo(1, 0)); - dateType="MM-dd"; - LineChartVO freeBerthRatios=getFreeBerthRatios(request, xAxisData, dateType,berthRatio); + dateType = "MM-dd"; + LineChartVO freeBerthRatios = getFreeBerthRatios(request, xAxisData, dateType, berthRatio); return new BizResultVO().setData(freeBerthRatios); } } - - - private LineChartVO getFreeBerthRatios(ParkingLotUseStatisticForPageRequest request, - List xAxisData,String dateType ,int berthRatio){ + + private LineChartVO getFreeBerthRatios(ParkingLotUseStatisticForPageRequest request, List xAxisData, + String dateType, int berthRatio) { logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request)); BizResult> bizResult = parkingLotStatisticService .queryParkingLotUseStatisticForPage(request); @@ -387,33 +402,33 @@ public class BerthsStatisticController extends BizController { // 保存空置率 if (!parkLotMap.containsKey(key)) { Map timeAndVal = Maps.newHashMap(); - if(ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE == berthRatio){ + if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE == berthRatio) { timeAndVal.put(statisBeginTime, statisticDTO.getFreeRatio() * 100); parkLotMap.put(key, timeAndVal); - }else if(ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER == berthRatio){ + } else if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER == berthRatio) { timeAndVal.put(statisBeginTime, statisticDTO.getTurnoverRatio() * 100); parkLotMap.put(key, timeAndVal); } } else { - if(ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE == berthRatio){ + if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE == berthRatio) { parkLotMap.get(key).put(statisBeginTime, statisticDTO.getFreeRatio() * 100); - }else if(ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER == berthRatio){ + } else if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER == berthRatio) { parkLotMap.get(key).put(statisBeginTime, statisticDTO.getTurnoverRatio() * 100); } } } } - //判断是否包含所有待查询的停车场信息 - if(request.getPlNos().size()>parkLotMap.size()){ - for (String plNo:request.getPlNos()) { - if(!parkLotMap.containsKey(plNo)){ - ParkingLotDTO parkingLotDTO=ParkingLotCacheUtil.getParkLotByPlNo(plNo); - parkNameMap.put(plNo, parkingLotDTO.getPlName()); - parkLotMap.put(plNo, Maps.newHashMap()); - } - } - } + // 判断是否包含所有待查询的停车场信息 + if (request.getPlNos().size() > parkLotMap.size()) { + for (String plNo : request.getPlNos()) { + if (!parkLotMap.containsKey(plNo)) { + ParkingLotDTO parkingLotDTO = ParkingLotCacheUtil.getParkLotByPlNo(plNo); + parkNameMap.put(plNo, parkingLotDTO.getPlName()); + parkLotMap.put(plNo, Maps.newHashMap()); + } + } + } // 封装车位统计信息 LineChartVO freeBerthRatios = new LineChartVO(); @@ -437,7 +452,7 @@ public class BerthsStatisticController extends BizController { for (String timestamp : xAxisData) { if (freeRatioMaps.containsKey(timestamp)) { lastFreeRatio = freeRatioMaps.get(timestamp).intValue(); - }else{ + } else { lastFreeRatio = 0; } freeRations.add(lastFreeRatio); @@ -449,5 +464,53 @@ public class BerthsStatisticController extends BizController { freeBerthRatios.setSeries(series); return freeBerthRatios; } + + + + @ApiOperation("获取停车场信息统计和今日收益") + @PostMapping("getParkStaticsticAndTodayAmount") + @ResponseBody + public BizResultVO> getParkStaticsticAndTodayAmount(@RequestBody QueryTodayOrderRequest request) throws Exception{ + if(CollectionUtils.isEmpty(request.getPlNos())){ + throw new BizException(ErrorType.PARAMM_NULL, "入参不能为空!"); + } + + //今日收益 + List listVO= new ArrayList(); + BizResult> result = tdBOrderService.queryTodayAmountSumByPlno(request); + Map mapAmount=ResultUtils.getBizResultData(result); + //空闲车位数 + ParkFreeBerthGetByPlnoRequest parkFreeBerthGetByPlnoRequest = new ParkFreeBerthGetByPlnoRequest(); + parkFreeBerthGetByPlnoRequest.setPlNos(request.getPlNos()); + parkFreeBerthGetByPlnoRequest.setSysCode(request.getSysCode()); + BizResult> freeBerthsNumBizResult = parkFreeBerthService.getParkFreeBerthByPlno(parkFreeBerthGetByPlnoRequest); + Map freeBerthsNumMap = ResultUtils.getBizResultData(freeBerthsNumBizResult); + for (String plNo : request.getPlNos()) { + //先查询缓存 + ParkingLotDTO lotDTO = ParkingLotCacheUtil.getParkLotByPlNo(plNo); + if(lotDTO == null){ + //查询数据库 + QueryParkLotInfoByPkNoRequest request1 = new QueryParkLotInfoByPkNoRequest(); + request1.setSysCode(request.getSysCode()); + request1.setPklNo(plNo); + BizResult bizResult2 = parkingLotQueryService.QueryParkingLotByPkNo(request1); + lotDTO = ResultUtils.getBizResultData(bizResult2); + } + if(lotDTO == null || StringUtils.isBlank(lotDTO.getPlName()) || lotDTO.getPlName().equals("null")){ + continue; + } + ParkStaticsticAndTodayAmountVO VO=new ParkStaticsticAndTodayAmountVO(); + VO.setParkId(plNo); + VO.setParkName(lotDTO.getPlName()); + VO.setTotalBerthsNum(lotDTO.getPlBerthNum()); + VO.setUseingBerthsNum(lotDTO.getPlBerthNum()-freeBerthsNumMap.get(plNo)); + VO.setOrderTotalFee(mapAmount.get(plNo)); + listVO.add(VO); + } + return new BizResultVO>().setData(listVO); + } + + + } diff --git a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/InOutParkStatisticController.java b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/InOutParkStatisticController.java index 9fcf01c..9535615 100644 --- a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/InOutParkStatisticController.java +++ b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/InOutParkStatisticController.java @@ -10,14 +10,12 @@ import java.util.Map; 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.security.config.authentication.UserServiceBeanDefinitionParser; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -25,20 +23,15 @@ 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; import com.alibaba.dubbo.common.utils.CollectionUtils; -import com.alibaba.dubbo.common.utils.StringUtils; import com.alibaba.fastjson.JSON; -import com.clouds.common.entity.UserInfo; -import com.clouds.common.utils.AmountUtils; 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; @@ -48,16 +41,13 @@ 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.BillManageDTO; import com.zteits.clouds.api.dto.park.dto.InOutParkDTO; import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO; import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticSumDTO; import com.zteits.clouds.api.dto.park.param.InOutParkRequest; import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest; -import com.zteits.clouds.api.dto.pay.param.TdCompanyParkQueryRequest; import com.zteits.clouds.api.service.clouds.InOutParkStatisticService; 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.LineChartVO; import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO.SerieVO; @@ -68,17 +58,15 @@ import io.swagger.annotations.ApiOperation; /** * 企业云平台->数据统计->进出场上报。 * - * Copyright: Copyright (c) 2017 zteits + * Copyright: Copyright (c) 2017 zteits * * @ClassName: InOutParkStatisticController.java - * @Description: + * @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 创建 + * @date: 2017年7月26日 上午11:30:04 Modification History: Date Author Version + * Description ---------------------------------------------------------* + * 2017年7月26日 langlw v1.0.0 创建 */ @Api(value = "企业云平台->数据统计->进出场上报数据统计", description = "企业云平台->数据统计->进出场上报数据统计") @Controller @@ -92,31 +80,29 @@ public class InOutParkStatisticController extends BizController { private ParkingLotUseStatisticService parkingLotStatisticService; @Autowired private InOutParkStatisticService inOutParkStatisticService; - - + @ApiOperation("数据统计进出场上报") @PostMapping("queryInOutParkForList") @ResponseBody - public BizResultVO> queryInOutParkForList( - @RequestBody InOutParkRequest request) throws Exception { + public BizResultVO> queryInOutParkForList(@RequestBody InOutParkRequest request) + throws Exception { logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request)); - if (null == request.getBeginTime() || null==request.getEndTime()) { - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); - } + if (null == request.getBeginTime() || null == request.getEndTime()) { + throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); + } BizResult> bizResult = inOutParkStatisticService.queryInOutParkForList(request); return returnJqGridData(bizResult, InOutParkDTO.class); } - + @ApiOperation("数据统计进出场上报折线图") @PostMapping("queryInOutParkForChart") @ResponseBody - public BizResultVO queryInOutParkForChart( - @RequestBody InOutParkRequest request) throws Exception { - if (null == request.getBeginTime() || null==request.getEndTime() || null == request.getPlNos()) { - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间、停车场编号集合"); - } - - ParkingLotUseStatisticForPageRequest UseStatisticRequest=new ParkingLotUseStatisticForPageRequest(); + public BizResultVO queryInOutParkForChart(@RequestBody InOutParkRequest request) throws Exception { + if (null == request.getBeginTime() || null == request.getEndTime() || null == request.getPlNos()) { + throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间、停车场编号集合"); + } + + ParkingLotUseStatisticForPageRequest UseStatisticRequest = new ParkingLotUseStatisticForPageRequest(); UseStatisticRequest.setPlNos(request.getPlNos()); UseStatisticRequest.setBeginTime(request.getBeginTime()); UseStatisticRequest.setEndTime(request.getEndTime()); @@ -125,6 +111,7 @@ public class InOutParkStatisticController extends BizController { Calendar beginTime = Calendar.getInstance(); beginTime.setTime(request.getBeginTime()); + // int year = beginTime.get(Calendar.YEAR); Calendar endTime = Calendar.getInstance(); endTime.setTime(request.getEndTime()); @@ -132,78 +119,99 @@ public class InOutParkStatisticController extends BizController { Long dayDifference = DateUtil.getTimeDifference(new Timestamp(request.getEndTime().getTime()), new Timestamp(request.getBeginTime().getTime())); List xAxisData = Lists.newArrayList(); - String dateType=""; - - if (dayDifference == 0L) { - //同一天 - // 20分钟为一个时间戳 - UseStatisticRequest.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER20MINUTE); - int totaltimestampCount = (endTime.get(Calendar.HOUR_OF_DAY)-beginTime.get(Calendar.HOUR_OF_DAY))*3; - for (int i = 0; i < totaltimestampCount; i++) { - int hour1 = beginTime.get(Calendar.HOUR_OF_DAY)+i/3; - String hour = String.format("%02d", hour1); - String minute = String.format("%02d", (i % 3) * 20); - xAxisData.add(hour + ":" + minute); - } - dateType="HH:mm"; - LineChartVO vehicleFlows=getVehicleFlows(UseStatisticRequest, xAxisData, dateType); - return new BizResultVO().setData(vehicleFlows); + String dateType = ""; - } else if (dayDifference <= 3L) { - // 1小时为一个时间戳 + if (dayDifference == 0L) { + // 同一天 + // 1个小时为一个时间戳 UseStatisticRequest.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++) { - 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)); - int endDay = endTime.get(Calendar.DAY_OF_MONTH); - if(beginDay != endDay){ - totaltimestampCount = 24; - } - for (int j = 0; j < totaltimestampCount; j++) { - String hour = String.format("%02d", (j)); - xAxisData.add(month + "-" + day + " " + hour); - } - beginTime.add(Calendar.DAY_OF_MONTH, 1); + for (int j = 0; j <= totaltimestampCount+1; j++) { + String hour = String.format("%02d", (j)); + xAxisData.add(hour + ":00"); } - dateType="MM-dd HH"; - LineChartVO vehicleFlows=getVehicleFlows(UseStatisticRequest, xAxisData, dateType); + dateType = "HH:mm"; + LineChartVO vehicleFlows = getVehicleFlows(UseStatisticRequest, xAxisData, dateType); return new BizResultVO().setData(vehicleFlows); - } else { + } + // else if (dayDifference <= 3L) { + // // 1小时为一个时间戳 + // UseStatisticRequest.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++) { + // Calendar tempDate = Calendar.getInstance(); + // tempDate .setTime(request.getBeginTime()); + // tempDate.add(Calendar.DAY_OF_MONTH, i); + // int beginMonth = tempDate.get(Calendar.MONTH) + 1; + // int beginDay = tempDate.get(Calendar.DAY_OF_MONTH); + // month = String.format("%02d", (beginMonth)); + // day = String.format("%02d", (beginDay)); + // for (int j = 0; j < 24; j++) { + // String hour = String.format("%02d", (j)); + // xAxisData.add(year + "-" + month + "-" + day + " " + hour); + // } + // } + // dateType = "yyyy-MM-dd HH"; + // + // + //// + //// int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY); + //// String day = ""; + //// String month = ""; + //// for (int i = 0; i < dayDifference.intValue(); i++) { + //// 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)); + //// int endDay = endTime.get(Calendar.DAY_OF_MONTH); + //// if(beginDay != endDay){ + //// totaltimestampCount = 24; + //// } + //// for (int j = 0; j < totaltimestampCount; j++) { + //// String hour = String.format("%02d", (j)); + //// xAxisData.add(month + "-" + day + " " + hour); + //// } + //// beginTime.add(Calendar.DAY_OF_MONTH, 1); + //// } + //// dateType="MM-dd HH"; + // LineChartVO vehicleFlows=getVehicleFlows(UseStatisticRequest, + // xAxisData, dateType); + // return new BizResultVO().setData(vehicleFlows); + // + // } + else { // 1天为一个时间戳 UseStatisticRequest.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); - for (int i = 0; i < dayDifference.intValue()+1; i++) { - int beginMonth = beginTime.get(Calendar.MONTH) + 1; - int beginDay = beginTime.get(Calendar.DAY_OF_MONTH); + for (int i = 0; i <= dayDifference.intValue(); i++) { + Calendar tempDate = Calendar.getInstance(); + tempDate.setTime(request.getBeginTime()); + tempDate.add(Calendar.DAY_OF_MONTH, i); + int beginMonth = tempDate.get(Calendar.MONTH) + 1; + int beginDay = tempDate.get(Calendar.DAY_OF_MONTH); String month = String.format("%02d", (beginMonth)); String day = String.format("%02d", (beginDay)); xAxisData.add(month + "-" + day); - beginTime.add(Calendar.DAY_OF_MONTH, 1); - } - dateType="MM-dd"; - LineChartVO vehicleFlows=getVehicleFlows(UseStatisticRequest, xAxisData, dateType); + dateType = "MM-dd"; + LineChartVO vehicleFlows = getVehicleFlows(UseStatisticRequest, xAxisData, dateType); return new BizResultVO().setData(vehicleFlows); } } - /** * 进出场折线图 + * * @param request * @param xAxisData * @param dateType - * @return - * 2017年7月28日 zhaowg + * @return 2017年7月28日 zhaowg */ - private LineChartVO getVehicleFlows(ParkingLotUseStatisticForPageRequest request, - List xAxisData,String dateType){ + private LineChartVO getVehicleFlows(ParkingLotUseStatisticForPageRequest request, List xAxisData, + String dateType) { // 调用后场服务 logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request)); BizResult> bizResult = parkingLotStatisticService @@ -225,9 +233,13 @@ public class InOutParkStatisticController extends BizController { String key = statisticDTO.getPlNo(); parkNameMap.put(key, statisticDTO.getPlName()); String statisBeginTime = DateUtil.getDateString(statisticDTO.getStatisticBeginTime(), dateType); - //保存进场车流量和出场车流量 - inParkMap.put(statisBeginTime, (inParkMap.get(statisBeginTime)==null?0:inParkMap.get(statisBeginTime))+statisticDTO.getTmpVehicleFlow()); - outParkMap.put(statisBeginTime, (outParkMap.get(statisBeginTime)==null?0:outParkMap.get(statisBeginTime))+statisticDTO.getOutParkCount()); + // 保存进场车流量和出场车流量 + inParkMap.put(statisBeginTime, + (inParkMap.get(statisBeginTime) == null ? 0 : inParkMap.get(statisBeginTime)) + + statisticDTO.getTmpVehicleFlow()); + outParkMap.put(statisBeginTime, + (outParkMap.get(statisBeginTime) == null ? 0 : outParkMap.get(statisBeginTime)) + + statisticDTO.getOutParkCount()); } } @@ -254,14 +266,14 @@ public class InOutParkStatisticController extends BizController { if (inParkMap.containsKey(timestamp)) { lastfixFlow = inParkMap.get(timestamp).intValue(); - }else{ - lastfixFlow =0; + } else { + lastfixFlow = 0; } inParkSerieVoData.add(lastfixFlow); if (outParkMap.containsKey(timestamp)) { lasttmpFlow = outParkMap.get(timestamp).intValue(); - }else{ + } else { lasttmpFlow = 0; } outParkSerieVoData.add(lasttmpFlow); @@ -274,14 +286,11 @@ public class InOutParkStatisticController extends BizController { vehicleFlows.setSeries(vehicleSeries); return vehicleFlows; } - - - + @ApiOperation("导出进出场统计excel") @GetMapping("exportInOutParkStatisticExcel") public void exportInOutParkStatisticExcel(@RequestParam String beginTime, @RequestParam String endTime, - @RequestParam List plNos,@RequestParam String parkNames, - Integer inOutStatus,Integer parkType, + @RequestParam List plNos, @RequestParam String parkNames, Integer inOutStatus, Integer parkType, HttpServletRequest requests, HttpServletResponse response) throws Exception { ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest(); request.setSysCode(sysCode); @@ -290,9 +299,10 @@ public class InOutParkStatisticController extends BizController { request.setPlNos(plNos); request.setBaseRequest(new BaseInfo(1, 0)); request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER20MINUTE); - BizResult bizResultSum = parkingLotStatisticService.QueryInOutParkStatisticSum(request); - - InOutParkRequest inOutParkRequest =new InOutParkRequest(); + BizResult bizResultSum = parkingLotStatisticService + .QueryInOutParkStatisticSum(request); + + InOutParkRequest inOutParkRequest = new InOutParkRequest(); inOutParkRequest.setBaseRequest(new BaseInfo(1, 0)); inOutParkRequest.setSysCode(sysCode); inOutParkRequest.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT)); @@ -301,22 +311,20 @@ public class InOutParkStatisticController extends BizController { inOutParkRequest.setInOutStatus(inOutStatus); inOutParkRequest.setParkType(parkType); BizResult> bizResult = inOutParkStatisticService.queryInOutParkForList(inOutParkRequest); - - - + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); - String[] title = new String[] { "停车场", "车牌号", "车辆类型", "进出场状态","进场时间","出场时间","停车时长" }; + String[] title = new String[] { "停车场", "车牌号", "车辆类型", "进出场状态", "进场时间", "出场时间", "停车时长" }; String sheetName = "车辆进出场统计"; String fileName = "车辆进出场统计" + format2.format(new Date()); - + String[] billTitle = new String[8]; if (bizResultSum != null && bizResultSum.getData() != null) { ParkingLotUseStatisticSumDTO dto = bizResultSum.getData(); billTitle[0] = "车辆进出场统计"; billTitle[1] = "汇总"; - billTitle[2] = "停车场: " +parkNames; + billTitle[2] = "停车场: " + parkNames; billTitle[3] = "进场时间: " + beginTime; billTitle[4] = "出场时间:" + endTime; billTitle[5] = "进场车辆总数: " + (dto.getInParkSum() != null ? dto.getInParkSum() : 0); @@ -326,16 +334,13 @@ public class InOutParkStatisticController extends BizController { billTitle[0] = "车辆进出场统计"; billTitle[1] = "汇总"; billTitle[2] = "停车场:"; - billTitle[3] = "进场时间:" ; - billTitle[4] = "出场时间:" ; + billTitle[3] = "进场时间:"; + billTitle[4] = "出场时间:"; billTitle[5] = "进场车辆总数:"; billTitle[6] = "出场车辆总数:"; billTitle[7] = "具体明细"; } - - - - + // 1.创建excel信息 XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); // 2.设置excel表头和表体 @@ -351,29 +356,29 @@ public class InOutParkStatisticController extends BizController { int index = 0; obj[index++] = e.getParkName(); obj[index++] = e.getCarNumber(); - //TODO - if(null!=e.getParkType()){ - if(1==e.getParkType()){ - obj[index++] ="固定停车"; - }else{ - obj[index++] ="临时停车"; + // TODO + if (null != e.getParkType()) { + if (1 == e.getParkType()) { + obj[index++] = "固定停车"; + } else { + obj[index++] = "临时停车"; } - }else{ - obj[index++] ="临时停车"; + } else { + obj[index++] = "临时停车"; } - - if(null !=e.getInOutState()){ - if(1==e.getInOutState() || 2==e.getInOutState() || 3==e.getInOutState()){ - obj[index++] ="在场"; - }else{ - obj[index++] ="出场"; + + if (null != e.getInOutState()) { + if (1 == e.getInOutState() || 2 == e.getInOutState() || 3 == e.getInOutState()) { + obj[index++] = "在场"; + } else { + obj[index++] = "出场"; } - }else{ - obj[index++] ="出场"; + } else { + obj[index++] = "出场"; } obj[index++] = format.format(e.getInTime()); - obj[index++] = e.getOutTime() != null? format.format(e.getOutTime()) : ""; - obj[index++] = e.getParkingDuration() != null? DateUtil.secondToTime(e.getParkingDuration()) : ""; + obj[index++] = e.getOutTime() != null ? format.format(e.getOutTime()) : ""; + obj[index++] = e.getParkingDuration() != null ? DateUtil.secondToTime(e.getParkingDuration()) : ""; contentList.add(obj); } ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); @@ -381,5 +386,5 @@ public class InOutParkStatisticController extends BizController { // 4.excel输出配置 ExcelUtil.write(response, workSheet, fileName); } - + } diff --git a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/IndexPageStatisticController.java b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/IndexPageStatisticController.java index 6a8a867..812d2e2 100644 --- a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/IndexPageStatisticController.java +++ b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/IndexPageStatisticController.java @@ -2,26 +2,21 @@ package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; import java.math.BigDecimal; import java.math.RoundingMode; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import javax.validation.Valid; -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.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - import com.alibaba.dubbo.common.utils.CollectionUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; + import com.clouds.common.cache.park.ParkingLotCacheUtil; import com.clouds.common.utils.DateUtil; import com.clouds.common.utils.ResultUtils; @@ -37,12 +32,19 @@ import com.zteits.clouds.api.dto.clouds.dto.CustIncomeTotalDTO; import com.zteits.clouds.api.dto.clouds.dto.CustIncomeTotalParkDTO; import com.zteits.clouds.api.dto.clouds.dto.ParkingCountDTO; import com.zteits.clouds.api.dto.clouds.param.CustIncomeTotalQueryRequset; +import com.zteits.clouds.api.dto.park.dto.ParkLotEqpTypeCountStatisticByCountryDTO; import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO; +import com.zteits.clouds.api.dto.park.dto.TodayVehicleFlowOccupyRateAndTurnOverDTO; +import com.zteits.clouds.api.dto.park.param.CommonPlnosQueryRequest; +import com.zteits.clouds.api.dto.park.param.EqpTypeQueryByPlNosRequest; import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest; import com.zteits.clouds.api.dto.park.param.RealTimeVehicleFlowQueryRequest; import com.zteits.clouds.api.service.clouds.CustIncomeService; import com.zteits.clouds.api.service.park.IInOutParkingService; +import com.zteits.clouds.api.service.park.ParkingLotBerthsService; +import com.zteits.clouds.api.service.park.ParkingLotEqpService; +import com.zteits.clouds.api.service.park.ParkingLotQueryService; import com.zteits.clouds.api.service.park.ParkingLotUseStatisticService; import com.zteits.irain.portal.constant.ParkConstant; import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.BerthsAndFlowLineChartVO; @@ -51,8 +53,17 @@ import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.CustInco import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.CustIncomeTotalVO; import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO; import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO.SerieVO; - +import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.ParkLotEqpTypeCountVO; import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +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.ResponseBody; +import org.springframework.web.bind.annotation.RestController; /** * Copyright: Copyright (c) 2017 zteits @@ -82,7 +93,15 @@ public class IndexPageStatisticController extends BizController { private IInOutParkingService iInOutParkingService; @Autowired private ParkingLotUseStatisticService parkingLotStatisticService; - + @Autowired + private ParkingLotEqpService parkingLotEqpService; + + @Autowired + private ParkingLotQueryService parkingLotQueryService; + + @Autowired + private ParkingLotBerthsService parkingLotBerthsService; + /** * 云平台首页->企业客户负责所有的停车场汇总.
* @@ -143,8 +162,6 @@ public class IndexPageStatisticController extends BizController { BigDecimal escapeAmount = dto.getEscapeAmount(); BigDecimal payedTotalAmount = dto.getPayedTotalAmount(); - - CustIncomeTotalParkVO vo = new CustIncomeTotalParkVO(); //金额为分 @@ -153,13 +170,14 @@ public class IndexPageStatisticController extends BizController { vo.setPayedTotalAmount(payedTotalAmount.setScale(2, BigDecimal.ROUND_HALF_UP).toString()); //占比乘以100取两位小数 //应收 - if (null == amountDueTotal || amountDueTotal.doubleValue()==0) { + if (null == amountDueTotal || amountDueTotal.doubleValue() == 0) { vo.setLoopData(1, "00.00"); vo.setLoopData(2, "00.00"); } else { //实收 - vo.setLoopData(1, payedTotalAmount.divide(amountDueTotal, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100.00")) + vo.setLoopData(1, payedTotalAmount.divide(amountDueTotal, 4, BigDecimal.ROUND_HALF_UP).multiply( + new BigDecimal("100.00")) .setScale(2, BigDecimal.ROUND_HALF_UP).toString()); //逃逸 vo.setLoopData(2, escapeAmount.divide(amountDueTotal, 4, BigDecimal.ROUND_HALF_UP).multiply( @@ -189,6 +207,16 @@ public class IndexPageStatisticController extends BizController { return new BizResultVO>(result); } + @ApiOperation("查询今日车流量占用率周转率") + @PostMapping("/queryTodayVehicleFlowOccupyRateAndTurnOver") + public BizResultVO> queryTodayVehicleFlowOccupyRateAndTurnOver( + @RequestBody CommonPlnosQueryRequest request) { + BizResult> bizResult = parkingLotStatisticService + .queryTodayVehicleFlowOccupyRateAndTurnOver(request); + return new BizResultVO<>(bizResult); + + } + /** * 根据停车场编号,获取该停车场今日车流量(当天0:00到操作时间的车流量) 折线图 * @@ -196,10 +224,11 @@ public class IndexPageStatisticController extends BizController { * @return 2017年6月19日 zhaowg */ @ApiOperation("根据停车场编号获取该停车场今日车流量和车位折线图") - @PostMapping("getTodayVehicleFlowForLineChart") + @PostMapping("/getTodayVehicleFlowForLineChart") + @Deprecated public BizResultVO getTodayVehicleFlowForLineChart( @RequestBody @Valid ParkingLotUseStatisticForPageRequest request) { - logger.info("根据停车场编号获取该停车场今日车流量和车位折线图"); + logger.info("根据停车场编号获取该停车场今日车流量和车位折线图"); //开始时间 今日0点开始 Calendar beginTime = Calendar.getInstance(); beginTime.set(Calendar.HOUR_OF_DAY, 0); @@ -236,7 +265,7 @@ public class IndexPageStatisticController extends BizController { //每20分钟统计一次 request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER20MINUTE); request.setBaseRequest(new BaseInfo(1, 0)); - logger.info("调用DUBBO服务入参:"+JSON.toJSONString(request)); + logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request)); BizResult> bizResult = parkingLotStatisticService .queryParkingLotUseStatisticForPage(request); PageBean pageBean = ResultUtils.getBizResultData(bizResult); @@ -268,19 +297,21 @@ public class IndexPageStatisticController extends BizController { } //保存固定车流量和临时车流量 - 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()); + 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()); + } + } + //判断是否包含所有待查询的停车场信息 + if (request.getPlNos().size() > parkLotMap.size()) { + for (String plNo : request.getPlNos()) { + if (!parkLotMap.containsKey(plNo)) { + ParkingLotDTO parkingLotDTO = ParkingLotCacheUtil.getParkLotByPlNo(plNo); + parkNameMap.put(plNo, parkingLotDTO.getPlName()); + parkLotMap.put(plNo, Maps.newHashMap()); + } } - } - //判断是否包含所有待查询的停车场信息 - if(request.getPlNos().size()>parkLotMap.size()){ - for (String plNo:request.getPlNos()) { - if(!parkLotMap.containsKey(plNo)){ - ParkingLotDTO parkingLotDTO=ParkingLotCacheUtil.getParkLotByPlNo(plNo); - parkNameMap.put(plNo, parkingLotDTO.getPlName()); - parkLotMap.put(plNo, Maps.newHashMap()); - } - } } //封装车位统计信息 LineChartVO freeBerthRatios = new LineChartVO(); @@ -304,8 +335,8 @@ public class IndexPageStatisticController extends BizController { for (String timestamp : xAxisData) { if (freeRatioMaps.containsKey(timestamp)) { lastFreeRatio = freeRatioMaps.get(timestamp).intValue(); - }else{ - lastFreeRatio = 0; + } else { + lastFreeRatio = 0; } freeRations.add(lastFreeRatio); } @@ -337,15 +368,15 @@ public class IndexPageStatisticController extends BizController { for (String timestamp : xAxisData) { if (fixVehicleFlowMap.containsKey(timestamp)) { lastfixFlow = fixVehicleFlowMap.get(timestamp).intValue(); - }else{ - lastfixFlow = 0; + } else { + lastfixFlow = 0; } fixSerieVoData.add(lastfixFlow); if (tmpVehicleFlowMap.containsKey(timestamp)) { lasttmpFlow = tmpVehicleFlowMap.get(timestamp).intValue(); - }else{ - lasttmpFlow = 0; + } else { + lasttmpFlow = 0; } tmpSerieVoData.add(lasttmpFlow); } @@ -373,6 +404,96 @@ public class IndexPageStatisticController extends BizController { } /** + * 实时统计今日停车次数,停车次数以出场时间进行统计 + * + * @return + */ + @ApiOperation("实时查询当前停车次数") + @PostMapping("/realtimeParkingOutNum") + public BizResultVO realtimeParkingOutNum(@RequestBody CommonPlnosQueryRequest request) { + BizResult bizResult = iInOutParkingService.queryRealTimeOutParkNumOfPlNos(request); + return new BizResultVO<>(bizResult); + } + + /** + * 今日实时周转率 + * + * @param request + * @return + * @desc 今日实时进场次数/总车位数 + */ + @ApiOperation("实时查询当前周转率") + @PostMapping("/realtimeTurnoverRate") + public BizResultVO> realtimeTurnoverRate(@RequestBody CommonPlnosQueryRequest request) { + BizResultVO> res = new BizResultVO<>(); + Map resMap = new HashMap<>(); + //1、查询截止当前进场停车次数 + BizResult bizResult = iInOutParkingService.queryRealTimeInParkNumOfPlNos(request); + if(ResultUtils.isError(bizResult)){ + res.setCode(bizResult.getErrCode().getCode()); + res.setMsg(bizResult.getErrMsg()); + return res; + } + //2、根据停车场编号查询停车场总车位数 + BizResult berthResult = parkingLotQueryService.queryBerthNumByPlNos(request); + if(ResultUtils.isError(berthResult)){ + res.setCode(berthResult.getErrCode().getCode()); + res.setMsg(berthResult.getErrMsg()); + return res; + } + + //停车次数 + resMap.put("parkNum",bizResult.getData()); + //总车位数 + resMap.put("allBerthNum",berthResult.getData()); + double rate = bizResult.getData() * 1.0 / berthResult.getData() * 100; + String rateStr = new DecimalFormat("#.00").format(rate); + resMap.put("rate",rateStr); + res.setData(resMap); + return res; + } + + /** + * 今日实时占用率 + * + * @param request + * @return + * @desc 1-(今日实时空余车位数/总车位数) + */ + @ApiOperation("实时查询当前占用率") + @PostMapping("/realtimeoccupationRate") + public BizResultVO> realtimeoccupationRate(@RequestBody CommonPlnosQueryRequest request) { + BizResultVO> res = new BizResultVO<>(); + Map resMap = new HashMap<>(); + + //1、查询截止当前空余车位数 + BizResult bizResult = parkingLotBerthsService.queryAllFreeBerthNum(request); + if(ResultUtils.isError(bizResult)){ + res.setCode(bizResult.getErrCode().getCode()); + res.setMsg(bizResult.getErrMsg()); + return res; + } + //2、根据停车场编号查询停车场总车位数 + BizResult berthResult = parkingLotQueryService.queryBerthNumByPlNos(request); + if(ResultUtils.isError(berthResult)){ + res.setCode(berthResult.getErrCode().getCode()); + res.setMsg(berthResult.getErrMsg()); + return res; + } + //空余车位数 + resMap.put("freeBerthNum",bizResult.getData()); + //总车位数 + resMap.put("allBerthNum",berthResult.getData()); + + double rate = (1-bizResult.getData() * 1.0 / berthResult.getData()) * 100; + String rateStr = new DecimalFormat("#.00").format(rate); + resMap.put("rate",rateStr); + res.setData(resMap); + return res; + + } + + /** * 实时查询今日空置率
* 今日空置率:当天0:00到操作时间的每个时间戳的空置率做加权算法,
* 0:00-7:00加权10%,7:00-9:00加权40%,9:00-17:00加权15%,17:00-21:00加权25%,21:00-24:00加权10%,加权后的空置率之和除以时间戳数,得到“今日空置率” @@ -402,12 +523,14 @@ public class IndexPageStatisticController extends BizController { } Double totalfreeRatio = 0.00; for (ParkingLotUseStatisticDTO statisticDTO : pageBean.getDataList()) { - totalfreeRatio += this.weightForFreeRation(statisticDTO.getStatisticBeginTime(), - statisticDTO.getFreeRatio(), statisticDTO.getPlNo()); + totalfreeRatio += statisticDTO.getFreeRatio(); + //暂时不加权 + //this.weightForFreeRation(statisticDTO.getStatisticBeginTime(), + //statisticDTO.getFreeRatio(), statisticDTO.getPlNo()); } logger.info("加权后的空置率之和:" + totalfreeRatio + " 时间戳个数:" + pageBean.getDataList().size()); Double avgFreeRation = totalfreeRatio / pageBean.getDataList().size(); - String result = String.format("%.2f", avgFreeRation); + String result = String.format("%.2f", avgFreeRation * 100); return new BizResultVO().setData(result); } @@ -455,4 +578,26 @@ public class IndexPageStatisticController extends BizController { return new BizResultVO>(result); } + /** + * @param request + * @return 2017年8月18日 wangfei + */ + @ApiOperation(value = "根据停车场编号统计设备数量") + @PostMapping("statisticParkLotEqpCountByPlNos") + @ResponseBody + public BizResult> statisticParkLotEqpCountByPlNos(@RequestBody + EqpTypeQueryByPlNosRequest request) { + logger.info("停车场编号:" + request.getPlNos() + " 统计设备数量等信息"); + List resultList = new ArrayList<>(); + BizResult> result = parkingLotEqpService + .StatisticParkLotEqpCountByPlNos(request); + if (!CollectionUtils.isEmpty(result.getData())) { + for (ParkLotEqpTypeCountStatisticByCountryDTO i : result.getData()) { + ParkLotEqpTypeCountVO vo = new ParkLotEqpTypeCountVO(); + BeanUtils.copyProperties(i, vo); + resultList.add(vo); + } + } + return new BizResult<>(resultList); + } } diff --git a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/MonthBillManagementController.java b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/MonthBillManagementController.java index dbb20df..9cb8c58 100644 --- a/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/MonthBillManagementController.java +++ b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/MonthBillManagementController.java @@ -14,13 +14,11 @@ import javax.servlet.http.HttpSession; import com.alibaba.dubbo.common.utils.CollectionUtils; import com.alibaba.dubbo.common.utils.StringUtils; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.clouds.common.entity.UserInfo; import com.clouds.common.utils.AmountUtils; 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; @@ -42,7 +40,6 @@ import com.zteits.clouds.api.dto.clouds.dto.MonthBillSummaryStatisticDTO; import com.zteits.clouds.api.dto.clouds.dto.YearMonthCardStatisticDTO; import com.zteits.clouds.api.dto.clouds.param.BillQueryRequest; import com.zteits.clouds.api.dto.clouds.param.MonthBillRequest; -import com.zteits.clouds.api.dto.pay.param.TdCompanyParkQueryRequest; import com.zteits.clouds.api.dto.pay.param.YearMonthCardStatisticRequest; import com.zteits.clouds.api.service.clouds.MonthBillManagementService; import com.zteits.clouds.api.service.clouds.YearMonthCardStatisticService; @@ -76,11 +73,6 @@ public class MonthBillManagementController extends BizController { private MonthBillManagementService monthBillManagementService; @Autowired private YearMonthCardStatisticService yearMonthCardStatisticService; - - @Autowired - private TdCustCompanyService tdCustCompanyService; - @Autowired - private HttpSession session; @Autowired private SessionCommUtil sessionCommUtil; @Value("${project.syscode}") @@ -180,18 +172,20 @@ public class MonthBillManagementController extends BizController { public BizResultVO> queryBillforMonthList( @RequestBody BillQueryRequest billQueryRequest, HttpServletRequest request, HttpServletResponse response) throws Exception { - // 2.调用接口查询当前登录人管辖的停车场名称 + // 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); - } + List plNos = userInfo.getOrgIds(); +// 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不存在"); // } @@ -215,16 +209,17 @@ public class MonthBillManagementController extends BizController { throws Exception { // 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); - } + List plNos = userInfo.getOrgIds(); +// 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不存在"); // } @@ -268,8 +263,8 @@ public class MonthBillManagementController extends BizController { SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); String[] title = new String[] {"流水号", "时间", "车主车牌号", "进场时间", "出场时间", "停车时长", "收费规则", "支付方式", "应收金额", "优惠券", "红包", "实收金额", "共计"}; - String sheetName = "月账单"; - String fileName = "月账单管理" + format2.format(new Date()); + String sheetName = "账单"; + String fileName = "账单管理" + format2.format(new Date()); // 1.创建excel信息 XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); @@ -367,8 +362,8 @@ public class MonthBillManagementController extends BizController { SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); String[] title = new String[] {"交易单号", "交易时间", "种类", "卡名称", "车牌号", "支付金额", "有效期"}; - String sheetName = "月账单"; - String fileName = "月账单管理" + format2.format(new Date()); + String sheetName = "账单"; + String fileName = "账单管理" + format2.format(new Date()); // 1.创建excel信息 XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); @@ -456,17 +451,20 @@ public class MonthBillManagementController extends BizController { billQueryRequest.setBaseRequest(new BaseInfo(1, 0)); // 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); - } + List plNos = userInfo.getOrgIds(); +// // 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); +// } billQueryRequest.setParkIdList(plNos); logger.info("月账单导出所有 req={}", JSONObject.toJSONString(billQueryRequest)); respondResult = monthBillManagementService @@ -477,7 +475,7 @@ public class MonthBillManagementController extends BizController { SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); String[] title = new String[] {"停车场名称", "现金", "微信", "支付宝", "合计"}; String[] sheetName = new String[] {"临停收费", "年卡月卡收费"}; - String fileName = "月账单管理" + format2.format(new Date()); + String fileName = "账单管理" + format2.format(new Date()); // 1.创建excel信息,多个sheet页 XSSFWorkbook workbook = new XSSFWorkbook(); @@ -549,17 +547,17 @@ public class MonthBillManagementController extends BizController { * @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; - } - - } - -} +// 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; +// } +// +// } + +} \ No newline at end of file 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 index ec75291..8e56b5f 100644 --- 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 @@ -112,21 +112,27 @@ public class ParkLotStatisticController { 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); - } + // 2.调用接口查询当前登录人管辖的停车场名称 + UserInfo userInfo = sessionCommUtil.getUserInfo(); + List plNos=Lists.newArrayList(); + if(null != userInfo){ + plNos= userInfo.getOrgIds(); + } +// 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); +// } + if(CollectionUtils.isEmpty(plNos)){ + 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 index d4597e7..4c12ad4 100644 --- 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 @@ -7,28 +7,14 @@ 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; @@ -49,357 +35,334 @@ 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; +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; /** - * * 停车场车流量数据统计 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 创建 + * 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()) { + private Logger logger = LoggerFactory.getLogger(VehicleFlowStatisticController.class); + + @Value("${project.syscode}") + private String sysCode; + + @Autowired + private ParkingLotUseStatisticService parkingLotStatisticService; + @Autowired + private SessionCommUtil sessionCommUtil; + + @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()) { + 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")); - } - + // 2.调用接口查询当前登录人管辖的停车场名称 + UserInfo userInfo = sessionCommUtil.getUserInfo(); + List plNos = userInfo.getOrgIds(); +// 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()); +// int year = beginTime.get(Calendar.YEAR); + 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) { + // 1小时为一个时间戳 + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); + int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY); + + for (int j = 0; j <= totaltimestampCount+1; j++) { + String hour = String.format("%02d", (j)); + xAxisData.add(hour+":00"); + } + dateType = "HH:mm"; + 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++) { + Calendar tempDate = Calendar.getInstance(); + tempDate .setTime(request.getBeginTime()); + tempDate.add(Calendar.DAY_OF_MONTH, i); + int beginMonth = tempDate.get(Calendar.MONTH) + 1; + int beginDay = tempDate.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/parklotmanage/ParkLotManageController.java b/src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/parklotmanage/ParkLotManageController.java index da98071..affb187 100644 --- 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 @@ -1,5 +1,6 @@ package com.zteits.irain.portal.web.parkinglotcloudplatform.parklotmanage; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -103,19 +104,11 @@ public class ParkLotManageController{ 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); - } + List plNos =new ArrayList<>(); + if(null !=userInfo){ + plNos = userInfo.getOrgIds(); + } return plNos; } } diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 89f2cee..cb82f88 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -1,6 +1,6 @@ #irain irain.url=http://api.parkingwang.com:8280 -server.port=8192 +server.port=8093 #irain艾润 irain.appid=avakrky0gk1m7n00 #irain diff --git a/src/main/resources/dubbo/dubbo-park-consumer.xml b/src/main/resources/dubbo/dubbo-park-consumer.xml index a193d5f..133c8b2 100644 --- a/src/main/resources/dubbo/dubbo-park-consumer.xml +++ b/src/main/resources/dubbo/dubbo-park-consumer.xml @@ -138,4 +138,9 @@ version="${spring.dubbo.provider.version}" timeout="30000"/> + + + \ No newline at end of file