From e8613bbdd0596c61003ecaaa36fbc637016a40dd Mon Sep 17 00:00:00 2001 From: XinYi Song <2037158277@qq.com> Date: Thu, 24 Feb 2022 17:37:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=B7=B2=E5=A4=84=E7=90=86=E5=92=8C=E6=9C=AA=E5=A4=84=E7=90=86?= =?UTF-8?q?=E7=9A=84=E7=81=AB=E7=82=B9=E7=9A=84=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xkrs/controller/FireController.java | 20 ++++++++++++++++ src/main/java/com/xkrs/dao/FireDao.java | 23 +++++++++++++++++++ 2 files changed, 43 insertions(+) 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); }