|  |  |  | 
|---|
|  |  |  | package com.doumee.service.business.impl.hksync; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.haikang.model.HKConstants; | 
|---|
|  |  |  | import com.doumee.core.haikang.model.param.BaseResponse; | 
|---|
|  |  |  | import com.doumee.core.haikang.model.param.request.VisitAppointmentRequest; | 
|---|
|  |  |  | import com.doumee.core.haikang.model.param.respose.VisitAppointmentResponse; | 
|---|
|  |  |  | import com.doumee.core.haikang.model.param.request.*; | 
|---|
|  |  |  | import com.doumee.core.haikang.model.param.respose.*; | 
|---|
|  |  |  | import com.doumee.core.haikang.service.HKService; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.DateUtil; | 
|---|
|  |  |  | import com.doumee.dao.business.DeviceMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.EmpowerJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.VisitsJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Device; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Empower; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Member; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Visits; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | public class HkSyncEmpowerServiceImpl extends HkSyncBaseServiceImpl { | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private EmpowerJoinMapper empowerJoinMapper; | 
|---|
|  |  |  | private EmpowerJoinMapper empowerMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DeviceMapper deviceMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 同步海康组织信息,根据erp同步组织结果,定时检查需要下发到海康的组织信息 | 
|---|
|  |  |  | * 定时查询权限下发任务进度执行结果 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public  void syncEmpowerData(){ | 
|---|
|  |  |  | public  void syncEmpowerDetailData(){ | 
|---|
|  |  |  | if(Constants.DEALING_HK_EMPOWER_DETAIL){ | 
|---|
|  |  |  | return   ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Constants.DEALING_HK_EMPOWER_DETAIL = true; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | //查询所有完成下载,待查询结果的数据记录 | 
|---|
|  |  |  | List<Empower>  list = getDealListDetail(); | 
|---|
|  |  |  | if(list == null || list.size() ==0){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(Empower c : list){ | 
|---|
|  |  |  | AuthItemListRequest param = new AuthItemListRequest(); | 
|---|
|  |  |  | param.setPageNo(1); | 
|---|
|  |  |  | param.setPageSize(100); | 
|---|
|  |  |  | param.setPersonIds(new ArrayList<>()); | 
|---|
|  |  |  | AuthItemListPersonRequest p = new AuthItemListPersonRequest(); | 
|---|
|  |  |  | p.setPersonIds(c.getMemberHkId()); | 
|---|
|  |  |  | param.getPersonIds().add(p); | 
|---|
|  |  |  | TaskDataAdditionResourceRequest rec = new TaskDataAdditionResourceRequest(); | 
|---|
|  |  |  | rec.setResourceIndexCode(c.getDeviceIndexCode()); | 
|---|
|  |  |  | rec.setResourceType(c.getDeviceType()); | 
|---|
|  |  |  | rec.setChannelNos(c.getDeviceChannelNo().split(",")); | 
|---|
|  |  |  | param.setResourceInfos(rec); | 
|---|
|  |  |  | //查询已下载 | 
|---|
|  |  |  | param.setPersonStatus(new Integer[]{3}); | 
|---|
|  |  |  | //查询下发状态 | 
|---|
|  |  |  | BaseResponse<AuthItemListResponse> response = HKService.authItemList(param); | 
|---|
|  |  |  | if(response!=null | 
|---|
|  |  |  | && StringUtils.equals(response.getCode(),HKConstants.RESPONSE_SUCCEE) | 
|---|
|  |  |  | && response.getData()!=null | 
|---|
|  |  |  | && response.getData().getList() != null | 
|---|
|  |  |  | && response.getData().getList().size()>0 ){ | 
|---|
|  |  |  | //更新已完成下载任务 | 
|---|
|  |  |  | empowerMapper.update(null,new UpdateWrapper<Empower>() | 
|---|
|  |  |  | .lambda() | 
|---|
|  |  |  | .eq(Empower::getHkId,c.getHkId() ) | 
|---|
|  |  |  | .set(Empower::getSendStatus,Constants.EmpowerStatus.pass) ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | }finally { | 
|---|
|  |  |  | Constants.DEALING_HK_EMPOWER_DETAIL=false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 定时查询权限下发任务进度执行结果 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public  void syncEmpowerResultData(){ | 
|---|
|  |  |  | if(Constants.DEALING_HK_EMPOWER_RESULT){ | 
|---|
|  |  |  | return   ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Constants.DEALING_HK_EMPOWER_RESULT=true; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | //查询所有执行中得数据 | 
|---|
|  |  |  | List<Empower>  list = getIngTaskListResult(); | 
|---|
|  |  |  | if(list == null || list.size() ==0){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(Empower c : list){ | 
|---|
|  |  |  | TaskProgressRequest param = new TaskProgressRequest(); | 
|---|
|  |  |  | param.setTaskId(c.getHkId()); | 
|---|
|  |  |  | //查询下发状态 | 
|---|
|  |  |  | BaseResponse<TaskProgressNumResponse> response = HKService.taskProgressNum(param); | 
|---|
|  |  |  | if(response!=null | 
|---|
|  |  |  | && StringUtils.equals(response.getCode(),HKConstants.RESPONSE_SUCCEE) | 
|---|
|  |  |  | && response.getData()!=null | 
|---|
|  |  |  | && response.getData().getIsDownloadFinished() != null | 
|---|
|  |  |  | && response.getData().getIsDownloadFinished() ){ | 
|---|
|  |  |  | //更新已完成下载任务 | 
|---|
|  |  |  | empowerMapper.update(null,new UpdateWrapper<Empower>() | 
|---|
|  |  |  | .lambda() | 
|---|
|  |  |  | .eq(Empower::getHkId,c.getHkId() ) | 
|---|
|  |  |  | .set(Empower::getSendStatus,Constants.EmpowerStatus.downloaded) ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | }finally { | 
|---|
|  |  |  | Constants.DEALING_HK_EMPOWER_RESULT =false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 处理人员授权数据,定时下发 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public  void syncEmpowerData() { | 
|---|
|  |  |  | if(Constants.DEALING_HK_EMPOWER){ | 
|---|
|  |  |  | return   ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Constants.DEALING_HK_EMPOWER =true; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | //查询所有需要同步的企业数据 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | MPJLambdaWrapper<Empower> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | queryWrapper.selectAll(Empower.class); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getName,Visits::getReceptMemberName) | 
|---|
|  |  |  | .select("t1.hk_id as receptMemberHkId") | 
|---|
|  |  |  | .leftJoin(Member.class,Member::getId,Visits::getReceptMemberId); | 
|---|
|  |  |  | queryWrapper.eq(Visits::getStatus,Constants.VisitStatus.pass)//审批通过 | 
|---|
|  |  |  | .eq(Visits::getHkStatus,Constants.ZERO)//未同步到海康 | 
|---|
|  |  |  | .orderByAsc(Visits::getCreateDate); | 
|---|
|  |  |  | List<Empower> list = empowerJoinMapper.selectJoinList(Empower.class,queryWrapper); | 
|---|
|  |  |  | if(list ==null || list.size()==0){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Date date = new Date(); | 
|---|
|  |  |  | for(Empower c : list) { | 
|---|
|  |  |  | //删除的数据,进行删除 | 
|---|
|  |  |  | VisitAppointmentRequest request = new VisitAppointmentRequest(); | 
|---|
|  |  |  | BaseResponse<VisitAppointmentResponse> response = HKService.visitAppiontment(request); | 
|---|
|  |  |  | if (response != null | 
|---|
|  |  |  | && StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) | 
|---|
|  |  |  | &&response.getData()!=null | 
|---|
|  |  |  | &&StringUtils.isNotBlank(response.getData().getAppointRecordId())) { | 
|---|
|  |  |  | //海康下发成功 | 
|---|
|  |  |  | c.setHkId( response.getData().getAppointRecordId());//预约标识 | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //海康下发成功 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | empowerJoinMapper.updateById(c); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //先删除所有需要取消授权的数据 | 
|---|
|  |  |  | //            dealDelListTask(getDealList(Constants.ONE)); | 
|---|
|  |  |  | //查询所有需要同步的数据 | 
|---|
|  |  |  | dealNewListTask(getDealList(Constants.ZERO)); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | }finally { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void dealDelListTask(List<Empower> list) { | 
|---|
|  |  |  | //按照父级申请分批处理每次申请数据 | 
|---|
|  |  |  | if(list ==null || list.size()==0){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Date date = new Date(); | 
|---|
|  |  |  | //创建任务 | 
|---|
|  |  |  | String taskId = hkTaskAddtion(); | 
|---|
|  |  |  | List<Empower> successList = new ArrayList<>(); | 
|---|
|  |  |  | List<Empower> errorList = new ArrayList<>(); | 
|---|
|  |  |  | for(Empower c : list) { | 
|---|
|  |  |  | //向任务添加人员、设备信息数据 | 
|---|
|  |  |  | if(addTaskData(c,taskId,HKConstants.OPERA_TYPE.DEL.getKey())){ | 
|---|
|  |  |  | successList.add(c); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | errorList.add(c); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(successList.size()>0){ | 
|---|
|  |  |  | //开始执行下发 | 
|---|
|  |  |  | boolean status = startTask(taskId); | 
|---|
|  |  |  | for(Empower model : successList){ | 
|---|
|  |  |  | Empower update = new Empower(); | 
|---|
|  |  |  | update.setId(model.getId()); | 
|---|
|  |  |  | update.setSendDate(date); | 
|---|
|  |  |  | update.setEditDate(date); | 
|---|
|  |  |  | update.setHkId(taskId); | 
|---|
|  |  |  | update.setRemark(status?"下发任务成功":"下发任务失败"); | 
|---|
|  |  |  | //下发中 | 
|---|
|  |  |  | update.setSendStatus(status?Constants.EmpowerStatus.ing:Constants.EmpowerStatus.fail); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(Empower model : errorList){ | 
|---|
|  |  |  | Empower update = new Empower(); | 
|---|
|  |  |  | update.setId(model.getId()); | 
|---|
|  |  |  | update.setSendDate(date); | 
|---|
|  |  |  | update.setEditDate(date); | 
|---|
|  |  |  | update.setHkId(taskId); | 
|---|
|  |  |  | update.setSendStatus(Constants.EmpowerStatus.fail); | 
|---|
|  |  |  | update.setRemark( "添加下发任务数据刪除授权失败"); | 
|---|
|  |  |  | empowerMapper.updateById(update); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void dealNewListTask(List<Empower> list) { | 
|---|
|  |  |  | //按照父级申请分批处理每次申请数据 | 
|---|
|  |  |  | if(list ==null || list.size()==0){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | clearAllEmpowerFirst(list); | 
|---|
|  |  |  | Date date = new Date(); | 
|---|
|  |  |  | //创建任务 | 
|---|
|  |  |  | String taskId = hkTaskAddtion(); | 
|---|
|  |  |  | List<Empower> successList = new ArrayList<>(); | 
|---|
|  |  |  | List<Empower> errorList = new ArrayList<>(); | 
|---|
|  |  |  | for(Empower c : list) { | 
|---|
|  |  |  | //向任务添加人员、设备信息数据 | 
|---|
|  |  |  | if(addTaskData(c,taskId,HKConstants.OPERA_TYPE.ADD.getKey())){ | 
|---|
|  |  |  | successList.add(c); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | errorList.add(c); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(successList.size()>0){ | 
|---|
|  |  |  | //开始执行下发 | 
|---|
|  |  |  | boolean status = startTask(taskId); | 
|---|
|  |  |  | for(Empower model : successList){ | 
|---|
|  |  |  | Empower update = new Empower(); | 
|---|
|  |  |  | update.setId(model.getId()); | 
|---|
|  |  |  | update.setSendDate(date); | 
|---|
|  |  |  | update.setEditDate(date); | 
|---|
|  |  |  | update.setHkId(taskId); | 
|---|
|  |  |  | update.setRemark(status?"下发任务成功":"下发任务失败"); | 
|---|
|  |  |  | //下发中 | 
|---|
|  |  |  | update.setSendStatus(status?Constants.EmpowerStatus.ing:Constants.EmpowerStatus.fail); | 
|---|
|  |  |  | empowerMapper.updateById(update); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for(Empower model : errorList){ | 
|---|
|  |  |  | Empower update = new Empower(); | 
|---|
|  |  |  | update.setId(model.getId()); | 
|---|
|  |  |  | update.setSendDate(date); | 
|---|
|  |  |  | update.setEditDate(date); | 
|---|
|  |  |  | update.setHkId(taskId); | 
|---|
|  |  |  | update.setSendStatus(Constants.EmpowerStatus.fail); | 
|---|
|  |  |  | update.setRemark( "添加下发任务数据失败"); | 
|---|
|  |  |  | empowerMapper.updateById(update); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void clearAllEmpowerFirst(List<Empower> list) { | 
|---|
|  |  |  | //查询全部数据 | 
|---|
|  |  |  | List<Device> allDevice = deviceMapper.selectList(new QueryWrapper<Device>().lambda().isNotNull(Device::getHkId)); | 
|---|
|  |  |  | //创建任务 | 
|---|
|  |  |  | String taskId = hkTaskAddtion(); | 
|---|
|  |  |  | for(Empower c : list) { | 
|---|
|  |  |  | //向任务添加人员、设备信息数据 | 
|---|
|  |  |  | addTaskDataAll(c,taskId,allDevice); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | startTask(taskId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private boolean addTaskData(Empower c,String taskId,int type) { | 
|---|
|  |  |  | 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   资源对象 | 
|---|
|  |  |  | TaskDataAdditionResourceRequest res = new TaskDataAdditionResourceRequest(); | 
|---|
|  |  |  | res.setChannelNos(c.getDeviceChannelNo().split(",")); | 
|---|
|  |  |  | res.setResourceType(c.getDeviceType()); | 
|---|
|  |  |  | 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(type); | 
|---|
|  |  |  | 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 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.selectAll(Empower.class); | 
|---|
|  |  |  | queryWrapper.selectAs(Device::getChannelNo,Empower::getDeviceChannelNo); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getHkId,Empower::getMemberHkId); | 
|---|
|  |  |  | queryWrapper.selectAs(Device::getHkId,Empower::getDeviceIndexCode); | 
|---|
|  |  |  | queryWrapper.selectAs(Device::getResourceType,Empower::getDeviceType); | 
|---|
|  |  |  | 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.last("limit 100");//每次限制下发100个 | 
|---|
|  |  |  | List<Empower> list = empowerMapper.selectJoinList(Empower.class,queryWrapper); | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private List<Empower> getDealListDetail() { | 
|---|
|  |  |  | MPJLambdaWrapper<Empower> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | queryWrapper.selectAll(Empower.class); | 
|---|
|  |  |  | queryWrapper.selectAs(Device::getChannelNo,Empower::getDeviceChannelNo); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getHkId,Empower::getMemberHkId); | 
|---|
|  |  |  | queryWrapper.leftJoin(Member.class,Member::getId,Empower::getMemberId); | 
|---|
|  |  |  | queryWrapper.selectAs(Device::getHkId,Empower::getDeviceIndexCode); | 
|---|
|  |  |  | queryWrapper.selectAs(Device::getDevTypeCode,Empower::getDeviceType); | 
|---|
|  |  |  | queryWrapper.leftJoin(Device.class,Device::getId,Empower::getDeviceId); | 
|---|
|  |  |  | queryWrapper.eq(Empower::getSendStatus,Constants.EmpowerStatus.downloaded); | 
|---|
|  |  |  | List<Empower> list = empowerMapper.selectJoinList(Empower.class,queryWrapper); | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private List<Empower> getIngTaskListResult() { | 
|---|
|  |  |  | MPJLambdaWrapper<Empower> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | queryWrapper.selectAll(Empower.class); | 
|---|
|  |  |  | queryWrapper.eq(Empower::getSendStatus,Constants.EmpowerStatus.ing); | 
|---|
|  |  |  | queryWrapper.groupBy(Empower::getHkId); | 
|---|
|  |  |  | List<Empower> list = empowerMapper.selectJoinList(Empower.class,queryWrapper); | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|