添加了查询已处理和未处理的火点的数量

This commit is contained in:
XinYi Song 2022-02-24 17:37:41 +08:00
parent cde7338d33
commit e8613bbdd0
2 changed files with 43 additions and 0 deletions

View File

@ -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<String, Object> stringObjectMap = fireDao.selectProcessed(street, month);
BigInteger processed = (BigInteger) stringObjectMap.get("processed");
Map<String, Object> stringObjectMap1 = fireDao.selectNotProcessed(street, month);
BigInteger notprocessed = (BigInteger) stringObjectMap1.get("notprocessed");
Map<String,Object> map = new HashMap<>(3);
map.put("processed",processed);
map.put("notProcessed",notprocessed);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale);
}
}

View File

@ -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<Fire,Long>, 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<String,Object> 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<String,Object> selectProcessed(String street, String month);
}