Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
be5a4805ca
|
|
@ -0,0 +1,86 @@
|
|||
package com.bonus.canteen.core.cook.task;
|
||||
|
||||
import com.bonus.canteen.core.common.utils.RedisUtil;
|
||||
import com.bonus.canteen.core.cook.service.ICookRecipeService;
|
||||
import com.bonus.canteen.core.kitchen.domain.AccessAuthority;
|
||||
import com.bonus.canteen.core.kitchen.domain.KitchenStaffInfo;
|
||||
import com.bonus.canteen.core.kitchen.service.IKitchenDeviceInfoService;
|
||||
import com.bonus.canteen.core.kitchen.service.IKitchenStaffInfoService;
|
||||
import com.bonus.canteen.core.kitchen.utils.NetSDK.FaceManage;
|
||||
import com.bonus.canteen.core.kitchen.utils.initServer;
|
||||
import com.bonus.canteen.core.kitchen.vo.KitchenDeviceListVO;
|
||||
import com.bonus.common.houqin.constant.DeviceTypeEnum;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class KitchenStaffInfoFaceTask {
|
||||
private static final Logger logger = LoggerFactory.getLogger(KitchenStaffInfoFaceTask.class);
|
||||
@Autowired
|
||||
private IKitchenStaffInfoService kitchenStaffInfoService;
|
||||
|
||||
@Autowired
|
||||
private IKitchenDeviceInfoService kitchenDeviceInfoService;
|
||||
|
||||
// @Autowired
|
||||
// private TransactionTemplate transactionTemplate;
|
||||
|
||||
//@XxlJob("cookRecipeHandler")
|
||||
@Scheduled(fixedDelay = 10*60*1000)
|
||||
public void KitchenStaffInfoFaceHandler() {
|
||||
if(1==1){
|
||||
return;
|
||||
}
|
||||
logger.info("[定时修复发送门禁人脸信息]开始:{},{}", "0", LocalDateTime.now());
|
||||
try{
|
||||
List<KitchenStaffInfo> list=this.kitchenStaffInfoService.selectKitchenStaffInfoList(new KitchenStaffInfo());
|
||||
int userl=-1;
|
||||
for(KitchenStaffInfo info:list){
|
||||
if("1".equals(info.getFaceFlage())){
|
||||
continue;
|
||||
}
|
||||
List<AccessAuthority> devlist=new ArrayList<>();
|
||||
if(info.getAccessAuthorityList()!=null&&info.getAccessAuthorityList().size()>0){
|
||||
for(AccessAuthority aaInfo:info.getAccessAuthorityList()){
|
||||
if(DeviceTypeEnum.DOOR.getKey().equals(aaInfo.getDeviceType())){
|
||||
devlist.add(aaInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(devlist!=null&&devlist.size()>0){
|
||||
for(AccessAuthority aaInfo:devlist){
|
||||
KitchenDeviceListVO vo=kitchenDeviceInfoService.selectKitchenDeviceInfoByDeviceId(aaInfo.getDeviceId());
|
||||
String ip="192.168.20.51";
|
||||
String user="admin";
|
||||
String pass="JYY202509";
|
||||
userl=initServer.LoginReture(ip,user,pass,(short) 8000,1);
|
||||
if(userl==-1){
|
||||
logger.info("[定时修复发送门禁人脸信息]:{},{}", ip+"无法登录", LocalDateTime.now());
|
||||
}else{
|
||||
logger.info("[定时修复发送门禁人脸信息]:{},{}", ip+"登录成功", LocalDateTime.now());
|
||||
logger.info(info.getStaffNo());
|
||||
logger.info(info.getFaceUrl());
|
||||
int faceres=FaceManage.addFaceByUrl(userl,info.getStaffNo(),info.getFaceUrl());
|
||||
if(faceres==1){
|
||||
kitchenStaffInfoService.updateKitchenStaffInfoFaceFlage(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
initServer.logout(userl);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("[定时修复发送门禁人脸信息]结束:{},{}", "1", LocalDateTime.now());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,8 @@ package com.bonus.canteen.core.kitchen.domain;
|
|||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
import com.bonus.canteen.core.common.utils.FileUrlUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
|
@ -13,7 +15,7 @@ import com.bonus.common.core.web.domain.BaseEntity;
|
|||
|
||||
/**
|
||||
* 厨房员工违规报警对象 kitchen_staff_illegal_warning
|
||||
*
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-06-16
|
||||
*/
|
||||
|
|
@ -42,6 +44,11 @@ public class KitchenStaffIllegalWarning extends BaseEntity {
|
|||
@ApiModelProperty(value = "记录照片地址")
|
||||
private String imgUrl;
|
||||
|
||||
|
||||
public String getImgUrl() {
|
||||
return FileUrlUtil.getFileUrl(this.imgUrl);
|
||||
}
|
||||
|
||||
/** 记录内容 */
|
||||
@Excel(name = "记录内容")
|
||||
@ApiModelProperty(value = "记录内容")
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ public class KitchenStaffInfo extends BaseEntity {
|
|||
private String encryptedSearchValue;
|
||||
|
||||
private String searchValue;
|
||||
|
||||
private String faceFlage;
|
||||
public String getHealthCertFrontImg() {
|
||||
return FileUrlUtil.getFileUrl(this.healthCertFrontImg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ public interface KitchenDeviceInfoMapper extends BaseMapper<KitchenDeviceInfo> {
|
|||
*/
|
||||
public int insertKitchenDeviceInfo(KitchenDeviceInfo kitchenDeviceInfo);
|
||||
|
||||
|
||||
/**
|
||||
* 修改厨房设备基础信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bonus.canteen.core.kitchen.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.canteen.core.kitchen.domain.KitchenDeviceInfo;
|
||||
import com.bonus.canteen.core.kitchen.domain.KitchenStaffInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
|
@ -42,7 +44,7 @@ public interface KitchenStaffInfoMapper {
|
|||
* @return 结果
|
||||
*/
|
||||
public int updateKitchenStaffInfo(KitchenStaffInfo kitchenStaffInfo);
|
||||
|
||||
public int updateKitchenStaffInfoFaceFlage(KitchenStaffInfo kitchenStaffInfo);
|
||||
/**
|
||||
* 删除厨房员工资料
|
||||
*
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public interface IKitchenStaffInfoService {
|
|||
*/
|
||||
public int updateKitchenStaffInfo(KitchenStaffInfo kitchenStaffInfo);
|
||||
|
||||
public int updateKitchenStaffInfoFaceFlage(KitchenStaffInfo kitchenStaffInfo);
|
||||
/**
|
||||
* 修改厨房员工人脸状态
|
||||
*
|
||||
|
|
|
|||
|
|
@ -63,47 +63,67 @@ public class KitchenStaffFaceServiceImpl implements IKitchenStaffFaceService {
|
|||
} else {
|
||||
long startTime = System.currentTimeMillis();
|
||||
//发送请求 调用人脸特征提取接口
|
||||
String url = FileUrlUtil.getFileUrl(dto.getPhotoUrl());
|
||||
System.out.println("人脸特征提取url:" + url);
|
||||
String response = FaceFeatureDetector.detectFaceFeature(url);
|
||||
System.out.println("人脸特征提取接口返回结果:" + response);
|
||||
JSONObject jsonResponse = JSONObject.parseObject(response.toString());
|
||||
if (jsonResponse.getInteger("code") != 30002) {
|
||||
System.out.println("人脸特征提取失败," + jsonResponse.getString("msg"));
|
||||
log.error("人脸特征提取失败,{}", jsonResponse.getString("msg"));
|
||||
throw new ServiceException("人脸特征提取失败," + jsonResponse.getString("msg"));
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
System.out.println("人脸特征提取耗时:" + (endTime - startTime) + "ms");
|
||||
List<KitchenStaffFace> list = new ArrayList<>();
|
||||
String dataStr = jsonResponse.getString("data");
|
||||
// 将data字符串解析为JSONArray
|
||||
JSONArray dataArray = JSONArray.parseArray(dataStr);
|
||||
if (dataArray != null && !dataArray.isEmpty()) {
|
||||
Object faceFeature = dataArray.get(0);
|
||||
KitchenStaffFace faceVO = new KitchenStaffFace();
|
||||
faceVO.setErrorMsg("[软件]成功");
|
||||
faceVO.setFeatures(faceFeature.toString());
|
||||
faceVO.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
faceVO.setStaffId(dto.getStaffId());
|
||||
faceVO.setPhotoUrl(dto.getPhotoUrl());
|
||||
faceVO.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
faceVO.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
faceVO.setCreateTime(DateUtils.getTime());
|
||||
faceVO.setUpdateTime(DateUtils.getTime());
|
||||
list.add(faceVO);
|
||||
int code = kitchenStaffFaceMapper.insertStaffFace(list.get(0));
|
||||
if (code == 0) {
|
||||
System.out.println("[人脸识别算法]:保存失败");
|
||||
log.error("[人脸识别算法]:保存失败");
|
||||
throw new ServiceException("[人脸识别算法]:保存失败");
|
||||
}
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(dto.getStaffId().intValue(),"update");
|
||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.MORNING_INSPECTION_DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
}else{
|
||||
throw new ServiceException("人脸特征提取失败,未检测到人脸");
|
||||
// String url = FileUrlUtil.getFileUrl(dto.getPhotoUrl());
|
||||
// System.out.println("人脸特征提取url:" + url);
|
||||
// String response = FaceFeatureDetector.detectFaceFeature(url);
|
||||
// System.out.println("人脸特征提取接口返回结果:" + response);
|
||||
// JSONObject jsonResponse = JSONObject.parseObject(response.toString());
|
||||
// if (jsonResponse.getInteger("code") != 30002) {
|
||||
// System.out.println("人脸特征提取失败," + jsonResponse.getString("msg"));
|
||||
// log.error("人脸特征提取失败,{}", jsonResponse.getString("msg"));
|
||||
// throw new ServiceException("人脸特征提取失败," + jsonResponse.getString("msg"));
|
||||
// }
|
||||
// long endTime = System.currentTimeMillis();
|
||||
// System.out.println("人脸特征提取耗时:" + (endTime - startTime) + "ms");
|
||||
// List<KitchenStaffFace> list = new ArrayList<>();
|
||||
// String dataStr = jsonResponse.getString("data");
|
||||
// // 将data字符串解析为JSONArray
|
||||
// JSONArray dataArray = JSONArray.parseArray(dataStr);
|
||||
// if (dataArray != null && !dataArray.isEmpty()) {
|
||||
// Object faceFeature = dataArray.get(0);
|
||||
// KitchenStaffFace faceVO = new KitchenStaffFace();
|
||||
// faceVO.setErrorMsg("[软件]成功");
|
||||
// faceVO.setFeatures(faceFeature.toString());
|
||||
// faceVO.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
// faceVO.setStaffId(dto.getStaffId());
|
||||
// faceVO.setPhotoUrl(dto.getPhotoUrl());
|
||||
// faceVO.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
// faceVO.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
// faceVO.setCreateTime(DateUtils.getTime());
|
||||
// faceVO.setUpdateTime(DateUtils.getTime());
|
||||
// list.add(faceVO);
|
||||
// int code = kitchenStaffFaceMapper.insertStaffFace(list.get(0));
|
||||
// if (code == 0) {
|
||||
// System.out.println("[人脸识别算法]:保存失败");
|
||||
// log.error("[人脸识别算法]:保存失败");
|
||||
// throw new ServiceException("[人脸识别算法]:保存失败");
|
||||
// }
|
||||
//
|
||||
// DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(dto.getStaffId().intValue(),"update");
|
||||
// MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.MORNING_INSPECTION_DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
// }else{
|
||||
// throw new ServiceException("人脸特征提取失败,未检测到人脸");
|
||||
// }
|
||||
KitchenStaffFace faceVO = new KitchenStaffFace();
|
||||
faceVO.setErrorMsg("[软件]成功");
|
||||
faceVO.setFeatures("");
|
||||
faceVO.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
faceVO.setStaffId(dto.getStaffId());
|
||||
faceVO.setPhotoUrl(dto.getPhotoUrl());
|
||||
faceVO.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
faceVO.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
faceVO.setCreateTime(DateUtils.getTime());
|
||||
faceVO.setUpdateTime(DateUtils.getTime());
|
||||
int code = kitchenStaffFaceMapper.insertStaffFace(faceVO);
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(dto.getStaffId().intValue(),"update");
|
||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.MORNING_INSPECTION_DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
if (code == 0) {
|
||||
System.out.println("[人脸识别算法]:保存失败");
|
||||
log.error("[人脸识别算法]:保存失败");
|
||||
throw new ServiceException("[人脸识别算法]:保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ public class KitchenStaffIllegalWarningServiceImpl implements IKitchenStaffIlleg
|
|||
|
||||
@Override
|
||||
public void uploadVideoPhoto(byte[] imageBytes, VideoPhotoDTO videoPhotoDTO) {
|
||||
System.err.println("接收到图片 bytes 长度=" + (imageBytes != null ? imageBytes.length : 0));
|
||||
AjaxResult ar = fileServiceClient.uploadVideoFile(convertByteToMultipartFile(imageBytes,"demo.jpg"));
|
||||
SysFile sysFile = ar.getDataAs(SysFile.class);
|
||||
KitchenStaffIllegalWarning kitchenStaffIllegalWarning = new KitchenStaffIllegalWarning();
|
||||
|
|
@ -148,7 +149,9 @@ public class KitchenStaffIllegalWarningServiceImpl implements IKitchenStaffIlleg
|
|||
kitchenStaffIllegalWarning.setCreateBy(SecurityUtils.getUsername());
|
||||
kitchenStaffIllegalWarning.setCreateTime(DateUtils.getNowDate());
|
||||
kitchenStaffIllegalWarning.setStaffId(11L);
|
||||
KitchenDeviceInfo kitchenDeviceInfo = kitchenDeviceInfoMapper.selectKitchenDeviceInfoByChannelAndDeviceType(videoPhotoDTO.getChannel(), DeviceTypeEnum.CAMERA.getKey()+"");
|
||||
int channel = Integer.parseInt(videoPhotoDTO.getChannel())-33;
|
||||
|
||||
KitchenDeviceInfo kitchenDeviceInfo = kitchenDeviceInfoMapper.selectKitchenDeviceInfoByChannelAndDeviceType(channel+"", DeviceTypeEnum.CAMERA.getKey()+"");
|
||||
if(kitchenDeviceInfo != null){
|
||||
kitchenStaffIllegalWarning.setDeviceId(kitchenDeviceInfo.getDeviceId());
|
||||
}else {
|
||||
|
|
|
|||
|
|
@ -217,6 +217,10 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
|
|||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateKitchenStaffInfoFaceFlage(KitchenStaffInfo kitchenStaffInfo){
|
||||
return kitchenStaffInfoMapper.updateKitchenStaffInfoFaceFlage(kitchenStaffInfo);
|
||||
}
|
||||
@Override
|
||||
public int updateKitchenStaffFaceState(KitchenStaffInfo kitchenStaffInfo) {
|
||||
if(Objects.isNull(kitchenStaffInfo.getStaffId())) {
|
||||
|
|
|
|||
|
|
@ -129,7 +129,8 @@ public final class FaceManage {
|
|||
* @param employeeNo 人员工号
|
||||
* @throws JSONException
|
||||
*/
|
||||
public static void addFaceByUrl(int userID,String employeeNo,String fileUrl) throws JSONException {
|
||||
public static int addFaceByUrl(int userID,String employeeNo,String fileUrl) throws JSONException {
|
||||
int userl=-1;
|
||||
HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组
|
||||
String strInBuffer = "PUT /ISAPI/Intelligent/FDLib/FDSetUp?format=json";
|
||||
System.arraycopy(strInBuffer.getBytes(), 0, ptrByteArray.byValue, 0, strInBuffer.length());//字符串拷贝到数组中
|
||||
|
|
@ -137,7 +138,7 @@ public final class FaceManage {
|
|||
int lHandler = initServer.hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_FACE_DATA_RECORD, ptrByteArray.getPointer(), strInBuffer.length(), null, null);
|
||||
if (lHandler < 0){
|
||||
System.out.println("Addface NET_DVR_StartRemoteConfig 失败,错误码为"+initServer.hCNetSDK.NET_DVR_GetLastError());
|
||||
return;
|
||||
return userl;
|
||||
}else{
|
||||
System.out.println("Addface NET_DVR_StartRemoteConfig 成功!");
|
||||
HCNetSDK.NET_DVR_JSON_DATA_CFG struAddFaceDataCfg = new HCNetSDK.NET_DVR_JSON_DATA_CFG();
|
||||
|
|
@ -190,11 +191,13 @@ public final class FaceManage {
|
|||
System.out.println("下发人脸成功,但是有异常情况:" + jsonResult.toString());
|
||||
}else{
|
||||
System.out.println("下发人脸成功, json retun:" + jsonResult.toString());
|
||||
userl=1;
|
||||
}
|
||||
break;
|
||||
}else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
|
||||
//下发人脸时:dwState其实不会走到这里,因为设备不知道我们会下发多少个人,所以长连接需要我们主动关闭
|
||||
System.out.println("下发人脸完成");
|
||||
userl=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -202,7 +205,9 @@ public final class FaceManage {
|
|||
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + initServer.hCNetSDK.NET_DVR_GetLastError());
|
||||
}else{
|
||||
System.out.println("NET_DVR_StopRemoteConfig接口成功");
|
||||
userl=1;
|
||||
}
|
||||
return userl;
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class initServer implements CommandLineRunner {
|
|||
public static String devPass = "hzx12345";
|
||||
|
||||
public static int lUserID2 = -1;//用户句柄
|
||||
public static String devIp2 = "192.168.10.89";
|
||||
public static String devIp2 = "192.168.20.32";
|
||||
public static String devUser2 = "admin";
|
||||
public static String devPass2 = "JYY202509";
|
||||
@Override
|
||||
|
|
@ -193,5 +193,57 @@ public class initServer implements CommandLineRunner {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static int LoginReture(String ipadress, String user, String psw, short port,int type) {
|
||||
int returnl=-1;
|
||||
//注册
|
||||
HCNetSDK.NET_DVR_USER_LOGIN_INFO m_strLoginInfo = new HCNetSDK.NET_DVR_USER_LOGIN_INFO();//设备登录信息
|
||||
String m_sDeviceIP = ipadress;//设备ip地址
|
||||
m_strLoginInfo.sDeviceAddress = new byte[HCNetSDK.NET_DVR_DEV_ADDRESS_MAX_LEN];
|
||||
System.arraycopy(m_sDeviceIP.getBytes(), 0, m_strLoginInfo.sDeviceAddress, 0, m_sDeviceIP.length());
|
||||
String m_sUsername = user;//设备用户名
|
||||
m_strLoginInfo.sUserName = new byte[HCNetSDK.NET_DVR_LOGIN_USERNAME_MAX_LEN];
|
||||
System.arraycopy(m_sUsername.getBytes(), 0, m_strLoginInfo.sUserName, 0, m_sUsername.length());
|
||||
String m_sPassword = psw;//设备密码
|
||||
m_strLoginInfo.sPassword = new byte[HCNetSDK.NET_DVR_LOGIN_PASSWD_MAX_LEN];
|
||||
System.arraycopy(m_sPassword.getBytes(), 0, m_strLoginInfo.sPassword, 0, m_sPassword.length());
|
||||
m_strLoginInfo.wPort = port; //sdk端口
|
||||
m_strLoginInfo.bUseAsynLogin = false; //是否异步登录:0- 否,1- 是
|
||||
m_strLoginInfo.write();
|
||||
HCNetSDK.NET_DVR_DEVICEINFO_V40 m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V40();//设备信息
|
||||
if(type == 1){
|
||||
returnl = hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
|
||||
if (returnl == -1){
|
||||
System.out.println(ipadress+"门禁登录失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
|
||||
}else{
|
||||
System.out.println(ipadress+"门禁登录成功!");
|
||||
m_strDeviceInfo.read();
|
||||
iCharEncodeType = m_strDeviceInfo.byCharEncodeType;
|
||||
}
|
||||
}else{
|
||||
returnl = hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
|
||||
if (returnl == -1){
|
||||
System.out.println("智能识别登录失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
|
||||
}else{
|
||||
System.out.println("智能识别登录成功!");
|
||||
m_strDeviceInfo.read();
|
||||
iCharEncodeType = m_strDeviceInfo.byCharEncodeType;
|
||||
}
|
||||
}
|
||||
return returnl;
|
||||
}
|
||||
|
||||
public static void logout(int m_lUserID) {
|
||||
if (m_lUserID != -1) {
|
||||
boolean result = hCNetSDK.NET_DVR_Logout_V30(m_lUserID); // 使用V30版本注销,根据你的SDK版本选择合适的注销方法
|
||||
if (result) {
|
||||
System.out.println("Logout successful");
|
||||
} else {
|
||||
System.out.println("Logout failed");
|
||||
}
|
||||
m_lUserID = -1; // 重置用户ID
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.validation.Valid;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bonus.canteen.core.user.domain.AppUserFace;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.houqin.constant.RetCodeEnum;
|
||||
import com.bonus.common.houqin.encrypt.RequiresGuest;
|
||||
|
|
@ -52,4 +53,17 @@ public class UserFaceController extends BaseController {
|
|||
return UserFaceService.uploadUserFace(dto);
|
||||
}
|
||||
|
||||
@ApiOperation("保存APP人脸图片特征值")
|
||||
@PostMapping({"/saveAppFaceEigenvalue"})
|
||||
@RequiresGuest
|
||||
public AjaxResult saveAppFaceEigenvalue(@RequestBody @Valid AppUserFace dto) {
|
||||
return UserFaceService.saveAppFaceEigenvalue(dto);
|
||||
}
|
||||
@ApiOperation("保存APP人脸图片特征值")
|
||||
@PostMapping({"/saveHealthAppFaceEigenvalue"})
|
||||
@RequiresGuest
|
||||
public AjaxResult saveHealthAppFaceEigenvalue(@RequestBody @Valid AppUserFace dto) {
|
||||
return UserFaceService.saveHealthAppFaceEigenvalue(dto);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package com.bonus.canteen.core.user.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AppUserFace {
|
||||
private List<UserFace> userFaceList;
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.bonus.canteen.core.user.mapper;
|
|||
|
||||
import java.util.List;
|
||||
import com.bonus.canteen.core.user.domain.UserFace;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 人员生物识别特征Mapper接口
|
||||
|
|
@ -13,4 +14,8 @@ public interface UserFaceMapper {
|
|||
int insertUserFace(UserFace userFace);
|
||||
|
||||
int deleteUserFace(UserFace userFace);
|
||||
|
||||
int saveBatch(@Param("list") List<UserFace> list);
|
||||
|
||||
int saveHealthBatch(@Param("list") List<UserFace> list);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bonus.canteen.core.user.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.canteen.core.user.domain.AppUserFace;
|
||||
import com.bonus.canteen.core.user.domain.UserFace;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
|
|
@ -20,4 +22,13 @@ public interface IUserFaceService {
|
|||
* @return 人员生物识别特征
|
||||
*/
|
||||
AjaxResult uploadUserFace(@Valid UserFace dto);
|
||||
/**
|
||||
* 保存APP人脸图片特征值
|
||||
*
|
||||
* @param dto 人员生物识别特征主键
|
||||
* @return 人员生物识别特征
|
||||
*/
|
||||
AjaxResult saveAppFaceEigenvalue(AppUserFace dto);
|
||||
|
||||
AjaxResult saveHealthAppFaceEigenvalue(AppUserFace dto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,8 @@ package com.bonus.canteen.core.user.service.impl;
|
|||
import java.beans.FeatureDescriptor;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
|
|
@ -14,6 +12,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.bonus.canteen.core.common.utils.FileUrlUtil;
|
||||
import com.bonus.canteen.core.common.utils.HttpClient;
|
||||
import com.bonus.canteen.core.common.utils.MqUtil;
|
||||
import com.bonus.canteen.core.user.domain.AppUserFace;
|
||||
import com.bonus.canteen.core.user.domain.DeviceMqPersonalUpdateMessageDTO;
|
||||
import com.bonus.canteen.core.user.utils.ArcFaceHelper;
|
||||
import com.bonus.canteen.core.user.utils.FaceFeatureDetector;
|
||||
|
|
@ -31,6 +30,7 @@ import org.springframework.stereotype.Service;
|
|||
import com.bonus.canteen.core.user.mapper.UserFaceMapper;
|
||||
import com.bonus.canteen.core.user.domain.UserFace;
|
||||
import com.bonus.canteen.core.user.service.IUserFaceService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 人员生物识别特征Service业务层处理
|
||||
|
|
@ -105,10 +105,69 @@ public class UserFaceServiceImpl implements IUserFaceService {
|
|||
}
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(dto.getUserId().intValue(), "update");
|
||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
}else{
|
||||
} else {
|
||||
throw new ServiceException("人脸特征提取失败,未检测到人脸");
|
||||
}
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存APP人脸图片特征值
|
||||
*
|
||||
* @param dto 人员生物识别特征主键
|
||||
* @return 人员生物识别特征
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult saveAppFaceEigenvalue(AppUserFace dto) {
|
||||
if (ObjectUtil.isNull(dto)) {
|
||||
throw new ServiceException("参数为空!");
|
||||
}
|
||||
if (ObjectUtil.isNull(dto.getUserFaceList()) || dto.getUserFaceList().isEmpty()) {
|
||||
throw new ServiceException("人脸特征值为空!");
|
||||
}
|
||||
List<UserFace> list = dto.getUserFaceList();
|
||||
list.forEach(faceVO -> {
|
||||
faceVO.setErrorMsg("[软件]成功");
|
||||
faceVO.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
faceVO.setUpdateTime(DateUtils.getTime());
|
||||
faceVO.setPhotoType(1L);
|
||||
});
|
||||
int code = userFaceMapper.saveBatch(list);
|
||||
if (code > 0) {
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(null, "update");
|
||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
throw new ServiceException("保存失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult saveHealthAppFaceEigenvalue(AppUserFace dto) {
|
||||
if (ObjectUtil.isNull(dto)) {
|
||||
throw new ServiceException("参数为空!");
|
||||
}
|
||||
if (ObjectUtil.isNull(dto.getUserFaceList()) || dto.getUserFaceList().isEmpty()) {
|
||||
throw new ServiceException("人脸特征值为空!");
|
||||
}
|
||||
List<UserFace> list = dto.getUserFaceList();
|
||||
list.forEach(faceVO -> {
|
||||
faceVO.setErrorMsg("[软件]成功");
|
||||
faceVO.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
faceVO.setUpdateTime(DateUtils.getTime());
|
||||
faceVO.setPhotoType(1L);
|
||||
});
|
||||
int code = userFaceMapper.saveHealthBatch(list);
|
||||
if (code > 0) {
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(null, "update");
|
||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.MORNING_INSPECTION_DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
throw new ServiceException("保存失败");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
features,
|
||||
face_state
|
||||
from user_face
|
||||
where face_state = '1'
|
||||
and features_build_time >= NOW() - INTERVAL 1 DAY
|
||||
where face_state = '1' and features_state = '0'
|
||||
<if test="userId != null and userId != '' and userId != 0 and userId != '0'">
|
||||
and user_id = #{userId}
|
||||
</if>
|
||||
|
|
@ -23,10 +22,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
features,
|
||||
face_state
|
||||
from kitchen_staff_face
|
||||
where face_state = '1'
|
||||
and features_build_time >= NOW() - INTERVAL 1 DAY
|
||||
<if test="userId != null and userId != '' and userId != 0 and userId != '0'">
|
||||
and staff_id = #{userId}
|
||||
</if>
|
||||
where face_state = '1' and features_state = '0'
|
||||
<if test="userId != null and userId != '' and userId != 0 and userId != '0'">
|
||||
and staff_id = #{userId}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -593,7 +593,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="unitPrice != null">unit_price = #{unitPrice},</if>
|
||||
<if test="largePrice != null">large_price = #{largePrice},</if>
|
||||
<if test="littlePrice != null">little_price = #{littlePrice},</if>
|
||||
<if test="imageUrl != null and imageUrl != ''">image_url = #{imageUrl},</if>
|
||||
<if test="imageUrl != null">image_url = #{imageUrl},</if>
|
||||
<if test="particulars != null">particulars = #{particulars},</if>
|
||||
<if test="recommend != null and recommend != ''">recommend = #{recommend},</if>
|
||||
<if test="indexRecommend != null">index_recommend = #{indexRecommend},</if>
|
||||
|
|
|
|||
|
|
@ -17,15 +17,16 @@
|
|||
|
||||
<insert id="addPhysicalExaminationData">
|
||||
insert into kitchen_staff_physical_examination(staff_id, device_id, sex, age, height, weight, bmi, bodyFat, muscle, boneMass,
|
||||
waterContent, extwater, protein, metabolism, fatLevel, bodyAge)
|
||||
waterContent, extwater, protein, metabolism, fatLevel, bodyAge,phone)
|
||||
values (#{dto.userId},#{dto.machineId},#{dto.sex},#{dto.age},#{dto.height},#{dto.weight},#{dto.bmi},#{dto.bodyFat},#{dto.muscle},#{dto.boneMass},#{dto.waterContent},#{dto.extwater},#{dto.protein}
|
||||
,#{dto.metabolism},#{dto.fatLevel},#{dto.bodyAge})
|
||||
,#{dto.metabolism},#{dto.fatLevel},#{dto.bodyAge},#{dto.phone})
|
||||
</insert>
|
||||
|
||||
<select id="selectUserById" resultType="com.bonus.canteen.core.healthmachine.bean.BodyMeasurement">
|
||||
select
|
||||
staff_id as userId,
|
||||
staff_no as userCode
|
||||
staff_no as userCode,
|
||||
mobile as phone
|
||||
from kitchen_staff_info
|
||||
where staff_id = #{userId}
|
||||
limit 1
|
||||
|
|
@ -50,4 +51,4 @@
|
|||
where user_id = #{userId} and del_flag = 0
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -10,13 +10,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<insert id="insertStaffFace" parameterType="com.bonus.canteen.core.kitchen.domain.KitchenStaffFace">
|
||||
insert into kitchen_staff_face(staff_id,photo_url,features,create_by,error_msg,create_time,update_by,update_time)
|
||||
values(#{staffId},#{photoUrl},#{features},#{createBy},#{errorMsg},#{createTime},#{updateBy},#{updateTime})
|
||||
insert into kitchen_staff_face(staff_id,photo_url,features,create_by,error_msg,create_time,update_by,update_time,features_state)
|
||||
values(#{staffId},#{photoUrl},#{features},#{createBy},#{errorMsg},#{createTime},#{updateBy},#{updateTime},'0')
|
||||
on duplicate key update features = #{features},
|
||||
photo_url = #{photoUrl},
|
||||
error_msg = #{errorMsg},
|
||||
update_by = #{updateBy},
|
||||
update_time = #{updateTime}
|
||||
update_time = #{updateTime},
|
||||
features_state = '0'
|
||||
</insert>
|
||||
|
||||
<update id="updateStaffFaceState" >
|
||||
|
|
|
|||
|
|
@ -26,13 +26,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="faceFlage" column="face_flage" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectKitchenStaffInfoVo">
|
||||
select kst.staff_id, kst.canteen_id, staff_no, staff_name, post_name, mobile, password, sex, kst.area_id, health_cert_expire,
|
||||
health_cert_front_img, health_cert_back_img, nutrity_cert_expire,
|
||||
safety_cert_expire, kst.create_by, kst.create_time, kst.update_by, kst.update_time,
|
||||
ksf.photo_url, ksf.face_state, bc.canteen_name, ba.area_name
|
||||
ksf.photo_url, ksf.face_state, bc.canteen_name, ba.area_name,kst.face_flage
|
||||
from kitchen_staff_info kst
|
||||
left join kitchen_staff_face ksf on kst.staff_id = ksf.staff_id
|
||||
left join basic_canteen bc on kst.canteen_id = bc.canteen_id
|
||||
|
|
@ -159,6 +160,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where staff_id = #{staffId}
|
||||
</update>
|
||||
|
||||
<update id="updateKitchenStaffInfoFaceFlage" parameterType="com.bonus.canteen.core.kitchen.domain.KitchenStaffInfo">
|
||||
update kitchen_staff_info set face_flage='1' where staff_id=#{staffId}
|
||||
</update>
|
||||
<delete id="deleteKitchenStaffInfoByStaffId" parameterType="Long">
|
||||
delete from kitchen_staff_info where staff_id = #{staffId}
|
||||
</delete>
|
||||
|
|
|
|||
|
|
@ -4,17 +4,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.canteen.core.user.mapper.UserFaceMapper">
|
||||
<insert id="insertUserFace" parameterType="com.bonus.canteen.core.user.domain.UserFace">
|
||||
insert into user_face(user_id,photo_url,features,create_by,error_msg,create_time,update_by,update_time)
|
||||
values(#{userId},#{photoUrl},#{features},#{createBy},#{errorMsg},#{createTime},#{updateBy},#{updateTime})
|
||||
insert into user_face(user_id,photo_url,features,create_by,error_msg,create_time,update_by,update_time,features_state)
|
||||
values(#{userId},#{photoUrl},#{features},#{createBy},#{errorMsg},#{createTime},#{updateBy},#{updateTime},'0')
|
||||
on duplicate key update features = #{features},
|
||||
photo_url = #{photoUrl},
|
||||
error_msg = #{errorMsg},
|
||||
update_by = #{updateBy},
|
||||
update_time = #{updateTime}
|
||||
update_time = #{updateTime},
|
||||
features_state = '0'
|
||||
</insert>
|
||||
|
||||
<delete id="deleteUserFace" parameterType="com.bonus.canteen.core.user.domain.UserFace">
|
||||
delete from user_face
|
||||
where user_id = #{userId}
|
||||
</delete>
|
||||
|
||||
<insert id="saveBatch">
|
||||
insert into user_face(user_id,photo_url,features,create_by,error_msg,create_time,update_by,update_time,features_state)
|
||||
values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(#{item.userId},#{item.photoUrl},#{item.features},#{item.createBy},#{item.errorMsg},#{item.createTime},#{item.updateBy},#{item.updateTime},'1')
|
||||
</foreach>
|
||||
on duplicate key update features = values(features),
|
||||
photo_url = values(photo_url),
|
||||
error_msg = values(error_msg),
|
||||
update_by = values(update_by),
|
||||
update_time = values(update_time),
|
||||
features_state = '1'
|
||||
</insert>
|
||||
|
||||
<select id="saveHealthBatch" resultType="int">
|
||||
insert into kitchen_staff_face(staff_id, photo_url, features, create_by, error_msg, create_time, update_by,
|
||||
update_time, features_state)
|
||||
values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(#{item.userId}, #{item.photoUrl}, #{item.features}, #{item.createBy}, #{item.errorMsg}, #{item.createTime},
|
||||
#{item.updateBy}, #{item.updateTime}, '1')
|
||||
</foreach>
|
||||
on duplicate key update features = values(features),
|
||||
photo_url = values(photo_url),
|
||||
error_msg = values(error_msg),
|
||||
update_by = values(update_by),
|
||||
update_time = values(update_time),
|
||||
features_state = '1'
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue