diff --git a/health-consultation/health-consultation-biz/src/main/java/com/renkang/consultation/mapper/ConDoctorMapper.java b/health-consultation/health-consultation-biz/src/main/java/com/renkang/consultation/mapper/ConDoctorMapper.java index a694d73..6ab544b 100644 --- a/health-consultation/health-consultation-biz/src/main/java/com/renkang/consultation/mapper/ConDoctorMapper.java +++ b/health-consultation/health-consultation-biz/src/main/java/com/renkang/consultation/mapper/ConDoctorMapper.java @@ -12,6 +12,7 @@ import org.apache.ibatis.annotations.Update; import java.math.BigDecimal; import java.util.List; import java.util.Map; +import java.util.Set; /** * @Description: con_doctor @@ -71,6 +72,8 @@ public interface ConDoctorMapper extends BaseMapper , MPJBaseMapper selectDoctorInfoByIds(@Param("doctorIds") Set doctorIds); + @Select("SELECT * FROM con_doctor WHERE status = '1' and del_flag = '0' and id = #{doctorId} and is_accept = '1'") public ConDoctorDO selectDoctorInfoByIdNew(String doctorId); diff --git a/health-consultation/health-consultation-biz/src/main/java/com/renkang/consultation/mapper/xml/ConDoctorMapper.xml b/health-consultation/health-consultation-biz/src/main/java/com/renkang/consultation/mapper/xml/ConDoctorMapper.xml index d2b4305..567916d 100644 --- a/health-consultation/health-consultation-biz/src/main/java/com/renkang/consultation/mapper/xml/ConDoctorMapper.xml +++ b/health-consultation/health-consultation-biz/src/main/java/com/renkang/consultation/mapper/xml/ConDoctorMapper.xml @@ -532,4 +532,18 @@ and id != #{doctorId} + diff --git a/health-consultation/health-consultation-biz/src/main/java/com/renkang/consultation/service/impl/ConSessionServiceImpl.java b/health-consultation/health-consultation-biz/src/main/java/com/renkang/consultation/service/impl/ConSessionServiceImpl.java index 40b36f2..969620c 100644 --- a/health-consultation/health-consultation-biz/src/main/java/com/renkang/consultation/service/impl/ConSessionServiceImpl.java +++ b/health-consultation/health-consultation-biz/src/main/java/com/renkang/consultation/service/impl/ConSessionServiceImpl.java @@ -28,6 +28,7 @@ import com.renkang.im.entity.ImGroupMsgTextReqDO; import org.apache.poi.ss.usermodel.Workbook; import org.apache.shiro.SecurityUtils; import org.jeecg.bean.request.ListUser; +import org.jeecg.bean.response.BaseEmployeeInfo; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.system.api.ISysBaseAPI; @@ -767,44 +768,112 @@ public class ConSessionServiceImpl extends ServiceImpl conSessionDOList = conSessionMapper.companySessionList(imIds); + if (CollUtil.isNotEmpty(conSessionDOList)) { + Set fromAccount = conSessionDOList.stream().map(ConSession::getFromAccount).collect(Collectors.toSet()); + Set toAccount = conSessionDOList.stream().map(ConSession::getToAccount).collect(Collectors.toSet()); + Set userIds = new HashSet<>(fromAccount); + userIds.addAll(toAccount); + List baseUsers = sysBaseAPI.queryBaseEmployeeInfo(userIds); + List doctors = conDoctorMapper.selectDoctorInfoByIds(userIds); + List sexModels = dictUtil.queryDictItemListByCode("sex2"); + // 根据key转成map + Map sexMap = sexModels.stream() + .filter(model -> model != null && StrUtil.isNotBlank(model.getValue())) + .collect(Collectors.toMap(DictModel::getValue, model -> model, + (existing, replacement) -> existing)); + // 根据id转成map + Map userMap = baseUsers.stream() + .filter(user -> user != null && StrUtil.isNotBlank(user.getUserId())) + .collect(Collectors.toMap(BaseEmployeeInfo::getUserId, user -> user, + (existing, replacement) -> existing)); + // 根据id转成map + Map doctorMap = doctors.stream() + .filter(doctor -> doctor != null && StrUtil.isNotBlank(doctor.getId())) + .collect(Collectors.toMap(ConDoctorDO::getId, doctor -> doctor, + (existing, replacement) -> existing)); - for (ConSession conSessionDO : conSessionDOList) { - LoginUser loginUser = sysBaseAPI.getUserById(conSessionDO.getFromAccount()); - if (loginUser != null) { - conSessionDO.setToAccountName(loginUser.getRealname()); - conSessionDO.setToAccountHead(loginUser.getAvatar()); - String gen = dictUtil.queryDictItemListByCodeAndType("sex2", String.valueOf(loginUser.getSex())); - conSessionDO.setMemberSex(gen); - } - - if (StrUtil.equals(conSessionDO.getSessionType(), "1")) { - CompletableFuture future = CompletableFuture.supplyAsync(() -> sysBaseAPI.getUserById(conSessionDO.getToAccount())); - LoginUser toLoginUser = future.join(); - if(toLoginUser != null){ - conSessionDO.setFromAccountName(toLoginUser.getRealname()); + for (ConSession conSessionDO : conSessionDOList) { + // 根据原接口取值默认fromAccount + BaseEmployeeInfo user = userMap.get(conSessionDO.getFromAccount()); + if (null != user) { + conSessionDO.setToAccountName(user.getRealName()); + conSessionDO.setToAccountHead(user.getAvatar()); + conSessionDO.setOrgCode(user.getSecondDeptName() + "-" + user.getThirdDeptName()); + if (null != user.getSex()){ + DictModel dictModel = sexMap.get(user.getSex().toString()); + if (null != dictModel) { + conSessionDO.setMemberSex(dictModel.getText()); + } + } } - ConDoctorDO conDoctorDO = conDoctorMapper.selectDoctorInfoById(conSessionDO.getToAccount()); - conSessionDO.setDoctorInfo(conDoctorDO); - } - if (StrUtil.equals(conSessionDO.getSessionType(), "3")) { - CompletableFuture future = CompletableFuture.supplyAsync(() -> sysBaseAPI.getUserById(conSessionDO.getFromAccount())); - LoginUser toLoginUser = future.join(); - if (toLoginUser != null) { - conSessionDO.setFromAccountName(toLoginUser.getRealname()); - } - ConDoctorDO conDoctorDO = conDoctorMapper.selectDoctorInfoById(conSessionDO.getFromAccount()); - conSessionDO.setDoctorInfo(conDoctorDO); - } - SysDepart secondDepartOrgCode = sysCache.getDepartByOrgCode(GlobalUtils.getSecondDepartOrgCode(conSessionDO.getOrgCode())); - SysDepart thridDepartOrgCode = sysCache.getDepartByOrgCode(GlobalUtils.getThirdDepartOrgCode(conSessionDO.getOrgCode())); - if (secondDepartOrgCode != null && thridDepartOrgCode != null) { - conSessionDO.setOrgCode(secondDepartOrgCode.getDepartName() + "-" + thridDepartOrgCode.getDepartName()); + if (StrUtil.equals(conSessionDO.getSessionType(), "1")) { + BaseEmployeeInfo toUser = userMap.get(conSessionDO.getToAccount()); + if (toUser != null) { + conSessionDO.setFromAccountName(toUser.getRealName()); + } + ConDoctorDO conDoctorDO = doctorMap.get(conSessionDO.getToAccount()); + conSessionDO.setDoctorInfo(conDoctorDO); + } + + if (StrUtil.equals(conSessionDO.getSessionType(), "3")) { + BaseEmployeeInfo formUser = userMap.get(conSessionDO.getFromAccount()); + if (formUser != null) { + conSessionDO.setFromAccountName(formUser.getRealName()); + } + ConDoctorDO conDoctorDO = doctorMap.get(conSessionDO.getFromAccount()); + conSessionDO.setDoctorInfo(conDoctorDO); + } } } return conSessionDOList; } +// @Override +// public List companySessionList(ListImIds list) { +// if (ObjectUtil.isNull(list) || CollectionUtil.isEmpty(list.getImIds())) { +// return Collections.emptyList(); +// } +// String imIds = String.join(",", list.getImIds()); +// List conSessionDOList = conSessionMapper.companySessionList(imIds); +// +// for (ConSession conSessionDO : conSessionDOList) { +// LoginUser loginUser = sysBaseAPI.getUserById(conSessionDO.getFromAccount()); +// if (loginUser != null) { +// conSessionDO.setToAccountName(loginUser.getRealname()); +// conSessionDO.setToAccountHead(loginUser.getAvatar()); +// String gen = dictUtil.queryDictItemListByCodeAndType("sex2", String.valueOf(loginUser.getSex())); +// conSessionDO.setMemberSex(gen); +// } +// +// if (StrUtil.equals(conSessionDO.getSessionType(), "1")) { +// CompletableFuture future = CompletableFuture.supplyAsync(() -> sysBaseAPI.getUserById(conSessionDO.getToAccount())); +// LoginUser toLoginUser = future.join(); +// if(toLoginUser != null){ +// conSessionDO.setFromAccountName(toLoginUser.getRealname()); +// } +// ConDoctorDO conDoctorDO = conDoctorMapper.selectDoctorInfoById(conSessionDO.getToAccount()); +// conSessionDO.setDoctorInfo(conDoctorDO); +// } +// if (StrUtil.equals(conSessionDO.getSessionType(), "3")) { +// CompletableFuture future = CompletableFuture.supplyAsync(() -> sysBaseAPI.getUserById(conSessionDO.getFromAccount())); +// LoginUser toLoginUser = future.join(); +// if (toLoginUser != null) { +// conSessionDO.setFromAccountName(toLoginUser.getRealname()); +// } +// ConDoctorDO conDoctorDO = conDoctorMapper.selectDoctorInfoById(conSessionDO.getFromAccount()); +// conSessionDO.setDoctorInfo(conDoctorDO); +// } +// SysDepart secondDepartOrgCode = sysCache.getDepartByOrgCode(GlobalUtils.getSecondDepartOrgCode(conSessionDO.getOrgCode())); +// SysDepart thridDepartOrgCode = sysCache.getDepartByOrgCode(GlobalUtils.getThirdDepartOrgCode(conSessionDO.getOrgCode())); +// +// if (secondDepartOrgCode != null && thridDepartOrgCode != null) { +// conSessionDO.setOrgCode(secondDepartOrgCode.getDepartName() + "-" + thridDepartOrgCode.getDepartName()); +// } +// } +// return conSessionDOList; +// } + @Override public List professorSessionList(ListImIds list) { if (ObjectUtil.isNull(list) || CollectionUtil.isEmpty(list.getImIds())) {