1.增加运营商和平台管理员数据权限 2.C端用户统计

This commit is contained in:
yuyang 2021-11-19 18:24:17 +08:00
parent 31ba31c00c
commit 7c33a09758
17 changed files with 435 additions and 150 deletions

View File

@ -21,7 +21,7 @@ public interface XhpcChargingPileMapper {
* @param name 桩名称 * @param name 桩名称
* @return * @return
*/ */
List<Map<String, Object>> selectXhpcChargingPileList(@Param("name") String name, @Param("type") Integer type, @Param("serialNumber") String serialNumber, @Param("chargingStationId") Long chargingStationId); List<Map<String, Object>> 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);
/** /**
* 终端 * 终端

View File

@ -34,7 +34,7 @@ public interface XhpcChargingStationMapper {
* @param operatorName 运营商名称 * @param operatorName 运营商名称
* @return 电站集合 * @return 电站集合
*/ */
List<Map<String, Object>> selectXhpcChargingStationList(@Param("name") String name, @Param("operatorName") String operatorName); List<Map<String, Object>> 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); void updateXhpcTerminal(@Param("chargingStationId") Long chargingStationId,@Param("rateModelId") Long rateModelId);
/**
* 获取登陆用户信息
*/
Map<String, Object> getLandUser(@Param("userId") Long userId);
} }

View File

@ -3,6 +3,7 @@ package com.xhpc.charging.station.service;
import com.xhpc.common.api.dto.XhpcChargingStationDto; import com.xhpc.common.api.dto.XhpcChargingStationDto;
import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.domain.XhpcChargingStation; import com.xhpc.common.domain.XhpcChargingStation;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -215,4 +216,9 @@ public interface IXhpcChargingStationService {
*/ */
Integer editStationsStatus(List<Integer> chargingStationId, Integer pushStatus); Integer editStationsStatus(List<Integer> chargingStationId, Integer pushStatus);
/**
* 获取登陆用户信息
*/
Map<String, Object> getLandUser(Long userId);
} }

View File

@ -6,6 +6,7 @@ import com.xhpc.charging.station.mapper.XhpcImgMapper;
import com.xhpc.charging.station.mapper.XhpcTerminalMapper; import com.xhpc.charging.station.mapper.XhpcTerminalMapper;
import com.xhpc.charging.station.utils.img.QrImgUtils; import com.xhpc.charging.station.utils.img.QrImgUtils;
import com.xhpc.common.api.PowerPileService; 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.utils.StringUtils;
import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.domain.XhpcChargingPile; import com.xhpc.common.domain.XhpcChargingPile;
@ -62,7 +63,29 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService {
@Override @Override
public List<Map<String, Object>> selectXhpcChargingPileList(String name, Integer type, String serialNumber, Long chargingStationId) { public List<Map<String, Object>> selectXhpcChargingPileList(String name, Integer type, String serialNumber, Long chargingStationId) {
return xhpcChargingPileMapper.selectXhpcChargingPileList(name, type, serialNumber, chargingStationId); //获取登陆用户
Long userId = SecurityUtils.getUserId();
//桩的统计该时段金额
List<Map<String, Object>> list =new ArrayList<>();
if(userId !=1) {
Map<String, Object> 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 @Override

View File

@ -10,6 +10,7 @@ import com.xhpc.common.api.dto.XhpcRateDto;
import com.xhpc.common.api.dto.XhpcRateTimeDto; import com.xhpc.common.api.dto.XhpcRateTimeDto;
import com.xhpc.common.core.domain.R; import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.utils.DateUtils; 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.core.web.domain.AjaxResult;
import com.xhpc.common.data.redis.CacheRateModel; import com.xhpc.common.data.redis.CacheRateModel;
import com.xhpc.common.domain.XhpcChargingStation; import com.xhpc.common.domain.XhpcChargingStation;
@ -60,6 +61,12 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
return xhpcChargingStationPushStatusMapper.editStationsStatus(chargingStationIds, pushStatus); return xhpcChargingStationPushStatusMapper.editStationsStatus(chargingStationIds, pushStatus);
} }
@Override
public Map<String, Object> getLandUser(Long userId) {
return xhpcChargingStationMapper.getLandUser(userId);
}
/** /**
* 保存电站状态 * 保存电站状态
* *
@ -98,8 +105,28 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
*/ */
@Override @Override
public List<Map<String, Object>> selectXhpcChargingStationList(String name, String operatorName) { public List<Map<String, Object>> selectXhpcChargingStationList(String name, String operatorName) {
//获取登陆用户
Long userId = SecurityUtils.getUserId();
//桩的统计该时段金额 //桩的统计该时段金额
List<Map<String, Object>> list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName); List<Map<String, Object>> list =new ArrayList<>();
if(userId !=1) {
Map<String, Object> 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++) { for (int i = 0; i < list.size(); i++) {
Map<String, Object> map = list.get(i); Map<String, Object> map = list.get(i);
Long chargingStationId = Long.valueOf(map.get("chargingStationId").toString()); Long chargingStationId = Long.valueOf(map.get("chargingStationId").toString());

View File

@ -98,6 +98,12 @@
<if test="chargingStationId !=null and chargingStationId!=''"> <if test="chargingStationId !=null and chargingStationId!=''">
and cp.charging_station_id=#{chargingStationId} and cp.charging_station_id=#{chargingStationId}
</if> </if>
<if test="number !=0 and number ==1">
and cp.charging_station_id in(select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
</if>
<if test="number !=0 and number ==2">
and cp.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{operatorId})
</if>
order by cp.create_time desc order by cp.create_time desc
</select> </select>

View File

@ -82,6 +82,12 @@
<if test="operatorName !=null and operatorName !=''"> <if test="operatorName !=null and operatorName !=''">
and ope.name like CONCAT('%',#{operatorName},'%') and ope.name like CONCAT('%',#{operatorName},'%')
</if> </if>
<if test="type !=0 and type ==1">
and cs.charging_station_id in(select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
</if>
<if test="type !=0 and type ==2">
and cs.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{operatorId})
</if>
</select> </select>
@ -878,4 +884,9 @@
<update id="updateXhpcTerminal"> <update id="updateXhpcTerminal">
update xhpc_terminal set rate_model_id=#{rateModelId} WHERE charging_station_id=#{chargingStationId} update xhpc_terminal set rate_model_id=#{rateModelId} WHERE charging_station_id=#{chargingStationId}
</update> </update>
<select id="getLandUser" resultType="map">
select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId}
</select>
</mapper> </mapper>

View File

@ -381,6 +381,6 @@
<select id="getTerminal" resultType="String"> <select id="getTerminal" resultType="String">
select serial_number as serialNumber from xhpc_terminal where charging_station_id=#{chargingStationId} and status=#{status} select serial_number as serialNumber from xhpc_terminal where charging_station_id=#{chargingStationId} and status=#{status} and del_flag=2
</select> </select>
</mapper> </mapper>

View File

@ -107,4 +107,9 @@ public interface XhpcHistoryOrderMapper {
* *
*/ */
void updateXhpcHistoryOrder(@Param("historyOrderId")Long historyOrderId,@Param("state")Integer state); void updateXhpcHistoryOrder(@Param("historyOrderId")Long historyOrderId,@Param("state")Integer state);
/**
* 获取登陆用户信息
*/
Map<String, Object> getLandUser(@Param("userId")Long userId);
} }

View File

@ -90,4 +90,9 @@ public interface IXhpcHistoryOrderService {
*/ */
void addXhpcChargeOrder(String orderNo,Integer type); void addXhpcChargeOrder(String orderNo,Integer type);
/**
* 获取登陆用户信息
*/
Map<String, Object> getLandUser(Long userId);
} }

View File

@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.xhpc.common.api.SmsService; 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.core.web.domain.AjaxResult;
import com.xhpc.common.data.redis.CacheRealtimeData; import com.xhpc.common.data.redis.CacheRealtimeData;
import com.xhpc.common.redis.service.RedisService; import com.xhpc.common.redis.service.RedisService;
@ -82,7 +83,29 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService {
}else{ }else{
number =2; number =2;
} }
return xhpcHistoryOrderMapper.getListPage(phone,transactionNumber,status,chargingStationName,operatorId,source,startTime,endTime,userId,type,number); //获取登陆用户
Long logUserId = SecurityUtils.getUserId();
//桩的统计该时段金额
List<Map<String, Object>> list =new ArrayList<>();
if(userId !=1){
Map<String, Object> 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 @Override
@ -419,6 +442,12 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService {
} }
@Override
public Map<String, Object> getLandUser(Long userId) {
return xhpcHistoryOrderMapper.getLandUser(userId);
}
/** /**
* 历史信息费率时段 * 历史信息费率时段
*/ */

View File

@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.xhpc.common.api.SmsService; 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.core.web.domain.AjaxResult;
import com.xhpc.common.data.redis.CacheOrderData; import com.xhpc.common.data.redis.CacheOrderData;
import com.xhpc.common.data.redis.CacheRealtimeData; import com.xhpc.common.data.redis.CacheRealtimeData;
@ -60,6 +61,14 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
@Override @Override
public List<Map<String, Object>> list(String phone, String transactionNumber, Integer source, String chargingStationName, String terminalName, Long operatorId, String startTime, String endTime,Integer status,Long userId,Integer type) { public List<Map<String, Object>> 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<Map<String, Object>> list =new ArrayList<>();
//number 3 用户类型和电话都有 1 电话 2 用户类型
//type 1 平台 2 运营商 3流量方
Integer number=0; Integer number=0;
if(!"".equals(phone) && phone!=null && !"".equals(source) && source !=null){ if(!"".equals(phone) && phone!=null && !"".equals(source) && source !=null){
number =3; number =3;
@ -71,7 +80,25 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
if(type ==null || userId ==null){ if(type ==null || userId ==null){
return new ArrayList<>(); return new ArrayList<>();
} }
return xhpcRealTimeOrderMapper.list(phone,transactionNumber,source,chargingStationName,terminalName,operatorId,startTime,endTime,number,status,userId,type); if(userId !=1) {
Map<String, Object> 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 @Override

View File

@ -2,13 +2,15 @@ package com.xhpc.order.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.xhpc.common.core.utils.SecurityUtils;
import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.order.domain.XhpcStatisticsStation; import com.xhpc.order.domain.XhpcStatisticsStation;
import com.xhpc.order.domain.XhpcStatisticsTimeInterval; import com.xhpc.order.domain.XhpcStatisticsTimeInterval;
import com.xhpc.order.mapper.XhpcStatisticsServiceMapper; import com.xhpc.order.mapper.XhpcStatisticsServiceMapper;
import com.xhpc.order.service.IXhpcHistoryOrderService;
import com.xhpc.order.service.IXhpcStatisticsService; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -25,6 +27,8 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService {
@Autowired @Autowired
private XhpcStatisticsServiceMapper xhpcStatisticsServiceMapper; private XhpcStatisticsServiceMapper xhpcStatisticsServiceMapper;
@Autowired
private IXhpcHistoryOrderService xhpcHistoryOrderService;
@Override @Override
public List<Map<String, Object>> getTimeIntervalPage(String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type) { public List<Map<String, Object>> getTimeIntervalPage(String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type) {
if (getJudge(internetUserId, operatorId, type)){ if (getJudge(internetUserId, operatorId, type)){
@ -34,11 +38,26 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService {
if(!"".equals(chargingStationIds) && chargingStationIds !=null){ if(!"".equals(chargingStationIds) && chargingStationIds !=null){
chargingStationId= Arrays.asList(chargingStationIds.split(",")); chargingStationId= Arrays.asList(chargingStationIds.split(","));
} }
// if(("".equals(startTime) && "".equals(endTime)) ||(startTime==null && endTime==null)){ //获取登陆用户
// startTime =date(1); Long logUserId = SecurityUtils.getUserId();
// endTime =date(2); List<Map<String, Object>> list =new ArrayList<>();
// } if(userId !=1){
List<Map<String, Object>> list = xhpcStatisticsServiceMapper.getTimeIntervalPage(chargingStationId, internetUserId, operatorId, startTime, endTime, type,userId); Map<String, Object> 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<Map<String, Object>> page =new ArrayList<>(); List<Map<String, Object>> page =new ArrayList<>();
if(list !=null && list.size()>0){ if(list !=null && list.size()>0){
for (int i = 1; i <=24 ; i++) { for (int i = 1; i <=24 ; i++) {
@ -140,11 +159,29 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService {
if(!"".equals(chargingStationIds) && chargingStationIds !=null){ if(!"".equals(chargingStationIds) && chargingStationIds !=null){
chargingStationId= Arrays.asList(chargingStationIds.split(",")); chargingStationId= Arrays.asList(chargingStationIds.split(","));
} }
// if(("".equals(startTime) && "".equals(endTime)) ||(startTime==null && endTime==null)){
// startTime =date(1); //获取登陆用户
// endTime =date(2); Long logUserId = SecurityUtils.getUserId();
// } List<Map<String, Object>> list =new ArrayList<>();
return xhpcStatisticsServiceMapper.getDateIntervalPage(chargingStationId, internetUserId, operatorId, startTime, endTime, type,userId); if(userId !=1){
Map<String, Object> 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 @Override
@ -160,11 +197,30 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService {
if(!"".equals(operatorIds) && operatorIds !=null){ if(!"".equals(operatorIds) && operatorIds !=null){
operatorUserId= Arrays.asList(operatorIds.split(",")); operatorUserId= Arrays.asList(operatorIds.split(","));
} }
// if(("".equals(startTime) && "".equals(endTime)) ||(startTime==null && endTime==null)){
// startTime =date(1); //获取登陆用户
// endTime =date(2); Long logUserId = SecurityUtils.getUserId();
// } List<Map<String, Object>> list =new ArrayList<>();
return xhpcStatisticsServiceMapper.getStationIntervalPage(chargingStationId,operatorUserId,internetUserId,operatorId,startTime,endTime,type,userId); if(userId !=1){
Map<String, Object> 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 @Override
@ -176,11 +232,29 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService {
if(!"".equals(operatorIds) && operatorIds !=null){ if(!"".equals(operatorIds) && operatorIds !=null){
operatorUserId= Arrays.asList(operatorIds.split(",")); operatorUserId= Arrays.asList(operatorIds.split(","));
} }
// if(("".equals(startTime) && "".equals(endTime)) ||(startTime==null && endTime==null)){
// startTime =date(1); //获取登陆用户
// endTime =date(2); Long logUserId = SecurityUtils.getUserId();
// } List<Map<String, Object>> list =new ArrayList<>();
return xhpcStatisticsServiceMapper.getOperatorIntervalPage(operatorUserId, operatorId, startTime, endTime, type,userId); if(userId !=1){
Map<String, Object> 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 @Override
@ -204,22 +278,79 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService {
if(getJudge(null,operatorId,type)){ if(getJudge(null,operatorId,type)){
return new ArrayList<>(); return new ArrayList<>();
} }
// if(("".equals(startTime) && "".equals(endTime)) ||(startTime==null && endTime==null)){
// startTime =date(1); //获取登陆用户
// endTime =date(2); Long logUserId = SecurityUtils.getUserId();
// } List<Map<String, Object>> list =new ArrayList<>();
return xhpcStatisticsServiceMapper.getTerminalIntervalPage(chargingStationId, terminalId, operatorId, startTime, endTime, type,userId); if(userId !=1){
Map<String, Object> 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 @Override
public AjaxResult getChargingStationList(Long operatorId, Long userId, Integer type) { 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<String, Object> 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 @Override
public AjaxResult getOperatorList(Long operatorId, Long userId, Integer type) { 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<String, Object> 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 @Override
@ -230,7 +361,29 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService {
@Override @Override
public AjaxResult getTerminalList(Long chargingStationId, Long userId, Integer type) { 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<String, Object> 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 @Override
@ -317,54 +470,55 @@ public class XhpcStatisticsServiceImpl implements IXhpcStatisticsService {
export(out, titles, keys, data); export(out, titles, keys, data);
} }
@Override
public void export(ServletOutputStream out, String[] titles, String[] keys, List<Map<String, Object>> data) throws Exception { public void export(ServletOutputStream out, String[] titles, String[] keys, List<Map<String, Object>> data) throws Exception {
try { // try {
//Making the head. // //Making the head.
HSSFWorkbook workbook = new HSSFWorkbook(); // HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet hssfSheet = workbook.createSheet("sheet1"); // HSSFSheet hssfSheet = workbook.createSheet("sheet1");
HSSFRow row = hssfSheet.createRow(0); // HSSFRow row = hssfSheet.createRow(0);
HSSFCellStyle hssfCellStyle = workbook.createCellStyle(); // HSSFCellStyle hssfCellStyle = workbook.createCellStyle();
hssfCellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); // hssfCellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
hssfCellStyle.setFillForegroundColor(HSSFColor.SKY_BLUE.index); // hssfCellStyle.setFillForegroundColor(HSSFColor.SKY_BLUE.index);
hssfCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); // hssfCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
HSSFCell hssfCell; // HSSFCell hssfCell;
for (int i = 0; i < titles.length; i++) { // for (int i = 0; i < titles.length; i++) {
hssfCell = row.createCell(i); // hssfCell = row.createCell(i);
hssfCell.setCellValue(titles[i]); // hssfCell.setCellValue(titles[i]);
hssfCell.setCellStyle(hssfCellStyle); // hssfCell.setCellStyle(hssfCellStyle);
hssfSheet.setColumnWidth(i, hssfCell.getStringCellValue().getBytes().length * 256 + 200); // hssfSheet.setColumnWidth(i, hssfCell.getStringCellValue().getBytes().length * 256 + 200);
} // }
//
//Loading data. // //Loading data.
HSSFRow dataRow; // HSSFRow dataRow;
HSSFCell dataCell; // HSSFCell dataCell;
int valuesLength = keys.length; // int valuesLength = keys.length;
for (int i = 1; i <= data.size(); i++) { // for (int i = 1; i <= data.size(); i++) {
Map<String, Object> map = data.get(i - 1); // Map<String, Object> map = data.get(i - 1);
if (null != map) { // if (null != map) {
dataRow = hssfSheet.createRow(i); // dataRow = hssfSheet.createRow(i);
for (int j = 0; j < valuesLength; j++) { // for (int j = 0; j < valuesLength; j++) {
if (null != map.get(keys[j])) { // if (null != map.get(keys[j])) {
dataCell = dataRow.createCell(j); // dataCell = dataRow.createCell(j);
String s = String.valueOf(map.get(keys[j])); // String s = String.valueOf(map.get(keys[j]));
dataCell.setCellValue(s); // dataCell.setCellValue(s);
} // }
} // }
} // }
} // }
// Exporting to the client. // // Exporting to the client.
try { // try {
workbook.write(out); // workbook.write(out);
out.flush(); // out.flush();
out.close(); // out.close();
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
throw new Exception("导出信息失败!"); // throw new Exception("导出信息失败!");
} // }
} }

View File

@ -651,13 +651,13 @@
#{phone}, '%')) #{phone}, '%'))
</if> </if>
</if> </if>
<if test="status==2"> <if test="status==1">
and co.source =0 and co.source =0
and co.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId}) and co.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if> </if>
<if test="status==3"> <if test="status==2">
and co.source =1 and co.source =0
and co.user_id=#{userId} and co.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
</if> </if>
order by ho.create_time desc order by ho.create_time desc
</select> </select>
@ -787,4 +787,8 @@
<update id="updateXhpcHistoryOrder"> <update id="updateXhpcHistoryOrder">
update xhpc_history_order set state = #{state} where history_order_id=#{historyOrderId} update xhpc_history_order set state = #{state} where history_order_id=#{historyOrderId}
</update> </update>
<select id="getLandUser" resultType="map">
select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId}
</select>
</mapper> </mapper>

View File

@ -444,13 +444,13 @@
#{phone}, '%')) #{phone}, '%'))
</if> </if>
</if> </if>
<if test="type==2"> <if test="type==1">
and co.source =0 and co.source =0
and co.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId}) and co.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if> </if>
<if test="type==3"> <if test="type==2">
and co.source =1 and co.source =0
and co.user_id=#{userId} and co.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
</if> </if>
order by co.create_time desc order by co.create_time desc
</select> </select>

View File

@ -94,16 +94,11 @@
<if test="endTime !=null and endTime !=''"> <if test="endTime !=null and endTime !=''">
and create_time &lt;= #{endTime} and create_time &lt;= #{endTime}
</if> </if>
<if test="type==1">
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if>
<if test="type==2"> <if test="type==2">
and operator_id=#{operatorId} and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
</if>
<if test="type==3">
and internet_user_id=#{internetUserId}
</if>
<if test="type==1 and userId !=1">
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})
)
</if> </if>
group by status group by status
order by status order by status
@ -143,16 +138,11 @@
<if test="endTime !=null and endTime !=''"> <if test="endTime !=null and endTime !=''">
and create_time &lt;= #{endTime} and create_time &lt;= #{endTime}
</if> </if>
<if test="type==1">
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if>
<if test="type==2"> <if test="type==2">
and operator_id=#{operatorId} and internet_user_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
</if>
<if test="type==3">
and internet_user_id=#{internetUserId}
</if>
<if test="type==1 and userId !=1">
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})
)
</if> </if>
group by DATE_FORMAT(create_time,'%Y-%m-%d') group by DATE_FORMAT(create_time,'%Y-%m-%d')
order by DATE_FORMAT(create_time,'%Y-%m-%d') desc order by DATE_FORMAT(create_time,'%Y-%m-%d') desc
@ -189,11 +179,11 @@
<if test="endTime !=null and endTime !=''"> <if test="endTime !=null and endTime !=''">
and ss.create_time &lt;= #{endTime} and ss.create_time &lt;= #{endTime}
</if> </if>
<if test="type==2"> <if test="type==1">
and ss.operator_id=#{operatorId} and ss.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if> </if>
<if test="type==3"> <if test="type==2">
and ss.internet_user_id=#{internetUserId} and ss.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
</if> </if>
<if test="chargingStationIds !=null and chargingStationIds.size()>0"> <if test="chargingStationIds !=null and chargingStationIds.size()>0">
and ss.charging_station_id in and ss.charging_station_id in
@ -207,11 +197,6 @@
#{operatorId} #{operatorId}
</foreach> </foreach>
</if> </if>
<if test="type==1 and userId !=1">
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})
)
</if>
group by ss.charging_station_id group by ss.charging_station_id
</select> </select>
@ -250,18 +235,11 @@
#{operatorIds} #{operatorIds}
</foreach> </foreach>
</if> </if>
<if test="type==1">
and ss.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if>
<if test="type==2"> <if test="type==2">
<if test="operatorId !=null"> and ss.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
and ss.operator_id =#{operatorId}
</if>
</if>
<if test="type==3">
and ss.internet_user_id=#{internetUserId}
</if>
<if test="type==1 and userId !=1">
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})
)
</if> </if>
group by ss.operator_id group by ss.operator_id
</select> </select>
@ -338,19 +316,17 @@
<if test="endTime !=null and endTime !=''"> <if test="endTime !=null and endTime !=''">
and ss.create_time &lt;= #{endTime} and ss.create_time &lt;= #{endTime}
</if> </if>
<if test="type==2">
and ss.operator_id=#{operatorId}
</if>
<if test="chargingStationId !=null"> <if test="chargingStationId !=null">
and cs.charging_station_id=#{chargingStationId} and cs.charging_station_id=#{chargingStationId}
</if> </if>
<if test="terminalId !=null"> <if test="terminalId !=null">
and te.terminal_id=#{terminalId} and te.terminal_id=#{terminalId}
</if> </if>
<if test="type==1 and userId !=1"> <if test="type==1">
and operator_id in ( and ss.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
SELECT operator_id from xhpc_charging_station where charging_station_id in (SELECT charging_station_id FROM xhpc_user_privilege where user_id=#{userId}) </if>
) <if test="type==2">
and ss.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
</if> </if>
group by ss.terminal_id group by ss.terminal_id
</select> </select>
@ -361,11 +337,11 @@
charging_station_id as chargingStationId charging_station_id as chargingStationId
from xhpc_charging_station from xhpc_charging_station
where 1=1 where 1=1
<if test="type==2"> <if test="type==1">
and operator_id =#{operatorId} and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if> </if>
<if test="type==1 and userId !=1"> <if test="type==2">
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})
</if> </if>
</select> </select>
@ -376,13 +352,12 @@
name as operatorName name as operatorName
from xhpc_operator from xhpc_operator
where 1=1 where 1=1
<if test="type==2">
and operator_id =#{operatorId} <if test="type==1">
and operator_id in (select operator_id from xhpc_charging_station where operator_id=#{userId})
</if> </if>
<if test="type==1 and userId !=1"> <if test="type==2">
and operator_id in ( 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}))
SELECT operator_id from xhpc_charging_station where charging_station_id in (SELECT charging_station_id FROM xhpc_user_privilege where user_id=#{userId})
)
</if> </if>
</select> </select>
@ -403,9 +378,13 @@
name as terminalName name as terminalName
from xhpc_terminal from xhpc_terminal
where 1=1 where 1=1
<if test="chargingStationId !=null"> <if test="type==1">
and charging_station_id =#{chargingStationId} and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if> </if>
<if test="type==2">
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
</if>
</select> </select>
<insert id="addStatisticsTime"> <insert id="addStatisticsTime">

View File

@ -200,7 +200,7 @@
<select id="userSum" resultType="map"> <select id="userSum" resultType="map">
select select
count(xau.app_user_id) userSum, count(xau.app_user_id) userSum,
(select count(app_user_id) from xhpc_app_user where datediff(now(),create_time)>30) userVitality (select count(DISTINCT user_id) from xhpc_charge_order where datediff(now(),create_time)>30) userVitality
from xhpc_app_user xau from xhpc_app_user xau
LEFT JOIN (select count(1) count ,user_id from xhpc_charge_order where del_flag = 0 ) a on a.user_id = LEFT JOIN (select count(1) count ,user_id from xhpc_charge_order where del_flag = 0 ) a on a.user_id =
xau.app_user_id xau.app_user_id