| | |
| | | Constants.DEALING_HK_EMPOWER =true; |
| | | try { |
| | | //先删除所有需要取消授权的数据 |
| | | // dealDelListTask(getDealList(Constants.ONE)); |
| | | dealDelListTask(getDealList(Constants.ONE)); |
| | | //查询所有需要同步的数据 |
| | | dealNewListTask(getDealList(Constants.ZERO)); |
| | | }catch (Exception e){ |
| | |
| | | if(list ==null || list.size()==0){ |
| | | return; |
| | | } |
| | | clearAllEmpowerFirst(list); |
| | | // clearAllEmpowerFirst(list); |
| | | Date date = new Date(); |
| | | //创建任务 |
| | | String taskId = hkTaskAddtion(); |
| | |
| | | //创建任务 |
| | | String taskId = hkTaskAddtion(); |
| | | for(Empower c : list) { |
| | | //向任务添加人员、设备信息数据 |
| | | addTaskDataAll(c,taskId,allDevice); |
| | | //向任务刪除人员的所有设备信息数据 |
| | | addTaskDataAllDel(c.getHkId(),taskId,allDevice); |
| | | } |
| | | startTask(taskId); |
| | | } |
| | |
| | | return false; |
| | | } |
| | | } |
| | | private boolean addTaskDataAll(Empower c,String taskId,List<Device> deviceList) { |
| | | if(StringUtils.isBlank(c.getMemberHkId() ) |
| | | ||StringUtils.isBlank(c.getDeviceChannelNo()) |
| | | ||StringUtils.isBlank(c.getDeviceType()) |
| | | ||StringUtils.isBlank(c.getDeviceIndexCode())){ |
| | | //必填参数校验 |
| | | return false; |
| | | } |
| | | TaskDataAdditionRequest param = new TaskDataAdditionRequest(); |
| | | param.setTaskId(taskId); |
| | | List<TaskDataAdditionResourceRequest> resourceInfos = new ArrayList<>();// object[] True 资源对象 |
| | | for(Device d:deviceList){ |
| | | TaskDataAdditionResourceRequest res = new TaskDataAdditionResourceRequest(); |
| | | res.setChannelNos(d.getChannelNo().split(",")); |
| | | res.setResourceType(d.getResourceType()); |
| | | res.setResourceIndexCode(c.getDeviceIndexCode()); |
| | | resourceInfos.add(res); |
| | | } |
| | | List<TaskDataAdditionPersonRequest> personInfos = new ArrayList<>(); |
| | | TaskDataAdditionPersonRequest pinfo = new TaskDataAdditionPersonRequest(); |
| | | pinfo.setName(c.getMemberName()); |
| | | pinfo.setEndTime(DateUtil.getISO8601Timestamp(c.getEndTime())); |
| | | pinfo.setStartTime(DateUtil.getISO8601Timestamp(c.getStartTime())); |
| | | pinfo.setOperatorType(HKConstants.OPERA_TYPE.DEL.getKey()); |
| | | pinfo.setPersonId(c.getMemberHkId()); |
| | | param.setResourceInfos(resourceInfos); |
| | | param.setPersonInfos(personInfos); |
| | | BaseResponse response = HKService.taskDataAddition(param); |
| | | if(response!=null |
| | | && StringUtils.equals(response.getCode(),HKConstants.RESPONSE_SUCCEE)){ |
| | | return true; |
| | | }else{ |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private boolean startTask(String taskId) { |
| | | TaskProgressRequest param = new TaskProgressRequest(); |
| | | param.setTaskId(taskId); |
| | | BaseResponse response = HKService.taskStart(param); |
| | | if(response!=null |
| | | && StringUtils.equals(response.getCode(),HKConstants.RESPONSE_SUCCEE)){ |
| | | return true; |
| | | }else{ |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private String hkTaskAddtion() { |
| | | TaskAdditionRequest param = new TaskAdditionRequest(); |
| | | param.setTaskType(HKConstants.TASK_TYPE.FACE.getKey()); |
| | | BaseResponse<TaskAdditionResponse> response = HKService.taskAddition(param); |
| | | if(response!=null |
| | | && StringUtils.equals(response.getCode(),HKConstants.RESPONSE_SUCCEE) |
| | | && response.getData()!=null |
| | | && StringUtils.isNotBlank(response.getData().getTaskId())){ |
| | | return response.getData().getTaskId(); |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "海康创建下载任务失败=================="); |
| | | } |
| | | } |
| | | |
| | | private List<Empower> getDealList(int del ) { |
| | | MPJLambdaWrapper<Empower> queryWrapper = new MPJLambdaWrapper<>(); |
| | |
| | | queryWrapper.leftJoin(Device.class,Device::getId,Empower::getDeviceId); |
| | | queryWrapper.leftJoin(Member.class,Member::getId,Empower::getMemberId); |
| | | queryWrapper.eq(Empower::getSendStatus,Constants.EmpowerStatus.wait); |
| | | // queryWrapper.eq( Empower::getIsdeleted,del); |
| | | queryWrapper.eq( Empower::getIsdeleted,del); |
| | | // queryWrapper.last("limit 100");//每次限制下发100个 |
| | | List<Empower> list = empowerMapper.selectJoinList(Empower.class,queryWrapper); |
| | | return list; |