¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.format.annotation.DateTimeFormat; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | 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; |
| | | |
| | | @Api(tags = "åè¦åæ") |
| | | @RequestMapping("/warning") |
| | | @RestController |
| | | @SuppressWarnings("rawtypes") |
| | | public class WarningAnalyseController { |
| | | @Resource |
| | | private WarningAnalyseService warningService; |
| | | |
| | | /** |
| | | * 1.æ¥è¯¢å½åæ¶é´çææç¹ä½valueå¼ï¼ä»¥47.datæ¥è¯¢å³å¯ï¼ |
| | | * 2.çé大äºyssh_bjyjä¸çjcbjåæ®µçå¼ è¿åid+ç»çº¬åº¦+value |
| | | */ |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "è·å宿¶æ¥è¦", notes = "è·å宿¶æ¥è¦åææ°æ®") |
| | | @GetMapping("/runAlarm") |
| | | public Result alarmAnalyse() { |
| | | return Result.OK(warningService.getRunTimeAlarmAnalyse()); |
| | | } |
| | | |
| | | /** |
| | | * 1.æ¥è¯¢å½åæ¶é´çææç¹ä½valueå¼ï¼ä»¥47.datæ¥è¯¢å³å¯ï¼ |
| | | * 2.çé大äºyssh_bjyjä¸çjcyjåæ®µçå¼ è¿åid+ç»çº¬åº¦+value |
| | | */ |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "è·å宿¶é¢è¦", notes = "è·å宿¶é¢è¦åææ°æ®") |
| | | @GetMapping("/runWarning") |
| | | public Result warningAnalyse() { |
| | | return Result.OK(warningService.getRunTimeWarningAnalyse()); |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "æ¬æé¢è¦ãæ¥è¦ç»è®¡", notes = "æ¬æé¢è¦ãæ¥è¦ç»è®¡ï¼è¿ååæ°alarmNumber对åºå¼ä¸ºæ¬ææ¥è¦æ°æ®éï¼åæ°warningNumber对åºå¼ä¸ºæ¬æé¢è¦æ°æ®é") |
| | | @GetMapping("/monthCount") |
| | | public Result thisMonthCount() { |
| | | return Result.OK(warningService.countThisMonthAlarmAndWarning()); |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "æ¯æ¥é¢è¦ãæ¥è¦æ°éååè¶å¿", notes = "ä¸å¨æ¯æ¥é¢è¦ãæ¥è¦æ°éç»è®¡ï¼è¿ååæ°alarmDayCount为ä¸å¨æ¯æ¥æ¥è¦ç»è®¡æ°éå表ï¼åæ°warningDayCount为ä¸å¨æ¯æ¥é¢è¦ç»è®¡æ°éå表") |
| | | @GetMapping("/everydayCount") |
| | | public Result everydayCount() { |
| | | return Result.OK(warningService.countEverydayAlarmAndWarning()); |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "ä¸å°æ¶çæµç«ç¹æ°æ®ååè¶å¿", notes = "è¿åå¼ä¸ºä¸å°æ¶çæµç«ç¹çæµæ°æ®ï¼è¿åå¼ä¸ºmapéåï¼å
¶ä¸key为ç«ç¹åç§°ï¼value为listéåï¼ä¿åæ¯å¤©çæµæ°å¼æ°æ®") |
| | | @GetMapping("/locationDataChange") |
| | | public Result locationDataChange() { |
| | | //return Result.OK(warningService.selectEachLocationDataChange()); |
| | | |
| | | 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(); |
| | | map = warningService.select3Hours(); |
| | | // if (null != map && map.size() > 0) { |
| | | // CacheUtils.put(key, map); |
| | | // } |
| | | //} |
| | | |
| | | return Result.ok(map); |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "è·åæ¬æçæµå¤§æ°æ®ç«ç¹æå¤§å¼TOP10", notes = "è·åæ¬æçæµå¤§æ°æ®ç«ç¹æå¤§å¼TOP10æ°éå表") |
| | | @GetMapping("/monthTop10") |
| | | public Result monthTop10() { |
| | | //return Result.OK(warningService.selectThisMonthLocationValueDataTop10()); |
| | | |
| | | //String key = dateFormat.format(new Date()) + "_top10"; |
| | | //Object obj = CacheUtils.get(key); |
| | | List<Qxsh> 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) |
| | | @ApiOperation(value = "æ ¹æ®æ¶é´è·åæ¥è¦åé¢è¦ä¿¡æ¯", notes = "æ ¹æ®æ¶é´è·åæ¥è¦åé¢è¦ä¿¡æ¯") |
| | | @GetMapping("/getAlarmAndWarnByTime") |
| | | public Result getAlarmAndWarnByTime( |
| | | @RequestParam(value = "begin", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date begin, |
| | | @RequestParam(value = "end", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date end) { |
| | | if (null == begin || null == end) { |
| | | return Result.error(null); |
| | | } |
| | | |
| | | if (begin.getTime() > end.getTime()) { |
| | | Date tmp = end; |
| | | begin = end; |
| | | end = tmp; |
| | | } |
| | | |
| | | return Result.OK(warningService.getAlarmAndWarnByTime(begin, end)); |
| | | } |
| | | } |