FaceImportUtilTest.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package com.xjrsoft.module.hikvision.util;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.xjrsoft.XjrSoftApplication;
  4. import com.xjrsoft.common.utils.ImageUtil;
  5. import com.xjrsoft.module.personnel.entity.StundentFaceProcess;
  6. import com.xjrsoft.module.personnel.entity.TeacherFaceProcess;
  7. import com.xjrsoft.module.personnel.service.IFaceManagementService;
  8. import com.xjrsoft.module.personnel.service.IStundentFaceProcessService;
  9. import com.xjrsoft.module.personnel.service.ITeacherFaceProcessService;
  10. import com.xjrsoft.module.system.entity.File;
  11. import com.xjrsoft.module.system.service.IFileService;
  12. import org.junit.jupiter.api.Test;
  13. import org.junit.runner.RunWith;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.boot.test.context.SpringBootTest;
  16. import org.springframework.test.context.junit4.SpringRunner;
  17. import java.util.List;
  18. import static org.junit.jupiter.api.Assertions.*;
  19. /**
  20. * @author dzx
  21. * @date 2024/6/7
  22. */
  23. @RunWith(SpringRunner.class)
  24. @SpringBootTest(classes = XjrSoftApplication.class)
  25. class FaceImportUtilTest {
  26. @Autowired
  27. private IStundentFaceProcessService stundentFaceProcessService;
  28. @Autowired
  29. private ITeacherFaceProcessService teacherFaceProcessService;
  30. @Autowired
  31. private IFileService fileService;
  32. @Test
  33. void test(){
  34. List<TeacherFaceProcess> list = teacherFaceProcessService.list(
  35. new QueryWrapper<TeacherFaceProcess>().lambda()
  36. .notLike(TeacherFaceProcess::getHikvisionResult, "{\"code\":\"0\",\"msg\":\"success\",")
  37. .orderByAsc(TeacherFaceProcess::getModifyDate)
  38. );
  39. for (TeacherFaceProcess process : list) {
  40. // byte[] imageBytes = fileService.downloadFileByZip(process.getFacePhoto());
  41. // //压缩到200k
  42. // imageBytes = ImageUtil.compressUnderSize(imageBytes, 204800);
  43. File file = fileService.getOne(
  44. new QueryWrapper<File>().lambda().eq(File::getFolderId, process.getFacePhoto())
  45. );
  46. String result = FaceImportUtil.ImportStudentFace(process.getUserId() + "", file.getFileUrl());
  47. process.setHikvisionResult(result);
  48. teacherFaceProcessService.updateById(process);
  49. }
  50. }
  51. @Test
  52. void test2(){
  53. List<StundentFaceProcess> list = stundentFaceProcessService.list(
  54. new QueryWrapper<StundentFaceProcess>().lambda()
  55. .notLike(StundentFaceProcess::getHikvisionResult, "{\"code\":\"0\",\"msg\":\"success\",")
  56. );
  57. for (StundentFaceProcess process : list) {
  58. // byte[] imageBytes = fileService.downloadFileByZip(process.getFacePhoto());
  59. // //压缩到200k
  60. // imageBytes = ImageUtil.compressUnderSize(imageBytes, 204800);
  61. File file = fileService.getOne(
  62. new QueryWrapper<File>().lambda().eq(File::getFolderId, process.getFacePhoto())
  63. );
  64. String result = FaceImportUtil.ImportStudentFace(process.getUserId() + "", file.getFileUrl());
  65. process.setHikvisionResult(result);
  66. stundentFaceProcessService.updateById(process);
  67. }
  68. }
  69. }