diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/CqEnterController.java b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/CqEnterController.java index eca0545..4975421 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/CqEnterController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/CqEnterController.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.minio.MinioClient; import io.minio.PutObjectOptions; import io.swagger.annotations.Api; +import io.swagger.models.auth.In; import lombok.RequiredArgsConstructor; import net.shapelight.common.config.MinioConfig; import net.shapelight.common.utils.R; @@ -76,8 +77,8 @@ public class CqEnterController { } @GetMapping("/rulesByType") - public R rulesByType(int typeId){ - if(typeId == 0){ + public R rulesByType(Integer typeId){ + if(typeId == null){ typeId = cqMemberMapper.speciallyForVisitors(); } List typeRules = cqEnterMapper.rulesByType(typeId); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/vo/TypeRules.java b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/vo/TypeRules.java index aa1bd81..85da58d 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/vo/TypeRules.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/vo/TypeRules.java @@ -11,4 +11,5 @@ public class TypeRules { private String checkItem; private String remark; private int state; + private int id; } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/member/CqMemberController.java b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/member/CqMemberController.java index 3add067..5ce6f44 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/member/CqMemberController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/member/CqMemberController.java @@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.minio.MinioClient; import io.minio.PutObjectOptions; import io.swagger.annotations.Api; +import io.swagger.models.auth.In; +import lombok.Builder; import lombok.RequiredArgsConstructor; import net.shapelight.common.config.MinioConfig; import net.shapelight.common.utils.R; @@ -26,6 +28,10 @@ import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.io.InputStream; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -55,8 +61,7 @@ public class CqMemberController { @GetMapping("/list") public R list(@RequestParam(defaultValue = "1") int page, - @RequestParam(defaultValue = "10") int size, - String unitName) { + @RequestParam(defaultValue = "10") int size) { // 创建分页对象 Page pageRequest = new Page<>(page, size); @@ -89,21 +94,21 @@ public class CqMemberController { memberListVo.setIdCard(tenSafeVideoEntity.getIdCard()); /* memberListVo.setIsEnterSulfurArea(tenSafeVideoEntity.getIsEnterSulfurArea());*/ if (tenSafeVideoEntity.getIsEnterSulfurArea() == null) { - memberListVo.setIsEnterSulfurArea("是"); + memberListVo.setIsEnterSulfurArea(0); } else { - memberListVo.setIsEnterSulfurArea("否"); + memberListVo.setIsEnterSulfurArea(tenSafeVideoEntity.getIsEnterSulfurArea()); } //memberListVo.setIsProtectDevice(tenSafeVideoEntity.getIsProtectDevice()); if (tenSafeVideoEntity.getIsProtectDevice() == null) { - memberListVo.setIsProtectDevice("是"); + memberListVo.setIsProtectDevice(0); } else { - memberListVo.setIsProtectDevice("否"); + memberListVo.setIsProtectDevice(tenSafeVideoEntity.getIsProtectDevice()); } //memberListVo.setIsWatchSafeVideo(tenSafeVideoEntity.getIsWatchSafeVideo()); if (tenSafeVideoEntity.getIsWatchSafeVideo() == null) { - memberListVo.setIsWatchSafeVideo("是"); + memberListVo.setIsWatchSafeVideo(0); } else { - memberListVo.setIsWatchSafeVideo("否"); + memberListVo.setIsWatchSafeVideo(tenSafeVideoEntity.getIsWatchSafeVideo()); } memberListVo.setEmployeeType(cqMemberMapper. @@ -129,6 +134,172 @@ public class CqMemberController { return R.ok(); } + + + @GetMapping("/find") + public R find(@RequestParam(defaultValue = "1") int page, + @RequestParam(defaultValue = "10") int size, + String orgId, String name, String idCard, Integer personTypeId, String phone, + String startDate, String endDate, int isvisitor, Integer isWatched) { + + + // 创建分页对象 + Page pageRequest = new Page<>(page, size); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + + + if (orgId != null && !orgId.isEmpty()){ + //orgId变成cellId + Long cellId = cqMemberMapper.orgidBecomesCellId(orgId); + queryWrapper.eq("cell_id", cellId); + } + + if (name != null && !name.isEmpty()){ + queryWrapper.eq("name", name); + } + + if (idCard != null && !idCard.isEmpty()){ + queryWrapper.eq("id_card", idCard); + } + + if (personTypeId != null){ + queryWrapper.eq("label_id", idCard); + } + + if (phone != null && !phone.isEmpty()){ + queryWrapper.eq("mobile", phone); + } + + if (isvisitor == 1){ + Integer i = cqMemberMapper.speciallyForVisitors(); + queryWrapper.eq("label_id", i); + } + if (isWatched != null){ + queryWrapper.eq("is_watch_safe_video", isWatched); + } + + // 对于日期,确保它们是字符串且非空,并进行适当转换 + if (startDate != null && !startDate.isEmpty()) { + // 这里假设 startDate 是 String 类型,并转换为 Date + Date parsedStartDate = parseDate(startDate); + if (parsedStartDate != null) { + queryWrapper.gt("live_start", parsedStartDate); + } + } + + if (endDate != null && !endDate.isEmpty()) { + // 同样处理 endDate + Date parsedEndDate = parseDate(endDate); + if (parsedEndDate != null) { + queryWrapper.lt("live_end", parsedEndDate); + } + } + + queryWrapper.orderByDesc("last_update_time"); + + // 使用 MyBatis-Plus 提供的分页查询 + IPage pageResult = cqMemberMapper.selectPage(pageRequest, queryWrapper); + + List list = pageResult.getRecords(); + System.out.println("list = " + list); + + return R.ok().put("data", list).put("total", pageResult.getTotal()); + } + + + public Date parseDate(String dateStr) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); // 根据实际日期格式调整 + try { + return sdf.parse(dateStr); + } catch (ParseException e) { + e.printStackTrace(); + return null; // 处理异常 + } + } + + @GetMapping("/queryVisitor") + public R queryVisitor(@RequestParam(defaultValue = "1") int page, + @RequestParam(defaultValue = "10") int size, + String orgId, String name, String idCard) { + // 创建分页对象 + Page pageRequest = new Page<>(page, size); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + + //orgId变成cellId + Long cellId = cqMemberMapper.orgidBecomesCellId(orgId); + + // 假设你想按名字进行筛选(name 为数据库中的字段名) + if (!orgId.isEmpty()){ + queryWrapper.eq("cell_id", cellId); + } + + if (!name.isEmpty()){ + queryWrapper.eq("name", name); + } + + if (!idCard.isEmpty()){ + queryWrapper.eq("id_card", idCard); + } + + + queryWrapper.eq("label_id", 69); + + + queryWrapper.orderByDesc("upload_time"); + + + // 使用 MyBatis-Plus 提供的分页查询 + IPage pageResult = cqMemberMapper.selectPage(pageRequest, null); + + List list = pageResult.getRecords(); + + List listVo = new ArrayList<>(); + + for (TenPersonEntity tenSafeVideoEntity : list) { + MemberListVo memberListVo = new MemberListVo(); + memberListVo.setId(tenSafeVideoEntity.getPersonId()); + memberListVo.setUnitId(tenSafeVideoEntity.getOrgId()); + memberListVo.setUnitName(cqMemberMapper.lookUpTheNameBasedOnTheDepartmentId + (tenSafeVideoEntity.getOrgId())); + memberListVo.setName(tenSafeVideoEntity.getName()); + memberListVo.setSex(tenSafeVideoEntity.getGender() == 0 ? "女" : "男"); + memberListVo.setPhone(tenSafeVideoEntity.getMobile()); + memberListVo.setIdCard(tenSafeVideoEntity.getIdCard()); + /* memberListVo.setIsEnterSulfurArea(tenSafeVideoEntity.getIsEnterSulfurArea());*/ + if (tenSafeVideoEntity.getIsEnterSulfurArea() == null) { + memberListVo.setIsEnterSulfurArea(0); + } else { + memberListVo.setIsEnterSulfurArea(tenSafeVideoEntity.getIsEnterSulfurArea()); + } + //memberListVo.setIsProtectDevice(tenSafeVideoEntity.getIsProtectDevice()); + if (tenSafeVideoEntity.getIsProtectDevice() == null) { + memberListVo.setIsProtectDevice(0); + } else { + memberListVo.setIsProtectDevice(tenSafeVideoEntity.getIsProtectDevice()); + } + //memberListVo.setIsWatchSafeVideo(tenSafeVideoEntity.getIsWatchSafeVideo()); + if (tenSafeVideoEntity.getIsWatchSafeVideo() == null) { + memberListVo.setIsWatchSafeVideo(0); + } else { + memberListVo.setIsWatchSafeVideo(tenSafeVideoEntity.getIsWatchSafeVideo()); + } + + memberListVo.setEmployeeType(cqMemberMapper. + takeTheNameAccordingToType(tenSafeVideoEntity.getPersonType())); + + + memberListVo.setIsExtract(tenSafeVideoEntity.getFaceFailure()); + + listVo.add(memberListVo); + } + + return R.ok().put("data", listVo).put("total", pageResult.getTotal()); + } + + + @PostMapping("/Upload") public R gbUpload(MultipartFile file) { if (file.isEmpty() || file.getSize() == 0) { @@ -189,33 +360,82 @@ public class CqMemberController { long id = new SnowflakeIdWorker().nextId(); tenPersonEntity.setPersonId(id); tenPersonEntity.setUuid(UUIDUtil.uuid()); - tenPersonEntity.setCellId(1255898969448382468L); + + //这里是不是要加个选项 + tenPersonEntity.setCellId(cqMemberMapper.orgidBecomesCellId(visitorDto.getOrgId())); tenPersonEntity.setAppFlag(0); //tenPersonEntity.setDeptId(cqSafeVideoMapper.runTheNameById(visitorDto.getUnitName())); - tenPersonEntity.setDeptId(Long.valueOf(visitorDto.getUnitId())); + tenPersonEntity.setDeptId(cqMemberMapper.orgidBecomesCellId(visitorDto.getOrgId())); tenPersonEntity.setLabelId(cqMemberMapper.speciallyForVisitors()); tenPersonEntity.setName(visitorDto.getName()); - tenPersonEntity.setGender(visitorDto.getSex()); + + if (visitorDto.getSex() != null){ + tenPersonEntity.setGender(visitorDto.getSex()); + }else{ + tenPersonEntity.setGender(2); + } tenPersonEntity.setIc(visitorDto.getIdCard()); tenPersonEntity.setMobile(visitorDto.getPhone()); tenPersonEntity.setOrgImageTemp(visitorDto.getFacePhotoUrl()); tenPersonEntity.setIsProtectDevice(visitorDto.getIsProtectDevice()); tenPersonEntity.setIsEnterSulfurArea(visitorDto.getIsEnterSulfurArea()); tenPersonEntity.setIsWatchSafeVideo(visitorDto.getIsWatchSafeVideo()); + if(visitorDto.getStartDate()!=null){ + //tenPersonEntity.setLiveStart(visitorDto.getStartDate()); + + String startDateStr = visitorDto.getStartDate(); // 前端传来的字符串日期 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // 根据前端传来的日期格式设置 + + try { + LocalDate localDate = LocalDate.parse(startDateStr, formatter); // 将字符串转换为 LocalDate + Date startDate = java.sql.Date.valueOf(localDate); // 转换为 java.util.Date + tenPersonEntity.setLiveStart(startDate); // 设置到实体中 + } catch (Exception e) { + e.printStackTrace(); // 处理异常 + // 你可以选择抛出自定义异常或返回错误信息 + } + + + + } + if (visitorDto.getEndDate()!=null){ + String endDateStr = visitorDto.getEndDate(); // 前端传来的字符串日期 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // 根据前端传来的日期格式设置 + + try { + LocalDate localDate = LocalDate.parse(endDateStr, formatter); // 将字符串转换为 LocalDate + Date endDate = java.sql.Date.valueOf(localDate); // 转换为 java.util.Date + tenPersonEntity.setLiveEnd(endDate); // 设置到实体中 + } catch (Exception e) { + e.printStackTrace(); // 处理异常 + // 你可以选择抛出自定义异常或返回错误信息 + } + } net.shapelight.modules.ten.entity.TenPersonEntity tenPersonEntity1 = new net.shapelight.modules.ten.entity.TenPersonEntity(); //把前面的复制到后面 BeanUtils.copyProperties(tenPersonEntity, tenPersonEntity1); if (tenPersonService.saveTenPerson(tenPersonEntity1) == 0) { - return R.ok(); + return R.ok().put("data", tenPersonEntity1); } else { return R.error(); } } + @PutMapping("batchChangeStatus") + public R batchChangeStatus(List memberIds){ + + for (Long memberId : memberIds) { + cqMemberMapper.changeViewingState(memberId); + } + + return R.ok(); + } + + } \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/member/dto/VisitorDto.java b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/member/dto/VisitorDto.java index c6a5de9..eb0efd4 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/member/dto/VisitorDto.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/member/dto/VisitorDto.java @@ -5,19 +5,24 @@ import lombok.Data; import lombok.NoArgsConstructor; import net.shapelight.common.base.BaseEntity; +import java.util.Date; + @Data @AllArgsConstructor @NoArgsConstructor public class VisitorDto extends BaseEntity { - private Integer unitId; + private String orgId; private String name; - private int sex; + private Integer sex; private String idCard; private String phone; private String facePhotoUrl; private int isProtectDevice; //防护设备 private int isEnterSulfurArea; //含硫 private int isWatchSafeVideo; //安全视频是否观看 + private String startDate; + private String endDate; + } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/member/vo/MemberListVo.java b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/member/vo/MemberListVo.java index 9bdebf3..36e3675 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/member/vo/MemberListVo.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/member/vo/MemberListVo.java @@ -21,9 +21,9 @@ public class MemberListVo { private String phone; //身份证号 private String idCard; - private String isEnterSulfurArea; //含硫 - private String isProtectDevice; //防护设备 - private String isWatchSafeVideo; //安全视频是否观看 + private int isEnterSulfurArea; //含硫 + private int isProtectDevice; //防护设备 + private int isWatchSafeVideo; //安全视频是否观看 //员工类型 private String employeeType; //是否提取成功 diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/dal/mysql/member/CqMemberMapper.java b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/dal/mysql/member/CqMemberMapper.java index 1d99b91..d8e04cf 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/dal/mysql/member/CqMemberMapper.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/dal/mysql/member/CqMemberMapper.java @@ -16,4 +16,8 @@ public interface CqMemberMapper extends BaseMapper { String takeTheNameAccordingToType(Integer personType); Integer speciallyForVisitors(); + + Long orgidBecomesCellId(String orgId); + + int changeViewingState(Long memberId); } diff --git a/shapelight-admin/src/main/resources/mapper/iCq/CqEnterMapper.xml b/shapelight-admin/src/main/resources/mapper/iCq/CqEnterMapper.xml index 656542e..d8b05c2 100644 --- a/shapelight-admin/src/main/resources/mapper/iCq/CqEnterMapper.xml +++ b/shapelight-admin/src/main/resources/mapper/iCq/CqEnterMapper.xml @@ -28,7 +28,7 @@ - SELECT name FROM ten_cell_dept WHERE org_id = #{orgId} + SELECT name FROM ten_cell WHERE org_id = #{orgId} SELECT label_id FROM ten_label WHERE name = '访客人员' + \ No newline at end of file