From 7c33a09758c258e3c669b0fe5dca0e08b11ab0f6 Mon Sep 17 00:00:00 2001 From: yuyang <2265829957@qq.com> Date: Fri, 19 Nov 2021 18:24:17 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E8=BF=90=E8=90=A5=E5=95=86?= =?UTF-8?q?=E5=92=8C=E5=B9=B3=E5=8F=B0=E7=AE=A1=E7=90=86=E5=91=98=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9D=83=E9=99=90=202.C=E7=AB=AF=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/XhpcChargingPileMapper.java | 2 +- .../mapper/XhpcChargingStationMapper.java | 11 +- .../service/IXhpcChargingStationService.java | 6 + .../service/XhpcChargingPileServiceImpl.java | 25 +- .../XhpcChargingStationServiceImpl.java | 29 +- .../mapper/XhpcChargingPileMapper.xml | 6 + .../mapper/XhpcChargingStationMapper.xml | 11 + .../resources/mapper/XhpcTerminalMapper.xml | 2 +- .../order/mapper/XhpcHistoryOrderMapper.java | 5 + .../service/IXhpcHistoryOrderService.java | 5 + .../impl/XhpcHistoryOrderServiceImpl.java | 31 +- .../impl/XhpcRealTimeOrderServiceImpl.java | 29 +- .../impl/XhpcStatisticsServiceImpl.java | 308 +++++++++++++----- .../mapper/XhpcHistoryOrderMapper.xml | 12 +- .../mapper/XhpcRealTimeOrderMapper.xml | 8 +- .../resources/mapper/XhpcStatisticsMapper.xml | 93 ++---- .../resources/mapper/XhpcAppUserMapper.xml | 2 +- 17 files changed, 435 insertions(+), 150 deletions(-) diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingPileMapper.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingPileMapper.java index 727467aa..b91b2a11 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingPileMapper.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingPileMapper.java @@ -21,7 +21,7 @@ public interface XhpcChargingPileMapper { * @param name 桩名称 * @return */ - List> selectXhpcChargingPileList(@Param("name") String name, @Param("type") Integer type, @Param("serialNumber") String serialNumber, @Param("chargingStationId") Long chargingStationId); + List> selectXhpcChargingPileList(@Param("name") String name, @Param("type") Integer type, @Param("serialNumber") String serialNumber, @Param("chargingStationId") Long chargingStationId,@Param("operatorId")Long operatorId,@Param("number")Integer number); /** * 终端 diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingStationMapper.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingStationMapper.java index 8f8f36e0..12dceea7 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingStationMapper.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingStationMapper.java @@ -34,7 +34,7 @@ public interface XhpcChargingStationMapper { * @param operatorName 运营商名称 * @return 电站集合 */ - List> selectXhpcChargingStationList(@Param("name") String name, @Param("operatorName") String operatorName); + List> selectXhpcChargingStationList(@Param("name") String name, @Param("operatorName") String operatorName,@Param("operatorId")Long operatorId,@Param("type")Integer type); /** * 新增电站 @@ -246,4 +246,13 @@ public interface XhpcChargingStationMapper { */ void updateXhpcTerminal(@Param("chargingStationId") Long chargingStationId,@Param("rateModelId") Long rateModelId); + + /** + * 获取登陆用户信息 + */ + Map getLandUser(@Param("userId") Long userId); + + + + } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java index 9f96bbff..d3f8cdf6 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java @@ -3,6 +3,7 @@ package com.xhpc.charging.station.service; import com.xhpc.common.api.dto.XhpcChargingStationDto; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.domain.XhpcChargingStation; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -215,4 +216,9 @@ public interface IXhpcChargingStationService { */ Integer editStationsStatus(List chargingStationId, Integer pushStatus); + /** + * 获取登陆用户信息 + */ + Map getLandUser(Long userId); + } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java index f04dc550..9b92a4b9 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java @@ -6,6 +6,7 @@ import com.xhpc.charging.station.mapper.XhpcImgMapper; import com.xhpc.charging.station.mapper.XhpcTerminalMapper; import com.xhpc.charging.station.utils.img.QrImgUtils; import com.xhpc.common.api.PowerPileService; +import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.domain.XhpcChargingPile; @@ -62,7 +63,29 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService { @Override public List> selectXhpcChargingPileList(String name, Integer type, String serialNumber, Long chargingStationId) { - return xhpcChargingPileMapper.selectXhpcChargingPileList(name, type, serialNumber, chargingStationId); + //获取登陆用户 + + Long userId = SecurityUtils.getUserId(); + //桩的统计、该时段金额 + List> list =new ArrayList<>(); + if(userId !=1) { + Map landUser = xhpcChargingStationService.getLandUser(userId); + if(landUser !=null){ + if(landUser.get("operatorId") !=null){ + Long operatorId = Long.valueOf(landUser.get("operatorId").toString()); + if("01".equals(landUser.get("userType").toString())){ + list= xhpcChargingPileMapper.selectXhpcChargingPileList(name, type, serialNumber, chargingStationId,operatorId,1); + }else{ + list= xhpcChargingPileMapper.selectXhpcChargingPileList(name, type, serialNumber, chargingStationId,operatorId,2); + } + } + } + }else{ + list= xhpcChargingPileMapper.selectXhpcChargingPileList(name, type, serialNumber, chargingStationId,userId,0); + } + + + return list; } @Override diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java index 99dcc1bc..be82c779 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java @@ -10,6 +10,7 @@ import com.xhpc.common.api.dto.XhpcRateDto; import com.xhpc.common.api.dto.XhpcRateTimeDto; import com.xhpc.common.core.domain.R; import com.xhpc.common.core.utils.DateUtils; +import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.data.redis.CacheRateModel; import com.xhpc.common.domain.XhpcChargingStation; @@ -60,6 +61,12 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi return xhpcChargingStationPushStatusMapper.editStationsStatus(chargingStationIds, pushStatus); } + @Override + public Map getLandUser(Long userId) { + + return xhpcChargingStationMapper.getLandUser(userId); + } + /** * 保存电站状态 * @@ -98,8 +105,28 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi */ @Override public List> selectXhpcChargingStationList(String name, String operatorName) { + //获取登陆用户 + Long userId = SecurityUtils.getUserId(); //桩的统计、该时段金额 - List> list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName); + List> list =new ArrayList<>(); + if(userId !=1) { + Map landUser = xhpcChargingStationMapper.getLandUser(userId); + if(landUser !=null){ + if(landUser.get("operatorId") !=null){ + Long operatorId = Long.valueOf(landUser.get("operatorId").toString()); + if("01".equals(landUser.get("userType").toString())){ + //运营商看自己的场站 + list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,operatorId,1); + }else{ + //查询赋值的场站 + list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,operatorId,2); + } + } + } + }else{ + list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,userId,0); + } + for (int i = 0; i < list.size(); i++) { Map map = list.get(i); Long chargingStationId = Long.valueOf(map.get("chargingStationId").toString()); diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml index 65e4d3a8..4c69ff66 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml @@ -98,6 +98,12 @@ and cp.charging_station_id=#{chargingStationId} + + and cp.charging_station_id in(select charging_station_id from xhpc_charging_station where operator_id=#{operatorId}) + + + and cp.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{operatorId}) + order by cp.create_time desc diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml index 4a8cabce..3185f039 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml @@ -82,6 +82,12 @@ and ope.name like CONCAT('%',#{operatorName},'%') + + and cs.charging_station_id in(select charging_station_id from xhpc_charging_station where operator_id=#{operatorId}) + + + and cs.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{operatorId}) + @@ -878,4 +884,9 @@ update xhpc_terminal set rate_model_id=#{rateModelId} WHERE charging_station_id=#{chargingStationId} + + + diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcTerminalMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcTerminalMapper.xml index f779b179..563a78f6 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcTerminalMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcTerminalMapper.xml @@ -381,6 +381,6 @@ diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java index ac30a7cd..e92fe142 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java @@ -107,4 +107,9 @@ public interface XhpcHistoryOrderMapper { * */ void updateXhpcHistoryOrder(@Param("historyOrderId")Long historyOrderId,@Param("state")Integer state); + + /** + * 获取登陆用户信息 + */ + Map getLandUser(@Param("userId")Long userId); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java index 4cb03415..6fd3b30e 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java @@ -90,4 +90,9 @@ public interface IXhpcHistoryOrderService { */ void addXhpcChargeOrder(String orderNo,Integer type); + + /** + * 获取登陆用户信息 + */ + Map getLandUser(Long userId); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java index 621aaec4..8a4ff229 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import com.xhpc.common.api.SmsService; +import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.data.redis.CacheRealtimeData; import com.xhpc.common.redis.service.RedisService; @@ -82,7 +83,29 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService { }else{ number =2; } - return xhpcHistoryOrderMapper.getListPage(phone,transactionNumber,status,chargingStationName,operatorId,source,startTime,endTime,userId,type,number); + //获取登陆用户 + Long logUserId = SecurityUtils.getUserId(); + //桩的统计、该时段金额 + List> list =new ArrayList<>(); + if(userId !=1){ + Map landUser = xhpcHistoryOrderMapper.getLandUser(logUserId); + if(landUser !=null){ + if(landUser.get("operatorId") !=null){ + Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString()); + if("01".equals(landUser.get("userType").toString())){ + //运营商看自己的场站 + list = xhpcHistoryOrderMapper.getListPage(phone,transactionNumber,1,chargingStationName,operatorId,source,startTime,endTime,logOperatorId,type,number); + }else{ + //查询赋值的场站 + list = xhpcHistoryOrderMapper.getListPage(phone,transactionNumber,2,chargingStationName,operatorId,source,startTime,endTime,logOperatorId,type,number); + } + } + } + + }else{ + list =xhpcHistoryOrderMapper.getListPage(phone,transactionNumber,0,chargingStationName,operatorId,source,startTime,endTime,userId,type,number); + } + return list; } @Override @@ -419,6 +442,12 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService { } + @Override + public Map getLandUser(Long userId) { + + return xhpcHistoryOrderMapper.getLandUser(userId); + } + /** * 历史信息费率时段 */ diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java index 5a75f121..3a551465 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import com.xhpc.common.api.SmsService; +import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.data.redis.CacheOrderData; import com.xhpc.common.data.redis.CacheRealtimeData; @@ -60,6 +61,14 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { @Override public List> list(String phone, String transactionNumber, Integer source, String chargingStationName, String terminalName, Long operatorId, String startTime, String endTime,Integer status,Long userId,Integer type) { + + //获取登陆用户 + Long logUserId = SecurityUtils.getUserId(); + //桩的统计、该时段金额 + List> list =new ArrayList<>(); + + //number 3 用户类型和电话都有 1 电话 2 用户类型 + //type 1 平台 2 运营商 3流量方 Integer number=0; if(!"".equals(phone) && phone!=null && !"".equals(source) && source !=null){ number =3; @@ -71,7 +80,25 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { if(type ==null || userId ==null){ return new ArrayList<>(); } - return xhpcRealTimeOrderMapper.list(phone,transactionNumber,source,chargingStationName,terminalName,operatorId,startTime,endTime,number,status,userId,type); + if(userId !=1) { + Map landUser = xhpcHistoryOrderService.getLandUser(logUserId); + if(landUser !=null){ + if(landUser.get("operatorId") !=null){ + Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString()); + if("01".equals(landUser.get("userType").toString())){ + //运营商看自己的场站 + list = xhpcRealTimeOrderMapper.list(phone,transactionNumber,source,chargingStationName,terminalName,operatorId,startTime,endTime,number,status,logOperatorId,1); + }else{ + //查询赋值的场站 + list = xhpcRealTimeOrderMapper.list(phone,transactionNumber,source,chargingStationName,terminalName,operatorId,startTime,endTime,number,status,logOperatorId,2); + } + } + } + }else{ + list = xhpcRealTimeOrderMapper.list(phone,transactionNumber,source,chargingStationName,terminalName,operatorId,startTime,endTime,number,status,userId,0); + } + + return list; } @Override 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 d8f82570..7049063f 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 @@ -2,13 +2,15 @@ package com.xhpc.order.service.impl; import cn.hutool.core.date.DateUtil; +import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.order.domain.XhpcStatisticsStation; import com.xhpc.order.domain.XhpcStatisticsTimeInterval; import com.xhpc.order.mapper.XhpcStatisticsServiceMapper; +import com.xhpc.order.service.IXhpcHistoryOrderService; import com.xhpc.order.service.IXhpcStatisticsService; -import org.apache.poi.hssf.usermodel.*; -import org.apache.poi.hssf.util.HSSFColor; + +import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -25,6 +27,8 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService { @Autowired private XhpcStatisticsServiceMapper xhpcStatisticsServiceMapper; + @Autowired + private IXhpcHistoryOrderService xhpcHistoryOrderService; @Override public List> getTimeIntervalPage(String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type) { if (getJudge(internetUserId, operatorId, type)){ @@ -34,11 +38,26 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService { if(!"".equals(chargingStationIds) && chargingStationIds !=null){ chargingStationId= Arrays.asList(chargingStationIds.split(",")); } -// if(("".equals(startTime) && "".equals(endTime)) ||(startTime==null && endTime==null)){ -// startTime =date(1); -// endTime =date(2); -// } - List> list = xhpcStatisticsServiceMapper.getTimeIntervalPage(chargingStationId, internetUserId, operatorId, startTime, endTime, type,userId); + //获取登陆用户 + Long logUserId = SecurityUtils.getUserId(); + List> list =new ArrayList<>(); + if(userId !=1){ + Map landUser = xhpcHistoryOrderService.getLandUser(logUserId); + if(landUser !=null){ + if(landUser.get("operatorId") !=null){ + Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString()); + if("01".equals(landUser.get("userType").toString())){ + //运营商看自己的场站 + list = xhpcStatisticsServiceMapper.getTimeIntervalPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 1,logOperatorId); + }else{ + //查询赋值的场站 + list = xhpcStatisticsServiceMapper.getTimeIntervalPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 2,logOperatorId); + } + } + } + }else{ + list =xhpcStatisticsServiceMapper.getTimeIntervalPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 0,userId); + } List> page =new ArrayList<>(); if(list !=null && list.size()>0){ for (int i = 1; i <=24 ; i++) { @@ -140,11 +159,29 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService { if(!"".equals(chargingStationIds) && chargingStationIds !=null){ chargingStationId= Arrays.asList(chargingStationIds.split(",")); } -// if(("".equals(startTime) && "".equals(endTime)) ||(startTime==null && endTime==null)){ -// startTime =date(1); -// endTime =date(2); -// } - return xhpcStatisticsServiceMapper.getDateIntervalPage(chargingStationId, internetUserId, operatorId, startTime, endTime, type,userId); + + //获取登陆用户 + Long logUserId = SecurityUtils.getUserId(); + List> list =new ArrayList<>(); + if(userId !=1){ + Map landUser = xhpcHistoryOrderService.getLandUser(logUserId); + if(landUser !=null){ + if(landUser.get("operatorId") !=null){ + Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString()); + if("01".equals(landUser.get("userType").toString())){ + //运营商看自己的场站 + list = xhpcStatisticsServiceMapper.getDateIntervalPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 1,logOperatorId); + }else{ + //查询赋值的场站 + list = xhpcStatisticsServiceMapper.getDateIntervalPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 2,logOperatorId); + } + } + } + }else{ + list =xhpcStatisticsServiceMapper.getDateIntervalPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 0,userId); + } + + return list; } @Override @@ -160,11 +197,30 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService { if(!"".equals(operatorIds) && operatorIds !=null){ operatorUserId= Arrays.asList(operatorIds.split(",")); } -// if(("".equals(startTime) && "".equals(endTime)) ||(startTime==null && endTime==null)){ -// startTime =date(1); -// endTime =date(2); -// } - return xhpcStatisticsServiceMapper.getStationIntervalPage(chargingStationId,operatorUserId,internetUserId,operatorId,startTime,endTime,type,userId); + + //获取登陆用户 + Long logUserId = SecurityUtils.getUserId(); + List> list =new ArrayList<>(); + if(userId !=1){ + Map landUser = xhpcHistoryOrderService.getLandUser(logUserId); + if(landUser !=null){ + if(landUser.get("operatorId") !=null){ + Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString()); + if("01".equals(landUser.get("userType").toString())){ + //运营商看自己的场站 + list = xhpcStatisticsServiceMapper.getStationIntervalPage(chargingStationId,operatorUserId,internetUserId,operatorId,startTime,endTime,1,logOperatorId); + }else{ + //查询赋值的场站 + list = xhpcStatisticsServiceMapper.getStationIntervalPage(chargingStationId,operatorUserId,internetUserId,operatorId,startTime,endTime,2,logOperatorId); + } + } + } + }else{ + list =xhpcStatisticsServiceMapper.getStationIntervalPage(chargingStationId,operatorUserId,internetUserId,operatorId,startTime,endTime,0,userId); + } + + + return list; } @Override @@ -176,11 +232,29 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService { if(!"".equals(operatorIds) && operatorIds !=null){ operatorUserId= Arrays.asList(operatorIds.split(",")); } -// if(("".equals(startTime) && "".equals(endTime)) ||(startTime==null && endTime==null)){ -// startTime =date(1); -// endTime =date(2); -// } - return xhpcStatisticsServiceMapper.getOperatorIntervalPage(operatorUserId, operatorId, startTime, endTime, type,userId); + + //获取登陆用户 + Long logUserId = SecurityUtils.getUserId(); + List> list =new ArrayList<>(); + if(userId !=1){ + Map landUser = xhpcHistoryOrderService.getLandUser(logUserId); + if(landUser !=null){ + if(landUser.get("operatorId") !=null){ + Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString()); + if("01".equals(landUser.get("userType").toString())){ + //运营商看自己的场站 + list = xhpcStatisticsServiceMapper.getOperatorIntervalPage(operatorUserId, operatorId, startTime, endTime, 1,logOperatorId); + }else{ + //查询赋值的场站 + list = xhpcStatisticsServiceMapper.getOperatorIntervalPage(operatorUserId, operatorId, startTime, endTime, 2,logOperatorId); + } + } + } + }else{ + list =xhpcStatisticsServiceMapper.getOperatorIntervalPage(operatorUserId, operatorId, startTime, endTime, 0,userId); + } + + return list; } @Override @@ -204,22 +278,79 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService { if(getJudge(null,operatorId,type)){ return new ArrayList<>(); } -// if(("".equals(startTime) && "".equals(endTime)) ||(startTime==null && endTime==null)){ -// startTime =date(1); -// endTime =date(2); -// } - return xhpcStatisticsServiceMapper.getTerminalIntervalPage(chargingStationId, terminalId, operatorId, startTime, endTime, type,userId); + + //获取登陆用户 + Long logUserId = SecurityUtils.getUserId(); + List> list =new ArrayList<>(); + if(userId !=1){ + Map landUser = xhpcHistoryOrderService.getLandUser(logUserId); + if(landUser !=null){ + if(landUser.get("operatorId") !=null){ + Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString()); + if("01".equals(landUser.get("userType").toString())){ + //运营商看自己的场站 + list = xhpcStatisticsServiceMapper.getTerminalIntervalPage(chargingStationId, terminalId, operatorId, startTime, endTime, type,logOperatorId); + }else{ + //查询赋值的场站 + list = xhpcStatisticsServiceMapper.getTerminalIntervalPage(chargingStationId, terminalId, operatorId, startTime, endTime, type,logOperatorId); + } + } + } + }else{ + list =xhpcStatisticsServiceMapper.getTerminalIntervalPage(chargingStationId, terminalId, operatorId, startTime, endTime, type,userId); + } + + + return list; } @Override public AjaxResult getChargingStationList(Long operatorId, Long userId, Integer type) { - return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingStationList(operatorId, userId, type)); + + //获取登陆用户 + Long logUserId = SecurityUtils.getUserId(); + if(userId !=1){ + Map landUser = xhpcHistoryOrderService.getLandUser(logUserId); + if(landUser !=null){ + if(landUser.get("operatorId") !=null){ + Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString()); + if("01".equals(landUser.get("userType").toString())){ + //运营商看自己的场站 + return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingStationList(operatorId, logOperatorId, 1)); + }else{ + //查询赋值的场站 + return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingStationList(operatorId, logOperatorId, 2)); + } + } + } + }else{ + return AjaxResult.success(xhpcStatisticsServiceMapper.getChargingStationList(operatorId, userId, 0)); + } + return AjaxResult.success(); } @Override public AjaxResult getOperatorList(Long operatorId, Long userId, Integer type) { - - return AjaxResult.success(xhpcStatisticsServiceMapper.getOperatorList(operatorId, userId, type)); + //获取登陆用户 + Long logUserId = SecurityUtils.getUserId(); + if(userId !=1){ + Map landUser = xhpcHistoryOrderService.getLandUser(logUserId); + if(landUser !=null){ + if(landUser.get("operatorId") !=null){ + Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString()); + if("01".equals(landUser.get("userType").toString())){ + //运营商看自己的场站 + return AjaxResult.success(xhpcStatisticsServiceMapper.getOperatorList(operatorId, logOperatorId, 1)); + }else{ + //查询赋值的场站 + return AjaxResult.success(xhpcStatisticsServiceMapper.getOperatorList(operatorId, logOperatorId, 2)); + } + } + } + }else{ + AjaxResult.success(xhpcStatisticsServiceMapper.getOperatorList(operatorId, userId, 0)); + } + return AjaxResult.success(); } @Override @@ -230,7 +361,29 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService { @Override public AjaxResult getTerminalList(Long chargingStationId, Long userId, Integer type) { - return AjaxResult.success(xhpcStatisticsServiceMapper.getTerminalList(chargingStationId, userId, type)); + //获取登陆用户 + Long logUserId = SecurityUtils.getUserId(); + if(userId !=1){ + Map landUser = xhpcHistoryOrderService.getLandUser(logUserId); + if(landUser !=null){ + if(landUser.get("operatorId") !=null){ + Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString()); + if("01".equals(landUser.get("userType").toString())){ + //运营商看自己的场站 + return AjaxResult.success(xhpcStatisticsServiceMapper.getTerminalList(chargingStationId, logOperatorId, 1)); + }else{ + //查询赋值的场站 + return AjaxResult.success(xhpcStatisticsServiceMapper.getTerminalList(chargingStationId, logOperatorId, 2)); + } + } + } + }else{ + return AjaxResult.success(xhpcStatisticsServiceMapper.getTerminalList(chargingStationId, userId, 0)); + } + + + + return AjaxResult.success(); } @Override @@ -317,54 +470,55 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService { export(out, titles, keys, data); } + @Override public void export(ServletOutputStream out, String[] titles, String[] keys, List> data) throws Exception { - try { - //Making the head. - HSSFWorkbook workbook = new HSSFWorkbook(); - HSSFSheet hssfSheet = workbook.createSheet("sheet1"); - HSSFRow row = hssfSheet.createRow(0); - HSSFCellStyle hssfCellStyle = workbook.createCellStyle(); - hssfCellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); - hssfCellStyle.setFillForegroundColor(HSSFColor.SKY_BLUE.index); - hssfCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); - HSSFCell hssfCell; - for (int i = 0; i < titles.length; i++) { - hssfCell = row.createCell(i); - hssfCell.setCellValue(titles[i]); - hssfCell.setCellStyle(hssfCellStyle); - hssfSheet.setColumnWidth(i, hssfCell.getStringCellValue().getBytes().length * 256 + 200); - } - - //Loading data. - HSSFRow dataRow; - HSSFCell dataCell; - int valuesLength = keys.length; - for (int i = 1; i <= data.size(); i++) { - Map map = data.get(i - 1); - if (null != map) { - dataRow = hssfSheet.createRow(i); - for (int j = 0; j < valuesLength; j++) { - if (null != map.get(keys[j])) { - dataCell = dataRow.createCell(j); - String s = String.valueOf(map.get(keys[j])); - dataCell.setCellValue(s); - } - } - } - } - // Exporting to the client. - try { - workbook.write(out); - out.flush(); - out.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } catch (Exception e) { - e.printStackTrace(); - throw new Exception("导出信息失败!"); - } +// try { +// //Making the head. +// HSSFWorkbook workbook = new HSSFWorkbook(); +// HSSFSheet hssfSheet = workbook.createSheet("sheet1"); +// HSSFRow row = hssfSheet.createRow(0); +// HSSFCellStyle hssfCellStyle = workbook.createCellStyle(); +// hssfCellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); +// hssfCellStyle.setFillForegroundColor(HSSFColor.SKY_BLUE.index); +// hssfCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); +// HSSFCell hssfCell; +// for (int i = 0; i < titles.length; i++) { +// hssfCell = row.createCell(i); +// hssfCell.setCellValue(titles[i]); +// hssfCell.setCellStyle(hssfCellStyle); +// hssfSheet.setColumnWidth(i, hssfCell.getStringCellValue().getBytes().length * 256 + 200); +// } +// +// //Loading data. +// HSSFRow dataRow; +// HSSFCell dataCell; +// int valuesLength = keys.length; +// for (int i = 1; i <= data.size(); i++) { +// Map map = data.get(i - 1); +// if (null != map) { +// dataRow = hssfSheet.createRow(i); +// for (int j = 0; j < valuesLength; j++) { +// if (null != map.get(keys[j])) { +// dataCell = dataRow.createCell(j); +// String s = String.valueOf(map.get(keys[j])); +// dataCell.setCellValue(s); +// } +// } +// } +// } +// // Exporting to the client. +// try { +// workbook.write(out); +// out.flush(); +// out.close(); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// throw new Exception("导出信息失败!"); +// } } diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index c60efc77..c48142c2 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -651,13 +651,13 @@ #{phone}, '%')) - + and co.source =0 and co.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId}) - - and co.source =1 - and co.user_id=#{userId} + + and co.source =0 + and co.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId}) order by ho.create_time desc @@ -787,4 +787,8 @@ update xhpc_history_order set state = #{state} where history_order_id=#{historyOrderId} + + diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml index 3a63910c..609c8dad 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml @@ -444,13 +444,13 @@ #{phone}, '%')) - + and co.source =0 and co.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId}) - - and co.source =1 - and co.user_id=#{userId} + + and co.source =0 + and co.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId}) order by co.create_time desc 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 2e765986..db4b0cf2 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml @@ -94,16 +94,11 @@ and create_time <= #{endTime} + + and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId}) + - and operator_id=#{operatorId} - - - and internet_user_id=#{internetUserId} - - - and operator_id in ( - SELECT operator_id from xhpc_charging_station where charging_station_id in (SELECT charging_station_id FROM xhpc_user_privilege where user_id=#{userId}) - ) + and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId}) group by status order by status @@ -143,16 +138,11 @@ and create_time <= #{endTime} + + and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId}) + - and operator_id=#{operatorId} - - - and internet_user_id=#{internetUserId} - - - and operator_id in ( - SELECT operator_id from xhpc_charging_station where charging_station_id in (SELECT charging_station_id FROM xhpc_user_privilege where user_id=#{userId}) - ) + and internet_user_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId}) group by DATE_FORMAT(create_time,'%Y-%m-%d') order by DATE_FORMAT(create_time,'%Y-%m-%d') desc @@ -189,11 +179,11 @@ and ss.create_time <= #{endTime} - - and ss.operator_id=#{operatorId} + + and ss.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId}) - - and ss.internet_user_id=#{internetUserId} + + and ss.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId}) and ss.charging_station_id in @@ -207,11 +197,6 @@ #{operatorId} - - and operator_id in ( - SELECT operator_id from xhpc_charging_station where charging_station_id in (SELECT charging_station_id FROM xhpc_user_privilege where user_id=#{userId}) - ) - group by ss.charging_station_id @@ -250,18 +235,11 @@ #{operatorIds} + + and ss.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId}) + - - and ss.operator_id =#{operatorId} - - - - and ss.internet_user_id=#{internetUserId} - - - and operator_id in ( - SELECT operator_id from xhpc_charging_station where charging_station_id in (SELECT charging_station_id FROM xhpc_user_privilege where user_id=#{userId}) - ) + and ss.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId}) group by ss.operator_id @@ -338,19 +316,17 @@ and ss.create_time <= #{endTime} - - and ss.operator_id=#{operatorId} - and cs.charging_station_id=#{chargingStationId} and te.terminal_id=#{terminalId} - - and operator_id in ( - SELECT operator_id from xhpc_charging_station where charging_station_id in (SELECT charging_station_id FROM xhpc_user_privilege where user_id=#{userId}) - ) + + and ss.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId}) + + + and ss.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId}) group by ss.terminal_id @@ -361,11 +337,11 @@ charging_station_id as chargingStationId from xhpc_charging_station where 1=1 - - and operator_id =#{operatorId} + + and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId}) - - and charging_station_id in (SELECT charging_station_id FROM xhpc_user_privilege where user_id=#{userId}) + + and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId}) @@ -376,13 +352,12 @@ name as operatorName from xhpc_operator where 1=1 - - and operator_id =#{operatorId} + + + and operator_id in (select operator_id from xhpc_charging_station where operator_id=#{userId}) - - and operator_id in ( - SELECT operator_id from xhpc_charging_station where charging_station_id in (SELECT charging_station_id FROM xhpc_user_privilege where user_id=#{userId}) - ) + + and operator_id in (select operator_id from xhpc_charging_station where charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})) @@ -403,9 +378,13 @@ name as terminalName from xhpc_terminal where 1=1 - - and charging_station_id =#{chargingStationId} + + and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId}) + + and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId}) + + diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml index e7421b10..363c1c86 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml @@ -200,7 +200,7 @@