package com.gkhy.safePlatform.targetDuty.service.impl;
|
|
import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService;
|
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.DepInfoRPCRespDTO;
|
import com.gkhy.safePlatform.commons.enums.ResultCodes;
|
import com.gkhy.safePlatform.commons.vo.ResultVO;
|
import com.gkhy.safePlatform.targetDuty.service.CommonService;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.springframework.stereotype.Service;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
import java.util.Set;
|
|
/**
|
* 公共服务实现类
|
*
|
* @author xurui
|
* @since 2022-07-20 11:49:22
|
*/
|
@Service("commonServiceImpl")
|
public class CommonServiceImpl implements CommonService {
|
|
@DubboReference(check = false)
|
private AccountDepartmentService accountDepartmentService;
|
|
@Override
|
public String getDepName(Long depId) {
|
return this.getDepInfo(depId).getDepName();
|
}
|
|
@Override
|
public DepInfoRPCRespDTO getDepInfo(Long depId) {
|
// 设置部门名称
|
ResultVO<DepInfoRPCRespDTO> rpcResult = accountDepartmentService.getDepInfoByDepId(depId);
|
if (rpcResult != null && rpcResult.getCode().equals(ResultCodes.OK.getCode())) {
|
if (rpcResult.getData() != null) {
|
DepInfoRPCRespDTO dep = (DepInfoRPCRespDTO) rpcResult.getData();
|
return dep;
|
}
|
}
|
return new DepInfoRPCRespDTO();
|
}
|
|
|
@Override
|
public Map<Long,String> getDepName(Set<Long> collectDepIdSet) {
|
Map<Long, String> depPool = new HashMap<>();
|
collectDepIdSet.forEach(depId ->{
|
// 设置部门名称
|
if (!depPool.containsKey(depId)) {
|
try {
|
ResultVO<DepInfoRPCRespDTO> rpcResult = accountDepartmentService.getDepInfoByDepId(depId);
|
if (rpcResult != null && rpcResult.getCode().equals(ResultCodes.OK.getCode())) {
|
if (rpcResult.getData() != null) {
|
DepInfoRPCRespDTO dep = (DepInfoRPCRespDTO) rpcResult.getData();
|
depPool.put(dep.getDepId(), dep.getDepName());
|
}
|
}
|
} catch (Exception e) {
|
System.out.println("exception::"+e);
|
}
|
}
|
});
|
return depPool;
|
}
|
}
|