修改由于定时任务下无当前登录用户,导致代码报错的bug

This commit is contained in:
Renpc-kilig 2021-11-02 10:30:24 +08:00
parent 5a3a8a2bf3
commit a73575dbce
4 changed files with 14 additions and 5 deletions

View File

@ -171,8 +171,8 @@ public class ReceiverUserController extends DefaultBaseController {
* 任务执行状态监测
* 通过获取任务下派时设置的下派超时限制与当前时间做计算来判断是否超时(是否即将超时)
*/
@Scheduled(cron = "0 0/5 * * * ?")
// @Scheduled(cron = "0/5 * * * * ?")
// @Scheduled(cron = "0 0/5 * * * ?")
@Scheduled(cron = "0/5 * * * * ?")
@Async
public void executeStatusTasks() throws ParseException {
System.err.println("----------任务执行状态监测开始----------");

View File

@ -16,6 +16,8 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import java.util.*;
@ -53,8 +55,9 @@ public class DistributeSubServiceImpl extends DefaultBaseService implements IDis
String distributeSubId = UUIDUtil.getUUID();
Map<String, Object> params = HashMapUtil.beanToMap(distributeSubVO);
params.put("distributeSubId", distributeSubId);
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
try {
if (null == securityComponent) {
if (null != authentication) {
if (StringUtils.isBlank(token)) {
setSaveInfo(params);
} else {

View File

@ -27,6 +27,8 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import java.text.ParseException;
@ -77,8 +79,9 @@ public class ReceiverUserServiceImpl extends DefaultBaseService implements IRece
String receiverUserId = UUIDUtil.getUUID();
Map<String, Object> params = HashMapUtil.beanToMap(receiverUserVO);
params.put("receiverUserId", receiverUserId);
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
try {
if (null == securityComponent) {
if (null != authentication) {
if (StringUtils.isBlank(token)) {
setSaveInfo(params);
} else {

View File

@ -17,6 +17,8 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import java.util.*;
@ -54,8 +56,9 @@ public class UrgeServiceImpl extends DefaultBaseService implements IUrgeService
String urgeId = UUIDUtil.getUUID();
Map<String, Object> params = HashMapUtil.beanToMap(urgeVO);
params.put("urgeId", urgeId);
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
try {
if (null == securityComponent) {
if (null != authentication) {
if (StringUtils.isBlank(token)) {
setSaveInfo(params);
} else {