|  |  | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
 |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
 |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
 |  |  | import com.dingtalk.api.response.OapiV2DepartmentGetResponse; | 
 |  |  | import com.dingtalk.api.response.OapiV2DepartmentListsubResponse; | 
 |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
 |  |  | import com.doumee.config.DataSyncConfig; | 
 |  |  | import com.doumee.core.constants.ResponseStatus; | 
 |  |  | import com.doumee.core.dingTalk.DingTalk; | 
 |  |  | import com.doumee.core.erp.ErpConstants; | 
 |  |  | import com.doumee.core.erp.model.openapi.request.erp.OrgListRequest; | 
 |  |  | import com.doumee.core.erp.model.openapi.response.erp.ErpOrgListResponse; | 
 |  |  | import com.doumee.core.exception.BusinessException; | 
 |  |  | import com.doumee.core.haikang.model.HKConstants; | 
 |  |  | import com.doumee.core.haikang.model.param.BaseResponse; | 
 |  |  | 
 |  |  | import com.doumee.dao.system.model.SystemUser; | 
 |  |  | import com.doumee.service.business.CompanyService; | 
 |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
 |  |  | import com.taobao.api.ApiException; | 
 |  |  | import org.apache.commons.collections.CollectionUtils; | 
 |  |  | import org.apache.commons.lang3.StringUtils; | 
 |  |  | import org.apache.shiro.SecurityUtils; | 
 |  |  | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  | import shade.com.alibaba.fastjson2.JSONArray; | 
 |  |  | import shade.com.alibaba.fastjson2.JSONObject; | 
 |  |  |  | 
 |  |  | import java.util.*; | 
 |  |  | import java.util.stream.Collectors; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private CompanyJoinMapper companyJoinMapper; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private DingTalk dingTalk; | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
 |  |  | 
 |  |  |                 throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,父级组织信息尚未同步下发成功~"); | 
 |  |  |             } | 
 |  |  |             if(Objects.nonNull(parent.getType())&&!Constants.equalsInteger(parent.getType(),-1)){ | 
 |  |  |                 if(Constants.equalsInteger(company.getType(),parent.getType())){ | 
 |  |  |                 if(!Constants.equalsInteger(company.getType(),parent.getType())){ | 
 |  |  |                     throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,组织信息错误"); | 
 |  |  |                 } | 
 |  |  |             }else if(Objects.isNull(parent.getType())){ | 
 |  |  | 
 |  |  |                 throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,组织同步下发失败,请稍后重试"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |         queryWrapper.eq(Objects.nonNull(pageWrap.getModel().getStatus()),Company::getStatus,Constants.ZERO); | 
 |  |  |         queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getName()),Company::getName,pageWrap.getModel().getName()); | 
 |  |  |         queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getParentName()),"c.name",pageWrap.getModel().getParentName()); | 
 |  |  |         queryWrapper.orderByAsc(Company::getPinyin); | 
 |  |  |         queryWrapper.orderByAsc(Company::getSortnum); | 
 |  |  |         IPage<Company> companyIPage = companyJoinMapper.selectJoinPage(page, Company.class, queryWrapper); | 
 |  |  |         return PageData.from(companyIPage); | 
 |  |  |     } | 
 |  |  | 
 |  |  |  | 
 |  |  |         wrapper.eq(Company::getIsdeleted,Constants.ZERO) | 
 |  |  |                 .eq(Constants.equalsInteger(type,Constants.ONE),Company::getType,type) | 
 |  |  |                 .orderByAsc(Company::getPinyin); | 
 |  |  |                 .orderByAsc(Company::getSortnum); | 
 |  |  |         List<Company> companies = companyMapper.selectList(wrapper); | 
 |  |  |         return getCompanyTree( companies, null); | 
 |  |  |     } | 
 |  |  | 
 |  |  |         queryWrapper.eq(Company::getIsdeleted,Constants.ZERO); | 
 |  |  |         if(Objects.nonNull(type) && ( Constants.equalsInteger(type,Constants.ONE) || Constants.equalsInteger(type,Constants.ZERO))){ | 
 |  |  | //            queryWrapper.eq(type!=null,Company::getType,type); | 
 |  |  |             queryWrapper.apply("( type = "+type+" or type  = -1  )"); | 
 |  |  |             queryWrapper.apply("( t.type = "+type+" or t.type  = -1  )"); | 
 |  |  |         }else if(Objects.nonNull(type) &&  Constants.equalsInteger(type,Constants.TWO)){ | 
 |  |  |             String companySpecialId = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.SPECIAL_COMPANY_ID).getCode(); | 
 |  |  |             if(StringUtils.isNotBlank(companySpecialId)){ | 
 |  |  | 
 |  |  |         for (Company updCompany:companyPool) { | 
 |  |  |             companyMapper.updateById(updCompany); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     // org_dept_create 部门新建 {"timeStamp":"1758783935796","eventId":"0c779adba04143958a3960e8e36bbce5","deptId":[1040735458]} | 
 |  |  |     // org_dept_modify 部门修改 {"timeStamp":"1758785791639","eventId":"6c2d8c7a61a7419e8928fda3effb3bf4","deptId":[1040735458]} | 
 |  |  |     // org_dept_remove 部门删除 {"timeStamp":"1758785817760","eventId":"47e289f334e041719ed354052da474de","deptId":[1040735458]} | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public void ddPushCompanyInfo(String eventType, JSONObject eventData) throws ApiException { | 
 |  |  |         JSONArray jsonArray = eventData.getJSONArray("deptId"); | 
 |  |  |         if(jsonArray.isEmpty()){ | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |         if(eventType.equals("org_dept_remove")){ | 
 |  |  |             //删除对应部门信息 | 
 |  |  |             List<Long> deptIdList = new ArrayList<>(); | 
 |  |  |             for (int i = 0; i < jsonArray.size(); i++) { | 
 |  |  |                 Long deptId = jsonArray.getLong(i); | 
 |  |  |                  deptIdList.add(deptId); | 
 |  |  |             } | 
 |  |  |             if(CollectionUtils.isNotEmpty(deptIdList)){ | 
 |  |  |                 syncDelCompany(deptIdList); | 
 |  |  |             } | 
 |  |  |         }else if(eventType.equals("org_dept_create")||eventType.equals("org_dept_modify")){ | 
 |  |  |             for (int i = 0; i < jsonArray.size(); i++) { | 
 |  |  |                 Company company  = companyMapper.selectOne(new QueryWrapper<Company>().lambda() | 
 |  |  |                         .eq(Company::getIsdeleted,Constants.ZERO) | 
 |  |  |                         .eq(Company::getErpId,jsonArray.getLong(i)) | 
 |  |  |                 ); | 
 |  |  |                 OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse = dingTalk.syncDepartmentInfo(jsonArray.getLong(i)); | 
 |  |  |                 if(Objects.isNull(company)){ | 
 |  |  |                     getAddCompanyModel(deptGetResponse,company); | 
 |  |  |                 }else{ | 
 |  |  |                     getUpdateCompanyModel(deptGetResponse,company); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void doHkDeleteOrg(List<Integer> delIds,List<String> delHkIds,  Date date) { | 
 |  |  |         if(delHkIds.size() == 0){ | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |         OrgDelRequest request = new OrgDelRequest(); | 
 |  |  |         request.setIndexCodes( delHkIds.toArray(new String[]{})); | 
 |  |  |         BaseResponse<List<OrgUpdateFailureResponse>> result =  HKService.delBatchOrg(request); | 
 |  |  |         if(result !=null && StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE)){ | 
 |  |  |             List<String> fIds = new ArrayList<>(); | 
 |  |  |             if(result.getData()!=null){ | 
 |  |  |                 for(OrgUpdateFailureResponse r : result.getData()){ | 
 |  |  |                     if(r.getCode().equals("0x00052102")){ | 
 |  |  |                         //不存在的也算删除成功 | 
 |  |  |                         fIds.add(r.getOrgIndexCode());//删除失败的数据集合 | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             //标记删除成功的数据(海康对接状态为已同步,,同步失败的仍为待同步,等下一次继续处理,知道全部删除完毕) | 
 |  |  |             companyMapper.update(null,new UpdateWrapper<Company>().lambda() | 
 |  |  |                     .set(Company::getHkStatus,Constants.ONE) | 
 |  |  |                     .set(Company::getHkDate,date) | 
 |  |  |                     .set(Company::getHkId,null ) | 
 |  |  |                     .in(Company::getId, delIds) | 
 |  |  |                     .notIn(fIds.size()>0,Company::getHkId, fIds)); | 
 |  |  |             companyMapper.update(null,new UpdateWrapper<Company>().lambda() | 
 |  |  |                     .set(Company::getHkStatus,Constants.TWO) | 
 |  |  |                     .set(Company::getHkDate,date) | 
 |  |  |                     .in(Company::getId, delIds) | 
 |  |  |                     .in(fIds.size()>0,Company::getHkId, fIds)); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public String syncDDCompany() throws ApiException { | 
 |  |  |         List<OapiV2DepartmentGetResponse.DeptGetResponse> list = dingTalk.syncAllDDDepartmentList(); | 
 |  |  |         if(list !=null && list.size()>0){ | 
 |  |  |             List<Company> addList = new ArrayList<>(); | 
 |  |  |             List<Company> updateList = new ArrayList<>(); | 
 |  |  |             List<Long> delIds = new ArrayList<>();//修改为使用钉钉id  erpId | 
 |  |  |             List<Company>  allList = companyMapper.selectList(new QueryWrapper<Company>().lambda() | 
 |  |  |                     .eq(Company::getIsdeleted,Constants.ZERO).eq(Company::getType,Constants.ONE)); | 
 |  |  |             dealCompanyChangeList(list,addList,updateList,delIds,allList); | 
 |  |  |             if(delIds.size()>0){ | 
 |  |  |                 syncDelCompany(delIds); | 
 |  |  |             } | 
 |  |  |             return "同步数据:新增【"+addList.size()+"】条,更新【"+updateList.size()+"】条,删除【"+delIds.size()+"】条"; | 
 |  |  |         }else{ | 
 |  |  |             throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "同步钉钉数据为空!"); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void dealCompanyChangeList(List<OapiV2DepartmentGetResponse.DeptGetResponse> list, List<Company> addList, List<Company> updateList, List<Long> delIds, List<Company> allList) { | 
 |  |  |         Date date = new Date(); | 
 |  |  |         for(OapiV2DepartmentGetResponse.DeptGetResponse respone : list){ | 
 |  |  |             //根据erpid查询企业信息,判断是新增还是更新 | 
 |  |  |             Company company = findCompanyByERPId(allList,respone.getDeptId().toString()); | 
 |  |  |             if(company == null){ | 
 |  |  |                 //如果是新增 | 
 |  |  |                 //封装新增组织对象数据 | 
 |  |  |                 addList.add(getAddCompanyModel(respone,new Company())); | 
 |  |  |             }else{ | 
 |  |  |                 updateList.add(getUpdateCompanyModel(respone,company)); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         if(allList!=null && allList.size()>0){ | 
 |  |  |             for(Company  c : allList){ | 
 |  |  |                 if(!isCompanyDeleted(c,list)){ | 
 |  |  |                     delIds.add(Long.valueOf(c.getErpId())); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 整理钉钉同步 新增组织对象 | 
 |  |  |      * @param deptGetResponse | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     private Company getAddCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse,Company company) { | 
 |  |  |         return  syncDDAddCompanyModel(deptGetResponse,company); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 整理钉钉同步 新增 需要修改的组织对象 | 
 |  |  |      * @param deptGetResponse | 
 |  |  |      * @param company | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     private Company getUpdateCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse, Company company) { | 
 |  |  |         return syncDDEditCompanyModel(deptGetResponse,company); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 根据ERPID  判断数据是否已在集合里存在 | 
 |  |  |      * @param allList | 
 |  |  |      * @param id | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     private Company findCompanyByERPId(List<Company> allList, String id) { | 
 |  |  |         if(allList!=null){ | 
 |  |  |             for(Company com :allList){ | 
 |  |  |                 if(StringUtils.equals(com.getErpId(),id)){ | 
 |  |  |                     return com; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return  null; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private boolean isCompanyDeleted(Company c, List<OapiV2DepartmentGetResponse.DeptGetResponse> list) { | 
 |  |  |         for(OapiV2DepartmentGetResponse.DeptGetResponse m : list){ | 
 |  |  |             if(StringUtils.equals(c.getErpId(),m.getDeptId().toString())){ | 
 |  |  |                 return  true; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return false; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 整理 钉钉同步的 组织信息 | 
 |  |  |      * @param deptGetResponse | 
 |  |  |      * @param company | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public Company syncDDAddCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse,Company company){ | 
 |  |  |         company = new Company(); | 
 |  |  |         company.setCreateDate(new Date()); | 
 |  |  |         company.setIsdeleted(Constants.ZERO); | 
 |  |  |         company.setStatus(Constants.ZERO); | 
 |  |  |  | 
 |  |  |         company.setName(deptGetResponse.getName()); | 
 |  |  |         company.setErpId(deptGetResponse.getDeptId().toString()); | 
 |  |  |         company.setErpParentId(deptGetResponse.getParentId().toString()); | 
 |  |  |         company.setSortnum(deptGetResponse.getOrder().intValue());//默认最上面 | 
 |  |  |  | 
 |  |  |         company.setType(Constants.ONE); | 
 |  |  |         String rootOrgId = systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_ROOTORG_CODE).getCode(); | 
 |  |  |         company.setCompanyPath(company.getId()+"/");//名称路径 | 
 |  |  |         company.setCompanyNamePath(company.getName());//名称路径 | 
 |  |  |         company.setHkParentId(rootOrgId); | 
 |  |  |         String idPath = ""; | 
 |  |  |         if(StringUtils.isNotBlank(company.getErpParentId())){ | 
 |  |  |             Company parent = companyMapper.selectOne(new QueryWrapper<Company>().lambda().eq(Company::getErpId,company.getErpParentId()) | 
 |  |  |                     .eq(Company::getIsdeleted,Constants.ZERO).last(" limit 1 ")); | 
 |  |  |             if(parent == null || Constants.equalsInteger(parent.getIsdeleted(),Constants.ONE)){ | 
 |  |  |                 throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,父级组织信息不存在~"); | 
 |  |  |             } | 
 |  |  | //            if(StringUtils.isBlank(parent.getHkId())){ | 
 |  |  | //                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,父级组织信息尚未同步下发成功~"); | 
 |  |  | //            } | 
 |  |  |             if(Objects.nonNull(parent.getType())&&!Constants.equalsInteger(parent.getType(),-1)){ | 
 |  |  |                 if(!Constants.equalsInteger(company.getType(),parent.getType())){ | 
 |  |  |                     throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,组织信息错误"); | 
 |  |  |                 } | 
 |  |  |             }else if(Objects.isNull(parent.getType())){ | 
 |  |  |                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,组织信息错误"); | 
 |  |  |             } | 
 |  |  |             idPath = parent.getCompanyPath(); | 
 |  |  |             company.setHkParentId(parent.getHkId()); | 
 |  |  |             company.setCompanyPath(parent.getCompanyPath()+company.getId()+"/"); | 
 |  |  |             company.setCompanyNamePath(parent.getCompanyNamePath()+"/"+company.getName()); | 
 |  |  |             company.setParentId(parent.getId()); | 
 |  |  |         } | 
 |  |  |         company.setHkCompanyPath(company.getCompanyNamePath()); | 
 |  |  |         company.setCreateDate(new Date()); | 
 |  |  |         company.setIsdeleted(Constants.ZERO); | 
 |  |  |         company.setHkStatus(Constants.ZERO); | 
 |  |  |         company.setStatus(Constants.ZERO); | 
 |  |  |         company.setHkDate(company.getCreateDate()); | 
 |  |  |         company.setEditDate(company.getCreateDate()); | 
 |  |  |         company.setEditor(company.getCreator()); | 
 |  |  |         company.setPinyin(Constants.getChinesePingyin(company.getName())); | 
 |  |  |         companyMapper.insert(company); | 
 |  |  |  | 
 |  |  |         company.setHkId(UUID.randomUUID().toString().replace("-","")); | 
 |  |  |         //下发海康安防平台 | 
 |  |  |         Boolean issueStatus = addHkOrg(company); | 
 |  |  |         Company com = new Company(); | 
 |  |  |         com.setId(company.getId()); | 
 |  |  |         com.setHkId(issueStatus?company.getHkId():null); | 
 |  |  |         com.setHkStatus(issueStatus?Constants.ONE:Constants.TWO); | 
 |  |  |         com.setCompanyPath(idPath+company.getId()+"/"); | 
 |  |  |         companyMapper.updateById(com); | 
 |  |  |         return company; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public Company syncDDEditCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse,Company company){ | 
 |  |  |         company.setErpParentId(deptGetResponse.getParentId().toString()); | 
 |  |  |         String idPath = ""; | 
 |  |  |         if(StringUtils.isNotBlank(company.getErpParentId())){ | 
 |  |  |             Company parent = companyMapper.selectOne(new QueryWrapper<Company>().lambda().eq(Company::getErpId,company.getErpParentId()) | 
 |  |  |                     .eq(Company::getIsdeleted,Constants.ZERO).last("limit 1 ")); | 
 |  |  |             if(parent == null || Constants.equalsInteger(parent.getIsdeleted(),Constants.ONE)){ | 
 |  |  |                 throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,父级组织信息不存在~"); | 
 |  |  |             } | 
 |  |  |             if(Objects.nonNull(parent.getType())&&!Constants.equalsInteger(parent.getType(),-1)){ | 
 |  |  |                 if(!Constants.equalsInteger(company.getType(),parent.getType())){ | 
 |  |  |                     throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,组织信息错误"); | 
 |  |  |                 } | 
 |  |  |             }else if(Objects.isNull(parent.getType())){ | 
 |  |  |                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,组织信息错误"); | 
 |  |  |             } | 
 |  |  |             idPath = parent.getCompanyPath(); | 
 |  |  |             company.setHkParentId(parent.getHkId()); | 
 |  |  |             company.setCompanyPath(parent.getCompanyPath()+company.getId()+"/"); | 
 |  |  |             company.setCompanyNamePath(parent.getCompanyNamePath()+"/"+company.getName()); | 
 |  |  |             company.setParentId(parent.getId()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         company.setName(deptGetResponse.getName()); | 
 |  |  |         company.setErpId(deptGetResponse.getDeptId().toString()); | 
 |  |  |         company.setErpParentId(deptGetResponse.getParentId().toString()); | 
 |  |  |         company.setSortnum(deptGetResponse.getOrder().intValue());//默认最上面 | 
 |  |  |         company.setEditDate(new Date()); | 
 |  |  |         company.setHkCompanyPath(company.getCompanyNamePath()); | 
 |  |  |         company.setHkStatus(Constants.ZERO); | 
 |  |  |         company.setStatus(Constants.ZERO); | 
 |  |  |         company.setSortnum(deptGetResponse.getOrder().intValue()); | 
 |  |  |         company.setHkDate(company.getCreateDate()); | 
 |  |  |         company.setEditDate(company.getCreateDate()); | 
 |  |  |         company.setEditor(company.getCreator()); | 
 |  |  |         company.setPinyin(Constants.getChinesePingyin(company.getName())); | 
 |  |  |         companyMapper.updateById(company); | 
 |  |  |         //下发海康安防平台 | 
 |  |  |         Boolean issueStatus = editHkOrg(company); | 
 |  |  |         Company com = new Company(); | 
 |  |  |         com.setId(company.getId()); | 
 |  |  |         com.setHkId(issueStatus?company.getHkId():null); | 
 |  |  |         com.setHkStatus(issueStatus?Constants.ONE:Constants.TWO); | 
 |  |  |         com.setCompanyPath(idPath+company.getId()+"/"); | 
 |  |  |         companyMapper.updateById(com); | 
 |  |  |         return company; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public void syncDelCompany(List<Long> deptIdList){ | 
 |  |  |         List<Company> companyList = companyMapper.selectList(new QueryWrapper<Company>() | 
 |  |  |                 .lambda() | 
 |  |  |                 .eq(Company::getIsdeleted,Constants.ZERO) | 
 |  |  |                 .in(Company::getErpId,deptIdList) | 
 |  |  |         ); | 
 |  |  |         if(CollectionUtils.isNotEmpty(companyList)){ | 
 |  |  |             List<Integer> delIds = companyList.stream().map(i->i.getId()).collect(Collectors.toList()); | 
 |  |  |             List<String> delHKIds = companyList.stream().filter(i->StringUtils.isNotBlank(i.getHkId())).map(i->i.getHkId()).collect(Collectors.toList()); | 
 |  |  |  | 
 |  |  |             //标记业务删除 | 
 |  |  |             companyMapper.update(new UpdateWrapper<Company>().lambda() | 
 |  |  |                     .set(Company::getIsdeleted,Constants.ONE) | 
 |  |  |                     .set(Company::getEditDate,new Date()) | 
 |  |  |                     .in(Company::getId,delIds) | 
 |  |  |             ); | 
 |  |  |             //海康删除的数据,进行删除 | 
 |  |  |             doHkDeleteOrg(delIds,delHKIds,new Date()); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | } |