添加了查询一年中每月的火情数量

This commit is contained in:
XinYi Song 2022-02-16 10:14:17 +08:00
parent 52ec30f940
commit ca53051967
2 changed files with 27 additions and 1 deletions

View File

@ -74,7 +74,22 @@ public class FireController {
public String selectEveryDayCount(@RequestParam("beginTime") String beginTime,@RequestParam("endTime") String endTime){ public String selectEveryDayCount(@RequestParam("beginTime") String beginTime,@RequestParam("endTime") String endTime){
List<Map<String, Object>> maps = equipmentDao.selectEveryDayCount(beginTime, endTime); List<Map<String, Object>> maps = equipmentDao.selectEveryDayCount(beginTime, endTime);
if(maps == null || maps.size() == 0){ if(maps == null || maps.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"该月暂时唯有火情信息!",locale); 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); return outputEncapsulationObject(PromptMessageEnum.SUCCESS,maps,locale);
} }

View File

@ -67,4 +67,15 @@ public interface EquipmentDao extends JpaRepository<Equipment,Long> {
"from equipment e,fire f where f.alarm_date BETWEEN ?1 AND ?2 " + "from equipment e,fire f where f.alarm_date BETWEEN ?1 AND ?2 " +
"AND e.equipment_code = f.device_code GROUP BY LEFT(f.alarm_date,10),e.street",nativeQuery = true) "AND e.equipment_code = f.device_code GROUP BY LEFT(f.alarm_date,10),e.street",nativeQuery = true)
List<Map<String,Object>> selectEveryDayCount(String beginTime, String endTime); List<Map<String,Object>> selectEveryDayCount(String beginTime, String endTime);
/**
* 查询一年中每个月的各个街道的火情数量
* @param beginTime
* @param endTime
* @return
*/
@Query(value = "select LEFT(f.alarm_date,7) AS data,e.street as street,count(f.id) AS firenumber " +
"from equipment e,fire f where f.alarm_date BETWEEN ?1 AND ?2 " +
"AND e.equipment_code = f.device_code GROUP BY LEFT(f.alarm_date,7),e.street",nativeQuery = true)
List<Map<String,Object>> selectEveryMonthCount(String beginTime, String endTime);
} }