diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcStatisticsServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcStatisticsServiceImpl.java index e35535aa..22a9cd3d 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcStatisticsServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcStatisticsServiceImpl.java @@ -20,19 +20,7 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService { private XhpcStatisticsServiceMapper xhpcStatisticsServiceMapper; @Override public List> getTimeIntervalPage(String chargingPileIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type) { - - if(type==null){ - return new ArrayList<>(); - } - if(type==2){ - if(operatorId==null){ - return new ArrayList<>(); - } - }else if(type==3){ - if(internetUserId==null){ - return new ArrayList<>(); - } - }else if(type!=1){ + if (getJudge(internetUserId, operatorId, type)){ return new ArrayList<>(); } List chargingPileId =new ArrayList<>(); @@ -132,21 +120,9 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService { } return page; } - @Override public List> getDateIntervalPage(String chargingPileIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type) { - if(type==null){ - return new ArrayList<>(); - } - if(type==2){ - if(operatorId==null){ - return new ArrayList<>(); - } - }else if(type==3){ - if(internetUserId==null){ - return new ArrayList<>(); - } - }else if(type!=1){ + if (getJudge(internetUserId, operatorId, type)){ return new ArrayList<>(); } List chargingPileId =new ArrayList<>(); @@ -159,18 +135,7 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService { @Override public List> getStationIntervalPage(String stationName, String operatorName, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type) { - if(type==null){ - return new ArrayList<>(); - } - if(type==2){ - if(operatorId==null){ - return new ArrayList<>(); - } - }else if(type==3){ - if(internetUserId==null){ - return new ArrayList<>(); - } - }else if(type!=1){ + if (getJudge(internetUserId, operatorId, type)){ return new ArrayList<>(); } return xhpcStatisticsServiceMapper.getStationIntervalPage(stationName,operatorName,internetUserId,operatorId,startTime,endTime,type); @@ -178,34 +143,15 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService { @Override public List> getOperatorIntervalPage(String operatorName, Long operatorId, String startTime, String endTime, Long userId, Integer type) { - if(type==null){ + if(getJudge(null,operatorId,type)){ return new ArrayList<>(); } - if(type==2){ - if(operatorId==null){ - return new ArrayList<>(); - } - }else if(type==3){ - return new ArrayList<>(); - }else if(type!=1){ - return new ArrayList<>(); - } - return xhpcStatisticsServiceMapper.getOperatorIntervalPage(operatorName, operatorId, startTime, endTime, type); } @Override public List> getInternetUserIntervalPage(String internetUserName, Long internetUserId, String startTime, String endTime, Long userId, Integer type) { - if(type==null){ - return new ArrayList<>(); - } - if(type==2){ - return new ArrayList<>(); - }else if(type==3){ - if(internetUserId==null){ - return new ArrayList<>(); - } - }else if(type!=1){ + if(getJudge(internetUserId,null,type)){ return new ArrayList<>(); } return xhpcStatisticsServiceMapper.getInternetUserIntervalPage(internetUserName, internetUserId, startTime, endTime, type); @@ -213,22 +159,30 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService { @Override public List> getTerminalIntervalPage(String chargingStationName, String terminalName, Long operatorId, String startTime, String endTime, Long userId, Integer type) { - if(type==null){ - return new ArrayList<>(); - } - if(type==2){ - if(operatorId==null){ - return new ArrayList<>(); - } - }else if(type==3){ - return new ArrayList<>(); - }else if(type!=1){ + if(getJudge(null,operatorId,type)){ return new ArrayList<>(); } return xhpcStatisticsServiceMapper.getTerminalIntervalPage(chargingStationName, terminalName, operatorId, startTime, endTime, type); } + private boolean getJudge(Long internetUserId, Long operatorId, Integer type) { + if (type == null) { + return true; + } + if (type == 2) { + if (operatorId == null) { + return true; + } + } else if (type == 3) { + if (internetUserId == null) { + return true; + } + } else if (type != 1) { + return true; + } + return false; + } private Map getStatistics(String time){ Map map =new HashMap<>(); map.put("chargingDegree",0.00); diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml index 9147ae2c..3fb9b2da 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml @@ -110,7 +110,7 @@ sum(operation_commission) operationCommission, sum(operation_svc_commission) operationSvcCommission, DATE_FORMAT(create_time,'%Y-%m-%d') createTime - from xhpc_statistics_data + from xhpc_statistics_station where del_flag=0 and type=1 and charging_pile_id in