Browse Source

添加2级组织名称

dev_shibei_match
jianjun 4 years ago
parent
commit
199961197b
  1. 11
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/CustomerStaffInfoCacheResult.java
  2. 16
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerStaffRedis.java
  3. 13
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/CustomerStaffInfoCache.java
  4. 11
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/CustomerStaffResultDTO.java
  5. 51
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/StaffOrgRelationResultDTO.java
  6. 3
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerAgencyDao.java
  7. 6
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetmessage/impl/EpmetMessageServiceImpl.java
  8. 41
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  9. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java
  10. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  11. 4
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerAgencyDao.xml

11
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个值agencygriddept
* @see com.epmet.commons.tools.enums.OrgTypeEnum
*/
private String fromOrgType;
/**
* 角色map key为角色key value 为角色名称
*/

16
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<String, Object> roleMap = redisUtils.hGetAll(key);
if (!CollectionUtils.isEmpty(roleMap)) {
return ConvertUtils.mapToEntity(roleMap, CustomerStaffInfoCache.class);
return ConvertUtils.mapToEntity(roleMap, CustomerStaffInfoCacheResult.class);
}
Result<CustomerStaffInfoCache> 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<String, Object> map = BeanUtil.beanToMap(staffResult.getData(), false, true);
Map<String, Object> map = BeanUtil.beanToMap(resultData, false, true);
redisUtils.hMSet(key, map);
return staffResult.getData();
return ConvertUtils.sourceToTarget(resultData,CustomerStaffInfoCacheResult.class);
}
/**

13
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;
/**
* 所属组织的上级组织
*/

11
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<IdAndNameDTO> deptList;
//特殊处理的 属性 start ==========
/**
* 2级组织名称 根据添加的来源返回xx组织-组织/网格/部门
*/
private String twoOrgName;
}

51
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

3
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<CustomerAgencyEntity> {
* @param staffId
* @return
*/
String getStaffFromOrgType(@Param("staffId") String staffId);
StaffOrgRelationResultDTO getStaffFromOrgType(@Param("staffId") String staffId);
}

6
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<String> 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);

41
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<StaffRoleResultDTO> roleList = govStaffRoleDao.getStaffRoleList(staffId);
Map<String, String> roleMap = roleList.stream().collect(Collectors.toMap(StaffRoleResultDTO::getRoleKey, StaffRoleResultDTO::getRoleName));
@ -543,6 +564,9 @@ public class EpmetUserServiceImpl implements EpmetUserService {
List<IdAndNameDTO> 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<CustomerDepartmentDTO> 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;
}

2
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);
}

2
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);
}

4
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerAgencyDao.xml

@ -146,8 +146,8 @@
)
</if>
</select>
<select id="getStaffFromOrgType" resultType="java.lang.String">
SELECT ORG_TYPE FROM staff_org_relation WHERE del_flag = '0' AND staff_id = #{staffId}
<select id="getStaffFromOrgType" resultType="com.epmet.dataaggre.dto.govorg.result.StaffOrgRelationResultDTO">
SELECT STAFF_ID,ORG_ID,ORG_TYPE FROM staff_org_relation WHERE del_flag = '0' AND staff_id = #{staffId}
</select>
</mapper>

Loading…
Cancel
Save