From 811378d28db922f1e2945015ac9b0154db46ea54 Mon Sep 17 00:00:00 2001 From: songhuangfeng123 <shf18767906695@163.com> Date: 星期六, 06 八月 2022 17:40:40 +0800 Subject: [PATCH] fix --- goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/CommonServiceImpl.java | 67 +++++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 0 deletions(-) diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/CommonServiceImpl.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/CommonServiceImpl.java new file mode 100644 index 0000000..c096282 --- /dev/null +++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/CommonServiceImpl.java @@ -0,0 +1,67 @@ +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; + } +} \ No newline at end of file -- Gitblit v1.9.2