From 0bc5a2b60824a003ddb98bd630a17cf0478366ab Mon Sep 17 00:00:00 2001 From: yuyang Date: Fri, 31 Dec 2021 15:36:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=BA=E7=AB=99=E5=88=97=E8=A1=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=97=A5=E5=BF=97=E5=92=8C=E7=A7=9F=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XhpcChargingStationController.java | 14 +++++++--- .../mapper/XhpcChargingStationMapper.java | 10 +++---- .../service/IXhpcChargingStationService.java | 3 ++- .../XhpcChargingStationServiceImpl.java | 27 ++++++++++++------- .../mapper/XhpcChargingStationMapper.xml | 11 +++++--- .../com/xhpc/common/util}/LogUserUtils.java | 2 +- .../com/xhpc/user/aspect/UserDaoAspect.java | 1 + .../service/impl/XhpcAppUserServiceImpl.java | 2 +- 8 files changed, 45 insertions(+), 25 deletions(-) rename xhpc-modules/{xhpc-user/src/main/java/com/xhpc/user/aspect => xhpc-common/src/main/java/com/xhpc/common/util}/LogUserUtils.java (96%) diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingStationController.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingStationController.java index a728d7d5..a7d2f176 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingStationController.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingStationController.java @@ -12,6 +12,7 @@ import com.xhpc.common.security.annotation.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; @@ -30,6 +31,7 @@ public class XhpcChargingStationController extends BaseController { @Autowired private IXhpcChargingStationService xhpcChargingStationService; + @Log(title = "充电站状态编辑", businessType = BusinessType.UPDATE) @PostMapping("/editStationStatus") public AjaxResult editStationStatus(@RequestBody Map map) { @@ -41,6 +43,7 @@ public class XhpcChargingStationController extends BaseController { return AjaxResult.success("充电站状态编辑成功", null); } + @Log(title = "充电站状态保存", businessType = BusinessType.UPDATE) @PostMapping("/saveStationStatus") public AjaxResult saveStationStatus(@RequestBody Map map) { @@ -67,10 +70,9 @@ public class XhpcChargingStationController extends BaseController { */ //@PreAuthorize(hasPermi = "system:station:list") @GetMapping("/list") - public TableDataInfo list(String name, String operatorName) { - + public TableDataInfo list(HttpServletRequest request,String name, String operatorName) { startPage(); - List> list = xhpcChargingStationService.selectXhpcChargingStationList(name, operatorName); + List> list = xhpcChargingStationService.selectXhpcChargingStationList(request,name, operatorName); return getDataTable(list); } @@ -123,6 +125,7 @@ public class XhpcChargingStationController extends BaseController { */ //@PreAuthorize(hasPermi = "system:station:remove") //@Log(title = "电站", businessType = BusinessType.DELETE) + @Log(title = "删除电站", businessType = BusinessType.DELETE) @DeleteMapping("/{chargingStationIds}") public AjaxResult remove(@PathVariable Long chargingStationIds) { @@ -134,6 +137,7 @@ public class XhpcChargingStationController extends BaseController { */ //@PreAuthorize(hasPermi = "system:station:remove") //@Log(title = "电站", businessType = BusinessType.DELETE) + @Log(title = "电站状态改变", businessType = BusinessType.UPDATE) @PostMapping("/status") public AjaxResult status(@RequestBody XhpcChargingStation xhpcChargingStation) { @@ -147,6 +151,7 @@ public class XhpcChargingStationController extends BaseController { */ //@PreAuthorize(hasPermi = "system:station:remove") //@Log(title = "电站", businessType = BusinessType.DELETE) + @Log(title = "APP端、小程序是否可见", businessType = BusinessType.UPDATE) @PostMapping("/clientVisible") public AjaxResult clientVisible(@RequestBody XhpcChargingStation xhpcChargingStation) { @@ -172,6 +177,7 @@ public class XhpcChargingStationController extends BaseController { * @param xhpcChargingStationDto * @return */ + @Log(title = "添加场站", businessType = BusinessType.INSERT) @PostMapping(value = "/addXhpcChargingStation") public AjaxResult addXhpcChargingStation(@RequestBody XhpcChargingStationDto xhpcChargingStationDto) { @@ -196,6 +202,7 @@ public class XhpcChargingStationController extends BaseController { * * @return */ + @Log(title = "编辑电站(基本信息)", businessType = BusinessType.UPDATE) @PostMapping(value = "/updateXhpcTerminal") public AjaxResult updateXhpcTerminal(@RequestBody XhpcChargingStation xhpcChargingStation) { @@ -207,6 +214,7 @@ public class XhpcChargingStationController extends BaseController { * * @return */ + @Log(title = "编辑电站(编辑费率)", businessType = BusinessType.UPDATE) @PostMapping(value = "/updateXhpcRateTime") public AjaxResult updateXhpcRateTime(@RequestBody XhpcChargingStationDto xhpcChargingStationDto) { 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 372e92d5..a4165cd2 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 @@ -43,7 +43,7 @@ public interface XhpcChargingStationMapper { * @param operatorName 运营商名称 * @return 电站集合 */ - List> selectXhpcChargingStationList(@Param("name") String name, @Param("operatorName") String operatorName,@Param("operatorId")Long operatorId,@Param("type")Integer type); + List> 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); } 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 0dbcb977..8a6b4d1e 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 @@ -5,6 +5,7 @@ import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.domain.XhpcChargingStation; import org.apache.ibatis.annotations.Param; +import javax.servlet.http.HttpServletRequest; import java.util.List; import java.util.Map; @@ -51,7 +52,7 @@ public interface IXhpcChargingStationService { * @param operatorName 运营商名称 * @return 电站集合 */ - List> selectXhpcChargingStationList(String name, String operatorName); + List> selectXhpcChargingStationList(HttpServletRequest request, String name, String operatorName); /** * 新增电站 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 a8c8909a..2e5b4ba0 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 @@ -18,6 +18,8 @@ import com.xhpc.common.domain.XhpcRate; import com.xhpc.common.domain.XhpcRateModel; import com.xhpc.common.domain.XhpcRateTime; 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.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -26,6 +28,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; +import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.*; import java.util.regex.Matcher; @@ -51,6 +54,8 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi @Autowired private RedisService redisService; @Autowired + private LogUserUtils logUserUtils; + @Autowired private XhpcChargingStationPushStatusMapper xhpcChargingStationPushStatusMapper; private static final Logger logger = LoggerFactory.getLogger(XhpcChargingStationServiceImpl.class); @@ -117,11 +122,13 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi * @return 电站 */ @Override - public List> selectXhpcChargingStationList(String name, String operatorName) { + public List> selectXhpcChargingStationList(HttpServletRequest request, String name, String operatorName) { //获取登陆用户 Long userId = SecurityUtils.getUserId(); //桩的统计、该时段金额 List> list =new ArrayList<>(); + LoginUser logUser = logUserUtils.getLogUser(request); + String tenantId = logUser.getTenantId(); if(userId !=1) { Map landUser = xhpcChargingStationMapper.getLandUser(userId); 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())){ Long operatorId = Long.valueOf(landUser.get("operatorId").toString()); //运营商看自己的场站 - list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,operatorId,1); + list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,operatorId,1,tenantId); }else{ //查询赋值的场站 - list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,userId,2); + list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,userId,2,tenantId); } } } }else{ - list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,userId,0); + list = xhpcChargingStationMapper.selectXhpcChargingStationList(name, operatorName,userId,0,tenantId); } for (int i = 0; i < list.size(); i++) { @@ -385,7 +392,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi //添加费率计费模型 XhpcRateModel xhpcRateModel = new XhpcRateModel(); BeanUtils.copyProperties(xhpcChargingStationDto, xhpcRateModel); - int i = xhpcChargingStationMapper.addXhpcRateModel(xhpcRateModel); + int i = xhpcChargingStationMapper.insertXhpcRateModel(xhpcRateModel); if (i == 0) { return AjaxResult.error("1005", "费率计费模型添加失败"); } @@ -395,7 +402,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi XhpcChargingStation xhpcChargingStation = new XhpcChargingStation(); BeanUtils.copyProperties(xhpcChargingStationDto, xhpcChargingStation); xhpcChargingStation.setRateModelId(rateModelId); - int j = xhpcChargingStationMapper.addXhpcChargingStation(xhpcChargingStation); + int j = xhpcChargingStationMapper.insertxhpcChargingStation(xhpcChargingStation); if (j == 0) { return AjaxResult.error("1006", "电站基本信息添加失败"); } @@ -425,7 +432,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi xhpcRate.setServiceFee(xhpcRateDto.getServiceFee()); xhpcRate.setRateModelId(rateModelId); xhpcRate.setRateValue(xhpcRateDto.getId()); - xhpcChargingStationMapper.addXhpcRate(xhpcRate); + xhpcChargingStationMapper.insertXhpcRate(xhpcRate); map.put(xhpcRateDto.getId(), xhpcRate.getRateId()); }else{ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); @@ -602,7 +609,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi Map landUser = xhpcChargingStationMapper.getLandUser(logUserId); if(landUser !=null){ 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(); BeanUtils.copyProperties(xhpcChargingStationDto, xhpcRateModel); xhpcRateModel.setRemark("修改"); - int i = xhpcChargingStationMapper.addXhpcRateModel(xhpcRateModel); + int i = xhpcChargingStationMapper.insertXhpcRateModel(xhpcRateModel); if (i == 0) { return AjaxResult.error("1005", "费率计费模型添加失败"); } @@ -922,7 +929,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi xhpcRate.setServiceFee(xhpcRateDto.getServiceFee()); xhpcRate.setRateModelId(rateModelId); xhpcRate.setRateValue(xhpcRateDto.getId()); - xhpcChargingStationMapper.addXhpcRate(xhpcRate); + xhpcChargingStationMapper.insertXhpcRate(xhpcRate); map.put(xhpcRateDto.getId(), xhpcRate.getRateId()); }else{ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 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 6b82386c..fd99a605 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 @@ -88,6 +88,9 @@ and cs.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{operatorId}) + + and tenant_id=#{tenantId} + @@ -395,7 +398,7 @@ and te.del_flag = 0 - insert into xhpc_rate_model @@ -446,7 +449,7 @@ - insert into xhpc_charging_station @@ -629,7 +632,7 @@ - insert into xhpc_rate @@ -890,7 +893,7 @@ select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId} - + insert into xhpc_user_privilege( user_id, diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/LogUserUtils.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/LogUserUtils.java similarity index 96% rename from xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/LogUserUtils.java rename to xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/LogUserUtils.java index be61b47a..61eef6da 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/LogUserUtils.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/LogUserUtils.java @@ -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.redis.service.RedisService; diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/UserDaoAspect.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/UserDaoAspect.java index a4e76cdd..c63e46d4 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/UserDaoAspect.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/UserDaoAspect.java @@ -3,6 +3,7 @@ package com.xhpc.user.aspect; import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.utils.StringUtils; +import com.xhpc.common.util.LogUserUtils; import com.xhpc.system.api.model.LoginUser; import org.apache.commons.beanutils.BeanUtils; import org.aspectj.lang.ProceedingJoinPoint; diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java index b750fabb..1e228198 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java @@ -16,7 +16,7 @@ import com.xhpc.common.security.service.TokenService; import com.xhpc.common.util.UserTypeUtil; import com.xhpc.system.api.domain.SysUser; 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.mapper.XhpcAppUserMapper; import com.xhpc.user.service.IXhpcAppUserUserService;