|
@@ -21,7 +21,9 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
@@ -367,23 +369,21 @@ public class MqttSubHandle {
|
|
|
new LambdaUpdateWrapper<DevInfo>()
|
|
new LambdaUpdateWrapper<DevInfo>()
|
|
|
.eq(DevInfo::getClientId, clientId)
|
|
.eq(DevInfo::getClientId, clientId)
|
|
|
.set(DevInfo::getExistFlag, presence == 1 ? DevInfo.Constants.ExistFlag.EXIST : DevInfo.Constants.ExistFlag.NOT_EXIST)
|
|
.set(DevInfo::getExistFlag, presence == 1 ? DevInfo.Constants.ExistFlag.EXIST : DevInfo.Constants.ExistFlag.NOT_EXIST)
|
|
|
- .set(DevInfo::getPresenceChangeTime,
|
|
|
|
|
-// obj.get("timestamp") != null
|
|
|
|
|
-// ? LocalDateTime.ofInstant(Instant.ofEpochMilli(obj.getLongValue("timestamp")), ZoneId.of("UTC"))
|
|
|
|
|
-// :
|
|
|
|
|
- LocalDateTime.now())
|
|
|
|
|
|
|
+ .set(DevInfo::getPresenceChangeTime, LocalDateTime.now())
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ PersonInOutInfo personInOut = personInOutService.queryOneByDevId(dev.getDevId(), DateTimeFormatter.ofPattern("yyyyMMdd").format(LocalDate.now()));
|
|
|
if (presence == 1) {
|
|
if (presence == 1) {
|
|
|
- PersonInOutInfo personInOut = new PersonInOutInfo();
|
|
|
|
|
- personInOut.setTenantId(dev.getTenantId());
|
|
|
|
|
- personInOut.setDevId(dev.getDevId());
|
|
|
|
|
- personInOut.setEnterTime(LocalDateTime.now());
|
|
|
|
|
- personInOutService.save(personInOut);
|
|
|
|
|
- } else if (presence == 0) {
|
|
|
|
|
- PersonInOutInfo personInOut = personInOutService.queryOneByDevId(dev.getDevId());
|
|
|
|
|
- if (personInOut != null) {
|
|
|
|
|
- personInOut.setLeaveTime(LocalDateTime.now());
|
|
|
|
|
|
|
+ if (personInOut == null) {
|
|
|
|
|
+ personInOut = new PersonInOutInfo();
|
|
|
|
|
+ personInOut.setTenantId(dev.getTenantId());
|
|
|
|
|
+ personInOut.setDevId(dev.getDevId());
|
|
|
|
|
+ personInOut.setCountDate(DateTimeFormatter.ofPattern("yyyyMMdd").format(LocalDate.now()));
|
|
|
|
|
+ personInOut.setCount(1);
|
|
|
|
|
+ personInOutService.save(personInOut);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ personInOut.setCount(personInOut.getCount() + 1);
|
|
|
personInOutService.updateById(personInOut);
|
|
personInOutService.updateById(personInOut);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|