优化短信发送策略:
1、被删除的用户不发短信 2、被禁用的用户不发短信 3、关掉开关的用户不发短信 4、过期用户不发短信 5、管理员用户不发短信
This commit is contained in:
parent
68b514d815
commit
ea418a7cfa
@ -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;
|
||||
|
||||
/**
|
||||
* 添加火点数据
|
||||
*
|
||||
|
@ -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) {
|
||||
|
@ -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<RelRoleAuthorityEntity,Long> {
|
||||
public interface RelRoleAuthorityDao extends JpaRepository<RelRoleAuthorityEntity, Long>, JpaSpecificationExecutor<RelRoleAuthorityEntity> {
|
||||
|
||||
/**
|
||||
* 根据userId查询出权限的id
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select authority_id from rel_role_authority where user_id = ?", nativeQuery = true)
|
||||
List<Integer> selectAuthorityByUserId(@Param("userId") Integer userId);
|
||||
|
||||
@Query(value = "SELECT * FROM rel_role_authority WHERE authority_id = ?1", nativeQuery = true)
|
||||
List<RelRoleAuthorityEntity> selectByAuthorityId(Integer authorityId);
|
||||
|
||||
}
|
||||
|
@ -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<RelUserRoleEntity,Long> {
|
||||
public interface RelUserRoleDao extends JpaRepository<RelUserRoleEntity, Long>, JpaSpecificationExecutor<RelUserRoleEntity> {
|
||||
|
||||
}
|
||||
|
@ -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<RelRoleAuthorityEntity> administratorList = relRoleAuthorityDao.selectByAuthorityId(1);
|
||||
List<String> 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<RelRoleAuthorityEntity> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user