120 lines
3.9 KiB
Java
120 lines
3.9 KiB
Java
package com.xkrs.controller;
|
|
|
|
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
|
import com.xkrs.dao.EquipmentDao;
|
|
import com.xkrs.dao.FireDao;
|
|
import com.xkrs.model.entity.Fire;
|
|
import com.xkrs.service.FireService;
|
|
import com.xkrs.util.Query;
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.transaction.Transactional;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
|
|
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
|
|
|
/**
|
|
* @Author: XinYi Song
|
|
* @Date: 2022/2/11 9:03
|
|
*/
|
|
@RestController
|
|
public class FireController {
|
|
|
|
@Resource
|
|
private FireService fireService;
|
|
|
|
@Resource
|
|
private EquipmentDao equipmentDao;
|
|
|
|
@Resource
|
|
private FireDao fireDao;
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
/**
|
|
* 根据设备编号获取火情信息
|
|
* @param code
|
|
* @return
|
|
*/
|
|
@GetMapping("/getFireInformation")
|
|
public String getFireInformation(@RequestParam("code") String code){
|
|
return fireService.getFireInformation(code);
|
|
}
|
|
|
|
/**
|
|
* 根据设备编码和时间段查询火情信息
|
|
* @param code
|
|
* @param startTime
|
|
* @param endTime
|
|
* @return
|
|
*/
|
|
@GetMapping("/selectFireBetweenTime")
|
|
public String selectFireBetweenTime(@RequestParam("code") String code, @RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime){
|
|
return fireService.selectFireBetweenTime(code,startTime,endTime);
|
|
}
|
|
|
|
/**
|
|
* 查询最新的300条火情信息
|
|
* @return
|
|
*/
|
|
@GetMapping("/findThreeHundredData")
|
|
public String findThreeHundredData(){
|
|
return fireService.findThreeHundredData();
|
|
}
|
|
|
|
/**
|
|
* 查询一个月中每一天各个街道的火情数量
|
|
* @param beginTime
|
|
* @param endTime
|
|
* @return
|
|
*/
|
|
@GetMapping("/selectEveryDayCount")
|
|
public String selectEveryDayCount(@RequestParam("beginTime") String beginTime,@RequestParam("endTime") String endTime){
|
|
List<Map<String, Object>> maps = equipmentDao.selectEveryDayCount(beginTime, endTime);
|
|
if(maps == null || maps.size() == 0){
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"该月暂时没有火情信息!",locale);
|
|
}
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,maps,locale);
|
|
}
|
|
|
|
/**
|
|
* 查询一年中每个月的各个街道的火情数量
|
|
* @param beginTime
|
|
* @param endTime
|
|
* @return
|
|
*/
|
|
@GetMapping("/selectEveryMonthCount")
|
|
public String selectEveryMonthCount(@RequestParam("beginTime") String beginTime,@RequestParam("endTime") String endTime){
|
|
List<Map<String, Object>> maps = equipmentDao.selectEveryMonthCount(beginTime, endTime);
|
|
if(maps == null || maps.size() == 0){
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"该年暂时没有火情信息!",locale);
|
|
}
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,maps,locale);
|
|
}
|
|
|
|
/**
|
|
* 修改火点状态
|
|
* @param map
|
|
* @return
|
|
*/
|
|
@Transactional(rollbackOn = Exception.class)
|
|
@PostMapping("/updateFireState")
|
|
public String updateFireState(@RequestBody Map map){
|
|
String alarmCode = (String) map.get("alarmCode");
|
|
Fire byAlarmCode = fireDao.findByAlarmCode(alarmCode);
|
|
if(byAlarmCode != null){
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"火情编码错误,请检查!",locale);
|
|
}
|
|
if("1".equals(byAlarmCode.getFireState())){
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"该火情已处理!",locale);
|
|
}
|
|
fireDao.updateFireState(alarmCode);
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功!",locale);
|
|
}
|
|
}
|