|
|
@@ -14,6 +14,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import com.admin.alarm_event.AlarmEvent;
|
|
|
+import com.admin.alarm_event.StayTime;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
@@ -1906,26 +1907,26 @@ public class WxxcxIndexController<AesException extends Throwable> {
|
|
|
private final static String TOKEN = "lnServer";
|
|
|
|
|
|
/**
|
|
|
- * 检测用户是否拥有设备
|
|
|
+ * 查询前一天上厕所的次数
|
|
|
*
|
|
|
* @param time
|
|
|
* @param dev_id
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/getWcTimes")
|
|
|
- @ApiOperation(value = "查询前一天上厕所的次数")
|
|
|
+ @ApiOperation(value = "查询前一天用卫生间的次数")
|
|
|
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();
|
|
|
// 判断查询结果并返回
|
|
|
- List<AlarmEvent> stayTimes = null;
|
|
|
+ List<StayTime> stayTimes = null;
|
|
|
try {
|
|
|
stayTimes = jdbcTemplate.query(
|
|
|
- "SELECT * FROM alarm_event WHERE dev_id = ? AND DATE(create_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<>(AlarmEvent.class)
|
|
|
+ new BeanPropertyRowMapper<>(StayTime.class)
|
|
|
);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -1940,6 +1941,56 @@ public class WxxcxIndexController<AesException extends Throwable> {
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询当天上卫生间的次数,以及用马桶的次数
|
|
|
+ *
|
|
|
+ * @param time
|
|
|
+ * @param dev_id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getWcInfo")
|
|
|
+ @ApiOperation(value = "查询当天上卫生间的次数,以及用马桶的次数")
|
|
|
+ public R getWcInfo(String dev_id, String time) {
|
|
|
+ R r = JSONUtil.getSuccessMsg(null);
|
|
|
+ LocalDate inputDate = LocalDate.parse(time);
|
|
|
+ String inputDateStr = inputDate.toString();
|
|
|
+ // 判断查询结果并返回
|
|
|
+ List<StayTime> stayTimes = null;
|
|
|
+ try {
|
|
|
+ stayTimes = jdbcTemplate.query(
|
|
|
+ "SELECT * FROM stay_time WHERE dev_id = ? AND DATE(leave_time) = ? order by leave_time ",
|
|
|
+ new Object[]{dev_id, inputDateStr},
|
|
|
+ new BeanPropertyRowMapper<>(StayTime.class)
|
|
|
+ );
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(roomList)) {
|
|
|
+ for (StayTime stayTime : roomList) {
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(toiletList)) {
|
|
|
+ stayTime.setToiletList(toiletList.stream().filter(
|
|
|
+ toilet ->
|
|
|
+ toilet.getEnter_time().compareTo(stayTime.getEnter_time())>=0 && toilet.getLeave_time().compareTo(stayTime.getLeave_time())<=0
|
|
|
+ ).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ r.data.put("stayTimes", roomList);
|
|
|
+ r.data.put("count", roomList.size());
|
|
|
+ return r;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ r.data.put("stayTimes", null);
|
|
|
+ r.data.put("count", 0);
|
|
|
+ return r;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//公众号模块
|
|
|
|