Forráskód Böngészése

redis log
webSocket

wanggaokun 1 éve
szülő
commit
8e18df4e46

+ 11 - 0
pdaaphm-admin/pom.xml

@@ -24,6 +24,17 @@
             <optional>true</optional> <!-- 表示依赖不会传递 -->
         </dependency>
 
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-websocket</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.7.6</version> <!-- 使用最新版本 -->
+        </dependency>
+
         <!-- swagger3-->
         <dependency>
             <groupId>io.springfox</groupId>

+ 2 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/biz/controller/AlgorithmController.java

@@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse;
 import com.pdaaphm.biz.dto.AlgorithmDTO;
 import com.pdaaphm.common.core.domain.entity.SysDictData;
 import com.pdaaphm.common.utils.StringUtils;
+import com.pdaaphm.common.utils.uuid.IdUtils;
 import com.pdaaphm.system.service.ISysDictTypeService;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -57,6 +58,7 @@ public class AlgorithmController extends BaseController
             algorithm.setTypes(sysDictDataList.stream().map(SysDictData::getDictValue).collect(Collectors.toList()));
         }
         List<Algorithm> list = algorithmService.selectAlgorithmList(algorithm);
+        list.forEach(item -> item.setTaskId("TASK-" + item.getId()));
         return getDataTable(list);
     }
 

+ 36 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/biz/controller/LogController.java

@@ -0,0 +1,36 @@
+package com.pdaaphm.biz.controller;
+
+import com.pdaaphm.biz.service.IRedisLogService;
+import com.pdaaphm.common.annotation.Log;
+import com.pdaaphm.common.core.domain.AjaxResult;
+import com.pdaaphm.common.core.redis.RedisCache;
+import com.pdaaphm.common.enums.BusinessType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import static com.pdaaphm.common.core.domain.AjaxResult.success;
+
+/**
+ * @Description LogController
+ * @Author WGK
+ * @Date 2023/10/18 18:32
+ */
+
+@RestController
+@RequestMapping("/log")
+public class LogController {
+    @Autowired
+    private IRedisLogService redisLogService;
+    @Log(title = "算法", businessType = BusinessType.UPDATE)
+    @GetMapping(value = "/info/{taskId}")
+    public AjaxResult getLogInfo(@PathVariable("taskId") String taskId) throws IOException {
+        return success(redisLogService.getLogInfo(taskId));
+    }
+
+}

+ 2 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/biz/domain/Algorithm.java

@@ -68,5 +68,7 @@ public class Algorithm extends BaseEntity
      */
     private String dictType;
 
+    private String taskId;
+
     private List<String> types;
 }

+ 13 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/IRedisLogService.java

@@ -0,0 +1,13 @@
+package com.pdaaphm.biz.service;
+
+/**
+ * @Description IRedisLogService
+ * @Author WGK
+ * @Date 2023/10/18 17:53
+ */
+public interface IRedisLogService {
+  String getLogInfo (String taskId);
+
+  void info(String taskId, String megStr);
+  void error(String taskId, String megStr);
+}

+ 21 - 3
pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/AlgorithmServiceImpl.java

@@ -17,8 +17,10 @@ import com.pdaaphm.biz.factory.AlgorithmFactory;
 import com.pdaaphm.biz.mapper.AlgorithmIoFieldMapper;
 import com.pdaaphm.biz.mapper.AlgorithmSubTypeMapper;
 import com.pdaaphm.biz.mapper.SubAlgorithmMapper;
+import com.pdaaphm.biz.service.IRedisLogService;
 import com.pdaaphm.biz.service.RunAlgorithmService;
 import com.pdaaphm.common.config.PadaphmConfig;
+import com.pdaaphm.common.core.redis.RedisCache;
 import com.pdaaphm.common.utils.DateUtils;
 import com.pdaaphm.common.utils.file.FileUploadUtils;
 import org.springframework.beans.BeanUtils;
@@ -49,6 +51,11 @@ public class AlgorithmServiceImpl implements IAlgorithmService
     private AlgorithmFactory algorithmFactory;
     @Autowired
     private AlgorithmSubTypeMapper algorithmSubTypeMapper;
+    @Autowired
+    private IRedisLogService redisLogService;
+
+    @Autowired
+    private RedisCache redisCache;
 
     /**
      * 查询算法
@@ -170,9 +177,14 @@ public class AlgorithmServiceImpl implements IAlgorithmService
     @Override
     public List<Map> getOption() { return algorithmMapper.getOption(); }
 
-    @Async
+    // @Async
     @Override
     public void runAlgorithms(Long id) throws IOException {
+        String key = "TASK-" + id;
+        redisCache.deleteObject(key);
+        redisCache.expire(key, 300, TimeUnit.SECONDS);
+        redisLogService.info(key , "任务启动.....");
+        redisLogService.info(key , "更新任务状态.....");
         algorithmMapper.updateStatusById(id, Algorithm.runningCode);
         Date startTime = DateUtils.getNowDate();
         algorithmMapper.updateStartTimeById(id, startTime);
@@ -183,6 +195,7 @@ public class AlgorithmServiceImpl implements IAlgorithmService
         if(CollectionUtils.isEmpty(list)){
             return;
         }
+        redisLogService.info(key , "数据处理中.....");
         List<String> docAddress = new ArrayList<>(list.size());
         List<String> resultAddress = new ArrayList<>(list.size());
         String prefix = PadaphmConfig.getProfile();
@@ -207,16 +220,21 @@ public class AlgorithmServiceImpl implements IAlgorithmService
                 resultAddress.add(fileNameFinal);
             }
         }
+        redisLogService.info(key, "数据处理完成.....");
         RequestDTO requestDto = new RequestDTO();
         requestDto.setDocList(docAddress);
         requestDto.setResultList(resultAddress);
+        redisLogService.info(key , "分析算法程序开始.....");
         runAlgorithmService.runAlgorithm(id, (String)list.get(0).get("url"), requestDto);
+        redisLogService.info(key , "执行算法完成.....");
+        redisLogService.info(key , "保存结果数据.....");
         Date completedTime = DateUtils.getNowDate();
         algorithmMapper.updateCompletedTimeById(id, completedTime);
-        Long diffInMillies = completedTime.getTime() - startTime.getTime();
+        long diffInMillies = completedTime.getTime() - startTime.getTime();
         Long costSecond = TimeUnit.MILLISECONDS.toSeconds(diffInMillies);
         algorithmMapper.updateCostSecondById(id, costSecond);
         algorithmMapper.updateStatusById(id, Algorithm.completedCode);
-        return;
+        redisLogService.info(key , "保存数据完成.....");
+        redisLogService.info(key, "任务执行完成");
     }
 }

+ 55 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/RedisLogService.java

@@ -0,0 +1,55 @@
+package com.pdaaphm.biz.service.impl;
+
+import cn.hutool.core.date.DateUtil;
+import com.pdaaphm.biz.service.IRedisLogService;
+import com.pdaaphm.common.core.redis.RedisCache;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.MessageFormat;
+
+/**
+ * @Description RedisLogService
+ * @Author WGK
+ * @Date 2023/10/18 18:13
+ */
+@Service
+@Slf4j
+public class RedisLogService implements IRedisLogService {
+
+    @Autowired
+    private RedisCache redisCache;
+
+    @Override
+    public String getLogInfo(String taskId) {
+        String sss = redisCache.getCacheObject(taskId);
+        log.error(sss);
+        return sss;
+    }
+
+    @Override
+    public void info(String taskId, String megStr) {
+        this.addInfo("INFO" , taskId, megStr);
+    }
+
+    @Override
+    public void error(String taskId, String megStr) {
+        this.addInfo("ERROR" , taskId, megStr);
+    }
+
+    private void addInfo(String level, String taskId, String megStr) {
+        String message = String.format("<p> %s: [%s] -> %s </p>", level, DateUtil.now(), megStr );
+        if ("ERROR".equals(level)) {
+            message = String.format("<p style='color: #e3270e'> %s: [%s] %s </p>", level, DateUtil.now(), megStr );
+        }
+        // String msg = "当前任务ID: " + taskId + ";任务进展:" + megStr;
+        log.info(megStr);
+        if(redisCache.hasKey(taskId)) {
+            message = redisCache.getCacheObject(taskId) + message;
+        }
+        // redisCache.appendCacheString(taskId, message);
+        // log.error(redisCache.getCacheObject(taskId));
+        redisCache.setCacheObject(taskId, message);
+    }
+}

+ 16 - 8
pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/RunMatlabImpl.java

@@ -8,9 +8,11 @@ import com.pdaaphm.biz.dto.RequestDTO;
 import com.pdaaphm.biz.mapper.AlgorithmIoFieldMapper;
 import com.pdaaphm.biz.mapper.FileMapper;
 import com.pdaaphm.biz.mapper.SubAlgorithmMapper;
+import com.pdaaphm.biz.service.IRedisLogService;
 import com.pdaaphm.biz.service.RunAlgorithmService;
 import com.pdaaphm.common.config.PadaphmConfig;
 import com.pdaaphm.common.utils.DateUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -27,6 +29,7 @@ import java.util.*;
 import java.io.IOException;
 
 @Service
+@Slf4j
 public class RunMatlabImpl implements RunAlgorithmService {
 
     @Autowired
@@ -38,6 +41,9 @@ public class RunMatlabImpl implements RunAlgorithmService {
     @Autowired
     private AlgorithmIoFieldMapper algorithmIoFieldMapper;
 
+    @Autowired
+    private IRedisLogService redisLogService;
+
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
     @Override
@@ -54,6 +60,7 @@ public class RunMatlabImpl implements RunAlgorithmService {
         int p = 0;
         List<Map> matlabIoMapList = algorithmIoFieldMapper.selectMatlabIoPathTypeIndexByAlgoId(id);
         List<String> matlabOutputPathList = new LinkedList<>();
+        redisLogService.info("TASK-"+ id, "分析算法程序......");
         for (Map matlabIoMap : matlabIoMapList) {
             if (AlgorithmIoField.inputCode.equals(matlabIoMap.get("type"))) {
                 String matlabInputPathWithNoFileType = matlabIoMap.get("matlab_io_path") + "\\input" + matlabIoMap.get("index");
@@ -72,9 +79,12 @@ public class RunMatlabImpl implements RunAlgorithmService {
                 matlabOutputPathList.add(matlabOutputPathWithNoFileType);
             }
         }
+        redisLogService.info("TASK-"+ id, "分析算法文件完成......");
+        redisLogService.info("TASK-"+ id, "执行算法......");
 
         //run matlab exe
         runMatExe(url);
+        redisLogService.info("TASK-"+ id, "执行算法完成......");
 
         //将matlab输出的文件从matlabOutputPathList里copy到文件系统outputPath
 
@@ -101,6 +111,7 @@ public class RunMatlabImpl implements RunAlgorithmService {
         // save result path to subAlgorithm
         List<Map> subAlgorithmOutputList = subAlgorithmMapper.selectSubAlgorithmOutputList(id);
         if (resultList == null) {
+            redisLogService.error("TASK-"+ id, "算法未配置输出......");
             return res.error("算法未配置输出");
         }
         for (int i = 0; i < resultList.size(); i++) {
@@ -131,6 +142,7 @@ public class RunMatlabImpl implements RunAlgorithmService {
                 subAlgorithm.setCreateTime(DateUtils.getNowDate());
                 subAlgorithmMapper.updateSubAlgorithm(subAlgorithm);
             } else {
+                redisLogService.error("TASK-"+ id, "输出文件未生成!");
                 logger.error("输出文件未生成!");
                 // todo 对程序结果产生负面影响的分子,应反馈给前端
                 // update algorithm
@@ -237,12 +249,10 @@ public class RunMatlabImpl implements RunAlgorithmService {
             // Optionally, wait for the threads to finish reading.
             outputThread.join();
             errorThread.join();
-
-            System.out.println("外部程序执行完成,退出码:" + exitCode);
+            log.info("外部程序执行完成,退出码:{}", exitCode);
         } catch (IOException | InterruptedException e) {
-            e.printStackTrace();
+            log.error(e.getMessage());
         }
-        return;
     }
 
     public static void main(String args[]) {
@@ -286,11 +296,9 @@ public class RunMatlabImpl implements RunAlgorithmService {
             // Optionally, wait for the threads to finish reading.
             outputThread.join();
             errorThread.join();
-
-            System.out.println("外部程序执行完成,退出码:" + exitCode);
+            log.info("外部程序执行完成,退出码:{}", exitCode);
         } catch (IOException | InterruptedException e) {
-            e.printStackTrace();
+            log.error(e.getMessage());
         }
-        return;
     }
 }

+ 19 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/webSocket/config/WebSocketConfig.java

@@ -0,0 +1,19 @@
+package com.pdaaphm.webSocket.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.socket.server.standard.ServerEndpointExporter;
+
+/**
+ * @Description WebSocketConfig
+ * @Author WGK
+ * @Date 2023/10/18 14:15
+ */
+// @Configuration
+public class WebSocketConfig {
+    @Bean
+    public ServerEndpointExporter serverEndpointExporter() {
+        return new ServerEndpointExporter();
+    }
+
+}

+ 106 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/webSocket/config/WebSocketServer.java

@@ -0,0 +1,106 @@
+package com.pdaaphm.webSocket.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.websocket.OnClose;
+import javax.websocket.OnError;
+import javax.websocket.OnMessage;
+import javax.websocket.OnOpen;
+import javax.websocket.Session;
+import javax.websocket.server.PathParam;
+import javax.websocket.server.ServerEndpoint;
+import java.io.IOException;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @Description WebSocketServer
+ * @Author WGK
+ * @Date 2023/10/18 14:30
+ */
+@Slf4j
+@ServerEndpoint("/socketserver/{taskId}")
+@Component
+public class WebSocketServer {
+    /**
+     * concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
+     */
+    private static ConcurrentHashMap<String, WebSocketServer> webSocketMap = new ConcurrentHashMap<>();
+    /**
+     * 与某个客户端的连接会话,需要通过它来给客户端发送数据
+     */
+    private Session session;
+    /**
+     * 接收taskId
+     */
+    private String taskId = "";
+
+    /**
+     * 连接建立成功调用的方法
+     */
+    @OnOpen
+    public void onOpen(Session session, @PathParam("taskId") String taskId) {
+        this.session = session;
+        this.taskId = taskId;
+        if (webSocketMap.containsKey(taskId)) {
+            webSocketMap.remove(taskId);
+            webSocketMap.put(taskId, this);
+        } else {
+            webSocketMap.put(taskId, this);
+        }
+        try {
+            sendMessage("socket连接成功");
+        } catch (IOException e) {
+            log.error("socket>>" + taskId + ",网络异常!!!!!!");
+        }
+    }
+
+    /**
+     * 连接关闭调用的方法
+     */
+    @OnClose
+    public void onClose() {
+        if (webSocketMap.containsKey(taskId)) {
+            webSocketMap.remove(taskId);
+        }
+    }
+
+    /**
+     * 收到客户端消息后调用的方法
+     *
+     * @param message 客户端发送过来的消息
+     */
+    @OnMessage
+    public void onMessage(String message, Session session) {
+        log.info("socket>>>:" + taskId + ",报文:" + message);
+    }
+
+    /**
+     * onError
+     *
+     * @param session session
+     * @param error error
+     */
+    @OnError
+    public void onError(Session session, Throwable error) {
+        log.error("用户错误:" + this.taskId + ",原因:" + error.getMessage());
+        error.printStackTrace();
+    }
+
+    /**
+     * 实现服务器主动推送
+     *
+     * @param message message
+     * @throws IOException ex
+     */
+    public void sendMessage(String message) throws IOException {
+        // 加锁,否则会出现java.lang.IllegalStateException: The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method异常,并发使用session发送消息导致的
+        synchronized (this.session) {
+            this.session.getBasicRemote().sendText(message);
+        }
+    }
+
+    public ConcurrentHashMap<String, WebSocketServer> getWebSocketMap() {
+        return webSocketMap;
+    }
+}

+ 10 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/webSocket/service/IWebSocketService.java

@@ -0,0 +1,10 @@
+package com.pdaaphm.webSocket.service;
+
+/**
+ * @Description IWebSocketService
+ * @Author WGK
+ * @Date 2023/10/18 17:55
+ */
+public interface IWebSocketService {
+    void sendMessage(String taskId, String logMessage);
+}

+ 36 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/webSocket/service/impl/WebSocketServiceImpl.java

@@ -0,0 +1,36 @@
+package com.pdaaphm.webSocket.service.impl;
+
+import com.pdaaphm.webSocket.config.WebSocketServer;
+import com.pdaaphm.webSocket.service.IWebSocketService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @Description WebSocketServiceImpl
+ * @Author WGK
+ * @Date 2023/10/18 17:57
+ */
+@Slf4j
+@Service
+public class WebSocketServiceImpl implements IWebSocketService {
+    @Autowired
+    public WebSocketServer webSocketServer;
+
+    public void sendMessage(String taskId, String logMessage) {
+        try {
+            ConcurrentHashMap<String, WebSocketServer> map = webSocketServer.getWebSocketMap();
+            WebSocketServer server = map.get(taskId);
+            if (server != null) {
+                server.sendMessage(logMessage);
+            } else {
+                log.warn("客户端已退出");
+            }
+        } catch (IOException e) {
+            log.error("向客户端发送消息时出现异常,异常原因:{}", e.getMessage(), e);
+        }
+    }
+}

+ 44 - 65
pdaaphm-common/src/main/java/com/pdaaphm/common/core/redis/RedisCache.java

@@ -1,11 +1,5 @@
 package com.pdaaphm.common.core.redis;
 
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.BoundSetOperations;
 import org.springframework.data.redis.core.HashOperations;
@@ -13,64 +7,66 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.stereotype.Component;
 
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
 /**
  * spring redis 工具类
  *
  * @author Allen
  **/
-@SuppressWarnings(value = { "unchecked", "rawtypes" })
+@SuppressWarnings(value = {"unchecked", "rawtypes"})
 @Component
-public class RedisCache
-{
+public class RedisCache {
     @Autowired
     public RedisTemplate redisTemplate;
 
     /**
      * 缓存基本的对象,Integer、String、实体类等
      *
-     * @param key 缓存的键值
+     * @param key   缓存的键值
      * @param value 缓存的值
      */
-    public <T> void setCacheObject(final String key, final T value)
-    {
+    public <T> void setCacheObject(final String key, final T value) {
         redisTemplate.opsForValue().set(key, value);
     }
 
     /**
      * 缓存基本的对象,Integer、String、实体类等
      *
-     * @param key 缓存的键值
-     * @param value 缓存的值
-     * @param timeout 时间
+     * @param key      缓存的键值
+     * @param value    缓存的值
+     * @param timeout  时间
      * @param timeUnit 时间颗粒度
      */
-    public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)
-    {
+    public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) {
         redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
     }
 
     /**
      * 设置有效时间
      *
-     * @param key Redis键
+     * @param key     Redis键
      * @param timeout 超时时间
      * @return true=设置成功;false=设置失败
      */
-    public boolean expire(final String key, final long timeout)
-    {
+    public boolean expire(final String key, final long timeout) {
         return expire(key, timeout, TimeUnit.SECONDS);
     }
 
     /**
      * 设置有效时间
      *
-     * @param key Redis键
+     * @param key     Redis键
      * @param timeout 超时时间
-     * @param unit 时间单位
+     * @param unit    时间单位
      * @return true=设置成功;false=设置失败
      */
-    public boolean expire(final String key, final long timeout, final TimeUnit unit)
-    {
+    public boolean expire(final String key, final long timeout, final TimeUnit unit) {
         return redisTemplate.expire(key, timeout, unit);
     }
 
@@ -80,8 +76,7 @@ public class RedisCache
      * @param key Redis键
      * @return 有效时间
      */
-    public long getExpire(final String key)
-    {
+    public long getExpire(final String key) {
         return redisTemplate.getExpire(key);
     }
 
@@ -91,8 +86,7 @@ public class RedisCache
      * @param key 键
      * @return true 存在 false不存在
      */
-    public Boolean hasKey(String key)
-    {
+    public Boolean hasKey(String key) {
         return redisTemplate.hasKey(key);
     }
 
@@ -102,8 +96,7 @@ public class RedisCache
      * @param key 缓存键值
      * @return 缓存键值对应的数据
      */
-    public <T> T getCacheObject(final String key)
-    {
+    public <T> T getCacheObject(final String key) {
         ValueOperations<String, T> operation = redisTemplate.opsForValue();
         return operation.get(key);
     }
@@ -113,8 +106,7 @@ public class RedisCache
      *
      * @param key
      */
-    public boolean deleteObject(final String key)
-    {
+    public boolean deleteObject(final String key) {
         return redisTemplate.delete(key);
     }
 
@@ -124,20 +116,18 @@ public class RedisCache
      * @param collection 多个对象
      * @return
      */
-    public boolean deleteObject(final Collection collection)
-    {
+    public boolean deleteObject(final Collection collection) {
         return redisTemplate.delete(collection) > 0;
     }
 
     /**
      * 缓存List数据
      *
-     * @param key 缓存的键值
+     * @param key      缓存的键值
      * @param dataList 待缓存的List数据
      * @return 缓存的对象
      */
-    public <T> long setCacheList(final String key, final List<T> dataList)
-    {
+    public <T> long setCacheList(final String key, final List<T> dataList) {
         Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
         return count == null ? 0 : count;
     }
@@ -148,24 +138,21 @@ public class RedisCache
      * @param key 缓存的键值
      * @return 缓存键值对应的数据
      */
-    public <T> List<T> getCacheList(final String key)
-    {
+    public <T> List<T> getCacheList(final String key) {
         return redisTemplate.opsForList().range(key, 0, -1);
     }
 
     /**
      * 缓存Set
      *
-     * @param key 缓存键值
+     * @param key     缓存键值
      * @param dataSet 缓存的数据
      * @return 缓存数据的对象
      */
-    public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
-    {
+    public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) {
         BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
         Iterator<T> it = dataSet.iterator();
-        while (it.hasNext())
-        {
+        while (it.hasNext()) {
             setOperation.add(it.next());
         }
         return setOperation;
@@ -177,8 +164,7 @@ public class RedisCache
      * @param key
      * @return
      */
-    public <T> Set<T> getCacheSet(final String key)
-    {
+    public <T> Set<T> getCacheSet(final String key) {
         return redisTemplate.opsForSet().members(key);
     }
 
@@ -188,8 +174,7 @@ public class RedisCache
      * @param key
      * @param dataMap
      */
-    public <T> void setCacheMap(final String key, final Map<String, T> dataMap)
-    {
+    public <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
         if (dataMap != null) {
             redisTemplate.opsForHash().putAll(key, dataMap);
         }
@@ -201,32 +186,29 @@ public class RedisCache
      * @param key
      * @return
      */
-    public <T> Map<String, T> getCacheMap(final String key)
-    {
+    public <T> Map<String, T> getCacheMap(final String key) {
         return redisTemplate.opsForHash().entries(key);
     }
 
     /**
      * 往Hash中存入数据
      *
-     * @param key Redis键
-     * @param hKey Hash键
+     * @param key   Redis键
+     * @param hKey  Hash键
      * @param value 值
      */
-    public <T> void setCacheMapValue(final String key, final String hKey, final T value)
-    {
+    public <T> void setCacheMapValue(final String key, final String hKey, final T value) {
         redisTemplate.opsForHash().put(key, hKey, value);
     }
 
     /**
      * 获取Hash中的数据
      *
-     * @param key Redis键
+     * @param key  Redis键
      * @param hKey Hash键
      * @return Hash中的对象
      */
-    public <T> T getCacheMapValue(final String key, final String hKey)
-    {
+    public <T> T getCacheMapValue(final String key, final String hKey) {
         HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
         return opsForHash.get(key, hKey);
     }
@@ -234,24 +216,22 @@ public class RedisCache
     /**
      * 获取多个Hash中的数据
      *
-     * @param key Redis键
+     * @param key   Redis键
      * @param hKeys Hash键集合
      * @return Hash对象集合
      */
-    public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys)
-    {
+    public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
         return redisTemplate.opsForHash().multiGet(key, hKeys);
     }
 
     /**
      * 删除Hash中的某条数据
      *
-     * @param key Redis键
+     * @param key  Redis键
      * @param hKey Hash键
      * @return 是否成功
      */
-    public boolean deleteCacheMapValue(final String key, final String hKey)
-    {
+    public boolean deleteCacheMapValue(final String key, final String hKey) {
         return redisTemplate.opsForHash().delete(key, hKey) > 0;
     }
 
@@ -261,8 +241,7 @@ public class RedisCache
      * @param pattern 字符串前缀
      * @return 对象列表
      */
-    public Collection<String> keys(final String pattern)
-    {
+    public Collection<String> keys(final String pattern) {
         return redisTemplate.keys(pattern);
     }
 }