diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/CustomerStaffInfoCacheResult.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/CustomerStaffInfoCacheResult.java index 8359f4d020..ef027fc105 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/CustomerStaffInfoCacheResult.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/CustomerStaffInfoCacheResult.java @@ -26,6 +26,11 @@ public class CustomerStaffInfoCacheResult implements Serializable { */ private String agencyName; + /** + * 2级组织名称 根据添加的来源返回(xx组织-组织/网格/部门) + */ + private String twoOrgName; + /** * 工作人员ID */ @@ -51,6 +56,12 @@ public class CustomerStaffInfoCacheResult implements Serializable { */ private String headPhoto; + /** + * 工作人员是从哪中组织类型添加的 3个值:agency,grid,dept + * @see com.epmet.commons.tools.enums.OrgTypeEnum + */ + private String fromOrgType; + /** * 角色map key为角色key value 为角色名称 */ diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java index 362294b66b..af2d09cc09 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java @@ -2,6 +2,7 @@ package com.epmet.commons.tools.redis.common; import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.CommonAggFeignClient; import com.epmet.commons.tools.redis.RedisKeys; @@ -33,7 +34,8 @@ public class CustomerStaffRedis { //@PostConstruct public void init() { - CustomerStaffInfoCache role = this.getStaffInfo("45687aa479955f9d06204d415238f7cc", "9e37adcce6472152e6508a19d3683e02"); + CustomerStaffInfoCacheResult role = this.getStaffInfo("45687aa479955f9d06204d415238f7cc", "9e37adcce6472152e6508a19d3683e02"); + role = this.getStaffInfo("45687aa479955f9d06204d415238f7cc", "7f694a66efe60a47c2114875f310248a"); System.out.println(JSON.toJSONString(role)); } @@ -47,25 +49,27 @@ public class CustomerStaffRedis { * @date 2021/8/19 10:29 下午 * @remark 此方法仅用于 获取某个工作人员的信息,不用于获取客户下所有工作人员信息 */ - public CustomerStaffInfoCache getStaffInfo(String customerId, String staffId) { + public CustomerStaffInfoCacheResult getStaffInfo(String customerId, String staffId) { String key = RedisKeys.getCustomerStaffInfoKey(customerId, staffId); Map roleMap = redisUtils.hGetAll(key); if (!CollectionUtils.isEmpty(roleMap)) { - return ConvertUtils.mapToEntity(roleMap, CustomerStaffInfoCache.class); + return ConvertUtils.mapToEntity(roleMap, CustomerStaffInfoCacheResult.class); } Result staffResult = commonAggFeignClient.getStaffInfo(staffId); if (staffResult == null || !staffResult.success()) { throw new RenException("获取工作人员信息失败"); } - if (staffResult.getData() == null) { + CustomerStaffInfoCache resultData = staffResult.getData(); + if (resultData == null) { log.warn("getStaffInfo staff is null,staffId:{}", staffId); return null; } - Map map = BeanUtil.beanToMap(staffResult.getData(), false, true); + + Map map = BeanUtil.beanToMap(resultData, false, true); redisUtils.hMSet(key, map); - return staffResult.getData(); + return ConvertUtils.sourceToTarget(resultData,CustomerStaffInfoCacheResult.class); } /** diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java index 4ea3abe7dc..577bdf3910 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; /** + * desc:客户工作人员缓存实体类 * @Author zxc * @DateTime 2021/6/15 10:00 上午 * @DESC @@ -15,7 +16,7 @@ import java.util.Map; @Data public class CustomerStaffInfoCache implements Serializable { - private static final long serialVersionUID = -4078910245000135305L; + private static final long serialVersionUID = 4627478063125903910L; /** * 工作人员所属组织ID */ @@ -26,6 +27,11 @@ public class CustomerStaffInfoCache implements Serializable { */ private String agencyName; + /** + * 2级组织名称 根据添加的来源返回(xx组织-组织/网格/部门) + */ + private String twoOrgName; + /** * 工作人员ID */ @@ -62,6 +68,11 @@ public class CustomerStaffInfoCache implements Serializable { */ private String fromOrgType; + /** + * 工作人员是从哪中组织添加的 组织Id + */ + private String fromOrgId; + /** * 所属组织的上级组织 */ diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/CustomerStaffResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/CustomerStaffResultDTO.java index b3281cbad7..b12ea53fec 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/CustomerStaffResultDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/CustomerStaffResultDTO.java @@ -57,6 +57,11 @@ public class CustomerStaffResultDTO implements Serializable { */ private String fromOrgType; + /** + * 工作人员是从哪中组织添加的 组织Id + */ + private String fromOrgId; + /** * 角色map key为角色key value 为角色名称 */ @@ -77,4 +82,10 @@ public class CustomerStaffResultDTO implements Serializable { */ private List deptList; + //特殊处理的 属性 start ========== + /** + * 2级组织名称 根据添加的来源返回(xx组织-组织/网格/部门) + */ + private String twoOrgName; + } diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/StaffOrgRelationResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/StaffOrgRelationResultDTO.java new file mode 100644 index 0000000000..6ede0cb39e --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/StaffOrgRelationResultDTO.java @@ -0,0 +1,51 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dataaggre.dto.govorg.result; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 工作人员注册组织关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-08-19 + */ +@Data +public class StaffOrgRelationResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * 工作人员Id + */ + private String staffId; + + /** + * 工作人员添加入口Id(agencyId;deptId;gridId) + */ + private String orgId; + + /** + * 工作人员添加入口类型(组织:agency;部门:dept;网格:gridId) + */ + private String orgType; + + +} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerAgencyDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerAgencyDao.java index 5d343f2616..544f7387dd 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerAgencyDao.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerAgencyDao.java @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dataaggre.dto.govorg.result.AgencyGridResultDTO; import com.epmet.dataaggre.dto.govorg.result.StaffAgencyGridListResultDTO; import com.epmet.dataaggre.dto.govorg.result.StaffOrgNameResultDTO; +import com.epmet.dataaggre.dto.govorg.result.StaffOrgRelationResultDTO; import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -72,5 +73,5 @@ public interface CustomerAgencyDao extends BaseDao { * @param staffId * @return */ - String getStaffFromOrgType(@Param("staffId") String staffId); + StaffOrgRelationResultDTO getStaffFromOrgType(@Param("staffId") String staffId); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetmessage/impl/EpmetMessageServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetmessage/impl/EpmetMessageServiceImpl.java index c83e72ac5e..22ffaec9a6 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetmessage/impl/EpmetMessageServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetmessage/impl/EpmetMessageServiceImpl.java @@ -6,8 +6,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; -import com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoCache; import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.dao.epmetmessage.InfoReceiversDao; import com.epmet.dataaggre.dto.govorg.ReceiverDTO; @@ -98,7 +98,7 @@ public class EpmetMessageServiceImpl implements EpmetMessageService { List staffNameList = new ArrayList<>(); for (String userId : group.getStaffIdList()) { //查询每个工作人员的基本信息,获取姓名 - CustomerStaffInfoCache staffInfoCache = customerStaffRedis.getStaffInfo(customerId, userId); + CustomerStaffInfoCacheResult staffInfoCache = customerStaffRedis.getStaffInfo(customerId, userId); if (null != staffInfoCache) { staffNameList.add(staffInfoCache.getRealName()); } @@ -130,7 +130,7 @@ public class EpmetMessageServiceImpl implements EpmetMessageService { for (String userId : group.getStaffIdList()) { //查询每个工作人员的基本信息 - CustomerStaffInfoCache staffInfoCache = customerStaffRedis.getStaffInfo(formDTO.getCustomerId(), userId); + CustomerStaffInfoCacheResult staffInfoCache = customerStaffRedis.getStaffInfo(formDTO.getCustomerId(), userId); if (null != staffInfoCache) { StaffInfoCommonDTO staffInfo=new StaffInfoCommonDTO(); staffInfo.setStaffId(userId); diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java index adbf1503e9..3e72e9b17b 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java @@ -3,7 +3,9 @@ package com.epmet.dataaggre.service.epmetuser.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.form.IdAndNameDTO; +import com.epmet.commons.tools.enums.OrgTypeEnum; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.BadgeConstant; @@ -19,6 +21,7 @@ import com.epmet.dataaggre.dto.govorg.CustomerDepartmentDTO; import com.epmet.dataaggre.dto.govorg.CustomerGridDTO; import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO; import com.epmet.dataaggre.dto.govorg.result.StaffOrgNameResultDTO; +import com.epmet.dataaggre.dto.govorg.result.StaffOrgRelationResultDTO; import com.epmet.dataaggre.entity.epmetuser.CustomerStaffEntity; import com.epmet.dataaggre.entity.epmetuser.GovStaffRoleEntity; import com.epmet.dataaggre.entity.epmetuser.ResiUserBadgeEntity; @@ -531,8 +534,26 @@ public class EpmetUserServiceImpl implements EpmetUserService { return null; } result.setAgencyName(agencyDTO.getOrganizationName()); - String fromOrgType = govOrgService.getStaffFromOrgType(staffId); + StaffOrgRelationResultDTO fromOrgTypeDto = govOrgService.getStaffFromOrgType(staffId); + String fromOrgType = OrgTypeEnum.AGENCY.getCode(); + if (fromOrgTypeDto != null){ + fromOrgType = fromOrgTypeDto.getOrgType(); + result.setFromOrgId(fromOrgTypeDto.getOrgId()); + } result.setFromOrgType(fromOrgType); + boolean isContinueMkName = true; + StringBuilder showNameBuilder = new StringBuilder(16); + if (OrgTypeEnum.AGENCY.getCode().equals(fromOrgType)){ + String allParentName = agencyDTO.getAllParentName(); + if (StringUtils.isNotBlank(allParentName)){ + showNameBuilder.append(allParentName.substring(allParentName.lastIndexOf(StrConstant.HYPHEN)+NumConstant.ONE)); + showNameBuilder.append(StrConstant.HYPHEN); + showNameBuilder.append(agencyDTO.getOrganizationName()); + isContinueMkName = false; + }else{ + showNameBuilder.append(agencyDTO.getOrganizationName()); + } + } List roleList = govStaffRoleDao.getStaffRoleList(staffId); Map roleMap = roleList.stream().collect(Collectors.toMap(StaffRoleResultDTO::getRoleKey, StaffRoleResultDTO::getRoleName)); @@ -543,6 +564,9 @@ public class EpmetUserServiceImpl implements EpmetUserService { List idAndNameList = new ArrayList<>(); for (CustomerGridDTO customerGridDTO : list) { IdAndNameDTO grid = new IdAndNameDTO(); + if (isContinueMkName && OrgTypeEnum.GRID.getCode().equals(fromOrgType)&&grid.getId().equals(result.getFromOrgId())){ + showNameBuilder.append(agencyDTO.getOrganizationName()).append(StrConstant.HYPHEN).append(grid.getName()); + } grid.setId(customerGridDTO.getId()); grid.setName(customerGridDTO.getGridName()); idAndNameList.add(grid); @@ -552,14 +576,17 @@ public class EpmetUserServiceImpl implements EpmetUserService { List deptList = govOrgService.getStaffDeptList(staffId); idAndNameList = new ArrayList<>(); for (CustomerDepartmentDTO org : deptList) { - IdAndNameDTO grid = new IdAndNameDTO(); - grid.setId(org.getId()); - grid.setName(org.getDepartmentName()); - idAndNameList.add(grid); + IdAndNameDTO dept = new IdAndNameDTO(); + if (isContinueMkName && OrgTypeEnum.GRID.getCode().equals(fromOrgType)&&dept.getId().equals(result.getFromOrgId())){ + showNameBuilder.append(agencyDTO.getOrganizationName()).append(StrConstant.HYPHEN).append(dept.getName()); + } + dept.setId(org.getId()); + dept.setName(org.getDepartmentName()); + idAndNameList.add(dept); } result.setDeptList(idAndNameList); - - + //特殊处理 显示的名字 + result.setTwoOrgName(showNameBuilder.toString()); return result; } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java index 4aeae36d72..0d62b87e59 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java @@ -134,5 +134,5 @@ public interface GovOrgService { * @param staffId * @return */ - String getStaffFromOrgType(String staffId); + StaffOrgRelationResultDTO getStaffFromOrgType(String staffId); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java index 2341d88128..78ee0d9077 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java @@ -426,7 +426,7 @@ public class GovOrgServiceImpl implements GovOrgService { } @Override - public String getStaffFromOrgType(String staffId) { + public StaffOrgRelationResultDTO getStaffFromOrgType(String staffId) { return customerAgencyDao.getStaffFromOrgType(staffId); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerAgencyDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerAgencyDao.xml index eda0707461..f9e133f945 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerAgencyDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerAgencyDao.xml @@ -146,8 +146,8 @@ ) - + SELECT STAFF_ID,ORG_ID,ORG_TYPE FROM staff_org_relation WHERE del_flag = '0' AND staff_id = #{staffId}