package com.zteits.park.dao.impl; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.clouds.common.utils.DateUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.xiaoleilu.hutool.util.CollectionUtil; import com.zteits.clouds.api.apibase.constants.DataStatusEnum; import com.zteits.clouds.api.dto.clouds.dto.TurnoverRatioDTO; import com.zteits.clouds.api.dto.govclouds.dto.ParkingOccupyDTO; import com.zteits.clouds.api.dto.govclouds.param.QueryParkingOccupyRequest; import com.zteits.clouds.api.dto.park.dto.MonthVehicleFlowAndVacancyRateAndTurnoverDTO; 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.ParkingLotUseStatisticForPageRequest; import com.zteits.park.dao.ParkingLotUseStatisticDao; import com.zteits.park.domain.ParkingLotUseStatistic; import com.zteits.park.domain.ParkingLotUseStatisticExample; import com.zteits.park.domain.ParkingLotUseStatisticExample.Criteria; import com.zteits.park.domain.ParkingLotUseStatisticMaxAndMin; import com.zteits.park.domain.ParkingLotUseStatisticSum; import com.zteits.park.domain.ParkingOccupyDO; import com.zteits.park.mapper.ParkingLotUseStatisticMapper; import com.zteits.park.mapper.smapper.ParkingLotUseStatisticSMapper; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @Component public class ParkingLotUseStatisticDaoImpl implements ParkingLotUseStatisticDao { @Autowired private ParkingLotUseStatisticMapper parkingLotUseStatisticMapper; @Autowired private ParkingLotUseStatisticSMapper parkingLotUseStatisticSMapper; @Override public int insertSelective(ParkingLotUseStatistic record) { return parkingLotUseStatisticMapper.insertSelective(record); } @Override public int batchSave(List records) { if (CollectionUtil.isEmpty(records)) { return 0; } return parkingLotUseStatisticSMapper.batchSave(records); } @Override public PageInfo queryParkingLotUseStatisticForPage( Date beginTime, Date endTime, Integer statisticType, List plNos, Integer pageNum, Integer pageSize) { // 1.设置分页信息 PageHelper.startPage(pageNum, pageSize); //2.查询数据 ParkingLotUseStatisticExample example = new ParkingLotUseStatisticExample(); Criteria sql = example.createCriteria(); sql.andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value()); if (!CollectionUtils.isEmpty(plNos)) { sql.andPlNoIn(plNos); } if (null != statisticType) { sql.andStatisticTypeEqualTo(statisticType); } if (null != beginTime && null != endTime) { sql.andStatisticBeginTimeBetween(beginTime, endTime); } else if (null != beginTime) { sql.andStatisticBeginTimeGreaterThanOrEqualTo(beginTime); } else if (null != endTime) { sql.andStatisticBeginTimeLessThanOrEqualTo(endTime); } example.setOrderByClause("statistic_begin_time desc,pl_no asc"); List list = parkingLotUseStatisticMapper.selectByExample(example); return new PageInfo<>(list); } @Override public PageInfo queryCarFlowByMonthForPage( ParkingLotUseStatisticForPageRequest request) { Integer pageNum = request.getBaseRequest().getPageNum(); pageNum = pageNum == null ? 1 : pageNum; Integer pageSize = request.getBaseRequest().getPageSize(); pageSize = pageSize == null ? 10 : pageSize; PageHelper.startPage(pageNum, pageSize); List dtoList = parkingLotUseStatisticSMapper.queryCarFlowByMonthForPage(request); return new PageInfo<>(dtoList); } @Override public ParkingLotUseStatisticMaxAndMin QueryVehicleFlowStatisticMaxAndMin( Date beginTime, Date endTime, Integer statisticType, List plNos) { return parkingLotUseStatisticSMapper.QueryVehicleFlowStatisticMaxAndMin(beginTime, endTime, statisticType, plNos); } @Override public ParkingLotUseStatisticMaxAndMin QueryBerthUseStatisticMaxAndMin( Date beginTime, Date endTime, Integer statisticType, List plNos) { return parkingLotUseStatisticSMapper.QueryBerthUseStatisticMaxAndMin(beginTime, endTime, statisticType, plNos); } @Override public long countByExample(ParkingLotUseStatisticExample example) { return parkingLotUseStatisticMapper.countByExample(example); } @Override public ParkingLotUseStatisticSum QueryInOutParkStatisticSum(Date beginTime, Date endTime, Integer statisticType, List plNos) { return parkingLotUseStatisticSMapper.QueryInOutParkStatisticSum(beginTime, endTime, statisticType, plNos); } @Override public List queryTodayVehicleFlowOccupyRateAndTurnOver(Date beginTime, Date endTime, Integer statisticType, List plNos) { return parkingLotUseStatisticSMapper.queryTodayVehicleFlowOccupyRateAndTurnOver(beginTime, endTime, statisticType, plNos); } @Override public PageInfo queryMonthVehicleFlowAndVacancyRateAndTurnover( Date beginTime, Date endTime, List plNos, Integer pageNum, Integer pageSize) { // 1.set page information // 设置分页信息 PageHelper.startPage(pageNum, pageSize); //2.query Monthly parking volume, vacancy rate and turnover rate are examined //按月统计进出场车流量和占用率和周转率 List list = parkingLotUseStatisticSMapper .queryMonthVehicleFlowAndVacancyRateAndTurnover(beginTime, endTime, plNos); return new PageInfo(list); } @Override public List queryTwentyFourHoursOccupyRate(QueryParkingOccupyRequest request) { List dtoList = new ArrayList<>(); List doList = parkingLotUseStatisticSMapper.queryTwentyFourHoursOccupyRate(request); if (!(CollectionUtils.isEmpty(doList))) { for (ParkingOccupyDO pdo : doList) { ParkingOccupyDTO dto = new ParkingOccupyDTO(); BeanUtils.copyProperties(pdo, dto); dtoList.add(dto); } } return dtoList; } @Override public void statistic20MinData(Date startDate, Date endDate, List states) { parkingLotUseStatisticSMapper.statistic20MinData(startDate, endDate, states); } @Override public void statistic20MinDataForSelectByLCPark(Date startDate, Date endDate, List states) { int pageSize = 100; List temps; String startDateStr = com.xiaoleilu.hutool.date.DateUtil.format(startDate,"yyyy-MM-dd HH:mm:ss"); String endDateStr = com.xiaoleilu.hutool.date.DateUtil.format(endDate,"yyyy-MM-dd HH:mm:ss"); String recordStr = com.xiaoleilu.hutool.date.DateUtil.date().toString("yyyyMM"); //统计路侧的 List parkingLotUseStatistics = parkingLotUseStatisticSMapper.statistic20MinDataForSelectByLCPark(startDateStr,endDateStr,states,recordStr); //分页处理 if(CollectionUtil.isNotEmpty(parkingLotUseStatistics)){ int totals = parkingLotUseStatistics.size(); int page = totals/pageSize; for (int i=0;i 0){ temps = parkingLotUseStatistics.subList(page*pageSize, page*pageSize+totals%pageSize); parkingLotUseStatisticSMapper.statistic20MinDataForInsert(temps); } } } @Override public void statistic20MinDataForSelectByFBPark(Date startDate, Date endDate, List states) { int pageSize = 100; List temps = new ArrayList(); String startDateStr = com.xiaoleilu.hutool.date.DateUtil.format(startDate,"yyyy-MM-dd HH:mm:ss"); String endDateStr = com.xiaoleilu.hutool.date.DateUtil.format(endDate,"yyyy-MM-dd HH:mm:ss"); String recordStr = com.xiaoleilu.hutool.date.DateUtil.date().toString("yyyyMM"); //List parkingLotUseStatistics = parkingLotUseStatisticSMapper.statistic20MinDataForSelect(startDate, endDate, states); //统计封闭的 List parkingLotUseStatistics = parkingLotUseStatisticSMapper.statistic20MinDataForSelectByFBPark(startDate,endDate,states); //分页处理 if(CollectionUtil.isNotEmpty(parkingLotUseStatistics)){ int totals = parkingLotUseStatistics.size(); int page = totals/pageSize; for (int i=0;i 0){ temps = parkingLotUseStatistics.subList(page*pageSize, page*pageSize+totals%pageSize); parkingLotUseStatisticSMapper.statistic20MinDataForInsert(temps); } } } @Override public void static1HourAnd1DayData(Date startDate, Date endDate, Integer type) { parkingLotUseStatisticSMapper.static1HourAnd1DayData(startDate, endDate, type); } @Override public List queryCarFlowChartByDay(ParkingLotUseStatisticForPageRequest request) { return parkingLotUseStatisticSMapper.queryCarFlowChartByDay(request); } @Override public List queryCarFlowChartByMonth(ParkingLotUseStatisticForPageRequest request) { return parkingLotUseStatisticSMapper.queryCarFlowChartByMonth(request); } @Override public PageInfo queryTurnoverRatioNew(ParkingLotUseStatisticForPageRequest request) { PageHelper.startPage(request.getBaseRequest().getPageNum(),request.getBaseRequest().getPageSize()); List list=parkingLotUseStatisticSMapper.queryTurnoverRatioNew(request); return new PageInfo<>(list); } @Override public PageInfo queryTurnoverRatioNewForChart(ParkingLotUseStatisticForPageRequest request) { PageHelper.startPage(request.getBaseRequest().getPageNum(),request.getBaseRequest().getPageSize()); List list=parkingLotUseStatisticSMapper.queryTurnoverRatioNewForChart(request); return new PageInfo<>(list); } @Override public List query20MinNewDataGroupByPlNO() { return parkingLotUseStatisticSMapper.query20MinNewDataGroupByPlNO(); } }