批量下发设备修改
This commit is contained in:
parent
01012b1898
commit
f3d4e784d2
@ -567,7 +567,7 @@ public class AsyncHikvision {
|
||||
log.error("批量下发权限失败:", e);
|
||||
hikvisionCall.updateAllFailStatusIfNullForAuth(projectSn, workerList, 1, 1);
|
||||
hikvisionCall.updateAllFailStatusIfNullForAuth(projectSn, workerList, 1, 3);
|
||||
sendExcNotice(e, workerList, null);
|
||||
sendExcNotice(e, workerList, null, projectSn);
|
||||
}
|
||||
}
|
||||
|
||||
@ -577,8 +577,9 @@ public class AsyncHikvision {
|
||||
* @param e
|
||||
* @param workerList
|
||||
* @param dev
|
||||
* @param projectSn
|
||||
*/
|
||||
private void sendExcNotice(Exception e, List<WorkerInfo> workerList, UfaceDev dev) {
|
||||
private void sendExcNotice(Exception e, List<WorkerInfo> workerList, UfaceDev dev, String projectSn) {
|
||||
String exc;
|
||||
if (HttpUtils.isTimeOut(e)) {
|
||||
exc = ",连接ISC网络异常";
|
||||
@ -587,7 +588,7 @@ public class AsyncHikvision {
|
||||
}
|
||||
if (CollUtil.isNotEmpty(workerList)) {
|
||||
List<WorkerInfo> failWorkers = workerInfoService.list(Wrappers.<WorkerInfo>lambdaQuery()
|
||||
.eq(WorkerInfo::getProjectSn, dev.getProjectSn())
|
||||
.eq(WorkerInfo::getProjectSn, projectSn)
|
||||
.ne(WorkerInfo::getSendSuccessStatus, 1)
|
||||
.in(WorkerInfo::getId, workerList.stream().map(WorkerInfo::getId).collect(Collectors.toList()))
|
||||
);
|
||||
@ -604,13 +605,7 @@ public class AsyncHikvision {
|
||||
|
||||
private ArrayList<WorkerInfo> getNeedEditWorkers(List<WorkerInfo> workerList, ProjectInfoExtVo project, Map<String, WorkerInfo> workerIdMap) throws Exception {
|
||||
ArrayList<WorkerInfo> needEditWorkers = new ArrayList<>();
|
||||
JSONObject plJo = HikvisionUtil.queryPersonList(project, new JoBuilder()
|
||||
.put("personIds", StrUtil.join(",", workerList.stream().map(WorkerInfo::getId).collect(Collectors.toList())))
|
||||
.put("pageNo", 1)
|
||||
.put("pageSize", 1000)
|
||||
.build());
|
||||
JSONObject plDataJo = HikvisionUtil.getJSONObjectData(plJo);
|
||||
JSONArray plListJa = plDataJo.getJSONArray("list");
|
||||
JSONArray plListJa = getPersonListByWorkerList(workerList, project);
|
||||
HashSet<String> iscPersonIds = new HashSet<>();
|
||||
for (int i = 0; i < plListJa.size(); i++) {
|
||||
JSONObject jo = plListJa.getJSONObject(i);
|
||||
@ -630,6 +625,21 @@ public class AsyncHikvision {
|
||||
return needEditWorkers;
|
||||
}
|
||||
|
||||
private JSONArray getPersonListByWorkerList(List<WorkerInfo> workerList, ProjectInfoExtVo project) throws Exception {
|
||||
JSONArray rtJa = new JSONArray();
|
||||
for (List<WorkerInfo> splitList : CollUtil.splitList(workerList, 1000)) {
|
||||
JSONObject plJo = HikvisionUtil.queryPersonList(project, new JoBuilder()
|
||||
.put("personIds", StrUtil.join(",", splitList.stream().map(WorkerInfo::getId).collect(Collectors.toList())))
|
||||
.put("pageNo", 1)
|
||||
.put("pageSize", 1000)
|
||||
.build());
|
||||
JSONObject plDataJo = HikvisionUtil.getJSONObjectData(plJo);
|
||||
JSONArray plListJa = plDataJo.getJSONArray("list");
|
||||
rtJa.addAll(plListJa);
|
||||
}
|
||||
return rtJa;
|
||||
}
|
||||
|
||||
/**
|
||||
* 一个设备批量下发人员
|
||||
*
|
||||
@ -641,7 +651,7 @@ public class AsyncHikvision {
|
||||
* @param sendNotice
|
||||
* @param workerList
|
||||
*/
|
||||
@Async("workerAuthHkExecutor")
|
||||
@Async("workerBeWaitHkExecutor")
|
||||
public Future sendBatchWorkersForOneDevAsync(Map<String, WorkerInfo> workerIdMap, Map<String, UfaceDev> devSnMap, ProjectInfoExtVo project, Map<String, JSONObject> devSnToIscDevSnMap, Map.Entry<String, List<JSONObject>> devSnToJoEntry, String projectSn, boolean sendNotice, List<WorkerInfo> workerList) {
|
||||
String devSn = devSnToJoEntry.getKey();
|
||||
UfaceDev dev = devSnMap.get(devSn);
|
||||
@ -654,12 +664,10 @@ public class AsyncHikvision {
|
||||
return null;
|
||||
}
|
||||
if (CollUtil.isNotEmpty(addAuthWorkerIds)) {
|
||||
JSONObject aaRJo = HikvisionUtil.addAuth(project, getAddOrDeleteAuthParam(devSnToJoEntry, addAuthWorkerIds, devSnToIscDevSnMap));
|
||||
HikvisionUtil.getJSONObjectData(aaRJo);
|
||||
addAuthByWorkerList(project, devSnToIscDevSnMap, devSnToJoEntry, addAuthWorkerIds);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(deleteAuthWorkerIds)) {
|
||||
JSONObject aaRJo = HikvisionUtil.deleteAuth(project, getAddOrDeleteAuthParam(devSnToJoEntry, deleteAuthWorkerIds, devSnToIscDevSnMap));
|
||||
HikvisionUtil.getJSONObjectData(aaRJo);
|
||||
deleteAuthByWorkerList(project, devSnToIscDevSnMap, devSnToJoEntry, deleteAuthWorkerIds);
|
||||
}
|
||||
//然后调用【根据出入权限配置快捷下载】(设备列表)(【添加权限配置】+【快捷下发】这是一个流程,你添加了几个权限,下发成功之后,就清零了)
|
||||
JSONObject daJo = HikvisionUtil.downloadAuth(project, getQueryDownloadProgressParam(devSnToJoEntry, devSnToIscDevSnMap));
|
||||
@ -674,9 +682,8 @@ public class AsyncHikvision {
|
||||
Thread.sleep(1000);
|
||||
} while (totalPercent != 100);
|
||||
//权限下发后(进度100后),用【查询权限条目列表】(人员列表,设备列表)接口去查,返回参数有权限状态,返回已下载的就是有权限
|
||||
JSONObject qaiJo = HikvisionUtil.queryAuthItem(project, getQueryAuthItemParam(devSnToJoEntry, devSnToIscDevSnMap));
|
||||
JSONObject qaiRtJo = HikvisionUtil.getJSONObjectData(qaiJo);
|
||||
JSONArray qaiList = qaiRtJo.getJSONArray("list");
|
||||
List<String> workerIds = devSnToJoEntry.getValue().stream().map(jsonObject -> jsonObject.getString("workerId")).collect(Collectors.toList());
|
||||
JSONArray qaiList = queryAuthItemByWorkerList(project, workerIds, devSnToJoEntry, devSnToIscDevSnMap);
|
||||
Set<String> rtWorkerIdSet;
|
||||
if (CollUtil.isNotEmpty(qaiList)) {
|
||||
for (int i = 0; i < qaiList.size(); i++) {
|
||||
@ -713,11 +720,36 @@ public class AsyncHikvision {
|
||||
log.error("批量下发权限失败:", e);
|
||||
hikvisionCall.updateAllFailStatusIfNullForAuth(projectSn, new ArrayList<>(workerIdMap.values()), 1, 1);
|
||||
hikvisionCall.updateAllFailStatusIfNullForAuth(projectSn, new ArrayList<>(workerIdMap.values()), 1, 3);
|
||||
sendExcNotice(e, workerList, dev);
|
||||
sendExcNotice(e, workerList, dev, projectSn);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private JSONArray queryAuthItemByWorkerList(ProjectInfoExtVo project, List<String> workerIds, Map.Entry<String, List<JSONObject>> devSnToJoEntry, Map<String, JSONObject> devSnToIscDevSnMap) throws Exception {
|
||||
JSONArray rtJa = new JSONArray();
|
||||
for (List<String> splitList : CollUtil.splitList(workerIds, 1000)) {
|
||||
JSONObject qaiJo = HikvisionUtil.queryAuthItem(project, getQueryAuthItemParam(devSnToJoEntry, devSnToIscDevSnMap, splitList));
|
||||
JSONObject qaiRtJo = HikvisionUtil.getJSONObjectData(qaiJo);
|
||||
JSONArray qaiList = qaiRtJo.getJSONArray("list");
|
||||
rtJa.addAll(qaiList);
|
||||
}
|
||||
return rtJa;
|
||||
}
|
||||
|
||||
private void deleteAuthByWorkerList(ProjectInfoExtVo project, Map<String, JSONObject> devSnToIscDevSnMap, Map.Entry<String, List<JSONObject>> devSnToJoEntry, List<String> deleteAuthWorkerIds) throws Exception {
|
||||
for (List<String> splitWorkerIds : CollUtil.splitList(deleteAuthWorkerIds, 1000)) {
|
||||
JSONObject aaRJo = HikvisionUtil.deleteAuth(project, getAddOrDeleteAuthParam(devSnToJoEntry, splitWorkerIds, devSnToIscDevSnMap));
|
||||
HikvisionUtil.getJSONObjectData(aaRJo);
|
||||
}
|
||||
}
|
||||
|
||||
private void addAuthByWorkerList(ProjectInfoExtVo project, Map<String, JSONObject> devSnToIscDevSnMap, Map.Entry<String, List<JSONObject>> devSnToJoEntry, List<String> addAuthWorkerIds) throws Exception {
|
||||
for (List<String> splitWorkerIds : CollUtil.splitList(addAuthWorkerIds, 1000)) {
|
||||
JSONObject aaRJo = HikvisionUtil.addAuth(project, getAddOrDeleteAuthParam(devSnToJoEntry, splitWorkerIds, devSnToIscDevSnMap));
|
||||
HikvisionUtil.getJSONObjectData(aaRJo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理结果:一个设备批量下发人员
|
||||
*
|
||||
@ -811,9 +843,9 @@ public class AsyncHikvision {
|
||||
return aaJo;
|
||||
}
|
||||
|
||||
private JSONObject getQueryAuthItemParam(Map.Entry<String, List<JSONObject>> entry, Map<String, JSONObject> devSnToIscDevSnMap) {
|
||||
private JSONObject getQueryAuthItemParam(Map.Entry<String, List<JSONObject>> entry, Map<String, JSONObject> devSnToIscDevSnMap, List<String> workerIds) {
|
||||
JSONObject aaJo = new JSONObject();
|
||||
aaJo.put("personIds", entry.getValue().stream().map(jsonObject -> jsonObject.getString("workerId")).collect(Collectors.toList()));
|
||||
aaJo.put("personIds", workerIds);
|
||||
aaJo.put("resourceInfos", Collections.singletonList(new JoBuilder()
|
||||
.put("resourceIndexCode", devSnToIscDevSnMap.get(entry.getKey()).getString("parentIndexCode"))
|
||||
.put("resourceType", "acsDevice")
|
||||
|
||||
@ -515,10 +515,10 @@ public class AsyncConfig {
|
||||
public ThreadPoolTaskExecutor sendBatchExecutor() {
|
||||
MdcThreadPoolTaskExecutor executor = new MdcThreadPoolTaskExecutor();
|
||||
/** 核心线程数(默认线程数) */
|
||||
executor.setCorePoolSize(maxPoolSize * 5);
|
||||
executor.setCorePoolSize(maxPoolSize);
|
||||
/** 最大线程数 */
|
||||
executor.setMaxPoolSize(maxPoolSize * 5);
|
||||
executor.setQueueCapacity(queueCapacity * 10);
|
||||
executor.setMaxPoolSize(maxPoolSize);
|
||||
executor.setQueueCapacity(queueCapacity);
|
||||
/** 允许线程空闲时间(单位:默认为秒) */
|
||||
executor.setKeepAliveSeconds(60);
|
||||
/** 线程池名前缀 */
|
||||
@ -537,7 +537,7 @@ public class AsyncConfig {
|
||||
executor.setCorePoolSize(maxPoolSize);
|
||||
/** 最大线程数 */
|
||||
executor.setMaxPoolSize(maxPoolSize);
|
||||
executor.setQueueCapacity(queueCapacity);
|
||||
executor.setQueueCapacity(queueCapacity * 100);
|
||||
/** 允许线程空闲时间(单位:默认为秒) */
|
||||
executor.setKeepAliveSeconds(60);
|
||||
/** 线程池名前缀 */
|
||||
@ -556,7 +556,7 @@ public class AsyncConfig {
|
||||
executor.setCorePoolSize(maxPoolSize);
|
||||
/** 最大线程数 */
|
||||
executor.setMaxPoolSize(maxPoolSize);
|
||||
executor.setQueueCapacity(queueCapacity * 10);
|
||||
executor.setQueueCapacity(queueCapacity * 100);
|
||||
/** 允许线程空闲时间(单位:默认为秒) */
|
||||
executor.setKeepAliveSeconds(60);
|
||||
/** 线程池名前缀 */
|
||||
@ -568,4 +568,23 @@ public class AsyncConfig {
|
||||
return executor;
|
||||
}
|
||||
|
||||
@Bean("workerBeWaitHkExecutor")
|
||||
public ThreadPoolTaskExecutor workerBeWaitHkExecutor() {
|
||||
MdcThreadPoolTaskExecutor executor = new MdcThreadPoolTaskExecutor();
|
||||
/** 核心线程数(默认线程数) */
|
||||
executor.setCorePoolSize(maxPoolSize);
|
||||
/** 最大线程数 */
|
||||
executor.setMaxPoolSize(maxPoolSize);
|
||||
executor.setQueueCapacity(queueCapacity * 100);
|
||||
/** 允许线程空闲时间(单位:默认为秒) */
|
||||
executor.setKeepAliveSeconds(60);
|
||||
/** 线程池名前缀 */
|
||||
executor.setThreadNamePrefix("workerBeWaitHkExecutor-");
|
||||
// 线程池对拒绝任务的处理策略
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
|
||||
// 初始化
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -100,6 +100,18 @@ public class WorkerInfoController {
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@OperLog(operModul = "劳务管理", operType = "批量删除劳务人员", operDesc = "批量删除劳务人员信息")
|
||||
@ApiOperation(value = "批量删除劳务人员信息", notes = "批量删除劳务人员信息", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "ids", value = "劳务人员ids(多个逗号分隔)", paramType = "body", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "body", required = true, dataType = "String"),
|
||||
})
|
||||
@PostMapping(value = "/deleteBatch")
|
||||
public Result deleteBatch(@RequestBody Map<String, Object> map) {
|
||||
workerInfoService.deleteBatch(MapUtils.getString(map, "ids"));
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
|
||||
@ -165,4 +165,7 @@ public interface IWorkerInfoService extends IService<WorkerInfo> {
|
||||
void editWorkerForHikvision(WorkerInfo workerInfo);
|
||||
|
||||
void editWorkerAndAuthForHikvision(WorkerInfo workerInfo, WorkerInfo oldWorkerInfo);
|
||||
|
||||
void deleteBatch(String ids);
|
||||
|
||||
}
|
||||
|
||||
@ -2541,4 +2541,11 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
asyncHikvision.editWorkerAndAuthAsync(workerInfo, true, true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBatch(String ids) {
|
||||
for (String workerId : StrUtil.split(ids, ",")) {
|
||||
deleteWorkerInfo(workerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user