|
@@ -9,8 +9,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.hfln.portal.common.constant.mqtt.topic.TopicConstants;
|
|
import com.hfln.portal.common.constant.mqtt.topic.TopicConstants;
|
|
import com.hfln.portal.common.dto.data.device.DeviceDTO;
|
|
import com.hfln.portal.common.dto.data.device.DeviceDTO;
|
|
-import com.hfln.portal.common.dto.data.event.AlarmEventDTO;
|
|
|
|
import com.hfln.portal.common.dto.data.event.EventListDTO;
|
|
import com.hfln.portal.common.dto.data.event.EventListDTO;
|
|
|
|
+import com.hfln.portal.common.dto.data.event.StayTimeDTO;
|
|
import com.hfln.portal.common.dto.data.home.HomeInfoDTO;
|
|
import com.hfln.portal.common.dto.data.home.HomeInfoDTO;
|
|
import com.hfln.portal.common.dto.data.oss.OssFileDTO;
|
|
import com.hfln.portal.common.dto.data.oss.OssFileDTO;
|
|
import com.hfln.portal.common.dto.data.room.RegionDTO;
|
|
import com.hfln.portal.common.dto.data.room.RegionDTO;
|
|
@@ -23,9 +23,10 @@ import com.hfln.portal.common.request.room.SubRegionInfo;
|
|
import com.hfln.portal.common.request.share.ShareConfirmParam;
|
|
import com.hfln.portal.common.request.share.ShareConfirmParam;
|
|
import com.hfln.portal.common.request.share.ShareParam;
|
|
import com.hfln.portal.common.request.share.ShareParam;
|
|
import com.hfln.portal.common.request.share.updateShareParam;
|
|
import com.hfln.portal.common.request.share.updateShareParam;
|
|
-import com.hfln.portal.common.response.device.WcTimesQueryRes;
|
|
|
|
|
|
+import com.hfln.portal.common.response.device.UsedInfoQueryRes;
|
|
import com.hfln.portal.common.vo.PageRecord;
|
|
import com.hfln.portal.common.vo.PageRecord;
|
|
import com.hfln.portal.domain.customer.OssBusiType;
|
|
import com.hfln.portal.domain.customer.OssBusiType;
|
|
|
|
+import com.hfln.portal.domain.customer.util.CopyUtils;
|
|
import com.hfln.portal.domain.customer.util.DevPosFixUtil;
|
|
import com.hfln.portal.domain.customer.util.DevPosFixUtil;
|
|
import com.hfln.portal.domain.customer.util.WxOfficeAccountClient;
|
|
import com.hfln.portal.domain.customer.util.WxOfficeAccountClient;
|
|
import com.hfln.portal.domain.exception.ErrorEnum;
|
|
import com.hfln.portal.domain.exception.ErrorEnum;
|
|
@@ -48,7 +49,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
-import java.time.LocalDate;
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -102,6 +102,9 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
@Autowired
|
|
@Autowired
|
|
private MqttSubHandle mqttSubHandle;
|
|
private MqttSubHandle mqttSubHandle;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private StayTimeService stayTimeService;
|
|
|
|
+
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public HomeInfoDTO queryHomeInfo(Long userId) {
|
|
public HomeInfoDTO queryHomeInfo(Long userId) {
|
|
@@ -886,27 +889,56 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public WcTimesQueryRes getWcTimes(Long devId, String time) {
|
|
|
|
-
|
|
|
|
- LocalDate inputDate = LocalDate.parse(time);
|
|
|
|
- LocalDate tomorrow = inputDate.plusDays(1);
|
|
|
|
- List<AlarmEvent> list = alarmEventService.list(new LambdaQueryWrapper<AlarmEvent>().eq(AlarmEvent::getDevId, devId).ge(AlarmEvent::getCreateTime, inputDate).lt(AlarmEvent::getCreateTime, tomorrow));
|
|
|
|
- WcTimesQueryRes res = new WcTimesQueryRes();
|
|
|
|
- if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
|
+ public UsedInfoQueryRes getUsedInfo(UsedInfoQueryReq req) {
|
|
|
|
|
|
|
|
+ List<StayTime> stayTimes = stayTimeService.queryStayTime(req);
|
|
|
|
+ UsedInfoQueryRes res = new UsedInfoQueryRes();
|
|
|
|
+ if (CollectionUtils.isEmpty(stayTimes)) {
|
|
res.setStayTimes(null);
|
|
res.setStayTimes(null);
|
|
res.setCount(0);
|
|
res.setCount(0);
|
|
- } else {
|
|
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
- List<AlarmEventDTO> dtoList = new ArrayList<>();
|
|
|
|
- for (AlarmEvent alarmEvent : list) {
|
|
|
|
- AlarmEventDTO dto = new AlarmEventDTO();
|
|
|
|
- BeanUtils.copyProperties(alarmEvent, dto);
|
|
|
|
- dtoList.add(dto);
|
|
|
|
|
|
+ List<StayTimeDTO> roomList = stayTimes.stream().filter(stayTime ->
|
|
|
|
+ {
|
|
|
|
+ if (stayTime != null && stayTime.getType() != null) {
|
|
|
|
+ if (0 == (stayTime.getType())) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ ).map(e -> CopyUtils.copy(e, StayTimeDTO.class)).collect(Collectors.toList());
|
|
|
|
+ List<StayTimeDTO> toiletList = stayTimes.stream().filter(stayTime ->
|
|
|
|
+ {
|
|
|
|
+ if (stayTime != null && stayTime.getType() != null) {
|
|
|
|
+ if (1 == (stayTime.getType())) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ ).map(e -> CopyUtils.copy(e, StayTimeDTO.class)).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ if (CollectionUtils.isNotEmpty(roomList)) {
|
|
|
|
+ for (StayTimeDTO stayTime : roomList) {
|
|
|
|
+
|
|
|
|
+ if (CollectionUtils.isNotEmpty(toiletList)) {
|
|
|
|
+ stayTime.setChildStayTime(toiletList.stream().filter(
|
|
|
|
+ toilet ->
|
|
|
|
+ !toilet.getEnterTime().isBefore(stayTime.getEnterTime()) && !toilet.getLeaveTime().isAfter(stayTime.getLeaveTime())
|
|
|
|
+ ).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- res.setStayTimes(dtoList);
|
|
|
|
- res.setCount(list.size());
|
|
|
|
|
|
+
|
|
|
|
+ res.setStayTimes(roomList);
|
|
|
|
+ res.setCount(roomList.size());
|
|
|
|
+ return res;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ res.setStayTimes(null);
|
|
|
|
+ res.setCount(0);
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
|