海康提示修改

This commit is contained in:
GUO 2024-06-04 21:40:40 +08:00
parent a739a82a2a
commit 799cff0823
4 changed files with 28 additions and 24 deletions

View File

@ -5,6 +5,7 @@ import com.zhgd.jeecg.common.execption.OpenPromptException;
import com.zhgd.jeecg.common.util.SpringContextUtils;
import com.zhgd.jeecg.common.util.pass.HttpUtils;
import com.zhgd.xmgl.call.HikvisionCall;
import com.zhgd.xmgl.constant.Cts;
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
import com.zhgd.xmgl.modules.car.entity.CarInfo;
import com.zhgd.xmgl.modules.project.entity.Project;
@ -17,11 +18,11 @@ import com.zhgd.xmgl.modules.worker.entity.TeamInfo;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.worker.mapper.EnterpriseInfoMapper;
import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionCompareDataMapper;
import com.zhgd.xmgl.modules.xz.service.impl.XzHikvisionCompareDataServiceImpl;
import com.zhgd.xmgl.modules.xz.entity.XzHikvisionSync;
import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionCompareDataMapper;
import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionSyncMapper;
import com.zhgd.xmgl.security.util.SecurityUtils;
import com.zhgd.xmgl.modules.xz.service.impl.XzHikvisionCompareDataServiceImpl;
import com.zhgd.xmgl.security.entity.UserInfo;
import com.zhgd.xmgl.util.ThreadLocalUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@ -148,8 +149,8 @@ public class AsyncHikvision {
} else {
msg = "同步失败,人员名称:" + workerInfo.getWorkerName() + ",身份证号:" + workerInfo.getIdCard() + "。失败原因:下发异常";
}
if (SecurityUtils.getUser() != null && SecurityUtils.getUser().getUserId() != null) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), msg, title, type);
if (ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class) != null) {
noticeService.addUserNotice(ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class).getUserId(), msg, title, type);
}
hikvisionCall.updateAllFailStatusIfNullByNow(workerInfo.getProjectSn(), workerInfo.getId(), 1, getSyncTimeWithInitIfAbsent(1, workerInfo.getId()));
}
@ -215,8 +216,8 @@ public class AsyncHikvision {
} else {
msg = "同步失败,车牌号:" + carInfo.getCarNumber() + "。失败原因:下发异常";
}
if (SecurityUtils.getUser() != null && SecurityUtils.getUser().getUserId() != null) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), msg, title, type);
if (ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class) != null) {
noticeService.addUserNotice(ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class).getUserId(), msg, title, type);
}
hikvisionCall.updateAllFailStatusIfNullByNow(carInfo.getProjectSn(), carInfo.getId(), 4, getSyncTimeWithInitIfAbsent(2, carInfo.getId()));
}
@ -287,8 +288,8 @@ public class AsyncHikvision {
} else {
msg = "同步失败,组织名称:" + name + "。失败原因:下发异常";
}
if (SecurityUtils.getUser() != null && SecurityUtils.getUser().getUserId() != null) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), msg, title, type);
if (ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class) != null) {
noticeService.addUserNotice(ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class).getUserId(), msg, title, type);
}
xzHikvisionCompareDataService.compareRetryFail();
}
@ -406,9 +407,9 @@ public class AsyncHikvision {
}
} catch (Exception e) {
if (HttpUtils.isTimeOut(e)) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), "失败原因平台连接isc网络异常", "人员下发设备提醒", "1");
noticeService.addUserNotice(ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class).getUserId(), "失败原因平台连接isc网络异常", "人员下发设备提醒", "1");
} else {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), e.getMessage(), "人员下发设备提醒", "1");
noticeService.addUserNotice(ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class).getUserId(), e.getMessage(), "人员下发设备提醒", "1");
}
hikvisionCall.updateAllFailStatusIfNullByNowForAuth(workerInfo.getProjectSn(), workerInfo.getId(), 3, 1, getSyncTimeWithInitIfAbsent(1, workerInfo.getId()));
return;
@ -427,8 +428,8 @@ public class AsyncHikvision {
failSbStr = "下发权限失败:" + failSbStr;
msg += failSbStr;
}
if (SecurityUtils.getUser() != null && SecurityUtils.getUser().getUserId() != null) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), StringUtils.substring(msg, 0, msg.length() - 1), title, type);
if (ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class) != null) {
noticeService.addUserNotice(ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class).getUserId(), StringUtils.substring(msg, 0, msg.length() - 1), title, type);
}
hikvisionCall.updateAllFailStatusIfNullByNowForAuth(workerInfo.getProjectSn(), workerInfo.getId(), 3, 1, getSyncTimeWithInitIfAbsent(1, workerInfo.getId()));
} catch (Exception e) {
@ -469,9 +470,9 @@ public class AsyncHikvision {
}
} catch (Exception e) {
if (HttpUtils.isTimeOut(e)) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), "网络异常", "人员下发设备提醒", "1");
noticeService.addUserNotice(ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class).getUserId(), "网络异常", "人员下发设备提醒", "1");
} else {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), e.getMessage(), "人员下发设备提醒", "1");
noticeService.addUserNotice(ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class).getUserId(), e.getMessage(), "人员下发设备提醒", "1");
}
hikvisionCall.updateAllFailStatusIfNullByNowForAuth(workerInfo.getProjectSn(), workerInfo.getId(), 3, 3, getSyncTimeWithInitIfAbsent(1, workerInfo.getId()));
return;
@ -490,8 +491,8 @@ public class AsyncHikvision {
failSbStr = "移除权限失败:" + failSbStr;
msg += failSbStr;
}
if (SecurityUtils.getUser() != null && SecurityUtils.getUser().getUserId() != null) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), StringUtils.substring(msg, 0, msg.length() - 1), title, type);
if (ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class) != null) {
noticeService.addUserNotice(ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class).getUserId(), StringUtils.substring(msg, 0, msg.length() - 1), title, type);
}
hikvisionCall.updateAllFailStatusIfNullByNowForAuth(workerInfo.getProjectSn(), workerInfo.getId(), 3, 3, getSyncTimeWithInitIfAbsent(1, workerInfo.getId()));
} catch (Exception e) {

View File

@ -61,7 +61,7 @@ import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionCompareDataMapper;
import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionSyncMapper;
import com.zhgd.xmgl.modules.xz.service.IXzHikvisionCompareDataService;
import com.zhgd.xmgl.modules.xz.service.impl.XzHikvisionSyncServiceImpl;
import com.zhgd.xmgl.security.util.SecurityUtils;
import com.zhgd.xmgl.security.entity.UserInfo;
import com.zhgd.xmgl.util.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -1078,8 +1078,8 @@ public class HikvisionCall {
updateFailStatusByNow(carInfo.getProjectSn(), carInfo.getId(), type, operate, AsyncHikvision.getSyncTime(), null);
}
if (isNotice) {
if (SecurityUtils.getUser() != null && SecurityUtils.getUser().getUserId() != null) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), msg, title, "24");
if (ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class) != null) {
noticeService.addUserNotice(ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class).getUserId(), msg, title, "24");
} else if (carInfo.getUserIds() != null && carInfo.getUserIds().size() > 0) {
for (String userId : carInfo.getUserIds()) {
noticeService.addUserNotice(Long.valueOf(userId), msg, title, "24");
@ -1125,8 +1125,8 @@ public class HikvisionCall {
} else {
xzHikvisionCompareDataService.compareRetryFail();
}
if (SecurityUtils.getUser() != null && SecurityUtils.getUser().getUserId() != null) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), msg, title, type);
if (ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class) != null) {
noticeService.addUserNotice(ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class).getUserId(), msg, title, type);
}
}
@ -1192,8 +1192,8 @@ public class HikvisionCall {
updateFailStatusByNow(workerInfo.getProjectSn(), workerInfo.getId(), type, operate, AsyncHikvision.getSyncTime(), null);
xzHikvisionCompareDataService.compareRetryFail();
}
if (SecurityUtils.getUser() != null && SecurityUtils.getUser().getUserId() != null) {
noticeService.addUserNotice(SecurityUtils.getUser().getUserId(), msg, title, noticeType);
if (ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class) != null) {
noticeService.addUserNotice(ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class).getUserId(), msg, title, noticeType);
}
}

View File

@ -44,4 +44,5 @@ public interface Cts {
String RESERVATION_TYPE = "reservationType";
String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
String YYYY_MM_DD = "yyyy-MM-dd";
String TL_AUTH_USER = "authUser";
}

View File

@ -1,6 +1,7 @@
package com.zhgd.xmgl.security;
import com.zhgd.xmgl.constant.Cts;
import com.zhgd.xmgl.security.util.SecurityUtils;
import com.zhgd.xmgl.util.RequestIdUtil;
import com.zhgd.xmgl.util.ThreadLocalUtil;
import lombok.extern.slf4j.Slf4j;
@ -17,6 +18,7 @@ public class RequestIdFilter implements Filter {
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
RequestIdUtil.setRequestId("-i");
ThreadLocalUtil.addInKey(Cts.TL_IS_FROM_WEB, true);
ThreadLocalUtil.addInKey(Cts.TL_AUTH_USER, SecurityUtils.getUser());
log.info("接口开始...");
try {
filterChain.doFilter(servletRequest, servletResponse);