下发状态修改

This commit is contained in:
guoshengxiong 2024-06-11 10:22:58 +08:00
parent d177acd242
commit aadbcb74f3
4 changed files with 29 additions and 39 deletions

View File

@ -146,7 +146,7 @@ public class AsyncHikvision {
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()));
hikvisionCall.updateAllFailStatusIfNull(workerInfo.getProjectSn(), workerInfo.getId(), 1);
}
@Async("hikvisionExecutor")
@ -192,7 +192,7 @@ public class AsyncHikvision {
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()));
hikvisionCall.updateAllFailStatusIfNull(carInfo.getProjectSn(), carInfo.getId(), 4);
}
@Async("carInfoExecutor")
@ -359,7 +359,7 @@ public class AsyncHikvision {
} else {
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()));
hikvisionCall.updateAllFailStatusIfNullForAuth(workerInfo.getProjectSn(), workerInfo.getId(), 3, 1, getSyncTimeWithInitIfAbsent(1, workerInfo.getId()));
return;
}
@ -379,7 +379,7 @@ public class AsyncHikvision {
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()));
hikvisionCall.updateAllFailStatusIfNullForAuth(workerInfo.getProjectSn(), workerInfo.getId(), 3, 1, getSyncTimeWithInitIfAbsent(1, workerInfo.getId()));
} catch (Exception e) {
log.error("海康:", e);
}
@ -422,7 +422,7 @@ public class AsyncHikvision {
} else {
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()));
hikvisionCall.updateAllFailStatusIfNullForAuth(workerInfo.getProjectSn(), workerInfo.getId(), 3, 3, getSyncTimeWithInitIfAbsent(1, workerInfo.getId()));
return;
}
@ -442,7 +442,7 @@ public class AsyncHikvision {
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()));
hikvisionCall.updateAllFailStatusIfNullForAuth(workerInfo.getProjectSn(), workerInfo.getId(), 3, 3, getSyncTimeWithInitIfAbsent(1, workerInfo.getId()));
} catch (Exception e) {
log.error("海康:", e);
}

View File

@ -1001,9 +1001,9 @@ public class HikvisionCall {
}
if (setSuc) {
updateSuccessStatusByNow(carInfo.getProjectSn(), carInfo.getId(), type, operate, AsyncHikvision.getSyncTime(), null);
updateSuccessStatus(carInfo.getProjectSn(), carInfo.getId(), type, operate, null);
} else {
updateFailStatusByNow(carInfo.getProjectSn(), carInfo.getId(), type, operate, AsyncHikvision.getSyncTime(), null);
updateFailStatus(carInfo.getProjectSn(), carInfo.getId(), type, operate, null);
}
xzHikvisionCompareDataService.compareRetryStatus(carInfo, type, operate, setSuc);
@ -1125,10 +1125,10 @@ public class HikvisionCall {
}
}
if (success) {
updateSuccessStatusByNow(workerInfo.getProjectSn(), workerInfo.getId(), type, operate, AsyncHikvision.getSyncTime(), null);
updateSuccessStatus(workerInfo.getProjectSn(), workerInfo.getId(), type, operate, null);
xzHikvisionCompareDataService.compareRetryStatus();
} else {
updateFailStatusByNow(workerInfo.getProjectSn(), workerInfo.getId(), type, operate, AsyncHikvision.getSyncTime(), null);
updateFailStatus(workerInfo.getProjectSn(), workerInfo.getId(), type, operate, null);
xzHikvisionCompareDataService.compareRetryFail();
}
if (ThreadLocalUtil.getByKey(Cts.TL_AUTH_USER, UserInfo.class) != null) {
@ -1136,7 +1136,7 @@ public class HikvisionCall {
}
}
public void updateAllFailStatusIfNullByNowForAuth(String projectSn, Long whoId, Integer bigType, Integer operate, Date now) {
public void updateAllFailStatusIfNullForAuth(String projectSn, Long whoId, Integer bigType, Integer operate, Date now) {
xzHikvisionSyncMapper.update(null, new LambdaUpdateWrapper<XzHikvisionSync>()
.set(XzHikvisionSync::getIsSuccess, 0)
.isNull(XzHikvisionSync::getIsSuccess)
@ -1146,42 +1146,33 @@ public class HikvisionCall {
.eq(XzHikvisionSync::getWhoId, whoId)
.eq(XzHikvisionSync::getCreateDate, now)
);
updateTotalStatus(projectSn, whoId, bigType, now);
updateTotalStatus(projectSn, whoId, bigType);
}
public void updateAllFailStatusIfNullByNow(String projectSn, Long whoId, Integer bigType, Date now) {
public void updateAllFailStatusIfNull(String projectSn, Long whoId, Integer bigType) {
xzHikvisionSyncMapper.update(null, new LambdaUpdateWrapper<XzHikvisionSync>()
.set(XzHikvisionSync::getIsSuccess, 0)
.isNull(XzHikvisionSync::getIsSuccess)
.eq(XzHikvisionSync::getProjectSn, projectSn)
.eq(XzHikvisionSync::getWhoId, whoId)
.eq(XzHikvisionSync::getCreateDate, now)
.eq(XzHikvisionSync::getBigType, bigType)
);
updateTotalStatus(projectSn, whoId, bigType, now);
updateTotalStatus(projectSn, whoId, bigType);
}
public void updateFailStatusByNow(String projectSn, Long whoId, Integer type, Date now, String deviceSn) {
updateFailStatusByNow(projectSn, whoId, type, null, now, deviceSn);
public void updateFailStatus(String projectSn, Long whoId, Integer type, Integer operate, String deviceSn) {
updateStatus(projectSn, whoId, type, operate, deviceSn, false);
}
public void updateFailStatusByNow(String projectSn, Long whoId, Integer type, Integer operate, Date now, String deviceSn) {
updateStatusByNow(projectSn, whoId, type, operate, now, deviceSn, false);
public void updateSuccessStatus(String projectSn, Long whoId, Integer type, Integer operate, String deviceSn) {
updateStatus(projectSn, whoId, type, operate, deviceSn, true);
}
public void updateSuccessStatusByNow(String projectSn, Long whoId, Integer type, Date now, String deviceSn) {
updateSuccessStatusByNow(projectSn, whoId, type, null, now, deviceSn);
}
public void updateSuccessStatusByNow(String projectSn, Long whoId, Integer type, Integer operate, Date now, String deviceSn) {
updateStatusByNow(projectSn, whoId, type, operate, now, deviceSn, true);
}
private void updateStatusByNow(String projectSn, Long whoId, Integer type, Integer operate, Date now, String deviceSn, Boolean isSuccess) {
private void updateStatus(String projectSn, Long whoId, Integer type, Integer operate, String deviceSn, Boolean isSuccess) {
LambdaQueryWrapper<XzHikvisionSync> queryWrapper = new LambdaQueryWrapper<XzHikvisionSync>()
.eq(XzHikvisionSync::getProjectSn, projectSn)
.eq(XzHikvisionSync::getWhoId, whoId)
.eq(XzHikvisionSync::getType, type)
.eq(XzHikvisionSync::getCreateDate, now)
.eq(StringUtils.isNotBlank(deviceSn), XzHikvisionSync::getDeviceSn, deviceSn);
if (operate != null) {
if (operate == 3) {
@ -1197,14 +1188,14 @@ public class HikvisionCall {
xzHikvisionSync.setIsSuccess(isSuccess ? 1 : 0);
xzHikvisionSyncMapper.updateById(xzHikvisionSync);
updateTotalStatus(projectSn, whoId, type, now);
updateTotalStatus(projectSn, whoId, xzHikvisionSync.getBigType());
}
public void updateTotalStatus(String projectSn, Long whoId, Integer bigType, Date now) {
public void updateTotalStatus(String projectSn, Long whoId, Integer bigType) {
List<XzHikvisionSync> xzHikvisionSyncs = xzHikvisionSyncMapper.selectList(new LambdaQueryWrapper<XzHikvisionSync>()
.eq(XzHikvisionSync::getProjectSn, projectSn)
.eq(XzHikvisionSync::getWhoId, whoId)
.eq(XzHikvisionSync::getCreateDate, now)
.eq(XzHikvisionSync::getBigType, bigType)
);
Integer sendSuccessStatus = null;
if (CollUtil.isEmpty(xzHikvisionSyncs)) {
@ -1218,7 +1209,7 @@ public class HikvisionCall {
} else {
sendSuccessStatus = 3;
}
if (bigType >= 4) {
if (Objects.equals(bigType, 2)) {
carInfoMapper.update(null, new LambdaUpdateWrapper<CarInfo>()
.eq(CarInfo::getId, whoId)
.set(CarInfo::getSendSuccessStatus, sendSuccessStatus)
@ -2199,7 +2190,7 @@ public class HikvisionCall {
}
private void updateSucForUpdatePersonAuth(WorkerInfo workerInfo, String devSn, int i) {
updateSuccessStatusByNow(workerInfo.getProjectSn(), workerInfo.getId(), 3, i == 0 ? 1 : 3, AsyncHikvision.getSyncTime(), devSn);
updateSuccessStatus(workerInfo.getProjectSn(), workerInfo.getId(), 3, i == 0 ? 1 : 3, devSn);
}
}

View File

@ -475,7 +475,7 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
}
public void resetHkStatus(WorkerInfo workerInfo) {
hikvisionCall.updateTotalStatus(workerInfo.getProjectSn(), workerInfo.getId(), 1, AsyncHikvision.getSyncTime());
hikvisionCall.updateTotalStatus(workerInfo.getProjectSn(), workerInfo.getId(), 1);
}
/**

View File

@ -28,10 +28,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @Description: 星纵-海康同步数据
@ -184,6 +181,7 @@ public class XzHikvisionSyncServiceImpl extends ServiceImpl<XzHikvisionSyncMappe
Long whoId = xzHikvisionSync.getWhoId();
ThreadLocalUtil.addInKey("now", xzHikvisionSync.getCreateDate());
if (xzHikvisionSync.getType() >= 4) {
//车辆
CarInfo carInfo = carInfoMapper.selectById(whoId);
if (carInfo == null) {
return;
@ -196,6 +194,7 @@ public class XzHikvisionSyncServiceImpl extends ServiceImpl<XzHikvisionSyncMappe
hikvisionCall.deleteCarInfoForHikvision(carInfo, false);
}
} else {
//人员
WorkerInfo workerInfo = workerInfoMapper.selectById(whoId);
Project p = projectMapper.selectOne(new LambdaQueryWrapper<Project>()
.eq(Project::getProjectSn, workerInfo.getProjectSn())