| | |
| | | import com.doumee.dao.admin.request.UpdateCompanySortDTO; |
| | | import com.doumee.dao.admin.response.CompanyDTO; |
| | | import com.doumee.dao.business.CompanyMapper; |
| | | import com.doumee.dao.business.MemberMapper; |
| | | import com.doumee.dao.business.join.CompanyJoinMapper; |
| | | import com.doumee.dao.business.model.Category; |
| | | import com.doumee.dao.business.model.Company; |
| | |
| | | @Autowired |
| | | private CompanyMapper companyMapper; |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | @Autowired |
| | | private DataSyncConfig dataSyncConfig; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | |
| | | user = company.getLoginUserInfo(); |
| | | } |
| | | String rootOrgId = systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_ROOTORG_CODE).getCode(); |
| | | company.setCompanyPath(company.getName());//名称路径 |
| | | company.setHkParentId(rootOrgId); |
| | | if(company.getParentId() !=null){ |
| | | Company parent = findById(company.getParentId()); |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对不起,父级组织信息尚未同步下发成功~"); |
| | | } |
| | | company.setHkParentId(parent.getHkId()); |
| | | company.setCompanyPath(parent.getCompanyPath()+"/"+company.getName()); |
| | | } |
| | | company.setHkCompanyPath(company.getCompanyPath()); |
| | | company.setCreateDate(new Date()); |
| | | company.setCreator(user.getId()); |
| | | company.setIsdeleted(Constants.ZERO); |
| | |
| | | company.setStatus(Constants.ZERO); |
| | | company.setHkDate(company.getHkDate()); |
| | | company.setHkId(UUID.randomUUID().toString().replace("-","")); |
| | | |
| | | companyMapper.insert(company); |
| | | //下发海康安防平台 |
| | | if(!addHkOrg(company)){ |
| | |
| | | private boolean addHkOrg(Company company) { |
| | | List<OrgAddRequest> addList = new ArrayList<>(); |
| | | addList.add(getOrgAddModel(company)); |
| | | |
| | | BaseResponse<OrgOrUserAddResponse> result = HKService.addBatchOrg(addList); |
| | | if(result !=null && StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE)){ |
| | | OrgOrUserAddResponse data = result.getData(); |
| | |
| | | return model; |
| | | } |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public Integer createLaborServices(Company company) { |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(loginUserInfo ==null){ |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void deleteById(Integer id, LoginUserInfo user ) { |
| | | if(id== null ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | |
| | | Company model = findById(id); |
| | | if(model == null || Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,组织信息不存在~"); |
| | | } |
| | | if(StringUtils.isBlank(model.getHkId())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,组织信息尚未同步下发成功,暂不支持修改,请尝试删除后重新添加~"); |
| | | if(companyMapper.selectCount(new QueryWrapper<Company>().lambda() |
| | | .eq(Company::getParentId,model.getId()) |
| | | .eq(Company::getIsdeleted,Constants.ZERO)) >0){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,该部门存在下级部门,不能进行删除操作!"); |
| | | } |
| | | |
| | | if(memberMapper.selectCount(new QueryWrapper<Member>().lambda() |
| | | .eq(Member::getCompanyId,model.getId()) |
| | | .eq(Member::getIsdeleted,Constants.ZERO)) >0){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,该部门下存在人员信息,不能进行删除操作!"); |
| | | } |
| | | Company company = new Company(); |
| | | company.setId(id); |
| | | company.setEditDate(new Date()); |
| | |
| | | company.setHkDate(company.getHkDate()); |
| | | companyMapper.updateById(company); |
| | | //下发海康安防平台 |
| | | if(!delHkOrg(model)){ |
| | | if(StringUtils.isBlank(model.getHkId()) && Constants.equalsInteger(Constants.ONE,model.getHkStatus()) && !delHkOrg(model)){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,组织删除下发失败,请确认该组织无下级组织或组织人员信息~"); |
| | | } |
| | | } |
| | |
| | | public void updateStatusById(Company company) { |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(loginUserInfo==null){ |
| | | loginUserInfo = company.getLoginUserInfo() |
| | | loginUserInfo = company.getLoginUserInfo(); |
| | | } |
| | | company.setEditDate(new Date()); |
| | | company.setEditor(loginUserInfo.getId()); |