|
@@ -152,12 +152,12 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
|
|
|
vos.add(lastSevenDaysTrackVo);
|
|
vos.add(lastSevenDaysTrackVo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- List<SmartAttendance> attendances=smartAttendanceService.track(startTime,endTime,userId);
|
|
|
|
|
|
|
+ List<SmartAttendance> attendances = smartAttendanceService.track(startTime, endTime, userId);
|
|
|
// 获取班级名称
|
|
// 获取班级名称
|
|
|
SmartUser smartUser = smartUserService.getSmartById(userId);
|
|
SmartUser smartUser = smartUserService.getSmartById(userId);
|
|
|
SmartClass smartClass = smartClassService.getSmartClassById(smartUser.getSchoolClass());
|
|
SmartClass smartClass = smartClassService.getSmartClassById(smartUser.getSchoolClass());
|
|
|
String className = smartClass.getName();
|
|
String className = smartClass.getName();
|
|
|
- SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );
|
|
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
for (SmartAttendance attendance : attendances) {
|
|
for (SmartAttendance attendance : attendances) {
|
|
|
LastSevenDaysTrackVo lastSevenDaysTrackVo = new LastSevenDaysTrackVo();
|
|
LastSevenDaysTrackVo lastSevenDaysTrackVo = new LastSevenDaysTrackVo();
|
|
|
lastSevenDaysTrackVo.setName(attendance.getXwUserName());
|
|
lastSevenDaysTrackVo.setName(attendance.getXwUserName());
|
|
@@ -178,6 +178,8 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @PassToken
|
|
|
|
|
+ @DESRespondSecret(validated = false)
|
|
|
public String callBack(HttpServletRequest request, HttpServletResponse response) {
|
|
public String callBack(HttpServletRequest request, HttpServletResponse response) {
|
|
|
try {
|
|
try {
|
|
|
BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
|
|
BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
|
|
@@ -187,103 +189,148 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
|
|
|
responseStrBuilder.append(inputStr);
|
|
responseStrBuilder.append(inputStr);
|
|
|
}
|
|
}
|
|
|
JSONObject jsonObject = JSONObject.parseObject(responseStrBuilder.toString());
|
|
JSONObject jsonObject = JSONObject.parseObject(responseStrBuilder.toString());
|
|
|
-// System.out.println("jsonObject = " + jsonObject);
|
|
|
|
|
-// 比对结果
|
|
|
|
|
- Integer resultStatus = jsonObject.getInteger("resultStatus");
|
|
|
|
|
- if (1 == resultStatus) {
|
|
|
|
|
|
|
|
|
|
-// 抓拍的照片 base64字符串
|
|
|
|
|
- String scenePhoto = jsonObject.getString("scenePhoto");
|
|
|
|
|
- scenePhoto = "data:image/jpeg;base64," + scenePhoto;
|
|
|
|
|
- System.out.println("scenePhoto = " + scenePhoto.substring(0, 100));
|
|
|
|
|
-// base64转文件
|
|
|
|
|
- MultipartFile multipartFile = MultipartFileUtils.base64ToMultipartFile(scenePhoto);
|
|
|
|
|
-// 上传到cos桶,并生成图片地址
|
|
|
|
|
- String image = smartUploadService.upload(new MultipartFile[]{multipartFile});
|
|
|
|
|
-
|
|
|
|
|
- // 设备sn
|
|
|
|
|
- String sn = jsonObject.getString("sn");
|
|
|
|
|
- SmartDevice smartDevice = smartDeviceService.getNum(sn);
|
|
|
|
|
- String address = "";
|
|
|
|
|
- String type = "";
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(smartDevice)) {
|
|
|
|
|
- // 地点
|
|
|
|
|
- address = smartDevice.getAddress();
|
|
|
|
|
|
|
+ DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ // 比对时间
|
|
|
|
|
+ String time = jsonObject.getString("time");
|
|
|
|
|
+ logger.info("time = " + time);
|
|
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.now().withHour(0).withSecond(0).withMinute(0);
|
|
|
|
|
+ LocalDateTime localDateTime2 = LocalDateTime.parse(time, dateTimeFormatter1);
|
|
|
|
|
+// 只获取当天的
|
|
|
|
|
+ if (localDateTime.isBefore(localDateTime2)) {
|
|
|
|
|
+// 比对结果
|
|
|
|
|
+ Integer resultStatus = jsonObject.getInteger("resultStatus");
|
|
|
|
|
+ if (1 == resultStatus) {
|
|
|
|
|
+
|
|
|
|
|
+ // 设备sn
|
|
|
|
|
+ String sn = jsonObject.getString("sn");
|
|
|
|
|
+ SmartDevice smartDevice = smartDeviceService.getNum(sn);
|
|
|
|
|
+ String address = "";
|
|
|
|
|
+ String type = "";
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(smartDevice)) {
|
|
|
|
|
+ // 地点
|
|
|
|
|
+ address = smartDevice.getAddress();
|
|
|
// 类型
|
|
// 类型
|
|
|
- type = smartDevice.getName();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ type = smartDevice.getName();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 名字,学生会加班级[]
|
|
// 名字,学生会加班级[]
|
|
|
- String name = jsonObject.getString("name");
|
|
|
|
|
- System.out.println("name = " + name);
|
|
|
|
|
- String[] split = name.split("\\[");
|
|
|
|
|
- String s = split[0];
|
|
|
|
|
- System.out.println("s = " + s);
|
|
|
|
|
|
|
+ String name = jsonObject.getString("name");
|
|
|
|
|
+ System.out.println("name = " + name);
|
|
|
|
|
+ String[] split = name.split("\\[");
|
|
|
|
|
+ String s = split[0];
|
|
|
|
|
+ logger.info("name = " + s);
|
|
|
// 百胜门禁编号
|
|
// 百胜门禁编号
|
|
|
- String idNum = jsonObject.getString("idNum");
|
|
|
|
|
- System.out.println("idNum = " + idNum);
|
|
|
|
|
- SmartUser smartUser = smartUserService.getBsStudentNo(idNum);
|
|
|
|
|
- Integer userId = 0;
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(smartUser)) {
|
|
|
|
|
- userId = smartUser.getId();
|
|
|
|
|
- } else {
|
|
|
|
|
- userId = 0;
|
|
|
|
|
- }
|
|
|
|
|
- DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
- String dateTime = dateTimeFormatter1.format(LocalDateTime.now());
|
|
|
|
|
-
|
|
|
|
|
- SmartFaceDiscern smartFaceDiscern = new SmartFaceDiscern();
|
|
|
|
|
- smartFaceDiscern.setImage(image);
|
|
|
|
|
- smartFaceDiscern.setName(s);
|
|
|
|
|
- smartFaceDiscern.setLocation(address);
|
|
|
|
|
- smartFaceDiscern.setType(type);
|
|
|
|
|
- smartFaceDiscern.setUserId(userId);
|
|
|
|
|
- smartFaceDiscern.setDateTime(dateTime);
|
|
|
|
|
- smartFaceDiscern.setIdNum(idNum);
|
|
|
|
|
- smartFaceDiscern.setSn(sn);
|
|
|
|
|
- smartFaceDiscernService.save(smartFaceDiscern);
|
|
|
|
|
-
|
|
|
|
|
- if (userId != 0) {
|
|
|
|
|
-
|
|
|
|
|
-// 通过学生id找到关联的家长affiliate,并找到公众号,如果openid为空则不传
|
|
|
|
|
- List<SmartUser> userList = smartUserService.getAffiliateList(userId);
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(userList) && userList.size() > 0) {
|
|
|
|
|
-
|
|
|
|
|
- for (SmartUser user : userList) {
|
|
|
|
|
- String gzhOpenId = user.getGzhOpenId();
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(gzhOpenId)) {
|
|
|
|
|
- String pushType = "";
|
|
|
|
|
- if (type.contains("进校")) {
|
|
|
|
|
- pushType = "进入大门";
|
|
|
|
|
- } else if (type.contains("出校")) {
|
|
|
|
|
- pushType = "离开大门";
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ String idNum = jsonObject.getString("idNum");
|
|
|
|
|
+ logger.info("idNum = " + idNum);
|
|
|
|
|
+ SmartUser smartUser = smartUserService.getBsStudentNo(idNum);
|
|
|
|
|
+ Integer userId = 0;
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(smartUser)) {
|
|
|
|
|
+ userId = smartUser.getId();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ userId = 0;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 时间格式是 yyyy-MM-dd HH:mm:ss,当前时间格式有问题
|
|
|
|
|
- LocalDateTime date = LocalDateTime.now();
|
|
|
|
|
- String format = date.format(dateTimeFormatter1);
|
|
|
|
|
|
|
|
|
|
- // 公众号信息推送
|
|
|
|
|
- Message2.send(gzhOpenId, pushType, address, format);
|
|
|
|
|
|
|
+ SmartFaceDiscern smartFaceDiscern = new SmartFaceDiscern();
|
|
|
|
|
+
|
|
|
|
|
+ smartFaceDiscern.setName(s);
|
|
|
|
|
+ smartFaceDiscern.setLocation(address);
|
|
|
|
|
+ smartFaceDiscern.setType(type);
|
|
|
|
|
+ smartFaceDiscern.setUserId(userId);
|
|
|
|
|
+ smartFaceDiscern.setDateTime(time);
|
|
|
|
|
+ smartFaceDiscern.setIdNum(idNum);
|
|
|
|
|
+ smartFaceDiscern.setSn(sn);
|
|
|
|
|
+ if (userId != 0) {
|
|
|
|
|
+ // 判断是否已经添加
|
|
|
|
|
+ LambdaQueryWrapper<SmartFaceDiscern> wrapperFD = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapperFD.eq(SmartFaceDiscern::getDateTime, smartFaceDiscern.getDateTime())
|
|
|
|
|
+ .eq(SmartFaceDiscern::getUserId, userId);
|
|
|
|
|
+ List<SmartFaceDiscern> list = smartFaceDiscernService.list(wrapperFD);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(list) && list.size() == 0) {
|
|
|
|
|
+ // 抓拍的照片 base64字符串
|
|
|
|
|
+ String scenePhoto = jsonObject.getString("scenePhoto");
|
|
|
|
|
+ scenePhoto = "data:image/jpeg;base64," + scenePhoto;
|
|
|
|
|
+ logger.info("scenePhoto =" + scenePhoto.substring(0, 50));
|
|
|
|
|
+// base64转文件
|
|
|
|
|
+ MultipartFile multipartFile = MultipartFileUtils.base64ToMultipartFile(scenePhoto);
|
|
|
|
|
+ String image="";
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 上传到cos桶,并生成图片地址
|
|
|
|
|
+ image = smartUploadService.upload(new MultipartFile[]{multipartFile});
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ logger.error("上传cos桶失败");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- SmartNotification smartNotification = new SmartNotification();
|
|
|
|
|
- smartNotification.setUserId(smartUser.getId());
|
|
|
|
|
- smartNotification.setUserName(smartUser.getName());
|
|
|
|
|
- smartNotification.setTypeName(pushType);
|
|
|
|
|
- smartNotification.setLocation(address);
|
|
|
|
|
- smartNotification.setImage(image);
|
|
|
|
|
- smartNotification.setDateTime(dateTime);
|
|
|
|
|
- smartNotification.setType(2);
|
|
|
|
|
|
|
+ smartFaceDiscern.setImage(image);
|
|
|
|
|
+ smartFaceDiscernService.save(smartFaceDiscern);
|
|
|
|
|
|
|
|
- smartNotificationService.save(smartNotification);
|
|
|
|
|
|
|
+// 通过学生id找到关联的家长affiliate,并找到公众号,如果openid为空则不传
|
|
|
|
|
+ List<SmartUser> userList = smartUserService.getAffiliateList(userId);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(userList) && userList.size() > 0) {
|
|
|
|
|
+
|
|
|
|
|
+ for (SmartUser user : userList) {
|
|
|
|
|
+ String gzhOpenId = user.getGzhOpenId();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(gzhOpenId)) {
|
|
|
|
|
+ String pushType = "";
|
|
|
|
|
+ if (type.contains("进校")) {
|
|
|
|
|
+ pushType = "进入大门";
|
|
|
|
|
+ } else if (type.contains("出校")) {
|
|
|
|
|
+ pushType = "离开大门";
|
|
|
|
|
+ }
|
|
|
|
|
+ LocalDateTime date = LocalDateTime.now();
|
|
|
|
|
+ String format = date.format(dateTimeFormatter1);
|
|
|
|
|
+ // 公众号信息推送
|
|
|
|
|
+ Message2.send(gzhOpenId, pushType, address, format);
|
|
|
|
|
+
|
|
|
|
|
+ SmartNotification smartNotification = new SmartNotification();
|
|
|
|
|
+ smartNotification.setUserId(smartUser.getId());
|
|
|
|
|
+ smartNotification.setUserName(smartUser.getName());
|
|
|
|
|
+ smartNotification.setTypeName(pushType);
|
|
|
|
|
+ smartNotification.setLocation(address);
|
|
|
|
|
+ smartNotification.setImage(image);
|
|
|
|
|
+ smartNotification.setDateTime(time);
|
|
|
|
|
+ smartNotification.setType(2);
|
|
|
|
|
+
|
|
|
|
|
+ smartNotificationService.save(smartNotification);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ smartFaceDiscern.setUserId(0);
|
|
|
|
|
+// 判断是否已经添加
|
|
|
|
|
+ LambdaQueryWrapper<SmartFaceDiscern> wrapperFD = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapperFD.eq(SmartFaceDiscern::getDateTime, time)
|
|
|
|
|
+ .eq(SmartFaceDiscern::getName, s)
|
|
|
|
|
+ .eq(SmartFaceDiscern::getType, type);
|
|
|
|
|
+ List<SmartFaceDiscern> list = smartFaceDiscernService.list(wrapperFD);
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtils.isEmpty(list) && list.size() == 0) {
|
|
|
|
|
+ // 抓拍的照片 base64字符串
|
|
|
|
|
+ String scenePhoto = jsonObject.getString("scenePhoto");
|
|
|
|
|
+ scenePhoto = "data:image/jpeg;base64," + scenePhoto;
|
|
|
|
|
+ logger.info("scenePhoto =" + scenePhoto.substring(0, 50));
|
|
|
|
|
+// base64转文件
|
|
|
|
|
+ MultipartFile multipartFile = MultipartFileUtils.base64ToMultipartFile(scenePhoto);
|
|
|
|
|
+ String image="";
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 上传到cos桶,并生成图片地址
|
|
|
|
|
+ image = smartUploadService.upload(new MultipartFile[]{multipartFile});
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ logger.error("上传cos桶失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ smartFaceDiscern.setImage(image);
|
|
|
|
|
+ smartFaceDiscernService.save(smartFaceDiscern);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} catch (
|
|
} catch (
|
|
@@ -319,10 +366,16 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
|
- LocalDateTime end = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).plusDays(1);
|
|
|
|
|
- System.out.println("end = " + end);
|
|
|
|
|
- LocalDateTime satrt = end.minusDays(7);
|
|
|
|
|
- System.out.println("satrt = " + satrt);
|
|
|
|
|
|
|
+ LocalDateTime dateTime1 = LocalDateTime.of(2022, 8, 29, 12, 0, 0);
|
|
|
|
|
+ LocalDateTime dateTime2 = LocalDateTime.of(2022, 8, 30, 12, 0, 0);
|
|
|
|
|
+ LocalDateTime dateTime3 = LocalDateTime.of(2022, 8, 28, 12, 0, 0);
|
|
|
|
|
+
|
|
|
|
|
+ boolean isBefore = dateTime1.isBefore(dateTime2);
|
|
|
|
|
+ boolean isBefore2 = dateTime1.isBefore(dateTime3);
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("dateTime1 is before dateTime2: " + isBefore);
|
|
|
|
|
+ System.out.println("dateTime1 is before dateTime2: " + isBefore2);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|