FaceImportUtilTest.java 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. );
  38. for (TeacherFaceProcess process : list) {
  39. // byte[] imageBytes = fileService.downloadFileByZip(process.getFacePhoto());
  40. // //压缩到200k
  41. // imageBytes = ImageUtil.compressUnderSize(imageBytes, 204800);
  42. File file = fileService.getOne(
  43. new QueryWrapper<File>().lambda().eq(File::getFolderId, process.getFacePhoto())
  44. );
  45. String result = FaceImportUtil.ImportStudentFace(process.getUserId() + "", file.getFileUrl());
  46. process.setHikvisionResult(result);
  47. teacherFaceProcessService.updateById(process);
  48. }
  49. }
  50. @Test
  51. void test2(){
  52. List<StundentFaceProcess> list = stundentFaceProcessService.list(
  53. new QueryWrapper<StundentFaceProcess>().lambda()
  54. .notLike(StundentFaceProcess::getHikvisionResult, "{\"code\":\"0\",\"msg\":\"success\",")
  55. );
  56. for (StundentFaceProcess process : list) {
  57. // byte[] imageBytes = fileService.downloadFileByZip(process.getFacePhoto());
  58. // //压缩到200k
  59. // imageBytes = ImageUtil.compressUnderSize(imageBytes, 204800);
  60. File file = fileService.getOne(
  61. new QueryWrapper<File>().lambda().eq(File::getFolderId, process.getFacePhoto())
  62. );
  63. String result = FaceImportUtil.ImportStudentFace(process.getUserId() + "", file.getFileUrl());
  64. process.setHikvisionResult(result);
  65. stundentFaceProcessService.updateById(process);
  66. }
  67. }
  68. }