yeshijie 7 سال پیش
والد
کامیت
b012c74afb

+ 25 - 16
patient-co-manage/redis-cache/src/main/java/com/yihu/wlyy/controller/redis/RedisScheduledController.java

@ -27,10 +27,12 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.io.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@ -50,18 +52,16 @@ public class RedisScheduledController {
    private String rdbFilePath;
    @Value("${ehr-redis.cache.memory.outFilePath}")
    private String outFilePath;
//    @Value("${ehr-redis.server.host}")
//    private String redisServerHost;
//    @Value("${ehr-redis.server.username}")
//    private String redisServerUsername;
//    @Value("${ehr-redis.server.password}")
//    private String redisServerPwd;
//    @Value("${ehr-redis.server.ssh-port}")
//    private int redisServerSshPort;
    private String redisServerHost = "";
    private String redisServerUsername = "";
    private String redisServerPwd = "";
    private int redisServerSshPort = 22;
    @Value("${ehr-redis.cache.memory.filename}")
    private String filename;
    @Value("${ehr-redis.server.host}")
    private String redisServerHost;
    @Value("${ehr-redis.server.username}")
    private String redisServerUsername;
    @Value("${ehr-redis.server.password}")
    private String redisServerPwd;
    @Value("${ehr-redis.server.ssh-port}")
    private int redisServerSshPort;
    @Autowired
    private RedisCacheKeyMemoryService redisCacheKeyMemoryService;
@ -84,20 +84,21 @@ public class RedisScheduledController {
    @RequestMapping(value = "/redis/cache/statistics/exportAndImportRedisMemoryData", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("导出 redis 内存分析报告,并导入到数据库")
    public void exportAndImportRedisMemoryData() {
    public String exportAndImportRedisMemoryData() {
        long start = System.currentTimeMillis();
        try {
            // 导出内存分析报告CSV文件(得到的内存值是近似值,比实际略小)
            // 生产环境服务器不允许代码直接通过SSH访问服务器,故暂时注释,另寻方法。
            exportRedisMemoryReport();
//            exportRedisMemoryReport();
            long export = System.currentTimeMillis();
            logger.info("成功导出Redis内存分析报告,耗时:" + (export - start) + " 毫秒");
            // 导入CSV格式的内存分析数据
            FlatFileItemReader<RedisCacheKeyMemory> itemReader = new FlatFileItemReader<>();
            itemReader.setResource(new FileSystemResource(outFilePath));
            itemReader.setResource(new FileSystemResource(outFilePath+filename));
            itemReader.setLinesToSkip(1);
            DefaultLineMapper<RedisCacheKeyMemory> lineMapper = new DefaultLineMapper<>();
            lineMapper.setLineTokenizer(new DelimitedLineTokenizer());
@ -114,6 +115,8 @@ public class RedisScheduledController {
            int i = 0;
            while ((redisCacheKeyMemory = itemReader.read()) != null) {
                redisCacheKeyMemory.setId(UuidUtil.randomUUID());
                redisCacheKeyMemory.setModifyDate(new Date());
                redisCacheKeyMemory.setCreateDate(new Date());
                redisCacheKeyMemoryList.add(redisCacheKeyMemory);
                if (redisCacheKeyMemoryList.size() == 1000) {
                    redisCacheKeyMemoryService.save(redisCacheKeyMemoryList);
@ -131,6 +134,7 @@ public class RedisScheduledController {
            e.printStackTrace();
            logger.error("发生异常:" + e.getMessage());
        }
        return "导出成功";
    }
    /**
@ -160,7 +164,11 @@ public class RedisScheduledController {
            InputStream in = channel.getInputStream();
            channel.connect();
            File outFile = new File(outFilePath);
            File file = new File(outFilePath);
            if(!file.exists()){
                file.mkdirs();
            }
            File outFile = new File(file,filename);
            if (!outFile.exists()){
                outFile.createNewFile();
            }
@ -179,6 +187,7 @@ public class RedisScheduledController {
            channel.disconnect();
            session.disconnect();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("生成Redis内存分析报告发生异常:" + e.getMessage());
            throw new Exception();
        } finally {

+ 17 - 4
patient-co-manage/redis-cache/src/main/resources/application.yml

@ -58,8 +58,13 @@ ehr-redis:
  cache:
    memory:
      rdbFilePath: /usr/local/bin/dump.rdb
      outFilePath: /usr/local/ehr/redisReport/memory.csv
      outFilePath: /usr/local/ehr/redisReport/
      filename: memory.csv
  server:
    host: 172.19.103.47
    username: root
    password: jkzl
    ssh-port: 22
---
spring:
  profiles: test
@ -73,7 +78,11 @@ spring:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
  server:
    host: 172.19.103.47
    username: root
    password: jkzl
    ssh-port: 22
---
spring:
@ -88,4 +97,8 @@ spring:
    host: 27.155.101.77 # Redis server host.
    port: 6380 # Redis server port.
    password: jkzl_ehr
  server:
    host: 172.19.103.47
    username: root
    password: jkzl
    ssh-port: 22

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/message/MessageService.java

@ -45,7 +45,7 @@ public class MessageService extends BaseService {
            if(messageNoticeSetting == null){
                messageNoticeSetting = new MessageNoticeSetting();
                messageNoticeSetting.setCreateTime(new Date());
                messageNoticeSetting.setFamilyTopicSwitch(1);
                messageNoticeSetting.setFamilyTopicSwitch(0);
                messageNoticeSetting.setCoordinationSwitch(1);
                messageNoticeSetting.setHealthSignSwitch(1);
                messageNoticeSetting.setImSwitch(1);

+ 1 - 1
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/MessageService.java

@ -43,7 +43,7 @@ public class MessageService {
            if(messageNoticeSetting == null){
                messageNoticeSetting = new MessageNoticeSetting();
                messageNoticeSetting.setCreateTime(new Date());
                messageNoticeSetting.setFamilyTopicSwitch(1);
                messageNoticeSetting.setFamilyTopicSwitch(0);
                messageNoticeSetting.setCoordinationSwitch(1);
                messageNoticeSetting.setHealthSignSwitch(1);
                messageNoticeSetting.setImSwitch(1);

+ 1 - 1
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/MessageService.java

@ -42,7 +42,7 @@ public class MessageService {
            if(messageNoticeSetting == null){
                messageNoticeSetting = new MessageNoticeSetting();
                messageNoticeSetting.setCreateTime(new Date());
                messageNoticeSetting.setFamilyTopicSwitch(1);
                messageNoticeSetting.setFamilyTopicSwitch(0);
                messageNoticeSetting.setCoordinationSwitch(1);
                messageNoticeSetting.setHealthSignSwitch(1);
                messageNoticeSetting.setImSwitch(1);

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -483,7 +483,7 @@ public class MessageService extends BaseService {
            if(messageNoticeSetting == null){
                messageNoticeSetting = new MessageNoticeSetting();
                messageNoticeSetting.setCreateTime(new Date());
                messageNoticeSetting.setFamilyTopicSwitch(1);
                messageNoticeSetting.setFamilyTopicSwitch(0);
                messageNoticeSetting.setCoordinationSwitch(1);
                messageNoticeSetting.setHealthSignSwitch(1);
                messageNoticeSetting.setImSwitch(1);

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -519,7 +519,7 @@ public class MessageService extends BaseService {
            if(messageNoticeSetting == null){
                messageNoticeSetting = new MessageNoticeSetting();
                messageNoticeSetting.setCreateTime(new Date());
                messageNoticeSetting.setFamilyTopicSwitch(1);
                messageNoticeSetting.setFamilyTopicSwitch(0);
                messageNoticeSetting.setCoordinationSwitch(1);
                messageNoticeSetting.setHealthSignSwitch(1);
                messageNoticeSetting.setImSwitch(1);