|
@@ -28,6 +28,7 @@ import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.apache.http.util.EntityUtils;
|
|
|
import org.python.antlr.ast.If;
|
|
import org.python.antlr.ast.If;
|
|
|
|
|
+import org.python.antlr.ast.Name;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.*;
|
|
import org.springframework.http.*;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
@@ -81,7 +82,7 @@ public class FaceDiscernServiceImpl extends ServiceImpl<FaceDiscernMapper, FaceD
|
|
|
// redis 缓存
|
|
// redis 缓存
|
|
|
if (jedisUtil.exists("shoolAccessCount")) {
|
|
if (jedisUtil.exists("shoolAccessCount")) {
|
|
|
String count = jedisUtil.get("shoolAccessCount");
|
|
String count = jedisUtil.get("shoolAccessCount");
|
|
|
- List<AccessCountDto> list = JSON.parseArray(count,AccessCountDto.class);
|
|
|
|
|
|
|
+ List<AccessCountDto> list = JSON.parseArray(count, AccessCountDto.class);
|
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, list);
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -137,7 +138,7 @@ public class FaceDiscernServiceImpl extends ServiceImpl<FaceDiscernMapper, FaceD
|
|
|
|
|
|
|
|
String jsonStr = null;
|
|
String jsonStr = null;
|
|
|
try {
|
|
try {
|
|
|
- jsonStr = objectMapper.writeValueAsString(accessCountDtos); //areaList序列化为json字符串
|
|
|
|
|
|
|
+ jsonStr = objectMapper.writeValueAsString(accessCountDtos); //areaList序列化为json字符串
|
|
|
} catch (JsonProcessingException e) {
|
|
} catch (JsonProcessingException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
@@ -151,8 +152,8 @@ public class FaceDiscernServiceImpl extends ServiceImpl<FaceDiscernMapper, FaceD
|
|
|
public BaseResponse unitAccessCount(String startTime, String endTime, String id) {
|
|
public BaseResponse unitAccessCount(String startTime, String endTime, String id) {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
// redis 缓存
|
|
// redis 缓存
|
|
|
- if (jedisUtil.exists("unitAccessCount"+id)) {
|
|
|
|
|
- String address = jedisUtil.get("unitAccessCount"+id);
|
|
|
|
|
|
|
+ if (jedisUtil.exists("unitAccessCount" + id)) {
|
|
|
|
|
+ String address = jedisUtil.get("unitAccessCount" + id);
|
|
|
List<AccessCountDto> list = JSON.parseArray(address, AccessCountDto.class);
|
|
List<AccessCountDto> list = JSON.parseArray(address, AccessCountDto.class);
|
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, list);
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, list);
|
|
|
}
|
|
}
|
|
@@ -182,7 +183,6 @@ public class FaceDiscernServiceImpl extends ServiceImpl<FaceDiscernMapper, FaceD
|
|
|
long days = duration.toDays();
|
|
long days = duration.toDays();
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
for (int i = 0; i <= days; i++) {
|
|
for (int i = 0; i <= days; i++) {
|
|
|
startTime = start.plusDays(i).format(pattern);
|
|
startTime = start.plusDays(i).format(pattern);
|
|
|
String stop = start.plusDays(i + 1).format(pattern);
|
|
String stop = start.plusDays(i + 1).format(pattern);
|
|
@@ -213,20 +213,26 @@ public class FaceDiscernServiceImpl extends ServiceImpl<FaceDiscernMapper, FaceD
|
|
|
}
|
|
}
|
|
|
String jsonStr = null;
|
|
String jsonStr = null;
|
|
|
try {
|
|
try {
|
|
|
- jsonStr = objectMapper.writeValueAsString(accessCountDtos); //areaList序列化为json字符串
|
|
|
|
|
|
|
+ jsonStr = objectMapper.writeValueAsString(accessCountDtos); //areaList序列化为json字符串
|
|
|
} catch (JsonProcessingException e) {
|
|
} catch (JsonProcessingException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
- jedisUtil.setnx("unitAccessCount"+id, jsonStr);
|
|
|
|
|
|
|
+ jedisUtil.setnx("unitAccessCount" + id, jsonStr);
|
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, accessCountDtos);
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, accessCountDtos);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 个人轨迹
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
public BaseResponse personalTrack(String id) {
|
|
public BaseResponse personalTrack(String id) {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
// redis 缓存
|
|
// redis 缓存
|
|
|
- if (jedisUtil.exists("personalTrack"+id)) {
|
|
|
|
|
- String address = jedisUtil.get("personalTrack"+id);
|
|
|
|
|
|
|
+ if (jedisUtil.exists("personalTrack" + id)) {
|
|
|
|
|
+ String address = jedisUtil.get("personalTrack" + id);
|
|
|
List<PersonalTrackDto> list = JSON.parseArray(address, PersonalTrackDto.class);
|
|
List<PersonalTrackDto> list = JSON.parseArray(address, PersonalTrackDto.class);
|
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, list);
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, list);
|
|
|
}
|
|
}
|
|
@@ -257,7 +263,7 @@ public class FaceDiscernServiceImpl extends ServiceImpl<FaceDiscernMapper, FaceD
|
|
|
String pictureScene = faceDiscern.getPictureScene();
|
|
String pictureScene = faceDiscern.getPictureScene();
|
|
|
if (ObjectUtils.isNotEmpty(pictureScene)) {
|
|
if (ObjectUtils.isNotEmpty(pictureScene)) {
|
|
|
if ("U".equals(faceDiscern.getFacediscernType())) {
|
|
if ("U".equals(faceDiscern.getFacediscernType())) {
|
|
|
- pictureScene="https://chtech.ncjti.edu.cn/studentsportrait/dev-img/"+pictureScene;
|
|
|
|
|
|
|
+ pictureScene = "https://chtech.ncjti.edu.cn/studentsportrait/dev-img/" + pictureScene;
|
|
|
}
|
|
}
|
|
|
dto.setImage(pictureScene);
|
|
dto.setImage(pictureScene);
|
|
|
}
|
|
}
|
|
@@ -310,7 +316,7 @@ public class FaceDiscernServiceImpl extends ServiceImpl<FaceDiscernMapper, FaceD
|
|
|
|
|
|
|
|
|
|
|
|
|
String[] split = hotwaterAddress.split("-");
|
|
String[] split = hotwaterAddress.split("-");
|
|
|
- String address=split[0]+ "栋";
|
|
|
|
|
|
|
+ String address = split[0] + "栋";
|
|
|
Coord coord = coordService.getOne(Wrappers.<Coord>lambdaQuery().eq(Coord::getBuildingName, address));
|
|
Coord coord = coordService.getOne(Wrappers.<Coord>lambdaQuery().eq(Coord::getBuildingName, address));
|
|
|
if (ObjectUtils.isNotEmpty(coord)) {
|
|
if (ObjectUtils.isNotEmpty(coord)) {
|
|
|
String longitude = coord.getLongitude();
|
|
String longitude = coord.getLongitude();
|
|
@@ -331,7 +337,7 @@ public class FaceDiscernServiceImpl extends ServiceImpl<FaceDiscernMapper, FaceD
|
|
|
Stall one = stallService.getOne(Wrappers.<Stall>lambdaQuery().eq(Stall::getAddress, consumeAddress));
|
|
Stall one = stallService.getOne(Wrappers.<Stall>lambdaQuery().eq(Stall::getAddress, consumeAddress));
|
|
|
String name = one.getName();
|
|
String name = one.getName();
|
|
|
dto.setDateTime(consumeTime);
|
|
dto.setDateTime(consumeTime);
|
|
|
- dto.setAffair(consumeAddress+":"+name);
|
|
|
|
|
|
|
+ dto.setAffair(consumeAddress + ":" + name);
|
|
|
|
|
|
|
|
Instant instant = consumeTime.toInstant();
|
|
Instant instant = consumeTime.toInstant();
|
|
|
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.ofOffset("GMT", ZoneOffset.ofHours(8)));
|
|
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.ofOffset("GMT", ZoneOffset.ofHours(8)));
|
|
@@ -342,11 +348,11 @@ public class FaceDiscernServiceImpl extends ServiceImpl<FaceDiscernMapper, FaceD
|
|
|
LocalDateTime localDateTime5 = localDateTime.withHour(22).withMinute(0).withSecond(0);
|
|
LocalDateTime localDateTime5 = localDateTime.withHour(22).withMinute(0).withSecond(0);
|
|
|
if (localDateTime.isBefore(localDateTime2)) {
|
|
if (localDateTime.isBefore(localDateTime2)) {
|
|
|
dto.setName("早餐");
|
|
dto.setName("早餐");
|
|
|
- } else if ( localDateTime.isBefore(localDateTime3)) {
|
|
|
|
|
|
|
+ } else if (localDateTime.isBefore(localDateTime3)) {
|
|
|
dto.setName("午餐");
|
|
dto.setName("午餐");
|
|
|
- } else if ( localDateTime.isBefore(localDateTime4)) {
|
|
|
|
|
|
|
+ } else if (localDateTime.isBefore(localDateTime4)) {
|
|
|
dto.setName("晚餐");
|
|
dto.setName("晚餐");
|
|
|
- } else if ( localDateTime.isBefore(localDateTime5)) {
|
|
|
|
|
|
|
+ } else if (localDateTime.isBefore(localDateTime5)) {
|
|
|
dto.setName("夜宵");
|
|
dto.setName("夜宵");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -365,20 +371,18 @@ public class FaceDiscernServiceImpl extends ServiceImpl<FaceDiscernMapper, FaceD
|
|
|
}));
|
|
}));
|
|
|
String jsonStr = null;
|
|
String jsonStr = null;
|
|
|
try {
|
|
try {
|
|
|
- jsonStr = objectMapper.writeValueAsString(personalTrackDtos); //areaList序列化为json字符串
|
|
|
|
|
|
|
+ jsonStr = objectMapper.writeValueAsString(personalTrackDtos); //areaList序列化为json字符串
|
|
|
} catch (JsonProcessingException e) {
|
|
} catch (JsonProcessingException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
- jedisUtil.setnx("personalTrack"+id, jsonStr);
|
|
|
|
|
|
|
+ jedisUtil.setnx("personalTrack" + id, jsonStr);
|
|
|
|
|
|
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, personalTrackDtos);
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, personalTrackDtos);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public List<FaceDisernDto> getStudentCount(){
|
|
|
|
|
|
|
+ public List<FaceDisernDto> getStudentCount() {
|
|
|
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
// 前七天
|
|
// 前七天
|
|
@@ -387,7 +391,7 @@ public class FaceDiscernServiceImpl extends ServiceImpl<FaceDiscernMapper, FaceD
|
|
|
// 今天凌晨
|
|
// 今天凌晨
|
|
|
String endTime = now.withHour(0).withMinute(0).withSecond(0).format(pattern);
|
|
String endTime = now.withHour(0).withMinute(0).withSecond(0).format(pattern);
|
|
|
|
|
|
|
|
- List<FaceDisernDto> dtoList = baseMapper.getStudentCount(startTime,endTime);
|
|
|
|
|
|
|
+ List<FaceDisernDto> dtoList = baseMapper.getStudentCount(startTime, endTime);
|
|
|
ArrayList<FaceDisernDto> faceDisernDtos = new ArrayList<>();
|
|
ArrayList<FaceDisernDto> faceDisernDtos = new ArrayList<>();
|
|
|
for (int i = 0; i <= 9; i++) {
|
|
for (int i = 0; i <= 9; i++) {
|
|
|
faceDisernDtos.add(dtoList.get(i));
|
|
faceDisernDtos.add(dtoList.get(i));
|
|
@@ -395,23 +399,217 @@ public class FaceDiscernServiceImpl extends ServiceImpl<FaceDiscernMapper, FaceD
|
|
|
return faceDisernDtos;
|
|
return faceDisernDtos;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 重复坐标
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public BaseResponse repetitionCoordinate(String id) {
|
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+ // redis 缓存
|
|
|
|
|
+ if (jedisUtil.exists("repetitionCoordinate"+id)) {
|
|
|
|
|
+ String address = jedisUtil.get("repetitionCoordinate"+id);
|
|
|
|
|
+ List<Map> list = JSON.parseArray(address, Map.class);
|
|
|
|
|
+ return BaseResponse.ok(StatusEnum.SUCCESS, list);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ObjectUtils.isEmpty(id)) {
|
|
|
|
|
+ return BaseResponse.error(StatusEnum.FAIL, "参数异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ NewSchooluser byId = newSchooluserService.getById(id);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(byId)) {
|
|
|
|
|
+ return BaseResponse.error(StatusEnum.FAIL, "该学生不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+// 前七天
|
|
|
|
|
+ String oldDay = now.minusDays(7).withHour(0).withMinute(0).withSecond(0).format(pattern);
|
|
|
|
|
+// 今天凌晨
|
|
|
|
|
+ String nowDay = now.withHour(0).withMinute(0).withSecond(0).format(pattern);
|
|
|
|
|
+
|
|
|
|
|
+ ArrayList<PersonalTrackDto> personalTrackDtos = new ArrayList<>();
|
|
|
|
|
+// 获取人脸轨迹
|
|
|
|
|
+ List<FaceDiscern> list = this.list(Wrappers.<FaceDiscern>lambdaQuery().between(FaceDiscern::getFacediscernTime, oldDay, nowDay).eq(FaceDiscern::getShooluserId, id));
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(list) && list.size() > 0) {
|
|
|
|
|
+ for (FaceDiscern faceDiscern : list) {
|
|
|
|
|
+ PersonalTrackDto dto = new PersonalTrackDto();
|
|
|
|
|
+// 时间
|
|
|
|
|
+ Date facediscernTime = faceDiscern.getFacediscernTime();
|
|
|
|
|
+ dto.setDateTime(facediscernTime);
|
|
|
|
|
+// 图片
|
|
|
|
|
+ String pictureScene = faceDiscern.getPictureScene();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(pictureScene)) {
|
|
|
|
|
+ if ("U".equals(faceDiscern.getFacediscernType())) {
|
|
|
|
|
+ pictureScene = "https://chtech.ncjti.edu.cn/studentsportrait/dev-img/" + pictureScene;
|
|
|
|
|
+ }
|
|
|
|
|
+ dto.setImage(pictureScene);
|
|
|
|
|
+ }
|
|
|
|
|
+// 事件
|
|
|
|
|
+ String facediscernAddress = faceDiscern.getFacediscernAddress();
|
|
|
|
|
+ dto.setAffair(facediscernAddress);
|
|
|
|
|
+
|
|
|
|
|
+ Coord coord = coordService.getOne(Wrappers.<Coord>lambdaQuery().eq(Coord::getBuildingName, facediscernAddress));
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(coord)) {
|
|
|
|
|
+ String longitude = coord.getLongitude();
|
|
|
|
|
+ String latitude = coord.getLatitude();
|
|
|
|
|
+ dto.setLongitude(longitude);
|
|
|
|
|
+ dto.setLatitude(latitude);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ personalTrackDtos.add(dto);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Access> accessList = accessService.list(Wrappers.<Access>lambdaQuery().between(Access::getAccessTime, oldDay, nowDay).eq(Access::getCardNumber, id));
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(accessList) && accessList.size() > 0) {
|
|
|
|
|
+ for (Access access : accessList) {
|
|
|
|
|
+ PersonalTrackDto dto = new PersonalTrackDto();
|
|
|
|
|
+ Date accessTime = access.getAccessTime();
|
|
|
|
|
+ dto.setDateTime(accessTime);
|
|
|
|
|
+ String accessEvent = access.getAccessEvent();
|
|
|
|
|
+ String accessAddress = access.getAccessAddress();
|
|
|
|
|
+ dto.setAffair(accessEvent + accessAddress);
|
|
|
|
|
+ dto.setName("扫码");
|
|
|
|
|
+
|
|
|
|
|
+ Coord coord = coordService.getOne(Wrappers.<Coord>lambdaQuery().eq(Coord::getBuildingName, access.getAccessAddress()));
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(coord)) {
|
|
|
|
|
+ String longitude = coord.getLongitude();
|
|
|
|
|
+ String latitude = coord.getLatitude();
|
|
|
|
|
+ dto.setLongitude(longitude);
|
|
|
|
|
+ dto.setLatitude(latitude);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ personalTrackDtos.add(dto);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ List<HotWater> hotWaterList = hotWaterService.list(Wrappers.<HotWater>lambdaQuery().between(HotWater::getHotwaterTime, oldDay, nowDay).eq(HotWater::getCardNumber, id));
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(hotWaterList) && hotWaterList.size() > 0) {
|
|
|
|
|
+ for (HotWater hotWater : hotWaterList) {
|
|
|
|
|
+ PersonalTrackDto dto = new PersonalTrackDto();
|
|
|
|
|
+ Date hotwaterTime = hotWater.getHotwaterTime();
|
|
|
|
|
+ String hotwaterAddress = hotWater.getHotwaterAddress();
|
|
|
|
|
+ dto.setDateTime(hotwaterTime);
|
|
|
|
|
+ dto.setAffair(hotwaterAddress);
|
|
|
|
|
+ dto.setName(hotWater.getHotwaterEvent());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String[] split = hotwaterAddress.split("-");
|
|
|
|
|
+ String address = split[0] + "栋";
|
|
|
|
|
+ Coord coord = coordService.getOne(Wrappers.<Coord>lambdaQuery().eq(Coord::getBuildingName, address));
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(coord)) {
|
|
|
|
|
+ String longitude = coord.getLongitude();
|
|
|
|
|
+ String latitude = coord.getLatitude();
|
|
|
|
|
+ dto.setLongitude(longitude);
|
|
|
|
|
+ dto.setLatitude(latitude);
|
|
|
|
|
+ }
|
|
|
|
|
+ personalTrackDtos.add(dto);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ List<Consume> consumeList = consumeService.list(Wrappers.<Consume>lambdaQuery().between(Consume::getConsumeTime, oldDay, nowDay).eq(Consume::getIdCard, id));
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(consumeList) && consumeList.size() > 0) {
|
|
|
|
|
+ for (Consume consume : consumeList) {
|
|
|
|
|
+ PersonalTrackDto dto = new PersonalTrackDto();
|
|
|
|
|
+ Date consumeTime = consume.getConsumeTime();
|
|
|
|
|
+ String consumeAddress = consume.getConsumeAddress();
|
|
|
|
|
+ Stall one = stallService.getOne(Wrappers.<Stall>lambdaQuery().eq(Stall::getAddress, consumeAddress));
|
|
|
|
|
+ String name = one.getName();
|
|
|
|
|
+ dto.setDateTime(consumeTime);
|
|
|
|
|
+ dto.setAffair(consumeAddress + ":" + name);
|
|
|
|
|
+
|
|
|
|
|
+ Instant instant = consumeTime.toInstant();
|
|
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.ofOffset("GMT", ZoneOffset.ofHours(8)));
|
|
|
|
|
+// LocalDateTime localDateTime1 = localDateTime.withHour(6).withMinute(0).withSecond(0);
|
|
|
|
|
+ LocalDateTime localDateTime2 = localDateTime.withHour(11).withMinute(0).withSecond(0);
|
|
|
|
|
+ LocalDateTime localDateTime3 = localDateTime.withHour(15).withMinute(0).withSecond(0);
|
|
|
|
|
+ LocalDateTime localDateTime4 = localDateTime.withHour(20).withMinute(0).withSecond(0);
|
|
|
|
|
+ LocalDateTime localDateTime5 = localDateTime.withHour(22).withMinute(0).withSecond(0);
|
|
|
|
|
+ if (localDateTime.isBefore(localDateTime2)) {
|
|
|
|
|
+ dto.setName("早餐");
|
|
|
|
|
+ } else if (localDateTime.isBefore(localDateTime3)) {
|
|
|
|
|
+ dto.setName("午餐");
|
|
|
|
|
+ } else if (localDateTime.isBefore(localDateTime4)) {
|
|
|
|
|
+ dto.setName("晚餐");
|
|
|
|
|
+ } else if (localDateTime.isBefore(localDateTime5)) {
|
|
|
|
|
+ dto.setName("夜宵");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Coord coord = coordService.getOne(Wrappers.<Coord>lambdaQuery().eq(Coord::getBuildingName, "食堂"));
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(coord)) {
|
|
|
|
|
+ String longitude = coord.getLongitude();
|
|
|
|
|
+ String latitude = coord.getLatitude();
|
|
|
|
|
+ dto.setLongitude(longitude);
|
|
|
|
|
+ dto.setLatitude(latitude);
|
|
|
|
|
+ }
|
|
|
|
|
+ personalTrackDtos.add(dto);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+// 升序排序
|
|
|
|
|
+ Collections.sort(personalTrackDtos, Comparator.comparing((h) -> {
|
|
|
|
|
+ return h.getDateTime();
|
|
|
|
|
+ }));
|
|
|
|
|
+// 以相反的顺序排列
|
|
|
|
|
+ Collections.reverse(personalTrackDtos);
|
|
|
|
|
+
|
|
|
|
|
+ HashMap<String, List<PersonalTrackDto>> map = new HashMap<>();
|
|
|
|
|
+ for (PersonalTrackDto personalTrackDto : personalTrackDtos) {
|
|
|
|
|
+ String longitude = personalTrackDto.getLongitude();
|
|
|
|
|
+ String latitude = personalTrackDto.getLatitude();
|
|
|
|
|
+ String s = longitude + "," + latitude;
|
|
|
|
|
+ if (map.containsKey(s)) {
|
|
|
|
|
+ List<PersonalTrackDto> dtos = map.get(s);
|
|
|
|
|
+ dtos.add(personalTrackDto);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ List<PersonalTrackDto> dtos = new ArrayList<>();
|
|
|
|
|
+ dtos.add(personalTrackDto);
|
|
|
|
|
+ map.put(s, dtos);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ArrayList<Map> mapArrayList = new ArrayList<>();
|
|
|
|
|
+ Set<String> strings = map.keySet();
|
|
|
|
|
+ for (String string : strings) {
|
|
|
|
|
+ HashMap<String, Object> map1 = new HashMap<>();
|
|
|
|
|
+ String[] split = string.split(",");
|
|
|
|
|
+ String s = split[0];
|
|
|
|
|
+ String s1 = split[1];
|
|
|
|
|
+ Coord coord = coordService.list(Wrappers.<Coord>lambdaQuery().eq(Coord::getLongitude, s).eq(Coord::getLatitude, s1)).get(0);
|
|
|
|
|
+ List<PersonalTrackDto> personalTrackDtos1 = map.get(string);
|
|
|
|
|
+ map1.put("name",coord.getBuildingName());
|
|
|
|
|
+ map1.put("date",personalTrackDtos1);
|
|
|
|
|
+ map1.put("longitude",s);
|
|
|
|
|
+ map1.put("latitude",s1);
|
|
|
|
|
+ mapArrayList.add(map1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String jsonStr = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonStr = objectMapper.writeValueAsString(mapArrayList); //areaList序列化为json字符串
|
|
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ jedisUtil.setnx("repetitionCoordinate"+id, jsonStr);
|
|
|
|
|
|
|
|
|
|
+ return BaseResponse.ok(StatusEnum.SUCCESS, mapArrayList);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
//用于记录查询百胜门禁机的页数
|
|
//用于记录查询百胜门禁机的页数
|
|
|
- private Integer page = 15;
|
|
|
|
|
|
|
+ private Integer page = 20;
|
|
|
//百胜云平台接口的 api_id,用于请求接口
|
|
//百胜云平台接口的 api_id,用于请求接口
|
|
|
private String api_id = "389f11a7-bddb-3d16-9480-e5da2bafe799";
|
|
private String api_id = "389f11a7-bddb-3d16-9480-e5da2bafe799";
|
|
|
//百胜云平台接口的 api_key,用于请求接口
|
|
//百胜云平台接口的 api_key,用于请求接口
|
|
|
private String api_key = "5C78D964F6C534DFA918EAC7854F4529";
|
|
private String api_key = "5C78D964F6C534DFA918EAC7854F4529";
|
|
|
|
|
|
|
|
- // 每2分钟就拉取一次
|
|
|
|
|
- @Scheduled(cron = "0 0 0/2 * * ? ")
|
|
|
|
|
|
|
+ // 每2小时就拉取一次
|
|
|
|
|
+ @Scheduled(cron = "0 0/20 * * * ? ")
|
|
|
public void autoQueryOnline() {
|
|
public void autoQueryOnline() {
|
|
|
if (page > 1) {
|
|
if (page > 1) {
|
|
|
page -= 1;
|
|
page -= 1;
|
|
|
} else {
|
|
} else {
|
|
|
- page = 10;
|
|
|
|
|
|
|
+ page = 20;
|
|
|
}
|
|
}
|
|
|
online();
|
|
online();
|
|
|
}
|
|
}
|