From ea418a7cfac14a09c28ac4531e1a472b9eb0294c Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Fri, 3 Jun 2022 18:52:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9F=AD=E4=BF=A1=E5=8F=91?= =?UTF-8?q?=E9=80=81=E7=AD=96=E7=95=A5=EF=BC=9A=201=E3=80=81=E8=A2=AB?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=9A=84=E7=94=A8=E6=88=B7=E4=B8=8D=E5=8F=91?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=202=E3=80=81=E8=A2=AB=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E7=94=A8=E6=88=B7=E4=B8=8D=E5=8F=91=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=203=E3=80=81=E5=85=B3=E6=8E=89=E5=BC=80=E5=85=B3=E7=9A=84?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=8D=E5=8F=91=E7=9F=AD=E4=BF=A1=204?= =?UTF-8?q?=E3=80=81=E8=BF=87=E6=9C=9F=E7=94=A8=E6=88=B7=E4=B8=8D=E5=8F=91?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=205=E3=80=81=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=8D=E5=8F=91=E7=9F=AD=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/controller/FirePointController.java | 4 --- .../xkrs/controller/SettingController.java | 4 +++ .../com/xkrs/dao/RelRoleAuthorityDao.java | 10 ++++-- .../java/com/xkrs/dao/RelUserRoleDao.java | 4 ++- .../service/impl/FirePointServiceImpl.java | 32 +++++++++++++++++-- 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index 3e15102..96c2125 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -2,7 +2,6 @@ package com.xkrs.controller; import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.common.tool.TokenUtil; -import com.xkrs.dao.CountyCodeWeiXinDao; import com.xkrs.dao.FirePointDao; import com.xkrs.dao.ShanDongFirePointDao; import com.xkrs.dao.SysUserDao; @@ -58,9 +57,6 @@ public class FirePointController { @Resource private StreetService streetService; - @Resource - private CountyCodeWeiXinDao countyCodeWeiXinDao; - /** * 添加火点数据 * diff --git a/src/main/java/com/xkrs/controller/SettingController.java b/src/main/java/com/xkrs/controller/SettingController.java index 7ec1074..3da73d5 100644 --- a/src/main/java/com/xkrs/controller/SettingController.java +++ b/src/main/java/com/xkrs/controller/SettingController.java @@ -1,6 +1,7 @@ package com.xkrs.controller; import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.dao.CountyCodeWeiXinDao; import com.xkrs.dao.SettingDao; import com.xkrs.model.entity.SettingEntity; import com.xkrs.model.qo.SettingQo; @@ -27,6 +28,9 @@ public class SettingController { @Resource private SettingDao settingDao; + @Resource + private CountyCodeWeiXinDao countyCodeWeiXinDao; + @Transactional(rollbackOn = Exception.class) @PostMapping("/updateswitchstate") public String updateSwitchState(@RequestBody SettingQo settingQo) { diff --git a/src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java b/src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java index 087c926..2fdd208 100644 --- a/src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java +++ b/src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java @@ -2,6 +2,7 @@ package com.xkrs.dao; import com.xkrs.model.entity.RelRoleAuthorityEntity; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -10,13 +11,18 @@ import java.util.List; /** * @author XinYi Song */ -public interface RelRoleAuthorityDao extends JpaRepository { +public interface RelRoleAuthorityDao extends JpaRepository, JpaSpecificationExecutor { /** * 根据userId查询出权限的id + * * @param userId * @return */ - @Query(value = "select authority_id from rel_role_authority where user_id = ?",nativeQuery = true) + @Query(value = "select authority_id from rel_role_authority where user_id = ?", nativeQuery = true) List selectAuthorityByUserId(@Param("userId") Integer userId); + + @Query(value = "SELECT * FROM rel_role_authority WHERE authority_id = ?1", nativeQuery = true) + List selectByAuthorityId(Integer authorityId); + } diff --git a/src/main/java/com/xkrs/dao/RelUserRoleDao.java b/src/main/java/com/xkrs/dao/RelUserRoleDao.java index ebd8e96..ca164c4 100644 --- a/src/main/java/com/xkrs/dao/RelUserRoleDao.java +++ b/src/main/java/com/xkrs/dao/RelUserRoleDao.java @@ -2,9 +2,11 @@ package com.xkrs.dao; import com.xkrs.model.entity.RelUserRoleEntity; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; /** * @author XinYi Song */ -public interface RelUserRoleDao extends JpaRepository { +public interface RelUserRoleDao extends JpaRepository, JpaSpecificationExecutor { + } diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 3b6f415..ad9f871 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -95,6 +95,9 @@ public class FirePointServiceImpl implements FirePointService { @Resource private CountyCodeWeiXinDao countyCodeWeiXinDao; + @Resource + private RelRoleAuthorityDao relRoleAuthorityDao; + /** * 添加火点信息 * @@ -383,17 +386,27 @@ public class FirePointServiceImpl implements FirePointService { if (sysUserList.isEmpty()) { return; } + List administratorList = relRoleAuthorityDao.selectByAuthorityId(1); List telephoneList = new ArrayList<>(); for (SysUserEntity sysUser : sysUserList) { try { String countyCode = sysUser.getCountyCode(); String startCountyCode = getStartCountyCode(countyCode); if (firePointEntity.getStreetCode().startsWith(startCountyCode)) { - if (sysUser.getReceiveSms() != 1) { + if (sysUser.getDeleteFlag() != 0) {//被删除的用户不发短信 + continue; + } + if (sysUser.getActiveFlag() != 0) {//被禁用的用户不发短信 + continue; + } + if (sysUser.getReceiveSms() != 1) {//关掉开关的用户不发短信 continue; } LocalDateTime sysUserOverDateTime = DateTimeUtil.stringToDateTimeFormatter(sysUser.getOverTime(), DateTimeUtil.COMMON_FORMATTER_DATETIME); - if (sysUserOverDateTime.isBefore(DateTimeUtil.getNowTime())) { + if (sysUserOverDateTime.isBefore(DateTimeUtil.getNowTime())) {//过期用户不发短信 + continue; + } + if (isAdministrator(administratorList, sysUser)) {//管理员用户不发短信 continue; } telephoneList.add("86" + sysUser.getUserName()); @@ -409,6 +422,21 @@ public class FirePointServiceImpl implements FirePointService { } } + /** + * 判断是否是管理员 + */ + private boolean isAdministrator(List administratorList, SysUserEntity sysUser) { + if (administratorList == null || administratorList.size() == 0) { + return false; + } + for (RelRoleAuthorityEntity administrator : administratorList) { + if (administrator.getUserId() == sysUser.getId()) { + return true; + } + } + return false; + } + private String getStartCountyCode(String countyCode) { try { String temp = countyCode;