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;