Pārlūkot izejas kodu

查询使用卫生间信息

chejianzheng 3 mēneši atpakaļ
vecāks
revīzija
9fb2782264

+ 1 - 1
src/main/java/com/admin/alarm_event/StayTime.java

@@ -35,7 +35,7 @@ public class StayTime extends SuperVO {
     private String stay_time;
 
     @ApiModelProperty(value = "事件类型,0:一般滞留事件,1:马桶滞留事件")
-    private String type;
+    private Integer type;
 
     private List<StayTime> toiletList;
 

+ 14 - 12
src/main/java/com/wxxcx/index/WxxcxIndexController.java

@@ -529,7 +529,7 @@ public class WxxcxIndexController<AesException extends Throwable> {
      */
     @GetMapping("/devListWithTimes")
     @ApiOperation(value = "查询设备列表")
-    public R devListWithTimes(String user_openid, String keyword, Integer zt) throws IOException {
+    public R devListWithTimes(String user_openid, String keyword, Integer zt, String time) throws IOException {
         R r = JSONUtil.getSuccessMsg(null);
         String con = "";
         if (StringUtils.isNotEmpty(keyword)) {
@@ -556,15 +556,18 @@ public class WxxcxIndexController<AesException extends Throwable> {
 
                 Map beanMap = objectMapper.convertValue(dev, Map.class);
 
-                LocalDate previousDate = LocalDate.now().minusDays(1);
-                String previousDateStr = previousDate.toString();
+                LocalDate inputDate = LocalDate.now();
+                if (StringUtils.isNotEmpty(time)) {
+                    inputDate = LocalDate.parse(time);
+                }
+                String inputDateStr = inputDate.toString();
                 // 判断查询结果并返回
-                List<AlarmEvent> stayTimes = null;
+                List<StayTime> stayTimes = null;
                 try {
                     stayTimes = jdbcTemplate.query(
-                            "SELECT * FROM alarm_event WHERE dev_id = ? AND DATE(create_time) = ?",
-                            new Object[]{dev.getDev_id(), previousDateStr},
-                            new BeanPropertyRowMapper<>(AlarmEvent.class)
+                            "SELECT * FROM stay_time WHERE dev_id = ? AND DATE(leave_time) = ? and type = 0 order by leave_time",
+                            new Object[]{dev.getDev_id(), inputDateStr},
+                            new BeanPropertyRowMapper<>(StayTime.class)
                     );
                 } catch (Exception e) {
                     e.printStackTrace();
@@ -1918,13 +1921,12 @@ public class WxxcxIndexController<AesException extends Throwable> {
     public R getWcTimes(String dev_id, String time) {
         R r = JSONUtil.getSuccessMsg(null);
         LocalDate inputDate = LocalDate.parse(time);
-        LocalDate previousDate = inputDate.minusDays(1);
-        String previousDateStr = previousDate.toString();
+        String previousDateStr = inputDate.toString();
         // 判断查询结果并返回
         List<StayTime> stayTimes = null;
         try {
             stayTimes = jdbcTemplate.query(
-                    "SELECT * FROM stay_time WHERE dev_id = ? AND DATE(leave_time) = ? and type = '0' order by leave_time",
+                    "SELECT * FROM stay_time WHERE dev_id = ? AND DATE(leave_time) = ? and type = 0 order by leave_time",
                     new Object[]{dev_id, previousDateStr},
                     new BeanPropertyRowMapper<>(StayTime.class)
             );
@@ -1967,8 +1969,8 @@ public class WxxcxIndexController<AesException extends Throwable> {
         }
         if (Objects.nonNull(stayTimes) && stayTimes.size() > 0) {
 
-            List<StayTime> roomList = stayTimes.stream().filter(stayTime -> ("0").equals(stayTime.getType())).collect(Collectors.toList());
-            List<StayTime> toiletList = stayTimes.stream().filter(stayTime -> ("1").equals(stayTime.getType())).collect(Collectors.toList());
+            List<StayTime> roomList = stayTimes.stream().filter(stayTime -> 0 == (stayTime.getType())).collect(Collectors.toList());
+            List<StayTime> toiletList = stayTimes.stream().filter(stayTime -> 1 == stayTime.getType()).collect(Collectors.toList());
 
             if (!CollectionUtils.isEmpty(roomList)) {
                 for (StayTime stayTime : roomList) {

+ 3 - 3
src/main/resources/application.yml

@@ -4,9 +4,9 @@ spring:
     druid:
       driver-class-name: com.mysql.cj.jdbc.Driver
       #           本地连接测试服务器
-#      url: jdbc:mysql://8.130.28.21:3306/hfln_dev?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&useSSL=false&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true&autoReconnect=true
-#      username: root
-#      password: Hfln@1024
+#      url: jdbc:mysql://8.130.28.21:3306/jkld?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&useSSL=false&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true&autoReconnect=true
+#      username: dev
+#      password: Hfln@dev1024
       #            打包生产连接
       url: jdbc:mysql://localhost:3306/jkld?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&useSSL=false&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true&autoReconnect=true
       username: root