| | |
| | | package com.moral.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.moral.common.bean.ResultBean; |
| | | import com.moral.entity.Alarm; |
| | | import com.moral.entity.Device; |
| | | import com.moral.entity.Sensor; |
| | | import com.moral.entity.alarm.AlarmConfig; |
| | | import com.moral.entity.alarm.AlarmConfigValue; |
| | | import com.moral.service.AlarmConfigService; |
| | | import com.moral.service.DeviceService; |
| | | import com.moral.service.HistoryService; |
| | | import com.moral.service.SensorService; |
| | | import com.moral.entity.charts.TimeUnits; |
| | | import com.moral.service.*; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("alarm") |
| | |
| | | HistoryService historyService; |
| | | @Resource |
| | | AlarmConfigService alarmConfigService; |
| | | @Resource |
| | | AlarmService alarmService; |
| | | @RequestMapping(value = "/count-by-times", method = RequestMethod.GET) |
| | | public ResultBean<List<Map>> countByTimes(Date start, Date end,@RequestParam(value = "timeUnits")Optional<TimeUnits> timeUnits){ |
| | | return new ResultBean<>(alarmService.countByTimes(start,end,timeUnits.isPresent()?timeUnits.get():null)); |
| | | } |
| | | /** |
| | | * |
| | | * @param alarm |
| | |
| | | if(!CollectionUtils.isEmpty(device.getOrganizationIds())){ |
| | | List<Sensor> sensorList = sensorService.queryByVersionId(device.getDeviceVersionId()).getData(); |
| | | String data = historyService.queryValueByMacAndTime(alarm.getMac(),alarm.getTime()); |
| | | AlarmConfigValue alarmConfigValue = alarmConfigService.queryValueByOrganizationId(device.getOrganizationIds().get(0)).get(); |
| | | AlarmConfigValue alarmConfigValue |
| | | = alarmConfigService |
| | | .queryValueByOrganizationId(device.getOrganizationIds().get(0)) |
| | | .get().getValue(); |
| | | if(device!=null |
| | | &&!CollectionUtils.isEmpty(sensorList) |
| | | &&!StringUtils.isEmpty(data) |