长庆项目day2

This commit is contained in:
ovo 2024-10-18 20:30:48 +08:00
parent 1def3f300d
commit 7203d655b3
8 changed files with 260 additions and 21 deletions

View File

@ -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> typeRules = cqEnterMapper.rulesByType(typeId);

View File

@ -11,4 +11,5 @@ public class TypeRules {
private String checkItem;
private String remark;
private int state;
private int id;
}

View File

@ -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<TenPersonEntity> 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<TenPersonEntity> pageRequest = new Page<>(page, size);
QueryWrapper<TenPersonEntity> 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<TenPersonEntity> pageResult = cqMemberMapper.selectPage(pageRequest, queryWrapper);
List<TenPersonEntity> 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<TenPersonEntity> pageRequest = new Page<>(page, size);
QueryWrapper<TenPersonEntity> 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<TenPersonEntity> pageResult = cqMemberMapper.selectPage(pageRequest, null);
List<TenPersonEntity> list = pageResult.getRecords();
List<MemberListVo> 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());
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<Long> memberIds){
for (Long memberId : memberIds) {
cqMemberMapper.changeViewingState(memberId);
}
return R.ok();
}
}

View File

@ -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;
}

View File

@ -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;
//是否提取成功

View File

@ -16,4 +16,8 @@ public interface CqMemberMapper extends BaseMapper<TenPersonEntity> {
String takeTheNameAccordingToType(Integer personType);
Integer speciallyForVisitors();
Long orgidBecomesCellId(String orgId);
int changeViewingState(Long memberId);
}

View File

@ -28,7 +28,7 @@
<select id="rulesByType" resultType="net.shapelight.modules.iCq.controller.enter.vo.TypeRules">
SELECT
tec.check_item, tec.remark,
tect.state
tect.state, tect.id
FROM
ten_enter_config tec
JOIN

View File

@ -2,10 +2,15 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.shapelight.modules.iCq.dal.mysql.member.CqMemberMapper">
<update id="changeViewingState">
UPDATE ten_person
SET is_watch_safe_video = NOT is_watch_safe_video
WHERE member_id = #{memberId};
</update>
<select id="lookUpTheNameBasedOnTheDepartmentId" resultType="java.lang.String">
SELECT name FROM ten_cell_dept WHERE org_id = #{orgId}
SELECT name FROM ten_cell WHERE org_id = #{orgId}
</select>
<select id="takeTheNameAccordingToType" resultType="java.lang.String">
SELECT DISTINCT(name) from ten_label WHERE type = #{personType}
@ -13,4 +18,7 @@
<select id="speciallyForVisitors" resultType="java.lang.Integer">
SELECT label_id FROM ten_label WHERE name = '访客人员'
</select>
<select id="orgidBecomesCellId" resultType="java.lang.Long">
SELECT cell_id from ten_cell WHERE org_id = #{orgId}
</select>
</mapper>