海康下发修改
This commit is contained in:
parent
ca1beb9b27
commit
470fe7b2da
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
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.redis.lock.RedisRepository;
|
||||
import com.zhgd.xmgl.call.HikvisionCall;
|
||||
import com.zhgd.xmgl.constant.Cts;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.Notice;
|
||||
@ -93,6 +94,8 @@ public class AsyncHikvision {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private XzHikvisionCompareDataServiceImpl xzHikvisionCompareDataService;
|
||||
@Autowired
|
||||
private RedisRepository redisRepository;
|
||||
|
||||
public static Date getSyncTimeWithInitIfAbsent(int bigType, Long tableId) {
|
||||
Date now = ThreadLocalUtil.getNotNull().getDate(XZ_HIKVISION_SYNC_TIME);
|
||||
@ -303,9 +306,9 @@ public class AsyncHikvision {
|
||||
}
|
||||
|
||||
@Async("carInfoExecutor")
|
||||
public void deleteEnterpriseInfoForHikvision(String enterpriseId, String projectSn, String enterpriseName) {
|
||||
public void deleteEnterpriseInfoForHikvision(String enterpriseId, String projectSn, String enterpriseName, Long projectEnterpriseId) {
|
||||
try {
|
||||
hikvisionCall.deleteEnterpriseInfoForHikvision(enterpriseId, projectSn, enterpriseName);
|
||||
hikvisionCall.deleteEnterpriseInfoForHikvision(enterpriseId, projectSn, enterpriseName,projectEnterpriseId);
|
||||
} catch (Exception e) {
|
||||
log.error("海康:", e);
|
||||
sendNoticeForOrg(enterpriseName, e, "删除");
|
||||
@ -745,6 +748,10 @@ public class AsyncHikvision {
|
||||
//添加权限
|
||||
if (Objects.equals(faceStatus, 3)) {
|
||||
hikvisionCall.updateSuccessStatus(projectSn, Long.valueOf(personId), 3, 1, dev.getDevSn());
|
||||
Long syncId = ThreadLocalUtil.getByKey(Cts.TL_HK_SYNC_ID, Long.class);
|
||||
if (syncId != null) {
|
||||
redisRepository.set(Cts.HK_SYNC_AUTH_SUCCESS_KEY + syncId, 1, 60L);
|
||||
}
|
||||
} else {
|
||||
hikvisionCall.updateFailStatus(projectSn, Long.valueOf(personId), 3, 1, dev.getDevSn());
|
||||
}
|
||||
|
||||
@ -1777,7 +1777,7 @@ public class HikvisionCall {
|
||||
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
||||
return;
|
||||
}
|
||||
Pair<Boolean, String> existAndIndexCode = existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, String.valueOf(enterpriseInfo.getId()));
|
||||
Pair<Boolean, String> existAndIndexCode = existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, String.valueOf(enterpriseInfo.getId()), null);
|
||||
HikvisionOrganization hikvisionOrganization = getHikvisionOrganization(enterpriseInfo, existAndIndexCode.getRight());
|
||||
if (existAndIndexCode.getLeft()) {
|
||||
editOrgFromHttp(project, hikvisionOrganization);
|
||||
@ -1786,13 +1786,25 @@ public class HikvisionCall {
|
||||
}
|
||||
}
|
||||
|
||||
private Pair<Boolean, String> existAndGetEnterpriseOrgIndexCodeByEnterpriseId(Project project, String enterpriseId) throws Exception {
|
||||
/**
|
||||
* @param project
|
||||
* @param enterpriseId
|
||||
* @param projectEnterpriseId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private Pair<Boolean, String> existAndGetEnterpriseOrgIndexCodeByEnterpriseId(Project project, String enterpriseId, Long projectEnterpriseId) throws Exception {
|
||||
if (projectEnterpriseId == null) {
|
||||
EnterpriseInfo enterpriseInfo = BeanUtil.toBean(enterpriseInfoService.getEnterpriseInfoById(new MapBuilder<String, Object>()
|
||||
.put(Cts.PROJECT_SN, project.getProjectSn()).put(Cts.ENTERPRISE_ID, enterpriseId).build()), EnterpriseInfo.class);
|
||||
JSONArray orgList = getOrgList(project, StrUtil.join(",", enterpriseId, enterpriseInfo != null ? enterpriseInfo.getProjectEnterprise().getId() : ""), project.getProjectSn());
|
||||
if (enterpriseInfo.getProjectEnterprise() != null) {
|
||||
projectEnterpriseId = enterpriseInfo.getProjectEnterprise().getId();
|
||||
}
|
||||
}
|
||||
JSONArray orgList = getOrgList(project, StrUtil.join(",", enterpriseId, projectEnterpriseId != null ? projectEnterpriseId : ""), project.getProjectSn());
|
||||
String index = null;
|
||||
if (CollUtil.isEmpty(orgList)) {
|
||||
index = enterpriseInfo != null ? String.valueOf(enterpriseInfo.getProjectEnterprise().getId()) : enterpriseId;
|
||||
index = projectEnterpriseId != null ? String.valueOf(projectEnterpriseId) : enterpriseId;
|
||||
} else {
|
||||
index = orgList.getJSONObject(0).getString("orgIndexCode");
|
||||
}
|
||||
@ -1805,14 +1817,15 @@ public class HikvisionCall {
|
||||
* @param enterpriseId
|
||||
* @param projectSn
|
||||
* @param enterpriseName
|
||||
* @param projectEnterpriseId
|
||||
*/
|
||||
public void deleteEnterpriseInfoForHikvision(String enterpriseId, String projectSn, String enterpriseName) throws Exception {
|
||||
public void deleteEnterpriseInfoForHikvision(String enterpriseId, String projectSn, String enterpriseName, Long projectEnterpriseId) throws Exception {
|
||||
Project project = projectMapper.selectOne(new LambdaQueryWrapper<Project>().eq(Project::getProjectSn, projectSn));
|
||||
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
||||
return;
|
||||
}
|
||||
Pair<Boolean, String> pair = existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, String.valueOf(enterpriseId));
|
||||
String rs = HikvisionUtil.deleteOrgByIndexCodes(project, Arrays.asList(pair.getRight()));
|
||||
Pair<Boolean, String> pair = existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, String.valueOf(enterpriseId), projectEnterpriseId);
|
||||
String rs = HikvisionUtil.deleteOrgByIndexCodes(project, Collections.singletonList(pair.getRight()));
|
||||
sendNoticeForOrg("删除组织到海康isc", rs, enterpriseName);
|
||||
}
|
||||
|
||||
@ -1835,7 +1848,7 @@ public class HikvisionCall {
|
||||
hikvisionOrganization.setClientId(null);
|
||||
hikvisionOrganization.setOrgIndexCode(String.valueOf(teamInfo.getId()));
|
||||
hikvisionOrganization.setOrgName(teamInfo.getTeamName());
|
||||
hikvisionOrganization.setParentIndexCode(existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, String.valueOf(teamInfo.getEnterpriseId())).getRight());
|
||||
hikvisionOrganization.setParentIndexCode(existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, String.valueOf(teamInfo.getEnterpriseId()), null).getRight());
|
||||
return hikvisionOrganization;
|
||||
}
|
||||
|
||||
@ -1905,7 +1918,7 @@ public class HikvisionCall {
|
||||
hikvisionOrganization.setClientId(null);
|
||||
hikvisionOrganization.setOrgIndexCode(String.valueOf(departmentInfo.getId()));
|
||||
hikvisionOrganization.setOrgName(departmentInfo.getDepartmentName());
|
||||
hikvisionOrganization.setParentIndexCode(existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, String.valueOf(departmentInfo.getEnterpriseId())).getRight());
|
||||
hikvisionOrganization.setParentIndexCode(existAndGetEnterpriseOrgIndexCodeByEnterpriseId(project, String.valueOf(departmentInfo.getEnterpriseId()), null).getRight());
|
||||
return hikvisionOrganization;
|
||||
}
|
||||
|
||||
|
||||
@ -53,4 +53,9 @@ public interface Cts {
|
||||
* 1添加权限2删除权限
|
||||
*/
|
||||
String IS_ADD_AUTH = "isAddAuth";
|
||||
/**
|
||||
* 1成功
|
||||
*/
|
||||
String HK_SYNC_AUTH_SUCCESS_KEY = "hkSyncAuthSuccess:";
|
||||
String TL_HK_SYNC_ID = "tl_hk_sync_id";
|
||||
}
|
||||
|
||||
@ -258,7 +258,7 @@ public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper,
|
||||
}
|
||||
EnterpriseInfo enterpriseInfo = baseMapper.selectById(enterpriseId);
|
||||
//同步海康
|
||||
asyncHikvision.deleteEnterpriseInfoForHikvision(enterpriseId, projectSn, enterpriseInfo.getEnterpriseName());
|
||||
asyncHikvision.deleteEnterpriseInfoForHikvision(enterpriseId, projectSn, enterpriseInfo.getEnterpriseName(), projectEnterprise != null ? projectEnterprise.getId() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -202,7 +202,7 @@ public class XzHikvisionCompareDataServiceImpl extends ServiceImpl<XzHikvisionCo
|
||||
//同步海康
|
||||
asyncHikvision.editEnterpriseInfoForHikvision(enterpriseInfo);
|
||||
} else {
|
||||
asyncHikvision.deleteEnterpriseInfoForHikvision(data.getUniqueId(), data.getProjectSn(), data.getOrgName());
|
||||
asyncHikvision.deleteEnterpriseInfoForHikvision(data.getUniqueId(), data.getProjectSn(), data.getOrgName(), enterpriseInfo.getProjectEnterprise() != null ? enterpriseInfo.getProjectEnterprise().getId() : null);
|
||||
}
|
||||
} else if (data.getExistIsc() == 0 && data.getExistMyPlatform() == 1) {
|
||||
//查询id是否存在isc,存在就更新,不存在就新增
|
||||
|
||||
@ -8,8 +8,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.redis.lock.RedisRepository;
|
||||
import com.zhgd.xmgl.async.AsyncHikvision;
|
||||
import com.zhgd.xmgl.call.HikvisionCall;
|
||||
import com.zhgd.xmgl.constant.Cts;
|
||||
import com.zhgd.xmgl.modules.car.entity.CarInfo;
|
||||
import com.zhgd.xmgl.modules.car.mapper.CarInfoMapper;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
@ -52,6 +54,9 @@ public class XzHikvisionSyncServiceImpl extends ServiceImpl<XzHikvisionSyncMappe
|
||||
IProjectUfaceConfigService projectUfaceConfigService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
RedisRepository redisRepository;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private HikvisionCall hikvisionCall;
|
||||
@Autowired
|
||||
private XzHikvisionSyncMapper xzHikvisionSyncMapper;
|
||||
@ -235,7 +240,15 @@ public class XzHikvisionSyncServiceImpl extends ServiceImpl<XzHikvisionSyncMappe
|
||||
QueryWrapper<UfaceDev> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(UfaceDev::getProjectSn, projectSn);
|
||||
List<UfaceDev> ufaceDevs = ufaceDevMapper.selectList(qw);
|
||||
ThreadLocalUtil.addInKey(Cts.TL_HK_SYNC_ID, id);
|
||||
projectUfaceConfigService.buildAndSendOneWorkerAndDevForHk(ufaceDevs, workerInfo, xzHikvisionSync.getOperate(), xzHikvisionSync.getDeviceSn(), projectSn);
|
||||
String redisKey = Cts.HK_SYNC_AUTH_SUCCESS_KEY + id;
|
||||
Object success = redisRepository.get(redisKey);
|
||||
redisRepository.del(redisKey);
|
||||
if (!Objects.equals(success,1)) {
|
||||
throw new OpenAlertException("重试失败");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -399,8 +399,7 @@ public class HikvisionUtil {
|
||||
String host = "https://" + project.getArtemisConfigHost();
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("indexCodes", indexCodes);
|
||||
String rs = doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
||||
return rs;
|
||||
return doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user