场站列表增加日志和租户

This commit is contained in:
yuyang 2021-12-31 15:36:54 +08:00
parent 883b1730c9
commit 0bc5a2b608
8 changed files with 45 additions and 25 deletions

View File

@ -12,6 +12,7 @@ import com.xhpc.common.security.annotation.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -30,6 +31,7 @@ public class XhpcChargingStationController extends BaseController {
@Autowired @Autowired
private IXhpcChargingStationService xhpcChargingStationService; private IXhpcChargingStationService xhpcChargingStationService;
@Log(title = "充电站状态编辑", businessType = BusinessType.UPDATE)
@PostMapping("/editStationStatus") @PostMapping("/editStationStatus")
public AjaxResult editStationStatus(@RequestBody Map<String, Object> map) { public AjaxResult editStationStatus(@RequestBody Map<String, Object> map) {
@ -41,6 +43,7 @@ public class XhpcChargingStationController extends BaseController {
return AjaxResult.success("充电站状态编辑成功", null); return AjaxResult.success("充电站状态编辑成功", null);
} }
@Log(title = "充电站状态保存", businessType = BusinessType.UPDATE)
@PostMapping("/saveStationStatus") @PostMapping("/saveStationStatus")
public AjaxResult saveStationStatus(@RequestBody Map<String, Object> map) { public AjaxResult saveStationStatus(@RequestBody Map<String, Object> map) {
@ -67,10 +70,9 @@ public class XhpcChargingStationController extends BaseController {
*/ */
//@PreAuthorize(hasPermi = "system:station:list") //@PreAuthorize(hasPermi = "system:station:list")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(String name, String operatorName) { public TableDataInfo list(HttpServletRequest request,String name, String operatorName) {
startPage(); startPage();
List<Map<String, Object>> list = xhpcChargingStationService.selectXhpcChargingStationList(name, operatorName); List<Map<String, Object>> list = xhpcChargingStationService.selectXhpcChargingStationList(request,name, operatorName);
return getDataTable(list); return getDataTable(list);
} }
@ -123,6 +125,7 @@ public class XhpcChargingStationController extends BaseController {
*/ */
//@PreAuthorize(hasPermi = "system:station:remove") //@PreAuthorize(hasPermi = "system:station:remove")
//@Log(title = "电站", businessType = BusinessType.DELETE) //@Log(title = "电站", businessType = BusinessType.DELETE)
@Log(title = "删除电站", businessType = BusinessType.DELETE)
@DeleteMapping("/{chargingStationIds}") @DeleteMapping("/{chargingStationIds}")
public AjaxResult remove(@PathVariable Long chargingStationIds) { public AjaxResult remove(@PathVariable Long chargingStationIds) {
@ -134,6 +137,7 @@ public class XhpcChargingStationController extends BaseController {
*/ */
//@PreAuthorize(hasPermi = "system:station:remove") //@PreAuthorize(hasPermi = "system:station:remove")
//@Log(title = "电站", businessType = BusinessType.DELETE) //@Log(title = "电站", businessType = BusinessType.DELETE)
@Log(title = "电站状态改变", businessType = BusinessType.UPDATE)
@PostMapping("/status") @PostMapping("/status")
public AjaxResult status(@RequestBody XhpcChargingStation xhpcChargingStation) { public AjaxResult status(@RequestBody XhpcChargingStation xhpcChargingStation) {
@ -147,6 +151,7 @@ public class XhpcChargingStationController extends BaseController {
*/ */
//@PreAuthorize(hasPermi = "system:station:remove") //@PreAuthorize(hasPermi = "system:station:remove")
//@Log(title = "电站", businessType = BusinessType.DELETE) //@Log(title = "电站", businessType = BusinessType.DELETE)
@Log(title = "APP端、小程序是否可见", businessType = BusinessType.UPDATE)
@PostMapping("/clientVisible") @PostMapping("/clientVisible")
public AjaxResult clientVisible(@RequestBody XhpcChargingStation xhpcChargingStation) { public AjaxResult clientVisible(@RequestBody XhpcChargingStation xhpcChargingStation) {
@ -172,6 +177,7 @@ public class XhpcChargingStationController extends BaseController {
* @param xhpcChargingStationDto * @param xhpcChargingStationDto
* @return * @return
*/ */
@Log(title = "添加场站", businessType = BusinessType.INSERT)
@PostMapping(value = "/addXhpcChargingStation") @PostMapping(value = "/addXhpcChargingStation")
public AjaxResult addXhpcChargingStation(@RequestBody XhpcChargingStationDto xhpcChargingStationDto) { public AjaxResult addXhpcChargingStation(@RequestBody XhpcChargingStationDto xhpcChargingStationDto) {
@ -196,6 +202,7 @@ public class XhpcChargingStationController extends BaseController {
* *
* @return * @return
*/ */
@Log(title = "编辑电站(基本信息)", businessType = BusinessType.UPDATE)
@PostMapping(value = "/updateXhpcTerminal") @PostMapping(value = "/updateXhpcTerminal")
public AjaxResult updateXhpcTerminal(@RequestBody XhpcChargingStation xhpcChargingStation) { public AjaxResult updateXhpcTerminal(@RequestBody XhpcChargingStation xhpcChargingStation) {
@ -207,6 +214,7 @@ public class XhpcChargingStationController extends BaseController {
* *
* @return * @return
*/ */
@Log(title = "编辑电站(编辑费率)", businessType = BusinessType.UPDATE)
@PostMapping(value = "/updateXhpcRateTime") @PostMapping(value = "/updateXhpcRateTime")
public AjaxResult updateXhpcRateTime(@RequestBody XhpcChargingStationDto xhpcChargingStationDto) { public AjaxResult updateXhpcRateTime(@RequestBody XhpcChargingStationDto xhpcChargingStationDto) {

View File

@ -43,7 +43,7 @@ public interface XhpcChargingStationMapper {
* @param operatorName 运营商名称 * @param operatorName 运营商名称
* @return 电站集合 * @return 电站集合
*/ */
List<Map<String, Object>> selectXhpcChargingStationList(@Param("name") String name, @Param("operatorName") String operatorName,@Param("operatorId")Long operatorId,@Param("type")Integer type); List<Map<String, Object>> selectXhpcChargingStationList(@Param("name") String name, @Param("operatorName") String operatorName,@Param("operatorId")Long operatorId,@Param("type")Integer type,@Param("tenantId")String tenantId);
/** /**
* 新增电站 * 新增电站
@ -175,17 +175,17 @@ public interface XhpcChargingStationMapper {
/** /**
* 添加费率模型 * 添加费率模型
*/ */
int addXhpcRateModel(XhpcRateModel xhpcRateModel); int insertXhpcRateModel(XhpcRateModel xhpcRateModel);
/** /**
* 添加场站信息 * 添加场站信息
*/ */
int addXhpcChargingStation(XhpcChargingStation xhpcChargingStation); int insertxhpcChargingStation(XhpcChargingStation xhpcChargingStation);
/** /**
* 添加费率 * 添加费率
*/ */
int addXhpcRate(XhpcRate xhpcRate); int insertXhpcRate(XhpcRate xhpcRate);
/** /**
@ -264,6 +264,6 @@ public interface XhpcChargingStationMapper {
/** /**
* 添加场站数据权限 * 添加场站数据权限
*/ */
void addXhpcUserPrivilege(@Param("userId") Long userId,@Param("chargingStationId") Long chargingStationId); void insertXhpcUserPrivilege(@Param("userId") Long userId,@Param("chargingStationId") Long chargingStationId);
} }

View File

@ -5,6 +5,7 @@ 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 org.apache.ibatis.annotations.Param;
import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -51,7 +52,7 @@ public interface IXhpcChargingStationService {
* @param operatorName 运营商名称 * @param operatorName 运营商名称
* @return 电站集合 * @return 电站集合
*/ */
List<Map<String, Object>> selectXhpcChargingStationList(String name, String operatorName); List<Map<String, Object>> selectXhpcChargingStationList(HttpServletRequest request, String name, String operatorName);
/** /**
* 新增电站 * 新增电站

View File

@ -18,6 +18,8 @@ import com.xhpc.common.domain.XhpcRate;
import com.xhpc.common.domain.XhpcRateModel; import com.xhpc.common.domain.XhpcRateModel;
import com.xhpc.common.domain.XhpcRateTime; import com.xhpc.common.domain.XhpcRateTime;
import com.xhpc.common.redis.service.RedisService; import com.xhpc.common.redis.service.RedisService;
import com.xhpc.common.util.LogUserUtils;
import com.xhpc.system.api.model.LoginUser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -26,6 +28,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -51,6 +54,8 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
@Autowired @Autowired
private RedisService redisService; private RedisService redisService;
@Autowired @Autowired
private LogUserUtils logUserUtils;
@Autowired
private XhpcChargingStationPushStatusMapper xhpcChargingStationPushStatusMapper; private XhpcChargingStationPushStatusMapper xhpcChargingStationPushStatusMapper;
private static final Logger logger = LoggerFactory.getLogger(XhpcChargingStationServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(XhpcChargingStationServiceImpl.class);
@ -117,11 +122,13 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
* @return 电站 * @return 电站
*/ */
@Override @Override
public List<Map<String, Object>> selectXhpcChargingStationList(String name, String operatorName) { public List<Map<String, Object>> selectXhpcChargingStationList(HttpServletRequest request, String name, String operatorName) {
//获取登陆用户 //获取登陆用户
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
//桩的统计该时段金额 //桩的统计该时段金额
List<Map<String, Object>> list =new ArrayList<>(); List<Map<String, Object>> list =new ArrayList<>();
LoginUser logUser = logUserUtils.getLogUser(request);
String tenantId = logUser.getTenantId();
if(userId !=1) { if(userId !=1) {
Map<String, Object> landUser = xhpcChargingStationMapper.getLandUser(userId); Map<String, Object> landUser = xhpcChargingStationMapper.getLandUser(userId);
if(landUser !=null){ if(landUser !=null){
@ -129,15 +136,15 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
if("01".equals(landUser.get("userType").toString()) || "03".equals(landUser.get("userType").toString())){ if("01".equals(landUser.get("userType").toString()) || "03".equals(landUser.get("userType").toString())){
Long operatorId = Long.valueOf(landUser.get("operatorId").toString()); Long operatorId = Long.valueOf(landUser.get("operatorId").toString());
//运营商看自己的场站 //运营商看自己的场站
list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,operatorId,1); list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,operatorId,1,tenantId);
}else{ }else{
//查询赋值的场站 //查询赋值的场站
list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,userId,2); list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,userId,2,tenantId);
} }
} }
} }
}else{ }else{
list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,userId,0); list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,userId,0,tenantId);
} }
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
@ -385,7 +392,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
//添加费率计费模型 //添加费率计费模型
XhpcRateModel xhpcRateModel = new XhpcRateModel(); XhpcRateModel xhpcRateModel = new XhpcRateModel();
BeanUtils.copyProperties(xhpcChargingStationDto, xhpcRateModel); BeanUtils.copyProperties(xhpcChargingStationDto, xhpcRateModel);
int i = xhpcChargingStationMapper.addXhpcRateModel(xhpcRateModel); int i = xhpcChargingStationMapper.insertXhpcRateModel(xhpcRateModel);
if (i == 0) { if (i == 0) {
return AjaxResult.error("1005", "费率计费模型添加失败"); return AjaxResult.error("1005", "费率计费模型添加失败");
} }
@ -395,7 +402,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
XhpcChargingStation xhpcChargingStation = new XhpcChargingStation(); XhpcChargingStation xhpcChargingStation = new XhpcChargingStation();
BeanUtils.copyProperties(xhpcChargingStationDto, xhpcChargingStation); BeanUtils.copyProperties(xhpcChargingStationDto, xhpcChargingStation);
xhpcChargingStation.setRateModelId(rateModelId); xhpcChargingStation.setRateModelId(rateModelId);
int j = xhpcChargingStationMapper.addXhpcChargingStation(xhpcChargingStation); int j = xhpcChargingStationMapper.insertxhpcChargingStation(xhpcChargingStation);
if (j == 0) { if (j == 0) {
return AjaxResult.error("1006", "电站基本信息添加失败"); return AjaxResult.error("1006", "电站基本信息添加失败");
} }
@ -425,7 +432,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
xhpcRate.setServiceFee(xhpcRateDto.getServiceFee()); xhpcRate.setServiceFee(xhpcRateDto.getServiceFee());
xhpcRate.setRateModelId(rateModelId); xhpcRate.setRateModelId(rateModelId);
xhpcRate.setRateValue(xhpcRateDto.getId()); xhpcRate.setRateValue(xhpcRateDto.getId());
xhpcChargingStationMapper.addXhpcRate(xhpcRate); xhpcChargingStationMapper.insertXhpcRate(xhpcRate);
map.put(xhpcRateDto.getId(), xhpcRate.getRateId()); map.put(xhpcRateDto.getId(), xhpcRate.getRateId());
}else{ }else{
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@ -602,7 +609,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
Map<String, Object> landUser = xhpcChargingStationMapper.getLandUser(logUserId); Map<String, Object> landUser = xhpcChargingStationMapper.getLandUser(logUserId);
if(landUser !=null){ if(landUser !=null){
if(landUser.get("userType") !=null && "02".equals(landUser.get("userType").toString())){ if(landUser.get("userType") !=null && "02".equals(landUser.get("userType").toString())){
xhpcChargingStationMapper.addXhpcUserPrivilege(logUserId,chargingStationId); xhpcChargingStationMapper.insertXhpcUserPrivilege(logUserId,chargingStationId);
} }
} }
} }
@ -892,7 +899,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
XhpcRateModel xhpcRateModel = new XhpcRateModel(); XhpcRateModel xhpcRateModel = new XhpcRateModel();
BeanUtils.copyProperties(xhpcChargingStationDto, xhpcRateModel); BeanUtils.copyProperties(xhpcChargingStationDto, xhpcRateModel);
xhpcRateModel.setRemark("修改"); xhpcRateModel.setRemark("修改");
int i = xhpcChargingStationMapper.addXhpcRateModel(xhpcRateModel); int i = xhpcChargingStationMapper.insertXhpcRateModel(xhpcRateModel);
if (i == 0) { if (i == 0) {
return AjaxResult.error("1005", "费率计费模型添加失败"); return AjaxResult.error("1005", "费率计费模型添加失败");
} }
@ -922,7 +929,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
xhpcRate.setServiceFee(xhpcRateDto.getServiceFee()); xhpcRate.setServiceFee(xhpcRateDto.getServiceFee());
xhpcRate.setRateModelId(rateModelId); xhpcRate.setRateModelId(rateModelId);
xhpcRate.setRateValue(xhpcRateDto.getId()); xhpcRate.setRateValue(xhpcRateDto.getId());
xhpcChargingStationMapper.addXhpcRate(xhpcRate); xhpcChargingStationMapper.insertXhpcRate(xhpcRate);
map.put(xhpcRateDto.getId(), xhpcRate.getRateId()); map.put(xhpcRateDto.getId(), xhpcRate.getRateId());
}else{ }else{
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

View File

@ -88,6 +88,9 @@
<if test="type ==2"> <if test="type ==2">
and cs.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{operatorId}) and cs.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{operatorId})
</if> </if>
<if test="tenantId !=null and tenantId !=''">
and tenant_id=#{tenantId}
</if>
</select> </select>
@ -395,7 +398,7 @@
and te.del_flag = 0 and te.del_flag = 0
</select> </select>
<insert id="addXhpcRateModel" parameterType="com.xhpc.common.domain.XhpcRateModel" useGeneratedKeys="true" <insert id="insertXhpcRateModel" parameterType="com.xhpc.common.domain.XhpcRateModel" useGeneratedKeys="true"
keyProperty="rateModelId"> keyProperty="rateModelId">
insert into xhpc_rate_model insert into xhpc_rate_model
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@ -446,7 +449,7 @@
</trim> </trim>
</insert> </insert>
<insert id="addXhpcChargingStation" parameterType="com.xhpc.common.domain.XhpcChargingStation" <insert id="insertxhpcChargingStation" parameterType="com.xhpc.common.domain.XhpcChargingStation"
useGeneratedKeys="true" keyProperty="chargingStationId"> useGeneratedKeys="true" keyProperty="chargingStationId">
insert into xhpc_charging_station insert into xhpc_charging_station
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@ -629,7 +632,7 @@
</trim> </trim>
</insert> </insert>
<insert id="addXhpcRate" parameterType="com.xhpc.common.domain.XhpcRate" useGeneratedKeys="true" <insert id="insertXhpcRate" parameterType="com.xhpc.common.domain.XhpcRate" useGeneratedKeys="true"
keyProperty="rateId"> keyProperty="rateId">
insert into xhpc_rate insert into xhpc_rate
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@ -890,7 +893,7 @@
select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId} select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId}
</select> </select>
<insert id="addXhpcUserPrivilege"> <insert id="insertXhpcUserPrivilege">
insert into xhpc_user_privilege( insert into xhpc_user_privilege(
<if test="null != userId and '' != userId"> <if test="null != userId and '' != userId">
user_id, user_id,

View File

@ -1,4 +1,4 @@
package com.xhpc.user.aspect; package com.xhpc.common.util;
import com.xhpc.common.core.constant.CacheConstants; import com.xhpc.common.core.constant.CacheConstants;
import com.xhpc.common.redis.service.RedisService; import com.xhpc.common.redis.service.RedisService;

View File

@ -3,6 +3,7 @@ package com.xhpc.user.aspect;
import com.xhpc.common.core.utils.SecurityUtils; 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.util.LogUserUtils;
import com.xhpc.system.api.model.LoginUser; import com.xhpc.system.api.model.LoginUser;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;

View File

@ -16,7 +16,7 @@ import com.xhpc.common.security.service.TokenService;
import com.xhpc.common.util.UserTypeUtil; import com.xhpc.common.util.UserTypeUtil;
import com.xhpc.system.api.domain.SysUser; import com.xhpc.system.api.domain.SysUser;
import com.xhpc.system.api.model.LoginUser; import com.xhpc.system.api.model.LoginUser;
import com.xhpc.user.aspect.LogUserUtils; import com.xhpc.common.util.LogUserUtils;
import com.xhpc.user.domain.XhpcAppUser; import com.xhpc.user.domain.XhpcAppUser;
import com.xhpc.user.mapper.XhpcAppUserMapper; import com.xhpc.user.mapper.XhpcAppUserMapper;
import com.xhpc.user.service.IXhpcAppUserUserService; import com.xhpc.user.service.IXhpcAppUserUserService;