diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java index 4a6332f74a..33807f7f08 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java @@ -205,7 +205,7 @@ public class LogMsgSendFilter extends LevelFilter { } return slashMatcher.start(); } catch (Exception e) { - logger.warn("getCharacterPosition no matche", e); + logger.warn("getCharacterPosition no matche"); return string.length(); } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index c3edf2dcbc..fd52f94968 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -498,6 +498,6 @@ public class RedisKeys { * @return */ public static String getCustomerStaffInfoKey(String customerId, String staffId) { - return rootPrefix.concat("gov:staff").concat(customerId).concat(StrConstant.COLON).concat(staffId); + return rootPrefix.concat("gov:staff:").concat(customerId).concat(StrConstant.COLON).concat(staffId); } } 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 3acbad8a1b..831d2f177d 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 @@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import javax.annotation.PostConstruct; import java.util.Map; /** @@ -32,14 +33,24 @@ public class CustomerStaffRedis { private RedisUtils redisUtils; @Autowired private CommonAggFeignClient commonAggFeignClient; + + private static CustomerStaffRedis customerStaffRedis; private static final String ROLE_MAP_KEY = "roleMap"; - //@PostConstruct + @PostConstruct public void init() { - CustomerStaffInfoCacheResult role = this.getStaffInfo("45687aa479955f9d06204d415238f7cc", "9e37adcce6472152e6508a19d3683e02"); - role = this.getStaffInfo("45687aa479955f9d06204d415238f7cc", "7f694a66efe60a47c2114875f310248a"); + customerStaffRedis = this; + customerStaffRedis.redisUtils = this.redisUtils; + customerStaffRedis.commonAggFeignClient = this.commonAggFeignClient; + } + + public static void initTest() { + CustomerStaffInfoCacheResult role = getStaffInfo("45687aa479955f9d06204d415238f7cc", "9e37adcce6472152e6508a19d3683e02"); + role = getStaffInfo("45687aa479955f9d06204d415238f7cc", "e08316376c972b5cb3f085bb39a3680f"); System.out.println(JSON.toJSONString(role)); - System.out.println(JSON.toJSONString(this.getStaffRoleMap("45687aa479955f9d06204d415238f7cc", "7f694a66efe60a47c2114875f310248a"))); + role = getStaffInfo("45687aa479955f9d06204d415238f7cc", "ec524bbbc41d0662cbb36236161005e9"); + System.out.println(JSON.toJSONString(role)); + System.out.println(JSON.toJSONString(getStaffRoleMap("45687aa479955f9d06204d415238f7cc", "7f694a66efe60a47c2114875f310248a"))); } /** @@ -52,22 +63,24 @@ public class CustomerStaffRedis { * @date 2021/8/19 10:29 下午 * @remark 此方法仅用于 获取某个工作人员的信息,不用于获取客户下所有工作人员信息 */ - public CustomerStaffInfoCacheResult getStaffInfo(String customerId, String staffId) { + public static CustomerStaffInfoCacheResult getStaffInfo(String customerId, String staffId) { String key = RedisKeys.getCustomerStaffInfoKey(customerId, staffId); - Map roleMap = redisUtils.hGetAll(key); + Map roleMap = customerStaffRedis.redisUtils.hGetAll(key); if (!CollectionUtils.isEmpty(roleMap)) { - return ConvertUtils.mapToEntity(roleMap, CustomerStaffInfoCacheResult.class); + return ConvertUtils.mapToEntity(roleMap, CustomerStaffInfoCacheResult.class); } CustomerStaffInfoCache resultData = reloadStaffCache(staffId, key); - if (resultData == null) return null; + if (resultData == null) { + return null; + } - return ConvertUtils.sourceToTarget(resultData,CustomerStaffInfoCacheResult.class); + return ConvertUtils.sourceToTarget(resultData, CustomerStaffInfoCacheResult.class); } @Nullable - private CustomerStaffInfoCache reloadStaffCache(String staffId, String key) { - Result staffResult = commonAggFeignClient.getStaffInfo(staffId); + private static CustomerStaffInfoCache reloadStaffCache(String staffId, String key) { + Result staffResult = customerStaffRedis.commonAggFeignClient.getStaffInfo(staffId); if (staffResult == null || !staffResult.success()) { throw new RenException("获取工作人员信息失败"); } @@ -78,7 +91,7 @@ public class CustomerStaffRedis { } Map map = BeanUtil.beanToMap(resultData, false, true); - redisUtils.hMSet(key, map); + customerStaffRedis.redisUtils.hMSet(key, map); return resultData; } @@ -87,20 +100,16 @@ public class CustomerStaffRedis { * * @param customerId * @param staffId - * @return com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoCache - * @author LiuJanJun - * @date 2021/8/19 10:29 下午 - * @remark 此方法仅用于 获取某个工作人员的信息,不用于获取客户下所有工作人员信息 */ - public Map getStaffRoleMap(String customerId, String staffId) { + public static Map getStaffRoleMap(String customerId, String staffId) { String key = RedisKeys.getCustomerStaffInfoKey(customerId, staffId); - Map roleMap = (Map) redisUtils.hGet(key,ROLE_MAP_KEY); + Map roleMap = (Map) customerStaffRedis.redisUtils.hGet(key, ROLE_MAP_KEY); if (!CollectionUtils.isEmpty(roleMap)) { - return roleMap; + return roleMap; } reloadStaffCache(staffId, key); - return getStaffRoleMap(customerId,staffId); + return getStaffRoleMap(customerId, staffId); } /** @@ -112,13 +121,13 @@ public class CustomerStaffRedis { * @author LiuJanJun * @date 2021/8/19 10:39 下午 */ - public boolean delStaffInfoFormCache(String customerId, String staffId) { + public static Boolean delStaffInfoFormCache(String customerId, String staffId) { if (StringUtils.isBlank(customerId) || StringUtils.isBlank(staffId)) { log.warn("delStaffInfoFormCache param is blank,customerId:{},staffId:{}", customerId, staffId); return false; } String key = RedisKeys.getCustomerStaffInfoKey(customerId, staffId); - return redisUtils.delete(key); + return customerStaffRedis.redisUtils.delete(key); } } diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/message/result/InfoRedDotResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/message/result/InfoRedDotResultDTO.java index ce159b6a33..40f96878c5 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/message/result/InfoRedDotResultDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/message/result/InfoRedDotResultDTO.java @@ -1,5 +1,6 @@ package com.epmet.dataaggre.dto.message.result; +import com.epmet.commons.tools.constant.NumConstant; import lombok.Data; import java.io.Serializable; @@ -17,10 +18,10 @@ public class InfoRedDotResultDTO implements Serializable { /** * 我发出的,新回复数量 */ - private Integer sentNewReplyCount; + private Integer sentNewReplyCount = NumConstant.ZERO; /** * 我收到的未读的消息数量 */ - private Integer receivedUnReadCount; + private Integer receivedUnReadCount = NumConstant.ZERO; } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DemoController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DemoController.java index e8fb5e18e3..16d6aa362f 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DemoController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DemoController.java @@ -2,7 +2,6 @@ package com.epmet.dataaggre.controller; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.Result; -import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.dataaggre.service.DemoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -21,8 +20,8 @@ public class DemoController { demoService.doIt(); - CustomerStaffRedis bean = SpringContextUtils.getBean(CustomerStaffRedis.class); - bean.init(); + //CustomerStaffRedis bean = SpringContextUtils.getBean(CustomerStaffRedis.class); + CustomerStaffRedis.initTest(); return new Result(); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetmessage/InfoReceiversDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetmessage/InfoReceiversDao.java index c0d8b4c86d..5d232ffe09 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetmessage/InfoReceiversDao.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetmessage/InfoReceiversDao.java @@ -90,4 +90,20 @@ public interface InfoReceiversDao extends BaseDao { * @date 2021/8/20 2:31 下午 */ List selectReplyAtt(String replyId); + + /** + * @Description 查询我收到的未读的消息数量 + * @Param userId + * @author zxc + * @date 2021/8/20 4:16 下午 + */ + Integer selectUnReadCount(@Param("userId") String userId); + + /** + * @Description 我发出的,新回复数量 + * @Param userId + * @author zxc + * @date 2021/8/20 4:20 下午 + */ + Integer selectNewReplyCount(@Param("userId") String userId); } \ No newline at end of file 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 0d602e6589..bb7395802a 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 @@ -46,8 +46,6 @@ public class EpmetMessageServiceImpl implements EpmetMessageService { @Autowired private InfoReceiversDao infoReceiversDao; @Autowired - private CustomerStaffRedis customerStaffRedis; - @Autowired private InfoProfileDao infoProfileDao; /** @@ -79,7 +77,7 @@ public class EpmetMessageServiceImpl implements EpmetMessageService { ReceiverDTO dto = new ReceiverDTO(); dto.setStaffId(item.getStaffId()); dto.setReadFlag(item.getReadFlag()); - CustomerStaffInfoCacheResult staffInfoCache = customerStaffRedis.getStaffInfo(item.getCustomerId(), item.getStaffId()); + CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(item.getCustomerId(), item.getStaffId()); dto.setStaffName(staffInfoCache.getRealName()); dto.setGender(staffInfoCache.getGender()); dto.setHeadPhoto(staffInfoCache.getHeadPhoto()); @@ -109,7 +107,7 @@ public class EpmetMessageServiceImpl implements EpmetMessageService { List staffNameList = new ArrayList<>(); for (String userId : group.getStaffIdList()) { //查询每个工作人员的基本信息,获取姓名 - CustomerStaffInfoCacheResult staffInfoCache = customerStaffRedis.getStaffInfo(customerId, userId); + CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, userId); if (null != staffInfoCache) { staffNameList.add(staffInfoCache.getRealName()); } @@ -140,7 +138,7 @@ public class EpmetMessageServiceImpl implements EpmetMessageService { if (CollectionUtils.isNotEmpty(staffIds.getList())) { for (String userId : staffIds.getList()) { //查询每个工作人员的基本信息 - CustomerStaffInfoCacheResult staffInfoCache = customerStaffRedis.getStaffInfo(formDTO.getCustomerId(), userId); + CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), userId); if (null != staffInfoCache) { StaffInfoCommonDTO staffInfo = new StaffInfoCommonDTO(); staffInfo.setStaffId(userId); @@ -171,7 +169,7 @@ public class EpmetMessageServiceImpl implements EpmetMessageService { result.setTotal((int) data.getTotal()); for (InfoReplyDetail detail : data.getList()) { //查询每个工作人员的基本信息 - CustomerStaffInfoCacheResult staffInfoCache = customerStaffRedis.getStaffInfo(formDTO.getCustomerId(), detail.getStaffId()); + CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), detail.getStaffId()); detail.setStaffName(staffInfoCache.getRealName()); detail.setGender(staffInfoCache.getGender().toString()); detail.setHeadPhoto(StringUtils.isNotBlank(staffInfoCache.getHeadPhoto()) ? staffInfoCache.getHeadPhoto() : StrConstant.EPMETY_STR); @@ -191,7 +189,10 @@ public class EpmetMessageServiceImpl implements EpmetMessageService { */ @Override public InfoRedDotResultDTO redDot(String userId) { - return null; + InfoRedDotResultDTO result = new InfoRedDotResultDTO(); + result.setReceivedUnReadCount(infoReceiversDao.selectUnReadCount(userId)); + result.setSentNewReplyCount(infoReceiversDao.selectNewReplyCount(userId)); + return result; } /** 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 c743821b4e..3cfb3acf89 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 @@ -76,8 +76,6 @@ public class EpmetUserServiceImpl implements EpmetUserService { private GovProjectService govProjectService; @Resource private GovStaffRoleDao govStaffRoleDao; - @Resource - private CustomerStaffRedis customerStaffRedis; /** * @Description 根据UserIds查询 @@ -487,7 +485,7 @@ public class EpmetUserServiceImpl implements EpmetUserService { RoleUsersResultDTO dto = new RoleUsersResultDTO(); dto.setStaffId(item.getStaffId()); //从redis获取用户信息 - CustomerStaffInfoCacheResult staffInfoCache = customerStaffRedis.getStaffInfo(item.getCustomerId(), item.getStaffId()); + CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(item.getCustomerId(), item.getStaffId()); dto.setGender(staffInfoCache.getGender()); dto.setHeadPhoto(staffInfoCache.getHeadPhoto()); dto.setName(staffInfoCache.getRealName()); @@ -539,7 +537,7 @@ public class EpmetUserServiceImpl implements EpmetUserService { CustomerStaffEntity staffEntity = customerStaffDao.selectOne(queryWrapper); CustomerStaffResultDTO result = ConvertUtils.sourceToTarget(staffEntity, CustomerStaffResultDTO.class); - //2.查询工作人员所属组织信息 + //查询工作人员所属组织信息 CustomerAgencyDTO agencyDTO = govOrgService.gridByAgencyId(null,staffId); if (agencyDTO == null){ log.error("getStaffInfo have any agency staffId:{}",staffId); @@ -571,30 +569,31 @@ public class EpmetUserServiceImpl implements EpmetUserService { Map roleMap = roleList.stream().collect(Collectors.toMap(StaffRoleResultDTO::getRoleKey, StaffRoleResultDTO::getRoleName)); result.setRoleMap(roleMap); - //1.查询当前人员所在的网格列表 + //1.查询工作人员所在的网格列表 List list = govOrgService.getStaffGridList(staffId); 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); + if (isContinueMkName && OrgTypeEnum.GRID.getCode().equals(fromOrgType)&&grid.getId().equals(result.getFromOrgId())){ + showNameBuilder.append(agencyDTO.getOrganizationName()).append(StrConstant.HYPHEN).append(grid.getName()); + } } result.setGridList(idAndNameList); + //查询工作人员所在的部门列表 List deptList = govOrgService.getStaffDeptList(staffId); idAndNameList = new ArrayList<>(); for (CustomerDepartmentDTO org : deptList) { 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); + if (isContinueMkName && OrgTypeEnum.DEPT.getCode().equals(fromOrgType)&&dept.getId().equals(result.getFromOrgId())){ + showNameBuilder.append(agencyDTO.getOrganizationName()).append(StrConstant.HYPHEN).append(dept.getName()); + } } result.setDeptList(idAndNameList); //特殊处理 显示的名字 diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoReceiversDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoReceiversDao.xml index a97dddcecf..52010a0236 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoReceiversDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoReceiversDao.xml @@ -104,4 +104,25 @@ ORDER BY m.SORT ASC + + + + + + \ No newline at end of file diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml index 6fea2678fe..2f1cae9706 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml @@ -68,10 +68,10 @@ sr.staff_id, case when gsr.role_key = - + 'agency_leader' - + 'dept_leader' @@ -92,10 +92,10 @@ ORDER BY gsr.role_key ]]> - + 'agency_leader' - + 'dept_leader' diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml index d08de26805..29da78941d 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml @@ -53,7 +53,7 @@ - + SELECT ca.customer_id, ca.id AS "agencyId", @@ -464,7 +464,7 @@ AND ca.del_flag = '0' AND cd.id = #{orgId} - + SELECT ca.customer_id, ca.id AS "agencyId", diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index 0333550df2..9405f9a4a9 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -99,8 +99,6 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl page(Map params) { @@ -343,7 +341,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl().ok(ConvertUtils.sourceToTarget(staffEntity, CustomerStaffDTO.class)); } @@ -416,7 +414,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl implements StaffRoleService { - @Autowired - private CustomerStaffRedis staffRedis; - - @Autowired - private GovStaffRoleTemplateDao govStaffRoleTemplateDao; - @Override public PageData page(Map params) { IPage page = baseDao.selectPage(