diff --git a/src/main/java/com/xkrs/controller/FireController.java b/src/main/java/com/xkrs/controller/FireController.java index f2b8e77..68b59fd 100644 --- a/src/main/java/com/xkrs/controller/FireController.java +++ b/src/main/java/com/xkrs/controller/FireController.java @@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.transaction.Transactional; +import java.math.BigInteger; +import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; @@ -116,4 +118,22 @@ public class FireController { fireDao.updateFireState(alarmCode); return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功!",locale); } + + /** + * 查询已处理和未处理的火点的数量 + * @param street + * @param month + * @return + */ + @GetMapping("/selectProcessedNum") + public String selectProcessedNum(@RequestParam("street") String street,@RequestParam("month") String month){ + Map stringObjectMap = fireDao.selectProcessed(street, month); + BigInteger processed = (BigInteger) stringObjectMap.get("processed"); + Map stringObjectMap1 = fireDao.selectNotProcessed(street, month); + BigInteger notprocessed = (BigInteger) stringObjectMap1.get("notprocessed"); + Map map = new HashMap<>(3); + map.put("processed",processed); + map.put("notProcessed",notprocessed); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale); + } } diff --git a/src/main/java/com/xkrs/dao/FireDao.java b/src/main/java/com/xkrs/dao/FireDao.java index 214ebd7..04eb123 100644 --- a/src/main/java/com/xkrs/dao/FireDao.java +++ b/src/main/java/com/xkrs/dao/FireDao.java @@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Component; import java.util.List; +import java.util.Map; /** * @Author: XinYi Song @@ -53,4 +54,26 @@ public interface FireDao extends JpaRepository, JpaSpecificationExecu @Modifying(clearAutomatically=true) @Query(value = "update fire set fire_state = '1' where alarm_code = ?",nativeQuery = true) void updateFireState(String alarmDate); + + /** + * 查询未处理的火情的数量 + * @param street + * @param month + * @return + */ + @Query(value = "select count(f.id) as notprocessed from equipment e,fire f where e.street = ?1 and " + + "f.device_code = e.equipment_code and f.alarm_date like concat('%',?2,'%') " + + "and f.fire_state = '0'",nativeQuery = true) + Map selectNotProcessed(String street, String month); + + /** + * 查询已处理的火情的数量 + * @param street + * @param month + * @return + */ + @Query(value = "select count(f.id) as processed from equipment e,fire f where e.street = ?1 and " + + "f.device_code = e.equipment_code and f.alarm_date like concat('%',?2,'%') " + + "and f.fire_state = '1'",nativeQuery = true) + Map selectProcessed(String street, String month); }