Browse Source

fit: 新增重点人员实体类

master
wxc 5 months ago
parent
commit
d2bc4a39ad
  1. 4
      src/main/java/com/biutag/supervision/controller/FileController.java
  2. 4
      src/main/java/com/biutag/supervision/controller/books/NegativeBookController.java
  3. 8
      src/main/java/com/biutag/supervision/mapper/SupRiskPersonalControlRecordMapper.java
  4. 8
      src/main/java/com/biutag/supervision/mapper/SupRiskPersonalMapper.java
  5. 62
      src/main/java/com/biutag/supervision/pojo/entity/SupRiskPersonal.java
  6. 43
      src/main/java/com/biutag/supervision/pojo/entity/SupRiskPersonalControlRecord.java
  7. 2
      src/main/java/com/biutag/supervision/pojo/entity/SupTaskTestingAlcoholPeople.java
  8. 4
      src/main/java/com/biutag/supervision/pojo/vo/TaskCountVo.java
  9. 2
      src/main/java/com/biutag/supervision/pojo/vo/TaskTestingAlcoholPeopleVo.java
  10. 11
      src/main/java/com/biutag/supervision/service/SupRiskPersonalControlRecordService.java
  11. 11
      src/main/java/com/biutag/supervision/service/SupRiskPersonalService.java
  12. 5
      src/main/java/com/biutag/supervision/service/SupTaskService.java
  13. 23
      src/main/java/com/biutag/supervision/util/ImgUtil.java
  14. 45
      src/main/java/com/biutag/supervision/util/ImgUtils.java
  15. 26
      src/test/java/com/biutag/supervision/PhotoTests.java

4
src/main/java/com/biutag/supervision/controller/FileController.java

@ -7,7 +7,7 @@ import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.dto.FileBase64Dto;
import com.biutag.supervision.pojo.vo.FileVo;
import com.biutag.supervision.service.FileService;
import com.biutag.supervision.util.ImgUtil;
import com.biutag.supervision.util.ImgUtils;
import com.biutag.supervision.util.WordUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@ -80,7 +80,7 @@ public class FileController {
}
InputStream is = fileService.download(filepath);
String base64 = Base64.getEncoder().encodeToString(is.readAllBytes());
if (ImgUtil.isImg(filepath)) {
if (ImgUtils.isImg(filepath)) {
base64 = String.format("data:image/%s;base64,", FileUtil.extName(filepath).toLowerCase()) + base64;
}
return Result.success(base64);

4
src/main/java/com/biutag/supervision/controller/books/NegativeBookController.java

@ -16,7 +16,7 @@ import com.biutag.supervision.pojo.entity.*;
import com.biutag.supervision.pojo.param.NegativeQueryParam;
import com.biutag.supervision.pojo.vo.*;
import com.biutag.supervision.service.*;
import com.biutag.supervision.util.ImgUtil;
import com.biutag.supervision.util.ImgUtils;
import dm.jdbc.util.StringUtil;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
@ -337,7 +337,7 @@ public class NegativeBookController {
AtomicInteger i = new AtomicInteger(0);
List<ImageData> imageDataList = negativeFiles.stream().filter(file -> item.getId().equals(file.getNegtiveId()))
// 过滤图片
.filter(file -> ImgUtil.isImg(file.getFileName())).map(file -> {
.filter(file -> ImgUtils.isImg(file.getFileName())).map(file -> {
// 下载文件
InputStream is = fileService.download(file.getFilePath());
byte[] bytes = IoUtil.readBytes(is);

8
src/main/java/com/biutag/supervision/mapper/SupRiskPersonalControlRecordMapper.java

@ -0,0 +1,8 @@
package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.SupRiskPersonalControlRecord;
public interface SupRiskPersonalControlRecordMapper extends BaseMapper<SupRiskPersonalControlRecord> {
}

8
src/main/java/com/biutag/supervision/mapper/SupRiskPersonalMapper.java

@ -0,0 +1,8 @@
package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.SupRiskPersonal;
public interface SupRiskPersonalMapper extends BaseMapper<SupRiskPersonal> {
}

62
src/main/java/com/biutag/supervision/pojo/entity/SupRiskPersonal.java

@ -0,0 +1,62 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Setter
@Getter
public class SupRiskPersonal {
// 证件号码
@TableId(value = "id_code")
private String idCode;
// 姓名
@TableField("name")
private String name;
// 性别男1女2
@TableField("gender")
private String gender;
// 年龄
@TableField("age")
private Integer age;
// 手机号
@TableField("mobile")
private String mobile;
// 人员类别
@TableField("personal_type")
private String personalType;
// 管控级别
@TableField("control_level")
private String controlLevel;
// 责任单位id
@TableField("responsible_depart_id")
private String responsibleDepartId;
// 责任单位名称
@TableField("responsible_depart_name")
private String responsibleDepartName;
// 责任民警警号
@TableField("responsible_emp_no")
private String responsibleEmpNo;
// 责任民警姓名
@TableField("responsible_name")
private String responsibleName;
// 创建时间
@TableField("create_time")
private LocalDateTime createTime;
}

43
src/main/java/com/biutag/supervision/pojo/entity/SupRiskPersonalControlRecord.java

@ -0,0 +1,43 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Setter
@Getter
public class SupRiskPersonalControlRecord {
// 主键
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
// 姓名
@TableField("name")
private String name;
// 证件号码
@TableField("id_code")
private String idCode;
// 包保督察人员警号
@TableField("control_emp_no")
private String controlEmpNo;
// 包保督察人员姓名
@TableField("control_name")
private String controlName;
// 管控间隔
@TableField("control_time_interval")
private String controlTimeInterval;
// 创建时间
@TableField("create_time")
private LocalDateTime createTime;
}

2
src/main/java/com/biutag/supervision/pojo/entity/SupTaskTestingAlcoholPeople.java

@ -32,8 +32,6 @@ public class SupTaskTestingAlcoholPeople {
@TableField("id_code")
private String idCode;
private String mobile;
// 单位ID
@TableField("depart_id")
private String departId;

4
src/main/java/com/biutag/supervision/pojo/vo/TaskCountVo.java

@ -11,9 +11,9 @@ import lombok.Setter;
@Getter
public class TaskCountVo {
private Long todoCount;
private Long todoCount = 0L;
private Long doneCount;
private Long doneCount = 0L;
private Long negativeTodoCount;

2
src/main/java/com/biutag/supervision/pojo/vo/TaskTestingAlcoholPeopleVo.java

@ -26,6 +26,8 @@ public class TaskTestingAlcoholPeopleVo {
// 身份证
private String idCode;
private String mobile;
// 测酒状态
private String status;

11
src/main/java/com/biutag/supervision/service/SupRiskPersonalControlRecordService.java

@ -0,0 +1,11 @@
package com.biutag.supervision.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.pojo.entity.SupRiskPersonalControlRecord;
import com.biutag.supervision.mapper.SupRiskPersonalControlRecordMapper;
import org.springframework.stereotype.Service;
@Service
public class SupRiskPersonalControlRecordService extends ServiceImpl<SupRiskPersonalControlRecordMapper, SupRiskPersonalControlRecord> {
}

11
src/main/java/com/biutag/supervision/service/SupRiskPersonalService.java

@ -0,0 +1,11 @@
package com.biutag.supervision.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.pojo.entity.SupRiskPersonal;
import com.biutag.supervision.mapper.SupRiskPersonalMapper;
import org.springframework.stereotype.Service;
@Service
public class SupRiskPersonalService extends ServiceImpl<SupRiskPersonalMapper, SupRiskPersonal> {
}

5
src/main/java/com/biutag/supervision/service/SupTaskService.java

@ -18,6 +18,8 @@ import com.biutag.supervision.pojo.vo.TaskVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Objects;
@RequiredArgsConstructor
@Service
public class SupTaskService extends ServiceImpl<SupTaskMapper, SupTask> {
@ -52,6 +54,9 @@ public class SupTaskService extends ServiceImpl<SupTaskMapper, SupTask> {
}
});
TaskCountVo taskCountVo = baseMapper.queryTaskCount(queryWrapper);
if (Objects.isNull(taskCountVo)) {
taskCountVo = new TaskCountVo();
}
Page<NegativeWorkModel> workModelPage = negativeWorkService.page(new NegativeQueryParam(), WorkStatusEnum.todo.name());
taskCountVo.setNegativeTodoCount(workModelPage.getTotal());
return taskCountVo;

23
src/main/java/com/biutag/supervision/util/ImgUtil.java

@ -1,23 +0,0 @@
package com.biutag.supervision.util;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import java.util.List;
/**
* @author wxc
* @date 2025/3/27
*/
public class ImgUtil {
public final static List<String> IMG_TYPES = List.of("jpg", "jpeg", "png", "gif", "ico", "svg", "webp");
public static boolean isImg(String fileName) {
if (StrUtil.isBlank(fileName)) {
return false;
}
return IMG_TYPES.contains(FileUtil.extName(fileName).toLowerCase());
}
}

45
src/main/java/com/biutag/supervision/util/ImgUtils.java

@ -0,0 +1,45 @@
package com.biutag.supervision.util;
import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.util.List;
/**
* @author wxc
* @date 2025/3/27
*/
public class ImgUtils {
public final static List<String> IMG_TYPES = List.of("jpg", "jpeg", "png", "gif", "ico", "svg", "webp");
public static boolean isImg(String fileName) {
if (StrUtil.isBlank(fileName)) {
return false;
}
return IMG_TYPES.contains(FileUtil.extName(fileName).toLowerCase());
}
public static String createSquareThumbnailBase64(InputStream is, int j) {
BufferedImage bufferedImage = ImgUtil.read(is);
int h = Math.min(bufferedImage.getHeight(), bufferedImage.getWidth());
int x = 0;
int y = 0;
if (bufferedImage.getHeight() >= bufferedImage.getWidth()) {
y = (bufferedImage.getHeight() - bufferedImage.getWidth()) / 2;
} else {
x = (bufferedImage.getWidth() - bufferedImage.getHeight()) / 2;
}
// 裁剪
Image cutImg = cn.hutool.core.img.ImgUtil.cut(bufferedImage, new Rectangle(x, y, h, h));
// 缩放
Image scaleImg = cn.hutool.core.img.ImgUtil.scale(cutImg, (float) NumberUtil.div(j, h));
return ImgUtil.toBase64(scaleImg, "jpg");
}
}

26
src/test/java/com/biutag/supervision/PhotoTests.java

@ -0,0 +1,26 @@
package com.biutag.supervision;
import com.biutag.supervision.util.ImgUtils;
import org.junit.jupiter.api.Test;
import java.io.FileInputStream;
import java.io.IOException;
/**
* @author wxc
* @date 2025/7/3
*/
public class PhotoTests {
@Test
public void testThumbnail() throws IOException {
//createSquareThumbnail(new FileInputStream("C:\\Users\\ldj\\Desktop\\文件类型\\3.jpg"), "D:\\deploy\\1.png", 100, true);
FileInputStream is = new FileInputStream("C:\\Users\\ldj\\Desktop\\文件类型\\3.jpg");
String base64 = ImgUtils.createSquareThumbnailBase64(is, 100);
System.out.println(base64);
}
}
Loading…
Cancel
Save