瀏覽代碼

修改代码规范2

xusl 3 年之前
父節點
當前提交
b622473b85
共有 16 個文件被更改,包括 1937 次插入2105 次删除
  1. 75 181
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/NwpService.java
  2. 9 13
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/OverHaulPlanService.java
  3. 68 69
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/PvModuleModelService.java
  4. 7 3
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/QuartzJobFactory.java
  5. 9 23
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/QuartzService.java
  6. 81 90
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/SysParameterService.java
  7. 5 8
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WeatherStationInfoService.java
  8. 33 35
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WeatherStationStatusDataService.java
  9. 5 8
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WindTowerInfoService.java
  10. 9 9
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WindTowerStatusDataService.java
  11. 107 108
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WindTurbineInfoService.java
  12. 11 12
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WindTurbineStatusDataService.java
  13. 2 1
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/util/Constant.java
  14. 3 1
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/util/CreateConsoleSh.java
  15. 0 67
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/util/GzipUtil.java
  16. 1513 1477
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/util/RedisUtils.java

+ 75 - 181
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/NwpService.java

@@ -5,14 +5,11 @@ import com.jiayue.ipfcst.common.core.util.CommonUtil;
 import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
 import com.jiayue.ipfcst.common.data.entity.ElectricField;
 import com.jiayue.ipfcst.common.data.entity.Nwp;
-import com.jiayue.ipfcst.common.data.entity.NwpHis;
 import com.jiayue.ipfcst.common.data.repository.NwpHisRepository;
 import com.jiayue.ipfcst.common.data.repository.NwpRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
-import com.sun.istack.internal.NotNull;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.time.DateFormatUtils;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
@@ -25,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.persistence.criteria.Predicate;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -62,141 +60,37 @@ public class NwpService extends BaseService {
     nwpRepository.saveAll(listNwp);
   }
 
-  /**
-   * 查询NWP数据,当查询结果不足时,需要本地化生成NWP数据并保存到数据库中,用于NWP数据上报时使用
-   *
-   * @param startTime 开始时间
-   * @param endTime   结束时间
-   * @return NWP数据结果集
-   */
-  @Transactional(propagation = Propagation.REQUIRED)
-  public List<Nwp> getNwpData(@NotNull final Long startTime, @NotNull final Long endTime) {
-    log.info("开始获取NWP数据" + DateFormatUtils.format(startTime, "yyyy-MM-dd HH:mm:ss") + " 至 " + DateFormatUtils.format(endTime, "yyyy-MM-dd HH:mm:ss"));
-    // 查询NWP数据
-    List<Nwp> nwpDataList = this.nwpRepository.findByPreTimeBetween(startTime, endTime);
-    nwpDataList.sort(Comparator.comparing(Nwp::getPreTime));// 按预测时间升序
-    log.info("查询现有NWP数据记录数:" + nwpDataList.size());
-    // 判断查询结果是否满足查询所需
-    Long momentTime = 15 * 60 * 1000L; // 15分钟一个时刻
-    Integer moments = Math.toIntExact((endTime - startTime) / momentTime + 1);
-    log.info("获取所需记录数:" + moments);
-    if (moments > nwpDataList.size()) {
-      // 如果查询结果少于所需预测数,则进行本地化计算,补齐预测记录
-      Map<Long, List<Nwp>> nwpDataMap = nwpDataList.stream().collect(Collectors.groupingBy(Nwp::getPreTime));
-      // 如果查询结果少于所需预测数,则进行本地化计算,补齐预测记录
-      List<Nwp> addNwpDataList = new ArrayList<>();
-      for (Long tempTime = startTime; tempTime <= endTime; tempTime = tempTime + momentTime) {
-        if (nwpDataMap.get(tempTime) == null) {
-          // 缺失时间点
-          List<Nwp> _nwpDataList = this.generateNwpData(tempTime);
-          addNwpDataList.addAll(_nwpDataList);
-        }
-      }
-
-      if (!addNwpDataList.isEmpty()) {
-        this.nwpRepository.saveAll(addNwpDataList);
-        // 将补齐的NWP数据追加到查询结果集中
-        nwpDataList.addAll(addNwpDataList);
-        // 进行告警
-        String errorInfo = "NWP数据不足";
-        log.error(errorInfo);
-        // 进行告警
-        String name = "NWP数据不足";
-        String describe = "";
-        String solution = "请检查NWP数据下载软件";
-        //super.saveSysAlarm(AlarmTypeEnum.E1, name, describe, errorInfo, solution);
-      }
-
-    }
-    // 处理NWP历史数据记录
-    List<NwpHis> nwpDataHiss = new ArrayList<>();
-    NwpHis nwpHis;
-    Long systemTime = new Date().getTime();
-
-    for (Nwp nwp : nwpDataList) {
-      nwpHis = new NwpHis();
-      BeanUtils.copyProperties(nwp, nwpHis);
-      // 设置提前几天预测
-      nwpHis.setForecastHowLongAgo(DateMomentUtil.getDaysBetweenTwoDate(systemTime, nwpHis.getPreTime()));
-      nwpDataHiss.add(nwpHis);
-    }
-    // 按预测时间升序
-    nwpDataHiss.sort(Comparator.comparing(NwpHis::getPreTime));
-    // 删除当日生成的短期历史记录
-    this.nwpHisRepository.deleteToday(startTime, endTime);
-    // 保存NWP历史记录
-    this.nwpHisRepository.saveAll(nwpDataHiss);
-    return nwpDataList;
-  }
-
-  /**
-   * 生成NWP数据,NWP数据为云下载数据,这里不进行覆盖更新,只针对NWP数据不足时补充
-   *
-   * @param startTime 开始时间
-   * @param endTime   结束时间
-   */
-  @Transactional(propagation = Propagation.REQUIRED)
-  public void buildNwpData(@NotNull final Long startTime, @NotNull final Long endTime) {
-    this.getNwpData(startTime, endTime);
-  }
-
-  /**
-   * 生成NWP数据
-   *
-   * @return nwp数据集
-   */
-  @Transactional(propagation = Propagation.REQUIRED)
-  private List<Nwp> generateNwpData(@NotNull final Long tempTime) {
-
-    List<Nwp> nwpDataList;
-
-    // 使用历史NWP数据生成NWP数据
-    List<Nwp> result = new ArrayList<>();
-    // 查询前一天同时刻NWP数据
-    nwpDataList = this.nwpRepository.findByPreTimeBetween(tempTime - 24 * 60 * 60 * 1000L, tempTime - 24 * 50 * 60 * 1000L);
-    if (nwpDataList.size() > 0) {
-      Nwp nwp = new Nwp();
-      BeanUtils.copyProperties(nwpDataList.get(0), nwp, "id");
-      nwp.setPreTime(tempTime);
-      nwp.setPreDate(DateFormatUtils.format(tempTime, "yyyy-MM-dd"));
-      result.add(nwp);
-    } else {// 如果未查询到前一天数据,则随机生成NWP数据
-      result.add(this.createNwpData(tempTime));
-    }
-    return result;
-  }
-
   private Nwp createNwpData(Long preTime) {
-    Long systemTime = System.currentTimeMillis();
+    long systemTime = System.currentTimeMillis();
     Nwp nwpData = new Nwp();
     nwpData.setFarmId("1");
     nwpData.setScDate(DateFormatUtils.format(systemTime, "yyyy-MM-dd"));
     nwpData.setScTime(DateFormatUtils.format(systemTime, "HH:mm:ss"));
     nwpData.setPreTime(preTime);
     nwpData.setPreDate(DateFormatUtils.format(preTime, "yyyy-MM-dd"));
-    nwpData.setPressure(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setT(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setRh(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setSenf(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setSwr(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setLwr(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-
-    nwpData.setWd10(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd30(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd50(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd70(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd80(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd90(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd100(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd170(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs10(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs30(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs50(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs70(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs80(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs90(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs100(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs170(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
+    nwpData.setPressure(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setT(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setRh(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setSenf(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setSwr(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setLwr(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+
+    nwpData.setWd10(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd30(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd50(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd70(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd80(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd90(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd100(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd170(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs10(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs30(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs50(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs70(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs80(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs90(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs100(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs170(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
     return nwpData;
   }
 
@@ -401,7 +295,7 @@ public class NwpService extends BaseService {
     Specification<Nwp> specification = specificationFindByTimeAndNo(startTime, endTime, stationCode);
     Pageable pageable = PageRequest.of(page - 1, size, sort);
     Page nwps = nwpRepository.findAll(specification, pageable);
-    List<Nwp> datas = new ArrayList<>();
+    List<Nwp> datas;
     datas = nwps.getContent();
     this.defaultReplace(datas);
     map.put("content", datas);
@@ -464,31 +358,31 @@ public class NwpService extends BaseService {
       BigDecimal wd90 = new BigDecimal(0);
       BigDecimal wd100 = new BigDecimal(0);
       BigDecimal wd170 = new BigDecimal(0);
-      for (int j = 0; j < nwpList.size(); j++) {
-        t = t.add(nwpList.get(j).getT() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getT());
-        rh = rh.add(nwpList.get(j).getRh() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getRh());
-        pressure = pressure.add(nwpList.get(j).getPressure() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getPressure());
-        swr = swr.add(nwpList.get(j).getSwr() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getSwr());
-        lwr = lwr.add(nwpList.get(j).getLwr() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getLwr());
-        directRadiation = directRadiation.add(nwpList.get(j).getDirectRadiation() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getDirectRadiation());
-        diffuseRadiation = diffuseRadiation.add(nwpList.get(j).getDiffuseRadiation() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getDiffuseRadiation());
-        senf = senf.add(nwpList.get(j).getSenf() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getSenf());
-        ws10 = ws10.add(nwpList.get(j).getWs10() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs10());
-        ws30 = ws30.add(nwpList.get(j).getWs30() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs30());
-        ws50 = ws50.add(nwpList.get(j).getWs50() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs50());
-        ws70 = ws70.add(nwpList.get(j).getWs70() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs70());
-        ws80 = ws80.add(nwpList.get(j).getWs80() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs80());
-        ws90 = ws90.add(nwpList.get(j).getWs90() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs90());
-        ws100 = ws100.add(nwpList.get(j).getWs100() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs100());
-        ws170 = ws170.add(nwpList.get(j).getWs170() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs170());
-        wd10 = wd10.add(nwpList.get(j).getWd10() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd10());
-        wd30 = wd30.add(nwpList.get(j).getWd30() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd30());
-        wd50 = wd50.add(nwpList.get(j).getWd50() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd50());
-        wd70 = wd70.add(nwpList.get(j).getWd70() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd70());
-        wd80 = wd80.add(nwpList.get(j).getWd80() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd80());
-        wd90 = wd90.add(nwpList.get(j).getWd90() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd90());
-        wd100 = wd100.add(nwpList.get(j).getWd100() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd100());
-        wd170 = wd170.add(nwpList.get(j).getWd170() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd170());
+      for (Nwp value : nwpList) {
+        t = t.add(value.getT() == null ? BigDecimal.valueOf(0) : value.getT());
+        rh = rh.add(value.getRh() == null ? BigDecimal.valueOf(0) : value.getRh());
+        pressure = pressure.add(value.getPressure() == null ? BigDecimal.valueOf(0) : value.getPressure());
+        swr = swr.add(value.getSwr() == null ? BigDecimal.valueOf(0) : value.getSwr());
+        lwr = lwr.add(value.getLwr() == null ? BigDecimal.valueOf(0) : value.getLwr());
+        directRadiation = directRadiation.add(value.getDirectRadiation() == null ? BigDecimal.valueOf(0) : value.getDirectRadiation());
+        diffuseRadiation = diffuseRadiation.add(value.getDiffuseRadiation() == null ? BigDecimal.valueOf(0) : value.getDiffuseRadiation());
+        senf = senf.add(value.getSenf() == null ? BigDecimal.valueOf(0) : value.getSenf());
+        ws10 = ws10.add(value.getWs10() == null ? BigDecimal.valueOf(0) : value.getWs10());
+        ws30 = ws30.add(value.getWs30() == null ? BigDecimal.valueOf(0) : value.getWs30());
+        ws50 = ws50.add(value.getWs50() == null ? BigDecimal.valueOf(0) : value.getWs50());
+        ws70 = ws70.add(value.getWs70() == null ? BigDecimal.valueOf(0) : value.getWs70());
+        ws80 = ws80.add(value.getWs80() == null ? BigDecimal.valueOf(0) : value.getWs80());
+        ws90 = ws90.add(value.getWs90() == null ? BigDecimal.valueOf(0) : value.getWs90());
+        ws100 = ws100.add(value.getWs100() == null ? BigDecimal.valueOf(0) : value.getWs100());
+        ws170 = ws170.add(value.getWs170() == null ? BigDecimal.valueOf(0) : value.getWs170());
+        wd10 = wd10.add(value.getWd10() == null ? BigDecimal.valueOf(0) : value.getWd10());
+        wd30 = wd30.add(value.getWd30() == null ? BigDecimal.valueOf(0) : value.getWd30());
+        wd50 = wd50.add(value.getWd50() == null ? BigDecimal.valueOf(0) : value.getWd50());
+        wd70 = wd70.add(value.getWd70() == null ? BigDecimal.valueOf(0) : value.getWd70());
+        wd80 = wd80.add(value.getWd80() == null ? BigDecimal.valueOf(0) : value.getWd80());
+        wd90 = wd90.add(value.getWd90() == null ? BigDecimal.valueOf(0) : value.getWd90());
+        wd100 = wd100.add(value.getWd100() == null ? BigDecimal.valueOf(0) : value.getWd100());
+        wd170 = wd170.add(value.getWd170() == null ? BigDecimal.valueOf(0) : value.getWd170());
       }
       if (nwpList.size() > 0) {
         nwp.setScTime(nwpList.get(0).getScTime());
@@ -496,30 +390,30 @@ public class NwpService extends BaseService {
         nwp.setPreTime(nwpList.get(0).getPreTime());
         nwp.setPreDate(nwpList.get(0).getPreDate());
         nwp.setFarmId(nwpList.get(0).getFarmId());
-        nwp.setT(t.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : t.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setRh(rh.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : rh.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setPressure(pressure.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : pressure.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setSwr(swr.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : swr.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setLwr(lwr.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : lwr.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setDirectRadiation(directRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : directRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setDiffuseRadiation(diffuseRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : diffuseRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setSenf(senf.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : senf.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs10(ws10.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws10.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs30(ws30.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws30.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs50(ws50.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws50.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs70(ws70.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws70.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs80(ws80.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws80.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs90(ws90.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws90.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs100(ws100.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws100.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs170(ws170.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws170.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd10(wd10.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd10.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd30(wd30.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd30.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd50(wd50.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd50.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd70(wd70.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd70.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd80(wd80.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd80.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd90(wd90.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd90.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd100(wd100.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd100.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd170(wd170.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd170.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
+        nwp.setT(t.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : t.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setRh(rh.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : rh.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setPressure(pressure.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : pressure.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setSwr(swr.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : swr.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setLwr(lwr.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : lwr.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setDirectRadiation(directRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : directRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setDiffuseRadiation(diffuseRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : diffuseRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setSenf(senf.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : senf.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs10(ws10.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws10.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs30(ws30.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws30.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs50(ws50.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws50.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs70(ws70.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws70.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs80(ws80.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws80.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs90(ws90.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws90.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs100(ws100.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws100.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs170(ws170.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws170.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd10(wd10.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd10.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd30(wd30.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd30.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd50(wd50.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd50.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd70(wd70.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd70.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd80(wd80.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd80.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd90(wd90.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd90.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd100(wd100.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd100.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd170(wd170.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd170.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
         dataList.add(nwp);
       }
     }

+ 9 - 13
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/OverHaulPlanService.java

@@ -2,7 +2,6 @@ package com.jiayue.ipfcst.console.service;
 
 import com.jiayue.ipfcst.common.core.exception.BusinessException;
 import com.jiayue.ipfcst.common.data.entity.OverhaulPlan;
-import com.jiayue.ipfcst.common.data.repository.ElectricFieldRepository;
 import com.jiayue.ipfcst.common.data.repository.OverhaulPlanRepository;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,12 +27,9 @@ import java.util.List;
 public class OverHaulPlanService {
   private final OverhaulPlanRepository overhaulPlanRepository;
 
-  private final ElectricFieldRepository electricFieldRepository;
-
   @Autowired
-  public OverHaulPlanService(OverhaulPlanRepository overhaulPlanRepository, ElectricFieldRepository electricFieldRepository) {
+  public OverHaulPlanService(OverhaulPlanRepository overhaulPlanRepository) {
     this.overhaulPlanRepository = overhaulPlanRepository;
-    this.electricFieldRepository = electricFieldRepository;
   }
 
   /**
@@ -104,14 +100,14 @@ public class OverHaulPlanService {
   }
 
 
-  public BigDecimal getOverhaulCapacityByStationCode(String stationCode){
-      BigDecimal overhaulCapacity = new BigDecimal(0);
-      long time = System.currentTimeMillis();
-      List<OverhaulPlan> overhaulPlans = overhaulPlanRepository.findByStartTimeLessThanAndEndTimeGreaterThanAndStatusAndStationCode(time, time, 1,stationCode);
-      if(overhaulPlans.size()>0){
-        overhaulCapacity = overhaulPlans.get(0).getOverhaulCapactity();
-      }
-      return overhaulCapacity;
+  public BigDecimal getOverhaulCapacityByStationCode(String stationCode) {
+    BigDecimal overhaulCapacity = new BigDecimal(0);
+    long time = System.currentTimeMillis();
+    List<OverhaulPlan> overhaulPlans = overhaulPlanRepository.findByStartTimeLessThanAndEndTimeGreaterThanAndStatusAndStationCode(time, time, 1, stationCode);
+    if (overhaulPlans.size() > 0) {
+      overhaulCapacity = overhaulPlans.get(0).getOverhaulCapactity();
+    }
+    return overhaulCapacity;
   }
 
   /**

+ 68 - 69
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/PvModuleModelService.java

@@ -1,6 +1,5 @@
 package com.jiayue.ipfcst.console.service;
 
-import com.jiayue.ipfcst.common.data.entity.InverterInfo;
 import com.jiayue.ipfcst.common.data.entity.PvModuleModel;
 import com.jiayue.ipfcst.common.data.repository.PvModuleModelRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
@@ -28,73 +27,73 @@ import java.util.Map;
 @Slf4j
 public class PvModuleModelService extends BaseService {
 
-    private final PvModuleModelRepository pvModuleModelRepository;
+  private final PvModuleModelRepository pvModuleModelRepository;
 
-    @Autowired
-    public PvModuleModelService(PvModuleModelRepository pvModuleModelRepository) {
-        this.pvModuleModelRepository = pvModuleModelRepository;
-    }
+  @Autowired
+  public PvModuleModelService(PvModuleModelRepository pvModuleModelRepository) {
+    this.pvModuleModelRepository = pvModuleModelRepository;
+  }
 
-    /**
-     * 获取所有光伏组件信息
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public List<PvModuleModel> getAll() {
-        return this.pvModuleModelRepository.findAll();
-    }
+  /**
+   * 获取所有光伏组件信息
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public List<PvModuleModel> getAll() {
+    return this.pvModuleModelRepository.findAll();
+  }
 
-    /**
-     * 保存光伏组件信息
-     *
-     * @param pvModuleModel 光伏组件信息
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void save(PvModuleModel pvModuleModel) {
-        this.pvModuleModelRepository.save(pvModuleModel);
-    }
+  /**
+   * 保存光伏组件信息
+   *
+   * @param pvModuleModel 光伏组件信息
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void save(PvModuleModel pvModuleModel) {
+    this.pvModuleModelRepository.save(pvModuleModel);
+  }
 
-    /**
-     * 删除场站信息
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public boolean delete(String ids) {
-        boolean flag = false;
-        if (!StringUtils.isEmpty(ids)) {
-            String[] idArray = ids.split(",");
-            if (idArray != null && idArray.length > 0) {
-                for (String id : idArray) {
-                    this.pvModuleModelRepository.deleteById(Integer.valueOf(id));
-                    log.info("删除光伏组件ID为[" + id + "]成功!");
+  /**
+   * 删除场站信息
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public boolean delete(String ids) {
+    boolean flag = false;
+    if (!StringUtils.isEmpty(ids)) {
+      String[] idArray = ids.split(",");
+      if (idArray != null && idArray.length > 0) {
+        for (String id : idArray) {
+          this.pvModuleModelRepository.deleteById(Integer.valueOf(id));
+          log.info("删除光伏组件ID为[" + id + "]成功!");
 
-                }
-                flag = true;
-            } else {
-                this.pvModuleModelRepository.deleteById(Integer.valueOf(ids));
-                flag = true;
-                log.info("删除光伏组件ID为[" + ids + "]成功!");
-            }
         }
+        flag = true;
+      } else {
+        this.pvModuleModelRepository.deleteById(Integer.valueOf(ids));
+        flag = true;
+        log.info("删除光伏组件ID为[" + ids + "]成功!");
+      }
+    }
 
-        return flag;
+    return flag;
 
-    }
+  }
 
-    /**
-     * 查询场站信息
-     *
-     * @return 场站信息
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public Map<String, Object> get(@RequestParam(defaultValue = "1") Integer page,
-                                   @RequestParam(defaultValue = "10") Integer size) {
-        Map<String, Object> map = new HashMap<>();
-        Sort sort = Sort.by(Sort.Direction.ASC, "id");
-        Pageable pageable = PageRequest.of(page - 1, size, sort); //页码:前端从1开始,jpa从0开始,做个转换
-        Page pagepvModuleModel = pvModuleModelRepository.findAll(pageable);
-        map.put("content", pagepvModuleModel.getContent());// 结果集
-        map.put("count", pagepvModuleModel.getTotalElements());// 总记录数
-        return map;
-    }
+  /**
+   * 查询场站信息
+   *
+   * @return 场站信息
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public Map<String, Object> get(@RequestParam(defaultValue = "1") Integer page,
+                                 @RequestParam(defaultValue = "10") Integer size) {
+    Map<String, Object> map = new HashMap<>();
+    Sort sort = Sort.by(Sort.Direction.ASC, "id");
+    Pageable pageable = PageRequest.of(page - 1, size, sort); //页码:前端从1开始,jpa从0开始,做个转换
+    Page pagepvModuleModel = pvModuleModelRepository.findAll(pageable);
+    map.put("content", pagepvModuleModel.getContent());// 结果集
+    map.put("count", pagepvModuleModel.getTotalElements());// 总记录数
+    return map;
+  }
 
   /**
    * 查询逆变器【分页查询】
@@ -112,20 +111,20 @@ public class PvModuleModelService extends BaseService {
     return this.pvModuleModelRepository.findAll(example, pageable);
   }
 
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void saveCloud(PvModuleModel bean) {
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(PvModuleModel bean) {
 //        PvModuleModel beanOld = pvModuleModelRepository.findByModel(bean.getModel());
 //        if (null != beanOld) {
 //            bean.setId(beanOld.getId());
 //        }
-        pvModuleModelRepository.save(bean);
-    }
+    pvModuleModelRepository.save(bean);
+  }
 
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void saveCloud(List<PvModuleModel> beans) {
-        if(beans != null && beans.size() > 0){
-            pvModuleModelRepository.deleteAll();
-            pvModuleModelRepository.saveAll(beans);
-        }
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(List<PvModuleModel> beans) {
+    if (beans != null && beans.size() > 0) {
+      pvModuleModelRepository.deleteAll();
+      pvModuleModelRepository.saveAll(beans);
     }
+  }
 }

+ 7 - 3
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/QuartzJobFactory.java

@@ -13,18 +13,22 @@ import org.springframework.stereotype.Service;
  * @version 2.0
  * @since 2018/10/11 11:24
  */
-@Service public class QuartzJobFactory extends SpringBeanJobFactory {
+@Service
+public class QuartzJobFactory extends SpringBeanJobFactory {
 
   private final AutowireCapableBeanFactory beanFactory;
 
-  @Autowired public QuartzJobFactory(AutowireCapableBeanFactory beanFactory) {
+  @Autowired
+  public QuartzJobFactory(AutowireCapableBeanFactory beanFactory) {
     this.beanFactory = beanFactory;
   }
 
   /**
    * 这里覆盖了super的createJobInstance方法,对其创建出来的类再进行autowire。
    */
-  @Override protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
+  @SuppressWarnings("NullableProblems")
+  @Override
+  protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
 
     Object jobInstance = super.createJobInstance(bundle);
 

+ 9 - 23
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/QuartzService.java

@@ -39,6 +39,14 @@ import java.util.Map;
 public class QuartzService extends BaseService {
 
   private final QuartzRepository quartzRepository;
+  @Value("${spring.datasource.druid.username}")
+  private String username;
+  @Value("${spring.datasource.druid.password}")
+  private String password;
+  @Value("${spring.datasource.druid.driver-class-name}")
+  private String driverClassName;
+  @Value("${spring.datasource.druid.url}")
+  private String url;
 
   @Autowired
   public QuartzService(QuartzRepository quartzRepository) {
@@ -48,17 +56,6 @@ public class QuartzService extends BaseService {
   }
 
   /**
-   * 根据任务名查询
-   *
-   * @param jobName 任务名
-   * @return Quartz
-   */
-  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public Quartz findByName(String jobName) {
-    return quartzRepository.findByJobName(jobName);
-  }
-
-  /**
    * 根据执行类查询
    *
    * @param executeClass 执行类
@@ -75,6 +72,7 @@ public class QuartzService extends BaseService {
    *
    * @param qt 任务实体
    */
+  @SuppressWarnings({"finally", "ReturnInsideFinallyBlock"})
   @Transactional(propagation = Propagation.REQUIRED)
   public boolean save(Quartz qt) {
     boolean flag = false;
@@ -213,18 +211,6 @@ public class QuartzService extends BaseService {
     }
   }
 
-  @Value("${spring.datasource.druid.username}")
-  private String username;
-
-  @Value("${spring.datasource.druid.password}")
-  private String password;
-
-  @Value("${spring.datasource.druid.driver-class-name}")
-  private String driverClassName;
-
-  @Value("${spring.datasource.druid.url}")
-  private String url;
-
   /**
    * 定时任务恢复初始化
    */

+ 81 - 90
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/SysParameterService.java

@@ -6,12 +6,6 @@ import com.jiayue.ipfcst.common.data.entity.SysParameter;
 import com.jiayue.ipfcst.common.data.repository.SysParameterRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
 import lombok.extern.slf4j.Slf4j;
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.Element;
-import net.sf.ehcache.search.Attribute;
-import net.sf.ehcache.search.Query;
-import net.sf.ehcache.search.Result;
-import net.sf.ehcache.search.Results;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.ehcache.EhCacheCacheManager;
 import org.springframework.data.domain.*;
@@ -19,7 +13,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
 
@@ -34,88 +27,85 @@ import java.util.Optional;
 @Slf4j
 public class SysParameterService extends BaseService {
 
-    private final SysParameterRepository sysParameterRepository;
+  private final SysParameterRepository sysParameterRepository;
 
-    private final EhCacheCacheManager ehCacheCacheManager;
-
-    @Autowired
-    public SysParameterService(SysParameterRepository sysParameterRepository, EhCacheCacheManager ehCacheCacheManager) {
-        this.sysParameterRepository = sysParameterRepository;
-        this.ehCacheCacheManager = ehCacheCacheManager;
-    }
+  @Autowired
+  public SysParameterService(SysParameterRepository sysParameterRepository, EhCacheCacheManager ehCacheCacheManager) {
+    this.sysParameterRepository = sysParameterRepository;
+  }
 
-    /**
-     * 新增系统参数
-     *
-     * @param sysParameter 系统参数实体
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void add(SysParameter sysParameter) throws BusinessException {
-        boolean b = this.sysParameterRepository.existsBySysKeyAndStationCode(sysParameter.getSysKey(),sysParameter.getStationCode());
-        if (b) {// 参数已存在
-            throw new BusinessException("系统参数已存在!");
-        } else {
-            this.sysParameterRepository.save(sysParameter);
-        }
+  /**
+   * 新增系统参数
+   *
+   * @param sysParameter 系统参数实体
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void add(SysParameter sysParameter) throws BusinessException {
+    boolean b = this.sysParameterRepository.existsBySysKeyAndStationCode(sysParameter.getSysKey(), sysParameter.getStationCode());
+    if (b) {// 参数已存在
+      throw new BusinessException("系统参数已存在!");
+    } else {
+      this.sysParameterRepository.save(sysParameter);
     }
+  }
 
-    /**
-     * 修改系统参数
-     *
-     * @param sysParameter 系统参数实体
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void update(SysParameter sysParameter) throws BusinessException {
-        if (StrUtil.isEmpty(sysParameter.getSysKey())) {
-            throw new BusinessException("系统参数标识不能为空!");
-        } else {
-            this.sysParameterRepository.save(sysParameter);
-        }
+  /**
+   * 修改系统参数
+   *
+   * @param sysParameter 系统参数实体
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void update(SysParameter sysParameter) throws BusinessException {
+    if (StrUtil.isEmpty(sysParameter.getSysKey())) {
+      throw new BusinessException("系统参数标识不能为空!");
+    } else {
+      this.sysParameterRepository.save(sysParameter);
     }
+  }
 
-    /**
-     * 删除系统参数
-     *
-     * @param id 主键编号
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(rollbackFor = Exception.class, propagation = Propagation.SUPPORTS)
-    public void delete(final Integer id) throws BusinessException {
-        this.sysParameterRepository.deleteById(id);
-    }
+  /**
+   * 删除系统参数
+   *
+   * @param id 主键编号
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(rollbackFor = Exception.class, propagation = Propagation.SUPPORTS)
+  public void delete(final Integer id) throws BusinessException {
+    this.sysParameterRepository.deleteById(id);
+  }
 
-    /**
-     * 查询参数
-     *
-     * @param sysParameter 查询条件
-     * @param page         页码
-     * @param size         每页记录数
-     * @return 分页结果
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public Page<SysParameter> get(final SysParameter sysParameter, final Integer page, final Integer size) {
-        ExampleMatcher matcher = ExampleMatcher.matching()
-                .withMatcher("sysKey", ExampleMatcher.GenericPropertyMatchers.contains())
-                .withMatcher("sysValue", ExampleMatcher.GenericPropertyMatchers.contains())
-                .withMatcher("describe", ExampleMatcher.GenericPropertyMatchers.contains());
-        Example<SysParameter> example = Example.of(sysParameter, matcher);
-        Pageable pageable = PageRequest.of(page - 1, size);
-        return this.sysParameterRepository.findAll(example, pageable);
-    }
+  /**
+   * 查询参数
+   *
+   * @param sysParameter 查询条件
+   * @param page         页码
+   * @param size         每页记录数
+   * @return 分页结果
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public Page<SysParameter> get(final SysParameter sysParameter, final Integer page, final Integer size) {
+    ExampleMatcher matcher = ExampleMatcher.matching()
+      .withMatcher("sysKey", ExampleMatcher.GenericPropertyMatchers.contains())
+      .withMatcher("sysValue", ExampleMatcher.GenericPropertyMatchers.contains())
+      .withMatcher("describe", ExampleMatcher.GenericPropertyMatchers.contains());
+    Example<SysParameter> example = Example.of(sysParameter, matcher);
+    Pageable pageable = PageRequest.of(page - 1, size);
+    return this.sysParameterRepository.findAll(example, pageable);
+  }
 
-    /**
-     * 查询参数值
-     *
-     * @param id 主键编号
-     * @return 参数
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public String getParameter(final Integer id) {
-        Optional<SysParameter> sysParameterOptional = this.sysParameterRepository.findById(id);
-        return sysParameterOptional.map(SysParameter::getSysValue).orElse(null);
-    }
+  /**
+   * 查询参数值
+   *
+   * @param id 主键编号
+   * @return 参数
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public String getParameter(final Integer id) {
+    Optional<SysParameter> sysParameterOptional = this.sysParameterRepository.findById(id);
+    return sysParameterOptional.map(SysParameter::getSysValue).orElse(null);
+  }
 
   /**
    * 根据描述查询告警信息
@@ -131,16 +121,17 @@ public class SysParameterService extends BaseService {
     Pageable pageable = PageRequest.of(page - 1, size);
     return this.sysParameterRepository.findAll(example, pageable);
   }
-    /**
-     * 查询所有参数信息
-     *
-     * @return 通道信息
-     */
-    public List<SysParameter> getAll() {
-      return  sysParameterRepository.findAll();
-    }
+
+  /**
+   * 查询所有参数信息
+   *
+   * @return 通道信息
+   */
+  public List<SysParameter> getAll() {
+    return sysParameterRepository.findAll();
+  }
 
   public List<SysParameter> getAllByStationCode(String stationCode) {
-    return  sysParameterRepository.findAllByStationCode(stationCode);
+    return sysParameterRepository.findAllByStationCode(stationCode);
   }
 }

+ 5 - 8
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WeatherStationInfoService.java

@@ -1,19 +1,16 @@
 package com.jiayue.ipfcst.console.service;
 
 import com.jiayue.ipfcst.common.core.exception.BusinessException;
-import com.jiayue.ipfcst.common.data.entity.InverterInfo;
 import com.jiayue.ipfcst.common.data.entity.WeatherStationInfo;
 import com.jiayue.ipfcst.common.data.repository.WeatherStationInfoRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.*;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Optional;
@@ -104,10 +101,10 @@ public class WeatherStationInfoService extends BaseService {
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
   public List<WeatherStationInfo> get(String stationCode) {
-    List<WeatherStationInfo> resultList = new ArrayList<>();
-    resultList =  this.weatherStationInfoRepository.findAll();
-    if (!"ALL".equals(stationCode)){
-      resultList = resultList.stream().filter(s->s.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    List<WeatherStationInfo> resultList;
+    resultList = this.weatherStationInfoRepository.findAll();
+    if (!"ALL".equals(stationCode)) {
+      resultList = resultList.stream().filter(s -> s.getStationCode().equals(stationCode)).collect(Collectors.toList());
     }
     return resultList.stream().sorted(Comparator.comparing(WeatherStationInfo::getStationCode)).collect(Collectors.toList());
   }
@@ -134,7 +131,7 @@ public class WeatherStationInfoService extends BaseService {
 
   @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
   public void saveCloud(List<WeatherStationInfo> beans) {
-    if(beans != null && beans.size() > 0){
+    if (beans != null && beans.size() > 0) {
       weatherStationInfoRepository.deleteAll();
       weatherStationInfoRepository.saveAll(beans);
     }

+ 33 - 35
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WeatherStationStatusDataService.java

@@ -1,10 +1,8 @@
 package com.jiayue.ipfcst.console.service;
 
-import com.jiayue.ipfcst.common.data.entity.InverterStatusData;
 import com.jiayue.ipfcst.common.data.entity.WeatherStationStatusData;
 import com.jiayue.ipfcst.common.data.repository.WeatherStationStatusDataRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
-import org.apache.commons.lang.time.DateFormatUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
@@ -17,9 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.persistence.criteria.Predicate;
 import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * 环境监测仪数据业务层
@@ -31,12 +27,12 @@ import java.util.stream.Collectors;
 @Service
 public class WeatherStationStatusDataService extends BaseService {
 
-    private final WeatherStationStatusDataRepository weatherStationStatusDataRepository;
+  private final WeatherStationStatusDataRepository weatherStationStatusDataRepository;
 
-    @Autowired
-    public WeatherStationStatusDataService(WeatherStationStatusDataRepository weatherStationStatusDataRepository){
-       this.weatherStationStatusDataRepository = weatherStationStatusDataRepository;
-    }
+  @Autowired
+  public WeatherStationStatusDataService(WeatherStationStatusDataRepository weatherStationStatusDataRepository) {
+    this.weatherStationStatusDataRepository = weatherStationStatusDataRepository;
+  }
 
   /**
    * 分页查询 环境监测仪数据 tl
@@ -47,93 +43,95 @@ public class WeatherStationStatusDataService extends BaseService {
    * @return
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public Map<String, Object> findByTimeBetweenAndNoAndTimeStep(String stationCode,Date startTime, Date endTime,
-                                               Integer page,Integer size,String no) {
+  public Map<String, Object> findByTimeBetweenAndNoAndTimeStep(String stationCode, Date startTime, Date endTime,
+                                                               Integer page, Integer size, String no) {
 
     Map<String, Object> map = new HashMap<>();
     Sort sort = Sort.by(Sort.Direction.DESC, "time");
-    Specification<WeatherStationStatusData> specification = this.specificationFindByTime(stationCode,startTime, endTime,no);
+    Specification<WeatherStationStatusData> specification = this.specificationFindByTime(stationCode, startTime, endTime, no);
     Pageable pageable = PageRequest.of(page - 1, size, sort); //页码:前端从1开始,jpa从0开始,做个转换
     Page inverterStatusDatas = weatherStationStatusDataRepository.findAll(specification, pageable);
-    List<WeatherStationStatusData> datas = new ArrayList<>();
+    List<WeatherStationStatusData> datas;
     datas = inverterStatusDatas.getContent();
     this.defaultReplace(datas);
     map.put("content", datas);// 结果集
     map.put("count", inverterStatusDatas.getTotalElements());// 总记录数
     return map;
   }
+
   /**
-   *  对集合进行 -99替换null操作
+   * 对集合进行 -99替换null操作
    *
-   * @param datas  需要替换集合
+   * @param datas 需要替换集合
    */
-  public void defaultReplace(List<WeatherStationStatusData> datas){
-    BigDecimal nullBig =  new BigDecimal(-99);
-    for(WeatherStationStatusData w:datas){
+  public void defaultReplace(List<WeatherStationStatusData> datas) {
+    BigDecimal nullBig = new BigDecimal(-99);
+    for (WeatherStationStatusData w : datas) {
 
-      if(w.getDirectR().compareTo(nullBig)==0){
+      if (w.getDirectR().compareTo(nullBig) == 0) {
         w.setDirectR(null);
       }
 
-      if(w.getGlobalR().compareTo(nullBig)==0){
+      if (w.getGlobalR().compareTo(nullBig) == 0) {
         w.setGlobalR(null);
       }
 
-      if(w.getDiffuseR().compareTo(nullBig)==0){
+      if (w.getDiffuseR().compareTo(nullBig) == 0) {
         w.setDiffuseR(null);
       }
 
-      if(w.getObliqueR().compareTo(nullBig)==0){
+      if (w.getObliqueR().compareTo(nullBig) == 0) {
         w.setObliqueR(null);
       }
 
-      if(w.getAirT().compareTo(nullBig)==0){
+      if (w.getAirT().compareTo(nullBig) == 0) {
         w.setAirT(null);
       }
 
-      if(w.getP().compareTo(nullBig)==0){
+      if (w.getP().compareTo(nullBig) == 0) {
         w.setP(null);
       }
 
-      if(w.getRh().compareTo(nullBig)==0){
+      if (w.getRh().compareTo(nullBig) == 0) {
         w.setRh(null);
       }
 
-      if(w.getCellT().compareTo(nullBig)==0){
+      if (w.getCellT().compareTo(nullBig) == 0) {
         w.setCellT(null);
       }
 
-      if(w.getWs().compareTo(nullBig)==0){
+      if (w.getWs().compareTo(nullBig) == 0) {
         w.setWs(null);
       }
 
-      if(w.getWd().compareTo(nullBig)==0){
+      if (w.getWd().compareTo(nullBig) == 0) {
         w.setWd(null);
       }
 
-      if(w.getHourDA().compareTo(nullBig)==0){
+      if (w.getHourDA().compareTo(nullBig) == 0) {
         w.setHourDA(null);
       }
 
-      if(w.getGlobalRDA().compareTo(nullBig)==0){
+      if (w.getGlobalRDA().compareTo(nullBig) == 0) {
         w.setGlobalRDA(null);
       }
 
-      if(w.getDirectRDA().compareTo(nullBig)==0){
+      if (w.getDirectRDA().compareTo(nullBig) == 0) {
         w.setDirectRDA(null);
       }
 
-      if(w.getDiffuseRDA().compareTo(nullBig)==0){
+      if (w.getDiffuseRDA().compareTo(nullBig) == 0) {
         w.setDiffuseRDA(null);
       }
 
-      if(w.getObliqueRDA().compareTo(nullBig)==0){
+      if (w.getObliqueRDA().compareTo(nullBig) == 0) {
         w.setObliqueRDA(null);
       }
 
     }
 
   }
+
   /**
    * 根据时间 分页查询条件 yh
    *
@@ -141,11 +139,11 @@ public class WeatherStationStatusDataService extends BaseService {
    * @param endTime   结束时间
    * @return 过滤条件
    */
-  Specification<WeatherStationStatusData> specificationFindByTime(final String stationCode, final Date startTime, final Date endTime,final String no) {
+  Specification<WeatherStationStatusData> specificationFindByTime(final String stationCode, final Date startTime, final Date endTime, final String no) {
     return (Specification<WeatherStationStatusData>) (root, criteriaQuery, cb) -> {
       List<Predicate> predicates = new ArrayList<>();
       predicates.add(cb.equal(root.get("stationCode").as(String.class), stationCode));
-      if (!"ALL".equals(no)){
+      if (!"ALL".equals(no)) {
         predicates.add(cb.equal(root.get("equipmentId").as(String.class), no));
       }
       if (startTime != null) {

+ 5 - 8
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WindTowerInfoService.java

@@ -1,9 +1,7 @@
 package com.jiayue.ipfcst.console.service;
 
 import com.jiayue.ipfcst.common.core.exception.BusinessException;
-import com.jiayue.ipfcst.common.data.entity.WeatherStationInfo;
 import com.jiayue.ipfcst.common.data.entity.WindTowerInfo;
-import com.jiayue.ipfcst.common.data.entity.WindTurbineInfo;
 import com.jiayue.ipfcst.common.data.repository.WindTowerInfoRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
 import lombok.extern.slf4j.Slf4j;
@@ -14,7 +12,6 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Optional;
@@ -94,10 +91,10 @@ public class WindTowerInfoService extends BaseService {
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
   public List<WindTowerInfo> get(String stationCode) {
-    List<WindTowerInfo> resultList = new ArrayList<>();
-    resultList =  this.windTowerInfoRepository.findAll();
-    if (!"ALL".equals(stationCode)){
-      resultList = resultList.stream().filter(s->s.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    List<WindTowerInfo> resultList;
+    resultList = this.windTowerInfoRepository.findAll();
+    if (!"ALL".equals(stationCode)) {
+      resultList = resultList.stream().filter(s -> s.getStationCode().equals(stationCode)).collect(Collectors.toList());
     }
     return resultList.stream().sorted(Comparator.comparing(WindTowerInfo::getStationCode)).collect(Collectors.toList());
   }
@@ -158,7 +155,7 @@ public class WindTowerInfoService extends BaseService {
 
   @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
   public void saveCloud(List<WindTowerInfo> beans) {
-    if(beans != null && beans.size() > 0){
+    if (beans != null && beans.size() > 0) {
       windTowerInfoRepository.deleteAll();
       windTowerInfoRepository.saveAll(beans);
     }

+ 9 - 9
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WindTowerStatusDataService.java

@@ -1,7 +1,6 @@
 package com.jiayue.ipfcst.console.service;
 
 import com.jiayue.ipfcst.common.data.entity.WindTowerStatusData;
-import com.jiayue.ipfcst.common.data.repository.PowerStationStatusDataRepository;
 import com.jiayue.ipfcst.common.data.repository.WindTowerStatusDataRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -13,6 +12,7 @@ import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
+
 import javax.persistence.criteria.Predicate;
 import java.lang.reflect.Field;
 import java.util.*;
@@ -30,8 +30,7 @@ public class WindTowerStatusDataService extends BaseService {
   private final WindTowerStatusDataRepository windTowerStatusDataRepository;
 
   @Autowired
-  public WindTowerStatusDataService(WindTowerStatusDataRepository windTowerStatusDataRepository,
-                                    PowerStationStatusDataRepository powerStationStatusDataRepository) {
+  public WindTowerStatusDataService(WindTowerStatusDataRepository windTowerStatusDataRepository) {
     this.windTowerStatusDataRepository = windTowerStatusDataRepository;
   }
 
@@ -44,20 +43,21 @@ public class WindTowerStatusDataService extends BaseService {
    * @return
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public Map<String, Object> findByTimeBetweenAndNoAndTimeStep(String stationCode,Date startTime, Date endTime,
-                                                               Integer page,Integer size,String no) {
+  public Map<String, Object> findByTimeBetweenAndNoAndTimeStep(String stationCode, Date startTime, Date endTime,
+                                                               Integer page, Integer size, String no) {
 
     Map<String, Object> map = new HashMap<>();
     Sort sort = Sort.by(Sort.Direction.DESC, "time");
-    Specification<WindTowerStatusData> specification = this.specificationFindByTime(stationCode,startTime, endTime,no);
+    Specification<WindTowerStatusData> specification = this.specificationFindByTime(stationCode, startTime, endTime, no);
     Pageable pageable = PageRequest.of(page - 1, size, sort); //页码:前端从1开始,jpa从0开始,做个转换
     Page windTowerStatusDatas = windTowerStatusDataRepository.findAll(specification, pageable);
-    List<WindTowerStatusData> datas = new ArrayList<>();
+    List<WindTowerStatusData> datas;
     datas = windTowerStatusDatas.getContent();
     map.put("content", datas);// 结果集
     map.put("count", windTowerStatusDatas.getTotalElements());// 总记录数
     return map;
   }
+
   /**
    * 根据时间 分页查询条件 yh
    *
@@ -65,11 +65,11 @@ public class WindTowerStatusDataService extends BaseService {
    * @param endTime   结束时间
    * @return 过滤条件
    */
-  Specification<WindTowerStatusData> specificationFindByTime(final String stationCode, final Date startTime, final Date endTime,final String no) {
+  Specification<WindTowerStatusData> specificationFindByTime(final String stationCode, final Date startTime, final Date endTime, final String no) {
     return (Specification<WindTowerStatusData>) (root, criteriaQuery, cb) -> {
       List<Predicate> predicates = new ArrayList<>();
       predicates.add(cb.equal(root.get("stationCode").as(String.class), stationCode));
-      if (!"ALL".equals(no)){
+      if (!"ALL".equals(no)) {
         predicates.add(cb.equal(root.get("equipmentId").as(String.class), no));
       }
       if (startTime != null) {

+ 107 - 108
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WindTurbineInfoService.java

@@ -12,7 +12,6 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Optional;
@@ -28,77 +27,77 @@ import java.util.stream.Collectors;
 @Service
 @Slf4j
 public class WindTurbineInfoService extends BaseService {
-    private final WindTurbineInfoRepository windTurbineInfoRepository;
+  private final WindTurbineInfoRepository windTurbineInfoRepository;
 
-    @Autowired
-    public WindTurbineInfoService(WindTurbineInfoRepository windTurbineInfoRepository) {
-        this.windTurbineInfoRepository = windTurbineInfoRepository;
-    }
+  @Autowired
+  public WindTurbineInfoService(WindTurbineInfoRepository windTurbineInfoRepository) {
+    this.windTurbineInfoRepository = windTurbineInfoRepository;
+  }
 
 
-    /**
-     * 新增风机
-     *
-     * @param windTurbine 风机
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void add(WindTurbineInfo windTurbine) throws BusinessException {
-        this.windTurbineInfoRepository.save(windTurbine);
+  /**
+   * 新增风机
+   *
+   * @param windTurbine 风机
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void add(WindTurbineInfo windTurbine) throws BusinessException {
+    this.windTurbineInfoRepository.save(windTurbine);
 //        boolean b = this.windTurbineRepository.existsById(windTurbine.getNo());
 //        if (b) {// 编号已存在
 //            throw new BusinessException("风机编号已存在!");
 //        } else {
 //            this.windTurbineRepository.save(windTurbine);
 //        }
-    }
+  }
 
-    /**
-     * 修改风机
-     *
-     * @param windTurbine 逆变器
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void update(WindTurbineInfo windTurbine) throws BusinessException {
-        if (StringUtils.isEmpty(windTurbine.getId())) {
-            throw new BusinessException("风机编号不能为空!");
-        } else {
-            this.windTurbineInfoRepository.save(windTurbine);
-        }
+  /**
+   * 修改风机
+   *
+   * @param windTurbine 逆变器
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void update(WindTurbineInfo windTurbine) throws BusinessException {
+    if (StringUtils.isEmpty(windTurbine.getId())) {
+      throw new BusinessException("风机编号不能为空!");
+    } else {
+      this.windTurbineInfoRepository.save(windTurbine);
     }
+  }
 
-    /**
-     * 删除风机
-     *
-     * @param no 逆变器编号
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void delete(final Integer no) throws BusinessException {
-        if (StringUtils.isEmpty(no)) {
-            throw new BusinessException("风机编号不能为空!");
-        } else {
-            this.windTurbineInfoRepository.deleteById(no);
-        }
+  /**
+   * 删除风机
+   *
+   * @param no 逆变器编号
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void delete(final Integer no) throws BusinessException {
+    if (StringUtils.isEmpty(no)) {
+      throw new BusinessException("风机编号不能为空!");
+    } else {
+      this.windTurbineInfoRepository.deleteById(no);
     }
+  }
 
-    /**
-     * 查询风机
-     *
-     * @param no 逆变器编号
-     * @return 逆变器
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public WindTurbineInfo get(final Integer no) throws BusinessException {
-        Optional<WindTurbineInfo> optional = this.windTurbineInfoRepository.findById(no);
-        if (optional.isPresent()) {
-            return optional.get();
-        } else {
-            throw new BusinessException("风机不存在!");
-        }
+  /**
+   * 查询风机
+   *
+   * @param no 逆变器编号
+   * @return 逆变器
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public WindTurbineInfo get(final Integer no) throws BusinessException {
+    Optional<WindTurbineInfo> optional = this.windTurbineInfoRepository.findById(no);
+    if (optional.isPresent()) {
+      return optional.get();
+    } else {
+      throw new BusinessException("风机不存在!");
     }
+  }
 
   /**
    * 根据场站编号查询风机
@@ -109,71 +108,71 @@ public class WindTurbineInfoService extends BaseService {
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
   public List<WindTurbineInfo> getByStationCode(String stationCode) {
-    List<WindTurbineInfo> resultList = new ArrayList<>();
-    resultList =  this.windTurbineInfoRepository.findAll();
-    if (!"ALL".equals(stationCode)){
-      resultList = resultList.stream().filter(s->s.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    List<WindTurbineInfo> resultList;
+    resultList = this.windTurbineInfoRepository.findAll();
+    if (!"ALL".equals(stationCode)) {
+      resultList = resultList.stream().filter(s -> s.getStationCode().equals(stationCode)).collect(Collectors.toList());
     }
     return resultList.stream().sorted(Comparator.comparing(WindTurbineInfo::getStationCode)).collect(Collectors.toList());
   }
 
-    /**
-     * 查询风机【分页查询】
-     *
-     * @param windTurbine 查询条件
-     * @param page        页码
-     * @param size        每页记录数
-     * @return 分页结果
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public Page<WindTurbineInfo> get(final WindTurbineInfo windTurbine, final Integer page, final Integer size) {
-        ExampleMatcher matcher =
-                ExampleMatcher.matching().withMatcher("modelNumber", ExampleMatcher.GenericPropertyMatchers.contains());
-        Example<WindTurbineInfo> example = Example.of(windTurbine, matcher);
-        Sort sort = Sort.by(Sort.Direction.ASC,"stationCode");
-        Pageable pageable = PageRequest.of(page - 1, size,sort);
-        return this.windTurbineInfoRepository.findAll(example, pageable);
-    }
+  /**
+   * 查询风机【分页查询】
+   *
+   * @param windTurbine 查询条件
+   * @param page        页码
+   * @param size        每页记录数
+   * @return 分页结果
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public Page<WindTurbineInfo> get(final WindTurbineInfo windTurbine, final Integer page, final Integer size) {
+    ExampleMatcher matcher =
+      ExampleMatcher.matching().withMatcher("modelNumber", ExampleMatcher.GenericPropertyMatchers.contains());
+    Example<WindTurbineInfo> example = Example.of(windTurbine, matcher);
+    Sort sort = Sort.by(Sort.Direction.ASC, "stationCode");
+    Pageable pageable = PageRequest.of(page - 1, size, sort);
+    return this.windTurbineInfoRepository.findAll(example, pageable);
+  }
 
-    /**
-     * 查询风机
-     *
-     * @return 分页结果
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public List<WindTurbineInfo> getAll() {
-        return this.windTurbineInfoRepository.findAll();
-    }
+  /**
+   * 查询风机
+   *
+   * @return 分页结果
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public List<WindTurbineInfo> getAll() {
+    return this.windTurbineInfoRepository.findAll();
+  }
 
 
-    /**
-     * 查询所有样板机风机 create by xiuwei
-     *
-     * @return 风机信息
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public List<WindTurbineInfo> getAllSample() {
-        WindTurbineInfo windTurbineInfo = new WindTurbineInfo();
-        windTurbineInfo.setSample(true);
-        return windTurbineInfoRepository.findAll(Example.of(windTurbineInfo));
-    }
+  /**
+   * 查询所有样板机风机 create by xiuwei
+   *
+   * @return 风机信息
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public List<WindTurbineInfo> getAllSample() {
+    WindTurbineInfo windTurbineInfo = new WindTurbineInfo();
+    windTurbineInfo.setSample(true);
+    return windTurbineInfoRepository.findAll(Example.of(windTurbineInfo));
+  }
 
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void saveCloud(WindTurbineInfo bean) {
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(WindTurbineInfo bean) {
 //        WindTurbineInfo beanOld = windTurbineInfoRepository.findByName(bean.getName());
 //        if (null != beanOld) {
 //            bean.setId(beanOld.getId());
 //        }
-        windTurbineInfoRepository.save(bean);
-    }
+    windTurbineInfoRepository.save(bean);
+  }
 
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void saveCloud(List<WindTurbineInfo> beans) {
-        if(beans != null && beans.size() > 0){
-            windTurbineInfoRepository.deleteAll();
-            windTurbineInfoRepository.saveAll(beans);
-        }
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(List<WindTurbineInfo> beans) {
+    if (beans != null && beans.size() > 0) {
+      windTurbineInfoRepository.deleteAll();
+      windTurbineInfoRepository.saveAll(beans);
     }
+  }
 
   /**
    * 批量新增逆变器

+ 11 - 12
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WindTurbineStatusDataService.java

@@ -52,15 +52,15 @@ public class WindTurbineStatusDataService {
                                                              Integer page, Integer size,
                                                              Integer[] no, String timeSortOrder, String noSortOrder) {
     Map<String, Object> map = new HashMap<>();
-    List<Sort.Order> orders = new ArrayList<Sort.Order>();
+    List<Sort.Order> orders = new ArrayList<>();
 
-    if (timeSortOrder.indexOf("asc") >= 0) {
+    if (timeSortOrder.contains("asc")) {
       orders.add(new Sort.Order(Sort.Direction.ASC, "time"));
     } else {
       orders.add(new Sort.Order(Sort.Direction.DESC, "time"));
     }
 
-    if (noSortOrder.indexOf("asc") >= 0) {
+    if (noSortOrder.contains("asc")) {
       orders.add(new Sort.Order(Sort.Direction.ASC, "equipmentNo"));
     } else {
       orders.add(new Sort.Order(Sort.Direction.DESC, "equipmentNo"));
@@ -70,7 +70,7 @@ public class WindTurbineStatusDataService {
     Specification<WindTurbineStatusData> specification = this.specificationFindByTimeAndNo(startTime, endTime, no);
     Pageable pageable = PageRequest.of(page - 1, size, sort);
     Page windTurbineStatusDatas = windTurbineStatusDataRepository.findAll(specification, pageable);
-    List<WindTurbineStatusData> datas = new ArrayList<>();
+    List<WindTurbineStatusData> datas;
     datas = windTurbineStatusDatas.getContent();
     this.defaultReplace(datas);
     map.put("content", datas);
@@ -98,10 +98,9 @@ public class WindTurbineStatusDataService {
         predicates.add(cb.lessThan(root.get("time").as(Date.class), endTime));
       }
       if (no != null) {
-        List<Predicate> list = new ArrayList<Predicate>();
         CriteriaBuilder.In<Integer> in = cb.in(root.get("equipmentNo"));
-        for (int i = 0; i < no.length; i++) {
-          in.value(no[i]);
+        for (Integer integer : no) {
+          in.value(integer);
         }
         predicates.add(in);
       }
@@ -122,15 +121,15 @@ public class WindTurbineStatusDataService {
    * @return
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public Map<String, Object> findByTimeBetweenForPaging(String stationCode,Date startTime, Date endTime,
+  public Map<String, Object> findByTimeBetweenForPaging(String stationCode, Date startTime, Date endTime,
                                                         Integer page, Integer size,
                                                         String windTurbineId) {
     Map<String, Object> map = new HashMap<>();
     Sort sort = Sort.by(Sort.Direction.DESC, "time");
-    Specification<WindTurbineStatusData> specification = this.specificationFindByTime(stationCode,startTime, endTime,windTurbineId);
+    Specification<WindTurbineStatusData> specification = this.specificationFindByTime(stationCode, startTime, endTime, windTurbineId);
     Pageable pageable = PageRequest.of(page - 1, size, sort); //页码:前端从1开始,jpa从0开始,做个转换
     Page windTurbineStatusDatas = windTurbineStatusDataRepository.findAll(specification, pageable);
-    List<WindTurbineStatusData> datas = new ArrayList<>();
+    List<WindTurbineStatusData> datas;
     datas = windTurbineStatusDatas.getContent();
     this.defaultReplace(datas);
     map.put("content", datas);// 结果集
@@ -145,11 +144,11 @@ public class WindTurbineStatusDataService {
    * @param endTime   结束时间
    * @return 过滤条件
    */
-  Specification<WindTurbineStatusData> specificationFindByTime(final String stationCode,final Date startTime, final Date endTime,final String windTurbineId) {
+  Specification<WindTurbineStatusData> specificationFindByTime(final String stationCode, final Date startTime, final Date endTime, final String windTurbineId) {
     return (Specification<WindTurbineStatusData>) (root, criteriaQuery, cb) -> {
       List<Predicate> predicates = new ArrayList<>();
       predicates.add(cb.equal(root.get("stationCode").as(String.class), stationCode));
-      if (!"ALL".equals(windTurbineId)){
+      if (!"ALL".equals(windTurbineId)) {
         predicates.add(cb.equal(root.get("equipmentId").as(String.class), windTurbineId));
       }
       if (startTime != null) {

+ 2 - 1
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/util/Constant.java

@@ -2,6 +2,7 @@ package com.jiayue.ipfcst.console.util;
 
 import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
 import com.jiayue.ipfcst.common.data.constant.enums.ElectricFieldTypeEnum;
+
 import java.util.Arrays;
 import java.util.List;
 
@@ -27,7 +28,7 @@ public class Constant {
    */
   public static String forecastCoe(Long forecastTime, ElectricFieldTypeEnum electricFieldTypeEnum) {
     int point = DateMomentUtil.getMoment(forecastTime, 15 * 60 * 1000L);
-    String coe = "";
+    String coe;
     if (ElectricFieldTypeEnum.E1.equals(electricFieldTypeEnum)) {
       coe = photovoltaicCoeList.get(point - 1);
     } else {

+ 3 - 1
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/util/CreateConsoleSh.java

@@ -9,6 +9,7 @@ import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
 
 /**
  * 生成console的linux启动脚本
@@ -32,7 +33,7 @@ public class CreateConsoleSh {
       t.merge(ctx, sw);
       os = new FileOutputStream("../syjy/ipfcstV3/bin/start-console.sh");
       // 采用UTF-8字符集
-      os.write(sw.toString().getBytes("UTF-8"));
+      os.write(sw.toString().getBytes(StandardCharsets.UTF_8));
       os.flush();
     } catch (IOException e) {
       e.printStackTrace();
@@ -41,6 +42,7 @@ public class CreateConsoleSh {
         try {
           os.close();
         } catch (IOException e) {
+          //noinspection ThrowablePrintedToSystemOut
           System.out.println(e);
         }
       }

+ 0 - 67
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/util/GzipUtil.java

@@ -1,67 +0,0 @@
-package com.jiayue.ipfcst.console.util;
-
-
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.codec.binary.Base64OutputStream;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.zip.GZIPOutputStream;
-
-/**
- * @author wll
- * @date 2020-04-20 10:55:39
- */
-@Slf4j
-public class GzipUtil {
-
-    private static int packSize = 800;
-
-    public static List<String> zipList(String result) throws IOException {
-        return zipList(result, packSize);
-    }
-
-    private static List<String> zipList(String result, int packSize) throws IOException {
-
-        String zipResult = zip(result);
-        zipResult = zipResult.replace("\r\n", "");
-
-        double length = zipResult.length();
-        int packageNumber = (int) Math.ceil(length / packSize);
-
-        List<String> list = new ArrayList<String>();
-
-        for (int i = 0; i < packageNumber; i++) {
-            if (i == packageNumber - 1) {
-                list.add(zipResult.substring(i * packSize, (int) length));
-            } else if (i == 0) {
-                list.add(zipResult.substring(0, packSize));
-            } else {
-                list.add(zipResult.substring(i * packSize, (i + 1) * packSize));
-            }
-        }
-
-
-        return list;
-    }
-
-    public static String zip(String result) throws IOException {
-        log.debug("qrCode默认编码:"+Charset.defaultCharset().name());
-        log.debug("file.encoding:"+System.getProperty("file.encoding"));
-        byte[] bytes = result.getBytes("utf-8");
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        Base64OutputStream b64os = new Base64OutputStream(bos);
-        GZIPOutputStream gout = new GZIPOutputStream(b64os);
-        gout.write(bytes);
-        gout.close();
-        b64os.close();
-
-        byte b1[] = bos.toByteArray();
-        bos.close();
-        return new String(b1, "utf-8");
-    }
-
-}

+ 1513 - 1477
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/util/RedisUtils.java

@@ -1,6 +1,5 @@
 package com.jiayue.ipfcst.console.util;
 
-import com.jiayue.ipfcst.common.data.abst.equipmentstatus.AbstractEquipmentStatusData;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import redis.clients.jedis.Jedis;
@@ -8,8 +7,6 @@ import redis.clients.jedis.JedisPool;
 import redis.clients.jedis.Pipeline;
 import redis.clients.jedis.Tuple;
 
-import java.lang.reflect.Field;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -26,1479 +23,1518 @@ public class RedisUtils {
     除了该工具类提供的方法外,还可以在外面调用getJedis()方法,获取到jedis实例后,调用它原生的api来操作
      */
 
-    /**
-     * 获取jedis对象,并选择redis库。jedis默认是0号库,可传入1-16之间的数选择库存放数据
-     * 原则上使用一个redis库存放数据,通过特定的key的命令规则来区分不同的数据就行了。
-     *
-     * @param index redis库号。使用可变参数的目的就是该参数可传可不传。
-     * @return 返回jedis对象
-     */
-    public Jedis getJedis(int... index) {
-        Jedis jedis = jedisPool.getResource();
-        if (index != null && index.length > 0) {
-            if (index[0] > 0 && index[0] <= 16){
-                jedis.select(index[0]);
-            }
-        }
-        return jedis;
-    }
-
-    /*########################  key的操作  ################################*/
-
-    /**
-     * 根据pattern返回当前库中的key
-     *
-     * @param pattern
-     * @return
-     */
-    public  Set<String> keys(String pattern) {
-        Jedis jedis = null;
-        Set<String> keys = null;
-        try {
-            jedis = getJedis();
-            keys = jedis.keys(pattern);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return keys;
-    }
-
-    /**
-     * 删除一个或多个key
-     *
-     * @param key 一个或多个key
-     */
-    public  Long del(String... key) {
-        Jedis jedis = null;
-        Long delNum = 0L;
-        try {
-            jedis = getJedis();
-            delNum =jedis.del(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return delNum;
-    }
-
-    /**
-     * 批量删除
-     * @param keyList 要删除的key的集合
-     */
-    public  void mdel(List<String> keyList){
-        Jedis jedis = getJedis();
-        //获取pipeline
-        Pipeline pipeline = jedis.pipelined();
-        for (String key : keyList) {
-            pipeline.del(key);
-        }
-        //执行结果同步,这样才能保证结果的正确性。实际上不执行该方法也执行了上面的命令,但是结果确不一定完全正确。
-        //注意
-        pipeline.sync();
-        //关闭连接
-        jedis.close();
-    }
-
-    /**
-     * 判断某个key是否还存在
-     *
-     * @param key key
-     * @return
-     */
-    public  Boolean exists(String key) {
-        Jedis jedis = null;
-        Boolean flag = false;
-        try {
-            jedis = getJedis();
-            flag = jedis.exists(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return flag;
-    }
-
-    /**
-     * 设置某个key的过期时间,单位秒
-     *
-     * @param key key
-     * @param seconds 过期时间秒
-     */
-    public  void expire(String key, int seconds) {
-        Jedis jedis = null;
-        try {
-            jedis = getJedis();
-            jedis.expire(key, seconds);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-    }
-
-    /**
-     * 查看某个key还有几秒过期,-1表示永不过期 ,-2表示已过期
-     *
-     * @param key key
-     * @return
-     */
-    public  Long timeToLive(String key) {
-        Jedis jedis = null;
-        Long ttl;
-        try {
-            jedis = getJedis();
-            ttl = jedis.ttl(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return ttl;
-    }
-
-    /**
-     * 查看某个key对应的value的类型
-     *
-     * @param key
-     * @return
-     */
-    public  String type(String key) {
-        Jedis jedis = null;
-        String type = null;
-        try {
-            jedis = getJedis();
-            type = jedis.type(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return type;
-    }
-
-
-    /*########################  string(字符串)的操作  ####################*/
-
-    /**
-     * 获取某个key的value,类型要对,只能value是string的才能获取
-     *
-     * @param key
-     * @return
-     */
-    public  String get(String key) {
-        Jedis jedis = null;
-        String value = null;
-        try {
-            jedis = getJedis();
-            value = jedis.get(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return value;
-    }
-
-    /**
-     * 设置某个key的value
-     *
-     * @param key
-     * @param value
-     */
-    public  void set(String key, String value) {
-        Jedis jedis = null;
-        try {
-            jedis = getJedis();
-            jedis.set(key, value);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-    }
-
-    /**
-     * 字符串后追加内容
-     *
-     * @param key key
-     * @param appendContent 要追加的内容
-     */
-    public  void append(String key, String appendContent) {
-        Jedis jedis = null;
-        try {
-            jedis = getJedis();
-            jedis.append(key, appendContent);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-    }
-
-    /**
-     * 返回key的value的长度
-     *
-     * @param key
-     * @return
-     */
-    public  Long strlen(String key) {
-        Jedis jedis = null;
-        Long strLen = 0L;
-        try {
-            jedis = getJedis();
-            strLen = jedis.strlen(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return strLen;
-    }
-
-    /**
-     * value 加1 必
-     * 须是字符型数字
-     * @param key
-     * @return 增加后的值
-     */
-    public  Long incr(String key) {
-        Jedis jedis = null;
-        Long incrResult = 0L;
-        try {
-            jedis = getJedis();
-            incrResult = jedis.incr(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return incrResult;
-    }
-
-    /**
-     * value 减1   必须是字符型数字
-     *
-     * @param key
-     * @return
-     */
-    public  Long decr(String key) {
-        Jedis jedis = null;
-        Long decrResult = 0L;
-        try {
-            jedis = getJedis();
-            decrResult = jedis.decr(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return decrResult;
-    }
-
-    /**
-     * value 加increment
-     *
-     * @param key key
-     * @param increment 加几
-     * @return
-     */
-    public  Long incrby(String key, int increment) {
-        Jedis jedis = null;
-        Long incrByResult = 0L;
-        try {
-            jedis = getJedis();
-            incrByResult = jedis.incrBy(key, increment);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return incrByResult;
-    }
-
-    /**
-     * value 减increment
-     *
-     * @param key
-     * @param increment
-     * @return
-     */
-    public  Long decrby(String key, int increment) {
-        Jedis jedis = null;
-        Long decrByResult = 0L;
-        try {
-            jedis = getJedis();
-            decrByResult = jedis.decrBy(key, increment);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return decrByResult;
-    }
-
-    /**
-     * 给某个key设置过期时间和value,成功返回OK
-     *
-     * @param key key
-     * @param seconds 过期时间秒
-     * @param value 设置的值
-     * @return
-     */
-    public  String setex(String key, int seconds, String value) {
-        Jedis jedis = null;
-        String result = null;
-        try {
-            jedis = getJedis();
-            result = jedis.setex(key, seconds, value);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return result;
-    }
-
-
-    /*########################  list(列表)的操作  #######################*/
-    //lpush rpush lpop rpop lrange lindex llen lset
-
-    /**
-     * 从左边向列表中添加值
-     *
-     * @param key key
-     * @param str 要添加的值
-     */
-    public  void lpush(String key, String str) {
-        Jedis jedis = null;
-        try {
-            jedis = getJedis();
-            jedis.lpush(key, str);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-    }
-
-    /**
-     * 从右边向列表中添加值
-     *
-     * @param key key
-     * @param str 要添加的值
-     */
-    public  void rpush(String key, String str) {
-        Jedis jedis = null;
-        try {
-            jedis = getJedis();
-            jedis.rpush(key, str);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-    }
-
-    /**
-     * 从左边取出一个列表中的值
-     *
-     * @param key
-     * @return
-     */
-    public  String lpop(String key) {
-        Jedis jedis = null;
-        String lpop = null;
-        try {
-            jedis = getJedis();
-            lpop = jedis.lpop(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return lpop;
-    }
-
-    /**
-     * 从右边取出一个列表中的值
-     *
-     * @param key
-     * @return
-     */
-    public  String rpop(String key) {
-        Jedis jedis = null;
-        String rpop = null;
-        try {
-            jedis = getJedis();
-            rpop = jedis.rpop(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return rpop;
-    }
-
-    /**
-     * 取出列表中指定范围内的值,0 到 -1 表示全部
-     *
-     * @param key
-     * @param startIndex
-     * @param endIndex
-     * @return
-     */
-    public  List<String> lrange(String key, int startIndex, int endIndex) {
-        Jedis jedis = null;
-        List<String> result = null;
-        try {
-            jedis = getJedis();
-            result = jedis.lrange(key, startIndex, endIndex);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return result;
-    }
-
-    /**
-     * 返回某列表指定索引位置的值
-     *
-     * @param key 列表key
-     * @param index 索引位置
-     * @return
-     */
-    public  String lindex(String key, int index) {
-        Jedis jedis = null;
-        String lindex = null;
-        try {
-            jedis = getJedis();
-            lindex = jedis.lindex(key, index);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return lindex;
-    }
-
-    /**
-     * 返回某列表的长度
-     *
-     * @param key
-     * @return
-     */
-    public  Long llen(String key) {
-        Jedis jedis = null;
-        Long llen = 0L;
-        try {
-            jedis = getJedis();
-            llen = jedis.llen(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return llen;
-    }
-
-    /**
-     * 给某列表指定位置设置为指定的值
-     *
-     * @param key
-     * @param index
-     * @param str
-     */
-    public  void lset(String key, Long index, String str) {
-        Jedis jedis = null;
-        try {
-            jedis = getJedis();
-            jedis.lset(key, index, str);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-    }
-
-    /**
-     * 对列表进行剪裁,保留指定闭区间的元素(索引位置也会重排)
-     * @param key 列表key
-     * @param startIndex 开始索引位置
-     * @param endIndex 结束索引位置
-     */
-    public  void ltrim(String key,Integer startIndex,Integer endIndex){
-        Jedis jedis = null;
-        try {
-            jedis = getJedis();
-            jedis.ltrim(key, startIndex, endIndex);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-    }
-
-    /**
-     * 从列表的左边阻塞弹出一个元素
-     * @param key 列表的key
-     * @param timeout 阻塞超时时间,0表示若没有元素就永久阻塞
-     * @return
-     */
-    public  List<String> blpop(String key,Integer timeout){
-        Jedis jedis = null;
-        List<String> valueList = null;
-        try {
-            jedis = getJedis();
-            valueList = jedis.blpop(timeout, key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return valueList;
-    }
-
-    /**
-     * 从列表的右边阻塞弹出一个元素
-     * @param key 列表的key
-     * @param timeout 阻塞超时时间,0表示若没有元素就永久阻塞
-     * @return
-     */
-    public  List<String> brpop(String key,Integer timeout){
-        Jedis jedis = null;
-        List<String> valueList = null;
-        try {
-            jedis = getJedis();
-            valueList = jedis.brpop(timeout, key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return valueList;
-    }
-
-
-    /*########################  hash(哈希表)的操作  #######################*/
-    //hset hget hmset hmget hgetall hdel hkeys hvals hexists hincrby
-
-    /**
-     * 给某个hash表设置一个键值对
-     *
-     * @param key
-     * @param field
-     * @param value
-     */
-    public  void hset(String key, String field, String value) {
-        Jedis jedis = null;
-        try {
-            jedis = getJedis();
-            jedis.hset(key, field, value);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-    }
-
-    /**
-     * 取出某个hash表中某个field对应的value
-     *
-     * @param key key
-     * @param field field
-     * @return
-     */
-    public  String hget(String key, String field) {
-        Jedis jedis = null;
-        String hget = null;
-        try {
-            jedis = getJedis();
-            hget = jedis.hget(key, field);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return hget;
-    }
-
-    /**
-     * 某个hash表设置一个或多个键值对
-     *
-     * @param key
-     * @param kvMap
-     */
-    public  void hmset(String key, Map<String, String> kvMap) {
-        Jedis jedis = null;
-        try {
-            jedis = getJedis();
-            jedis.hmset(key, kvMap);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-    }
-
-
-    /**
-     * 取出某个hash表中任意多个key对应的value的集合
-     *
-     * @param key
-     * @param fields
-     * @return
-     */
-    public  List<String> hmget(String key, String... fields) {
-        Jedis jedis = null;
-        List<String> hmget = null;
-        try {
-            jedis = getJedis();
-            hmget = jedis.hmget(key, fields);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return hmget;
-    }
-
-    /**
-     * 取出某个hash表中所有的键值对
-     *
-     * @param key
-     * @return
-     */
-    public  Map<String, String> hgetall(String key) {
-        Jedis jedis = null;
-        Map<String, String> kvMap = null;
-        try {
-            jedis = getJedis();
-            kvMap = jedis.hgetAll(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return kvMap;
-    }
-
-    /**
-     * 判断某个hash表中的某个key是否存在
-     *
-     * @param key
-     * @param field
-     * @return
-     */
-    public  Boolean hexists(String key, String field) {
-        Jedis jedis = null;
-        Boolean exists = null;
-        try {
-            jedis = getJedis();
-            exists = jedis.hexists(key, field);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return exists;
-    }
-
-    /**
-     * 返回某个hash表中所有的key
-     *
-     * @param key
-     * @return
-     */
-    public  Set<String> hkeys(String key) {
-        Jedis jedis = null;
-        Set<String> keys = null;
-        try {
-            jedis = getJedis();
-            keys = jedis.hkeys(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return keys;
-    }
-
-    /**
-     * 返回某个hash表中所有的value
-     *
-     * @param key
-     * @return
-     */
-    public  List<String> hvals(String key) {
-        Jedis jedis = null;
-        List<String> hvals = null;
-        try {
-            jedis = getJedis();
-            hvals = jedis.hvals(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return hvals;
-    }
-
-    /**
-     * 删除某个hash表中的一个或多个键值对
-     *
-     * @param key
-     * @param fields
-     */
-    public  void hdel(String key, String... fields) {
-        Jedis jedis = null;
-        try {
-            jedis = getJedis();
-            jedis.hdel(key, fields);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-    }
-
-    /**
-     * 给某个hash表中的某个field的value增加多少
-     *
-     * @param key       hash表的key
-     * @param field     表中的某个field
-     * @param increment 增加多少
-     * @return
-     */
-    public  Long hincrby(String key, String field, Long increment) {
-        Jedis jedis = null;
-        Long result = null;
-        try {
-            jedis = getJedis();
-            result = jedis.hincrBy(key, field, increment);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return result;
-    }
-
-    /*########################  set(集合)的操作  ###########################*/
-
-    /**
-     * 往set集合中添加一个或多个元素
-     * @param key key
-     * @param members 要添加的元素
-     * @return 添加成功的元素个数
-     */
-    public  Long sadd(String key,String... members){
-        Jedis jedis = null;
-        Long num = 0L;
-        try {
-            jedis = getJedis();
-            num = jedis.sadd(key, members);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return num;
-    }
-
-    /**
-     * 返回set集合中的所有元素,顺序与加入时的顺序一致
-     * @param key key
-     * @return
-     */
-    public  Set<String> smembers(String key){
-        Jedis jedis = null;
-        Set<String> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.smembers(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-    /**
-     * 判断集合中是否存在某个元素
-     * @param key key
-     * @param member 某个元素
-     * @return true存在,false不存在
-     */
-    public  Boolean sismember(String key,String member){
-        Jedis jedis = null;
-        Boolean isMember = false;
-        try {
-            jedis = getJedis();
-            isMember = jedis.sismember(key, member);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return isMember;
-    }
-
-    /**
-     * 返回set集合的长度
-     * @param key key
-     * @return
-     */
-    public  Long scard(String key){
-        Jedis jedis = null;
-        Long len = 0L;
-        try {
-            jedis = getJedis();
-            len = jedis.scard(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return len;
-    }
-
-    /**
-     * 删除set集合中指定的一个或多个元素
-     * @param key
-     * @param members 要删除的元素
-     * @return 删除成功的元素个数
-     */
-    public  Long srem(String key,String... members){
-        Jedis jedis = null;
-        Long num = 0L;
-        try {
-            jedis = getJedis();
-            num = jedis.srem(key,members);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return num;
-    }
-
-    /**
-     * 将key1中的元素key1Member移动到key2中
-     * @param key1 来源集合key
-     * @param key2 目的地集合key
-     * @param key1Member key1中的元素
-     * @return 1成功,0失败
-     */
-    public  Long smove(String key1,String key2,String key1Member){
-        Jedis jedis = null;
-        Long num = 0L;
-        try {
-            jedis = getJedis();
-            num = jedis.smove(key1,key2,key1Member);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return num;
-    }
-
-    /**
-     * 随机查询返回集合中的指定个数的元素(若count为负数,返回的元素可能会重复)
-     * @param key key
-     * @param count 要查询返回的元素个数
-     * @return 元素list集合
-     */
-    public  List<String> srandmember(String key,int count){
-        Jedis jedis = null;
-        List<String> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.srandmember(key,count);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-    /**
-     * 从set集合中随机弹出指定个数个元素
-     * @param key key
-     * @param count 要弹出的个数
-     * @return 随机弹出的元素
-     */
-    public  Set<String> spop(String key,int count){
-        Jedis jedis = null;
-        Set<String> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.spop(key,count);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-    /**
-     * 求交集,返回多个set集合相交的部分
-     * @param setKeys 多个set集合的key
-     * @return 相交的元素集合
-     */
-    public  Set<String> sinter(String... setKeys){
-        Jedis jedis = null;
-        Set<String> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.sinter(setKeys);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-    /**
-     * 求并集,求几个set集合的并集(因为set中不会有重复的元素,合并后的集合也不会有重复的元素)
-     * @param setKeys 多个set的key
-     * @return 合并后的集合
-     */
-    public  Set<String> sunion(String... setKeys){
-        Jedis jedis = null;
-        Set<String> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.sunion(setKeys);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-    /**
-     * 求差集,求几个集合之间的差集
-     * @param setKeys 多个set的key
-     * @return 差集
-     */
-    public  Set<String> sdiff(String... setKeys){
-        Jedis jedis = null;
-        Set<String> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.sdiff(setKeys);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-
-    /*########################  zset(有序集合)的操作  #######################*/
-
-    /**
-     * 添加一个元素到zset
-     * @param key key
-     * @param score 元素的分数
-     * @param member 元素
-     * @return 成功添加的元素个数
-     */
-    public  Long zadd(String key,double score, String member){
-        Jedis jedis = null;
-        Long num = null;
-        try {
-            jedis = getJedis();
-            num = jedis.zadd(key,score,member);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return num;
-    }
-
-    /**
-     * 添加一个或多个元素到zset
-     * @param key key
-     * @param memberScores 元素和分数的map集合,map的k是元素,v是分数
-     * @return 成功添加的元素个数
-     */
-    public  Long zadd(String key,Map<String,Double> memberScores){
-        Jedis jedis = null;
-        Long num = null;
-        try {
-            jedis = getJedis();
-            num = jedis.zadd(key,memberScores);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return num;
-    }
-
-    /**
-     * 查询指定闭区间的元素(根据分数升序)
-     * (0,-1表示全部)
-     * @param key zset的key
-     * @param start 开始区间
-     * @param end 结束区间
-     * @return 元素集合
-     */
-    public  Set<String> zrange(String key, long start, long end){
-        Jedis jedis = null;
-        Set<String> ascResult = null;
-        try {
-            jedis = getJedis();
-            ascResult = jedis.zrange(key,start,end);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return ascResult;
-    }
-
-    /**
-     * 查询指定闭区间的元素,带着分数
-     * (0,-1表示全部)
-     * @param key zset的key
-     * @param start 开始区间
-     * @param end 结束区间
-     * @return 元素集合 格式为:
-     * [{"element":"a","score":10.0,"binaryElement":"YQ=="},{"element":"b","score":20.0,"binaryElement":"Yg=="}]
-     */
-    public  Set<Tuple> zrangeWithScores(String key, long start, long end){
-        Jedis jedis = null;
-        Set<Tuple> ascResult = null;
-        try {
-            jedis = getJedis();
-            ascResult = jedis.zrangeWithScores(key,start,end);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return ascResult;
-    }
-
-    /**
-     * 查询指定索引闭区间的元素(根据分数降序)
-     * (0,-1表示全部)
-     * @param key zset的key
-     * @param start 开始区间
-     * @param end 结束区间
-     * @return 元素集合
-     */
-    public  Set<String> zrevrange(String key, long start, long end){
-        Jedis jedis = null;
-        Set<String> descResult = null;
-        try {
-            jedis = getJedis();
-            descResult = jedis.zrevrange(key,start,end);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return descResult;
-    }
-
-    /**
-     * 查询指定索引闭区间的元素,带着分数(根据分数降序)
-     * (0,-1表示全部)
-     * @param key zset的key
-     * @param start 开始区间
-     * @param end 结束区间
-     * @return 元素集合 格式为:
-     * [{"element":"b","score":20.0,"binaryElement":"Yg=="},{"element":"a","score":10.0,"binaryElement":"YQ=="}]
-     */
-    public  Set<Tuple> zrevrangeWithScores(String key, long start, long end){
-        Jedis jedis = null;
-        Set<Tuple> descResult = null;
-        try {
-            jedis = getJedis();
-            descResult = jedis.zrevrangeWithScores(key,start,end);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return descResult;
-    }
-
-    /**
-     * 返回有序集合(zset)中的元素个数
-     * @param key key
-     * @return 个数
-     */
-    public  Long zcard(String key){
-        Jedis jedis = null;
-        Long count = null;
-        try {
-            jedis = getJedis();
-            count = jedis.zcard(key);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return count;
-    }
-
-    /**
-     * 返回指定分数区间的元素个数(闭区间)
-     * @param key key
-     * @param startScore 开始分数
-     * @param endScore 结束分数
-     * @return 个数
-     */
-    public  Long zcount(String key,Long startScore,Long endScore){
-        Jedis jedis = null;
-        Long count = null;
-        try {
-            jedis = getJedis();
-            count = jedis.zcount(key,startScore,endScore);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return count;
-    }
-
-    /**
-     * 返回某元素在集合中的排名(根据分数降序排列时)
-     * @param key key
-     * @param member 集合中的元素
-     * @return 排名,从0开始
-     */
-    public  Long zrevrank(String key, String member){
-        Jedis jedis = null;
-        Long count = null;
-        try {
-            jedis = getJedis();
-            count = jedis.zrevrank(key,member);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return count;
-    }
-
-    /**
-     * 返回某元素在集合中的排名(根据分数升序排列时)
-     * @param key key
-     * @param member 集合中的元素
-     * @return 排名,从0开始
-     */
-    public  Long zrank(String key, String member){
-        Jedis jedis = null;
-        Long count = null;
-        try {
-            jedis = getJedis();
-            count = jedis.zrank(key,member);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return count;
-    }
-
-    /**
-     * 升序查询指定分数闭区间的元素
-     * @param key key
-     * @param min 最小分数
-     * @param max 最大分数
-     * @return 元素集合
-     */
-    public  Set<String> zrangeByScore(String key,double min, double max){
-        Jedis jedis = null;
-        Set<String> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.zrangeByScore(key, min, max);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-    /**
-     * 升序查询指定分数闭区间的元素,并指定偏移量
-     * @param key key
-     * @param min 最小分数
-     * @param max 最大分数
-     * @param offset 偏移量
-     * @param size 数量
-     * @return 元素集合
-     */
-    public  Set<String> zrangeByScore(String key,double min, double max,int offset,int size){
-        Jedis jedis = null;
-        Set<String> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.zrangeByScore(key, min, max,offset,size);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-    /**
-     * 升序查询指定分数闭区间的元素,带着分数
-     * @param key key
-     * @param min 最小分数
-     * @param max 最大分数
-     * @return 元素集合
-     */
-    public  Set<Tuple> zrangeByScoreWithScores(String key,double min, double max){
-        Jedis jedis = null;
-        Set<Tuple> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.zrangeByScoreWithScores(key, min, max);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-    /**
-     * 升序查询指定分数闭区间的元素,并指定偏移量,带着分数
-     * @param key key
-     * @param min 最小分数
-     * @param max 最大分数
-     * @param offset 偏移量
-     * @param size 数量
-     * @return 元素集合
-     */
-    public  Set<Tuple> zrangeByScoreWithScores(String key,double min, double max,int offset,int size){
-        Jedis jedis = null;
-        Set<Tuple> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.zrangeByScoreWithScores(key, min, max,offset,size);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-    /**
-     * 降序查询指定分数闭区间的元素
-     * @param key key
-     * @param max 最大分数
-     * @param min 最小分数
-     * @return 元素集合
-     */
-    public  Set<String> zrevrangebyscore(String key,double max,double min){
-        Jedis jedis = null;
-        Set<String> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.zrevrangeByScore(key, max,min);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-    /**
-     * 降序查询指定分数闭区间的元素,并指定偏移量
-     * @param key key
-     * @param max 最大分数
-     * @param min 最小分数
-     * @return 元素集合
-     */
-    public  Set<String> zrevrangebyscore(String key,double max,double min,int offset,int size){
-        Jedis jedis = null;
-        Set<String> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.zrevrangeByScore(key, max,min,offset,size);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-    /**
-     * 降序查询指定分数闭区间的元素,并带着分数
-     * @param key key
-     * @param min 最小分数
-     * @param max 最大分数
-     * @return 元素集合
-     */
-    public  Set<Tuple> zrevrangeByScoreWithScores(String key,double max,double min){
-        Jedis jedis = null;
-        Set<Tuple> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.zrevrangeByScoreWithScores(key,max,min);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-    /**
-     * 降序查询指定分数闭区间的元素,并指定偏移量,带着分数
-     * @param key key
-     * @param min 最小分数
-     * @param max 最大分数
-     * @param offset 偏移量
-     * @param size 数量
-     * @return 元素集合
-     */
-    public  Set<Tuple> zrevrangeByScoreWithScores(String key,double max,double min,int offset,int size){
-        Jedis jedis = null;
-        Set<Tuple> members = null;
-        try {
-            jedis = getJedis();
-            members = jedis.zrevrangeByScoreWithScores(key, min, max,offset,size);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return members;
-    }
-
-    /**
-     * 有序集合中指定删除一或多个元素
-     * @param key
-     * @param member 元素
-     * @return 删除成功的个数
-     */
-    public  Long zrem(String key, String... member){
-        Jedis jedis = null;
-        Long num = null;
-        try {
-            jedis = getJedis();
-            num = jedis.zrem(key,member);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return num;
-    }
-
-    /**
-     * 分数升序排名时,删除指定索引区间的元素
-     * @param key key
-     * @param start 开始索引
-     * @param end 结束索引
-     * @return 删除成功的个数
-     */
-    public  Long zremrangebyrank(String key,long start,long end){
-        Jedis jedis = null;
-        Long num = null;
-        try {
-            jedis = getJedis();
-            num = jedis.zremrangeByRank(key,start,end);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return num;
-    }
-
-    /**
-     * 分数升序排名时,删除指定分数区间的元素
-     * @param key key
-     * @param min 最小分数
-     * @param max 最大分数
-     * @return 删除成功的个数
-     */
-    public  Long zremrangeByScore(String key,long min,long max){
-        Jedis jedis = null;
-        Long num = null;
-        try {
-            jedis = getJedis();
-            num = jedis.zremrangeByScore(key,min,max);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return num;
-    }
-
-    /**
-     * 查询有序集合中某元素的分数
-     * @param key key
-     * @param member 元素
-     * @return 删除成功的个数
-     */
-    public  Double zscore(String key,String member){
-        Jedis jedis = null;
-        Double score = null;
-        try {
-            jedis = getJedis();
-            score = jedis.zscore(key,member);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return score;
-    }
-
-    /**
-     * 给有序集合中某元素的分数增加(正数)或减少(负数)
-     * @param key key
-     * @param score 分数
-     * @param member 元素
-     * @return 新的分数
-     */
-    public  Double zincrby(String key,double score,String member){
-        Jedis jedis = null;
-        Double newScore = null;
-        try {
-            jedis = getJedis();
-            newScore = jedis.zincrby(key,score,member);
-        }finally {
-            if (jedis != null){
-                jedis.close();
-            }
-        }
-        return newScore;
-    }
-    /**
-     * 私有化构造器,不让实例化对象
-     */
-    private RedisUtils() {
+  /**
+   * 私有化构造器,不让实例化对象
+   */
+  private RedisUtils() {
+  }
+
+  /*########################  key的操作  ################################*/
+
+  /**
+   * 获取jedis对象,并选择redis库。jedis默认是0号库,可传入1-16之间的数选择库存放数据
+   * 原则上使用一个redis库存放数据,通过特定的key的命令规则来区分不同的数据就行了。
+   *
+   * @param index redis库号。使用可变参数的目的就是该参数可传可不传。
+   * @return 返回jedis对象
+   */
+  public Jedis getJedis(int... index) {
+    Jedis jedis = jedisPool.getResource();
+    if (index != null && index.length > 0) {
+      if (index[0] > 0 && index[0] <= 16) {
+        jedis.select(index[0]);
+      }
+    }
+    return jedis;
+  }
+
+  /**
+   * 根据pattern返回当前库中的key
+   *
+   * @param pattern
+   * @return
+   */
+  public Set<String> keys(String pattern) {
+    Jedis jedis = null;
+    Set<String> keys;
+    try {
+      jedis = getJedis();
+      keys = jedis.keys(pattern);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return keys;
+  }
+
+  /**
+   * 删除一个或多个key
+   *
+   * @param key 一个或多个key
+   */
+  public Long del(String... key) {
+    Jedis jedis = null;
+    Long delNum;
+    try {
+      jedis = getJedis();
+      delNum = jedis.del(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return delNum;
+  }
+
+  /**
+   * 批量删除
+   *
+   * @param keyList 要删除的key的集合
+   */
+  public void mdel(List<String> keyList) {
+    Jedis jedis = getJedis();
+    //获取pipeline
+    Pipeline pipeline = jedis.pipelined();
+    for (String key : keyList) {
+      pipeline.del(key);
+    }
+    //执行结果同步,这样才能保证结果的正确性。实际上不执行该方法也执行了上面的命令,但是结果确不一定完全正确。
+    //注意
+    pipeline.sync();
+    //关闭连接
+    jedis.close();
+  }
+
+  /**
+   * 判断某个key是否还存在
+   *
+   * @param key key
+   * @return
+   */
+  public Boolean exists(String key) {
+    Jedis jedis = null;
+    Boolean flag;
+    try {
+      jedis = getJedis();
+      flag = jedis.exists(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return flag;
+  }
+
+  /**
+   * 设置某个key的过期时间,单位秒
+   *
+   * @param key     key
+   * @param seconds 过期时间秒
+   */
+  public void expire(String key, int seconds) {
+    Jedis jedis = null;
+    try {
+      jedis = getJedis();
+      jedis.expire(key, seconds);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+  }
+
+  /**
+   * 查看某个key还有几秒过期,-1表示永不过期 ,-2表示已过期
+   *
+   * @param key key
+   * @return
+   */
+  public Long timeToLive(String key) {
+    Jedis jedis = null;
+    Long ttl;
+    try {
+      jedis = getJedis();
+      ttl = jedis.ttl(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return ttl;
+  }
+
+
+  /*########################  string(字符串)的操作  ####################*/
+
+  /**
+   * 查看某个key对应的value的类型
+   *
+   * @param key
+   * @return
+   */
+  public String type(String key) {
+    Jedis jedis = null;
+    String type;
+    try {
+      jedis = getJedis();
+      type = jedis.type(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return type;
+  }
+
+  /**
+   * 获取某个key的value,类型要对,只能value是string的才能获取
+   *
+   * @param key
+   * @return
+   */
+  public String get(String key) {
+    Jedis jedis = null;
+    String value;
+    try {
+      jedis = getJedis();
+      value = jedis.get(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return value;
+  }
+
+  /**
+   * 设置某个key的value
+   *
+   * @param key
+   * @param value
+   */
+  public void set(String key, String value) {
+    Jedis jedis = null;
+    try {
+      jedis = getJedis();
+      jedis.set(key, value);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+  }
+
+  /**
+   * 字符串后追加内容
+   *
+   * @param key           key
+   * @param appendContent 要追加的内容
+   */
+  public void append(String key, String appendContent) {
+    Jedis jedis = null;
+    try {
+      jedis = getJedis();
+      jedis.append(key, appendContent);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+  }
+
+  /**
+   * 返回key的value的长度
+   *
+   * @param key
+   * @return
+   */
+  public Long strlen(String key) {
+    Jedis jedis = null;
+    Long strLen = 0L;
+    try {
+      jedis = getJedis();
+      strLen = jedis.strlen(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return strLen;
+  }
+
+  /**
+   * value 加1 必
+   * 须是字符型数字
+   *
+   * @param key
+   * @return 增加后的值
+   */
+  public Long incr(String key) {
+    Jedis jedis = null;
+    Long incrResult = 0L;
+    try {
+      jedis = getJedis();
+      incrResult = jedis.incr(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return incrResult;
+  }
+
+  /**
+   * value 减1   必须是字符型数字
+   *
+   * @param key
+   * @return
+   */
+  public Long decr(String key) {
+    Jedis jedis = null;
+    Long decrResult = 0L;
+    try {
+      jedis = getJedis();
+      decrResult = jedis.decr(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return decrResult;
+  }
+
+  /**
+   * value 加increment
+   *
+   * @param key       key
+   * @param increment 加几
+   * @return
+   */
+  public Long incrby(String key, int increment) {
+    Jedis jedis = null;
+    Long incrByResult = 0L;
+    try {
+      jedis = getJedis();
+      incrByResult = jedis.incrBy(key, increment);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return incrByResult;
+  }
+
+  /**
+   * value 减increment
+   *
+   * @param key
+   * @param increment
+   * @return
+   */
+  public Long decrby(String key, int increment) {
+    Jedis jedis = null;
+    Long decrByResult = 0L;
+    try {
+      jedis = getJedis();
+      decrByResult = jedis.decrBy(key, increment);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return decrByResult;
+  }
+
+
+  /*########################  list(列表)的操作  #######################*/
+  //lpush rpush lpop rpop lrange lindex llen lset
+
+  /**
+   * 给某个key设置过期时间和value,成功返回OK
+   *
+   * @param key     key
+   * @param seconds 过期时间秒
+   * @param value   设置的值
+   * @return
+   */
+  public String setex(String key, int seconds, String value) {
+    Jedis jedis = null;
+    String result = null;
+    try {
+      jedis = getJedis();
+      result = jedis.setex(key, seconds, value);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return result;
+  }
+
+  /**
+   * 从左边向列表中添加值
+   *
+   * @param key key
+   * @param str 要添加的值
+   */
+  public void lpush(String key, String str) {
+    Jedis jedis = null;
+    try {
+      jedis = getJedis();
+      jedis.lpush(key, str);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+  }
+
+  /**
+   * 从右边向列表中添加值
+   *
+   * @param key key
+   * @param str 要添加的值
+   */
+  public void rpush(String key, String str) {
+    Jedis jedis = null;
+    try {
+      jedis = getJedis();
+      jedis.rpush(key, str);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+  }
+
+  /**
+   * 从左边取出一个列表中的值
+   *
+   * @param key
+   * @return
+   */
+  public String lpop(String key) {
+    Jedis jedis = null;
+    String lpop;
+    try {
+      jedis = getJedis();
+      lpop = jedis.lpop(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return lpop;
+  }
+
+  /**
+   * 从右边取出一个列表中的值
+   *
+   * @param key
+   * @return
+   */
+  public String rpop(String key) {
+    Jedis jedis = null;
+    String rpop;
+    try {
+      jedis = getJedis();
+      rpop = jedis.rpop(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return rpop;
+  }
+
+  /**
+   * 取出列表中指定范围内的值,0 到 -1 表示全部
+   *
+   * @param key
+   * @param startIndex
+   * @param endIndex
+   * @return
+   */
+  public List<String> lrange(String key, int startIndex, int endIndex) {
+    Jedis jedis = null;
+    List<String> result;
+    try {
+      jedis = getJedis();
+      result = jedis.lrange(key, startIndex, endIndex);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return result;
+  }
+
+  /**
+   * 返回某列表指定索引位置的值
+   *
+   * @param key   列表key
+   * @param index 索引位置
+   * @return
+   */
+  public String lindex(String key, int index) {
+    Jedis jedis = null;
+    String lindex;
+    try {
+      jedis = getJedis();
+      lindex = jedis.lindex(key, index);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return lindex;
+  }
+
+  /**
+   * 返回某列表的长度
+   *
+   * @param key
+   * @return
+   */
+  public Long llen(String key) {
+    Jedis jedis = null;
+    Long llen;
+    try {
+      jedis = getJedis();
+      llen = jedis.llen(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return llen;
+  }
+
+  /**
+   * 给某列表指定位置设置为指定的值
+   *
+   * @param key
+   * @param index
+   * @param str
+   */
+  public void lset(String key, Long index, String str) {
+    Jedis jedis = null;
+    try {
+      jedis = getJedis();
+      jedis.lset(key, index, str);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+  }
+
+  /**
+   * 对列表进行剪裁,保留指定闭区间的元素(索引位置也会重排)
+   *
+   * @param key        列表key
+   * @param startIndex 开始索引位置
+   * @param endIndex   结束索引位置
+   */
+  public void ltrim(String key, Integer startIndex, Integer endIndex) {
+    Jedis jedis = null;
+    try {
+      jedis = getJedis();
+      jedis.ltrim(key, startIndex, endIndex);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+  }
+
+  /**
+   * 从列表的左边阻塞弹出一个元素
+   *
+   * @param key     列表的key
+   * @param timeout 阻塞超时时间,0表示若没有元素就永久阻塞
+   * @return
+   */
+  public List<String> blpop(String key, Integer timeout) {
+    Jedis jedis = null;
+    List<String> valueList;
+    try {
+      jedis = getJedis();
+      valueList = jedis.blpop(timeout, key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return valueList;
+  }
+
+
+  /*########################  hash(哈希表)的操作  #######################*/
+  //hset hget hmset hmget hgetall hdel hkeys hvals hexists hincrby
+
+  /**
+   * 从列表的右边阻塞弹出一个元素
+   *
+   * @param key     列表的key
+   * @param timeout 阻塞超时时间,0表示若没有元素就永久阻塞
+   * @return
+   */
+  public List<String> brpop(String key, Integer timeout) {
+    Jedis jedis = null;
+    List<String> valueList;
+    try {
+      jedis = getJedis();
+      valueList = jedis.brpop(timeout, key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return valueList;
+  }
+
+  /**
+   * 给某个hash表设置一个键值对
+   *
+   * @param key
+   * @param field
+   * @param value
+   */
+  public void hset(String key, String field, String value) {
+    Jedis jedis = null;
+    try {
+      jedis = getJedis();
+      jedis.hset(key, field, value);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+  }
+
+  /**
+   * 取出某个hash表中某个field对应的value
+   *
+   * @param key   key
+   * @param field field
+   * @return
+   */
+  public String hget(String key, String field) {
+    Jedis jedis = null;
+    String hget;
+    try {
+      jedis = getJedis();
+      hget = jedis.hget(key, field);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return hget;
+  }
+
+  /**
+   * 某个hash表设置一个或多个键值对
+   *
+   * @param key
+   * @param kvMap
+   */
+  public void hmset(String key, Map<String, String> kvMap) {
+    Jedis jedis = null;
+    try {
+      jedis = getJedis();
+      jedis.hmset(key, kvMap);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+  }
+
+  /**
+   * 取出某个hash表中任意多个key对应的value的集合
+   *
+   * @param key
+   * @param fields
+   * @return
+   */
+  public List<String> hmget(String key, String... fields) {
+    Jedis jedis = null;
+    List<String> hmget;
+    try {
+      jedis = getJedis();
+      hmget = jedis.hmget(key, fields);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return hmget;
+  }
+
+  /**
+   * 取出某个hash表中所有的键值对
+   *
+   * @param key
+   * @return
+   */
+  public Map<String, String> hgetall(String key) {
+    Jedis jedis = null;
+    Map<String, String> kvMap;
+    try {
+      jedis = getJedis();
+      kvMap = jedis.hgetAll(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return kvMap;
+  }
+
+  /**
+   * 判断某个hash表中的某个key是否存在
+   *
+   * @param key
+   * @param field
+   * @return
+   */
+  public Boolean hexists(String key, String field) {
+    Jedis jedis = null;
+    Boolean exists;
+    try {
+      jedis = getJedis();
+      exists = jedis.hexists(key, field);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return exists;
+  }
+
+  /**
+   * 返回某个hash表中所有的key
+   *
+   * @param key
+   * @return
+   */
+  public Set<String> hkeys(String key) {
+    Jedis jedis = null;
+    Set<String> keys;
+    try {
+      jedis = getJedis();
+      keys = jedis.hkeys(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return keys;
+  }
+
+  /**
+   * 返回某个hash表中所有的value
+   *
+   * @param key
+   * @return
+   */
+  public List<String> hvals(String key) {
+    Jedis jedis = null;
+    List<String> hvals;
+    try {
+      jedis = getJedis();
+      hvals = jedis.hvals(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return hvals;
+  }
+
+  /**
+   * 删除某个hash表中的一个或多个键值对
+   *
+   * @param key
+   * @param fields
+   */
+  public void hdel(String key, String... fields) {
+    Jedis jedis = null;
+    try {
+      jedis = getJedis();
+      jedis.hdel(key, fields);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+  }
+
+  /*########################  set(集合)的操作  ###########################*/
+
+  /**
+   * 给某个hash表中的某个field的value增加多少
+   *
+   * @param key       hash表的key
+   * @param field     表中的某个field
+   * @param increment 增加多少
+   * @return
+   */
+  public Long hincrby(String key, String field, Long increment) {
+    Jedis jedis = null;
+    Long result;
+    try {
+      jedis = getJedis();
+      result = jedis.hincrBy(key, field, increment);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return result;
+  }
+
+  /**
+   * 往set集合中添加一个或多个元素
+   *
+   * @param key     key
+   * @param members 要添加的元素
+   * @return 添加成功的元素个数
+   */
+  public Long sadd(String key, String... members) {
+    Jedis jedis = null;
+    Long num;
+    try {
+      jedis = getJedis();
+      num = jedis.sadd(key, members);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return num;
+  }
+
+  /**
+   * 返回set集合中的所有元素,顺序与加入时的顺序一致
+   *
+   * @param key key
+   * @return
+   */
+  public Set<String> smembers(String key) {
+    Jedis jedis = null;
+    Set<String> members;
+    try {
+      jedis = getJedis();
+      members = jedis.smembers(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+  /**
+   * 判断集合中是否存在某个元素
+   *
+   * @param key    key
+   * @param member 某个元素
+   * @return true存在,false不存在
+   */
+  public Boolean sismember(String key, String member) {
+    Jedis jedis = null;
+    Boolean isMember;
+    try {
+      jedis = getJedis();
+      isMember = jedis.sismember(key, member);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return isMember;
+  }
+
+  /**
+   * 返回set集合的长度
+   *
+   * @param key key
+   * @return
+   */
+  public Long scard(String key) {
+    Jedis jedis = null;
+    Long len;
+    try {
+      jedis = getJedis();
+      len = jedis.scard(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return len;
+  }
+
+  /**
+   * 删除set集合中指定的一个或多个元素
+   *
+   * @param key
+   * @param members 要删除的元素
+   * @return 删除成功的元素个数
+   */
+  public Long srem(String key, String... members) {
+    Jedis jedis = null;
+    Long num;
+    try {
+      jedis = getJedis();
+      num = jedis.srem(key, members);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return num;
+  }
+
+  /**
+   * 将key1中的元素key1Member移动到key2中
+   *
+   * @param key1       来源集合key
+   * @param key2       目的地集合key
+   * @param key1Member key1中的元素
+   * @return 1成功,0失败
+   */
+  public Long smove(String key1, String key2, String key1Member) {
+    Jedis jedis = null;
+    Long num;
+    try {
+      jedis = getJedis();
+      num = jedis.smove(key1, key2, key1Member);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return num;
+  }
+
+  /**
+   * 随机查询返回集合中的指定个数的元素(若count为负数,返回的元素可能会重复)
+   *
+   * @param key   key
+   * @param count 要查询返回的元素个数
+   * @return 元素list集合
+   */
+  public List<String> srandmember(String key, int count) {
+    Jedis jedis = null;
+    List<String> members;
+    try {
+      jedis = getJedis();
+      members = jedis.srandmember(key, count);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+  /**
+   * 从set集合中随机弹出指定个数个元素
+   *
+   * @param key   key
+   * @param count 要弹出的个数
+   * @return 随机弹出的元素
+   */
+  public Set<String> spop(String key, int count) {
+    Jedis jedis = null;
+    Set<String> members;
+    try {
+      jedis = getJedis();
+      members = jedis.spop(key, count);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+  /**
+   * 求交集,返回多个set集合相交的部分
+   *
+   * @param setKeys 多个set集合的key
+   * @return 相交的元素集合
+   */
+  public Set<String> sinter(String... setKeys) {
+    Jedis jedis = null;
+    Set<String> members;
+    try {
+      jedis = getJedis();
+      members = jedis.sinter(setKeys);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+  /**
+   * 求并集,求几个set集合的并集(因为set中不会有重复的元素,合并后的集合也不会有重复的元素)
+   *
+   * @param setKeys 多个set的key
+   * @return 合并后的集合
+   */
+  public Set<String> sunion(String... setKeys) {
+    Jedis jedis = null;
+    Set<String> members;
+    try {
+      jedis = getJedis();
+      members = jedis.sunion(setKeys);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+
+  /*########################  zset(有序集合)的操作  #######################*/
+
+  /**
+   * 求差集,求几个集合之间的差集
+   *
+   * @param setKeys 多个set的key
+   * @return 差集
+   */
+  public Set<String> sdiff(String... setKeys) {
+    Jedis jedis = null;
+    Set<String> members;
+    try {
+      jedis = getJedis();
+      members = jedis.sdiff(setKeys);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+  /**
+   * 添加一个元素到zset
+   *
+   * @param key    key
+   * @param score  元素的分数
+   * @param member 元素
+   * @return 成功添加的元素个数
+   */
+  public Long zadd(String key, double score, String member) {
+    Jedis jedis = null;
+    Long num;
+    try {
+      jedis = getJedis();
+      num = jedis.zadd(key, score, member);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return num;
+  }
+
+  /**
+   * 添加一个或多个元素到zset
+   *
+   * @param key          key
+   * @param memberScores 元素和分数的map集合,map的k是元素,v是分数
+   * @return 成功添加的元素个数
+   */
+  public Long zadd(String key, Map<String, Double> memberScores) {
+    Jedis jedis = null;
+    Long num;
+    try {
+      jedis = getJedis();
+      num = jedis.zadd(key, memberScores);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return num;
+  }
+
+  /**
+   * 查询指定闭区间的元素(根据分数升序)
+   * (0,-1表示全部)
+   *
+   * @param key   zset的key
+   * @param start 开始区间
+   * @param end   结束区间
+   * @return 元素集合
+   */
+  public Set<String> zrange(String key, long start, long end) {
+    Jedis jedis = null;
+    Set<String> ascResult;
+    try {
+      jedis = getJedis();
+      ascResult = jedis.zrange(key, start, end);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return ascResult;
+  }
+
+  /**
+   * 查询指定闭区间的元素,带着分数
+   * (0,-1表示全部)
+   *
+   * @param key   zset的key
+   * @param start 开始区间
+   * @param end   结束区间
+   * @return 元素集合 格式为:
+   * [{"element":"a","score":10.0,"binaryElement":"YQ=="},{"element":"b","score":20.0,"binaryElement":"Yg=="}]
+   */
+  public Set<Tuple> zrangeWithScores(String key, long start, long end) {
+    Jedis jedis = null;
+    Set<Tuple> ascResult;
+    try {
+      jedis = getJedis();
+      ascResult = jedis.zrangeWithScores(key, start, end);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return ascResult;
+  }
+
+  /**
+   * 查询指定索引闭区间的元素(根据分数降序)
+   * (0,-1表示全部)
+   *
+   * @param key   zset的key
+   * @param start 开始区间
+   * @param end   结束区间
+   * @return 元素集合
+   */
+  public Set<String> zrevrange(String key, long start, long end) {
+    Jedis jedis = null;
+    Set<String> descResult;
+    try {
+      jedis = getJedis();
+      descResult = jedis.zrevrange(key, start, end);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return descResult;
+  }
+
+  /**
+   * 查询指定索引闭区间的元素,带着分数(根据分数降序)
+   * (0,-1表示全部)
+   *
+   * @param key   zset的key
+   * @param start 开始区间
+   * @param end   结束区间
+   * @return 元素集合 格式为:
+   * [{"element":"b","score":20.0,"binaryElement":"Yg=="},{"element":"a","score":10.0,"binaryElement":"YQ=="}]
+   */
+  public Set<Tuple> zrevrangeWithScores(String key, long start, long end) {
+    Jedis jedis = null;
+    Set<Tuple> descResult;
+    try {
+      jedis = getJedis();
+      descResult = jedis.zrevrangeWithScores(key, start, end);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return descResult;
+  }
+
+  /**
+   * 返回有序集合(zset)中的元素个数
+   *
+   * @param key key
+   * @return 个数
+   */
+  public Long zcard(String key) {
+    Jedis jedis = null;
+    Long count;
+    try {
+      jedis = getJedis();
+      count = jedis.zcard(key);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return count;
+  }
+
+  /**
+   * 返回指定分数区间的元素个数(闭区间)
+   *
+   * @param key        key
+   * @param startScore 开始分数
+   * @param endScore   结束分数
+   * @return 个数
+   */
+  public Long zcount(String key, Long startScore, Long endScore) {
+    Jedis jedis = null;
+    Long count;
+    try {
+      jedis = getJedis();
+      count = jedis.zcount(key, startScore, endScore);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return count;
+  }
+
+  /**
+   * 返回某元素在集合中的排名(根据分数降序排列时)
+   *
+   * @param key    key
+   * @param member 集合中的元素
+   * @return 排名,从0开始
+   */
+  public Long zrevrank(String key, String member) {
+    Jedis jedis = null;
+    Long count;
+    try {
+      jedis = getJedis();
+      count = jedis.zrevrank(key, member);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return count;
+  }
+
+  /**
+   * 返回某元素在集合中的排名(根据分数升序排列时)
+   *
+   * @param key    key
+   * @param member 集合中的元素
+   * @return 排名,从0开始
+   */
+  public Long zrank(String key, String member) {
+    Jedis jedis = null;
+    Long count;
+    try {
+      jedis = getJedis();
+      count = jedis.zrank(key, member);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return count;
+  }
+
+  /**
+   * 升序查询指定分数闭区间的元素
+   *
+   * @param key key
+   * @param min 最小分数
+   * @param max 最大分数
+   * @return 元素集合
+   */
+  public Set<String> zrangeByScore(String key, double min, double max) {
+    Jedis jedis = null;
+    Set<String> members;
+    try {
+      jedis = getJedis();
+      members = jedis.zrangeByScore(key, min, max);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+  /**
+   * 升序查询指定分数闭区间的元素,并指定偏移量
+   *
+   * @param key    key
+   * @param min    最小分数
+   * @param max    最大分数
+   * @param offset 偏移量
+   * @param size   数量
+   * @return 元素集合
+   */
+  public Set<String> zrangeByScore(String key, double min, double max, int offset, int size) {
+    Jedis jedis = null;
+    Set<String> members;
+    try {
+      jedis = getJedis();
+      members = jedis.zrangeByScore(key, min, max, offset, size);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+  /**
+   * 升序查询指定分数闭区间的元素,带着分数
+   *
+   * @param key key
+   * @param min 最小分数
+   * @param max 最大分数
+   * @return 元素集合
+   */
+  public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max) {
+    Jedis jedis = null;
+    Set<Tuple> members;
+    try {
+      jedis = getJedis();
+      members = jedis.zrangeByScoreWithScores(key, min, max);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+  /**
+   * 升序查询指定分数闭区间的元素,并指定偏移量,带着分数
+   *
+   * @param key    key
+   * @param min    最小分数
+   * @param max    最大分数
+   * @param offset 偏移量
+   * @param size   数量
+   * @return 元素集合
+   */
+  public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max, int offset, int size) {
+    Jedis jedis = null;
+    Set<Tuple> members;
+    try {
+      jedis = getJedis();
+      members = jedis.zrangeByScoreWithScores(key, min, max, offset, size);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+  /**
+   * 降序查询指定分数闭区间的元素
+   *
+   * @param key key
+   * @param max 最大分数
+   * @param min 最小分数
+   * @return 元素集合
+   */
+  public Set<String> zrevrangebyscore(String key, double max, double min) {
+    Jedis jedis = null;
+    Set<String> members;
+    try {
+      jedis = getJedis();
+      members = jedis.zrevrangeByScore(key, max, min);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+  /**
+   * 降序查询指定分数闭区间的元素,并指定偏移量
+   *
+   * @param key key
+   * @param max 最大分数
+   * @param min 最小分数
+   * @return 元素集合
+   */
+  public Set<String> zrevrangebyscore(String key, double max, double min, int offset, int size) {
+    Jedis jedis = null;
+    Set<String> members;
+    try {
+      jedis = getJedis();
+      members = jedis.zrevrangeByScore(key, max, min, offset, size);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+  /**
+   * 降序查询指定分数闭区间的元素,并带着分数
+   *
+   * @param key key
+   * @param min 最小分数
+   * @param max 最大分数
+   * @return 元素集合
+   */
+  public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min) {
+    Jedis jedis = null;
+    Set<Tuple> members;
+    try {
+      jedis = getJedis();
+      members = jedis.zrevrangeByScoreWithScores(key, max, min);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+  /**
+   * 降序查询指定分数闭区间的元素,并指定偏移量,带着分数
+   *
+   * @param key    key
+   * @param min    最小分数
+   * @param max    最大分数
+   * @param offset 偏移量
+   * @param size   数量
+   * @return 元素集合
+   */
+  public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, int offset, int size) {
+    Jedis jedis = null;
+    Set<Tuple> members;
+    try {
+      jedis = getJedis();
+      members = jedis.zrevrangeByScoreWithScores(key, min, max, offset, size);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return members;
+  }
+
+  /**
+   * 有序集合中指定删除一或多个元素
+   *
+   * @param key
+   * @param member 元素
+   * @return 删除成功的个数
+   */
+  public Long zrem(String key, String... member) {
+    Jedis jedis = null;
+    Long num;
+    try {
+      jedis = getJedis();
+      num = jedis.zrem(key, member);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return num;
+  }
+
+  /**
+   * 分数升序排名时,删除指定索引区间的元素
+   *
+   * @param key   key
+   * @param start 开始索引
+   * @param end   结束索引
+   * @return 删除成功的个数
+   */
+  public Long zremrangebyrank(String key, long start, long end) {
+    Jedis jedis = null;
+    Long num;
+    try {
+      jedis = getJedis();
+      num = jedis.zremrangeByRank(key, start, end);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return num;
+  }
+
+  /**
+   * 分数升序排名时,删除指定分数区间的元素
+   *
+   * @param key key
+   * @param min 最小分数
+   * @param max 最大分数
+   * @return 删除成功的个数
+   */
+  public Long zremrangeByScore(String key, long min, long max) {
+    Jedis jedis = null;
+    Long num;
+    try {
+      jedis = getJedis();
+      num = jedis.zremrangeByScore(key, min, max);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return num;
+  }
+
+  /**
+   * 查询有序集合中某元素的分数
+   *
+   * @param key    key
+   * @param member 元素
+   * @return 删除成功的个数
+   */
+  public Double zscore(String key, String member) {
+    Jedis jedis = null;
+    Double score;
+    try {
+      jedis = getJedis();
+      score = jedis.zscore(key, member);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
+    }
+    return score;
+  }
+
+  /**
+   * 给有序集合中某元素的分数增加(正数)或减少(负数)
+   *
+   * @param key    key
+   * @param score  分数
+   * @param member 元素
+   * @return 新的分数
+   */
+  public Double zincrby(String key, double score, String member) {
+    Jedis jedis = null;
+    Double newScore;
+    try {
+      jedis = getJedis();
+      newScore = jedis.zincrby(key, score, member);
+    } finally {
+      if (jedis != null) {
+        jedis.close();
+      }
     }
+    return newScore;
+  }
 }