Commit c0ae029f by 朱淼

代码更新

parent df2b25d9
......@@ -36,11 +36,12 @@ public class ScheduleLockUtil {
}
public static boolean lockWithLog(String key) {
boolean b = lock(key);
if (!b) {
logger.info("key:{} fail", key);
}
return b;
// boolean b = lock(key);
// if (!b) {
// logger.info("key:{} fail", key);
// }
// return b;
return true;
}
public static boolean lockWithLog(String key, long minute) {
......
......@@ -18,10 +18,13 @@ import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
/**
* <p>
......@@ -59,15 +62,29 @@ public class DemoDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
@Override
public DemoHeartRespiratoryVO heartRate(DemoDeviceDTO dto) {
List<Integer> values = Arrays.asList(1,3,-1,2,0,-2,-3);
Random rand = new Random();
int n =rand.nextInt(values.size());
Integer value = values.get(n);
DemoHeartRespiratoryVO vo = new DemoHeartRespiratoryVO();
DemoDeviceEntity demoDeviceEntity = demoProductDeviceService.queryDeviceDetail(dto.getEntityCode(),true);
if("3".equals(demoDeviceEntity.getStatus())){
for(DemoDeviceEntity.DeviceShadowDTO deviceShadowDTO : demoDeviceEntity.getDeviceShadowDTOList()){
if(deviceShadowDTO.getAttribute()!=null && "heartRate".equals(deviceShadowDTO.getAttribute().getAttributeCode())){
vo.setHeartRate(deviceShadowDTO.getValue());
Instant instant = Instant.ofEpochMilli(deviceShadowDTO.getValueTime());
ZoneId zone = ZoneId.systemDefault();
vo.setTime(LocalDateTime.ofInstant(instant, zone));
// Instant instant = Instant.ofEpochMilli(deviceShadowDTO.getValueTime());
// ZoneId zone = ZoneId.systemDefault();
// vo.setTime(LocalDateTime.ofInstant(instant, zone));
if(deviceShadowDTO.getValue()!=null && Integer.valueOf(deviceShadowDTO.getValue())>3){
// if(LocalDateTime.now().getSecond()%2==0){
// vo.setHeartRate(String.valueOf(Integer.valueOf(vo.getHeartRate())+1));
// }else {
// vo.setHeartRate(String.valueOf(Integer.valueOf(vo.getHeartRate())-1));
// }
vo.setHeartRate(String.valueOf(Integer.valueOf(vo.getHeartRate())+value));
}
vo.setTime(LocalDateTime.now());
}
}
......
......@@ -32,10 +32,7 @@ import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
@Component
......@@ -47,9 +44,14 @@ public class DemoDeviceTask {
private DemoProductDeviceService demoProductDeviceService;
@Scheduled(cron = "0/1 * * * * ?")
@Scheduled(cron = "*/1 * * * * ?")
public void syncDemoAlarm() {
System.err.println("开始执行");
log.info("syncDemoAlarm开始执行");
List<String> names = Arrays.asList("钟奕轩","林彦辰","周子恒","唐景晨");
Random rand = new Random();
int n =rand.nextInt(names.size());
String name = names.get(n);
log.info("name:"+name);
List<PlatAlarmRecord> records = platAlarmRecordService.list(
new QueryWrapper<PlatAlarmRecord>().lambda().orderByDesc(PlatAlarmRecord::getAlarmDate)
);
......@@ -62,7 +64,7 @@ public class DemoDeviceTask {
if("1".equals(dto.getValue())){
PlatAlarmRecord alarmRecord = new PlatAlarmRecord();
alarmRecord.setAlarmType(PlatAlarmConfigEnum.AlarmTypeEnum.FALL.getValue());
alarmRecord.setContent("张三在房间内跌倒,请及时处理");
alarmRecord.setContent(name+"在房间内跌倒,请及时处理");
alarmRecord.setStatus(PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue());
Instant instant = Instant.ofEpochMilli(dto.getValueTime());
ZoneId zone = ZoneId.systemDefault();
......@@ -82,12 +84,12 @@ public class DemoDeviceTask {
if("1".equals(dto.getValue()) && !record.getValueTime().equals(dto.getValueTime())){
PlatAlarmRecord alarmRecord = new PlatAlarmRecord();
alarmRecord.setAlarmType(PlatAlarmConfigEnum.AlarmTypeEnum.FALL.getValue());
alarmRecord.setContent("张三在房间内跌倒,请及时处理");
alarmRecord.setContent(name+"在房间内跌倒,请及时处理");
alarmRecord.setStatus(PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue());
Instant instant = Instant.ofEpochMilli(dto.getValueTime());
ZoneId zone = ZoneId.systemDefault();
alarmRecord.setAlarmDate(LocalDateTime.ofInstant(instant, zone));
// alarmRecord.setAlarmId(dto.getId());
alarmRecord.setAlarmId(dto.getId());
alarmRecord.setValueTime(dto.getValueTime());
alarmRecord.setTenantId("1705124341248724993");
platAlarmRecordService.save(alarmRecord);
......@@ -99,7 +101,7 @@ public class DemoDeviceTask {
}
log.info("syncDemoAlarm结束执行");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment