Compare commits

...

7 Commits

Author SHA1 Message Date
ovo b08a36222b 长庆项目11.06 2024-11-06 10:08:43 +08:00
ovo 139718fc34 长庆项目10.30 2024-10-30 15:42:36 +08:00
suixing 2f2203d7ee 开门接口 2024-10-25 19:40:43 +08:00
ovo ca1ca75079 长庆项目10.25 2024-10-25 14:58:17 +08:00
ovo 6fea9672af 长庆项目10.24 2024-10-24 14:05:57 +08:00
ovo a861cad96f 长庆项目10.23 2024-10-23 15:37:01 +08:00
ovo 9927f980de 长庆项目 2024-10-21 17:21:41 +08:00
62 changed files with 2521 additions and 621 deletions

View File

@ -30,7 +30,7 @@
<junit.version>4.12</junit.version>
<jedis.version>2.9.0</jedis.version>
<druid.version>1.2.13</druid.version>
<mybatisplus.version>3.1.2</mybatisplus.version>
<mybatisplus.version>3.3.0</mybatisplus.version>
<mysql.version>8.0.25</mysql.version>
<mssql.version>4.0</mssql.version>
<oracle.version>11.2.0.3</oracle.version>
@ -279,6 +279,12 @@
<version>1.45</version>
</dependency>
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-boot-starter</artifactId>
<version>1.5.0</version>
</dependency>
</dependencies>
<!-- 阿里云maven仓库 -->

View File

@ -320,6 +320,37 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<!--
1. 加密后,方法体被清空,保留方法参数、注解等信息.主要兼容swagger文档注解扫描
2. 方法体被清空后,反编译只能看到方法名和注解,看不到方法体的具体内容
3. 加密后的项目需要设置javaagent来启动,启动过程中解密class,完全内存解密,不留下任何解密后的文件
4. 启动加密后的jar,生成xxx-encrypted.jar,这个就是加密后的jar文件,加密后不可直接执行
5. 无密码启动方式,java -javaagent:xxx-encrypted.jar -jar xxx-encrypted.jar
6. 有密码启动方式,java -javaagent:xxx-encrypted.jar='-pwd= 密码' -jar xxx-encrypted.jar
-->
<groupId>net.roseboy</groupId>
<artifactId>classfinal-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<password>#</password><!-- #表示启动时不需要密码,事实上对于代码混淆来说,这个密码没什么用,它只是一个启动密码 -->
<excludes>org.spring</excludes>
<packages>net.shapelight</packages><!-- 加密的包名,多个包用逗号分开 -->
<cfgfiles>application.yml,application-dev.yml</cfgfiles><!-- 加密的配置文件,多个包用逗号分开 -->
<libjars>hutool-all.jar</libjars> <!-- jar包lib下面要加密的jar依赖文件,多个包用逗号分开 -->
<!--<code>xxxxx</code> &lt;!&ndash; 指定机器启动,机器码 不绑定机器码 就注释掉此项 &ndash;&gt;-->
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>classFinal</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 跳过单元测试 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -345,6 +376,9 @@
</configuration>
<!-- 运行命令 mvn clean package docker:build 打包并生成docker镜像 -->
</plugin>
</plugins>
</build>
</project>

View File

@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
//import org.bytedeco.opencv.opencv_core.CvPoint;
//import org.bytedeco.opencv.opencv_imgproc.CvFont;
import net.shapelight.common.config.CxFeignConfig;
import net.shapelight.common.utils.SslUtils;
import net.shapelight.modules.feignClient.CxFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
@ -60,11 +61,11 @@ public class AdminApplication {
// });
}
/* @Bean
@PostConstruct
void init(){
String res = cxFeignClient.getToken("5bb50ad0cc40e10565089c35aa61e7f3","k9?8bCqaQ*R1e2Wx0f65AzY4^]LDp@_Z");
void init() throws Exception {
SslUtils.ignoreSsl();
String res = cxFeignClient.getToken("5bb50ad0cc40e10565089c35aa61e7f3","k9?8bCqaQ*R1e2Wx0f65AzY4^]LDp@_Z");
CxFeignConfig.token = res;
}*/
}
}

View File

@ -18,6 +18,7 @@ public class CxFeignConfig implements RequestInterceptor {
@Override
public void apply(RequestTemplate requestTemplate) {
requestTemplate.header("Bearer ", token);
requestTemplate.header("Authorization",
"Bearer "+ token);
}
}

View File

@ -127,6 +127,7 @@ public class ShiroConfig {
filterMap.put("/swagger-ui.html", "anon");
filterMap.put("/swagger-resources/**", "anon");
filterMap.put("/captcha.jpg", "anon");
filterMap.put("/cq/demo/**", "anon");
// filterMap.put("/aaa.txt", "anon");
filterMap.put("/**", "oauth2");

View File

@ -0,0 +1,49 @@
package net.shapelight.common.utils;
import javax.net.ssl.*;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
public class SslUtils {
private static void trustAllHttpsCertificates() throws Exception {
TrustManager[] trustAllCerts = new TrustManager[1];
TrustManager tm = new miTM();
trustAllCerts[0] = tm;
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
static class miTM implements TrustManager,X509TrustManager {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public boolean isServerTrusted(X509Certificate[] certs) {
return true;
}
public boolean isClientTrusted(X509Certificate[] certs) {
return true;
}
public void checkServerTrusted(X509Certificate[] certs, String authType)
throws CertificateException {
return;
}
public void checkClientTrusted(X509Certificate[] certs, String authType)
throws CertificateException {
return;
}
}
/**
* 忽略HTTPS请求的SSL证书必须在openConnection之前调用
* @throws Exception
*/
public static void ignoreSsl() throws Exception{
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
return true;
}
};
trustAllHttpsCertificates();
HttpsURLConnection.setDefaultHostnameVerifier(hv);
}
}

View File

@ -8,4 +8,5 @@ import net.shapelight.modules.face.util.UserRamCache;
@Data
public class UserCompareInfo extends UserInfo {
private Float similar;
private Integer isHeadOnView; //0否1是
}

View File

@ -33,10 +33,8 @@ public class FaceEngineFactory extends BasePooledObjectFactory<FaceEngine> {
@Override
public FaceEngine create() {
FaceEngine faceEngine = new FaceEngine(ArcFaceAutoConfiguration.CACHE_LIB_FOLDER);
/* FaceEngine faceEngine = new FaceEngine("/softTemp/jar/82K111TPM121XK4H.dat");*/
// FaceEngine faceEngine = new FaceEngine("/home/huangyifang/gb/咸阳师范/ArcSoft_ArcFacePro_linux_java_V4.1/libs/LINUX64/");
int activeCode;
if (StringUtils.isNotEmpty(activeFile)) {

View File

@ -2,48 +2,52 @@ package net.shapelight.modules.face.rtsp;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONObject;
import com.arcsoft.face.FaceEngine;
import com.arcsoft.face.FaceFeature;
import com.arcsoft.face.FaceInfo;
import com.arcsoft.face.FaceSimilar;
import com.arcsoft.face.enums.ExtractType;
import com.arcsoft.face.toolkit.ImageFactory;
import com.arcsoft.face.toolkit.ImageInfo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import io.minio.MinioClient;
import io.minio.PutObjectOptions;
import lombok.extern.slf4j.Slf4j;
import net.shapelight.common.config.GlobalValue;
import net.shapelight.common.config.MinioConfig;
import net.shapelight.common.utils.Constant;
import net.shapelight.modules.face.dto.FaceRecognitionResDTO;
import net.shapelight.common.utils.UUIDUtil;
import net.shapelight.modules.face.entity.UserCompareInfo;
import net.shapelight.modules.face.enums.ErrorCodeEnum;
import net.shapelight.modules.face.face.FacePreviewInfo;
import net.shapelight.modules.face.rpc.BusinessException;
import net.shapelight.modules.face.service.FaceEngineService;
import net.shapelight.modules.face.service.impl.FaceEngineServiceImpl;
import net.shapelight.modules.face.util.UserInfo;
import net.shapelight.modules.face.util.UserRamGroup;
import net.shapelight.modules.feignClient.CxFeignClient;
import net.shapelight.modules.iCq.controller.video.vo.FaceVideoVo;
import net.shapelight.modules.ten.dao.TenCellDao;
import net.shapelight.modules.ten.entity.TenCellEntity;
import net.shapelight.modules.ten.entity.TenPersonEntity;
import net.shapelight.modules.ten.service.TenPersonService;
import net.shapelight.modules.ten.service.impl.TenPersonServiceImpl;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.bytedeco.javacpp.avutil;
import org.bytedeco.javacv.*;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.Frame;
import org.bytedeco.javacv.FrameGrabber;
import org.bytedeco.javacv.Java2DFrameConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import static org.bytedeco.javacpp.avutil.AV_LOG_ERROR;
@ -96,6 +100,15 @@ public class RtspFrameGrabber {
@Autowired
private TenPersonServiceImpl tenPersonService;
@Autowired
private TenCellDao tenCellDao;
@Autowired
private MinioConfig minioConfig;
@Autowired
private MinioClient minioClient;
private void createGrabber() {
try {
@ -137,7 +150,10 @@ public class RtspFrameGrabber {
log.error(e.getMessage());
}
}
public void startGrabber(String cellId) {
public List<FaceVideoVo> startGrabber(String cellId) {
List<FaceVideoVo> faceVideoVos = new ArrayList<>();
avutil.av_log_set_level(AV_LOG_ERROR);
Java2DFrameConverter java2DFrameConverter = new Java2DFrameConverter();
if (grabber == null) {
@ -149,7 +165,21 @@ public class RtspFrameGrabber {
if (frame != null) {
// logger.info("处理帧.............................................");
BufferedImage bi = java2DFrameConverter.getBufferedImage(frame);
byte[] bytes = imageToBytes(bi, "jpg");
/* InputStream frameInputStream = new ByteArrayInputStream(bytes);
String frameFileName = "temp/" + "frame_" + UUIDUtil.uuid()
+ ".jpg";
PutObjectOptions framePutObjectOptions = new PutObjectOptions(bytes.length, -1);
framePutObjectOptions.setContentType("image/jpeg");
minioClient.putObject(
minioConfig.getBucketName(), frameFileName, frameInputStream, framePutObjectOptions);
System.out.println("文件名 = " + globalValue.getMinioEndpoint() + "/" +
globalValue.getMinioBucketName() + "/" + frameFileName);*/
/* // 读取图片
BufferedImage image = ImageIO.read(new File("C:\\Users\\zhangbo\\OneDrive\\图片\\Camera Roll\\1寸相片.jpg"));
@ -161,7 +191,8 @@ public class RtspFrameGrabber {
// 转换为byte数组
byte[] imageBytes = baos.toByteArray();*/
imageRecognition(bytes,cellId);
faceVideoVos = imageRecognition(bytes, cellId);
System.out.println("faceVideoVos = " + faceVideoVos);
} else {
log.error("解码失败");
@ -188,6 +219,8 @@ public class RtspFrameGrabber {
}
}
} finally {
grabber = null;
}
// try {
// Thread.sleep(100);
@ -195,59 +228,134 @@ public class RtspFrameGrabber {
// logger.error(e.getMessage());
// }
return faceVideoVos;
}
public void recognition(MultipartFile file,String cellId) {
public List<FaceVideoVo> recognition(MultipartFile file,String cellId) {
try {
byte[] bytes = file.getBytes();
imageRecognition(bytes,cellId);
return imageRecognition(bytes, cellId);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private void imageRecognition(byte[] bytes,String cellId) {
private List<FaceVideoVo> imageRecognition(byte[] bytes,String cellId) {
List<FaceVideoVo> temp = new ArrayList<>();
if (bytes != null && bytes.length > 0) {
ImageInfo imageInfo = ImageFactory.getRGBData(bytes);
List<FaceInfo> faceInfoList = faceEngineService.detectFaces(imageInfo);
if (CollectionUtil.isNotEmpty(faceInfoList)) {
faceInfoList.forEach(faceInfo -> {
FaceRecognitionResDTO faceRecognitionResDTO = new FaceRecognitionResDTO();
faceRecognitionResDTO.setRect(faceInfo.getRect());
byte[] featureBytes = faceEngineService.extractFaceFeature(imageInfo, faceInfo, ExtractType.REGISTER);
/* FaceRecognitionResDTO faceRecognitionResDTO = new FaceRecognitionResDTO();
faceRecognitionResDTO.setRect(faceInfo.getRect());*/
byte[] featureBytes = faceEngineService.extractFaceFeature(imageInfo,
faceInfo, ExtractType.REGISTER);
if (featureBytes != null) {
//底库
List<UserInfo> userInfoList = UserRamGroup.getUserList(cellId);
List<UserCompareInfo> userCompareInfoList = faceEngineService.faceRecognition(featureBytes,userInfoList,Float.parseFloat(globalValue.getRecFaceThd()));
if(!userCompareInfoList.isEmpty()) {
UserCompareInfo userCompareInfo = userCompareInfoList.get(0);
//人脸对比 这里长度永远为1
List<UserCompareInfo> userCompareInfoList = faceEngineService
.faceRecognition(featureBytes, userInfoList, Float.parseFloat(globalValue.getRecFaceThd()));
for (UserCompareInfo userCompareInfo : userCompareInfoList) {
FaceVideoVo faceVideoVo = new FaceVideoVo();
//System.out.println("faceInfo = " + faceInfo.getRect());
faceVideoVo.setRect(faceInfo.getRect());
if (faceInfo.getFace3DAngle().getYaw() > 20 || faceInfo.getFace3DAngle().getYaw() < -20) {
faceVideoVo.setIsHeadOnView(0);
}else if (faceInfo.getFace3DAngle().getPitch() > 20 || faceInfo.getFace3DAngle().getPitch() < -20) {
faceVideoVo.setIsHeadOnView(0);
}else {
faceVideoVo.setIsHeadOnView(1);
}
faceVideoVo.setPersonId(userCompareInfo.getFaceId()).setName(userCompareInfo.getName());
InputStream frameInputStream = new ByteArrayInputStream(bytes);
String frameFileName = "temp/" + "frame_" + UUIDUtil.uuid()
+ ".jpg";
PutObjectOptions framePutObjectOptions = new PutObjectOptions(bytes.length, -1);
framePutObjectOptions.setContentType("image/jpeg");
try {
frameInputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
try {
minioClient.putObject(
minioConfig.getBucketName(), frameFileName, frameInputStream, framePutObjectOptions);
} catch (Exception e) {
throw new RuntimeException(e);
}
System.out.println("文件名 = " + globalValue.getMinioEndpoint() + "/" +
globalValue.getMinioBucketName() + "/" + frameFileName);
faceVideoVo.setImageUrl(frameFileName);
temp.add(faceVideoVo);
TenPersonEntity tenPerson = personService.getOne(new LambdaQueryWrapper<TenPersonEntity>()
.eq(TenPersonEntity::getPersonId,userCompareInfo.getFaceId()));
Map<Integer,String> personnelTypeMap = new HashMap<>();
personnelTypeMap.put(Constant.PERSON_TYPE_OWNER,"2");//内部人员
personnelTypeMap.put(Constant.PERSON_TYPE_MEMBER,"1");//承包商
personnelTypeMap.put(Constant.PERSON_TYPE_TENANT,"3");//长期供应商
Map<String,Object> params = new HashMap<>();
params.put("pmWatchVideoRecordId","");
params.put("orgId",tenPerson.getOrgId());
params.put("orgName","");
params.put("personnelName",tenPerson.getName());
params.put("personnelId",tenPerson.getOpenId());
params.put("personnelCardId",tenPerson.getIdCard());
params.put("personnelType",personnelTypeMap.get(tenPerson.getPersonType()));
params.put("dictSex",tenPerson.getGender()==0?"":"");
.eq(TenPersonEntity::getPersonId, userCompareInfo.getFaceId()));
Map<Integer, String> personnelTypeMap = new HashMap<>();
personnelTypeMap.put(Constant.PERSON_TYPE_OWNER, "2");//内部人员
personnelTypeMap.put(Constant.PERSON_TYPE_MEMBER, "1");//承包商
personnelTypeMap.put(Constant.PERSON_TYPE_TENANT, "3");//长期供应商
personnelTypeMap.put(Constant.PERSON_TYPE_GUEST, "4");//访客
//
Map<String, Object> params = new HashMap<>();
params.put("pmWatchVideoRecordId", "");
params.put("orgId", tenPerson.getOrgId());
params.put("orgName", tenCellDao.selectOne(new QueryWrapper<TenCellEntity>().eq("cell_id", tenPerson.getCellId())).getName());
params.put("personnelName", tenPerson.getName());
params.put("personnelId", tenPerson.getOpenId());
params.put("personnelCardId", tenPerson.getIdCard());
params.put("personnelType", personnelTypeMap.get(tenPerson.getPersonType()));
params.put("dictSex", tenPerson.getGender() == 0 ? "" : "");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
params.put("watchVideoTime",sdf.format(System.currentTimeMillis()));
tenPerson.setIsWatchSafeVideo(1);
JSONObject jsonObject = feignClient.savePmWatchVideoRecord(params);
if(jsonObject.getBool("success")!=null&&jsonObject.getBool("success")) {
params.put("watchVideoTime", sdf.format(System.currentTimeMillis()));
if(tenPerson.getIsWatchSafeVideo() != 1){
tenPerson.setIsWatchSafeVideo(faceVideoVo.getIsHeadOnView() == 0 ? 2 : 1);
}
//tenPerson.setIsWatchSafeVideo();
tenPersonService.updateById(tenPerson);
System.out.println("params = " + params);
if(faceVideoVo.getIsHeadOnView() == 1){
JSONObject jsonObject = feignClient.savePmWatchVideoRecord(params);
if (jsonObject.getBool("success") != null && jsonObject.getBool("success")) {
personService.update(new LambdaUpdateWrapper<TenPersonEntity>()
.set(TenPersonEntity::getIsWatchSafeVideo,1)
.eq(TenPersonEntity::getPersonId,userCompareInfo.getFaceId()));
.set(TenPersonEntity::getIsWatchSafeVideo, 1)
.eq(TenPersonEntity::getPersonId, userCompareInfo.getFaceId()));
}
}
}
} else {
log.error("图片不合格,未检测到人脸");
}
@ -257,7 +365,9 @@ public class RtspFrameGrabber {
log.error("图片不合格,未检测到人脸");
}
} else {
}
return temp;
}
/**

View File

@ -113,7 +113,9 @@ public class FaceEngineServiceImpl implements FaceEngineService {
//人脸检测得到人脸列表
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
//人脸检测
int errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
int errorCode = faceEngine.detectFaces(imageInfo.getImageData(),
imageInfo.getWidth(), imageInfo.getHeight(),
imageInfo.getImageFormat(), faceInfoList);
if (errorCode == 0) {
return faceInfoList;
} else {

View File

@ -20,38 +20,30 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import net.shapelight.common.config.GlobalValue;
import net.shapelight.common.config.MinioConfig;
import net.shapelight.common.config.MinioUtils;
import net.shapelight.common.utils.*;
import net.shapelight.modules.app.entity.AppUserEntity;
import net.shapelight.modules.app.service.AppUserService;
import net.shapelight.modules.face.dto.FaceRecognitionResDTO;
import net.shapelight.modules.face.entity.UserCompareInfo;
import net.shapelight.modules.face.service.FaceEngineService;
import net.shapelight.modules.face.util.Base64Util;
import net.shapelight.modules.face.util.UserInfo;
import net.shapelight.modules.face.util.UserRamCache;
import net.shapelight.modules.face.util.UserRamGroup;
import net.shapelight.modules.feignClient.CxFeignClient;
import net.shapelight.modules.httpapi.service.AuthService;
import net.shapelight.modules.httpapi.service.RecordSaveSyncService;
import net.shapelight.modules.iCq.controller.enter.to.EnterVo;
import net.shapelight.modules.iCq.dal.mysql.enter.CqEnterMapper;
import net.shapelight.modules.nettyapi.config.CmdConstant;
import net.shapelight.modules.nettyapi.config.MyMessage;
import net.shapelight.modules.nettyapi.utils.Result;
import net.shapelight.modules.iCq.service.enter.CqEnterServiceImpl;
import net.shapelight.modules.sys.entity.*;
import net.shapelight.modules.sys.service.*;
import net.shapelight.modules.ten.entity.*;
import net.shapelight.modules.ten.service.*;
import net.shapelight.modules.vo.*;
import org.apache.commons.io.FilenameUtils;
import org.apache.ibatis.annotations.Param;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
@ -123,7 +115,7 @@ public class HttpApiController {
@Autowired
private TenPersonTrainService trainService;
@Autowired
private CqEnterMapper cqEnterMapper;
private CqEnterServiceImpl cqEnterService;
/**
*
@ -167,6 +159,11 @@ public class HttpApiController {
}
}
// 处理 open 标志位
String openKey = "DeviceOpen-" + sn;
Object openValue = redisUtils.get(openKey);
Integer open = (openValue != null) ? Integer.valueOf(openValue.toString()) : 0;
//保存人脸个数
// deviceEntity.setFaceCount(faceCount);
// deviceEntity.setLastUpdateTime(new Date());
@ -261,6 +258,8 @@ public class HttpApiController {
}else{
configMap.put("displayFaceFlag",1);
}
// 返回 open 标志位
configMap.put("open", open);
return R.ok().put("data",configMap);
}
@ -302,6 +301,12 @@ public class HttpApiController {
tenPersonSyncService.removeAllDeletePersons(deviceEntity.getDeviceId(),deviceEntity.getTenantId());
Map<String,Object> allPersons = new HashMap<>();
allPersons.put("allPerson",resAll);
System.out.println("allPersons = " + allPersons);
//测试
return R.ok().put("data",allPersons);
}
@ -328,15 +333,23 @@ public class HttpApiController {
return res;
}
log.debug("单个获取:"+sn);
TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
// SysDeviceEntity sysDeviceEntity = sysDeviceService.getBySn(sn);
//----------------------------------------以下业务-----------------------------------------------------
JSONObject dataJson = jsonContent.getJSONObject("data");
Long uid = dataJson.getLong("uid");
System.out.println("uid = " + uid);
TenCellEntity cellEntity = tenCellService.getById(deviceEntity.getCellId());
TenPersonEntity p = tenPersonService.getById(uid,cellEntity.getCellId());
/* if(Objects.equals(p.getName(), "")){
System.out.println("pxxxxxxxxxxxxxxxxxxx = " + p);
}*/
if(p == null || p.getDeleteFlag().intValue() == 1){
return R.error("人员不存在");
}
@ -456,11 +469,13 @@ public class HttpApiController {
puser.setLabelName(p.getLabelName());
puser.setIsProtectDevice(p.getIsProtectDevice());
puser.setIsEnterSulfurArea(p.getIsEnterSulfurArea());
puser.setIsCheckCert(p.getIsCheckCert());
puser.setIsWatchSafeVideo(p.getIsWatchSafeVideo());
List<TenPersonCert> tenPersonCertList = certService.list(new LambdaQueryWrapper<TenPersonCert>()
.eq(TenPersonCert::getPerson,p.getPersonId()));
.eq(TenPersonCert::getPerson,p.getOpenId()));
List<TenPersonTrain> tenPersonTrainList = trainService.list(new LambdaQueryWrapper<TenPersonTrain>()
.eq(TenPersonTrain::getPersonId,p.getPersonId()));
.eq(TenPersonTrain::getPersonId,p.getOpenId()));
puser.setTenPersonCertList(tenPersonCertList);
puser.setTenPersonTrainList(tenPersonTrainList);
@ -470,6 +485,12 @@ public class HttpApiController {
syncEntity.setState(Constant.PERSON_SYNC_OK);
tenPersonSyncService.updateById(syncEntity);
if(puser.getUser_name().equals("")){
System.out.println("puser = " + puser);
}
return R.ok().put("data",puser);
}
@ -702,6 +723,10 @@ public class HttpApiController {
String appKey = jsonContent.getString("appKey");
String timestamp = jsonContent.getString("timestamp");
String sign = jsonContent.getString("sign");
System.out.println("sign = " + sign);
//鉴权
R res = authService.auth(sn,appKey,timestamp,sign);
if((Integer) res.get("code") != 0){
@ -840,24 +865,54 @@ public class HttpApiController {
personnelTypeMap.put(Constant.PERSON_TYPE_OWNER,"2");//内部人员
personnelTypeMap.put(Constant.PERSON_TYPE_MEMBER,"1");//承包商
personnelTypeMap.put(Constant.PERSON_TYPE_TENANT,"3");//长期供应商
personnelTypeMap.put(Constant.PERSON_TYPE_GUEST,"4");//访客
Map<String,Object> params = new HashMap<>();
params.put("pmEntryExitRecordId","");
params.put("orgId",memberEntity.getOrgId());
params.put("orgName",memberEntity.getCellName());
params.put("personnelName",memberEntity.getName());
//TODO 访客ID
params.put("personnelId",memberEntity.getOpenId());
params.put("personnelType",personnelTypeMap.get(memberEntity.getPersonType()));
params.put("entryOrExit",String.valueOf(deviceEntity.getGateFlag()+1));
params.put("entryExitTime",new Date(unlockTime));
params.put("accessControlName",memberEntity.getOpenId());
params.put("state","");
params.put("failureReason","");
/*cn.hutool.json.JSONObject jsonObject = cxFeignClient.savePmEntryExitRecord(params);
params.put("personnelCardId", memberEntity.getIdCard());
Integer type = null;
if (memberEntity.getPersonType() == 5001){
type = 1;
}
if (memberEntity.getPersonType() == 5000){
type = 2;
}
if (memberEntity.getPersonType() == 5002){
type = 3;
}
if (memberEntity.getPersonType() == 5005){
type = 4;
}
params.put("personnelType",type);
params.put("entryOrExit", deviceEntity.getGateFlag() + 1); //1进2出
SimpleDateFormat sfm = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
params.put("entryExitTime", sfm.format(new Date(unlockTime)));
params.put("accessControlName",deviceEntity.getName());
params.put("state",failureReason.isEmpty() ? "1" : "0");
params.put("failureReason",failureReason);
System.out.println("params = " + params);
cn.hutool.json.JSONObject jsonObject = cxFeignClient.savePmEntryExitRecord(params);
if(jsonObject.getBool("success")!=null && jsonObject.getBool("success")){
log.debug("同步进出场记录成功");
}else {
log.debug("同步进出场记录失败"+"姓名:"+memberEntity.getName()+",errorMessage"+jsonObject.getStr("message"));
}*/
}
return R.ok();
}
@ -1855,8 +1910,6 @@ public class HttpApiController {
return R.error("陌生人,禁止通行");
}
@PostMapping("/updatePersonByIdCard")
@ApiOperation("设备修改人员")
@ApiImplicitParams({
@ -2092,8 +2145,9 @@ public class HttpApiController {
@PostMapping("/role")
public R roleList(@Param(value = "sn")String sn) {
TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
List<EnterVo> enterVoList = cqEnterMapper.queryByCellId(deviceEntity.getCellId());
return R.ok().put("data",enterVoList);
System.out.println("cqEnterService.queryByCellId(sn) = " + cqEnterService.queryByCellId(sn));
return R.ok().put("data",cqEnterService.queryByCellId(sn));
}
}

View File

@ -0,0 +1,287 @@
package net.shapelight.modules.iCq.controller.demo;
import com.arcsoft.face.ActiveDeviceInfo;
import com.arcsoft.face.FaceEngine;
import com.arcsoft.face.Rect;
import io.minio.MinioClient;
import io.minio.PutObjectOptions;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import net.shapelight.common.config.GlobalValue;
import net.shapelight.common.config.MinioConfig;
import net.shapelight.common.utils.R;
import net.shapelight.common.utils.UUIDUtil;
import net.shapelight.modules.face.rtsp.RtspFrameGrabber;
import net.shapelight.modules.iCq.controller.video.vo.FaceVideoVo;
import net.shapelight.modules.iCq.service.enter.CqEnterServiceImpl;
import net.shapelight.modules.iCq.utils.DemoUtil;
import net.shapelight.modules.job.task.PersonSynchronousTask;
import net.shapelight.modules.ten.dao.TenCellDao;
import net.shapelight.modules.ten.dao.TenPersonDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
@RestController
@RequestMapping("cq/demo")
@Api(value = "入场校验", tags = {"入场校验"})
@RequiredArgsConstructor
public class DemoController {
private final CqEnterServiceImpl cqEnterService;
private final TenPersonDao tenPersonDao;
@Autowired
private PersonSynchronousTask task;
@Autowired
private TenCellDao tenCellDao;
@Autowired
private GlobalValue globalValue;
@Autowired
private RtspFrameGrabber rtspFrameGrabber;
private final MinioConfig minioConfig;
private final MinioClient minioClient;
@GetMapping("/save1")
public void saveSupplier(String type){
/* System.out.println("测试开始");
TenCellEntity tenCellEntity = tenCellDao.selectOne(new QueryWrapper<TenCellEntity>().eq("cell_id", "1255898969448382468"));
String jsonString = "{\n" +
" \"success\": true,\n" +
" \"message\": null,\n" +
" \"errCode\": \"0\",\n" +
" \"resCode\": 1,\n" +
" \"apiVersion\": \"1\",\n" +
" \"timestamp\": 1726651858,\n" +
" \"data\": {\n" +
" \"apiVersion\": null,\n" +
" \"list\": [\n" +
" {\n" +
" \"pmSupplierId\": \"75c0fd40bbda47528917898a69957683\",\n" +
" \"orgId\": \"ORGACQ100005358\",\n" +
" \"orgName\": \"油田开发事业部\",\n" +
" \"userName\": \"姓名\",\n" +
" \"supplierName\": \"23\",\n" +
" \"supplierCardId\": \"412345676543456765\",\n" +
" \"mobile\": \"13567543546\",\n" +
" \"enterValidPeriod\": \"2024-08-13 00:00:00\",\n" +
" \"enterValidPeriodEnd\": \"2024-09-26 00:00:00\",\n" +
" \"isEnterSulfurArea\": \"\",\n" +
" \"isProtectDevice\": \"\",\n" +
" \"isBlackList\": \"\",\n" +
" \"isWatchVideo\": \"未观看\",\n" +
" \"attachment\": null\n" +
" }\n" +
" ],\n" +
" \"total\": 1\n" +
" }\n" +
"}";
JSONObject jsonObject = new JSONObject(jsonString);
task.save(jsonObject, tenCellEntity);*/
task.getPmInternalPersonnelList2(type);
}
@GetMapping("/offline")
public R activeOffline() {
FaceEngine faceEngine;
String USER_HOME = System.getProperty("user.home");
System.out.println(USER_HOME);
String jvmName = System.getProperty("java.vm.name", "").toLowerCase();
String osName = System.getProperty("os.name", "").toLowerCase();
String osArch = System.getProperty("os.arch", "").toLowerCase();
String abiType = System.getProperty("sun.arch.abi", "").toLowerCase();
String libPath = System.getProperty("sun.boot.library.path", "").toLowerCase();
USER_HOME = System.getProperty("user.home");
if (jvmName.startsWith("dalvik") && osName.startsWith("linux")) {
osName = "android";
} else if (jvmName.startsWith("robovm") && osName.startsWith("darwin")) {
osName = "ios";
osArch = "arm";
} else if (osName.startsWith("mac os x") || osName.startsWith("darwin")) {
osName = "macosx";
} else {
int spaceIndex = osName.indexOf(' ');
if (spaceIndex > 0) {
osName = osName.substring(0, spaceIndex);
}
}
if (osArch.equals("i386") || osArch.equals("i486") || osArch.equals("i586") || osArch.equals("i686")) {
osArch = "x86";
} else if (osArch.equals("amd64") || osArch.equals("x86-64") || osArch.equals("x64")) {
osArch = "x86_64";
} else if (osArch.startsWith("aarch64") || osArch.startsWith("armv8") || osArch.startsWith("arm64")) {
osArch = "arm64";
} else if ((osArch.startsWith("arm")) && ((abiType.equals("gnueabihf")) || (libPath.contains("openjdk-armhf")))) {
osArch = "armhf";
} else if (osArch.startsWith("arm")) {
osArch = "arm";
}
String PLATFORM = osName + "-" + osArch;
System.out.println("PLATFORM = " + PLATFORM);
String CACHE_LIB_FOLDER = USER_HOME + "/.arcface/cache/" + "4.1" + "/" + PLATFORM + "/";
System.out.println("CACHE_LIB_FOLDER = " + CACHE_LIB_FOLDER);
if (Pattern.matches("windows.*", osName)) {
System.out.println("osName = " + osName);
faceEngine = new FaceEngine(CACHE_LIB_FOLDER);
}else{
// faceEngine = new FaceEngine("D:\\00_桌面\\ArcSoft_ArcFacePro_windows_x64_java_V4.1\\libs\\WIN64");
faceEngine = new FaceEngine(CACHE_LIB_FOLDER);
}
ActiveDeviceInfo activeDeviceInfo = new ActiveDeviceInfo();
int code = faceEngine.getActiveDeviceInfo(activeDeviceInfo);
// System.out.println("\n设备信息" + activeDeviceInfo.toString() + "\n"); // 这个com.arcsoft.face.model.ActiveDeviceInfo@4ad9b7b并不是设备信息
System.out.println("设备信息:" + activeDeviceInfo.getDeviceInfo() + "\n"); // 这个的结果才是设备信息
return R.ok().put("data", activeDeviceInfo.getDeviceInfo());
}
@PostMapping("/changeBucketPolicy")
public R changeBucketPolicy() {
String info;
try {
MinioClient minioClient = new MinioClient(
globalValue.getMinioEndpoint(), // MinIO 服务器的 URL
globalValue.getMinioAccessKey(), // 访问密钥
globalValue.getMinioSecretKey() // 密钥
);
String bucketName = "cell"; // 替换为你的桶名
String policy = "{ \"Version\": \"2012-10-17\", \"Statement\": [ { \"Effect\": \"Allow\", \"Principal\": { \"AWS\": [ \"*\" ] }, \"Action\": [ \"s3:GetObject\", \"s3:ListBucket\" ], \"Resource\": [ \"arn:aws:s3:::" + bucketName + "\", \"arn:aws:s3:::" + bucketName + "/*\" ] } ] }";
// 设置桶策略
minioClient.setBucketPolicy(bucketName, policy);
info = "Bucket policy set successfully";
} catch (Exception e) {
info = "Error occurred";
}
return R.ok().put("data", info);
}
/* @PostMapping("/drawRectangleOnImage")
public R DrawRectangleOnImage(@RequestParam("image") MultipartFile image, @RequestParam String cellId) {
List<FaceVideoVo> recognition = rtspFrameGrabber.recognition(image, cellId);
List<Rect> rects = new ArrayList<>();
for (FaceVideoVo faceVideoVo : recognition) {
rects.add(faceVideoVo.getRect());
}
draw(recognition.get(0).getImageUrl(), rects);
System.out.println("recognition = " + recognition);
return R.ok();
}*/
/* private String draw(String imageUrl, List<Rect> rectList) {
try {
// URL 读取图片
BufferedImage image = ImageIO.read(new URL(globalValue.getMinioEndpoint() + "/" +
globalValue.getMinioBucketName() + "/" + imageUrl));
// 获取绘图上下文
Graphics2D g2d = image.createGraphics();
g2d.setColor(Color.RED); // 设置框的颜色
g2d.setStroke(new BasicStroke(3)); // 设置框的线条宽度
// 遍历每个矩形框并绘制
for (Rect rect : rectList) {
int left = rect.left;
int top = rect.top;
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
g2d.drawRect(left, top, width, height);
}
// 释放资源
g2d.dispose();
// BufferedImage 转换为 InputStream 以便上传
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", os);
InputStream inputStream = new ByteArrayInputStream(os.toByteArray());
// 设置文件目录和名称
String catalogue = "temp/";
String extension = "jpg"; // 假设是 JPG 格式
String fileName = catalogue + "t_" + UUIDUtil.uuid() + "." + extension;
// 上传文件到 MinIO
PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1);
putObjectOptions.setContentType("image/jpeg");
minioClient.putObject(
minioConfig.getBucketName(), fileName, inputStream, putObjectOptions);
inputStream.close();
System.out.println("矩形框已绘制并上传到 MinIO文件路径" + globalValue.getMinioEndpoint() + "/" +
globalValue.getMinioBucketName() + "/" + fileName);
return fileName;
} catch (Exception e) {
e.printStackTrace();
}
return "error";
}*/
/*@GetMapping("/testUtil")
public R testUtil(){
return R.ok().put("data", DemoUtil.demo());
}*/
@GetMapping("/temp")
public R temp(){
tenPersonDao.insertTemp("111");
return R.ok();
}
}

View File

@ -0,0 +1,21 @@
package net.shapelight.modules.iCq.controller.demo.vo;
import com.arcsoft.face.Rect;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class DrawVo {
private String imageUrl;
private List<Rect> rectList;
}

View File

@ -1,19 +1,19 @@
package net.shapelight.modules.iCq.controller.enter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import net.shapelight.common.utils.R;
import net.shapelight.modules.iCq.controller.enter.to.FTo;
import net.shapelight.modules.iCq.controller.enter.vo.FirstVo;
import net.shapelight.modules.iCq.controller.enter.vo.PeronType;
import net.shapelight.modules.iCq.controller.enter.vo.TypeRules;
import net.shapelight.modules.iCq.dal.mysql.enter.CqEnterMapper;
import net.shapelight.modules.iCq.dal.mysql.member.CqMemberMapper;
import net.shapelight.modules.iCq.dal.mysql.video.CqSafeVideoMapper;
import net.shapelight.modules.iCq.controller.enter.dto.ChangeTypeStatesDto;
import net.shapelight.modules.iCq.dal.mysql.enter.CqEnterConfigCellMapper;
import net.shapelight.modules.iCq.dal.mysql.enter.CqEnterConfigMapper;
import net.shapelight.modules.iCq.dal.mysql.enter.CqEnterConfigTypeMapper;
import net.shapelight.modules.iCq.service.enter.CqEnterServiceImpl;
import net.shapelight.modules.job.task.PersonSynchronousTask;
import oracle.jdbc.proxy.annotation.Post;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@RestController
@ -22,58 +22,52 @@ import java.util.List;
@RequiredArgsConstructor
public class CqEnterController {
private final CqEnterMapper cqEnterMapper;
private final CqEnterServiceImpl cqEnterService;
private final CqSafeVideoMapper safeVideoMapper;
private final CqMemberMapper cqMemberMapper;
@GetMapping("list")
public R find(String operator, String cellId){
System.out.println("cellId = " + cellId);
List<FTo> fTo = cqEnterMapper.classifiedQuery(cellId);
System.out.println(fTo);
ArrayList<FirstVo> firstVos = new ArrayList<>();
for (FTo f : fTo) {
FirstVo firstVo = new FirstVo();
firstVo.setCellId(f.getCellId());
firstVo.setUnitName(safeVideoMapper.findTheNameById(f.getCellId()));
firstVo.setPerson(operator);
firstVo.setConfigurationTime(f.getOperateTime());
firstVos.add(firstVo);
}
return R.ok().put("data", firstVos).put("total", firstVos.size());
@ApiOperation(value = "配置首页列表查询")
public R list(String operator, Long cellId){
return R.ok()
.put("data", cqEnterService.list(operator, cellId))
.put("total", cqEnterService.list(operator, cellId).size());
}
@GetMapping("/getPersonType")
@ApiOperation(value = "获取人员类型")
public R getPersonType(){
List<PeronType> personType = cqEnterMapper.getPersonType();
return R.ok().put("data", personType);
return R.ok().put("data", cqEnterService.getPersonType());
}
@GetMapping("/rulesByType")
public R rulesByType(String typeId, String cellId){
if(typeId == null){
typeId = String.valueOf(cqMemberMapper.speciallyForVisitors2());
}
List<TypeRules> typeRules = cqEnterMapper.rulesByType(typeId, cellId);
return R.ok().put("data", typeRules);
}
@PutMapping("/changeState/{id}")
public R changeState(@PathVariable("id") int ruleId){
if (cqEnterMapper.changeState(ruleId) == 1) {
return R.ok();
}else {
return R.error();
}
@GetMapping("/rulesByType")
@ApiOperation(value = "根据人员类型和单位id获取详细配置项")
public R rulesByType(Integer typeId, Long cellId){
return R.ok().put("data", cqEnterService.rulesByType(typeId, cellId));
}
@PostMapping("/changeState")
@ApiOperation(value = "改变配置状态")
public R changeState(@RequestBody ChangeTypeStatesDto data){
if (cqEnterService.changeState(data.getRuleId(), data.getCellId(), data.getTypeId())){
return R.ok();
}else {
return R.error();
}
}
@GetMapping("demo")
public R demo(String operator, Long cellId){
return R.ok()
.put("data", cqEnterService.list(operator, cellId))
.put("total", cqEnterService.list(operator, cellId).size());
}
}

View File

@ -0,0 +1,16 @@
package net.shapelight.modules.iCq.controller.enter.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class ChangeTypeStatesDto {
private Integer ruleId;
private String cellId;
private Integer typeId;
}

View File

@ -1,15 +0,0 @@
package net.shapelight.modules.iCq.controller.enter.to;
import lombok.Data;
@Data
public class EnterVo {
//配置ID
Integer enterConfigId;
//类型ID
Integer typeId;
//状态(1是2否)
Integer state;
//配置名称
String configName;
}

View File

@ -1,17 +0,0 @@
package net.shapelight.modules.iCq.controller.enter.to;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FTo {
private String cellId;
private Date operateTime;
}

View File

@ -0,0 +1,24 @@
package net.shapelight.modules.iCq.controller.enter.vo;
import lombok.Data;
@Data
public class CellRuleVo {
/**
* 配置ID
*/
Integer enterConfigId;
/**
* 类型id
*/
Integer typeId;
/**
* 状态(1是0否)
*/
Integer state;
/**
* 配置名称
*/
String configName;
}

View File

@ -0,0 +1,33 @@
package net.shapelight.modules.iCq.controller.enter.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ConfigListVo {
/**
* 单位id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long cellId;
/**
* 操作时间
*/
private Date operateTime;
/**
* 单位名称
*/
private String cellName;
/**
* 操作人
*/
private String operator;
}

View File

@ -1,18 +0,0 @@
package net.shapelight.modules.iCq.controller.enter.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FirstVo {
private String cellId;
private String unitName;
private String person;
private Date configurationTime;
}

View File

@ -7,7 +7,13 @@ import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PeronType {
public class PeronTypeVo {
/**
* 人员类型标志
*/
private int type;
/**
* 人员类型名称
*/
private String name;
}

View File

@ -7,9 +7,23 @@ import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TypeRules {
private String checkItem;
private String remark;
private int state;
public class TypeRuleVo {
/**
* 配置项id
*/
private int id;
/**
* 配置状态
*/
private int state;
/**
* 校验项
*/
private String checkItem;
/**
* 备注
*/
private String remark;
}

View File

@ -425,11 +425,9 @@ public class CqMemberController {
@PutMapping("batchChangeStatus")
public R batchChangeStatus(List<Long> memberIds){
for (Long memberId : memberIds) {
cqMemberMapper.changeViewingState(memberId);
}
return R.ok();
}

View File

@ -1,23 +1,36 @@
package net.shapelight.modules.iCq.controller.video;
import com.arcsoft.face.Rect;
import io.minio.MinioClient;
import io.minio.PutObjectOptions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import net.shapelight.common.config.GlobalValue;
import net.shapelight.common.config.MinioConfig;
import net.shapelight.common.utils.R;
import net.shapelight.common.utils.UUIDUtil;
import net.shapelight.modules.face.rtsp.RtspFrameGrabber;
import net.shapelight.modules.iCq.controller.video.dto.UpdateVideoDto;
import net.shapelight.modules.iCq.controller.video.dto.UploadVideoDto;
import net.shapelight.modules.iCq.dal.dataobject.video.TenSafeVideoEntity;
import net.shapelight.modules.iCq.dal.mysql.video.CqFileMapper;
import net.shapelight.modules.iCq.dal.mysql.video.CqSafeVideoMapper;
import net.shapelight.modules.iCq.controller.video.vo.FaceVideoVo;
import net.shapelight.modules.iCq.service.video.CqSafeVideoServiceImpl;
import net.shapelight.modules.ten.dao.TenCellDao;
import net.shapelight.modules.iCq.utils.DrawUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* 宣传片表
@ -30,15 +43,20 @@ public class CqSafeVideoController {
private final CqSafeVideoServiceImpl cqSafeVideoService;
private final CqSafeVideoMapper cqSafeVideoMapper;
private final CqFileMapper cqFileMapper;
private final TenCellDao cqCellMapper;
@Autowired
private RtspFrameGrabber rtspFrameGrabber;
@Autowired
private GlobalValue globalValue;
private final MinioConfig minioConfig;
private final MinioClient minioClient;
private final List<FaceVideoVo> list = new ArrayList<>();
@GetMapping("/getCells")
@ApiOperation(value = "获取单位列表")
@ -61,12 +79,15 @@ public class CqSafeVideoController {
@GetMapping("/list")
@ApiOperation(value = "列表视频接口")
public R list(@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size,
String cellId) {
List<TenSafeVideoEntity> list = cqSafeVideoService.list(page, size, cellId);
@RequestParam(defaultValue = "10") int limit,
@RequestParam(required = false) Long cellId,
@RequestParam(required = false) String videoName,
@RequestParam(required = false) String uploadName) {
return R.ok()
.put("data", list)
.put("total", list.size());
.put("data", cqSafeVideoService.list(page, limit, cellId,
videoName, uploadName))
.put("total", cqSafeVideoService.list(page, limit, cellId,
videoName, uploadName).size());
}
@DeleteMapping("/delete/{id}")
@ -79,9 +100,13 @@ public class CqSafeVideoController {
}
}
@PutMapping("/update")
@PostMapping("/update")
@ApiOperation(value = "更新视频接口")
public R update(@RequestBody UpdateVideoDto updateVideoDto) {
public R update(@RequestBody UpdateVideoDto updateVideoDto,
@RequestHeader(value = "X-HTTP-Method-Override", required = false) String methodOverride) {
System.out.println("methodOverride = " + methodOverride);
if (cqSafeVideoService.update(updateVideoDto) == 1) {
return R.ok();
} else {
@ -89,41 +114,136 @@ public class CqSafeVideoController {
}
}
@GetMapping("/inquireVideo")
@ApiOperation(value = "条件查询视频接口")
public R inquireVideo(@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(required = false) String cellId,
@RequestParam(required = false) String videoName,
@RequestParam(required = false) String uploadName){
List<TenSafeVideoEntity> tenSafeVideoEntities =
cqSafeVideoService.inquireVideo(cellId, videoName, uploadName);
return R.ok()
.put("data", tenSafeVideoEntities)
.put("total",tenSafeVideoEntities.size());
}
@GetMapping("/singleFind")
public R singleFind(int videoId){
TenSafeVideoEntity tenSafeVideoEntity = cqSafeVideoMapper.selectById(videoId);
return R.ok().put("data", tenSafeVideoEntity);
}
@GetMapping("/camara")
public R watchStart(String cellId) {
rtspFrameGrabber.startGrabber(cellId);
return R.ok();
public R watchStart(String cellId, Integer isEnd) {
List<FaceVideoVo> faceVideoVos = rtspFrameGrabber.startGrabber(cellId);
System.out.println("faceVideoVos = " + faceVideoVos);
for (FaceVideoVo faceVideoVo : faceVideoVos) {
boolean exists = false;
for (FaceVideoVo videoVo : list) {
if (Objects.equals(videoVo.getPersonId(), faceVideoVo.getPersonId())) {
exists = true;
if (faceVideoVo.getIsHeadOnView() == 0) {
list.remove(videoVo);
list.add(faceVideoVo);
}
break;
}
}
if (!exists) {
list.add(faceVideoVo);
}
}
System.out.println("list = " + list);
List<Rect> rects = new ArrayList<>();
for (FaceVideoVo faceVideoVo : faceVideoVos) {
rects.add(faceVideoVo.getRect());
}
String drawUrl = null;
try {
drawUrl = DrawUtils.draw(faceVideoVos.get(0).getImageUrl(), rects);
} catch (IndexOutOfBoundsException e) {
System.out.println(e);
}
if (isEnd == 1){
List<FaceVideoVo> listTemp = new ArrayList<>(list);
list.clear();
return R.ok().put("data", listTemp).put("drawUrl", drawUrl);
}
return R.ok().put("data", list).put("drawUrl", drawUrl);
}
@PostMapping("/face/recognition")
public R aWatchStart(@RequestParam("image") MultipartFile image, @RequestParam String cellId) {
rtspFrameGrabber.recognition(image,cellId);
return R.ok();
List<FaceVideoVo> recognition = rtspFrameGrabber.recognition(image, cellId);
for (FaceVideoVo faceVideoVo : recognition) {
System.out.println(faceVideoVo.getImageUrl());
}
List<Rect> rects = new ArrayList<>();
for (FaceVideoVo faceVideoVo : recognition) {
rects.add(faceVideoVo.getRect());
}
String drawUrl = null;
try {
drawUrl = DrawUtils.draw(recognition.get(0).getImageUrl(), rects);
} catch (IndexOutOfBoundsException e) {
System.out.println(e);
}
return R.ok().put("data", recognition).put("drawUrl", drawUrl);
}
/*private String draw(String imageUrl, List<Rect> rectList) {
try {
// URL 读取图片
BufferedImage image = ImageIO.read(new URL(globalValue.getMinioEndpoint() + "/" +
globalValue.getMinioBucketName() + "/" + imageUrl));
// 获取绘图上下文
Graphics2D g2d = image.createGraphics();
g2d.setColor(Color.RED); // 设置框的颜色
g2d.setStroke(new BasicStroke(3)); // 设置框的线条宽度
// 遍历每个矩形框并绘制
for (Rect rect : rectList) {
int left = rect.left;
int top = rect.top;
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
g2d.drawRect(left, top, width, height);
}
// 释放资源
g2d.dispose();
// BufferedImage 转换为 InputStream 以便上传
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", os);
InputStream inputStream = new ByteArrayInputStream(os.toByteArray());
// 设置文件目录和名称
String catalogue = "temp/";
String extension = "jpg"; // 假设是 JPG 格式
String fileName = catalogue + "t_" + UUIDUtil.uuid() + "." + extension;
// 上传文件到 MinIO
PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1);
putObjectOptions.setContentType("image/jpeg");
minioClient.putObject(
minioConfig.getBucketName(), fileName, inputStream, putObjectOptions);
inputStream.close();
System.out.println("矩形框已绘制并上传到 MinIO文件路径" + globalValue.getMinioEndpoint() + "/" +
globalValue.getMinioBucketName() + "/" + fileName);
return fileName;
} catch (Exception e) {
e.printStackTrace();
}
return "error";
}*/
}

View File

@ -13,7 +13,7 @@ public class VideoQueryDto {
/**
* 单位id
*/
private String cellId;
private Long cellId;
/**
* 视频名称
*/

View File

@ -0,0 +1,46 @@
package net.shapelight.modules.iCq.controller.video.vo;
import com.arcsoft.face.Rect;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class FaceVideoVo {
/**
* 人员id
*/
private String personId;
/**
* 人员name
*/
private String name;
/**
* 是否正脸
*/
private Integer isHeadOnView; //0否1是
/**
* 图片url
*/
private String imageUrl;
/**
* 人员头像坐标
*/
private Rect rect;
/**
* 绘制后图片url
*/
private String imageWithRectangle;
}

View File

@ -0,0 +1,54 @@
package net.shapelight.modules.iCq.dal.dataobject.enter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
/**
*
* @TableName ten_enter_config_cell
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class TenEnterConfigCell implements Serializable {
/**
*
*/
@NotNull(message="[]不能为空")
@ApiModelProperty("")
private Integer id;
/**
*
*/
@ApiModelProperty("")
private Integer enterConfigId;
/**
*
*/
@Size(max= 255,message="编码长度不能超过255")
@ApiModelProperty("")
@Length(max= 255,message="编码长度不能超过255")
private Long cellId;
/**
*
*/
@ApiModelProperty("")
private Date operateTime;
}

View File

@ -8,9 +8,7 @@ import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 宣传片表
*/
@Data
@TableName("ten_enter_config")
public class TenEnterConfigEntity implements Serializable {

View File

@ -0,0 +1,55 @@
package net.shapelight.modules.iCq.dal.dataobject.enter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
/**
*
* @TableName ten_enter_config_type
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class TenEnterConfigType implements Serializable {
/**
*
*/
@NotNull(message="[]不能为空")
@ApiModelProperty("")
private Integer id;
/**
*
*/
@ApiModelProperty("")
private Integer enterConfigId;
/**
*
*/
@ApiModelProperty("")
private Integer typeId;
/**
* 0关闭1启用
*/
@ApiModelProperty("0关闭1启用")
private Integer state;
/**
*
*/
@ApiModelProperty("")
private Long cellId;
}

View File

@ -0,0 +1,4 @@
package net.shapelight.modules.iCq.dal.dataobject.personTemp;
public class TenPersonSyncTempEntity {
}

View File

@ -3,7 +3,10 @@ package net.shapelight.modules.iCq.dal.dataobject.video;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
@ -13,6 +16,7 @@ import java.util.Date;
*/
@Data
@TableName("ten_safe_video")
@Accessors(chain = true)
public class TenSafeVideoEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ -20,6 +24,7 @@ public class TenSafeVideoEntity implements Serializable {
* 主键
*/
@TableId
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
@ -30,7 +35,8 @@ public class TenSafeVideoEntity implements Serializable {
/**
* 单位ID
*/
private String cellId;
@JsonSerialize(using = ToStringSerializer.class)
private Long cellId;
/**
* 单位名称
@ -40,7 +46,7 @@ public class TenSafeVideoEntity implements Serializable {
/**
* 上传人ID
*/
private String uploadId;
private Long uploadId;
/**
* 上传人姓名

View File

@ -0,0 +1,10 @@
package net.shapelight.modules.iCq.dal.mysql.enter;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.shapelight.modules.iCq.dal.dataobject.enter.TenEnterConfigCell;
import net.shapelight.modules.iCq.dal.dataobject.enter.TenEnterConfigEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CqEnterConfigCellMapper extends BaseMapper<TenEnterConfigCell> {
}

View File

@ -0,0 +1,12 @@
package net.shapelight.modules.iCq.dal.mysql.enter;
import com.github.yulichang.base.MPJBaseMapper;
import net.shapelight.modules.iCq.controller.enter.vo.CellRuleVo;
import net.shapelight.modules.iCq.dal.dataobject.enter.TenEnterConfigEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface CqEnterConfigMapper extends MPJBaseMapper<TenEnterConfigEntity> {
}

View File

@ -0,0 +1,11 @@
package net.shapelight.modules.iCq.dal.mysql.enter;
import com.github.yulichang.base.MPJBaseMapper;
import net.shapelight.modules.iCq.dal.dataobject.enter.TenEnterConfigType;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CqEnterConfigTypeMapper extends MPJBaseMapper<TenEnterConfigType> {
}

View File

@ -1,27 +0,0 @@
package net.shapelight.modules.iCq.dal.mysql.enter;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.shapelight.modules.iCq.controller.enter.to.EnterVo;
import net.shapelight.modules.iCq.controller.enter.to.FTo;
import net.shapelight.modules.iCq.controller.enter.vo.PeronType;
import net.shapelight.modules.iCq.controller.enter.vo.TypeRules;
import net.shapelight.modules.iCq.dal.dataobject.enter.TenEnterConfigEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface CqEnterMapper extends BaseMapper<TenEnterConfigEntity> {
List<FTo> classifiedQuery(@Param("cellId")String cellId);
List<PeronType> getPersonType();
List<TypeRules> rulesByType(String typeId, @Param("cellId") String cellId);
int changeState(int ruleId);
List<EnterVo> queryByCellId(Long cellId);
}

View File

@ -16,7 +16,6 @@ public interface CqMemberMapper extends BaseMapper<TenPersonEntity> {
String takeTheNameAccordingToType(Integer personType);
Integer speciallyForVisitors();
Long speciallyForVisitors2();
Long orgidBecomesCellId(String orgId);

View File

@ -0,0 +1,24 @@
package net.shapelight.modules.iCq.dal.mysql.personTemp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface TenPersonSyncTempMapper {
@Insert("INSERT INTO ten_person_sync_temp (open_id) VALUES (#{openId});")
public void insertTemp(String openId);
@Delete("DELETE FROM ten_person_sync_temp;")
void removeAll();
@Delete("DELETE FROM ten_person WHERE open_id NOT IN (SELECT open_id FROM ten_person_sync_temp);")
void removeDeletedPerson();
@Delete("DELETE FROM ten_person_sync_836266616957173761 WHERE person_id NOT IN (SELECT person_id from ten_person WHERE open_id in (SELECT open_id FROM ten_person_sync_temp));")
void removeDeletedPersonSync();
}

View File

@ -7,11 +7,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CqFileMapper extends BaseMapper<FileEntity> {
/**
* 根据文件id获取文件信息
* @param fileId
* @return
*/
FileEntity selectByFileId(String fileId);
}

View File

@ -9,7 +9,4 @@ import org.apache.ibatis.annotations.Mapper;
public interface CqSafeVideoMapper extends BaseMapper<TenSafeVideoEntity> {
String findTheNameById(String cellId);
}

View File

@ -0,0 +1,150 @@
package net.shapelight.modules.iCq.service.enter;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.RequiredArgsConstructor;
import net.shapelight.modules.iCq.controller.enter.vo.CellRuleVo;
import net.shapelight.modules.iCq.controller.enter.vo.ConfigListVo;
import net.shapelight.modules.iCq.controller.enter.vo.PeronTypeVo;
import net.shapelight.modules.iCq.controller.enter.vo.TypeRuleVo;
import net.shapelight.modules.iCq.dal.dataobject.enter.TenEnterConfigCell;
import net.shapelight.modules.iCq.dal.dataobject.enter.TenEnterConfigEntity;
import net.shapelight.modules.iCq.dal.dataobject.enter.TenEnterConfigType;
import net.shapelight.modules.iCq.dal.mysql.enter.CqEnterConfigCellMapper;
import net.shapelight.modules.iCq.dal.mysql.enter.CqEnterConfigMapper;
import net.shapelight.modules.iCq.dal.mysql.enter.CqEnterConfigTypeMapper;
import net.shapelight.modules.ten.dao.TenCellDao;
import net.shapelight.modules.ten.dao.TenDeviceDao;
import net.shapelight.modules.ten.dao.TenLabelDao;
import net.shapelight.modules.ten.entity.TenDeviceEntity;
import net.shapelight.modules.ten.entity.TenLabelEntity;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class CqEnterServiceImpl {
private final CqEnterConfigCellMapper cqEnterConfigCellMapper;
private final TenCellDao cqCellMapper;
private final TenLabelDao cqTenlableMapper;
private final CqEnterConfigMapper cqEnterConfigMapper;
private final CqEnterConfigTypeMapper cqEnterConfigTypeMapper;
private final TenDeviceDao tenDeviceMapper;
/**
* 查询/列表配置首页
* @param operator
* @param cellId
* @return
*/
public List<ConfigListVo> list(String operator, Long cellId) {
QueryWrapper<TenEnterConfigCell> queryWrapper = new QueryWrapper<>();
if (cellId != null) {
queryWrapper.eq("cell_id", cellId);
}
return cqEnterConfigCellMapper.selectList(queryWrapper
.select("cell_id", "MAX(operate_time) AS operate_time")
.groupBy("cell_id"))
.stream()
.map(tenEnterConfigCell -> {
ConfigListVo configListVo = new ConfigListVo();
BeanUtils.copyProperties(tenEnterConfigCell, configListVo);
configListVo.setCellName(cqCellMapper
.selectById(configListVo.getCellId())
.getName());
configListVo.setOperator(operator);
return configListVo;
})
.collect(Collectors.toList());
}
/**
* 获取人员类型
* @return
*/
public List<PeronTypeVo> getPersonType() {
return cqTenlableMapper.selectList(
new QueryWrapper<TenLabelEntity>()
.orderByAsc("type"))
.stream()
.map(tenLabelEntity -> {
PeronTypeVo peronTypeVo = new PeronTypeVo();
BeanUtils.copyProperties(tenLabelEntity, peronTypeVo);
return peronTypeVo;
}).collect(Collectors.toList());
}
/**
* 根据单位id和人员类型id返回配置规则
* @param typeId
* @param cellId
* @return
*/
public List<TypeRuleVo> rulesByType(Integer typeId, Long cellId) {
if (typeId == null) {
typeId = cqTenlableMapper.selectOne(new QueryWrapper<TenLabelEntity>()
.eq("name", "访客人员"))
.getType();
}
//查询主表 返回结果 join 从表
return cqEnterConfigMapper.selectJoinList(TypeRuleVo.class,
new MPJLambdaWrapper<TenEnterConfigEntity>()
.select(TenEnterConfigEntity::getCheckItem, TenEnterConfigEntity::getRemark)
.select(TenEnterConfigType::getState, TenEnterConfigType::getId)
//子表类 主表字段 子表字段
.leftJoin(TenEnterConfigType.class, TenEnterConfigType::getEnterConfigId, TenEnterConfigEntity::getId)
.eq(TenEnterConfigType::getTypeId, typeId)
.eq(TenEnterConfigType::getCellId, cellId)
);
}
/**
* 改变规则状态
* @param ruleId
* @return
*/
@Transactional
public boolean changeState(int ruleId, String cellId, int typeId) {
return cqEnterConfigCellMapper.update(
null,
new UpdateWrapper<TenEnterConfigCell>()
.eq("enter_config_id", ruleId)
.eq("cell_id", cellId)
.set("operate_time", new Date())) > 0
&& cqEnterConfigTypeMapper.update(
null,
new UpdateWrapper<TenEnterConfigType>()
.eq("enter_config_id", ruleId)
.eq("type_id", typeId)
.eq("cell_id", cellId)
.setSql("state = 1 - state")) > 0;
}
/**
* 根据sn号下发配置规则
* @param sn
* @return
*/
public List<CellRuleVo> queryByCellId(String sn) {
return cqEnterConfigTypeMapper.selectJoinList(CellRuleVo.class,
new MPJLambdaWrapper<TenEnterConfigType>()
.select(TenEnterConfigType::getEnterConfigId, TenEnterConfigType::getTypeId,
TenEnterConfigType::getState)
.selectAs(TenEnterConfigEntity::getCheckItem, CellRuleVo::getConfigName)
.leftJoin(TenEnterConfigEntity.class, TenEnterConfigEntity::getId, TenEnterConfigType::getEnterConfigId)
.eq(TenEnterConfigType::getCellId, tenDeviceMapper.selectOne(new QueryWrapper<TenDeviceEntity>()
.eq("sn", sn)).getCellId())
);
}
}

View File

@ -1,5 +0,0 @@
package net.shapelight.modules.iCq.service.video;
public interface CqSafeVideoService {
//接口声明
}

View File

@ -19,6 +19,7 @@ import org.modelmapper.ModelMapper;
import org.modelmapper.TypeMap;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.ArrayList;
import java.util.Date;
@ -40,7 +41,7 @@ public class CqSafeVideoServiceImpl {
* @return
*/
public List<CellVo> getCellInfos() {
return cqCellMapper.selectList(new QueryWrapper<>()).stream()
return cqCellMapper.selectList(null).stream()
.map(cell -> {
CellVo cellVo = new CellVo();
BeanUtils.copyProperties(cell, cellVo);
@ -49,10 +50,17 @@ public class CqSafeVideoServiceImpl {
.collect(Collectors.toList());
}
/**
* 新增视频
* @param uploadVideoDto
* @return
*/
public int insert(UploadVideoDto uploadVideoDto) {
TenSafeVideoEntity tenSafeVideoEntity = new TenSafeVideoEntity();
BeanUtils.copyProperties(uploadVideoDto, tenSafeVideoEntity);
BeanUtils.copyProperties(cqFileMapper.selectByFileId(uploadVideoDto.getFileId()), tenSafeVideoEntity);
BeanUtils.copyProperties(cqFileMapper.selectOne(new QueryWrapper<FileEntity>()
.eq("file_id", uploadVideoDto.getFileId())),
tenSafeVideoEntity);
tenSafeVideoEntity.setCellName(cqCellMapper.selectOne(new QueryWrapper<TenCellEntity>()
.select("name")
.eq("cell_id", uploadVideoDto.getCellId())).getName());
@ -60,40 +68,24 @@ public class CqSafeVideoServiceImpl {
return cqSafeVideoMapper.insert(tenSafeVideoEntity);
}
public List<TenSafeVideoEntity> list(int page, int size, String cellId) {
/**
* 查询视频列表
* @param page
* @param size
* @param cellId
* @param videoName
* @param uploadName
* @return
*/
public List<TenSafeVideoEntity> list(int page, int size, Long cellId,
String videoName, String uploadName) {
Page<TenSafeVideoEntity> pageRequest = new Page<>(page, size);
QueryWrapper<TenSafeVideoEntity> queryWrapper = new QueryWrapper<>();
if (cellId != null && !cellId.isEmpty()){
queryWrapper.eq("cell_id", cellId);
}
queryWrapper.orderByDesc("upload_time");
IPage<TenSafeVideoEntity> pageResult = cqSafeVideoMapper.selectPage(pageRequest, queryWrapper);
return pageResult.getRecords();
}
public boolean delete(Long id) {
return (cqSafeVideoMapper.deleteById(id) == 1);
}
public int update(UpdateVideoDto updateVideoDto) {
TenSafeVideoEntity tenSafeVideoEntity = new TenSafeVideoEntity();
FileEntity fileEntity = cqFileMapper.selectById(updateVideoDto.getFileId());
BeanUtils.copyProperties(fileEntity, tenSafeVideoEntity);
tenSafeVideoEntity.setId(updateVideoDto.getVideoId());
tenSafeVideoEntity.setCellId(String.valueOf(updateVideoDto.getCellId()));
tenSafeVideoEntity.setCellName(cqCellMapper.selectById(updateVideoDto.getCellId()).getName());
tenSafeVideoEntity.setUploadTime(new Date());
return cqSafeVideoMapper.updateById(tenSafeVideoEntity);
}
public List<TenSafeVideoEntity> inquireVideo(String cellId, String videoName, String uploadName) {
VideoQueryDto queryDto = new VideoQueryDto();
queryDto.setCellId(cellId)
.setVideoName(videoName)
.setUploadName(uploadName);
QueryWrapper<TenSafeVideoEntity> queryWrapper = new QueryWrapper<>();
if (queryDto.getCellId() != null && !queryDto.getCellId().isEmpty()) {
if (queryDto.getCellId() != null) {
queryWrapper.eq("cell_id", queryDto.getCellId());
}
if (queryDto.getVideoName() != null && !queryDto.getVideoName().isEmpty()) {
@ -103,6 +95,38 @@ public class CqSafeVideoServiceImpl {
queryWrapper.eq("upload_name", queryDto.getUploadName());
}
queryWrapper.orderByDesc("upload_time");
return cqSafeVideoMapper.selectList(queryWrapper);
IPage<TenSafeVideoEntity> pageResult = cqSafeVideoMapper.selectPage(pageRequest, queryWrapper);
return pageResult.getRecords();
}
/**
* 删除视频
* @param id
* @return
*/
public boolean delete(Long id) {
return (cqSafeVideoMapper.deleteById(id) == 1);
}
/**
* 更新视频
* @param updateVideoDto
* @return
*/
public int update(UpdateVideoDto updateVideoDto) {
TenSafeVideoEntity tenSafeVideoEntity = new TenSafeVideoEntity();
BeanUtils.copyProperties(
cqFileMapper.selectOne(new QueryWrapper<FileEntity>()
.eq("file_id", updateVideoDto.getFileId())
), tenSafeVideoEntity);
tenSafeVideoEntity
.setId(updateVideoDto.getVideoId())
.setCellId(updateVideoDto.getCellId())
.setCellName(cqCellMapper.selectById(updateVideoDto.getCellId()).getName())
.setUploadTime(new Date());
return cqSafeVideoMapper.updateById(tenSafeVideoEntity);
}
}

View File

@ -0,0 +1,90 @@
package net.shapelight.modules.iCq.utils;
import com.arcsoft.face.Rect;
import io.minio.MinioClient;
import io.minio.PutObjectOptions;
import net.shapelight.common.config.GlobalValue;
import net.shapelight.common.config.MinioConfig;
import net.shapelight.common.utils.UUIDUtil;
import org.springframework.stereotype.Component;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
@Component
public class DrawUtils {
private static GlobalValue globalValue;
private static MinioClient minioClient;
private static MinioConfig minioConfig;
public DrawUtils(GlobalValue globalValue, MinioClient minioClient, MinioConfig minioConfig) {
DrawUtils.globalValue = globalValue;
DrawUtils.minioClient = minioClient;
DrawUtils.minioConfig = minioConfig;
}
public static String draw(String imageUrl, List<Rect> rectList) {
try {
// URL 读取图片
BufferedImage image = ImageIO.read(new URL(globalValue.getMinioEndpoint() + "/" +
globalValue.getMinioBucketName() + "/" + imageUrl));
// 获取绘图上下文
Graphics2D g2d = image.createGraphics();
g2d.setColor(Color.RED); // 设置框的颜色
g2d.setStroke(new BasicStroke(3)); // 设置框的线条宽度
// 遍历每个矩形框并绘制
for (Rect rect : rectList) {
int left = rect.left;
int top = rect.top;
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
g2d.drawRect(left, top, width, height);
}
// 释放资源
g2d.dispose();
// BufferedImage 转换为 InputStream 以便上传
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", os);
InputStream inputStream = new ByteArrayInputStream(os.toByteArray());
// 设置文件目录和名称
String catalogue = "temp/";
String extension = "jpg"; // 假设是 JPG 格式
String fileName = catalogue + "t_" + UUIDUtil.uuid() + "." + extension;
// 上传文件到 MinIO
PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1);
putObjectOptions.setContentType("image/jpeg");
minioClient.putObject(
minioConfig.getBucketName(), fileName, inputStream, putObjectOptions);
inputStream.close();
System.out.println("矩形框已绘制并上传到 MinIO文件路径" + globalValue.getMinioEndpoint() + "/" +
globalValue.getMinioBucketName() + "/" + fileName);
return fileName;
} catch (Exception e) {
e.printStackTrace();
}
return "error";
}
}

View File

@ -56,9 +56,13 @@ public class DbBakTask implements ITask {
fileDir.setWritable(true,false);
}
String mysqlLocation = "SHOW VARIABLES LIKE 'basedir';";
//String cmd = "mysqldump -u"+ dbUsername +" -p"+dbPassword +" "+ dbName + " -r " + path;
//mysqldump -h172.17.0.1 -P3306 -ugb -pgb site_db_docker -r /opt/sl-site/db_bak/13.sql
String cmd = "mysqldump -h"+dbHost+" -P"+dbPort+" -u"+ dbUsername +" -p"+dbPassword +" --set-charset=UTF8 "+ dbName;
/*cmd = cmd + mysqlLocation + "\bin";*/
PrintWriter printWriter = null;
BufferedReader bufferedReader = null;
try {

File diff suppressed because one or more lines are too long

View File

@ -97,6 +97,7 @@ public class SysUserEntity extends BaseEntity implements Serializable {
* 部门ID
*/
//@NotNull(message="部门不能为空", groups = {AddGroup.class, UpdateGroup.class})
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty("所属部门ID")
private Long deptId;

View File

@ -169,7 +169,7 @@ public class TenDeviceController extends AbstractController {
@ApiImplicitParam(name="deviceSn",value = "设备Sn",paramType = "query",dataType = "String",required = true),
})
public R cleanPerson(@RequestBody Map<String, Object> deviceSn){
String sn = (String)deviceSn.get("deviceSn");
/* String sn = (String)deviceSn.get("deviceSn");
// CmdProcess.publishCleanPerson(sn);
//清除数据
int r = serverApiService.cleanData(sn);
@ -183,20 +183,16 @@ public class TenDeviceController extends AbstractController {
//升级app
// TenAppVerison v = new TenAppVerison();
// int a = serverApiService.appUpdate(sn,v);
if(r == -1){
return R.error("设备离线");
}
//重新配置同步表
return R.ok();
//重新配置同步表*/
String sn = (String) deviceSn.get("deviceSn");
// 设置 open 标志位的值为 1
String openKey = "DeviceOpen-" + sn;
redisUtils.set(openKey, "1", 30L);
return R.ok("开门成功");
}
/**

View File

@ -2,15 +2,20 @@ package net.shapelight.modules.ten.controller;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.zip.ZipOutputStream;
import cn.hutool.json.JSONObject;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import io.minio.MinioClient;
import io.minio.PutObjectOptions;
import io.swagger.annotations.Api;
@ -41,11 +46,13 @@ import net.shapelight.modules.sys.controller.AbstractController;
import net.shapelight.modules.sys.entity.SysUserEntity;
import net.shapelight.modules.sys.service.SysUserRoleService;
import net.shapelight.modules.sys.service.SysUserService;
import net.shapelight.modules.ten.dao.TenCellDao;
import net.shapelight.modules.ten.entity.*;
import net.shapelight.modules.ten.service.*;
import net.shapelight.modules.ten.vo.PersonExcelModel;
import net.shapelight.modules.vo.TenDeviceVo;
import net.shapelight.modules.vo.TenPersonOperationVo;
import net.shapelight.modules.vo.TenPersonVo;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
@ -106,6 +113,9 @@ public class TenPersonController extends AbstractController {
@Autowired
private CxFeignClient cxFeignClient;
@Autowired
private TenCellDao tenCellDao;
/**
* 查询住户列表
@ -339,6 +349,10 @@ public class TenPersonController extends AbstractController {
}
params.put("isBlacklistPersonnel", 1);
PageUtils page = tenPersonService.queryPage(params);
return R.ok().put("data", page);
}
@ -441,7 +455,7 @@ public class TenPersonController extends AbstractController {
@PostMapping("/save")
@RequiresPermissions("ten:person")
@ApiOperation(value = "保存人员信息")
public R save(@RequestBody TenPersonEntity tenPerson) {
public R save(@RequestBody TenPersonEntity tenPerson) throws IOException {
// TenPersonEntity room = tenPersonService.queryByNumberAndLayer(tenRoom.getRoomNumber(),
// tenRoom.getLayer(),
// tenRoom.getBuildId(),
@ -510,28 +524,80 @@ public class TenPersonController extends AbstractController {
tenPerson.setCreateTime(new Date());
tenPerson.setRegisterType(Constant.RESGISTER_TYPE_WEB);
tenPerson.setStatus(Constant.PESON_SUATUS_NOMOR);
//长庆新增
//setOrgId
tenPerson.setOrgId(tenCellDao.selectOne(new QueryWrapper<TenCellEntity>()
.eq("cell_id", tenPerson.getCellId())).getOrgId());
System.out.println("tenPerson = " + tenPerson);
int res = tenPersonService.saveTenPerson(tenPerson);
if (res==2) {
return R.error("照片未检测到人脸");
}
/* System.out.println(tenPerson.getPersonType() == Constant.PERSON_TYPE_GUEST);*/
if(tenPerson.getPersonType() == Constant.PERSON_TYPE_GUEST) {
Map<String,Object> params = new HashMap<>();
params.put("pmVisitorPersonnelId","");
params.put("orgId",tenPerson.getOrgId());
params.put("orgName",tenPerson.getCellName());
params.put("personnelName",tenPerson.getName());
params.put("personnelId",tenPerson.getOpenId());
params.put("personnelCardId",tenPerson.getIdCard());
params.put("enterValidPeriod",tenPerson.getLiveStart().toString());
params.put("enterValidPeriodEnd",tenPerson.getLiveEnd().toString());
params.put("mobile",tenPerson.getMobile());
params.put("isEnterSulfurArea",tenPerson.getIsEnterSulfurArea()==1?"":"");
params.put("isProtectDevice",tenPerson.getIsProtectDevice()==1?"":"");
params.put("isBlacklistPersonnel","");
params.put("isWatchSafeVideo",tenPerson.getIsWatchSafeVideo()==1?"":"");
params.put("attachment",tenPerson.getIsWatchSafeVideo());
//cxFeignClient.savePmVisitorPersonnel(params);
SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Map<String, Object> params = new HashMap<>();
params.put("pmVisitorPersonnelId", "");
params.put("orgId", tenPerson.getOrgId());
params.put("orgName", tenPerson.getCellName());
params.put("personnelName", tenPerson.getName());
//params.put("personnelId",tenPerson.getOpenId());
params.put("personnelCardId", tenPerson.getIdCard());
params.put("enterValidPeriod", targetFormat.format(tenPerson.getLiveStart()));
params.put("enterValidPeriodEnd", targetFormat.format(tenPerson.getLiveEnd()));
params.put("mobile", tenPerson.getMobile());
params.put("isEnterSulfurArea", tenPerson.getIsEnterSulfurArea() == 1 ? "" : "");
params.put("isProtectDevice", tenPerson.getIsProtectDevice() == 1 ? "" : "");
params.put("isBlacklistPersonnel", "");
params.put("isWatchSafeVideo", tenPerson.getIsWatchSafeVideo() == 1 ? "已观看" : "未观看");
String base64 = null;
try {
URL url = new URL(globalValue.getMinioEndpoint() + "/" +
globalValue.getMinioBucketName() + "/" + tenPerson.getFaceImage());
// 从URL获取图片
try (InputStream is = url.openStream()) {
// 使用ByteArrayOutputStream来收集数据
ByteArrayOutputStream bao = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int length;
// 循环读取数据直到输入流结束
while ((length = is.read(buffer)) != -1) {
bao.write(buffer, 0, length);
}
// 将图片数据转换为Base64编码
base64 = Base64.getEncoder().encodeToString(bao.toByteArray());
// 打印Base64编码的字符串
System.out.println("data:image/jpeg;base64," + base64);
}
} catch (IOException e) {
e.printStackTrace();
}
params.put("attachment", "data:image/jpeg;base64," + base64);
System.out.println("params = " + params);
JSONObject jsonObject = cxFeignClient.savePmVisitorPersonnel(params);
if(jsonObject.getStr("data") != null){
String openId = jsonObject.getStr("data");
// id
tenPerson.setOpenId(openId);
tenPersonService.update(tenPerson,
new UpdateWrapper<TenPersonEntity>().eq("person_id", id));
//tenPersonService.updateTenPersonById(tenPerson);
}
}
return R.ok();
}

View File

@ -137,4 +137,6 @@ public interface TenPersonDao extends BaseMapper<TenPersonEntity>{
List<TenDeptPersonCount> findDeptCount(@Param("tenantId")String tenantId);
int updateWatchSafeVideo(@Param("personId")Long personId,@Param("cellId")Long cellId);
void insertTemp(String openId);
}

View File

@ -28,7 +28,7 @@ public class TenPersonCert implements Serializable {
*/
@NotNull(message="[人员ID]不能为空")
@ApiModelProperty("人员ID")
private Long person;
private String person;
/**
* 证书ID
*/
@ -60,4 +60,15 @@ public class TenPersonCert implements Serializable {
@ApiModelProperty("证书类型")
@Length(max= 255,message="编码长度不能超过255")
private String certType;
/**
* 学员类别
*/
private String category;
/**
* 附件
*/
private String attachment;
}

View File

@ -384,5 +384,9 @@ public class TenPersonEntity extends BaseEntity implements Serializable {
private Integer isWatchSafeVideo;
private String belongContractorName;
private Integer isBlacklistPersonnel;
/**
* 是否核验证书
*/
private Integer isCheckCert;
}

View File

@ -29,7 +29,7 @@ public class TenPersonTrain implements Serializable {
*/
@NotNull(message="[人员ID]不能为空")
@ApiModelProperty("人员ID")
private Long personId;
private String personId;
/**
* 培训记录ID
*/
@ -63,4 +63,26 @@ public class TenPersonTrain implements Serializable {
@Length(max= 2,message="编码长度不能超过2")
private int isQualified;
/**
* 理论成绩
*/
private String theoreticalScore;
/**
* 实践成绩
*/
private String practiceScore;
/**
* 人员类型
*/
private String personnelType;
/**
* 培训班名称
*/
private String className;
}

View File

@ -165,5 +165,8 @@ public interface TenPersonService extends IService<TenPersonEntity> {
String saveOrUpdateByField(TenPersonEntity entity,String fieldName);
void updateTenPersonByOpenId(TenPersonEntity tenPerson);
void insertTemp(String openId);
}

View File

@ -24,6 +24,8 @@ public class TenPersonCertServiceImpl extends ServiceImpl<TenPersonCertDao, TenP
* @param fieldName 字段名称
* @return 操作结果
*/
//pmContractorCertId
public void saveOrUpdateByField(TenPersonCert entity, String fieldName) {
QueryWrapper<TenPersonCert> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(fieldName, MyBeanUtils.getFieldValueByName(entity,fieldName));

View File

@ -7,6 +7,7 @@ import com.arcsoft.face.FaceInfo;
import com.arcsoft.face.enums.ExtractType;
import com.arcsoft.face.toolkit.ImageFactory;
import com.arcsoft.face.toolkit.ImageInfo;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.minio.MinioClient;
import io.minio.PutObjectOptions;
@ -29,6 +30,7 @@ import net.shapelight.modules.face.service.FaceEngineService;
import net.shapelight.modules.face.util.Base64Util;
import net.shapelight.modules.face.util.UserInfo;
import net.shapelight.modules.face.util.UserRamGroup;
import net.shapelight.modules.iCq.dal.mysql.personTemp.TenPersonSyncTempMapper;
import net.shapelight.modules.nettyapi.service.ServerApiService;
import net.shapelight.modules.ten.controller.TenUserController;
import net.shapelight.modules.ten.entity.*;
@ -111,8 +113,15 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
@Value("${global.minio.bucketName}")
private String bucketName;
private TenPersonSyncTempMapper tenPersonSyncTempMapper;
@Override
public PageUtils queryPage(Map<String, Object> params) {
System.out.println("params = " + params);
List<Long> cellIds = new ArrayList<>();
// cellIds.add(709832651506188289L);
@ -369,6 +378,8 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
@CacheEvict(value = "TenPerson", allEntries = true)
public int saveTenPerson(TenPersonEntity entity) {
String userFileUrl = globalValue.getImagesDir() + "/org/";
System.out.println("userFileUrl = " + userFileUrl);
try {
//保存原始图片
String tempOrgImageFile = entity.getOrgImageTemp();
@ -389,6 +400,9 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
InputStream tempInputStream = minioClient.getObject(minioConfig.getBucketName(), tempOrgImageFile);
//----------------算法检测----------------------------------------------
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
while ((length = tempInputStream.read(buffer)) != -1) {
@ -398,9 +412,11 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
byte[] bytes = outputStream.toByteArray();
outputStream.close();
tempInputStream.close();
System.out.println("测试打印");
//-------------------------------------------------------------------------
ImageInfo rgbData = ImageFactory.getRGBData(bytes);
List<FaceInfo> faceInfoList = faceEngineService.detectFaces(rgbData);
System.out.println("--测试打印--");
if (CollectionUtil.isNotEmpty(faceInfoList)) {
FaceInfo faceInfo = faceInfoList.get(0);
FaceRecognitionResDTO faceRecognitionResDTO = new FaceRecognitionResDTO();
@ -558,6 +574,20 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
entity.setCreateTime(now);
entity.setLastUpdateTime(now);
entity.setIsEnterSulfurArea(entity.getIsEnterSulfurArea());
entity.setIsProtectDevice(entity.getIsProtectDevice());
entity.setIsWatchSafeVideo(entity.getIsWatchSafeVideo());
entity.setIsBlacklistPersonnel(0);
if (entity.getIsCheckCert()==null){
entity.setIsCheckCert(1);
}
//setOrgId
entity.setOrgId(entity.getOrgId());
////访客添加状态
// Date now = new Date();
// log.info("now:"+now.getTime()+" start:"+entity.getLiveStart().getTime()
@ -650,30 +680,30 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
}*/
//发送设备通知
// List<TenDeviceVo> devList = tenDeviceService.findByCellId(entity.getCellId());
// //状态是0正常发送推送
// if (entity.getStatus().intValue() == Constant.PESON_SUATUS_NOMOR) {
// for (TenDeviceVo dev : devList) {
// //添加到同步表下发设备通知
// TenPersonSyncEntity syncEntity = new TenPersonSyncEntity();
// syncEntity.setPersonId(entity.getPersonId());
// syncEntity.setTenantId(entity.getTenantId());
// syncEntity.setDeviceSn(dev.getSn());
// syncEntity.setDeviceId(dev.getDeviceId());
// syncEntity.setState(1);
// syncEntity.setLastUpdateTime(entity.getLastUpdateTime());
// tenPersonSyncService.insert(syncEntity);
//
// //下发通知
// List<TenPersonOperationVo> list = new ArrayList<>();
// TenPersonOperationVo vo = new TenPersonOperationVo();
// vo.setUid(syncEntity.getPersonId());
// vo.setOperation(1);
// vo.setLast_update_stamp(syncEntity.getLastUpdateTime());
// list.add(vo);
// serverApiService.personOperation(dev.getSn(), list);
// }
// }
List<TenDeviceVo> devList = tenDeviceService.findByCellId(entity.getCellId());
//状态是0正常发送推送
if (entity.getStatus() == Constant.PESON_SUATUS_NOMOR) {
for (TenDeviceVo dev : devList) {
//添加到同步表下发设备通知
TenPersonSyncEntity syncEntity = new TenPersonSyncEntity();
syncEntity.setPersonId(entity.getPersonId());
syncEntity.setTenantId(entity.getTenantId());
syncEntity.setDeviceSn(dev.getSn());
syncEntity.setDeviceId(dev.getDeviceId());
syncEntity.setState(1);
syncEntity.setLastUpdateTime(entity.getLastUpdateTime());
tenPersonSyncService.insert(syncEntity);
//下发通知
List<TenPersonOperationVo> list = new ArrayList<>();
TenPersonOperationVo vo = new TenPersonOperationVo();
vo.setUid(syncEntity.getPersonId());
vo.setOperation(1);
vo.setLast_update_stamp(syncEntity.getLastUpdateTime());
list.add(vo);
serverApiService.personOperation(dev.getSn(), list);
}
}
return 0;
}
return 1;
@ -1032,41 +1062,41 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
//配置同步信息并推送
// List<Map<String, String>> snPersonsList = tenPersonSyncService.findGroupDevicePersons(personIds, tenantId);
// for (Map<String, String> snPersons : snPersonsList) {
// String sn = snPersons.get("deviceSn");
// TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
// if(deviceEntity==null){
// continue;
// }
// String[] persons = snPersons.get("plist").split(",");
// List<TenPersonOperationVo> list = new ArrayList<>();
// for (String personStr : persons) {
// String[] personInfoStr = personStr.split("_");
// Long personId = Long.parseLong(personInfoStr[0]);
// Date lastUpdateTime = DateUtils.stringToDate(personInfoStr[1], DateUtils.DATE_TIME_PATTERN);
//
// TenPersonSyncEntity syncEntity = tenPersonSyncService.findByDeviceIdAndPersonId(deviceEntity.getDeviceId(), personId, tenantId);
// syncEntity.setLastUpdateTime(lastUpdateTime);
// syncEntity.setState(Constant.PERSON_SYNC_DELETE);
// tenPersonSyncService.updateById(syncEntity);
// }
// //下发通知
// List<TenPersonSyncEntity> allDelete = tenPersonSyncService.findDeviceAllDeletePersons(deviceEntity.getDeviceId(), deviceEntity.getTenantId());
// for (TenPersonSyncEntity syncEntity : allDelete) {
// TenPersonOperationVo vo = new TenPersonOperationVo();
// vo.setUid(syncEntity.getPersonId());
// vo.setOperation(Constant.PERSON_SYNC_DELETE);
// vo.setLast_update_stamp(syncEntity.getLastUpdateTime());
// list.add(vo);
// }
//
// int flag = serverApiService.personOperation(sn, list);
// if (flag == 0) {
// //下发成功删除状态为删除的同步人员
// tenPersonSyncService.removeAllDeletePersons(deviceEntity.getDeviceId(), tenantId);
// }
// }
List<Map<String, String>> snPersonsList = tenPersonSyncService.findGroupDevicePersons(personIds, tenantId);
for (Map<String, String> snPersons : snPersonsList) {
String sn = snPersons.get("deviceSn");
TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
if(deviceEntity==null){
continue;
}
String[] persons = snPersons.get("plist").split(",");
List<TenPersonOperationVo> list = new ArrayList<>();
for (String personStr : persons) {
String[] personInfoStr = personStr.split("_");
Long personId = Long.parseLong(personInfoStr[0]);
Date lastUpdateTime = DateUtils.stringToDate(personInfoStr[1], DateUtils.DATE_TIME_PATTERN);
TenPersonSyncEntity syncEntity = tenPersonSyncService.findByDeviceIdAndPersonId(deviceEntity.getDeviceId(), personId, tenantId);
syncEntity.setLastUpdateTime(lastUpdateTime);
syncEntity.setState(Constant.PERSON_SYNC_DELETE);
tenPersonSyncService.updateById(syncEntity);
}
//下发通知
List<TenPersonSyncEntity> allDelete = tenPersonSyncService.findDeviceAllDeletePersons(deviceEntity.getDeviceId(), deviceEntity.getTenantId());
for (TenPersonSyncEntity syncEntity : allDelete) {
TenPersonOperationVo vo = new TenPersonOperationVo();
vo.setUid(syncEntity.getPersonId());
vo.setOperation(Constant.PERSON_SYNC_DELETE);
vo.setLast_update_stamp(syncEntity.getLastUpdateTime());
list.add(vo);
}
int flag = serverApiService.personOperation(sn, list);
if (flag == 0) {
//下发成功删除状态为删除的同步人员
tenPersonSyncService.removeAllDeletePersons(deviceEntity.getDeviceId(), tenantId);
}
}
return true;
}
@ -1082,7 +1112,27 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
TenPersonEntity entity = tenPersonDao.selectById(personId, cellId);
if(entity!=null) {
entity.setLastUpdateTime(new Date());
tenPersonDao.updateById(entity);
List<TenPersonSyncEntity> syncEntitys = tenPersonSyncService.findByPersonId(entity.getPersonId(), entity.getTenantId());
for (TenPersonSyncEntity syncEn : syncEntitys) {
syncEn.setLastUpdateTime(entity.getLastUpdateTime());
syncEn.setState(2);
tenPersonSyncService.updateById(syncEn);
//下发通知
List<TenPersonOperationVo> list = new ArrayList<>();
TenPersonOperationVo vo = new TenPersonOperationVo();
vo.setUid(entity.getPersonId());
vo.setOperation(2);
vo.setLast_update_stamp(entity.getLastUpdateTime());
list.add(vo);
serverApiService.personOperation(syncEn.getDeviceSn(), list);
}
} else {
return false;
}
@ -1652,20 +1702,20 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
log.debug("内存增加人员:"+entity.getPersonId()+" 姓名:"+entity.getName());
//配置同步数据
// List<TenPersonSyncEntity> syncEntitys = tenPersonSyncService.findByPersonId(entity.getPersonId(), entity.getTenantId());
// for (TenPersonSyncEntity syncEn : syncEntitys) {
// syncEn.setLastUpdateTime(entity.getLastUpdateTime());
// syncEn.setState(2);
// tenPersonSyncService.updateById(syncEn);
// //下发通知
// List<TenPersonOperationVo> list = new ArrayList<>();
// TenPersonOperationVo vo = new TenPersonOperationVo();
// vo.setUid(entity.getPersonId());
// vo.setOperation(2);
// vo.setLast_update_stamp(entity.getLastUpdateTime());
// list.add(vo);
// serverApiService.personOperation(syncEn.getDeviceSn(), list);
// }
List<TenPersonSyncEntity> syncEntitys = tenPersonSyncService.findByPersonId(entity.getPersonId(), entity.getTenantId());
for (TenPersonSyncEntity syncEn : syncEntitys) {
syncEn.setLastUpdateTime(entity.getLastUpdateTime());
syncEn.setState(2);
tenPersonSyncService.updateById(syncEn);
//下发通知
List<TenPersonOperationVo> list = new ArrayList<>();
TenPersonOperationVo vo = new TenPersonOperationVo();
vo.setUid(entity.getPersonId());
vo.setOperation(2);
vo.setLast_update_stamp(entity.getLastUpdateTime());
list.add(vo);
serverApiService.personOperation(syncEn.getDeviceSn(), list);
}
}
tenPersonDao.updateById(entity);
@ -2738,4 +2788,48 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
return "update";
}
}
@Override
public void updateTenPersonByOpenId(TenPersonEntity tenPerson) {
UpdateWrapper<TenPersonEntity> updateWrapper = new UpdateWrapper<>();
// 根据某个字段设置更新条件比如根据 id 更新
updateWrapper.eq("open_id", tenPerson.getOrgId());
tenPersonDao.update(tenPerson, updateWrapper);
//发送设备通知
List<TenDeviceVo> devList = tenDeviceService.findByCellId(tenPerson.getCellId());
//状态是0正常发送推送
if (tenPerson.getStatus() == Constant.PESON_SUATUS_NOMOR) {
for (TenDeviceVo dev : devList) {
//添加到同步表下发设备通知
TenPersonSyncEntity syncEntity = new TenPersonSyncEntity();
syncEntity.setPersonId(tenPerson.getPersonId());
syncEntity.setTenantId(tenPerson.getTenantId());
syncEntity.setDeviceSn(dev.getSn());
syncEntity.setDeviceId(dev.getDeviceId());
syncEntity.setState(1);
syncEntity.setLastUpdateTime(tenPerson.getLastUpdateTime());
tenPersonSyncService.insert(syncEntity);
//下发通知
List<TenPersonOperationVo> list = new ArrayList<>();
TenPersonOperationVo vo = new TenPersonOperationVo();
vo.setUid(syncEntity.getPersonId());
vo.setOperation(1);
vo.setLast_update_stamp(syncEntity.getLastUpdateTime());
list.add(vo);
serverApiService.personOperation(dev.getSn(), list);
}
}
}
@Override
public void insertTemp(String openId) {
tenPersonSyncTempMapper.insertTemp(openId);
}
}

View File

@ -57,6 +57,7 @@ public class TenUserVo {
private Integer isProtectDevice;
private Integer isWatchSafeVideo;
private Integer isBlacklistPersonnel;
private Integer IsCheckCert;
private List<TenPersonCert> tenPersonCertList;
private List<TenPersonTrain> tenPersonTrainList;

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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.enter.CqEnterConfigMapper">
</mapper>

View File

@ -1,52 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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.enter.CqEnterMapper">
<update id="changeState">
UPDATE ten_enter_config_type
SET state = NOT state
WHERE id = #{ruleId};
</update>
<select id="classifiedQuery" resultType="net.shapelight.modules.iCq.controller.enter.to.FTo">
SELECT
cell_id,
MAX(operate_time) AS operate_time
FROM
ten_enter_config_cell
WHERE 1 = 1
<if test="cellId != null and cellId != ''">
AND cell_id = #{cellId}
</if>
GROUP BY
cell_id ;
</select>
<select id="getPersonType" resultType="net.shapelight.modules.iCq.controller.enter.vo.PeronType">
select type, name FROM ten_label WHERE delete_flag = 0
</select>
<select id="rulesByType" resultType="net.shapelight.modules.iCq.controller.enter.vo.TypeRules">
SELECT
tec.check_item, tec.remark,
tect.state, tect.id
FROM
ten_enter_config tec
JOIN
ten_enter_config_type tect
ON
tec.id = tect.enter_config_id
WHERE
tect.type_id = #{typeId}
<if test="cellId != null and cellId != ''">
and tect.cell_id = #{cellId};
</if>
</select>
<select id="queryByCellId" resultType="net.shapelight.modules.iCq.controller.enter.to.EnterVo">
SELECT
enter_config_id,type_id,state,check_item as configName
FROM
ten_enter_config_type a left join ten_enter_config b on a.enter_config_id = b.id
WHERE cell_id = #{cellId}
</select>
</mapper>

View File

@ -3,10 +3,5 @@
<mapper namespace="net.shapelight.modules.iCq.dal.mysql.video.CqFileMapper">
<select id="selectByFileId" resultType="net.shapelight.modules.iCq.dal.dataobject.video.FileEntity">
SELECT file_id, file_name, file_url
FROM ten_file
WHERE file_id = #{fileId}
</select>
</mapper>

View File

@ -18,9 +18,7 @@
<select id="speciallyForVisitors" resultType="java.lang.Integer">
SELECT label_id FROM ten_label WHERE name = '访客人员'
</select>
<select id="speciallyForVisitors2" resultType="java.lang.Long">
SELECT type FROM ten_label WHERE name = '访客人员'
</select>
<select id="orgidBecomesCellId" resultType="java.lang.Long">
SELECT cell_id from ten_cell WHERE org_id = #{orgId}
</select>

View File

@ -4,9 +4,4 @@
<mapper namespace="net.shapelight.modules.iCq.dal.mysql.video.CqSafeVideoMapper">
<select id="findTheNameById" resultType="java.lang.String">
SELECT name FROM ten_cell WHERE cell_id = #{cellId} and delete_flag = 0
</select>
</mapper>

View File

@ -143,7 +143,7 @@
</resultMap>
<insert id="insert" parameterType="net.shapelight.modules.ten.entity.TenPersonEntity">
<insert id="insert" parameterType="net.shapelight.modules.ten.entity.TenPersonEntity">
insert into ten_person
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="personId != null">
@ -328,6 +328,16 @@
<if test="isBlacklistPersonnel != null">
is_blacklist_personnel,
</if>
<if test="orgId != null">
org_id,
</if>
<if test="isCheckCert != null">
is_check_cert,
</if>
<if test="belongContractorName != null">
belong_contractor_name,
</if>
@ -513,13 +523,28 @@
#{isWatchSafeVideo},
</if>
<if test="isBlacklistPersonnel != null">
#{is_blacklist_personnel},
#{isBlacklistPersonnel},
</if>
<if test=" orgId != null">
#{orgId},
</if>
<if test=" isCheckCert != null">
#{isCheckCert},
</if>
<if test="belongContractorName != null">
#{belongContractorName},
</if>
</trim>
</insert>
<insert id="insertTemp">
INSERT INTO ten_person_sync_temp (open_id) VALUES (#{openId});
</insert>
<update id="updateById" parameterType="net.shapelight.modules.ten.entity.TenPersonEntity">
update ten_person
<set>
@ -890,6 +915,9 @@
<if test="params.liveEnd != null and params.liveEnd!=''">
and p.live_end &lt; #{params.liveEnd}
</if>
<if test="params.isBlacklistPersonnel != null and params.isBlacklistPersonnel!=''">
and p.is_blacklist_personnel = #{params.isBlacklistPersonnel}
</if>
order by p.create_time desc