1.增加从缓存获取员工 2.debug的日志调整.

pull/309/head
fjlinhua 3 years ago
parent 3ce2d6ffa5
commit ec38f76403

@ -8,6 +8,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer;
/** /**
@ -40,4 +41,17 @@ public class RedisConfig extends CachingConfigurerSupport
template.afterPropertiesSet(); template.afterPropertiesSet();
return template; return template;
} }
@Bean
/**
*
* @param connectionFactory
* @return
*/
public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory connectionFactory) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
return container;
}
} }

@ -77,12 +77,35 @@
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-swagger</artifactId> <artifactId>ruoyi-common-swagger</artifactId>
</dependency> </dependency>
<!-- nutz used nutmap-->
<dependency> <dependency>
<groupId>org.nutz</groupId> <groupId>org.nutz</groupId>
<artifactId>nutz</artifactId> <artifactId>nutz</artifactId>
<version>1.r.69.20210929</version> <version>1.r.69.20210929</version>
</dependency> </dependency>
<!-- ehcache -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>

@ -23,6 +23,10 @@ public class BulletinRecive extends BaseEntity
/** 接收员工ID */ /** 接收员工ID */
@Excel(name = "接收员工ID") @Excel(name = "接收员工ID")
private Long reciveUserId; private Long reciveUserId;
/**
* ID
*/
private Long reciveDeptId;
/** 阅读时间 */ /** 阅读时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ -48,8 +52,16 @@ public class BulletinRecive extends BaseEntity
/** A:已阅读B:已删除 C:未阅读 */ /** A:已阅读B:已删除 C:未阅读 */
@Excel(name = "A:已阅读B:已删除 C:未阅读") @Excel(name = "A:已阅读B:已删除 C:未阅读")
private String sts; private String sts;
/** public Long getReciveDeptId() {
return reciveDeptId;
}
public void setReciveDeptId(Long reciveDeptId) {
this.reciveDeptId = reciveDeptId;
}
/**
* ReciveId * ReciveId
* @param ID * @param ID
*/ */

@ -3,6 +3,7 @@ package com.ruoyi.system.service.impl;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.ruoyi.cache.service.IOrgCacheService;
import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.core.utils.DateUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -23,8 +24,7 @@ import com.ruoyi.system.mapper.BulletinInfoMapper;
import com.ruoyi.system.mapper.BulletinReciveMapper; import com.ruoyi.system.mapper.BulletinReciveMapper;
import com.ruoyi.system.domain.BulletinInfo; import com.ruoyi.system.domain.BulletinInfo;
import com.ruoyi.system.service.IBulletinInfoService; import com.ruoyi.system.service.IBulletinInfoService;
import com.ruoyi.util.IDUtil;
import ecc.c3.util.IDUtil;
/** /**
* Service * Service
@ -40,6 +40,8 @@ public class BulletinInfoServiceImpl implements IBulletinInfoService
private BulletinInfoMapper bulletinInfoMapper; private BulletinInfoMapper bulletinInfoMapper;
@Autowired @Autowired
private BulletinReciveMapper bulletinReciveMapper; private BulletinReciveMapper bulletinReciveMapper;
@Autowired
private IOrgCacheService orgCacheService;
/** /**
* *
@ -52,9 +54,8 @@ public class BulletinInfoServiceImpl implements IBulletinInfoService
{ {
List<BulletinRecive> reciveUserIdAndbulletinId=bulletinReciveMapper.selectBulletinReciveUserIdByBulletinIds(new String[] {bulletinId}); List<BulletinRecive> reciveUserIdAndbulletinId=bulletinReciveMapper.selectBulletinReciveUserIdByBulletinIds(new String[] {bulletinId});
BulletinInfo info= bulletinInfoMapper.selectBulletinInfoByBulletinId(bulletinId); BulletinInfo info= bulletinInfoMapper.selectBulletinInfoByBulletinId(bulletinId);
//TODO 把员工换算成名称 info.setCreateBy(orgCacheService.getSysUser(info.getCreateUserId()).map(sysUser->sysUser.getUserName()).orElse(""));
info.setCreateBy(info.getCreateUserId()+""); info.setUpdateBy(orgCacheService.getSysUser(info.getUpdateUserId()).map(sysUser->sysUser.getUserName()).orElse(""));
info.setUpdateBy(info.getUpdateUserId()+"");
List<Long> reciveUserIdList=reciveUserIdAndbulletinId.stream().map(userId->userId.getReciveUserId()).collect(Collectors.toList()); List<Long> reciveUserIdList=reciveUserIdAndbulletinId.stream().map(userId->userId.getReciveUserId()).collect(Collectors.toList());
info.setReceiveStaffIds(reciveUserIdList); info.setReceiveStaffIds(reciveUserIdList);
info.setReciveStaffNames(StringUtils.join(reciveUserIdList.iterator(), ",")); info.setReciveStaffNames(StringUtils.join(reciveUserIdList.iterator(), ","));
@ -78,13 +79,14 @@ public class BulletinInfoServiceImpl implements IBulletinInfoService
final NutMap reciveBulletinReciveMap=NutMap.NEW(); final NutMap reciveBulletinReciveMap=NutMap.NEW();
List<BulletinRecive> reciveUserIdAndbulletinIdList=bulletinReciveMapper.selectBulletinReciveUserIdByBulletinIds(bulletinIds); List<BulletinRecive> reciveUserIdAndbulletinIdList=bulletinReciveMapper.selectBulletinReciveUserIdByBulletinIds(bulletinIds);
reciveUserIdAndbulletinIdList.forEach(reciveUserIdAndBulletinId->{ reciveUserIdAndbulletinIdList.forEach(reciveUserIdAndBulletinId->{
//TODO 这里要把reciveUserId换算成用户名 String reciveUserName=orgCacheService.getSysUser(reciveUserIdAndBulletinId.getReciveUserId()).map(sysUser->sysUser.getUserName()).orElse("");
reciveUserNameMap.addv2(reciveUserIdAndBulletinId.getBulletinId(), reciveUserIdAndBulletinId.getReciveUserId()+""); reciveUserNameMap.addv2(reciveUserIdAndBulletinId.getBulletinId(), reciveUserName);
reciveBulletinReciveMap.addv2(reciveUserIdAndBulletinId.getBulletinId(), reciveUserIdAndBulletinId); reciveBulletinReciveMap.addv2(reciveUserIdAndBulletinId.getBulletinId(), reciveUserIdAndBulletinId);
}); });
list.forEach(info->{ list.forEach(info->{
String reciveStaffNames=String.join(",", reciveUserNameMap.getList(info.getBulletinId(), String.class, Collections.emptyList())); String reciveStaffNames=String.join(",", reciveUserNameMap.getList(info.getBulletinId(), String.class, Collections.emptyList()));
info.setReciveStaffNames(reciveStaffNames); info.setReciveStaffNames(reciveStaffNames);
info.setCreateBy(orgCacheService.getSysUser(info.getCreateUserId()).map(sysUser->sysUser.getUserName()).orElse(""));
info.setBulletinReciveList(reciveBulletinReciveMap.getList(info.getBulletinId(), BulletinRecive.class,Collections.emptyList())); info.setBulletinReciveList(reciveBulletinReciveMap.getList(info.getBulletinId(), BulletinRecive.class,Collections.emptyList()));
}); });
} }

@ -3,6 +3,7 @@ package com.ruoyi.system.service.impl;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.ruoyi.cache.service.IOrgCacheService;
import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.common.security.utils.SecurityUtils;
@ -30,6 +31,8 @@ public class BulletinReciveServiceImpl implements IBulletinReciveService
private BulletinReciveMapper bulletinReciveMapper; private BulletinReciveMapper bulletinReciveMapper;
@Autowired @Autowired
private BulletinInfoMapper bulletinInfoMapper; private BulletinInfoMapper bulletinInfoMapper;
@Autowired
private IOrgCacheService orgCacheService;
@Transactional @Transactional
/** /**
@ -67,6 +70,12 @@ public class BulletinReciveServiceImpl implements IBulletinReciveService
if(reciveList.isEmpty()) { if(reciveList.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
} }
reciveList.forEach(recive->{
orgCacheService.getSysUser(recive.getReciveUserId()).ifPresent(cacheSysUser->{
recive.setCreateBy(cacheSysUser.getUserName());
recive.setReciveDeptId(cacheSysUser.getDeptId());
});
});
NutMap map=NutMap.NEW(); NutMap map=NutMap.NEW();
String[] bulletinIds=new String[reciveList.size()]; String[] bulletinIds=new String[reciveList.size()];
for (int i = 0; i < bulletinIds.length; i++) { for (int i = 0; i < bulletinIds.length; i++) {

@ -6,6 +6,9 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.cache.domain.CacheSysDept;
import com.ruoyi.cache.service.IOrgCacheService;
import com.ruoyi.common.core.constant.UserConstants; import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.core.text.Convert;
@ -34,6 +37,8 @@ public class SysDeptServiceImpl implements ISysDeptService
@Autowired @Autowired
private SysRoleMapper roleMapper; private SysRoleMapper roleMapper;
@Autowired
private IOrgCacheService orgCacheService;
/** /**
* *
@ -218,7 +223,12 @@ public class SysDeptServiceImpl implements ISysDeptService
throw new ServiceException("部门停用,不允许新增"); throw new ServiceException("部门停用,不允许新增");
} }
dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept); int updateCount= deptMapper.insertDept(dept);
if(updateCount>0) {
CacheSysDept cacheDept=new CacheSysDept(dept);
orgCacheService.saveDeptInfo(cacheDept);
}
return updateCount;
} }
/** /**
@ -246,6 +256,10 @@ public class SysDeptServiceImpl implements ISysDeptService
// 如果该部门是启用状态,则启用该部门的所有上级部门 // 如果该部门是启用状态,则启用该部门的所有上级部门
updateParentDeptStatusNormal(dept); updateParentDeptStatusNormal(dept);
} }
if(result>0) {
CacheSysDept cacheDept=new CacheSysDept(dept);
orgCacheService.saveDeptInfo(cacheDept);
}
return result; return result;
} }

@ -1,4 +1,4 @@
package ecc.c3.util; package com.ruoyi.util;
import java.util.Random; import java.util.Random;

@ -1,4 +1,4 @@
package ecc.c3.util; package com.ruoyi.util;
/** /**
* Twitter_Snowflake<br> * Twitter_Snowflake<br>

@ -94,6 +94,13 @@
<logger name="io.lettuce" level="info" /> <logger name="io.lettuce" level="info" />
<logger name="druid.sql" level="info" /> <logger name="druid.sql" level="info" />
<logger name="org.mybatis" level="info" /> <logger name="org.mybatis" level="info" />
<logger name="io.micrometer" level="info" />
<logger name="com.baomidou" level="info" />
<logger name="io.netty" level="info" />
<logger name="net.sf" level="info" />
<logger name="org.reflections" level="info" />
<!-- Spring日志级别控制 --> <!-- Spring日志级别控制 -->
<logger name="com.ruoyi.system.mapper" level="debug" /> <logger name="com.ruoyi.system.mapper" level="debug" />

Loading…
Cancel
Save