燕山石化溯源三维电子沙盘-【后端】-服务
13693261870
2023-06-09 498718ad129e8a9010e6f2af2fde2f9d4508fd32
src/main/java/com/yssh/controller/WarningAnalyseController.java
@@ -1,5 +1,7 @@
package com.yssh.controller;
import com.yssh.entity.Qxsh;
import com.yssh.utils.CacheUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -20,7 +22,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Api(tags="告警分析")
@Api(tags = "告警分析")
@RequestMapping("/warning")
@RestController
@SuppressWarnings("rawtypes")
@@ -29,11 +31,7 @@
    @Autowired
    private IWarningAnalyseService warningService;
    private static ConcurrentHashMap<String, Object> cache = new ConcurrentHashMap<>(5);
    private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
    public static final long CACHE_HOLD_TIME_24H = 24 * 60 * 60 * 1000L;
    /**
     * 1.查询当前时间的所有点位value值(以47.dat查询即可)
@@ -78,15 +76,18 @@
        //return Result.OK(warningService.selectEachLocationDataChange());
        String key = dateFormat.format(new Date()) + "_local";
        Object obj = CacheUtils.get(key);
        Map<String, List<Double>> map;
        if (cache.containsKey(key)) {
            map = (Map<String, List<Double>>) cache.get(key);
        } else {
            map = warningService.selectEachLocationDataChange();
            if (null != map && map.size() > 0) {
                cache.put(key, map);
            }
        }
        //if (null != obj) {
        //    map = (Map<String, List<Double>>) obj;
        //} else {
            //map = warningService.selectEachLocationDataChange();
            map = warningService.select3Hours();
        //    if (null != map && map.size() > 0) {
        //        CacheUtils.put(key, map);
        //    }
        //}
        return Result.ok(map);
    }
@@ -97,18 +98,21 @@
    public Result monthTop10() {
        //return Result.OK(warningService.selectThisMonthLocationValueDataTop10());
        String key = dateFormat.format(new Date()) + "_top10";
        List<Map<String, Object>> list;
        if (cache.containsKey(key)) {
            list = (List<Map<String, Object>>) cache.get(key);
        } else {
            list = warningService.selectThisMonthLocationValueDataTop10();
            if (null != list && list.size() > 0) {
                cache.put(key, list);
            }
        }
        //String key = dateFormat.format(new Date()) + "_top10";
        //Object obj = CacheUtils.get(key);
        List<Qxsh> list;
        return Result.OK(list);
        //if (null != obj) {
        //    list = (List<Qxsh>) obj;
        //} else {
            //list = warningService.selectThisMonthLocationValueDataTop10();
            list = warningService.selectMonthTop10();
        //    if (null != list && list.size() > 0) {
        //        CacheUtils.put(key, list);
        //    }
        //}
        return Result.ok(list);
    }
    @ApiOperationSupport(order = 5)