Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a34c2add02
|
|
@ -7,8 +7,10 @@ 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.NetSDK.UserManage;
|
||||
import com.bonus.canteen.core.kitchen.utils.initServer;
|
||||
import com.bonus.canteen.core.kitchen.vo.KitchenDeviceListVO;
|
||||
import com.bonus.canteen.core.utils.BnsUtils;
|
||||
import com.bonus.common.houqin.constant.DeviceTypeEnum;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -17,8 +19,11 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
|
|
@ -34,15 +39,21 @@ public class KitchenStaffInfoFaceTask {
|
|||
// private TransactionTemplate transactionTemplate;
|
||||
|
||||
//@XxlJob("cookRecipeHandler")
|
||||
@Scheduled(fixedDelay = 10*60*1000)
|
||||
@Scheduled(fixedDelay = 1*60*1000)
|
||||
public void KitchenStaffInfoFaceHandler() {
|
||||
if(1==1){
|
||||
return;
|
||||
}
|
||||
logger.info("[定时修复发送门禁人脸信息]开始:{},{}", "0", LocalDateTime.now());
|
||||
SimpleDateFormat sdf =new SimpleDateFormat("HH");
|
||||
try{
|
||||
String hour=sdf.format(new Date());
|
||||
if(!"23".equals(hour)){
|
||||
return;
|
||||
}
|
||||
List<KitchenStaffInfo> list=this.kitchenStaffInfoService.selectKitchenStaffInfoList(new KitchenStaffInfo());
|
||||
int userl=-1;
|
||||
String ip="192.168.20.51";
|
||||
String user="admin";
|
||||
String pass="JYY202509";
|
||||
userl=initServer.LoginReture(ip,user,pass,(short) 8000,1);
|
||||
for(KitchenStaffInfo info:list){
|
||||
if("1".equals(info.getFaceFlage())){
|
||||
continue;
|
||||
|
|
@ -55,21 +66,25 @@ public class KitchenStaffInfoFaceTask {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
UserManage.addUserInfo(userl,info.getStaffNo(),info.getStaffName());
|
||||
File file = BnsUtils.getFile(info.getFaceUrl(),info.getFaceUrl().substring(info.getFaceUrl().indexOf("/")));
|
||||
System.out.println(file.getAbsolutePath());
|
||||
int faceres=FaceManage.AddFaceByBinaryFile(userl,info.getStaffNo(),file);
|
||||
if(faceres==1){
|
||||
info.setFaceFlage("1");
|
||||
kitchenStaffInfoService.updateKitchenStaffInfoFaceFlage(info);
|
||||
}else{
|
||||
info.setFaceFlage("0");
|
||||
kitchenStaffInfoService.updateKitchenStaffInfoFaceFlage(info);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.bonus.canteen.core.kitchen.service.IKitchenStaffDevicePrivilegeServic
|
|||
import com.bonus.canteen.core.kitchen.service.IKitchenStaffFaceService;
|
||||
import com.bonus.canteen.core.kitchen.utils.FileCommonUtils;
|
||||
import com.bonus.canteen.core.kitchen.utils.NetSDK.FaceManage;
|
||||
import com.bonus.canteen.core.kitchen.utils.NetSDK.UserManage;
|
||||
import com.bonus.canteen.core.kitchen.utils.initServer;
|
||||
import com.bonus.canteen.core.kitchen.vo.KitchenDeviceListVO;
|
||||
import com.bonus.canteen.core.user.domain.DeviceMqPersonalUpdateMessageDTO;
|
||||
|
|
@ -278,14 +279,30 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService {
|
|||
kitchenStaffDevicePrivilegeList.add(kitchenStaffDevicePrivilege);
|
||||
if((access.getDeviceId()!=null&&access.getDeviceId()==6)&&kitchenStaffInfo.getFaceUrl()!=null&&!"".equals(kitchenStaffInfo.getFaceUrl())){
|
||||
try{
|
||||
boolean dd=initServer.hCNetSDK.NET_DVR_RemoteControl(initServer.lUserID,20005,null,0);
|
||||
if(!dd){
|
||||
initServer.Login(initServer.devIp,initServer.devUser,initServer.devPass,(short) 8000,1);
|
||||
}
|
||||
FaceManage.deleteFaceInfo(initServer.lUserID,kitchenStaffInfo.getStaffNo());
|
||||
int numd=FaceManage.addFaceByUrl(initServer.lUserID,kitchenStaffInfo.getStaffNo(),kitchenStaffInfo.getFaceUrl());
|
||||
UserManage.addUserInfo(initServer.lUserID,kitchenStaffInfo.getStaffNo(),kitchenStaffInfo.getStaffName());
|
||||
System.out.println(kitchenStaffInfo.getFaceUrl());
|
||||
File file = BnsUtils.getFile(kitchenStaffInfo.getFaceUrl(),kitchenStaffInfo.getFaceUrl().substring(kitchenStaffInfo.getFaceUrl().indexOf("/")));
|
||||
System.out.println(file.getAbsolutePath());
|
||||
int numd=FaceManage.AddFaceByBinaryFile(initServer.lUserID,kitchenStaffInfo.getStaffNo(),file);
|
||||
if(numd>0){
|
||||
System.out.println(kitchenStaffInfo.getStaffNo()+" "+kitchenStaffInfo.getStaffName()+" "+"门禁人脸下发成功!");
|
||||
System.out.println(kitchenStaffInfo.getStaffNo()+" "+kitchenStaffInfo.getStaffName()+" "+"门禁人脸下发成功!"+kitchenStaffInfo.getFaceUrl());
|
||||
kitchenStaffInfo.setFaceFlage("1");
|
||||
kitchenStaffInfoMapper.updateKitchenStaffInfoFaceFlage(kitchenStaffInfo);
|
||||
}else{
|
||||
System.err.println(kitchenStaffInfo.getStaffNo()+" "+kitchenStaffInfo.getStaffName()+" "+"门禁人脸下发失败!请上传合规图片!"+kitchenStaffInfo.getFaceUrl());
|
||||
kitchenStaffInfo.setFaceFlage("0");
|
||||
kitchenStaffInfoMapper.updateKitchenStaffInfoFaceFlage(kitchenStaffInfo);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
System.err.println(kitchenStaffInfo.getStaffNo()+" "+kitchenStaffInfo.getStaffName()+" 人员权限不足 "+kitchenStaffInfo.getFaceUrl());
|
||||
}
|
||||
}
|
||||
kitchenStaffDevicePrivilegeService.insertKitchenStaffDevicePrivilege(kitchenStaffDevicePrivilegeList);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,139 @@ public final class FaceManage {
|
|||
* @throws JSONException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public static int AddFaceByBinaryFile(int userID,String employeeNo,File pathFile ) throws JSONException, InterruptedException{
|
||||
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());//字符串拷贝到数组中
|
||||
ptrByteArray.write();
|
||||
|
||||
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 userl;
|
||||
}
|
||||
else{
|
||||
System.out.println("Addface NET_DVR_StartRemoteConfig 成功!");
|
||||
|
||||
HCNetSDK.NET_DVR_JSON_DATA_CFG struAddFaceDataCfg = new HCNetSDK.NET_DVR_JSON_DATA_CFG();
|
||||
struAddFaceDataCfg.read();
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("faceLibType", "blackFD");
|
||||
jsonObject.put("FDID", "1");
|
||||
jsonObject.put("FPID", employeeNo);//人脸下发关联的工号
|
||||
|
||||
String strJsonData = jsonObject.toString();
|
||||
System.arraycopy(strJsonData.getBytes(), 0, ptrByteArray.byValue, 0, strJsonData.length());//字符串拷贝到数组中
|
||||
ptrByteArray.write();
|
||||
struAddFaceDataCfg.dwSize = struAddFaceDataCfg.size();
|
||||
struAddFaceDataCfg.lpJsonData = ptrByteArray.getPointer();
|
||||
struAddFaceDataCfg.dwJsonDataSize = strJsonData.length();
|
||||
/*****************************************
|
||||
* 从本地文件里面读取JPEG图片二进制数据
|
||||
*****************************************/
|
||||
FileInputStream picfile = null;
|
||||
int picdataLength = 0;
|
||||
try{
|
||||
picfile = new FileInputStream(pathFile);
|
||||
}
|
||||
catch(FileNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try{
|
||||
picdataLength = picfile.available();
|
||||
}
|
||||
catch(IOException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if(picdataLength < 0)
|
||||
{
|
||||
System.out.println("input file dataSize < 0");
|
||||
return userl;
|
||||
}
|
||||
|
||||
HCNetSDK.BYTE_ARRAY ptrpicByte = new HCNetSDK.BYTE_ARRAY(picdataLength);
|
||||
try {
|
||||
picfile.read(ptrpicByte.byValue);
|
||||
} catch (IOException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
ptrpicByte.write();
|
||||
struAddFaceDataCfg.dwPicDataSize = picdataLength;
|
||||
struAddFaceDataCfg.lpPicData = ptrpicByte.getPointer();
|
||||
struAddFaceDataCfg.write();
|
||||
|
||||
HCNetSDK.BYTE_ARRAY ptrOutuff = new HCNetSDK.BYTE_ARRAY(1024);
|
||||
|
||||
IntByReference pInt = new IntByReference(0);
|
||||
|
||||
while(true){
|
||||
int dwState = initServer.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, struAddFaceDataCfg.getPointer(), struAddFaceDataCfg.dwSize ,ptrOutuff.getPointer(), 1024, pInt);
|
||||
//读取返回的json并解析
|
||||
ptrOutuff.read();
|
||||
String strResult = new String(ptrOutuff.byValue).trim();
|
||||
System.out.println("dwState:" + dwState + ",strResult:" + strResult);
|
||||
if(dwState == -1){
|
||||
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + initServer.hCNetSDK.NET_DVR_GetLastError());
|
||||
break;
|
||||
}
|
||||
JSONObject jsonResult = new JSONObject(strResult);
|
||||
int statusCode = jsonResult.getInt("statusCode");
|
||||
String statusString = jsonResult.getString("statusString");
|
||||
|
||||
|
||||
if(dwState == -1){
|
||||
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + initServer.hCNetSDK.NET_DVR_GetLastError());
|
||||
break;
|
||||
}
|
||||
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT)
|
||||
{
|
||||
Thread.sleep(10);
|
||||
continue;
|
||||
}
|
||||
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED)
|
||||
{
|
||||
System.out.println("下发人脸失败, json retun:" + jsonResult.toString());
|
||||
break;
|
||||
}
|
||||
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION)
|
||||
{
|
||||
System.out.println("下发人脸异常, json retun:" + jsonResult.toString());
|
||||
break;
|
||||
}
|
||||
else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS)
|
||||
{//返回NET_SDK_CONFIG_STATUS_SUCCESS代表流程走通了,但并不代表下发成功,比如人脸图片不符合设备规范等原因,所以需要解析Json报文
|
||||
if (statusCode != 1){
|
||||
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;
|
||||
}
|
||||
}
|
||||
if(!initServer.hCNetSDK.NET_DVR_StopRemoteConfig(lHandler)){
|
||||
System.out.println("NET_DVR_StopRemoteConfig接口调用失败,错误码:" + initServer.hCNetSDK.NET_DVR_GetLastError());
|
||||
}
|
||||
else{
|
||||
System.out.println("NET_DVR_StopRemoteConfig接口成功");
|
||||
}
|
||||
}
|
||||
return userl;
|
||||
}
|
||||
|
||||
public static int AddFaceByBinary(int userID,String employeeNo,String pathName ) throws JSONException, InterruptedException{
|
||||
int userl=-1;
|
||||
HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组
|
||||
|
|
@ -63,7 +196,6 @@ public final class FaceManage {
|
|||
FileInputStream picfile = null;
|
||||
int picdataLength = 0;
|
||||
try{
|
||||
|
||||
picfile = new FileInputStream(new File(pathName));
|
||||
}
|
||||
catch(FileNotFoundException e)
|
||||
|
|
@ -105,7 +237,10 @@ public final class FaceManage {
|
|||
ptrOutuff.read();
|
||||
String strResult = new String(ptrOutuff.byValue).trim();
|
||||
System.out.println("dwState:" + dwState + ",strResult:" + strResult);
|
||||
|
||||
if(dwState == -1){
|
||||
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败,错误码:" + initServer.hCNetSDK.NET_DVR_GetLastError());
|
||||
break;
|
||||
}
|
||||
JSONObject jsonResult = new JSONObject(strResult);
|
||||
int statusCode = jsonResult.getInt("statusCode");
|
||||
String statusString = jsonResult.getString("statusString");
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.canteen.core.kitchen.utils;
|
|||
import com.bonus.canteen.core.kitchen.dto.UserVo;
|
||||
import com.bonus.canteen.core.kitchen.utils.NetSDK.*;
|
||||
import com.bonus.canteen.core.kitchen.utils.NetSDKCommom.ConfigFileUtil;
|
||||
import com.bonus.canteen.core.utils.BnsUtils;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -55,17 +56,20 @@ public class initServer implements CommandLineRunner {
|
|||
|
||||
Login(devIp,devUser,devPass,(short) 8000,1); //登陆
|
||||
System.out.println(devIp+":用户权柄=="+lUserID);
|
||||
// UserManage.addUserInfo(lUserID,"131551","贾胜凯");
|
||||
// int faceres=FaceManage.AddFaceByBinary(lUserID,"131551","C:\\Users\\Bonus\\Desktop\\jsk.jpg");
|
||||
// Login(devIp2,devUser2,devPass2,(short) 8000,2); //登陆
|
||||
// Alarm.SetAlarm(lUserID);
|
||||
// Alarm.SetAlarm(lUserID2);
|
||||
// UserManage.addUserInfo(lUserID,"15357932237","贾胜凯");
|
||||
// String urld="http://192.168.20.234:9090/lnyst/uploads/2025/09/28/e153b430-2d9c-4401-b59f-47bd41b7a94b.png";
|
||||
// File file = BnsUtils.getFile(urld,urld.substring(urld.indexOf("/")));
|
||||
// System.out.println(file.getAbsolutePath());
|
||||
// int faceres=FaceManage.AddFaceByBinaryFile(lUserID,"10003",new File("C:\\Users\\Bonus\\AppData\\Local\\Temp\\jsk.jpg"));
|
||||
Login(devIp2,devUser2,devPass2,(short) 8000,2); //登陆
|
||||
Alarm.SetAlarm(lUserID);
|
||||
Alarm.SetAlarm(lUserID2);
|
||||
// getAllUser();
|
||||
// UserManage.searchUserInfo(lUserID);
|
||||
// UserManage.addUserInfo(lUserID,"15357932237","贾胜凯22");
|
||||
// UserManage.deleteUserInfo(lUserID,"15357932237");
|
||||
// FaceManage.addFaceByBinary(lUserID,"15357932237","d://1.jpg");
|
||||
// FaceManage.addFaceByUrl(lUserID,"15357932237","http://open.hikvision.com/download/5cda567cf47ae80dd41a54b3.jpg");
|
||||
// FaceManage.addFaceByUrl(lUserID,"10003",urld);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class BnsUtils {
|
|||
InputStream inStream = null;
|
||||
OutputStream os = null;
|
||||
try {
|
||||
file = File.createTempFile("newImg",suffix);
|
||||
file = new File( System.getProperty("user.dir") +"\\newImg"+".jpg");
|
||||
//下载
|
||||
urlfile = new URL(url);
|
||||
inStream = urlfile.openStream();
|
||||
|
|
@ -74,6 +74,7 @@ public class BnsUtils {
|
|||
} finally {
|
||||
try {
|
||||
if (null != os) {
|
||||
os.flush();
|
||||
os.close();
|
||||
}
|
||||
if (null != inStream) {
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</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 kitchen_staff_info set face_flage=#{faceFlage} where staff_no=#{staffNo}
|
||||
</update>
|
||||
<delete id="deleteKitchenStaffInfoByStaffId" parameterType="Long">
|
||||
delete from kitchen_staff_info where staff_id = #{staffId}
|
||||
|
|
|
|||
Loading…
Reference in New Issue