|
|
@@ -1,12 +1,13 @@
|
|
|
package com.coffee.bus.service;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.coffee.bus.entity.BusClinicEntity;
|
|
|
-import com.coffee.bus.entity.BusDeviceRunningEntity;
|
|
|
import com.coffee.bus.entity.BusPatientEntity;
|
|
|
import com.coffee.bus.entity.PatientDeviceRepeatDomain;
|
|
|
import com.coffee.bus.enums.DeviceAlarmEnum;
|
|
|
@@ -24,6 +25,7 @@ import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
@@ -189,13 +191,13 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
|
|
|
* @author lifang
|
|
|
* @date 2022/5/8 21:52
|
|
|
* @param tenantId 医院id 用户请求时传输null
|
|
|
- * @return DeviceStatusStatsCountResult
|
|
|
+ * @return MonitorStatusStatsCountResult
|
|
|
*/
|
|
|
- public DeviceStatusStatsCountResult statusStats(String tenantId) {
|
|
|
+ public MonitorStatusStatsCountResult statusStats(String tenantId) {
|
|
|
PatientMonitorQuery query = new PatientMonitorQuery();
|
|
|
query.setTenantId(tenantId);
|
|
|
List<PatientMonitorResult> patientMonitorResults = this.selectAll(query);
|
|
|
- DeviceStatusStatsCountResult result = new DeviceStatusStatsCountResult();
|
|
|
+ MonitorStatusStatsCountResult result = new MonitorStatusStatsCountResult();
|
|
|
if(CollectionUtil.isNotEmpty(patientMonitorResults)){
|
|
|
patientMonitorResults.forEach(monitor->{
|
|
|
//运行数量
|
|
|
@@ -218,4 +220,62 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 描述: 按照时间对输注监控进行统计
|
|
|
+ * @author lifang
|
|
|
+ * @date 2022/5/8 22:40
|
|
|
+ * @param tenantId 医院id
|
|
|
+ * @return MonitorTimeStatsCountResult
|
|
|
+ */
|
|
|
+ public MonitorTimeStatsCountResult timeStats(String tenantId) {
|
|
|
+ PatientMonitorQuery query = new PatientMonitorQuery();
|
|
|
+ query.setTenantId(tenantId);
|
|
|
+ List<PatientMonitorResult> patientMonitorResults = this.selectAll(query);
|
|
|
+ MonitorTimeStatsCountResult result = new MonitorTimeStatsCountResult();
|
|
|
+ patientMonitorResults.forEach(monitor->{
|
|
|
+ Date startTime = monitor.getMonitorStartTime();
|
|
|
+ if(startTime==null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (includeTimes(startTime, 0)) {
|
|
|
+ result.setToday(result.getToday()+1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (includeTimes(startTime, 1)) {
|
|
|
+ result.setOneDay(result.getOneDay()+1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (includeTimes(startTime, 2)) {
|
|
|
+ result.setTwoDay(result.getTwoDay()+1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (includeTimes(startTime, 3)) {
|
|
|
+ result.setThreeDay(result.getThreeDay()+1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ result.setBeyondThreeDay(result.getBeyondThreeDay()+1);
|
|
|
+ });
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 描述: 判断所给时间是否在存在于某一时间段内
|
|
|
+ * @author lifang
|
|
|
+ * @date 2022/5/8 22:47
|
|
|
+ * @param time 时间
|
|
|
+ * @param offset 时间偏移量,单位:天 以当天时间为基准进行偏移
|
|
|
+ * @return boolean
|
|
|
+ */
|
|
|
+ private boolean includeTimes(Date time,int offset){
|
|
|
+ if(time==null){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ LocalDateTime dateTime = LocalDateTime.now().plusDays(offset);
|
|
|
+ LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(dateTime);
|
|
|
+ LocalDateTime endTime = LocalDateTimeUtil.endOfDay(dateTime);
|
|
|
+ return beginTime.getSecond()<time.getSeconds()
|
|
|
+ && time.getSeconds()<endTime.getSecond();
|
|
|
+ }
|
|
|
}
|