jsk ---厨房出入接口及BUg修改

This commit is contained in:
skjia 2025-07-03 19:48:30 +08:00
parent a415d405fc
commit 14c4f53941
35 changed files with 12575 additions and 25 deletions

View File

@ -0,0 +1,7 @@
package com.bonus.canteen.core.cook.task;
public class EnterExitRecordTask {
public static void main(String[] args) {
}
}

View File

@ -56,11 +56,19 @@ public class HealthPersonInfoServiceImpl implements IHealthPersonInfoService {
if(CollUtil.isNotEmpty(list)) {
for(HealthPersonInfo vo : list) {
vo.setMobile(SM4EncryptUtils.sm4Decrypt(vo.getMobile()));
vo.setMobile(maskPhoneNumber(vo.getMobile()));
}
}
return list;
}
public static String maskPhoneNumber(String phoneNumber) {
if (phoneNumber == null || phoneNumber.length() < 8) {
// 如果电话号码不足8位直接返回原号码
return phoneNumber;
}
// 使用正则表达式替换第四位到倒数第四位的字符为星号
return phoneNumber.replaceAll("(?<=.{3}).(?=.*.{4}$)", "*");
}
/**
* 新增人员健康情况
*

View File

@ -36,7 +36,7 @@ public class KitchenStaffEnterExitRecord extends BaseEntity {
/** 进入门禁时间 */
@ApiModelProperty(value = "进入门禁时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "进入门禁时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date enterTime;
@ -88,6 +88,7 @@ public class KitchenStaffEnterExitRecord extends BaseEntity {
private String startDate;
private String endDate;
private String articleTitle;
private String employeeNo;
}

View File

@ -0,0 +1,50 @@
package com.bonus.canteen.core.kitchen.dto;
public class UserVo {
private String employeeNo;
private String name;
private String userType;
private String closeDelayEnabled;
public String getEmployeeNo() {
return employeeNo;
}
public void setEmployeeNo(String employeeNo) {
this.employeeNo = employeeNo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
public String getCloseDelayEnabled() {
return closeDelayEnabled;
}
public void setCloseDelayEnabled(String closeDelayEnabled) {
this.closeDelayEnabled = closeDelayEnabled;
}
@Override
public String toString() {
return "UserVo{" +
"employeeNo='" + employeeNo +
"', name='" + name +
"', userType='" + userType +
"', closeDelayEnabled='" + closeDelayEnabled +"'"+
"}" ;
}
}

View File

@ -5,14 +5,14 @@ import com.bonus.canteen.core.kitchen.domain.KitchenStaffEnterExitRecord;
/**
* 厨房员工进出门禁记录Mapper接口
*
*
* @author xsheng
* @date 2025-06-23
*/
public interface KitchenStaffEnterExitRecordMapper {
/**
* 查询厨房员工进出门禁记录
*
*
* @param checkId 厨房员工进出门禁记录主键
* @return 厨房员工进出门禁记录
*/
@ -20,7 +20,7 @@ public interface KitchenStaffEnterExitRecordMapper {
/**
* 查询厨房员工进出门禁记录列表
*
*
* @param kitchenStaffEnterExitRecord 厨房员工进出门禁记录
* @return 厨房员工进出门禁记录集合
*/
@ -28,7 +28,7 @@ public interface KitchenStaffEnterExitRecordMapper {
/**
* 新增厨房员工进出门禁记录
*
*
* @param kitchenStaffEnterExitRecord 厨房员工进出门禁记录
* @return 结果
*/
@ -36,7 +36,7 @@ public interface KitchenStaffEnterExitRecordMapper {
/**
* 修改厨房员工进出门禁记录
*
*
* @param kitchenStaffEnterExitRecord 厨房员工进出门禁记录
* @return 结果
*/
@ -44,7 +44,7 @@ public interface KitchenStaffEnterExitRecordMapper {
/**
* 删除厨房员工进出门禁记录
*
*
* @param checkId 厨房员工进出门禁记录主键
* @return 结果
*/
@ -52,9 +52,13 @@ public interface KitchenStaffEnterExitRecordMapper {
/**
* 批量删除厨房员工进出门禁记录
*
*
* @param checkIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteKitchenStaffEnterExitRecordByCheckIds(Long[] checkIds);
public KitchenStaffEnterExitRecord selectKitchenStaffEnterExitRecordByEmployeeNo(String employeeNo);
public KitchenStaffEnterExitRecord selectKitchenStaffByEmployeeNo(String employeeNo);
}

View File

@ -5,14 +5,14 @@ import com.bonus.canteen.core.kitchen.domain.KitchenStaffEnterExitRecord;
/**
* 厨房员工进出门禁记录Service接口
*
*
* @author xsheng
* @date 2025-06-23
*/
public interface IKitchenStaffEnterExitRecordService {
/**
* 查询厨房员工进出门禁记录
*
*
* @param checkId 厨房员工进出门禁记录主键
* @return 厨房员工进出门禁记录
*/
@ -20,7 +20,7 @@ public interface IKitchenStaffEnterExitRecordService {
/**
* 查询厨房员工进出门禁记录列表
*
*
* @param kitchenStaffEnterExitRecord 厨房员工进出门禁记录
* @return 厨房员工进出门禁记录集合
*/
@ -28,7 +28,7 @@ public interface IKitchenStaffEnterExitRecordService {
/**
* 新增厨房员工进出门禁记录
*
*
* @param kitchenStaffEnterExitRecord 厨房员工进出门禁记录
* @return 结果
*/
@ -36,7 +36,7 @@ public interface IKitchenStaffEnterExitRecordService {
/**
* 修改厨房员工进出门禁记录
*
*
* @param kitchenStaffEnterExitRecord 厨房员工进出门禁记录
* @return 结果
*/
@ -44,7 +44,7 @@ public interface IKitchenStaffEnterExitRecordService {
/**
* 批量删除厨房员工进出门禁记录
*
*
* @param checkIds 需要删除的厨房员工进出门禁记录主键集合
* @return 结果
*/
@ -52,9 +52,13 @@ public interface IKitchenStaffEnterExitRecordService {
/**
* 删除厨房员工进出门禁记录信息
*
*
* @param checkId 厨房员工进出门禁记录主键
* @return 结果
*/
public int deleteKitchenStaffEnterExitRecordByCheckId(Long checkId);
public KitchenStaffEnterExitRecord selectKitchenStaffEnterExitRecordByEmployeeNo(String employeeNo);
public KitchenStaffEnterExitRecord selectKitchenStaffByEmployeeNo(String employeeNo);
}

View File

@ -11,7 +11,7 @@ import com.bonus.canteen.core.kitchen.service.IKitchenStaffEnterExitRecordServic
/**
* 厨房员工进出门禁记录Service业务层处理
*
*
* @author xsheng
* @date 2025-06-23
*/
@ -22,7 +22,7 @@ public class KitchenStaffEnterExitRecordServiceImpl implements IKitchenStaffEnte
/**
* 查询厨房员工进出门禁记录
*
*
* @param checkId 厨房员工进出门禁记录主键
* @return 厨房员工进出门禁记录
*/
@ -33,7 +33,7 @@ public class KitchenStaffEnterExitRecordServiceImpl implements IKitchenStaffEnte
/**
* 查询厨房员工进出门禁记录列表
*
*
* @param kitchenStaffEnterExitRecord 厨房员工进出门禁记录
* @return 厨房员工进出门禁记录
*/
@ -44,7 +44,7 @@ public class KitchenStaffEnterExitRecordServiceImpl implements IKitchenStaffEnte
/**
* 新增厨房员工进出门禁记录
*
*
* @param kitchenStaffEnterExitRecord 厨房员工进出门禁记录
* @return 结果
*/
@ -60,7 +60,7 @@ public class KitchenStaffEnterExitRecordServiceImpl implements IKitchenStaffEnte
/**
* 修改厨房员工进出门禁记录
*
*
* @param kitchenStaffEnterExitRecord 厨房员工进出门禁记录
* @return 结果
*/
@ -76,7 +76,7 @@ public class KitchenStaffEnterExitRecordServiceImpl implements IKitchenStaffEnte
/**
* 批量删除厨房员工进出门禁记录
*
*
* @param checkIds 需要删除的厨房员工进出门禁记录主键
* @return 结果
*/
@ -87,7 +87,7 @@ public class KitchenStaffEnterExitRecordServiceImpl implements IKitchenStaffEnte
/**
* 删除厨房员工进出门禁记录信息
*
*
* @param checkId 厨房员工进出门禁记录主键
* @return 结果
*/
@ -95,4 +95,14 @@ public class KitchenStaffEnterExitRecordServiceImpl implements IKitchenStaffEnte
public int deleteKitchenStaffEnterExitRecordByCheckId(Long checkId) {
return kitchenStaffEnterExitRecordMapper.deleteKitchenStaffEnterExitRecordByCheckId(checkId);
}
@Override
public KitchenStaffEnterExitRecord selectKitchenStaffEnterExitRecordByEmployeeNo(String employeeNo) {
return kitchenStaffEnterExitRecordMapper.selectKitchenStaffEnterExitRecordByEmployeeNo(employeeNo);
}
@Override
public KitchenStaffEnterExitRecord selectKitchenStaffByEmployeeNo(String employeeNo) {
return kitchenStaffEnterExitRecordMapper.selectKitchenStaffByEmployeeNo(employeeNo);
}
}

View File

@ -0,0 +1,45 @@
package com.bonus.canteen.core.kitchen.utils;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class ImageUtils {
/**
* 通过BufferedImage图片流调整图片大小
*/
public static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) throws IOException {
Image resultingImage = originalImage.getScaledInstance(targetWidth, targetHeight, Image.SCALE_AREA_AVERAGING);
BufferedImage outputImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB);
outputImage.getGraphics().drawImage(resultingImage, 0, 0, null);
return outputImage;
}
/**
* BufferedImage图片流转byte[]数组
*/
public static byte[] imageToBytes(BufferedImage bImage) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
ImageIO.write(bImage, "jpg", out);
} catch (IOException e) {
e.printStackTrace();
}
return out.toByteArray();
}
/**
* byte[]数组转BufferedImage图片流
*/
public static BufferedImage bytesToBufferedImage(byte[] ImageByte) {
ByteArrayInputStream in = new ByteArrayInputStream(ImageByte);
BufferedImage image = null;
try {
image = ImageIO.read(in);
} catch (IOException e) {
e.printStackTrace();
}
return image;
}
}

View File

@ -0,0 +1,40 @@
package com.bonus.canteen.core.kitchen.utils;
import com.bonus.canteen.core.kitchen.utils.NetSDK.FMSGCallBack_V31;
import com.sun.jna.Pointer;
import org.springframework.scheduling.annotation.Scheduled;
public class InitDevTask {
/**
* 定时初始化厨房门禁设备权柄防止设备突发出现断联
*/
@Scheduled(fixedDelay = 30*60*1000)
public void InitDev(){
boolean dd=initServer.hCNetSDK.NET_DVR_RemoteControl(initServer.lUserID,20005,null,0);
if(dd){
System.out.println("=========识别设备在线!");
return;
}else{
System.out.println("==========识别设备不在线!重新注册");
}
if(initServer.hCNetSDK == null){
if(!initServer.CreateSDKInstance()){
System.out.println("Load SDK fail");
return;
}
}
initServer.hCNetSDK.NET_DVR_Init();
boolean i= initServer.hCNetSDK.NET_DVR_SetLogToFile(3, "..//sdklog", false);
//设置报警回调函
if (initServer.fMSFCallBack_V31 == null) {
initServer.fMSFCallBack_V31 = new FMSGCallBack_V31();
Pointer pUser = null;
if (!initServer.hCNetSDK.NET_DVR_SetDVRMessageCallBack_V31(initServer.fMSFCallBack_V31, pUser)) {
System.out.println("设置回调函数失败!");
} else {
System.out.println("设置回调函数成功!");
}
}
initServer.Login(initServer.devIp,initServer.devUser,initServer.devPass,(short) 8000); //登陆
}
}

View File

@ -0,0 +1,41 @@
package com.bonus.canteen.core.kitchen.utils.NetSDK;
import com.bonus.canteen.core.kitchen.utils.initServer;
/**
* 报警模块实现功能1设备报警事件实时上传报警事件包括刷脸刷卡等认证事件和设备的操作事件
* 2事件主动获取获取保存在设备上的事件
*/
public final class Alarm {
//报警布防 布防和监听选其一
public static void SetAlarm(int userID) {
if (initServer.lAlarmHandle < 0)//尚未布防,需要布防
{
//报警布防参数设置
HCNetSDK.NET_DVR_SETUPALARM_PARAM m_strAlarmInfo = new HCNetSDK.NET_DVR_SETUPALARM_PARAM();
m_strAlarmInfo.dwSize = m_strAlarmInfo.size();
m_strAlarmInfo.byLevel = 1; //布防等级
m_strAlarmInfo.byAlarmInfoType = 1; // 智能交通报警信息上传类型0- 老报警信息NET_DVR_PLATE_RESULT1- 新报警信息(NET_ITS_PLATE_RESULT)
m_strAlarmInfo.byDeployType = 0; //布防类型 0客户端布防 1实时布防
m_strAlarmInfo.write();
initServer.lAlarmHandle = initServer.hCNetSDK.NET_DVR_SetupAlarmChan_V41(userID, m_strAlarmInfo);
System.out.println("lAlarmHandle: " + initServer.lAlarmHandle);
if (initServer.lAlarmHandle == -1) {
System.out.println("布防失败,错误码为" + initServer.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("布防成功");
}
}
}
//报警监听布防和监听选其一
// public static void StartListen() {
//
// initServer.lListenHandle = initServer.hCNetSDK.NET_DVR_StartListen_V30("10.17.36.14", (short) 7201, fMSFCallBack_V31, null);
// if (initServer.lListenHandle == -1) {
// System.out.println("监听失败" + initServer.hCNetSDK.NET_DVR_GetLastError());
// } else {
// System.out.println("监听成功");
// }
// }
}

View File

@ -0,0 +1,226 @@
package com.bonus.canteen.core.kitchen.utils.NetSDK;
import cn.hutool.extra.spring.SpringUtil;
import com.bonus.canteen.core.kitchen.domain.KitchenStaffEnterExitRecord;
import com.bonus.canteen.core.kitchen.service.IKitchenStaffEnterExitRecordService;
import com.bonus.canteen.core.kitchen.utils.ImageUtils;
import com.sun.jna.Pointer;
import org.springframework.beans.factory.annotation.Autowired;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.Date;
//布防回调函数
public class FMSGCallBack_V31 implements HCNetSDK.FMSGCallBack_V31 {
//报警信息回调函数
@Override
public boolean invoke(int lCommand, HCNetSDK.NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser) {
AlarmDataHandle(lCommand, pAlarmer, pAlarmInfo, dwBufLen, pUser);
return true;
}
public void AlarmDataHandle(int lCommand, HCNetSDK.NET_DVR_ALARMER pAlarmer, Pointer pAlarmInfo, int dwBufLen, Pointer pUser) {
// System.out.println("报警类型 lCommand:" + Integer.toHexString(lCommand));
switch (lCommand) {
case HCNetSDK.COMM_ALARM_ACS: //门禁主机报警信息
HCNetSDK.NET_DVR_ACS_ALARM_INFO strACSInfo = new HCNetSDK.NET_DVR_ACS_ALARM_INFO();
strACSInfo.write();
Pointer pACSInfo = strACSInfo.getPointer();
pACSInfo.write(0, pAlarmInfo.getByteArray(0, strACSInfo.size()), 0, strACSInfo.size());
strACSInfo.read();
/**门禁事件的详细信息解析通过主次类型的可以判断当前的具体门禁类型例如主类型0X5 次类型0x4b 表示人脸认证通过
主类型0X5 次类型0x4c 表示人脸认证失败*/
// System.out.println("【门禁主机报警信息】卡号:" + new String(strACSInfo.struAcsEventInfo.byCardNo).trim() + ",卡类型:" + strACSInfo.struAcsEventInfo.byCardType + ",报警主类型:" + Integer.toHexString(strACSInfo.dwMajor) + ",报警次类型:" + Integer.toHexString(strACSInfo.dwMinor));
// System.out.println("工号1"+strACSInfo.struAcsEventInfo.dwEmployeeNo);
//温度信息如果设备支持测温功能人脸温度信息从NET_DVR_ACS_EVENT_INFO_EXTEND_V20结构体获取
/*
if (strACSInfo.byAcsEventInfoExtendV20 == 1) {
HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND_V20 strAcsInfoExV20 = new HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND_V20();
strAcsInfoExV20.write();
Pointer pAcsInfoExV20 = strAcsInfoExV20.getPointer();
pAcsInfoExV20.write(0, strACSInfo.pAcsEventInfoExtendV20.getByteArray(0, strAcsInfoExV20.size()), 0, strAcsInfoExV20.size());
strAcsInfoExV20.read();
System.out.println("实时温度值:" + strAcsInfoExV20.fCurrTemperature);
}*/
//考勤状态
if (strACSInfo.byAcsEventInfoExtend == 1) {
HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND strAcsInfoEx = new HCNetSDK.NET_DVR_ACS_EVENT_INFO_EXTEND();
strAcsInfoEx.write();
Pointer pAcsInfoEx = strAcsInfoEx.getPointer();
pAcsInfoEx.write(0, strACSInfo.pAcsEventInfoExtend.getByteArray(0, strAcsInfoEx.size()), 0, strAcsInfoEx.size());
strAcsInfoEx.read();
try{
if(!"".equals(new String(strAcsInfoEx.byEmployeeNo).trim())) {
/** * 报警时间*/
String yearo=Integer.toString(strACSInfo.struTime.dwYear);
String montho=strACSInfo.struTime.dwMonth>=10?strACSInfo.struTime.dwMonth+"":("0"+strACSInfo.struTime.dwMonth)+"";
String dayo=strACSInfo.struTime.dwDay>=10?strACSInfo.struTime.dwDay+"":("0"+strACSInfo.struTime.dwDay)+"";
String houro=strACSInfo.struTime.dwHour>=10?strACSInfo.struTime.dwHour+"":("0"+strACSInfo.struTime.dwHour)+"";
String mino=strACSInfo.struTime.dwMinute>=10?strACSInfo.struTime.dwMinute+"":("0"+strACSInfo.struTime.dwMinute)+"";
String seco=strACSInfo.struTime.dwSecond>=10?strACSInfo.struTime.dwSecond+"":("0"+strACSInfo.struTime.dwSecond)+"";
String SwipeTime=yearo+"-"+montho+"-"+dayo+" "+houro+":"+mino+":"+seco;
System.out.println(SwipeTime+"====={正在获取工号:"+new String(strAcsInfoEx.byEmployeeNo).trim()+"}"+"{正在获取读卡器当前验证方式:"+strAcsInfoEx.byCurrentVerifyMode+"}"+"{正在获取是否为实时事件:"+strAcsInfoEx.byCurrentEvent+"}");
if (strACSInfo.dwPicDataLen > 0) {
IKitchenStaffEnterExitRecordService kitchenStaffEnterExitRecordService = SpringUtil.getBean(IKitchenStaffEnterExitRecordService.class);
String employeeNo=new String(strAcsInfoEx.byEmployeeNo).trim();
KitchenStaffEnterExitRecord user=kitchenStaffEnterExitRecordService.selectKitchenStaffByEmployeeNo(employeeNo);
if(user==null){
return;
}
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
KitchenStaffEnterExitRecord userRecord=kitchenStaffEnterExitRecordService.selectKitchenStaffByEmployeeNo(employeeNo);
Date swipedata=null;
try{
swipedata=sdf.parse(SwipeTime);
if(userRecord.getEnterTime()!=null){
Long recordnum=0L;
Long restnum=0L;
recordnum=userRecord.getEnterTime().getTime();
restnum=swipedata.getTime();
if(restnum-recordnum<30000L){
return;
}
}
}catch (Exception e){
}
KitchenStaffEnterExitRecord vo=new KitchenStaffEnterExitRecord();
vo.setStaffId(user.getStaffId());
vo.setEnterTime(swipedata);
vo.setCreateTime(new Date());
try{
kitchenStaffEnterExitRecordService.insertKitchenStaffEnterExitRecord(vo);
}catch (Exception e){
e.printStackTrace();
}
// FileOutputStream fout;
// try {
// /*** 人脸保存路径*/
// String filename = "C:/video/" +SwipeTime+"_"+ new String(strAcsInfoEx.byEmployeeNo).trim() + ".jpg";
// fout = new FileOutputStream(filename);
// //将字节写入文件
// long offset = 0;
// ByteBuffer buffers = strACSInfo.pPicData.getByteBuffer(offset, strACSInfo.dwPicDataLen);
// byte[] bytes = new byte[strACSInfo.dwPicDataLen];
// buffers.rewind();
// buffers.get(bytes);
// BufferedImage bimg= ImageUtils.bytesToBufferedImage(bytes);
// BufferedImage rbimg= ImageUtils.resizeImage(bimg,500,250);
// bytes=ImageUtils.imageToBytes(rbimg);
// fout.write(bytes);
// fout.close();
// } catch (FileNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
// deviceService server = SpringUtil.getBean(deviceService.class);
// System.out.println(adb.toString());
}
}catch (Exception e){
e.printStackTrace();
}
}
break;
case HCNetSDK.COMM_ID_INFO_ALARM: //身份证信息
HCNetSDK.NET_DVR_ID_CARD_INFO_ALARM strIDCardInfo = new HCNetSDK.NET_DVR_ID_CARD_INFO_ALARM();
strIDCardInfo.write();
Pointer pIDCardInfo = strIDCardInfo.getPointer();
pIDCardInfo.write(0, pAlarmInfo.getByteArray(0, strIDCardInfo.size()), 0, strIDCardInfo.size());
strIDCardInfo.read();
System.out.println("报警主类型:" + Integer.toHexString(strIDCardInfo.dwMajor) + ",报警次类型:" + Integer.toHexString(strIDCardInfo.dwMinor));
/**
* 身份证信息
*/
String IDnum=new String(strIDCardInfo.struIDCardCfg.byIDNum).trim();
System.out.println("【身份证信息】:身份证号码:" + IDnum+ ",姓名:" +
new String(strIDCardInfo.struIDCardCfg.byName).trim() + ",住址:"+new String(strIDCardInfo.struIDCardCfg.byAddr));
/**
* 报警时间
*/
String year1=Integer.toString(strIDCardInfo.struSwipeTime.wYear);
String SwipeTime1=year1+strIDCardInfo.struSwipeTime.byMonth+strIDCardInfo.struSwipeTime.byDay+strIDCardInfo.struSwipeTime.byHour+strIDCardInfo.struSwipeTime.byMinute+
strIDCardInfo.struSwipeTime.bySecond;
/**
* 保存图片
*/
//身份证图片
if (strIDCardInfo.dwPicDataLen>0||strIDCardInfo.pPicData!=null)
{
// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
// String nowtime = sf.format(new Date());
FileOutputStream fout;
try {
String filename = "../pic/" + SwipeTime1 + "_"+IDnum + ".jpg";
fout = new FileOutputStream(filename);
//将字节写入文件
long offset = 0;
ByteBuffer buffers = strIDCardInfo.pPicData.getByteBuffer(offset, strIDCardInfo.dwPicDataLen);
byte[] bytes = new byte[strIDCardInfo.dwPicDataLen];
buffers.rewind();
buffers.get(bytes);
fout.write(bytes);
fout.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (strIDCardInfo.dwCapturePicDataLen>0||strIDCardInfo.pCapturePicData!=null)
{
// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
// String nowtime = sf.format(new Date());
FileOutputStream fout;
try {
/**
* 人脸图片保存路径
*/
String filename = "../pic/" + SwipeTime1 + "_CapturePic_" +".jpg";
fout = new FileOutputStream(filename);
//将字节写入文件
long offset = 0;
ByteBuffer buffers = strIDCardInfo.pCapturePicData.getByteBuffer(offset, strIDCardInfo.dwCapturePicDataLen);
byte[] bytes = new byte[strIDCardInfo.dwCapturePicDataLen];
buffers.rewind();
buffers.get(bytes);
fout.write(bytes);
fout.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
break;
//门禁仅测温事件解析
case HCNetSDK.COMM_VCA_ALARM:
ByteBuffer dataBuffer = pAlarmInfo.getByteBuffer(0, dwBufLen);
byte[] dataByte = new byte[dwBufLen];
dataBuffer.rewind();
dataBuffer.get(dataByte);
//报警事件json报文
System.out.println("仅测温报警事件:"+new String(dataByte));
break;
default:
System.out.println("报警类型" + Integer.toHexString(lCommand));
break;
}
}
}

View File

@ -0,0 +1,409 @@
package com.bonus.canteen.core.kitchen.utils.NetSDK;
import com.bonus.canteen.core.kitchen.utils.NetSDKCommom.ConfigFileUtil;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.bonus.canteen.core.kitchen.utils.initServer;
import java.io.*;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 功能模块人员管理下发查询删除人脸图片下发人脸图片前先下发人员工号
*/
public final class FaceManage {
/**
* 功能按照二进制方式下发人脸图片
* @param userID 用户注册ID
* @param employeeNo 人员工号
* @throws JSONException
* @throws InterruptedException
*/
public static void addFaceByBinary(int userID,String employeeNo,String filePath ) throws JSONException, InterruptedException{
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;
}else{
System.out.println("Addface NET_DVR_StartRemoteConfig 成功!");
HCNetSDK.NET_DVR_JSON_DATA_CFG struAddFaceDataCfg = new HCNetSDK.NET_DVR_JSON_DATA_CFG();
struAddFaceDataCfg.read();
//输入参数XML或者JSON数据,添加人脸图片json报文
Map<String, Object> parameter = new HashMap<>();
parameter.put("employeeNo", employeeNo); // 员工ID号
String strJsonData = ConfigFileUtil.getReqBodyFromTemplate("/bonus-modules/bonus-smart-canteen/src/main/resources/conf/acs/AddFaceInfoParam.json", parameter);
System.out.println("下个人员参数:"+strJsonData);
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(new File(filePath));
}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;
}
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);
if(dwState == -1){
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败错误码" + initServer.hCNetSDK.NET_DVR_GetLastError());
break;
}
//读取返回的json并解析
ptrOutuff.read();
String strResult = new String(ptrOutuff.byValue).trim();
System.out.println("dwState:" + dwState + ",strResult:" + strResult);
JSONObject jsonResult = new JSONObject(strResult);
int statusCode = jsonResult.getInt("statusCode");
String statusString = jsonResult.getString("statusString");
if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT){
System.out.println("配置等待");
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());
}
break;
}else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
//下发人脸时dwState其实不会走到这里因为设备不知道我们会下发多少个人所以长连接需要我们主动关闭
System.out.println("下发人脸完成");
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接口成功");
}
}
}
/**
* 按URL方式下发人脸图片
* @param userID 用户注销ID
* @param employeeNo 人员工号
* @throws JSONException
*/
public static void addFaceByUrl(int userID,String employeeNo,String fileUrl) throws JSONException {
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;
}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("faceURL",fileUrl); //人脸图片URL,平台自己实现需要保证设备可以正常访问
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();
struAddFaceDataCfg.lpPicData = null;
struAddFaceDataCfg.dwPicDataSize=0;
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);
if(dwState == -1){
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败错误码" + initServer.hCNetSDK.NET_DVR_GetLastError());
break;
}
//读取返回的json并解析
ptrOutuff.read();
String strResult = new String(ptrOutuff.byValue).trim();
System.out.println("dwState:" + dwState + ",strResult:" + strResult);
JSONObject jsonResult = new JSONObject(strResult);
int statusCode = jsonResult.getInt("statusCode");
String statusString = jsonResult.getString("statusString");
if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT){
System.out.println("配置等待");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
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());
}
break;
}else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
//下发人脸时dwState其实不会走到这里因为设备不知道我们会下发多少个人所以长连接需要我们主动关闭
System.out.println("下发人脸完成");
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接口成功");
}
}
}
/**
* 查询人脸
* @param userID
* @param employeeNo
* @throws JSONException
*/
public static void searchFaceInfo(int userID,String employeeNo) throws JSONException{
HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组
String strInBuffer = "POST /ISAPI/Intelligent/FDLib/FDSearch?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_SEARCH, ptrByteArray.getPointer(), strInBuffer.length(), null, null);
if (lHandler < 0){
System.out.println("SearchFaceInfo NET_DVR_StartRemoteConfig 失败,错误码为"+initServer.hCNetSDK.NET_DVR_GetLastError());
return;
}else{
System.out.println("SearchFaceInfo NET_DVR_StartRemoteConfig成功!");
//输入参数XML或者JSON数据,查询人脸图片json报文
Map<String, Object> parameter = new HashMap<>();
parameter.put("employeeNo", employeeNo); // 员工ID号
String strInbuff = ConfigFileUtil.getReqBodyFromTemplate("/bonus-modules/bonus-smart-canteen/src/main/resources/conf/acs/SearchFaceInfoParam.json", parameter);
//批量查询人脸图片json报文
/* String input = "{\n" +
" \"searchResultPosition\":0,\n" +
" \"maxResults\":30,\n" +
" \"faceLibType\":\"blackFD\",\n" +
" \"FDID\":\"1\"\n" +
"}";*/
System.out.println("查询人脸参数报文:"+strInbuff);
//把string传递到Byte数组中后续用.getPointer()方法传入指针地址中
HCNetSDK.BYTE_ARRAY ptrInbuff = new HCNetSDK.BYTE_ARRAY(strInbuff.length());
System.arraycopy(strInbuff.getBytes(), 0, ptrInbuff.byValue, 0, strInbuff.length());
ptrInbuff.write();
HCNetSDK.NET_DVR_JSON_DATA_CFG m_struJsonData = new HCNetSDK.NET_DVR_JSON_DATA_CFG();
m_struJsonData.write();
IntByReference pInt = new IntByReference(0);
while(true){
int dwState =initServer.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, ptrInbuff.getPointer(), strInbuff.length(), m_struJsonData.getPointer(), m_struJsonData.size(), pInt);
m_struJsonData.read();
System.out.println(dwState);
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){
System.out.println("配置等待");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
continue;
}else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED){
System.out.println("查询人脸失败");
break;
}else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION){
System.out.println("查询人脸异常");
break;
}else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS){
System.out.println("查询人脸成功");
//解析JSON字符串
HCNetSDK.BYTE_ARRAY pJsonData = new HCNetSDK.BYTE_ARRAY(m_struJsonData.dwJsonDataSize);
pJsonData.write();
Pointer pPlateInfo = pJsonData.getPointer();
pPlateInfo.write(0, m_struJsonData.lpJsonData.getByteArray(0, pJsonData.size()), 0, pJsonData.size());
pJsonData.read();
String strResult = new String(pJsonData.byValue).trim();
System.out.println("strResult:" + strResult);
JSONObject jsonResult = new JSONObject(strResult);
int numOfMatches = jsonResult.getInt("numOfMatches");
if(numOfMatches != 0){//确认有人脸
JSONArray MatchList = jsonResult.getJSONArray("MatchList");
JSONObject MatchList_1 = MatchList.optJSONObject(0);
String FPID = MatchList_1.getString("FPID"); //获取json中人脸关联的工号
FileOutputStream fout;
try {
fout = new FileOutputStream(".//pic//["+ FPID +"]_FacePic.jpg");
//将字节写入文件
long offset = 0;
ByteBuffer buffers = m_struJsonData.lpPicData.getByteBuffer(offset, m_struJsonData.dwPicDataSize);
byte [] bytes = new byte[m_struJsonData.dwPicDataSize];
buffers.rewind();
buffers.get(bytes);
fout.write(bytes);
fout.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
break;
}else if(dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
System.out.println("获取人脸完成");
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接口成功");
lHandler = -1;
}
}
}
/**
* 人脸删除支持批量删除json中添加多个工号
* @param userID
* @param employeeNo
*/
public static void deleteFaceInfo(int userID,String employeeNo){
String deleteFaceUrl="PUT /ISAPI/Intelligent/FDLib/FDSearch/Delete?format=json&FDID=1&faceLibType=blackFD";
//输入参数XML或者JSON数据,删除人脸图片json报文
Map<String, Object> parameter = new HashMap<>();
parameter.put("employeeNo", employeeNo); // 员工ID号
String deleteFaceJson = ConfigFileUtil.getReqBodyFromTemplate("/bonus-modules/bonus-smart-canteen/src/main/resources/conf/acs/DeleteFaceInfoParam.json", parameter);
System.out.println("删除人脸图片参数:"+deleteFaceJson);
String result= TransIsapi.put_isapi(userID,deleteFaceUrl,deleteFaceJson);
System.out.println("删除人员结果:"+result);
}
/**
* 人脸采集下发人脸采集命令从设备中采集人脸图片保存到本地
* @param userID 用户注册ID
*/
public static void captureFaceInfo(int userID){
HCNetSDK.NET_DVR_CAPTURE_FACE_COND struCapCond = new HCNetSDK.NET_DVR_CAPTURE_FACE_COND();
struCapCond.read();
struCapCond.dwSize = struCapCond.size();
struCapCond.write();
int lCaptureFaceHandle = initServer.hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_CAPTURE_FACE_INFO, struCapCond.getPointer(), struCapCond.size(), null, null);
if (lCaptureFaceHandle == -1){
System.out.println("建立采集人脸长连接失败,错误码为" + initServer.hCNetSDK.NET_DVR_GetLastError());
return;
}else{
System.out.println("建立采集人脸长连接成功!");
}
//采集的人脸信息
HCNetSDK.NET_DVR_CAPTURE_FACE_CFG struFaceInfo = new HCNetSDK.NET_DVR_CAPTURE_FACE_CFG();
struFaceInfo.read();
while (true) {
int dwState = initServer.hCNetSDK.NET_DVR_GetNextRemoteConfig(lCaptureFaceHandle, struFaceInfo.getPointer(), struFaceInfo.size());
struFaceInfo.read();
if (dwState == -1) {
System.out.println("NET_DVR_GetNextRemoteConfig采集人脸失败错误码" + initServer.hCNetSDK.NET_DVR_GetLastError());
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) {
System.out.println("正在采集中,请等待...");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("采集人脸失败");
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
//超时时间5秒内设备本地人脸采集失败就会返回失败,连接会断开
System.out.println("采集人脸异常, 网络异常导致连接断开 ");
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
if ((struFaceInfo.dwFacePicSize > 0) && (struFaceInfo.pFacePicBuffer != null)) {
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
String newName = sf.format(new Date());
FileOutputStream fout;
try {
String filename = "..\\pic\\" + newName + "_capFaceInfo.jpg";
fout = new FileOutputStream(filename);
//将字节写入文件
long offset = 0;
ByteBuffer buffers = struFaceInfo.pFacePicBuffer.getByteBuffer(offset, struFaceInfo.dwFacePicSize);
byte[] bytes = new byte[struFaceInfo.dwFacePicSize];
buffers.rewind();
buffers.get(bytes);
fout.write(bytes);
fout.close();
System.out.println("采集人脸成功, 图片保存路径: " + filename);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
break;
} else {
System.out.println("其他异常, dwState: " + dwState);
break;
}
}
//采集成功之后断开连接释放资源
if (!initServer.hCNetSDK.NET_DVR_StopRemoteConfig(lCaptureFaceHandle)) {
System.out.println("NET_DVR_StopRemoteConfig接口调用失败错误码" + initServer.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_StopRemoteConfig接口成功");
}
}
}

View File

@ -0,0 +1,106 @@
package com.bonus.canteen.core.kitchen.utils.NetSDK;
import com.bonus.canteen.core.kitchen.utils.initServer;
import java.io.UnsupportedEncodingException;
/**
* @create 2021-04-13-15:23
* 功能透传接口实现透传ISAPI命令
*/
public final class TransIsapi {
public static String get_isapi(int lUserID, String url) {
HCNetSDK.NET_DVR_XML_CONFIG_INPUT struXMLInput = new HCNetSDK.NET_DVR_XML_CONFIG_INPUT();
struXMLInput.read();
HCNetSDK.BYTE_ARRAY stringRequest = new HCNetSDK.BYTE_ARRAY(1024);
stringRequest.read();
//输入ISAPI协议命令
System.arraycopy(url.getBytes(), 0, stringRequest.byValue, 0, url.length());
stringRequest.write();
struXMLInput.dwSize = struXMLInput.size();
struXMLInput.lpRequestUrl = stringRequest.getPointer();
struXMLInput.dwRequestUrlLen = url.length();
struXMLInput.lpInBuffer = null;
struXMLInput.dwInBufferSize = 0;
struXMLInput.write();
HCNetSDK.BYTE_ARRAY stringXMLOut = new HCNetSDK.BYTE_ARRAY(8 * 1024);
stringXMLOut.read();
HCNetSDK.BYTE_ARRAY struXMLStatus = new HCNetSDK.BYTE_ARRAY(1024);
struXMLStatus.read();
HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT struXMLOutput = new HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT();
struXMLOutput.read();
struXMLOutput.dwSize = struXMLOutput.size();
struXMLOutput.lpOutBuffer = stringXMLOut.getPointer();
struXMLOutput.dwOutBufferSize = stringXMLOut.size();
struXMLOutput.lpStatusBuffer = struXMLStatus.getPointer();
struXMLOutput.dwStatusSize = struXMLStatus.size();
struXMLOutput.write();
if (!initServer.hCNetSDK.NET_DVR_STDXMLConfig(lUserID, struXMLInput, struXMLOutput)) {
int iErr = initServer.hCNetSDK.NET_DVR_GetLastError();
System.err.println("NET_DVR_STDXMLConfig失败错误号" + iErr+"----URL:"+url);
return null;
} else {
stringXMLOut.read();
System.out.println("输出文本大小:" + struXMLOutput.dwReturnedXMLSize);
//打印输出XML文本
String strOutXML = new String(stringXMLOut.byValue).trim();
System.out.println(strOutXML);
struXMLStatus.read();
String strStatus = new String(struXMLStatus.byValue).trim();
System.out.println(strStatus);
return strOutXML;
}
}
public static String put_isapi(int lUserID, String url, String inputXml) {
HCNetSDK.NET_DVR_XML_CONFIG_INPUT struXMLInput = new HCNetSDK.NET_DVR_XML_CONFIG_INPUT();
struXMLInput.read();
HCNetSDK.BYTE_ARRAY stringRequest = new HCNetSDK.BYTE_ARRAY(1024);
stringRequest.read();
//输入ISAPI协议命令
System.arraycopy(url.getBytes(), 0, stringRequest.byValue, 0, url.length());
stringRequest.write();
struXMLInput.dwSize = struXMLInput.size();
struXMLInput.lpRequestUrl = stringRequest.getPointer();
struXMLInput.dwRequestUrlLen = url.length();
HCNetSDK.BYTE_ARRAY ptrInBuffer = new HCNetSDK.BYTE_ARRAY(inputXml.length());
ptrInBuffer.read();
try {
System.arraycopy(inputXml.getBytes("utf-8"), 0, ptrInBuffer.byValue, 0, inputXml.length());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
ptrInBuffer.write();
struXMLInput.lpInBuffer = ptrInBuffer.getPointer();
struXMLInput.dwInBufferSize = inputXml.length();
struXMLInput.write();
//输出缓冲区大小可以依据事件输出报文大小进行调整
HCNetSDK.BYTE_ARRAY stringXMLOut = new HCNetSDK.BYTE_ARRAY(2*1024*1024);
stringXMLOut.read();
HCNetSDK.BYTE_ARRAY struXMLStatus = new HCNetSDK.BYTE_ARRAY(1024);
struXMLStatus.read();
HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT struXMLOutput = new HCNetSDK.NET_DVR_XML_CONFIG_OUTPUT();
struXMLOutput.read();
struXMLOutput.dwSize = struXMLOutput.size();
struXMLOutput.lpOutBuffer = stringXMLOut.getPointer();
struXMLOutput.dwOutBufferSize = stringXMLOut.size();
struXMLOutput.lpStatusBuffer = struXMLStatus.getPointer();
struXMLOutput.dwStatusSize = struXMLStatus.size();
struXMLOutput.write();
if (!initServer.hCNetSDK.NET_DVR_STDXMLConfig(lUserID, struXMLInput, struXMLOutput)){
int iErr = initServer.hCNetSDK.NET_DVR_GetLastError();
System.err.println("NET_DVR_STDXMLConfig失败错误号" + iErr+"----URL:"+url);
return null;
} else {
stringXMLOut.read();
System.out.println("输出文本大小:" + struXMLOutput.dwReturnedXMLSize);
//打印输出XML文本
String strOutXML = new String(stringXMLOut.byValue).trim();
struXMLStatus.read();
String strStatus = new String(struXMLStatus.byValue).trim();
return strOutXML;
}
}
}

View File

@ -0,0 +1,447 @@
package com.bonus.canteen.core.kitchen.utils.NetSDK;
import com.alibaba.fastjson.JSON;
import com.bonus.canteen.core.kitchen.dto.UserVo;
import com.bonus.canteen.core.kitchen.utils.NetSDKCommom.ConfigFileUtil;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import org.json.JSONException;
import org.json.JSONObject;
import com.bonus.canteen.core.kitchen.utils.initServer;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* 功能人脸下发查询删除人员计划模板配置
*/
public class UserManage {
/**
* 添加人员
* @param lUserID 登录句柄
* @param employeeNo 工号
* @throws UnsupportedEncodingException
* @throws InterruptedException
* @throws JSONException
*/
public static void addUserInfo(int lUserID, String employeeNo,String userName) throws UnsupportedEncodingException, InterruptedException, JSONException {
HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组
String strInBuffer = "POST /ISAPI/AccessControl/UserInfo/Record?format=json"; //此URL也是下发人员
// String strInBuffer = "PUT /ISAPI/AccessControl/UserInfo/SetUp?format=json";
System.arraycopy(strInBuffer.getBytes(), 0, ptrByteArray.byValue, 0, strInBuffer.length());//字符串拷贝到数组中
ptrByteArray.write();
int lHandler = initServer.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_JSON_CONFIG, ptrByteArray.getPointer(), strInBuffer.length(), null, null);
if (lHandler < 0) {
System.out.println("AddUserInfo NET_DVR_StartRemoteConfig 失败,错误码为" + initServer.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("AddUserInfo NET_DVR_StartRemoteConfig 成功!");
//输入参数XML或者JSON数据,下发人员信息json报文,其他参数设置参考conf/acs/AddUserInfoParam.json中报文参数
Map<String, Object> parameter = new HashMap<>();
parameter.put("employeeNo", employeeNo); // 员工ID
parameter.put("name", userName); // 员工名称
parameter.put("enable", true); // 是否启用
parameter.put("doorNo", 1); // 门编号
String input = ConfigFileUtil.getReqBodyFromTemplate("/bonus-modules/bonus-smart-canteen/src/main/resources/conf/acs/AddUserInfoParam.json", parameter);
System.out.println("下发人员参数:"+input);
byte[] byInbuffer = input.getBytes("utf-8");
int iInBufLen = byInbuffer.length;
HCNetSDK.BYTE_ARRAY ptrInBuffer = new HCNetSDK.BYTE_ARRAY(iInBufLen);
ptrInBuffer.read();
System.arraycopy(byInbuffer,0,ptrInBuffer.byValue,0, iInBufLen);
ptrInBuffer.write();
/* byte[] Name = "测试1".getBytes("utf-8"); //根据iCharEncodeType判断如果iCharEncodeType返回6则是UTF-8编码
//如果是0或者1或者2则是GBK编码
//将中文字符编码之后用数组拷贝的方式避免因为编码导致的长度问题
String strInBuffer1 = "{\n" +
" \"UserInfo\":{\n" +
" \"employeeNo\":\""+employeeNo+"\",\n" +
" \"name\":\"";
String strInBuffer2 = "\",\n" +
" \"userType\":\"normal\",\n" +
" \"Valid\":{\n" +
" \"enable\":true,\n" +
" \"beginTime\":\"2019-08-01T17:30:08\",\n" +
" \"endTime\":\"2030-08-01T17:30:08\",\n" +
" \"timeType\":\"local\"\n" +
" },\n" +
" \"belongGroup\":\"1\",\n" +
" \"doorRight\":\"1\",\n" +
" \"RightPlan\":[\n" +
" {\n" +
" \"doorNo\":1,\n" +
" \"planTemplateNo\":\"1\"\n" +
" }\n" +
" ]\n" +
" }\n" +
"}";
int iStringSize = Name.length + strInBuffer1.length() + strInBuffer2.length();
HCNetSDK.BYTE_ARRAY ptrByte = new HCNetSDK.BYTE_ARRAY(iStringSize);
System.arraycopy(strInBuffer1.getBytes(), 0, ptrByte.byValue, 0, strInBuffer1.length());
System.arraycopy(Name, 0, ptrByte.byValue, strInBuffer1.length(), Name.length);
System.arraycopy(strInBuffer2.getBytes(), 0, ptrByte.byValue, strInBuffer1.length() + Name.length, strInBuffer2.length());
ptrByte.write();
System.out.println(new String(ptrByte.byValue));*/
HCNetSDK.BYTE_ARRAY ptrOutuff = new HCNetSDK.BYTE_ARRAY(1024);
// Pointer ptr =new PointerByReference()
IntByReference pInt = new IntByReference(0);
while (true) {
int dwState = initServer.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, ptrInBuffer.getPointer(), iInBufLen, ptrOutuff.getPointer(), 1024, pInt);
if (dwState == -1) {
System.out.println("NET_DVR_SendWithRecvRemoteConfig接口调用失败错误码" + initServer.hCNetSDK.NET_DVR_GetLastError());
break;
}
//读取返回的json并解析
ptrOutuff.read();
String strResult = new String(ptrOutuff.byValue).trim();
System.out.println("dwState:" + dwState + ",strResult:" + strResult);
JSONObject jsonResult = new JSONObject(strResult);
int statusCode = jsonResult.getInt("statusCode");
String statusString = jsonResult.getString("statusString");
if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_NEED_WAIT) {
System.out.println("配置等待");
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());
}
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
//下发人员时dwState其实不会走到这里因为设备不知道我们会下发多少个人所以长连接需要我们主动关闭
System.out.println("下发人员完成");
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接口成功");
}
}
}
/**
* 查询人员信息
* @param userID
* @throws JSONException
*/
public static void searchUserInfo(int userID) throws JSONException {
HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组
String strInBuffer = "POST /ISAPI/AccessControl/UserInfo/Search?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_JSON_CONFIG, ptrByteArray.getPointer(), strInBuffer.length(), null, null);
if (lHandler < 0) {
System.out.println("SearchUserInfo NET_DVR_StartRemoteConfig 失败,错误码为" + initServer.hCNetSDK.NET_DVR_GetLastError());
return;
} else {
//输入参数XML或者JSON数据,查询多条人员信息json报文
Map<String, Object> parameter = new HashMap<>();
parameter.put("searchID", UUID.randomUUID()); // 查询idinsertCheckImg
parameter.put("searchResultPosition", 1);
parameter.put("maxResults", 10); // 最大查询数量
String strInbuff = ConfigFileUtil.getReqBodyFromTemplate("/bonus-modules/bonus-smart-canteen/src/main/resources/conf/acs/SearchUserInfoParam.json", parameter);
System.out.println("查询的json报文:" + strInbuff);
//把string传递到Byte数组中后续用.getPointer()方法传入指针地址中
HCNetSDK.BYTE_ARRAY ptrInbuff = new HCNetSDK.BYTE_ARRAY(strInbuff.length());
System.arraycopy(strInbuff.getBytes(), 0, ptrInbuff.byValue, 0, strInbuff.length());
ptrInbuff.write();
//定义接收结果的结构体
HCNetSDK.BYTE_ARRAY ptrOutuff = new HCNetSDK.BYTE_ARRAY(1000 * 1024);
IntByReference pInt = new IntByReference(0);
while (true) {
/*
dwOutBuffSize是输出缓冲区大小需要自定义指定大小如果接口报错错误码43.说明接收设备数据的缓冲区或存放图片缓冲区不足应扩大缓冲区大小
*/
int dwState = initServer.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, ptrInbuff.getPointer(), strInbuff.length(), ptrOutuff.getPointer(), 1000 * 1024, pInt);
System.out.println(dwState);
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) {
System.out.println("配置等待");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("查询人员失败");
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
System.out.println("查询人员异常");
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
ptrOutuff.read();
// System.out.println("查询人员成功, json:" + new String(ptrOutuff.byValue).trim());
String jsonstr=new String(ptrOutuff.byValue).trim();
JSONObject jsonObject=new JSONObject(jsonstr);
String searchstr=jsonObject.getString("UserInfoSearch");
System.out.println("searchstr, json:" + searchstr);
JSONObject searchObject=new JSONObject(searchstr);
String searchstrs=searchObject.getString("UserInfo");
String allcount=searchObject.getString("totalMatches");
int allcountd=Integer.parseInt(allcount);
int num=(int)Math.floor(allcountd/10);
List<UserVo> users= JSON.parseArray(searchstrs,UserVo.class);
for(int k=1;k<=num;k++){
}
for(UserVo vo:users){
System.out.println(vo.toString());
}
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
System.out.println("获取人员完成");
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接口成功");
lHandler = -1;
}
}
}
public static void deleteUserInfo(int userID,String employeeNo) throws JSONException {
//删除单个人员
//输入参数XML或者JSON数据,删除人员信息json报文
Map<String, Object> parameter = new HashMap<>();
parameter.put("mode", "byEmployeeNo"); // 删除方式, byEmployeeNo: 按员工ID号
parameter.put("employeeNo", employeeNo); // 员工ID号
String deleteUserjson = ConfigFileUtil.getReqBodyFromTemplate("/bonus-modules/bonus-smart-canteen/src/main/resources/conf/acs/DeleteUserInfoParam.json", parameter);
//删除所有人员
// String deleteUserjson = "{\n" +
// "\t\"UserInfoDetail\": {\t\n" +
// "\t\t\"mode\": \"all\",\t\n" +
// "\t\t\"EmployeeNoList\": [\t\n" +
// "\t\t]\n" +
// "\n" +
// "\t}\n" +
// "}";
String deleteUserUrl = "PUT /ISAPI/AccessControl/UserInfoDetail/Delete?format=json";
String result = TransIsapi.put_isapi(userID, deleteUserUrl, deleteUserjson);
System.out.println(result);
//获取删除进度
while (true) {
String getDeleteProcessUrl = "GET /ISAPI/AccessControl/UserInfoDetail/DeleteProcess?format=json";
String deleteResult = TransIsapi.get_isapi(userID, getDeleteProcessUrl);
JSONObject jsonObject = new JSONObject(deleteResult);
JSONObject jsonObject1 = jsonObject.getJSONObject("UserInfoDetailDeleteProcess");
String process = jsonObject1.getString("status");
System.out.println("process ="+process);
if (process.equals("processing")) {
System.out.println("正在删除");
continue;
} else if (process.equals("success")) {
System.out.println("删除成功");
break;
}else if(process.equals("failed")){
System.out.println("删除失败");
break;
}
}
}
/**
* 人员计划模板配置
*
* @param userID 用户登录句柄
* @param iPlanTemplateNumber 计划模板编号从1开始最大值从门禁能力集获取
*/
public static void setCardTemplate(int userID, int iPlanTemplateNumber) {
//设置卡权限计划模板参数
HCNetSDK.NET_DVR_PLAN_TEMPLATE_COND struPlanCond = new HCNetSDK.NET_DVR_PLAN_TEMPLATE_COND();
struPlanCond.dwSize = struPlanCond.size();
struPlanCond.dwPlanTemplateNumber = iPlanTemplateNumber;//计划模板编号从1开始最大值从门禁能力集获取
struPlanCond.wLocalControllerID = 0;//就地控制器序号[1,64]0表示门禁主机
struPlanCond.write();
HCNetSDK.NET_DVR_PLAN_TEMPLATE struPlanTemCfg = new HCNetSDK.NET_DVR_PLAN_TEMPLATE();
struPlanTemCfg.dwSize = struPlanTemCfg.size();
struPlanTemCfg.byEnable = 1; //是否使能0- 1-
struPlanTemCfg.dwWeekPlanNo = 2;//周计划编号0表示无效
struPlanTemCfg.dwHolidayGroupNo[0] = 0;//假日组编号按值表示采用紧凑型排列中间遇到0则后续无效
byte[] byTemplateName;
try {
byTemplateName = "CardTemplatePlan_2".getBytes("GBK");
//计划模板名称
for (int i = 0; i < HCNetSDK.NAME_LEN; i++) {
struPlanTemCfg.byTemplateName[i] = 0;
}
System.arraycopy(byTemplateName, 0, struPlanTemCfg.byTemplateName, 0, byTemplateName.length);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
struPlanTemCfg.write();
IntByReference pInt = new IntByReference(0);
Pointer lpStatusList = pInt.getPointer();
if (false == initServer.hCNetSDK.NET_DVR_SetDeviceConfig(userID, HCNetSDK.NET_DVR_SET_CARD_RIGHT_PLAN_TEMPLATE_V50, 1, struPlanCond.getPointer(), struPlanCond.size(), lpStatusList, struPlanTemCfg.getPointer(), struPlanTemCfg.size())) {
System.out.println("NET_DVR_SET_CARD_RIGHT_PLAN_TEMPLATE_V50失败错误号" + initServer.hCNetSDK.NET_DVR_GetLastError());
return;
}
System.out.println("NET_DVR_SET_CARD_RIGHT_PLAN_TEMPLATE_V50成功");
//获取卡权限周计划参数
HCNetSDK.NET_DVR_WEEK_PLAN_COND struWeekPlanCond = new HCNetSDK.NET_DVR_WEEK_PLAN_COND();
struWeekPlanCond.dwSize = struWeekPlanCond.size();
struWeekPlanCond.dwWeekPlanNumber = 2;
struWeekPlanCond.wLocalControllerID = 0;
HCNetSDK.NET_DVR_WEEK_PLAN_CFG struWeekPlanCfg = new HCNetSDK.NET_DVR_WEEK_PLAN_CFG();
struWeekPlanCond.write();
struWeekPlanCfg.write();
Pointer lpCond = struWeekPlanCond.getPointer();
Pointer lpInbuferCfg = struWeekPlanCfg.getPointer();
if (false == initServer.hCNetSDK.NET_DVR_GetDeviceConfig(userID, HCNetSDK.NET_DVR_GET_CARD_RIGHT_WEEK_PLAN_V50, 1, lpCond, struWeekPlanCond.size(), lpStatusList, lpInbuferCfg, struWeekPlanCfg.size())) {
System.out.println("NET_DVR_GET_CARD_RIGHT_WEEK_PLAN_V50失败错误号" + initServer.hCNetSDK.NET_DVR_GetLastError());
return;
}
struWeekPlanCfg.read();
struWeekPlanCfg.byEnable = 1; //是否使能0- 1-
/**避免时间段交叉,先初始化, 七天八小时*/
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 8; j++) {
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].byEnable = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.byHour = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.byHour = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[j].struTimeSegment.struEndTime.bySecond = 0;
}
}
/**一周7天全天24小时*/
for (int i = 0; i < 7; i++) {
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].byEnable = 1;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byHour = 21;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byHour = 23;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.bySecond = 0;
}
/**一周7天每天设置2个时间段*/
/*for(int i=0;i<7;i++)
{
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].byEnable = 1;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byHour = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.byMinute = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byHour = 11;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.byMinute = 59;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[0].struTimeSegment.struEndTime.bySecond = 59;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].byEnable = 1;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.byHour = 13;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.byMinute = 30;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struBeginTime.bySecond = 0;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.byHour = 19;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.byMinute = 59;
struWeekPlanCfg.struPlanCfg[i].struPlanCfgDay[1].struTimeSegment.struEndTime.bySecond = 59;
}*/
struWeekPlanCfg.write();
//设置卡权限周计划参数
if (false == initServer.hCNetSDK.NET_DVR_SetDeviceConfig(userID, HCNetSDK.NET_DVR_SET_CARD_RIGHT_WEEK_PLAN_V50, 1, lpCond, struWeekPlanCond.size(), lpStatusList, lpInbuferCfg, struWeekPlanCfg.size())) {
System.out.println("NET_DVR_SET_CARD_RIGHT_WEEK_PLAN_V50失败错误号" + initServer.hCNetSDK.NET_DVR_GetLastError());
} else {
System.out.println("NET_DVR_SET_CARD_RIGHT_WEEK_PLAN_V50成功");
}
}
/**
* 查询人员信息
* @param userID
* @throws JSONException
*/
public static Map<String,Object> getSearchUserInfo(int userID,String strInbuff) throws JSONException {
Map<String,Object> map = new HashMap<>();
HCNetSDK.BYTE_ARRAY ptrByteArray = new HCNetSDK.BYTE_ARRAY(1024); //数组
String strInBuffer = "POST /ISAPI/AccessControl/UserInfo/Search?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_JSON_CONFIG, ptrByteArray.getPointer(), strInBuffer.length(), null, null);
if (lHandler < 0) {
System.out.println("SearchUserInfo NET_DVR_StartRemoteConfig 失败,错误码为" + initServer.hCNetSDK.NET_DVR_GetLastError());
return null;
} else {
// System.out.println("查询的json报文:" + strInbuff);
//把string传递到Byte数组中后续用.getPointer()方法传入指针地址中
HCNetSDK.BYTE_ARRAY ptrInbuff = new HCNetSDK.BYTE_ARRAY(strInbuff.length());
System.arraycopy(strInbuff.getBytes(), 0, ptrInbuff.byValue, 0, strInbuff.length());
ptrInbuff.write();
//定义接收结果的结构体
HCNetSDK.BYTE_ARRAY ptrOutuff = new HCNetSDK.BYTE_ARRAY(1000 * 1024);
IntByReference pInt = new IntByReference(0);
while (true) {
/*
dwOutBuffSize是输出缓冲区大小需要自定义指定大小如果接口报错错误码43.说明接收设备数据的缓冲区或存放图片缓冲区不足应扩大缓冲区大小
*/
int dwState = initServer.hCNetSDK.NET_DVR_SendWithRecvRemoteConfig(lHandler, ptrInbuff.getPointer(), strInbuff.length(), ptrOutuff.getPointer(), 1000 * 1024, pInt);
System.out.println(dwState);
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) {
System.out.println("配置等待");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
continue;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FAILED) {
System.out.println("查询人员失败");
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_EXCEPTION) {
System.out.println("查询人员异常");
break;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_SUCCESS) {
ptrOutuff.read();
// System.out.println("查询人员成功, json:" + new String(ptrOutuff.byValue).trim());
String jsonstr=new String(ptrOutuff.byValue).trim();
JSONObject jsonObject=new JSONObject(jsonstr);
String searchstr=jsonObject.getString("UserInfoSearch");
JSONObject searchObject=new JSONObject(searchstr);
String searchstrs=searchObject.getString("UserInfo");
String allcount=searchObject.getString("totalMatches");
int allcountd=Integer.parseInt(allcount);
int num=(int)Math.floor(allcountd/10);
if(allcountd%10==0){
num=num-1;
}
List<UserVo> users= JSON.parseArray(searchstrs,UserVo.class);
map.put("data",users);
map.put("num",num);
map.put("allcount",allcountd);
return map;
} else if (dwState == HCNetSDK.NET_SDK_CONFIG_STATUS_FINISH) {
System.out.println("获取人员完成");
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接口成功");
lHandler = -1;
}
}
return null;
}
}

View File

@ -0,0 +1,12 @@
package com.bonus.canteen.core.kitchen.utils.NetSDK;
public class osSelect {
public static boolean isLinux() {
return System.getProperty("os.name").toLowerCase().contains("linux");
}
public static boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("windows");
}
}

View File

@ -0,0 +1,115 @@
package com.bonus.canteen.core.kitchen.utils.NetSDKCommom;
import com.sun.jna.Pointer;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
public class CommonMethod {
public static void WriteBuffToPointer(byte[] byData, Pointer pInBuffer) {
pInBuffer.write(0, byData, 0, byData.length);
}
public static String byteToString(byte[] bytes) {
if (null == bytes || bytes.length == 0) {
return "";
}
int iLengthOfBytes = 0;
for (byte st : bytes) {
if (st != 0) {
iLengthOfBytes++;
} else
break;
}
String strContent = "";
try {
strContent = new String(bytes, 0, iLengthOfBytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return strContent;
}
/**
* utf8字节数组转gbk字节数组
*
* @param utf8Bytes
* @return
*/
public static byte[] UTF8toGBK(byte[] utf8Bytes) {
String utf8Str = new String(utf8Bytes, StandardCharsets.UTF_8);
byte[] gbkBytes = utf8Str.getBytes(Charset.forName("GBK"));
return gbkBytes;
}
/**
* utf8字节数组转gbk字符串
*
* @param utf8Bytes
* @return
*/
public static String UTF8toGBKStr(byte[] utf8Bytes) {
return new String(UTF8toGBK(utf8Bytes), Charset.forName("GBK"));
}
/**
* 获取resource文件夹下的文件绝对路径
*
* @param filePath 文件相对于resources文件夹的相对路径, 格式描述举例为 conf/XX/XX.json
* @return
*/
public static String getResFileAbsPath(String filePath) {
if (filePath == null) {
throw new RuntimeException("filePath null error!");
}
return System.getProperty("user.dir") + filePath;
}
/**
* 获取控制台的一行输入
*
* @param inputTip 输入提示
* @return 控制台的输入信息
*/
public static String getConsoleInput(String inputTip) {
System.out.println(inputTip);
Scanner scanner = new Scanner(System.in);
return scanner.nextLine();
}
/**
* 输出信息到文件中
*
* @param fileName 文件名
* @param postFix 文件后缀
* @param fileContent 文件内容
*/
public static void outputToFile(String fileName, String postFix, String fileContent) {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss_SSS");
String folder = System.getProperty("user.dir") + "\\outputFiles\\event\\";
File directory = new File(folder);
if (!directory.exists()) {
boolean created = directory.mkdirs();
if (!created) {
System.out.println(folder + "_文件夹创建失败");
}
}
String filePath = folder + fileName + "_" + format.format(new Date()) + postFix;
try {
FileOutputStream fos = new FileOutputStream(filePath);
fos.write(fileContent.getBytes());
fos.close();
} catch (IOException e) {
System.out.println("输出到文件出现异常:" + e.getMessage());
}
}
}

View File

@ -0,0 +1,83 @@
package com.bonus.canteen.core.kitchen.utils.NetSDKCommom;
import org.apache.commons.lang3.text.StrSubstitutor;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
/**
* @author zhengxiaohui
* @date 2023/8/15 19:07
* @desc 配置文件处理工具
*/
public class ConfigFileUtil {
/**
* 获取请求数据报文内容
* @param templateFilePath 报文模板格式文件位置,位于resources文件夹下面conf/--/--.xx
* @param parameter 模板中可以替换的占位参数信息
* @return
*/
public static String getReqBodyFromTemplate(String templateFilePath, Map<String, Object> parameter) {
String templateContent = ConfigFileUtil.readFileContent(templateFilePath);
return ConfigFileUtil.replace(templateContent, parameter);
}
/**
* 读取xml配置文件
*
* @param filePath 文件相对于resources文件夹的相对路径
* @return
*/
public static String readFileContent(String filePath) {
String resourcePath = CommonMethod.getResFileAbsPath(filePath);
// 读取指定文件路径的文件内容
String contentStr = "";
try {
Path path = Paths.get(resourcePath);
contentStr = new String(Files.readAllBytes(path));
} catch (IOException e) {
e.printStackTrace();
}
return contentStr;
}
/**
* 替换 占位符变量固定为 ${}格式
*
* @param source 源内容
* @param parameter 占位符参数
* <p>
* 转义符默认为'$'如果这个字符放在一个变量引用之前这个引用将被忽略不会被替换 如$${a}将直接输出${a}
* @return
*/
public static String replace(String source, Map<String, Object> parameter) {
return replace(source, parameter, "${", "}", false);
}
/**
* 替换
*
* @param source 源内容
* @param parameter 占位符参数
* @param prefix 占位符前缀 例如:${
* @param suffix 占位符后缀 例如:}
* @param enableSubstitutionInVariables 是否在变量名称中进行替换 例如:${system-${版本}}
* <p>
* 转义符默认为'$'如果这个字符放在一个变量引用之前这个引用将被忽略不会被替换 如$${a}将直接输出${a}
* @return
*/
public static String replace(String source, Map<String, Object> parameter, String prefix, String suffix, boolean enableSubstitutionInVariables) {
//StrSubstitutor不是线程安全的类
StrSubstitutor strSubstitutor = new StrSubstitutor(parameter, prefix, suffix);
//是否在变量名称中进行替换
strSubstitutor.setEnableSubstitutionInVariables(enableSubstitutionInVariables);
return strSubstitutor.replace(source);
}
}

View File

@ -0,0 +1,176 @@
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.sun.jna.Native;
import com.sun.jna.Pointer;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONException;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import javax.imageio.stream.FileImageOutputStream;
import java.io.File;
import java.util.*;
@Slf4j
@Component
public class initServer implements CommandLineRunner {
public static HCNetSDK hCNetSDK = null;
public static int lUserID = -1;//用户句柄
public static int lAlarmHandle = -1;
public static int lListenHandle = -1;
public static FMSGCallBack_V31 fMSFCallBack_V31 = null;
public static int iCharEncodeType = 0;//设备字符集
public static String devIp = "192.168.1.69";
public static String devUser = "admin";
public static String devPass = "hzx12345";
@Override
public void run(String... args) throws Exception {
if(hCNetSDK == null){
if(!CreateSDKInstance()){
System.out.println("Load SDK fail");
return;
}
}
hCNetSDK.NET_DVR_Init();
boolean i= hCNetSDK.NET_DVR_SetLogToFile(3, "..//sdklog", false);
//设置报警回调函
if (fMSFCallBack_V31 == null) {
fMSFCallBack_V31 = new FMSGCallBack_V31();
Pointer pUser = null;
if (!initServer.hCNetSDK.NET_DVR_SetDVRMessageCallBack_V31(fMSFCallBack_V31, pUser)) {
System.out.println("设置回调函数失败!");
} else {
System.out.println("设置回调函数成功!");
}
}
// Login("192.168.0.199","admin","bouns@ltfk",(short) 8000); //登陆
Login(devIp,devUser,devPass,(short) 8000); //登陆
Alarm.SetAlarm(lUserID);
// 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");
}
public List<UserVo> getAllUser() throws JSONException {
Map<String, Object> parameter = new HashMap<>();
parameter.put("searchID", UUID.randomUUID()); // 查询idinsertCheckImg
parameter.put("searchResultPosition", 0);
parameter.put("maxResults", 10); // 最大查询数量
String strInbuff = ConfigFileUtil.getReqBodyFromTemplate("/bonus-modules/bonus-smart-canteen/src/main/resources/conf/acs/SearchUserInfoParam.json", parameter);
Map<String,Object> map=UserManage.getSearchUserInfo(lUserID,strInbuff);
System.out.println("总数据=========="+(int)map.get("allcount"));
int num=(int)map.get("num");
List<UserVo> users=new ArrayList<>();
users.addAll((List<UserVo>)map.get("data"));
for(int k=1;k<=num;k++){
Map<String, Object> parameter2 = new HashMap<>();
parameter2.put("searchID", UUID.randomUUID()); // 查询idinsertCheckImg
parameter2.put("searchResultPosition", k*10);
parameter2.put("maxResults", 10); // 最大查询数量
String strInbuff2 = ConfigFileUtil.getReqBodyFromTemplate("/bonus-modules/bonus-smart-canteen/src/main/resources/conf/acs/SearchUserInfoParam.json", parameter2);
Map<String,Object> map2=UserManage.getSearchUserInfo(lUserID,strInbuff2);
users.addAll((List<UserVo>)map2.get("data"));
}
for(UserVo vo:users){
System.out.println(vo.toString());
}
return users;
}
public void byte2image(byte[] data,String path){
if(data.length<3||path.equals("")){
return;
}
try{
FileImageOutputStream imageOutput = new FileImageOutputStream(new File(path));
imageOutput.write(data, 0, data.length);
imageOutput.close();
System.out.println("Make Picture success,Please find image in " + path);
} catch(Exception ex) {
System.out.println("Exception: " + ex);
ex.printStackTrace();
}
}
//byte数组到16进制字符串
public String byte2string(byte[] data){
if(data==null||data.length<=1){ return "0x";}
if(data.length>200000){ return "0x";}
StringBuffer sb = new StringBuffer();
int buf[] = new int[data.length];
//byte数组转化成十进制
for(int k=0;k<data.length;k++){
buf[k] = data[k]<0?(data[k]+256):(data[k]);
}
//十进制转化成十六进制
for(int k=0;k<buf.length;k++){
if(buf[k]<16){ sb.append("0"+Integer.toHexString(buf[k]));}
else{ sb.append(Integer.toHexString(buf[k]));}
}
return "0x"+sb.toString().toUpperCase();
}
/**
* 根据不同操作系统选择不同的库文件和库路径
* @return
*/
public static boolean CreateSDKInstance(){
if(hCNetSDK == null){
synchronized (HCNetSDK.class){
String strDllPath = "";
try{
//System.setProperty("jna.debug_load", "true");
if(osSelect.isWindows()){
//win系统加载库路径
strDllPath = System.getProperty("user.dir") + "\\bonus-modules\\bonus-smart-canteen\\src\\main\\resources\\lib\\HCNetSDK.dll";
}else if(osSelect.isLinux()){
//Linux系统加载库路径
strDllPath = System.getProperty("user.dir") + "/bonus-modules/bonus-smart-canteen/src/main/resources/lib/libhcnetsdk.so";
}
hCNetSDK = (HCNetSDK) Native.loadLibrary(strDllPath, HCNetSDK.class);
}catch (Exception ex) {
System.out.println("loadLibrary: " + strDllPath + " Error: " + ex.getMessage());
return false;
}
}
}
return true;
}
/**
* 设备登录
* @param ipadress IP地址
* @param user 用户名
* @param psw 密码
* @param port 端口默认8000
*/
public static void Login(String ipadress, String user, String psw, short port) {
//注册
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();//设备信息
lUserID = hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
if (lUserID == -1){
System.out.println("登录失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
return;
}else{
System.out.println("登录成功!");
m_strDeviceInfo.read();
iCharEncodeType = m_strDeviceInfo.byCharEncodeType;
return;
}
}
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="conf.Acs"
prefHeight="400.0" prefWidth="600.0">
</AnchorPane>

View File

@ -0,0 +1,7 @@
{
"CardInfo" : {
"employeeNo":"${employeeNo}",
"cardNo":"${cardNo}",
"cardType":"normalCard"
}
}

View File

@ -0,0 +1,5 @@
{
"faceLibType":"blackFD",
"FDID":"1",
"FPID":"${employeeNo}"
}

View File

@ -0,0 +1,9 @@
{
"FingerPrintCfg": {
"employeeNo": "${employeeNo}",
"enableCardReader": [1],
"fingerPrintID": 1,
"fingerType": "normalFP",
"fingerData": "${fingerData}"
}
}

View File

@ -0,0 +1,22 @@
{
"UserInfo":{
"employeeNo": "${employeeNo}",
"name": "${name}",
"userType":"normal",
"Valid":{
"enable": ${enable},
"beginTime":"2023-01-01T00:00:00",
"endTime":"2033-12-30T23:59:59",
"timeType":"local"
},
"doorRight":"1",
"RightPlan":[
{
"doorNo": ${doorNo},
"planTemplateNo":"1"
}
],
"gender":"male",
"localUIRight":false
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<CaptureFingerPrintCond xmlns="http://www.isapi.org/ver20/XMLSchema" version="2.0">
<fingerNo>${fingerNo}</fingerNo>
<readerID>1</readerID>
</CaptureFingerPrintCond>

View File

@ -0,0 +1,9 @@
{
"CardInfoDelCond":{
"CardNoList":[
{
"cardNo":"${cardNo}"
}
]
}
}

View File

@ -0,0 +1,5 @@
{
"FPID": [{
"value": "${employeeNo}"
}]
}

View File

@ -0,0 +1,8 @@
{
"FingerPrintCfg": {
"employeeNo": "${employeeNo}",
"enableCardReader": [1],
"fingerPrintID": 1,
"deleteFingerPrint": true
}
}

View File

@ -0,0 +1,10 @@
{
"UserInfoDetail": {
"mode": "${mode}",
"EmployeeNoList": [
{
"employeeNo": "${employeeNo}"
}
]
}
}

View File

@ -0,0 +1,12 @@
{
"CardInfoSearchCond": {
"searchID": "${searchID}",
"searchResultPosition": 0,
"maxResults": 30,
"EmployeeNoList" : [
{
"employeeNo": "${employeeNo}"
}
]
}
}

View File

@ -0,0 +1,7 @@
{
"searchResultPosition":0,
"maxResults":30,
"faceLibType":"blackFD",
"FDID":"1",
"FPID":"${employeeNo}"
}

View File

@ -0,0 +1,8 @@
{
"FingerPrintCond": {
"searchID": "${searchID}",
"employeeNo": "${employeeNo}",
"cardReaderNo": 1,
"fingerPrintID": 1
}
}

View File

@ -0,0 +1,8 @@
{
"UserInfoSearchCond":{
"searchID":"${searchID}",
"searchResultPosition":${searchResultPosition},
"maxResults":${maxResults}
}
}

View File

@ -72,7 +72,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join health_person_info b on a.user_id = b.user_id
left join health_person_info_chronic c on a.user_id = c.user_id
left join health_person_body_record d on a.user_id = d.user_id and d.if_latest = 1
where 1 = 1
left join health_chronic hc on c.chronic_id=hc.chronic_id
where hc.chronic_id is not null
<if test="articleTitle != null and articleTitle != ''">
and(a.nick_name like concat('%', #{articleTitle}, '%') or a.phonenumber like concat('%', #{encryptedSearchValue}, '%') or b.doctor_num like concat('%', #{articleTitle}, '%'))
</if>
@ -141,7 +142,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join health_person_info b on a.user_id = b.user_id
left join health_person_body_record c on a.user_id = c.user_id and c.if_latest = 1
left join health_person_info_chronic d on a.user_id = d.user_id
where a.user_id = #{userId}
left join health_chronic hc on d.chronic_id=hc.chronic_id
where a.user_id = #{userId} and hc.chronic_id is not null
group by a.user_id,
a.user_name,
a.phonenumber,

View File

@ -114,4 +114,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{checkId}
</foreach>
</delete>
<select id="selectKitchenStaffEnterExitRecordByEmployeeNo" parameterType="java.lang.String" resultMap="KitchenStaffEnterExitRecordResult">
select * from (
select kseer.enter_time,kseer.exit_time,kseer.enter_img_url,kseer.exit_img_url,kseer.device_id,
kst.staff_id, kst.canteen_id, staff_no, staff_name, post_name, mobile, 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
from kitchen_staff_enter_exit_record kseer
left join kitchen_staff_info kst on kseer.staff_id=kst.staff_id
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
left join basic_area ba on kst.area_id = ba.area_id
where kst.employee_no = #{employeeNo} order by kseer.enter_time desc
) aa limit 0,1
</select>
<select id="selectKitchenStaffByEmployeeNo" parameterType="java.lang.String" resultMap="KitchenStaffEnterExitRecordResult">
select kst.staff_id, kst.canteen_id, staff_no, staff_name, post_name, mobile, 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
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
left join basic_area ba on kst.area_id = ba.area_id
where kst.employee_no = #{employeeNo}
</select>
</mapper>