|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | 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.HKResponseCode; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.core.utils.DateUtil; | 
|---|
|  |  |  | import com.doumee.dao.business.DeviceMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.MemberCardMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.MemberMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.dao.MemberMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.EmpowerJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.VisitsJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Member; | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.scheduling.annotation.Async; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public  Integer   syncEmpowerDetailData(Integer endId){ | 
|---|
|  |  |  | log.error(""); | 
|---|
|  |  |  | //        if(Constants.DEALING_HK_EMPOWER_DETAIL){ | 
|---|
|  |  |  | //            return   ; | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | 
|---|
|  |  |  | //查询下发状态 | 
|---|
|  |  |  | BaseResponse<TaskPersonDetailListResponse> response = HKService.taskPersoDetail(param); | 
|---|
|  |  |  | if(response!=null | 
|---|
|  |  |  | && StringUtils.equals(response.getCode(),HKConstants.RESPONSE_SUCCEE) | 
|---|
|  |  |  | && StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) | 
|---|
|  |  |  | && response.getData()!=null | 
|---|
|  |  |  | && response.getData().getList() != null | 
|---|
|  |  |  | && response.getData().getList().size() > 0 | 
|---|
|  |  |  | 
|---|
|  |  |  | request.setPersonIds(new String[]{delHkIds}); | 
|---|
|  |  |  | BaseResponse<List<UserDelResponse>> result =  HKService.delBatchUser(request); | 
|---|
|  |  |  | boolean succes = false; | 
|---|
|  |  |  | if(result !=null && StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE)){ | 
|---|
|  |  |  | if(result !=null && StringUtils.equals(result.getCode(), HKConstants.RESPONSE_SUCCEE)){ | 
|---|
|  |  |  | //标记删除成功的数据(海康对接状态为已同步,,同步失败的仍为待同步,等下一次继续处理,知道全部删除完毕) | 
|---|
|  |  |  | if(result.getData()!=null && result.getData().size()>0){ | 
|---|
|  |  |  | UserDelResponse tem = result.getData().get(0); | 
|---|
|  |  |  | 
|---|
|  |  |  | Thread t1=new Thread(new Runnable() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void run() { | 
|---|
|  |  |  | dealAllListTask(allList); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | dealAllListTask(allList); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | log.info("======================下发授权异常:"+e.getMessage()); | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | t1.start(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public class TaskRuner implements Runnable{ | 
|---|
|  |  |  | private    List<Empower> list ; | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void run() { | 
|---|
|  |  |  | dealNewListTask(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<Empower> getList() { | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setList(List<Empower> list) { | 
|---|
|  |  |  | this.list = list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | private void dealAllListTask(List<Empower> list) { | 
|---|
|  |  |  | //按照父级申请分批处理每次申请数据 | 
|---|
|  |  |  | if(list ==null || list.size()==0){ | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Empower> faceErrorList = new ArrayList<>(); | 
|---|
|  |  |  | for(Empower c : list) { | 
|---|
|  |  |  | //向任务添加人员、设备信息数据 | 
|---|
|  |  |  | if((Constants.equalsInteger(c.getMemberDeleted(),Constants.ONE) && | 
|---|
|  |  |  | if((Constants.equalsInteger(c.getIsdeleted(),Constants.ZERO) && | 
|---|
|  |  |  | Constants.equalsInteger(c.getMemberDeleted(),Constants.ONE) && | 
|---|
|  |  |  | Constants.equalsInteger(c.getMemberHkStatus(),Constants.ONE)) | 
|---|
|  |  |  | ||  Constants.equalsInteger(c.getDeviceDeleted(),1)){ | 
|---|
|  |  |  | //如果人員或者設備删除,取消下发 | 
|---|
|  |  |  | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(c.getMemberDeleted(),Constants.ONE) | 
|---|
|  |  |  | && Constants.equalsInteger(c.getIsdeleted(),1)){ | 
|---|
|  |  |  | && Constants.equalsInteger(c.getMemberHkStatus(),Constants.ONE) | 
|---|
|  |  |  | && Constants.equalsInteger(c.getIsdeleted(),Constants.ZERO)){ | 
|---|
|  |  |  | //如果人员已离职,新增授权无需下发,取消下发 | 
|---|
|  |  |  | cacenList.add(c); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | HKConstants.OPERA_TYPE flag = HKConstants.OPERA_TYPE.ADD; | 
|---|
|  |  |  | if(Constants.equalsObject(c.getIsdeleted(),Constants.ONE)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(c.getIsdeleted(),Constants.ONE)){ | 
|---|
|  |  |  | flag = HKConstants.OPERA_TYPE.DEL; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(addTaskData(c,taskId,flag.getKey())){ | 
|---|
|  |  |  | 
|---|
|  |  |  | queryWrapper.selectAs(Device::getChannelNo,Empower::getDeviceChannelNo); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getHkId,Empower::getMemberHkId); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getFaceStatus,Empower::getMemberFaceStatus); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getHkStatus,Empower::getMemberFaceStatus); | 
|---|
|  |  |  | queryWrapper.selectAs(Device::getOnline,Empower::getMemberHkStatus); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getHkStatus,Empower::getMemberHkStatus); | 
|---|
|  |  |  | queryWrapper.selectAs(Device::getOnline,Empower::getDeviceOnline); | 
|---|
|  |  |  | queryWrapper.selectAs(Device::getIsdeleted,Empower::getDeviceDeleted); | 
|---|
|  |  |  | queryWrapper.selectAs(Member::getIsdeleted,Empower::getMemberDeleted); | 
|---|
|  |  |  | queryWrapper.selectAs(Device::getHkId,Empower::getDeviceIndexCode); | 
|---|