| | |
| | | package com.yssh.controller; |
| | | |
| | | import com.yssh.entity.Qxsh; |
| | | import com.yssh.utils.CacheUtils; |
| | | import com.yssh.utils.DateUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.yssh.service.IWarningAnalyseService; |
| | | import com.yssh.service.WarningAnalyseService; |
| | | import com.yssh.utils.Result; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | @Api(tags = "告警分析") |
| | | @RequestMapping("/warning") |
| | | @RestController |
| | | @SuppressWarnings("rawtypes") |
| | | public class WarningAnalyseController { |
| | | |
| | | @Autowired |
| | | private IWarningAnalyseService warningService; |
| | | |
| | | private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); |
| | | @Resource |
| | | private WarningAnalyseService warningService; |
| | | |
| | | /** |
| | | * 1.查询当前时间的所有点位value值(以47.dat查询即可) |
| | |
| | | public Result locationDataChange() { |
| | | //return Result.OK(warningService.selectEachLocationDataChange()); |
| | | |
| | | String key = dateFormat.format(new Date()) + "_local"; |
| | | String key = DateUtils.getYyyyMmDd(new Date()) + "_local"; |
| | | Object obj = CacheUtils.get(key); |
| | | Map<String, List<Double>> map; |
| | | |
| | | if (null != obj) { |
| | | map = (Map<String, List<Double>>) obj; |
| | | } else { |
| | | map = warningService.selectEachLocationDataChange(); |
| | | if (null != map && map.size() > 0) { |
| | | CacheUtils.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); |
| | | } |
| | |
| | | public Result monthTop10() { |
| | | //return Result.OK(warningService.selectThisMonthLocationValueDataTop10()); |
| | | |
| | | String key = dateFormat.format(new Date()) + "_top10"; |
| | | Object obj = CacheUtils.get(key); |
| | | List<Map<String, Object>> list; |
| | | //String key = dateFormat.format(new Date()) + "_top10"; |
| | | //Object obj = CacheUtils.get(key); |
| | | List<Qxsh> list; |
| | | |
| | | if (null != obj) { |
| | | list = (List<Map<String, Object>>) obj; |
| | | } else { |
| | | list = warningService.selectThisMonthLocationValueDataTop10(); |
| | | if (null != list && list.size() > 0) { |
| | | CacheUtils.put(key, 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); |
| | | } |