Pārlūkot izejas kodu

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

wangzhinan 11 mēneši atpakaļ
vecāks
revīzija
54cd253753
19 mainītis faili ar 1878 papildinājumiem un 1533 dzēšanām
  1. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/OnenetDevice.java
  2. 13 0
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/config/MultipartConfig.java
  3. 12 7
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/CORSFilter.java
  4. 1 1
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/CsrfFilter.java
  5. 38 5
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  6. 2 0
      svr/svr-cloud-device/sql/2024.sql
  7. 2 0
      svr/svr-cloud-device/src/main/java/com/yihu/SvrCloudDeviceApplication.java
  8. 1 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DevicePatientHealthIndexDao.java
  9. 1 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java
  10. 203 203
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/NetdevTestController.java
  11. 59 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/StDeviceController.java
  12. 1246 1267
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/netdevsdk/NetDevSdkService.java
  13. 15 15
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  14. 6 6
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceUploadService.java
  15. 260 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/StDeviceService.java
  16. 2 15
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java
  17. 3 3
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/DeviceDataPushLogUtil.java
  18. 3 3
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/DeviceLostMessageUtil.java
  19. 10 5
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/SecurityOrderUtil.java

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/OnenetDevice.java

@ -22,7 +22,7 @@ public class OnenetDevice extends UuidIdentityEntityWithCreateTime{
    private String imsi;//sim的imsi
    private String psk;//onenet DTLS加密所使用的PSK
    private String deviceId;//onenet平台设备id
    private String deviceType;//设备厂商类型1未来鹰2 海康
    private String deviceType;//设备厂商类型1未来鹰2 海康 3赛特
    private String categoryCode;//设备类型标识 14气感,15烟感
    @Column(name="name")

+ 13 - 0
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/config/MultipartConfig.java

@ -1,5 +1,6 @@
package com.yihu.jw.gateway.config;
import com.yihu.jw.gateway.filter.CORSFilter;
import com.yihu.jw.gateway.filter.CsrfFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -19,6 +20,8 @@ public class MultipartConfig {
    @Autowired
    CsrfFilter csrfFilter;
    @Autowired
    private CORSFilter corsFilter;
    @Value("${server.tomcat.basedir}")
    String tomcatLocation;
@ -35,6 +38,16 @@ public class MultipartConfig {
        return factory.createMultipartConfig();
    }
    @Bean
    public FilterRegistrationBean testFilterRegistration3() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(corsFilter);
        registration.addUrlPatterns("/*");
        registration.setName("corsFilter");
        registration.setOrder(-1);
        return registration;
    }
    @Bean
    public FilterRegistrationBean testFilterRegistration4() {
        FilterRegistrationBean registration = new FilterRegistrationBean();

+ 12 - 7
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/CORSFilter.java

@ -1,9 +1,10 @@
package com.yihu.jw.gateway.filter;
import org.springframework.core.annotation.Order;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ -11,10 +12,13 @@ import java.io.IOException;
/**
 * Created by yeshijie on 2024/3/26.
 */
@Order(1)
@WebFilter(filterName = "corsFilter", urlPatterns = {"/*"})
//@Order(-1)
//@WebFilter(filterName = "corsFilter", urlPatterns = {"/*"}) 注解的jar启动不生效要tomcat
@Component
public class CORSFilter implements Filter {
    private Logger logger = LoggerFactory.getLogger(CORSFilter.class);
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
@ -24,9 +28,10 @@ public class CORSFilter implements Filter {
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletResponse response = (HttpServletResponse) servletResponse;
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        System.out.println(">>>>>>>>>>>>>>>>>来了》》》》》》》》》》》》》》》》"+request.getHeader("Origin"));
        logger.info(">>>>>>>>>>>>>>>>>来了》》》》》》》》》》》》》》》》"+request.getHeader("Origin"));
        //https://yyfbxt.szhz.hangzhou.gov.cn:8068/web/mgop/gov-open/zj/2002347641/reserved/index.html
        response.setHeader("Access-Control-Allow-Origin", "https://yyfbxt.szhz.hangzhou.gov.cn:8068");
//        response.setHeader("Access-Control-Allow-Origin", "https://yyfbxt.szhz.hangzhou.gov.cn:8068");
//        response.setHeader("Access-Control-Allow-Origin", "*");
//        response.setHeader("Access-Control-Allow-Headers", "access-control-allow-origin, authority, content-type, version-info, X-Requested-With");
        response.setHeader("Access-Control-Allow-Headers", "*");
//        response.setHeader("Access-Control-Expose-Headers", "*");
@ -35,7 +40,7 @@ public class CORSFilter implements Filter {
        //response.setHeader("Access-Control-Allow-Credentials", "true");
        if ("OPTIONS".equals(request.getMethod())) {
            response.setStatus(HttpServletResponse.SC_OK);
            System.out.println("OPTIONS=======================");
            logger.info("OPTIONS=======================");
            return;
        }
        filterChain.doFilter(request, response);

+ 1 - 1
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/CsrfFilter.java

@ -72,7 +72,7 @@ public class CsrfFilter implements Filter {
        // 不启用或者已忽略的URL不拦截
        if(!getEnable() ||referer == null||referer.indexOf("http://ehr.yihu.com")==0
                ||referer.indexOf("https://zhyzh.gongshu.gov.cn")==0
                ||referer.indexOf("https://yyfbxt.szhz.hangzhou.gov.cn")>0
                ||referer.indexOf("https://yyfbxt.szhz.hangzhou.gov.cn")==0
                ||referer.indexOf("27.154.233.186")>0
                ||referer.indexOf(host)>0){
            filterChain.doFilter(servletRequest, servletResponse);

+ 38 - 5
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -334,7 +334,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
     * @throws Exception
     */
    @RequestMapping(value = "/oauth/login", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> login(@RequestParam Map<String, String> parameters, HttpSession httpSession) throws Exception {
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> login(@RequestParam Map<String, String> parameters,
                                                               HttpSession httpSession,HttpServletRequest request) throws Exception {
        logger.info("login:登录进入1");
        //图形验证码验证
        String key = parameters.get("key");
@ -409,7 +410,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            }
        } else if("1".equals(parameters.get("pwdAndCaptcha"))){
            parameters.put("grant_type", "pwdAndCaptcha");
            KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
//            KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
            KeyPair keyPair = getKeyPair(httpSession,request);
            String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
            parameters.put("password", password);
            if (!testPwd(parameters.get("password"))) {
@ -419,7 +421,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            parameters.put("grant_type", "password");
            //解密密码
            if (parameters.get("password") != null) {
                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
//                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                KeyPair keyPair = getKeyPair(httpSession,request);
                String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
                parameters.put("password", password);
            } else {
@ -461,7 +464,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        实现同一账号只能在一处登陆*/
        if("1".equals(kickEachOther)){
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
//            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
                if (tokenStore.readAccessToken(token.getValue())!=null){
                    tokenStore.removeAccessToken(token.getValue());
@ -707,8 +710,38 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
    }
    //获取私钥
    public KeyPair getKeyPair(HttpSession httpSession,HttpServletRequest request){
        String referer = request.getHeader("Referer");
        if(referer.indexOf("https://yyfbxt.szhz.hangzhou.gov.cn")==0){
            OauthKeypairDO keypairDO = oauthKeypairDao.findByCode("yyfbxtKey");
            KeyPair keyPair = (KeyPair) SerializeUtil.unSerialize(keypairDO.getKeyPair());
            return keyPair;
        }
        KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
        return keyPair;
    }
    @RequestMapping(value = "/oauth/getPublicKey", method = RequestMethod.GET)
    public ObjEnvelop<PublickeyVO> getPublicKey(HttpSession httpSession, HttpServletResponse httpServletResponse) {
    public ObjEnvelop<PublickeyVO> getPublicKey(HttpSession httpSession, HttpServletRequest request) {
        String referer = request.getHeader("Referer");
        if(referer.indexOf("https://yyfbxt.szhz.hangzhou.gov.cn")==0){
            //跨域时公钥固定
            OauthKeypairDO keypairDO = oauthKeypairDao.findByCode("yyfbxtKey");
            if (keypairDO == null) {
                KeyPair keyPair = com.yihu.jw.security.utils.RSAUtils.getKey();
                byte[] bytekey = SerializeUtil.ObjTOSerialize(keyPair);
                OauthKeypairDO kpDO = new OauthKeypairDO();
                kpDO.setCode("yyfbxtKey");
                kpDO.setKeyPair(bytekey);
                keypairDO = oauthKeypairDao.save(kpDO);
            }
            KeyPair keyPair = (KeyPair) SerializeUtil.unSerialize(keypairDO.getKeyPair());
            PublickeyVO pk = new PublickeyVO();
            pk.setPublicKey(com.yihu.jw.security.utils.RSAUtils.generateBase64PublicKey(keyPair));
            return ObjEnvelop.getSuccess("success", pk);
        }
        KeyPair keyPair = com.yihu.jw.security.utils.RSAUtils.getKey();
        httpSession.setAttribute("privateKey", keyPair);
        PublickeyVO pk = new PublickeyVO();

+ 2 - 0
svr/svr-cloud-device/sql/2024.sql

@ -0,0 +1,2 @@
INSERT INTO `base`.`dm_device` (`id`, `category_code`, `photo`, `brands`, `model`, `name`, `is_multi_user`, `multi_user`, `czrq`, `del`, `service_topic`, `need_register`, `device_type`) VALUES ('53', '14', 'group1/M00/00/7D/rBoAbmJM_ImAIpVJAAEHObqvlCc406.png', '赛特', 'JT-GS894-C', '燃气泄漏监测', '1', NULL, '2024-04-18 17:39:36', '1', 'preventGasLeakage', NULL, '1');
INSERT INTO `base`.`dm_device` (`id`, `category_code`, `photo`, `brands`, `model`, `name`, `is_multi_user`, `multi_user`, `czrq`, `del`, `service_topic`, `need_register`, `device_type`) VALUES ('54', '15', 'group1/M00/00/5B/rBoAb2JM_I6AOxbPAAF-iVueMbM661.png', '赛特', 'GS524N', '火灾监测', '1', NULL, '2024-04-18 17:39:36', '1', 'preventFire', NULL, '1');

+ 2 - 0
svr/svr-cloud-device/src/main/java/com/yihu/SvrCloudDeviceApplication.java

@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.client.RestTemplate;
@ -19,6 +20,7 @@ import org.springframework.web.client.RestTemplate;
@SpringBootApplication
@EnableJpaAuditing
@EnableAsync
@ComponentScan("com.yihu")
public class SvrCloudDeviceApplication extends SpringBootServletInitializer {
    public static void main(String[] args)  {

+ 1 - 1
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DevicePatientHealthIndexDao.java

@ -9,7 +9,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
public interface DevicePatientHealthIndexDao
public interface DDevicePatientHealthIndexDao
		extends PagingAndSortingRepository<DevicePatientHealthIndex, Long>, JpaSpecificationExecutor<DevicePatientHealthIndex> {
	List<DevicePatientHealthIndex> findByIdcardAndType(String idcard, Integer type);

+ 1 - 1
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java

@ -9,7 +9,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatientDevice, Long>, JpaSpecificationExecutor<DevicePatientDevice> {
public interface DPatientDeviceDao extends PagingAndSortingRepository<DevicePatientDevice, Long>, JpaSpecificationExecutor<DevicePatientDevice> {
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    Iterable<DevicePatientDevice> findByUser(String user);

+ 203 - 203
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/NetdevTestController.java

@ -1,203 +1,203 @@
package com.yihu.jw.care.endpoint;
import com.yihu.jw.care.common.BaseController;
import com.yihu.jw.care.netdevsdk.NetDevSdkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * 宇视人脸数据测试接口
 * Created by yeshijie on 2022/5/25.
 */
@RestController
@RequestMapping(value = "/netDevTest",produces = "application/json")
@Api(value = "宇视人脸数据测试接口", description = "宇视人脸数据测试接口")
public class NetdevTestController extends BaseController {
    @Autowired
    private NetDevSdkService netDevSdkService;
    @GetMapping("discoveryDevice")
    @ApiOperation("设备搜索")
    public String discoveryDevice(){
        try {
            netDevSdkService.discoveryDevice();
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @GetMapping("SubscribeAlarm")
    @ApiOperation("订阅告警信息")
    public String SubscribeAlarm(){
        try {
            netDevSdkService.SubscribeAlarm();
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @GetMapping("UnSubscribeAlarm")
    @ApiOperation("取消订阅告警信息")
    public String UnSubscribeAlarm(){
        try {
            netDevSdkService.UnSubscribeAlarm();
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @GetMapping("registerPersonAlarm")
    @ApiOperation("注册人脸报警消息回调函数")
    public String registerPersonAlarm(){
        try {
            netDevSdkService.registerPersonAlarm();
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @GetMapping("cancelRegisterPersonAlarm")
    @ApiOperation("取消注册人脸报警消息回调函数")
    public String cancelRegisterPersonAlarm(){
        try {
            netDevSdkService.cancelRegisterPersonAlarm();
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @GetMapping("findPersonLib")
    @ApiOperation("查找人员库")
    public String findPersonLib(){
        try {
            netDevSdkService.findPersonLib();
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @GetMapping("findPerson")
    @ApiOperation("查找人员")
    public String findPerson(String szName){
        try {
            netDevSdkService.findPerson(szName);
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @GetMapping("pstDeviceInfo")
    @ApiOperation("获取设备信息")
    public String pstDeviceInfo(){
        try {
            return write(200,"查找成功","data",netDevSdkService.pstDeviceInfo());
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @ApiOperation("人脸识别记录")
    @GetMapping(value = "queryPassRecord")
    public String queryPassRecord(
            @ApiParam(value="开始时间",defaultValue = "2022-05-15 13:46:59")
            @RequestParam(value = "strBeginTime", required = true)  String strBeginTime ,
            @ApiParam(value="结束时间",defaultValue = "2022-05-25 13:46:59")
            @RequestParam(value = "strEndTime", required = true)  String strEndTime,
            @ApiParam(value="告警源",required = false)
            @RequestParam(value = "getPersonPassAlarmSource", required = false)  String getPersonPassAlarmSource)
    {
        try {
            netDevSdkService.queryPassRecord(strBeginTime,strEndTime,getPersonPassAlarmSource);
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @ApiOperation("告警记录")
    @GetMapping(value = "queryAlarmRecord")
    public String queryAlarmRecord(
            @ApiParam(value="开始时间",defaultValue = "2022-05-15 13:46:59")
            @RequestParam(value = "strBeginTime", required = true)  String strBeginTime ,
            @ApiParam(value="结束时间",defaultValue = "2022-05-25 13:46:59")
            @RequestParam(value = "strEndTime", required = true)  String strEndTime,
            @ApiParam(value="监控类型 0 1",required = true)
            @RequestParam(value = "monitorType", required = true)  Integer monitorType)
    {
        try {
            netDevSdkService.queryAlarmRecord(strBeginTime,strEndTime,monitorType);
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @ApiOperation("门禁查询出入记录")
    @GetMapping(value = "searchAccessRecords")
    public String searchAccessRecords(
            @ApiParam(value="开始时间",defaultValue = "2022-05-15 13:46:59")
            @RequestParam(value = "startTime", required = true)  String startTime ,
            @ApiParam(value="结束时间",defaultValue = "2022-05-25 13:46:59")
            @RequestParam(value = "endTime", required = true)  String endTime,
            @ApiParam(value="人员id",required = false)
            @RequestParam(value = "persionId", required = false)  String persionId)
    {
        try {
            netDevSdkService.searchAccessRecords(startTime,endTime,persionId);
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    /*********************************job 调用接口****************************************************/
    @GetMapping("updPatientFace")
    @ApiOperation("更新人脸库人员数据")
    public String updPatientFace(){
        try {
            String res = netDevSdkService.updPatientFace();
            if(res == null){
                return success();
            }else {
                return error(-1,res);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
    @GetMapping("synPatientFaceRecords")
    @ApiOperation("同步人脸数据")
    public String synPatientFaceRecords(){
        try {
            netDevSdkService.synPatientFaceRecords();
            return success();
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,e.getMessage());
        }
    }
}
//package com.yihu.jw.care.endpoint;
//
//import com.yihu.jw.care.common.BaseController;
//import com.yihu.jw.care.netdevsdk.NetDevSdkService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
///**
// * 宇视人脸数据测试接口
// * Created by yeshijie on 2022/5/25.
// */
//@RestController
//@RequestMapping(value = "/netDevTest",produces = "application/json")
//@Api(value = "宇视人脸数据测试接口", description = "宇视人脸数据测试接口")
//public class NetdevTestController extends BaseController {
//
//    @Autowired
//    private NetDevSdkService netDevSdkService;
//
//    @GetMapping("discoveryDevice")
//    @ApiOperation("设备搜索")
//    public String discoveryDevice(){
//        try {
//            netDevSdkService.discoveryDevice();
//            return success();
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1,e.getMessage());
//        }
//    }
//
//    @GetMapping("SubscribeAlarm")
//    @ApiOperation("订阅告警信息")
//    public String SubscribeAlarm(){
//        try {
//            netDevSdkService.SubscribeAlarm();
//            return success();
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1,e.getMessage());
//        }
//    }
//
//    @GetMapping("UnSubscribeAlarm")
//    @ApiOperation("取消订阅告警信息")
//    public String UnSubscribeAlarm(){
//        try {
//            netDevSdkService.UnSubscribeAlarm();
//            return success();
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1,e.getMessage());
//        }
//    }
//
//    @GetMapping("registerPersonAlarm")
//    @ApiOperation("注册人脸报警消息回调函数")
//    public String registerPersonAlarm(){
//        try {
//            netDevSdkService.registerPersonAlarm();
//            return success();
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1,e.getMessage());
//        }
//    }
//
//    @GetMapping("cancelRegisterPersonAlarm")
//    @ApiOperation("取消注册人脸报警消息回调函数")
//    public String cancelRegisterPersonAlarm(){
//        try {
//            netDevSdkService.cancelRegisterPersonAlarm();
//            return success();
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1,e.getMessage());
//        }
//    }
//
//    @GetMapping("findPersonLib")
//    @ApiOperation("查找人员库")
//    public String findPersonLib(){
//        try {
//            netDevSdkService.findPersonLib();
//            return success();
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1,e.getMessage());
//        }
//    }
//
//    @GetMapping("findPerson")
//    @ApiOperation("查找人员")
//    public String findPerson(String szName){
//        try {
//            netDevSdkService.findPerson(szName);
//            return success();
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1,e.getMessage());
//        }
//    }
//
//    @GetMapping("pstDeviceInfo")
//    @ApiOperation("获取设备信息")
//    public String pstDeviceInfo(){
//        try {
//            return write(200,"查找成功","data",netDevSdkService.pstDeviceInfo());
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1,e.getMessage());
//        }
//    }
//
//    @ApiOperation("人脸识别记录")
//    @GetMapping(value = "queryPassRecord")
//    public String queryPassRecord(
//            @ApiParam(value="开始时间",defaultValue = "2022-05-15 13:46:59")
//            @RequestParam(value = "strBeginTime", required = true)  String strBeginTime ,
//            @ApiParam(value="结束时间",defaultValue = "2022-05-25 13:46:59")
//            @RequestParam(value = "strEndTime", required = true)  String strEndTime,
//            @ApiParam(value="告警源",required = false)
//            @RequestParam(value = "getPersonPassAlarmSource", required = false)  String getPersonPassAlarmSource)
//    {
//        try {
//            netDevSdkService.queryPassRecord(strBeginTime,strEndTime,getPersonPassAlarmSource);
//            return success();
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1,e.getMessage());
//        }
//    }
//
//    @ApiOperation("告警记录")
//    @GetMapping(value = "queryAlarmRecord")
//    public String queryAlarmRecord(
//            @ApiParam(value="开始时间",defaultValue = "2022-05-15 13:46:59")
//            @RequestParam(value = "strBeginTime", required = true)  String strBeginTime ,
//            @ApiParam(value="结束时间",defaultValue = "2022-05-25 13:46:59")
//            @RequestParam(value = "strEndTime", required = true)  String strEndTime,
//            @ApiParam(value="监控类型 0 1",required = true)
//            @RequestParam(value = "monitorType", required = true)  Integer monitorType)
//    {
//        try {
//            netDevSdkService.queryAlarmRecord(strBeginTime,strEndTime,monitorType);
//            return success();
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1,e.getMessage());
//        }
//    }
//
//    @ApiOperation("门禁查询出入记录")
//    @GetMapping(value = "searchAccessRecords")
//    public String searchAccessRecords(
//            @ApiParam(value="开始时间",defaultValue = "2022-05-15 13:46:59")
//            @RequestParam(value = "startTime", required = true)  String startTime ,
//            @ApiParam(value="结束时间",defaultValue = "2022-05-25 13:46:59")
//            @RequestParam(value = "endTime", required = true)  String endTime,
//            @ApiParam(value="人员id",required = false)
//            @RequestParam(value = "persionId", required = false)  String persionId)
//    {
//        try {
//            netDevSdkService.searchAccessRecords(startTime,endTime,persionId);
//            return success();
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1,e.getMessage());
//        }
//    }
//
//    /*********************************job 调用接口****************************************************/
//    @GetMapping("updPatientFace")
//    @ApiOperation("更新人脸库人员数据")
//    public String updPatientFace(){
//        try {
//            String res = netDevSdkService.updPatientFace();
//            if(res == null){
//                return success();
//            }else {
//                return error(-1,res);
//            }
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1,e.getMessage());
//        }
//    }
//
//    @GetMapping("synPatientFaceRecords")
//    @ApiOperation("同步人脸数据")
//    public String synPatientFaceRecords(){
//        try {
//            netDevSdkService.synPatientFaceRecords();
//            return success();
//        }catch (Exception e){
//            e.printStackTrace();
//            return error(-1,e.getMessage());
//        }
//    }
//}

+ 59 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/StDeviceController.java

@ -0,0 +1,59 @@
package com.yihu.jw.care.endpoint;
import com.yihu.jw.care.common.BaseController;
import com.yihu.jw.care.service.StDeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
 * Created by yeshijie on 2024/4/16.
 */
@RestController
@RequestMapping("/stdevice")
@Api(value = "赛特威尔设备相关服务", description = "赛特威尔设备相关服务")
public class StDeviceController  extends BaseController {
    private static Logger logger = LoggerFactory.getLogger(StDeviceController.class);
    @Autowired
    private StDeviceService stDeviceService;
    @ApiOperation("消息通知接收")
    @RequestMapping(value = "messageNotification",method = {RequestMethod.POST,RequestMethod.GET})
    public String messageNotification(HttpServletRequest request) {
        try {
            String str = getRequestBodyData(request);
            logger.info("=========str=============:"+str);
            stDeviceService.messageNotification(str);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("Device data incoming failure");
            return success();
        }
    }
    @ApiOperation("测试消息通知接收")
    @RequestMapping(value = "testMessageNotification",method = {RequestMethod.POST})
    public String testMessageNotification(String str) {
        try {
            logger.info("=========str=============:"+str);
            stDeviceService.messageNotification(str);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("Device data incoming failure");
            return success();
        }
    }
}

+ 1246 - 1267
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/netdevsdk/NetDevSdkService.java

@ -1,1270 +1,1249 @@
package com.yihu.jw.care.netdevsdk;
import com.alibaba.fastjson.JSONObject;
import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.yihu.jw.care.dao.face.BaseDeviceFaceRecordDao;
import com.yihu.jw.care.dao.face.BaseDevicePatientFaceDao;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_DEVICE_TYPE_E;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_DEVICE_LOGIN_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_SELOG_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_DEVICE_BASE_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_LAPI_SUB_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_SUBSCRIBE_SUCC_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_LIB_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_PERSON_QUERY_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_BATCH_OPERATE_BASIC_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_PERSON_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_REGION_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_IMAGE_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_FILE_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_GENDER_TYPE_E;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_ID_TYPE_E;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_ALARM_LOG_COND_LIST_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_QUERY_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_QUERYCOND_TYPE_E;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_QUERYCOND_LOGICTYPE_E;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_SMART_ALARM_LOG_RESULT_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_FACE_RECORD_SNAPSHOT_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_FACE_ALARM_CMP_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_FACE_MEMBER_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_FACE_MEMBER_REGION_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_FACE_MEMBER_ID_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_FACE_ALARM_SNAP_IMAGE_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_FACE_ALARM_IMAGE_AREA_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_DISCOVERY_DEVINFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_REPORT_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_REPORT_TYPE_E;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_TMS_FACE_SNAPSHOT_PIC_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_PERSON_EVENT_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_ACS_ATTENDANCE_LOG_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_COMPARE_INFO_S;
import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.NETDEV_FACE_ATTR_S;
import com.yihu.jw.care.netdevsdk.util.Common;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.BaseDeviceFaceRecordDO;
import com.yihu.jw.entity.care.device.BaseDevicePatientFaceDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.swing.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
/**
 * 宇视人脸摄像头sdk
 * Created by yeshijie on 2022/5/19.
 */
@Service
public class NetDevSdkService {
    @Autowired
    private BaseDevicePatientFaceDao devicePatientFaceDao;
    @Autowired
    private BaseDeviceFaceRecordDao faceRecordDao;
    @Autowired
    private BasePatientDao patientDao;
    private static final Logger logger = LoggerFactory.getLogger(NetDevSdkService.class);
    // http://zhyzh.gongshu.gov.cn:3001/ 开vpn后可以本地调试
    //IP:10.18.50.18   账号admin  密码Admin12345@    HTTP端口80  HTTPS端口  443  RTSP端口 554
    private static final int dwPort = 80;//端口号 443
//    private static final int dwPort = 3001;//端口号 443
    private static final String strUserName = "admin";//用户名
    private static final String strPassword = "Admin12345@";//密码
//    private static final String strIPAddr = "zhyzh.gongshu.gov.cn";//ip地址
    private static final String strIPAddr = "10.18.50.18";//ip地址
    private static final Integer dwLoginProto = 1; /* 登录协议 0:onvif 1:私有*/
    private static final Integer dwDeviceType = 1; /* 设备类型 IPC/NVR */
    private static final String baseFaceImg = "https://zhyzh.gongshu.gov.cn/face/";
    public void init(){
        initSDK();
        initLogin();
    }
    /**
     * 初始化sdk
     */
    private void initSDK(){
        String strLogPath = "./sdklog/";
        boolean bRet = NetDemo.netdevsdk.NETDEV_SetLogPath(strLogPath);
        if(false == bRet){
            logger.info("日志路径设置失败:"+ NetDemo.netdevsdk.NETDEV_GetLastError());
        }
        bRet = NetDemo.netdevsdk.NETDEV_Init();
        if(false == bRet){
            logger.info("sdk初始化失败:"+NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
        try {
            Common.updateStructureByReferenceMethod = Structure.class.getDeclaredMethod("updateStructureByReference", Class.class, Structure.class, Pointer.class);
            Common.updateStructureByReferenceMethod.setAccessible(true);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        File file=new File(NetDemo.strPicturePath);
        if(!file.exists()){
            file.mkdir();
        }
    }
    /**
     * SDK清理
     */
    private void cleanupSDK(){
        NetDemo.netdevsdk.NETDEV_Cleanup();
    }
    /**
     * 登录
     */
    public void initLogin(){
        NETDEV_DEVICE_LOGIN_INFO_S stDevLoginInfo = new NETDEV_DEVICE_LOGIN_INFO_S();
        System.arraycopy(strUserName.getBytes(), 0, stDevLoginInfo.szUserName, 0, strUserName.getBytes().length);
        System.arraycopy(strPassword.getBytes(), 0, stDevLoginInfo.szPassword, 0, strPassword.getBytes().length);
        System.arraycopy(strIPAddr.getBytes(), 0, stDevLoginInfo.szIPAddr, 0, strIPAddr.getBytes().length);
        stDevLoginInfo.dwPort = dwPort;
        stDevLoginInfo.dwLoginProto = dwLoginProto;
        NETDEV_SELOG_INFO_S stSELogInfo = new NETDEV_SELOG_INFO_S();
        NetDemo.lpUserID = NetDemo.netdevsdk.NETDEV_Login_V30(stDevLoginInfo, stSELogInfo);
        if(NetDemo.lpUserID!=null){
            //4.25.5 注册人脸抓拍上报回调函数
            NetDemo.netdevsdk.NETDEV_SetFaceSnapshotCallBack(NetDemo.lpUserID,  cbFaceSnapshotCallBack, null);
        }else{
            logger.info("登录sdk失败,error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
        //获取设备信息
        NetDemo.pstDeviceInfo = new NETDEV_DEVICE_BASE_INFO_S();
        NetDemo.pstDeviceInfo.write();
        boolean bRet = NetDemo.netdevsdk.NETDEV_GetDeviceBaseInfo(NetDemo.lpUserID,NetDemo.pstDeviceInfo);
        if(bRet != true){
            logger.info("获取设备信息失败:" + NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
        NetDemo.pstDeviceInfo.read();
    }
    /**
     * 获取设备信息
     * @return
     */
    public JSONObject pstDeviceInfo(){
        JSONObject jsonObject = new JSONObject();
        if(NetDemo.pstDeviceInfo==null){
            logger.info("请先登录设备");
            return null;
        }
        jsonObject.put("dwChlID",NetDemo.pstDeviceInfo.dwChlID);//视频输入通道号  Video input channel ID
        jsonObject.put("dwDeviceType",NetDemo.pstDeviceInfo.dwDeviceType);//设备类型
        jsonObject.put("dwDevCode",NetDemo.pstDeviceInfo.dwDevCode);//设备编号
        jsonObject.put("dwCurrentLang",NetDemo.pstDeviceInfo.dwCurrentLang);//设备当前语言 参见枚举#NETDEV_LANG_TYPE_E Current language NETDEV_LANG_TYPE_E*
        jsonObject.put("stBuildDate",NetDemo.pstDeviceInfo.stBuildDate.dwYear
                +"-"+NetDemo.pstDeviceInfo.stBuildDate.dwMonth
                +"-"+NetDemo.pstDeviceInfo.stBuildDate.dwDay
                +" "+NetDemo.pstDeviceInfo.stBuildDate.dwHour
                +":"+NetDemo.pstDeviceInfo.stBuildDate.dwMinute);//发布时间
        jsonObject.put("szSerialNum",Common.byteArrayToString(NetDemo.pstDeviceInfo.szSerialNum));//设备序列号
        jsonObject.put("szMacAddress",Common.byteArrayToString(NetDemo.pstDeviceInfo.szMacAddress));//IPv4的Mac地址
        jsonObject.put("szDevName",Common.byteArrayToString(NetDemo.pstDeviceInfo.szDevName));//设备名称
        jsonObject.put("szDevModel",Common.byteArrayToString(NetDemo.pstDeviceInfo.szDevModel));//设备型号
        jsonObject.put("szVIIDVersion",Common.byteArrayToString(NetDemo.pstDeviceInfo.szVIIDVersion));//视图库组件版本号
        jsonObject.put("szSoftwareVersion",Common.byteArrayToString(NetDemo.pstDeviceInfo.szSoftwareVersion));//内部软件版本
        jsonObject.put("szFirmwareVersion",Common.byteArrayToString(NetDemo.pstDeviceInfo.szFirmwareVersion));//软件版本号
        jsonObject.put("szHardewareID",Common.byteArrayToString(NetDemo.pstDeviceInfo.szHardewareID));//硬件标识
        jsonObject.put("szUbootVersion",Common.byteArrayToString(NetDemo.pstDeviceInfo.szUbootVersion));//UBOOT引导版本
        jsonObject.put("szManufacturer",Common.byteArrayToString(NetDemo.pstDeviceInfo.szManufacturer));//厂商名称
        jsonObject.put("szProtoName",Common.byteArrayToString(NetDemo.pstDeviceInfo.szProtoName));//设备原型机名称
        jsonObject.put("dwChlID",NetDemo.pstDeviceInfo.dwChlID);//
        return jsonObject;
    }
    /**
     * 设备搜索回调
     */
    public void discoveryDevice(){
        boolean flag1 = NetDemo.netdevsdk.NETDEV_SetDiscoveryCallBack(cbDiscoveryCallBack, null);
        boolean flag2 = NetDemo.netdevsdk.NETDEV_Discovery("0.0.0.0", "0.0.0.0");
        logger.info("flag1:"+flag1+",flag2:"+flag2);
    }
    /**
     * 订阅告警信息
     */
    public void SubscribeAlarm() {
        if(null == NetDemo.lpUserID)
        {
            logger.info("未登录,请先登录");
            return;
        }
        boolean bRet = NetDemo.netdevsdk.NETDEV_SetAlarmCallBack_V30(NetDemo.lpUserID, cbAlarmMessCallBack, null);
        if(bRet) {
            logger.info("订阅告警信息成功");
        }else {
            logger.info("订阅告警信息失败,错误码"+ NetDemo.netdevsdk.NETDEV_GetLastError());
        }
    }
    /**
     * 取消订阅告警信息
     */
    public void UnSubscribeAlarm() {
        if(null == NetDemo.lpUserID)
        {
            logger.info("未登录,请先登录");
            return;
        }
        boolean bRet = NetDemo.netdevsdk.NETDEV_SetAlarmCallBack_V30(NetDemo.lpUserID, null, null);
        if(bRet==false) {
            logger.info("取消订阅告警信息失败,错误码"+ NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }else {
            logger.info("取消订阅告警信息成功");
        }
    }
    /**
     * 4.25.7 注册人脸报警消息回调函数
     */
    public void registerPersonAlarm() {
        if(null == NetDemo.lpUserID)
        {
            logger.info("未登录,请先登录");
            return;
        }
        boolean bRet = NetDemo.netdevsdk.NETDEV_SetPersonAlarmCallBack(NetDemo.lpUserID, personAlarmMessCB, NetDemo.lpUserID);
        if(false == bRet)
        {
            logger.info("设置人脸报警消息回调方法失败,错误码"+NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
        NETDEV_LAPI_SUB_INFO_S stSubInfo = new NETDEV_LAPI_SUB_INFO_S();
        stSubInfo.udwType = 16;
        stSubInfo.udwLibIDNum = 0xffff;
        NETDEV_SUBSCRIBE_SUCC_INFO_S stSubSuccInfo = new NETDEV_SUBSCRIBE_SUCC_INFO_S();
        bRet = NetDemo.netdevsdk.NETDEV_SubscibeLapiAlarm(NetDemo.lpUserID, stSubInfo, stSubSuccInfo);
        if(false == bRet){
            logger.info("注册人脸报警消息失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }else {
            logger.info("注册人脸报警消息");
        }
        NetDemo.dwPersonRecognizeMointerID = stSubSuccInfo.udwID;
    }
    /**
     * 取消注册人脸报警消息回调函数
     */
    public static void cancelRegisterPersonAlarm() {
        if(null == NetDemo.lpUserID)
        {
            logger.info("未登录,请先登录");
            return;
        }
        boolean bRet = NetDemo.netdevsdk.NETDEV_UnSubLapiAlarm(NetDemo.lpUserID, NetDemo.dwPersonRecognizeMointerID);
        if(false == bRet)
        {
            logger.info("取消注册人脸报警消息失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
        else
        {
            logger.info("取消成功");
        }
        NetDemo.dwPersonRecognizeMointerID = -1;
    }
    /**
     * 同步人脸数据
     */
    public void synPatientFaceRecords(){
        List<BaseDevicePatientFaceDO> list = devicePatientFaceDao.findListByType(1);
        for (BaseDevicePatientFaceDO faceDO:list){
            try {
                sysPatientFaceRecord(faceDO);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
    public String sysPatientFaceRecord(BaseDevicePatientFaceDO faceDO){
        String endTime = "";
        String idcard = faceDO.getIdcard();
        String patient = faceDO.getPatient();
        String name = faceDO.getName();
        if(null == NetDemo.lpUserID){
            return "未登录,请先登录";
        }
        if (StringUtils.isBlank(idcard)){
            return "身份证不能为空";
        }
        if(StringUtils.isNotBlank(faceDO.getSynTime())&&faceDO.getSynTime().compareTo(DateUtil.getNextMinute(DateUtil.getStringDate(), -30))>0){
            return "同步时间必须晚于当前时间30分钟";
        }
        do {
            String startTime = faceDO.getSynTime();
            if(StringUtils.isBlank(startTime)){
                //第一次取当前时间的前30分钟数据
                endTime = DateUtil.getStringDate();
                startTime = DateUtil.getNextMinute(endTime, -30);
            }else{
                endTime = DateUtil.getNextMinute(startTime, 30);//采集30分钟后的数据
            }
            logger.info(name+",startTime="+startTime+",endTime="+endTime);
            NETDEV_ALARM_LOG_COND_LIST_S stFindCond = new NETDEV_ALARM_LOG_COND_LIST_S();
            stFindCond.dwPageRow = 5;
            stFindCond.dwFirstRow = 0;
            stFindCond.dwCondSize = 5;
            stFindCond.astCondition[0] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[1] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[2] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[3] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[4] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[0].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
            stFindCond.astCondition[0].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_GREATER;
            Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(startTime, NetDemo.DateFormat)), stFindCond.astCondition[0].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
            stFindCond.astCondition[1].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
            stFindCond.astCondition[1].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_GREATER;
            Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(endTime, NetDemo.DateFormat)), stFindCond.astCondition[1].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
            stFindCond.astCondition[2].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
            stFindCond.astCondition[2].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_DESC_ORDER;
            Common.stringToByteArray("", stFindCond.astCondition[2].szConditionData);
            stFindCond.astCondition[3].dwQueryType = 57;
            stFindCond.astCondition[3].dwLogicFlag = 0;
            //1表示匹配成功
            Common.stringToByteArray("1", stFindCond.astCondition[3].szConditionData);
            stFindCond.astCondition[4].dwQueryType = 58;
            stFindCond.astCondition[4].dwLogicFlag = 0;
            Common.stringToByteArray(idcard, stFindCond.astCondition[4].szConditionData);
            NETDEV_SMART_ALARM_LOG_RESULT_INFO_S stResultInfo = new NETDEV_SMART_ALARM_LOG_RESULT_INFO_S();
            boolean bRet = false;
            while(true)
            {
                Pointer lpFindRecordHandlePointer = NetDemo.netdevsdk.NETDEV_FindFaceRecordDetailList(NetDemo.lpUserID, stFindCond, stResultInfo);
                if(lpFindRecordHandlePointer != null)
                {
                    while(true)
                    {
                        logger.info("人脸数据stFindCond.dwFirstRow:"+stFindCond.dwFirstRow);
                        NETDEV_FACE_RECORD_SNAPSHOT_INFO_S stRecordInfo = new NETDEV_FACE_RECORD_SNAPSHOT_INFO_S();
                        stRecordInfo.stCompareInfo = new NETDEV_FACE_ALARM_CMP_INFO_S();
                        stRecordInfo.stCompareInfo.stSnapshotImage = new NETDEV_FACE_ALARM_SNAP_IMAGE_S();
                        stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage = new NETDEV_FILE_INFO_S();
                        stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
                        stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage.udwSize = Common.NETDEMO_PICTURE_SIZE;
                        stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage = new NETDEV_FILE_INFO_S();
                        stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
                        stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.udwSize = Common.NETDEMO_PICTURE_SIZE;
                        stRecordInfo.stCompareInfo.stSnapshotImage.stArea = new NETDEV_FACE_ALARM_IMAGE_AREA_S();
                        stRecordInfo.stCompareInfo.pstPersonInfo = new Memory(Common.NETDEMO_PICTURE_SIZE);
                        bRet = NetDemo.netdevsdk.NETDEV_FindNextFaceRecordDetail(lpFindRecordHandlePointer, stRecordInfo);
                        if(bRet == true)
                        {
                            String passTime = Common.timeStamp2Date(String.valueOf(stRecordInfo.udwPassTime),NetDemo.DateFormat);
                            String strTime = Common.getDate();
                            //nvr 没有大图 String strFileNameBig = NetDemo.strPicturePath  + "_" + "PassTime_"+ stRecordInfo.udwPassTime + "_" + "_" + strTime +"BigImage.jpg";
                            String imgName = "PassTime_"+ stRecordInfo.udwPassTime + "_" + strTime +"SmallImage.jpg";
                            String strFileNameSmall = NetDemo.strPicturePath + imgName;
                            Common.savePicture(stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.pcData, stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.udwSize, strFileNameSmall);
                            BaseDeviceFaceRecordDO faceRecordDO = new BaseDeviceFaceRecordDO();
                            faceRecordDO.setPatient(patient);
                            faceRecordDO.setName(name);
                            faceRecordDO.setPassTime(passTime);
                            faceRecordDO.setCreateTime(new Date());
                            faceRecordDO.setImg(baseFaceImg+imgName);
                            faceRecordDao.save(faceRecordDO);
                        }
                        else
                        {
                            break;
                        }
                    }
                    bRet = NetDemo.netdevsdk.NETDEV_FindCloseFaceRecordDetail(lpFindRecordHandlePointer);
                    if(bRet != true)
                    {
                        logger.info("关闭人脸记录详情失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
                    }
                    if(stResultInfo.udwTotal <= stFindCond.dwFirstRow)
                    {
                        break;
                    }
                    stFindCond.dwFirstRow += stFindCond.dwPageRow;
                }
                else
                {
                    logger.info("查询结束");
                    break;
                }
            }
            faceDO.setSynTime(endTime);
            devicePatientFaceDao.save(faceDO);
        }while (endTime.compareTo(DateUtil.getNextMinute(DateUtil.getStringDate(), -30))<0);
        return null;
    }
    /**
     * 更新人脸库人员数据
     */
    public String updPatientFace(){
        if(null == NetDemo.lpUserID){
            return "未登录,请先登录";
        }
        Pointer pPersonLibHandle = NetDemo.netdevsdk.NETDEV_FindPersonLibList(NetDemo.lpUserID);
        if(null == pPersonLibHandle){
            return "获取人员库列表失败, "+NetDemo.netdevsdk.NETDEV_GetLastError();
        }
        else
        {
            boolean bRet = false;
            while(true)
            {
                NETDEV_LIB_INFO_S stPersonLibInfo = new NETDEV_LIB_INFO_S();
                bRet = NetDemo.netdevsdk.NETDEV_FindNextPersonLibInfo(pPersonLibHandle, stPersonLibInfo);
                if(false == bRet)
                {
                    logger.info("获取下一个人员库列表失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
                    break;
                }
                String szName = Common.byteArrayToString(stPersonLibInfo.szName);
                NetDemo.mapPersonLib.put(szName, stPersonLibInfo);
                logger.info("人脸信息--szName:"+Common.byteArrayToString(stPersonLibInfo.szName));
            }
            //关闭资源
            bRet = NetDemo.netdevsdk.NETDEV_FindClosePersonLibList(pPersonLibHandle);
            if(false == bRet)
            {
                return "关闭人脸库资源失败:"+ NetDemo.netdevsdk.NETDEV_GetLastError();
            }
        }
        if(NetDemo.mapPersonLib.size()==0){
            return "人员库不存在";
        }
        for (NETDEV_LIB_INFO_S stPersonLibInfo: NetDemo.mapPersonLib.values()){
            NETDEV_PERSON_QUERY_INFO_S stQueryInfo = new NETDEV_PERSON_QUERY_INFO_S();
            stQueryInfo.udwNum = 0;
            stQueryInfo.udwOffset =  0;
            stQueryInfo.udwLimit = 16;
            NETDEV_BATCH_OPERATE_BASIC_S stQueryResultInfo = new NETDEV_BATCH_OPERATE_BASIC_S();
            boolean bRet = false;
            while(true)
            {
                Pointer lpPersonFindHandle = NetDemo.netdevsdk.NETDEV_FindPersonInfoList(NetDemo.lpUserID, stPersonLibInfo.udwID, stQueryInfo, stQueryResultInfo);
                if(lpPersonFindHandle == null || stQueryResultInfo.udwTotal == 0)
                {
                    logger.info("获取人员列表失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
                    break;
                }
                else
                {
                    stQueryInfo.udwOffset += stQueryInfo.udwLimit;
                    while(true)
                    {
                        NETDEV_PERSON_INFO_S stPersonInfo = new NETDEV_PERSON_INFO_S();
                        stPersonInfo.stRegionInfo = new NETDEV_REGION_INFO_S();
                        stPersonInfo.stImageInfo[0] = new NETDEV_IMAGE_INFO_S();
                        stPersonInfo.stImageInfo[0].stFileInfo = new NETDEV_FILE_INFO_S();
                        stPersonInfo.stImageInfo[0].stFileInfo.udwSize = 1048576;
                        stPersonInfo.stImageInfo[0].stFileInfo.pcData = new Memory(stPersonInfo.stImageInfo[0].stFileInfo.udwSize);
                        stPersonInfo.write();
                        bRet = NetDemo.netdevsdk.NETDEV_FindNextPersonInfo(lpPersonFindHandle, stPersonInfo);
                        if(bRet != true)
                        {
                            break;
                        }
                        else
                        {
                            String udwPersonID = stPersonInfo.udwPersonID+"";
                            String szPersonName = Common.byteArrayToString(stPersonInfo.szPersonName);
                            if(stPersonInfo.udwIdentificationNum > 0){
                                String szNumber = Common.byteArrayToString(stPersonInfo.stIdentificationInfo[0].szNumber);
                                BaseDevicePatientFaceDO faceDO = devicePatientFaceDao.findByIdcard(szNumber);
                                if(faceDO == null){
                                    BasePatientDO patientDO = patientDao.findByIdcard(szNumber);
                                    if(patientDO!=null){
                                        faceDO = new BaseDevicePatientFaceDO();
                                        faceDO.setFaceId(udwPersonID);
                                        faceDO.setIdcard(szNumber);
                                        faceDO.setType(1);
                                        faceDO.setName(szPersonName);
                                        faceDO.setCreateTime(new Date());
                                        faceDO.setPatient(patientDO.getId());
                                        devicePatientFaceDao.save(faceDO);
                                    }
                                }
                            }else{
                                logger.info("人员没有身份证-- udwPersonID:"+udwPersonID
                                        +",szPersonName:"+szPersonName);
                            }
                        }
                    }
                    //关闭资源
                    bRet = NetDemo.netdevsdk.NETDEV_FindClosePersonInfoList(lpPersonFindHandle);
                    if(bRet == false)
                    {
                        logger.info("关闭人员列表资源失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
                    }
                }
                if(stQueryInfo.udwOffset >= stQueryResultInfo.udwTotal)
                {
                    break;
                }
            }
        }
        return null;
    }
    /**
     * 查找人员库
     */
    public void findPersonLib() {
        if(null == NetDemo.lpUserID)
        {
            logger.info("未登录,请先登录");
            return;
        }
        boolean bRet = false;
        Pointer pPersonLibHandle = NetDemo.netdevsdk.NETDEV_FindPersonLibList(NetDemo.lpUserID);
        if(null == pPersonLibHandle)
        {
            logger.info("获取人员库列表失败{}", NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
        else
        {
            while(true)
            {
                NETDEV_LIB_INFO_S stPersonLibInfo = new NETDEV_LIB_INFO_S();
                bRet = NetDemo.netdevsdk.NETDEV_FindNextPersonLibInfo(pPersonLibHandle, stPersonLibInfo);
                if(false == bRet)
                {
                    logger.info("获取下一个人员库列表失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
                    break;
                }
                NetDemo.mapPersonLib.put(Common.byteArrayToString(stPersonLibInfo.szName), stPersonLibInfo);
                logger.info("人脸信息--szName:"+Common.byteArrayToString(stPersonLibInfo.szName)
                        +",udwID:"+stPersonLibInfo.udwID
                        +",udwType:"+stPersonLibInfo.udwType
                        +",udwPersonNum:"+stPersonLibInfo.udwPersonNum
                        +",udwFaceNum:"+stPersonLibInfo.udwFaceNum
                        +",udwMemberNum:"+stPersonLibInfo.udwMemberNum
                        +",udwLastChange:"+stPersonLibInfo.udwLastChange
                        +",szBelongIndex:"+Common.byteArrayToString(stPersonLibInfo.szBelongIndex)
                        +",bIsMonitored:"+stPersonLibInfo.bIsMonitored
                        +",byRes:"+Common.byteArrayToString(stPersonLibInfo.byRes));
            }
            //关闭资源
            bRet = NetDemo.netdevsdk.NETDEV_FindClosePersonLibList(pPersonLibHandle);
            if(false == bRet)
            {
                logger.info("关闭人脸库资源失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
                return;
            }
        }
    }
    /**
     * 查找人员(必须先查找人员库)
     * @param szName
     */
    public void findPerson(String szName) {
        if(null == NetDemo.lpUserID){
            logger.info("未登录,请先登录");
            return;
        }
        if(NetDemo.mapPersonLib.size()==0)
        {
            logger.info("请先查找人员库");
            return;
        }
        if(StringUtils.isBlank(szName))
        {
            logger.info("请输入查找的人员库名称");
            return;
        }
        NETDEV_LIB_INFO_S stPersonLibInfo = NetDemo.mapPersonLib.get(szName);
        NETDEV_PERSON_QUERY_INFO_S stQueryInfo = new NETDEV_PERSON_QUERY_INFO_S();
        stQueryInfo.udwNum = 0;
        stQueryInfo.udwOffset =  0;
        stQueryInfo.udwLimit = 16;
        NETDEV_BATCH_OPERATE_BASIC_S stQueryResultInfo = new NETDEV_BATCH_OPERATE_BASIC_S();
        boolean bRet = false;
        NetDemo.mapPersonInfo.clear();
        while(true)
        {
            Pointer lpPersonFindHandle = NetDemo.netdevsdk.NETDEV_FindPersonInfoList(NetDemo.lpUserID, stPersonLibInfo.udwID, stQueryInfo, stQueryResultInfo);
            if(lpPersonFindHandle == null || stQueryResultInfo.udwTotal == 0)
            {
                logger.info("获取人员列表失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
                break;
            }
            else
            {
                stQueryInfo.udwOffset += stQueryInfo.udwLimit;
                while(true)
                {
                    NETDEV_PERSON_INFO_S stPersonInfo = new NETDEV_PERSON_INFO_S();
                    stPersonInfo.stRegionInfo = new NETDEV_REGION_INFO_S();
                    stPersonInfo.stImageInfo[0] = new NETDEV_IMAGE_INFO_S();
                    stPersonInfo.stImageInfo[0].stFileInfo = new NETDEV_FILE_INFO_S();
                    stPersonInfo.stImageInfo[0].stFileInfo.udwSize = 1048576;
                    stPersonInfo.stImageInfo[0].stFileInfo.pcData = new Memory(stPersonInfo.stImageInfo[0].stFileInfo.udwSize);
                    stPersonInfo.write();
                    bRet = NetDemo.netdevsdk.NETDEV_FindNextPersonInfo(lpPersonFindHandle, stPersonInfo);
                    if(bRet != true)
                    {
                        break;
                    }
                    else
                    {
                        NetDemo.mapPersonInfo.put(String.valueOf(stPersonInfo.udwPersonID), stPersonInfo);
                        Vector<String> PersonLibVector = new Vector<String>();
                        PersonLibVector.add(String.valueOf(stPersonInfo.udwPersonID));
                        PersonLibVector.add(Common.byteArrayToString(stPersonInfo.szPersonName));
                        if(stPersonInfo.udwGender == NETDEV_GENDER_TYPE_E.NETDEV_GENDER_TYPE_MAN)
                        {
                            PersonLibVector.add("man");
                        }
                        else if(stPersonInfo.udwGender == NETDEV_GENDER_TYPE_E.NETDEV_GENDER_TYPE_WOMAN)
                        {
                            PersonLibVector.add("woman");
                        }
                        else
                        {
                            PersonLibVector.add("unknow");
                        }
                        PersonLibVector.add(Common.byteArrayToString(stPersonInfo.szBirthday));
                        PersonLibVector.add(Common.byteArrayToString(stPersonInfo.stRegionInfo.szNation));
                        PersonLibVector.add(Common.byteArrayToString(stPersonInfo.stRegionInfo.szProvince));
                        PersonLibVector.add(Common.byteArrayToString(stPersonInfo.stRegionInfo.szCity));
                        if(stPersonInfo.udwIdentificationNum > 0)
                        {
                            if(stPersonInfo.stIdentificationInfo[0].udwType == NETDEV_ID_TYPE_E.NETDEV_CERTIFICATE_TYPE_ID)
                            {
                                PersonLibVector.add("Identity card");
                            }
                            else if(stPersonInfo.stIdentificationInfo[0].udwType == NETDEV_ID_TYPE_E.NETDEV_CERTIFICATE_TYPE_PASSPORT)
                            {
                                PersonLibVector.add("Passport");
                            }
                            else if(stPersonInfo.stIdentificationInfo[0].udwType == NETDEV_ID_TYPE_E.NETDEV_CERTIFICATE_TYPE_DRIVING_LICENSE)
                            {
                                PersonLibVector.add("Driving license");
                            }
                            else
                            {
                                PersonLibVector.add("other");
                            }
                            PersonLibVector.add(Common.byteArrayToString(stPersonInfo.stIdentificationInfo[0].szNumber));
                        }
                        if(stPersonInfo.udwIdentificationNum > 0){
                            logger.info("人员-- udwPersonID:"+stPersonInfo.udwPersonID
                                    +",szPersonName:"+Common.byteArrayToString(stPersonInfo.szPersonName)
                                    +",udwGender:"+stPersonInfo.udwGender
                                    +",szBirthday:"+Common.byteArrayToString(stPersonInfo.szBirthday)
                                    +",szNation:"+Common.byteArrayToString(stPersonInfo.stRegionInfo.szNation)
                                    +",szProvince:"+Common.byteArrayToString(stPersonInfo.stRegionInfo.szProvince)
                                    +",szCity:"+Common.byteArrayToString(stPersonInfo.stRegionInfo.szCity)
                                    +",udwType:"+stPersonInfo.stIdentificationInfo[0].udwType
                                    +",szNumber:"+Common.byteArrayToString(stPersonInfo.stIdentificationInfo[0].szNumber));
                        }else{
                            logger.info("人员-- udwPersonID:"+stPersonInfo.udwPersonID
                                    +",szPersonName:"+Common.byteArrayToString(stPersonInfo.szPersonName)
                                    +",udwGender:"+stPersonInfo.udwGender
                                    +",szBirthday:"+Common.byteArrayToString(stPersonInfo.szBirthday)
                                    +",szNation:"+Common.byteArrayToString(stPersonInfo.stRegionInfo.szNation)
                                    +",szProvince:"+Common.byteArrayToString(stPersonInfo.stRegionInfo.szProvince)
                                    +",szCity:"+Common.byteArrayToString(stPersonInfo.stRegionInfo.szCity));
                        }
                    }
                }
                //关闭资源
                bRet = NetDemo.netdevsdk.NETDEV_FindClosePersonInfoList(lpPersonFindHandle);
                if(bRet == false)
                {
                    logger.info("关闭人员列表资源失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
                }
            }
            if(stQueryInfo.udwOffset >= stQueryResultInfo.udwTotal)
            {
                break;
            }
        }
    }
    /**
     * 4.25.14 人脸识别记录
     */
    public void queryPassRecord(String strBeginTime,String strEndTime,String getPersonPassAlarmSource) {
        if(null == NetDemo.lpUserID)
        {
            logger.info("未登录,请先登录");
            return;
        }
        if(false == Common.isValidDate(strBeginTime,NetDemo.DateFormat) ||false == Common.isValidDate(strEndTime, NetDemo.DateFormat))
        {
            logger.info("请输入开始时间结束时间");
            return;
        }
        long get1=Common.date2TimeStamp(strBeginTime,NetDemo.DateFormat);
        long get2=Common.date2TimeStamp(strEndTime, NetDemo.DateFormat);
        if(get1>get2)
        {
            logger.info("开始时间不能大于结束时间");
            return;
        }
        NETDEV_ALARM_LOG_COND_LIST_S stFindCond = new NETDEV_ALARM_LOG_COND_LIST_S();
        stFindCond.dwPageRow = 16;
        stFindCond.dwFirstRow = 0;
        if(StringUtils.isBlank(getPersonPassAlarmSource))
        {
            logger.info("没有告警源");
            stFindCond.dwCondSize = 5;
            stFindCond.astCondition[0] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[1] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[2] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[3] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[4] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[0].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
            stFindCond.astCondition[0].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_LESS;
            Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(strBeginTime, NetDemo.DateFormat)), stFindCond.astCondition[0].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
            stFindCond.astCondition[1].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
            stFindCond.astCondition[1].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_GREATER;
            Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(strEndTime, NetDemo.DateFormat)), stFindCond.astCondition[1].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
            stFindCond.astCondition[2].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
            stFindCond.astCondition[2].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_DESC_ORDER;
            Common.stringToByteArray("", stFindCond.astCondition[2].szConditionData);
            stFindCond.astCondition[3].dwQueryType = 57;
            stFindCond.astCondition[3].dwLogicFlag = 0;
            Common.stringToByteArray("1", stFindCond.astCondition[3].szConditionData);
            stFindCond.astCondition[4].dwQueryType = 58;
            stFindCond.astCondition[4].dwLogicFlag = 0;
            Common.stringToByteArray("330103193303040742", stFindCond.astCondition[4].szConditionData);
        }
        else
        {
            stFindCond.dwCondSize = 4;
            stFindCond.astCondition[0] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[1] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[2] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[3] = new NETDEV_QUERY_INFO_S();
            stFindCond.astCondition[0].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
            stFindCond.astCondition[0].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_LESS;
            Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(strBeginTime, NetDemo.DateFormat)), stFindCond.astCondition[0].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
            stFindCond.astCondition[1].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
            stFindCond.astCondition[1].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_GREATER;
            Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(strEndTime, NetDemo.DateFormat)), stFindCond.astCondition[1].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
            stFindCond.astCondition[2].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
            stFindCond.astCondition[2].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_DESC_ORDER;
            Common.stringToByteArray("", stFindCond.astCondition[2].szConditionData);
            stFindCond.astCondition[3].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_ALARMSRCNAME;
            stFindCond.astCondition[3].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_DIM_QUERY;
            Common.stringToByteArray(getPersonPassAlarmSource, stFindCond.astCondition[3].szConditionData);
        }
        NETDEV_SMART_ALARM_LOG_RESULT_INFO_S stResultInfo = new NETDEV_SMART_ALARM_LOG_RESULT_INFO_S();
        boolean bRet = false;
        while(true)
        {
            Pointer lpFindRecordHandlePointer = NetDemo.netdevsdk.NETDEV_FindFaceRecordDetailList(NetDemo.lpUserID, stFindCond, stResultInfo);
            if(lpFindRecordHandlePointer != null)
            {
                while(true)
                {
                    logger.info("人脸数据stFindCond.dwFirstRow:"+stFindCond.dwFirstRow);
                    NETDEV_FACE_RECORD_SNAPSHOT_INFO_S stRecordInfo = new NETDEV_FACE_RECORD_SNAPSHOT_INFO_S();
                    stRecordInfo.stCompareInfo = new NETDEV_FACE_ALARM_CMP_INFO_S();
                    stRecordInfo.stCompareInfo.stMemberInfo = new NETDEV_FACE_MEMBER_INFO_S();
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberRegionInfo = new NETDEV_FACE_MEMBER_REGION_INFO_S();
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberIDInfo = new NETDEV_FACE_MEMBER_ID_INFO_S();
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo = new NETDEV_FILE_INFO_S();
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo.udwSize = Common.NETDEMO_PICTURE_SIZE;
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo = new NETDEV_FILE_INFO_S();
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo.udwSize = Common.NETDEMO_PICTURE_SIZE;
                    stRecordInfo.stCompareInfo.stSnapshotImage = new NETDEV_FACE_ALARM_SNAP_IMAGE_S();
                    stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage = new NETDEV_FILE_INFO_S();
                    stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
                    stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage.udwSize = Common.NETDEMO_PICTURE_SIZE;
                    stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage = new NETDEV_FILE_INFO_S();
                    stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
                    stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.udwSize = Common.NETDEMO_PICTURE_SIZE;
                    stRecordInfo.stCompareInfo.stSnapshotImage.stArea = new NETDEV_FACE_ALARM_IMAGE_AREA_S();
                    bRet = NetDemo.netdevsdk.NETDEV_FindNextFaceRecordDetail(lpFindRecordHandlePointer, stRecordInfo);
                    if(bRet == true)
                    {
                        logger.info("szMemberName="+Common.byteArrayToString(stRecordInfo.stCompareInfo.stMemberInfo.szMemberName));
                        String strTime = Common.getDate();
                        String strFileNameBig = NetDemo.strPicturePath  + "_" + "PassTime_"+ stRecordInfo.udwPassTime + "_" + "_" + strTime +"BigImage.jpg";
                        String strFileNameSmall = NetDemo.strPicturePath + "_" + "PassTime_"+ stRecordInfo.udwPassTime + "_" + strTime +"SmallImage.jpg";
                        Common.savePicture(stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.pcData, stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.udwSize, strFileNameSmall);
                    }
                    else
                    {
                        break;
                    }
                }
                bRet = NetDemo.netdevsdk.NETDEV_FindCloseFaceRecordDetail(lpFindRecordHandlePointer);
                if(bRet != true)
                {
                    logger.info("关闭人脸记录详情失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
                    return;
                }
                if(stResultInfo.udwTotal <= stFindCond.dwFirstRow)
                {
                    break;
                }
                stFindCond.dwFirstRow += stFindCond.dwPageRow;
            }
            else
            {
                String strPicPath = System.getProperty("user.dir").replaceAll("%20"," ") +File.separator +"Picture";
                logger.info("查询结束.路径:"+strPicPath);
                break;
            }
        }
    }
    /**
     * 告警记录 //数据量较大,建议采用分页形式展示
     * @param strBeginTime
     */
    public static void queryAlarmRecord(String strBeginTime,String strEndTime,Integer monitorType) {
        if(null == NetDemo.lpUserID)
        {
            logger.info("未登录,请先登录");
            return;
        }
        if(false == Common.isValidDate(strBeginTime, NetDemo.DateFormat) ||false == Common.isValidDate(strEndTime,NetDemo.DateFormat))
        {
            logger.info("Please check that the time format is correct.");
            return;
        }
        long get1=Common.date2TimeStamp(strBeginTime,NetDemo.DateFormat);
        long get2=Common.date2TimeStamp(strEndTime, NetDemo.DateFormat);
        if(get1>get2) {
            logger.info(" Start time can not more than end time");
            return;
        }
        NETDEV_ALARM_LOG_COND_LIST_S stFindCond = new NETDEV_ALARM_LOG_COND_LIST_S();
        stFindCond.dwPageRow = 16;
        stFindCond.dwFirstRow = 0;
        stFindCond.dwCondSize = 4;
        stFindCond.astCondition[0] = new NETDEV_QUERY_INFO_S();
        stFindCond.astCondition[1] = new NETDEV_QUERY_INFO_S();
        stFindCond.astCondition[2] = new NETDEV_QUERY_INFO_S();
        stFindCond.astCondition[3] = new NETDEV_QUERY_INFO_S();
        stFindCond.astCondition[0].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_ALARMTYPE;
        stFindCond.astCondition[0].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_EQUAL;
        if(monitorType == 0)
        {
            Common.stringToByteArray("1018", stFindCond.astCondition[0].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
        }
        else if(monitorType == 1)
        {
            Common.stringToByteArray("1020", stFindCond.astCondition[0].szConditionData);   //NETDEV_ALARM_SMART_FACE_MISMATCH_LIST
        }
        stFindCond.astCondition[1].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
        stFindCond.astCondition[1].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_LESS;
        Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(strBeginTime, NetDemo.DateFormat)), stFindCond.astCondition[1].szConditionData);
        stFindCond.astCondition[2].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
        stFindCond.astCondition[2].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_GREATER;
        Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(strEndTime, NetDemo.DateFormat)), stFindCond.astCondition[2].szConditionData);
        stFindCond.astCondition[3].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
        stFindCond.astCondition[3].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_DESC_ORDER;
        Common.stringToByteArray("", stFindCond.astCondition[3].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
        NETDEV_SMART_ALARM_LOG_RESULT_INFO_S  stResultInfo = new NETDEV_SMART_ALARM_LOG_RESULT_INFO_S();
        boolean bRet = false;
        while(true)
        {
            logger.info("告警记录1");
            Pointer lpFindRecordHandlePointer = NetDemo.netdevsdk.NETDEV_FindFaceRecordDetailList(NetDemo.lpUserID, stFindCond, stResultInfo);
            if(lpFindRecordHandlePointer != null)
            {
                while(true)
                {
                    logger.info("人脸数据1");
                    NETDEV_FACE_RECORD_SNAPSHOT_INFO_S stRecordInfo = new NETDEV_FACE_RECORD_SNAPSHOT_INFO_S();
                    stRecordInfo.stCompareInfo = new NETDEV_FACE_ALARM_CMP_INFO_S();
                    stRecordInfo.stCompareInfo.stMemberInfo = new NETDEV_FACE_MEMBER_INFO_S();
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberRegionInfo = new NETDEV_FACE_MEMBER_REGION_INFO_S();
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberIDInfo = new NETDEV_FACE_MEMBER_ID_INFO_S();
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo = new NETDEV_FILE_INFO_S();
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo.udwSize = Common.NETDEMO_PICTURE_SIZE;
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo = new NETDEV_FILE_INFO_S();
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo.udwSize = Common.NETDEMO_PICTURE_SIZE;
                    stRecordInfo.stCompareInfo.stSnapshotImage = new NETDEV_FACE_ALARM_SNAP_IMAGE_S();
                    stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage = new NETDEV_FILE_INFO_S();
                    stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
                    stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage.udwSize = Common.NETDEMO_PICTURE_SIZE;
                    stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage = new NETDEV_FILE_INFO_S();
                    stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
                    stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.udwSize = Common.NETDEMO_PICTURE_SIZE;
                    stRecordInfo.stCompareInfo.stSnapshotImage.stArea = new NETDEV_FACE_ALARM_IMAGE_AREA_S();
                    bRet = NetDemo.netdevsdk.NETDEV_FindNextFaceRecordDetail(lpFindRecordHandlePointer, stRecordInfo);
                    if(bRet == true)
                    {
                        String strTime = Common.getDate();
//                        if(NetDemo.jComboBoxDeviceType.getSelectedIndex() == 1)
//package com.yihu.jw.care.netdevsdk;
//
//import com.alibaba.fastjson.JSONObject;
//import com.sun.jna.Memory;
//import com.sun.jna.Pointer;
//import com.sun.jna.Structure;
//import com.yihu.jw.care.dao.face.BaseDeviceFaceRecordDao;
//import com.yihu.jw.care.dao.face.BaseDevicePatientFaceDao;
//import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib;
//import com.yihu.jw.care.netdevsdk.lib.NetDEVSDKLib.*;
//import com.yihu.jw.care.netdevsdk.util.Common;
//import com.yihu.jw.entity.base.patient.BasePatientDO;
//import com.yihu.jw.entity.care.device.BaseDeviceFaceRecordDO;
//import com.yihu.jw.entity.care.device.BaseDevicePatientFaceDO;
//import com.yihu.jw.patient.dao.BasePatientDao;
//import com.yihu.jw.util.date.DateUtil;
//import org.apache.commons.lang.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.io.File;
//import java.io.FileOutputStream;
//import java.io.IOException;
//import java.util.Date;
//import java.util.List;
//import java.util.Vector;
//
///**
// * 宇视人脸摄像头sdk
// * Created by yeshijie on 2022/5/19.
// */
//@Service
//public class NetDevSdkService {
//
//    @Autowired
//    private BaseDevicePatientFaceDao devicePatientFaceDao;
//    @Autowired
//    private BaseDeviceFaceRecordDao faceRecordDao;
//    @Autowired
//    private BasePatientDao patientDao;
//
//    private static final Logger logger = LoggerFactory.getLogger(NetDevSdkService.class);
//
//    // http://zhyzh.gongshu.gov.cn:3001/ 开vpn后可以本地调试
//    //IP:10.18.50.18   账号admin  密码Admin12345@    HTTP端口80  HTTPS端口  443  RTSP端口 554
//    private static final int dwPort = 80;//端口号 443
////    private static final int dwPort = 3001;//端口号 443
//    private static final String strUserName = "admin";//用户名
//    private static final String strPassword = "Admin12345@";//密码
////    private static final String strIPAddr = "zhyzh.gongshu.gov.cn";//ip地址
//    private static final String strIPAddr = "10.18.50.18";//ip地址
//    private static final Integer dwLoginProto = 1; /* 登录协议 0:onvif 1:私有*/
//    private static final Integer dwDeviceType = 1; /* 设备类型 IPC/NVR */
//    private static final String baseFaceImg = "https://zhyzh.gongshu.gov.cn/face/";
//
//    public void init(){
//        initSDK();
//        initLogin();
//    }
//
//    /**
//     * 初始化sdk
//     */
//    private void initSDK(){
//        String strLogPath = "./sdklog/";
//        boolean bRet = NetDemo.netdevsdk.NETDEV_SetLogPath(strLogPath);
//        if(false == bRet){
//            logger.info("日志路径设置失败:"+ NetDemo.netdevsdk.NETDEV_GetLastError());
//        }
//
//        bRet = NetDemo.netdevsdk.NETDEV_Init();
//        if(false == bRet){
//            logger.info("sdk初始化失败:"+NetDemo.netdevsdk.NETDEV_GetLastError());
//            return;
//        }
//
//        try {
//            Common.updateStructureByReferenceMethod = Structure.class.getDeclaredMethod("updateStructureByReference", Class.class, Structure.class, Pointer.class);
//            Common.updateStructureByReferenceMethod.setAccessible(true);
//        } catch (Exception e) {
//            throw new RuntimeException(e);
//        }
//
//        File file=new File(NetDemo.strPicturePath);
//        if(!file.exists()){
//            file.mkdir();
//        }
//    }
//
//    /**
//     * SDK清理
//     */
//    private void cleanupSDK(){
//        NetDemo.netdevsdk.NETDEV_Cleanup();
//    }
//
//    /**
//     * 登录
//     */
//    public void initLogin(){
//        NETDEV_DEVICE_LOGIN_INFO_S stDevLoginInfo = new NETDEV_DEVICE_LOGIN_INFO_S();
//        System.arraycopy(strUserName.getBytes(), 0, stDevLoginInfo.szUserName, 0, strUserName.getBytes().length);
//        System.arraycopy(strPassword.getBytes(), 0, stDevLoginInfo.szPassword, 0, strPassword.getBytes().length);
//        System.arraycopy(strIPAddr.getBytes(), 0, stDevLoginInfo.szIPAddr, 0, strIPAddr.getBytes().length);
//        stDevLoginInfo.dwPort = dwPort;
//        stDevLoginInfo.dwLoginProto = dwLoginProto;
//        NETDEV_SELOG_INFO_S stSELogInfo = new NETDEV_SELOG_INFO_S();
//
//        NetDemo.lpUserID = NetDemo.netdevsdk.NETDEV_Login_V30(stDevLoginInfo, stSELogInfo);
//        if(NetDemo.lpUserID!=null){
//            //4.25.5 注册人脸抓拍上报回调函数
//            NetDemo.netdevsdk.NETDEV_SetFaceSnapshotCallBack(NetDemo.lpUserID,  cbFaceSnapshotCallBack, null);
//        }else{
//            logger.info("登录sdk失败,error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
//            return;
//        }
//
//        //获取设备信息
//        NetDemo.pstDeviceInfo = new NETDEV_DEVICE_BASE_INFO_S();
//        NetDemo.pstDeviceInfo.write();
//        boolean bRet = NetDemo.netdevsdk.NETDEV_GetDeviceBaseInfo(NetDemo.lpUserID,NetDemo.pstDeviceInfo);
//        if(bRet != true){
//            logger.info("获取设备信息失败:" + NetDemo.netdevsdk.NETDEV_GetLastError());
//            return;
//        }
//        NetDemo.pstDeviceInfo.read();
//
//    }
//
//    /**
//     * 获取设备信息
//     * @return
//     */
//    public JSONObject pstDeviceInfo(){
//        JSONObject jsonObject = new JSONObject();
//        if(NetDemo.pstDeviceInfo==null){
//            logger.info("请先登录设备");
//            return null;
//        }
//
//        jsonObject.put("dwChlID",NetDemo.pstDeviceInfo.dwChlID);//视频输入通道号  Video input channel ID
//        jsonObject.put("dwDeviceType",NetDemo.pstDeviceInfo.dwDeviceType);//设备类型
//        jsonObject.put("dwDevCode",NetDemo.pstDeviceInfo.dwDevCode);//设备编号
//        jsonObject.put("dwCurrentLang",NetDemo.pstDeviceInfo.dwCurrentLang);//设备当前语言 参见枚举#NETDEV_LANG_TYPE_E Current language NETDEV_LANG_TYPE_E*
//        jsonObject.put("stBuildDate",NetDemo.pstDeviceInfo.stBuildDate.dwYear
//                +"-"+NetDemo.pstDeviceInfo.stBuildDate.dwMonth
//                +"-"+NetDemo.pstDeviceInfo.stBuildDate.dwDay
//                +" "+NetDemo.pstDeviceInfo.stBuildDate.dwHour
//                +":"+NetDemo.pstDeviceInfo.stBuildDate.dwMinute);//发布时间
//        jsonObject.put("szSerialNum",Common.byteArrayToString(NetDemo.pstDeviceInfo.szSerialNum));//设备序列号
//        jsonObject.put("szMacAddress",Common.byteArrayToString(NetDemo.pstDeviceInfo.szMacAddress));//IPv4的Mac地址
//        jsonObject.put("szDevName",Common.byteArrayToString(NetDemo.pstDeviceInfo.szDevName));//设备名称
//        jsonObject.put("szDevModel",Common.byteArrayToString(NetDemo.pstDeviceInfo.szDevModel));//设备型号
//        jsonObject.put("szVIIDVersion",Common.byteArrayToString(NetDemo.pstDeviceInfo.szVIIDVersion));//视图库组件版本号
//        jsonObject.put("szSoftwareVersion",Common.byteArrayToString(NetDemo.pstDeviceInfo.szSoftwareVersion));//内部软件版本
//        jsonObject.put("szFirmwareVersion",Common.byteArrayToString(NetDemo.pstDeviceInfo.szFirmwareVersion));//软件版本号
//        jsonObject.put("szHardewareID",Common.byteArrayToString(NetDemo.pstDeviceInfo.szHardewareID));//硬件标识
//        jsonObject.put("szUbootVersion",Common.byteArrayToString(NetDemo.pstDeviceInfo.szUbootVersion));//UBOOT引导版本
//        jsonObject.put("szManufacturer",Common.byteArrayToString(NetDemo.pstDeviceInfo.szManufacturer));//厂商名称
//        jsonObject.put("szProtoName",Common.byteArrayToString(NetDemo.pstDeviceInfo.szProtoName));//设备原型机名称
//
//        jsonObject.put("dwChlID",NetDemo.pstDeviceInfo.dwChlID);//
//        return jsonObject;
//    }
//
//    /**
//     * 设备搜索回调
//     */
//    public void discoveryDevice(){
//        boolean flag1 = NetDemo.netdevsdk.NETDEV_SetDiscoveryCallBack(cbDiscoveryCallBack, null);
//        boolean flag2 = NetDemo.netdevsdk.NETDEV_Discovery("0.0.0.0", "0.0.0.0");
//        logger.info("flag1:"+flag1+",flag2:"+flag2);
//    }
//
//    /**
//     * 订阅告警信息
//     */
//    public void SubscribeAlarm() {
//        if(null == NetDemo.lpUserID)
//        {
//            logger.info("未登录,请先登录");
//            return;
//        }
//        boolean bRet = NetDemo.netdevsdk.NETDEV_SetAlarmCallBack_V30(NetDemo.lpUserID, cbAlarmMessCallBack, null);
//        if(bRet) {
//            logger.info("订阅告警信息成功");
//        }else {
//            logger.info("订阅告警信息失败,错误码"+ NetDemo.netdevsdk.NETDEV_GetLastError());
//        }
//    }
//
//    /**
//     * 取消订阅告警信息
//     */
//    public void UnSubscribeAlarm() {
//        if(null == NetDemo.lpUserID)
//        {
//            logger.info("未登录,请先登录");
//            return;
//        }
//        boolean bRet = NetDemo.netdevsdk.NETDEV_SetAlarmCallBack_V30(NetDemo.lpUserID, null, null);
//        if(bRet==false) {
//            logger.info("取消订阅告警信息失败,错误码"+ NetDemo.netdevsdk.NETDEV_GetLastError());
//            return;
//        }else {
//            logger.info("取消订阅告警信息成功");
//        }
//    }
//
//    /**
//     * 4.25.7 注册人脸报警消息回调函数
//     */
//    public void registerPersonAlarm() {
//        if(null == NetDemo.lpUserID)
//        {
//            logger.info("未登录,请先登录");
//            return;
//        }
//        boolean bRet = NetDemo.netdevsdk.NETDEV_SetPersonAlarmCallBack(NetDemo.lpUserID, personAlarmMessCB, NetDemo.lpUserID);
//        if(false == bRet)
//        {
//            logger.info("设置人脸报警消息回调方法失败,错误码"+NetDemo.netdevsdk.NETDEV_GetLastError());
//            return;
//        }
//
//        NETDEV_LAPI_SUB_INFO_S stSubInfo = new NETDEV_LAPI_SUB_INFO_S();
//        stSubInfo.udwType = 16;
//        stSubInfo.udwLibIDNum = 0xffff;
//        NETDEV_SUBSCRIBE_SUCC_INFO_S stSubSuccInfo = new NETDEV_SUBSCRIBE_SUCC_INFO_S();
//        bRet = NetDemo.netdevsdk.NETDEV_SubscibeLapiAlarm(NetDemo.lpUserID, stSubInfo, stSubSuccInfo);
//        if(false == bRet){
//            logger.info("注册人脸报警消息失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
//            return;
//        }else {
//            logger.info("注册人脸报警消息");
//        }
//        NetDemo.dwPersonRecognizeMointerID = stSubSuccInfo.udwID;
//    }
//    /**
//     * 取消注册人脸报警消息回调函数
//     */
//    public static void cancelRegisterPersonAlarm() {
//        if(null == NetDemo.lpUserID)
//        {
//            logger.info("未登录,请先登录");
//            return;
//        }
//        boolean bRet = NetDemo.netdevsdk.NETDEV_UnSubLapiAlarm(NetDemo.lpUserID, NetDemo.dwPersonRecognizeMointerID);
//        if(false == bRet)
//        {
//            logger.info("取消注册人脸报警消息失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
//            return;
//        }
//        else
//        {
//            logger.info("取消成功");
//        }
//        NetDemo.dwPersonRecognizeMointerID = -1;
//    }
//
//    /**
//     * 同步人脸数据
//     */
//    public void synPatientFaceRecords(){
//        List<BaseDevicePatientFaceDO> list = devicePatientFaceDao.findListByType(1);
//        for (BaseDevicePatientFaceDO faceDO:list){
//            try {
//                sysPatientFaceRecord(faceDO);
//            }catch (Exception e){
//                e.printStackTrace();
//            }
//        }
//    }
//
//    public String sysPatientFaceRecord(BaseDevicePatientFaceDO faceDO){
//        String endTime = "";
//        String idcard = faceDO.getIdcard();
//        String patient = faceDO.getPatient();
//        String name = faceDO.getName();
//        int minus = 30;
//        if(null == NetDemo.lpUserID){
//            return "未登录,请先登录";
//        }
//        if (StringUtils.isBlank(idcard)){
//            return "身份证不能为空";
//        }
//
//        if(StringUtils.isNotBlank(faceDO.getSynTime())&&faceDO.getSynTime().compareTo(DateUtil.getNextMinute(DateUtil.getStringDate(), -minus))>0){
//            return "同步时间必须晚于当前时间30分钟";
//        }
//
//        do {
//            String startTime = faceDO.getSynTime();
//            if(StringUtils.isBlank(startTime)){
//                //第一次取当前时间的前30分钟数据
//                endTime = DateUtil.getStringDate();
//                startTime = DateUtil.getNextMinute(endTime, -minus);
//            }else{
//                endTime = DateUtil.getNextMinute(startTime, minus);//采集30分钟后的数据
//            }
//            logger.info(name+",startTime="+startTime+",endTime="+endTime);
//            NETDEV_ALARM_LOG_COND_LIST_S stFindCond = new NETDEV_ALARM_LOG_COND_LIST_S();
//            stFindCond.dwPageRow = 5;
//            stFindCond.dwFirstRow = 0;
//
//            stFindCond.dwCondSize = 5;
//            stFindCond.astCondition[0] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[1] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[2] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[3] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[4] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[0].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
//            stFindCond.astCondition[0].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_GREATER;
//            Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(startTime, NetDemo.DateFormat)), stFindCond.astCondition[0].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
//            stFindCond.astCondition[1].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
//            stFindCond.astCondition[1].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_GREATER;
//            Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(endTime, NetDemo.DateFormat)), stFindCond.astCondition[1].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
//            stFindCond.astCondition[2].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
//            stFindCond.astCondition[2].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_DESC_ORDER;
//            Common.stringToByteArray("", stFindCond.astCondition[2].szConditionData);
//
//            stFindCond.astCondition[3].dwQueryType = 57;
//            stFindCond.astCondition[3].dwLogicFlag = 0;
//            //1表示匹配成功
//            Common.stringToByteArray("1", stFindCond.astCondition[3].szConditionData);
//
//            stFindCond.astCondition[4].dwQueryType = 58;
//            stFindCond.astCondition[4].dwLogicFlag = 0;
//            Common.stringToByteArray(idcard, stFindCond.astCondition[4].szConditionData);
//
//
//            NETDEV_SMART_ALARM_LOG_RESULT_INFO_S stResultInfo = new NETDEV_SMART_ALARM_LOG_RESULT_INFO_S();
//            boolean bRet = false;
//            while(true)
//            {
//                Pointer lpFindRecordHandlePointer = NetDemo.netdevsdk.NETDEV_FindFaceRecordDetailList(NetDemo.lpUserID, stFindCond, stResultInfo);
//                logger.info("告警记录总数udwTotal:"+stResultInfo.udwTotal);
//                logger.info("此次返回告警记录个数udwNum:"+stResultInfo.udwNum);
//                if(lpFindRecordHandlePointer != null)
//                {
//                    while(true)
//                    {
//                        logger.info("人脸数据stFindCond.dwFirstRow:"+stFindCond.dwFirstRow);
//                        NETDEV_FACE_RECORD_SNAPSHOT_INFO_S stRecordInfo = new NETDEV_FACE_RECORD_SNAPSHOT_INFO_S();
//                        stRecordInfo.stCompareInfo = new NETDEV_FACE_ALARM_CMP_INFO_S();
//                        stRecordInfo.stCompareInfo.stMemberInfo = new NETDEV_FACE_MEMBER_INFO_S();
//                        stRecordInfo.stCompareInfo.stMemberInfo.stMemberRegionInfo = new NETDEV_FACE_MEMBER_REGION_INFO_S();
//                        stRecordInfo.stCompareInfo.stMemberInfo.stMemberIDInfo = new NETDEV_FACE_MEMBER_ID_INFO_S();
//                        stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo = new NETDEV_FILE_INFO_S();
//                        stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                        stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo.udwSize = Common.NETDEMO_PICTURE_SIZE;
//                        stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo = new NETDEV_FILE_INFO_S();
//                        stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                        stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo.udwSize = Common.NETDEMO_PICTURE_SIZE;
//                        stRecordInfo.stCompareInfo.stSnapshotImage = new NETDEV_FACE_ALARM_SNAP_IMAGE_S();
//                        stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage = new NETDEV_FILE_INFO_S();
//                        stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                        stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage.udwSize = Common.NETDEMO_PICTURE_SIZE;
//                        stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage = new NETDEV_FILE_INFO_S();
//                        stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                        stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.udwSize = Common.NETDEMO_PICTURE_SIZE;
//                        stRecordInfo.stCompareInfo.stSnapshotImage.stArea = new NETDEV_FACE_ALARM_IMAGE_AREA_S();
//                        stRecordInfo.stCompareInfo.pstPersonInfo = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                        bRet = NetDemo.netdevsdk.NETDEV_FindNextFaceRecordDetail(lpFindRecordHandlePointer, stRecordInfo);
//                        if(bRet == true)
//                        {
//                            String passTime = Common.timeStamp2Date(String.valueOf(stRecordInfo.udwPassTime),NetDemo.DateFormat);
//                            String strTime = Common.getDate();
//                            //nvr 没有大图 String strFileNameBig = NetDemo.strPicturePath  + "_" + "PassTime_"+ stRecordInfo.udwPassTime + "_" + "_" + strTime +"BigImage.jpg";
//                            String imgName = "PassTime_"+ stRecordInfo.udwPassTime + "_" + strTime +"SmallImage.jpg";
//                            String strFileNameSmall = NetDemo.strPicturePath + imgName;
//                            Common.savePicture(stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.pcData, stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.udwSize, strFileNameSmall);
//                            BaseDeviceFaceRecordDO faceRecordDO = new BaseDeviceFaceRecordDO();
//                            faceRecordDO.setPatient(patient);
//                            faceRecordDO.setName(name);
//                            faceRecordDO.setPassTime(passTime);
//                            faceRecordDO.setCreateTime(new Date());
//                            faceRecordDO.setImg(baseFaceImg+imgName);
//                            faceRecordDao.save(faceRecordDO);
//                        }
//                        else
//                        {
//                            break;
//                        }
//                    }
//                    bRet = NetDemo.netdevsdk.NETDEV_FindCloseFaceRecordDetail(lpFindRecordHandlePointer);
//                    if(bRet != true)
//                    {
//                        logger.info("关闭人脸记录详情失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
//                    }
//                    if(stResultInfo.udwTotal <= stFindCond.dwFirstRow)
//                    {
//                        break;
//                    }
//                    stFindCond.dwFirstRow += stFindCond.dwPageRow;
//                }
//                else
//                {
//                    logger.info("查询结束");
//                    break;
//                }
//            }
//            faceDO.setSynTime(endTime);
//            devicePatientFaceDao.save(faceDO);
//        }while (endTime.compareTo(DateUtil.getNextMinute(DateUtil.getStringDate(), -minus))<0);
//        return null;
//    }
//
//    /**
//     * 更新人脸库人员数据
//     */
//    public String updPatientFace(){
//        if(null == NetDemo.lpUserID){
//            return "未登录,请先登录";
//        }
//
//        Pointer pPersonLibHandle = NetDemo.netdevsdk.NETDEV_FindPersonLibList(NetDemo.lpUserID);
//        if(null == pPersonLibHandle){
//            return "获取人员库列表失败, "+NetDemo.netdevsdk.NETDEV_GetLastError();
//        }
//        else
//        {
//            boolean bRet = false;
//            while(true)
//            {
//                NETDEV_LIB_INFO_S stPersonLibInfo = new NETDEV_LIB_INFO_S();
//                bRet = NetDemo.netdevsdk.NETDEV_FindNextPersonLibInfo(pPersonLibHandle, stPersonLibInfo);
//                if(false == bRet)
//                {
//                    logger.info("获取下一个人员库列表失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
//                    break;
//                }
//                String szName = Common.byteArrayToString(stPersonLibInfo.szName);
//                NetDemo.mapPersonLib.put(szName, stPersonLibInfo);
//                logger.info("人脸信息--szName:"+Common.byteArrayToString(stPersonLibInfo.szName));
//            }
//            //关闭资源
//            bRet = NetDemo.netdevsdk.NETDEV_FindClosePersonLibList(pPersonLibHandle);
//            if(false == bRet)
//            {
//                return "关闭人脸库资源失败:"+ NetDemo.netdevsdk.NETDEV_GetLastError();
//            }
//        }
//
//        if(NetDemo.mapPersonLib.size()==0){
//            return "人员库不存在";
//        }
//
//        for (NETDEV_LIB_INFO_S stPersonLibInfo: NetDemo.mapPersonLib.values()){
//            NETDEV_PERSON_QUERY_INFO_S stQueryInfo = new NETDEV_PERSON_QUERY_INFO_S();
//            stQueryInfo.udwNum = 0;
//            stQueryInfo.udwOffset =  0;
//            stQueryInfo.udwLimit = 16;
//            NETDEV_BATCH_OPERATE_BASIC_S stQueryResultInfo = new NETDEV_BATCH_OPERATE_BASIC_S();
//            boolean bRet = false;
//            while(true)
//            {
//                Pointer lpPersonFindHandle = NetDemo.netdevsdk.NETDEV_FindPersonInfoList(NetDemo.lpUserID, stPersonLibInfo.udwID, stQueryInfo, stQueryResultInfo);
//                if(lpPersonFindHandle == null || stQueryResultInfo.udwTotal == 0)
//                {
//                    logger.info("获取人员列表失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
//                    break;
//                }
//                else
//                {
//                    stQueryInfo.udwOffset += stQueryInfo.udwLimit;
//                    while(true)
//                    {
//                        NETDEV_PERSON_INFO_S stPersonInfo = new NETDEV_PERSON_INFO_S();
//                        stPersonInfo.stRegionInfo = new NETDEV_REGION_INFO_S();
//
//                        stPersonInfo.stImageInfo[0] = new NETDEV_IMAGE_INFO_S();
//                        stPersonInfo.stImageInfo[0].stFileInfo = new NETDEV_FILE_INFO_S();
//                        stPersonInfo.stImageInfo[0].stFileInfo.udwSize = 1048576;
//                        stPersonInfo.stImageInfo[0].stFileInfo.pcData = new Memory(stPersonInfo.stImageInfo[0].stFileInfo.udwSize);
//                        stPersonInfo.write();
//                        bRet = NetDemo.netdevsdk.NETDEV_FindNextPersonInfo(lpPersonFindHandle, stPersonInfo);
//                        if(bRet != true)
//                        {
//                            break;
//                        }
//                        else
//                        {
//                            String udwPersonID = stPersonInfo.udwPersonID+"";
//                            String szPersonName = Common.byteArrayToString(stPersonInfo.szPersonName);
//                            if(stPersonInfo.udwIdentificationNum > 0){
//                                String szNumber = Common.byteArrayToString(stPersonInfo.stIdentificationInfo[0].szNumber);
//                                BaseDevicePatientFaceDO faceDO = devicePatientFaceDao.findByIdcard(szNumber);
//                                if(faceDO == null){
//                                    BasePatientDO patientDO = patientDao.findByIdcard(szNumber);
//                                    if(patientDO!=null){
//                                        faceDO = new BaseDevicePatientFaceDO();
//                                        faceDO.setFaceId(udwPersonID);
//                                        faceDO.setIdcard(szNumber);
//                                        faceDO.setType(1);
//                                        faceDO.setName(szPersonName);
//                                        faceDO.setCreateTime(new Date());
//                                        faceDO.setPatient(patientDO.getId());
//                                        devicePatientFaceDao.save(faceDO);
//                                    }
//                                }
//                            }else{
//                                logger.info("人员没有身份证-- udwPersonID:"+udwPersonID
//                                        +",szPersonName:"+szPersonName);
//                            }
//                        }
//                    }
//                    //关闭资源
//                    bRet = NetDemo.netdevsdk.NETDEV_FindClosePersonInfoList(lpPersonFindHandle);
//                    if(bRet == false)
//                    {
//                        logger.info("关闭人员列表资源失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
//                    }
//                }
//                if(stQueryInfo.udwOffset >= stQueryResultInfo.udwTotal)
//                {
//                    break;
//                }
//            }
//        }
//
//        return null;
//    }
//
//    /**
//     * 查找人员库
//     */
//    public void findPersonLib() {
//        if(null == NetDemo.lpUserID)
//        {
//            logger.info("未登录,请先登录");
//            return;
//        }
//        boolean bRet = false;
//
//        Pointer pPersonLibHandle = NetDemo.netdevsdk.NETDEV_FindPersonLibList(NetDemo.lpUserID);
//        if(null == pPersonLibHandle)
//        {
//            logger.info("获取人员库列表失败{}", NetDemo.netdevsdk.NETDEV_GetLastError());
//            return;
//        }
//        else
//        {
//            while(true)
//            {
//                NETDEV_LIB_INFO_S stPersonLibInfo = new NETDEV_LIB_INFO_S();
//                bRet = NetDemo.netdevsdk.NETDEV_FindNextPersonLibInfo(pPersonLibHandle, stPersonLibInfo);
//                if(false == bRet)
//                {
//                    logger.info("获取下一个人员库列表失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
//                    break;
//                }
//                NetDemo.mapPersonLib.put(Common.byteArrayToString(stPersonLibInfo.szName), stPersonLibInfo);
//                logger.info("人脸信息--szName:"+Common.byteArrayToString(stPersonLibInfo.szName)
//                        +",udwID:"+stPersonLibInfo.udwID
//                        +",udwType:"+stPersonLibInfo.udwType
//                        +",udwPersonNum:"+stPersonLibInfo.udwPersonNum
//                        +",udwFaceNum:"+stPersonLibInfo.udwFaceNum
//                        +",udwMemberNum:"+stPersonLibInfo.udwMemberNum
//                        +",udwLastChange:"+stPersonLibInfo.udwLastChange
//                        +",szBelongIndex:"+Common.byteArrayToString(stPersonLibInfo.szBelongIndex)
//                        +",bIsMonitored:"+stPersonLibInfo.bIsMonitored
//                        +",byRes:"+Common.byteArrayToString(stPersonLibInfo.byRes));
//
//            }
//            //关闭资源
//            bRet = NetDemo.netdevsdk.NETDEV_FindClosePersonLibList(pPersonLibHandle);
//            if(false == bRet)
//            {
//                logger.info("关闭人脸库资源失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
//                return;
//            }
//        }
//    }
//
//    /**
//     * 查找人员(必须先查找人员库)
//     * @param szName
//     */
//    public void findPerson(String szName) {
//        if(null == NetDemo.lpUserID){
//            logger.info("未登录,请先登录");
//            return;
//        }
//        if(NetDemo.mapPersonLib.size()==0)
//        {
//            logger.info("请先查找人员库");
//            return;
//        }
//        if(StringUtils.isBlank(szName))
//        {
//            logger.info("请输入查找的人员库名称");
//            return;
//        }
//
//        NETDEV_LIB_INFO_S stPersonLibInfo = NetDemo.mapPersonLib.get(szName);
//        NETDEV_PERSON_QUERY_INFO_S stQueryInfo = new NETDEV_PERSON_QUERY_INFO_S();
//        stQueryInfo.udwNum = 0;
//        stQueryInfo.udwOffset =  0;
//        stQueryInfo.udwLimit = 16;
//        NETDEV_BATCH_OPERATE_BASIC_S stQueryResultInfo = new NETDEV_BATCH_OPERATE_BASIC_S();
//        boolean bRet = false;
//        NetDemo.mapPersonInfo.clear();
//        while(true)
//        {
//            Pointer lpPersonFindHandle = NetDemo.netdevsdk.NETDEV_FindPersonInfoList(NetDemo.lpUserID, stPersonLibInfo.udwID, stQueryInfo, stQueryResultInfo);
//            if(lpPersonFindHandle == null || stQueryResultInfo.udwTotal == 0)
//            {
//                logger.info("获取人员列表失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
//                break;
//            }
//            else
//            {
//                stQueryInfo.udwOffset += stQueryInfo.udwLimit;
//                while(true)
//                {
//                    NETDEV_PERSON_INFO_S stPersonInfo = new NETDEV_PERSON_INFO_S();
//                    stPersonInfo.stRegionInfo = new NETDEV_REGION_INFO_S();
//
//                    stPersonInfo.stImageInfo[0] = new NETDEV_IMAGE_INFO_S();
//                    stPersonInfo.stImageInfo[0].stFileInfo = new NETDEV_FILE_INFO_S();
//                    stPersonInfo.stImageInfo[0].stFileInfo.udwSize = 1048576;
//                    stPersonInfo.stImageInfo[0].stFileInfo.pcData = new Memory(stPersonInfo.stImageInfo[0].stFileInfo.udwSize);
//                    stPersonInfo.write();
//                    bRet = NetDemo.netdevsdk.NETDEV_FindNextPersonInfo(lpPersonFindHandle, stPersonInfo);
//                    if(bRet != true)
//                    {
//                        break;
//                    }
//                    else
//                    {
//                        NetDemo.mapPersonInfo.put(String.valueOf(stPersonInfo.udwPersonID), stPersonInfo);
//                        Vector<String> PersonLibVector = new Vector<String>();
//                        PersonLibVector.add(String.valueOf(stPersonInfo.udwPersonID));
//                        PersonLibVector.add(Common.byteArrayToString(stPersonInfo.szPersonName));
//
//                        if(stPersonInfo.udwGender == NETDEV_GENDER_TYPE_E.NETDEV_GENDER_TYPE_MAN)
//                        {
//                            PersonLibVector.add("man");
//                        }
//                        else if(stPersonInfo.udwGender == NETDEV_GENDER_TYPE_E.NETDEV_GENDER_TYPE_WOMAN)
//                        {
                            String strFileNameBig = NetDemo.strPicturePath + strTime +"BigImage.jpg";
                            NETDEV_FILE_INFO_S stFileInfo = new NETDEV_FILE_INFO_S();
                            stFileInfo.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
                            stFileInfo.udwSize = Common.NETDEMO_PICTURE_SIZE;
                            bRet = NetDemo.netdevsdk.NETDEV_GetFaceRecordImageInfo(NetDemo.lpUserID, stRecordInfo.udwRecordID, 0, stFileInfo);
                            if(bRet == true)
                            {
                                Common.savePicture(stFileInfo.pcData, stFileInfo.udwSize, strFileNameBig);
                            }else {
                                System.out.printf("Get picture failed failed,error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
                            }
//                            PersonLibVector.add("woman");
//                        }
                        String strFileNameSmall = NetDemo.strPicturePath + strTime +"SmallImage.jpg";
                        Common.savePicture(stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.pcData, stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.udwSize, strFileNameSmall);
                    }
                    else
                    {
                        break;
                    }
                }
                bRet = NetDemo.netdevsdk.NETDEV_FindCloseFaceRecordDetail(lpFindRecordHandlePointer);
                if(bRet != true)
                {
                    logger.info("NETDEV_FindCloseFaceRecordDetail failed:"+NetDemo.netdevsdk.NETDEV_GetLastError());
                    return;
                }
                if(stFindCond.dwFirstRow >= stResultInfo.udwTotal)
                {
                    break;
                }
                stFindCond.dwFirstRow += stFindCond.dwPageRow;
            }
            else
            {   String strPicPath = System.getProperty("user.dir").replaceAll("%20"," ") + File.separator +"Picture";
                logger.info("Query ended.The path:"+strPicPath);
                break;
            }
        }
    }
    /**
     * 门禁查询出入记录 对接设备没有门禁记录
     */
    public void searchAccessRecords(String startTime,String endTime,String persionId) {
        if(null == NetDemo.lpUserID)
        {
            logger.info("未登录,请先登录");
            return;
        }
        NETDEV_ALARM_LOG_COND_LIST_S pstFindCond=new NETDEV_ALARM_LOG_COND_LIST_S();
        pstFindCond.dwPageRow=8;
        pstFindCond.dwFirstRow=0;
        pstFindCond.dwCondSize=3;
        pstFindCond.astCondition[0]=new NETDEV_QUERY_INFO_S();
        pstFindCond.astCondition[0].dwQueryType=4;
        pstFindCond.astCondition[0].dwLogicFlag=3;
        long get1=Common.date2TimeStamp(startTime, NetDemo.DateFormat);
        String getStartTime=Long.toString(get1);
        Common.stringToByteArray(getStartTime, pstFindCond.astCondition[0].szConditionData);
        pstFindCond.astCondition[1]=new NETDEV_QUERY_INFO_S();
        pstFindCond.astCondition[1].dwQueryType=4;
        pstFindCond.astCondition[1].dwLogicFlag=4;
        long get2=Common.date2TimeStamp(endTime, NetDemo.DateFormat);
        if(get1>get2)
        {
            logger.info("开始时间不能大于结束时间");
            return;
        }
        String getendtTime=Long.toString(get2);
        Common.stringToByteArray(getendtTime, pstFindCond.astCondition[1].szConditionData);
        pstFindCond.astCondition[2]=new NETDEV_QUERY_INFO_S();
        pstFindCond.astCondition[2].dwQueryType=4;
        pstFindCond.astCondition[2].dwLogicFlag=9;
        Common.stringToByteArray(getendtTime, pstFindCond.astCondition[2].szConditionData);
        logger.info("pstFindCond.astCondition.length:"+ pstFindCond.astCondition.length);
//        if(StringUtils.isNotBlank(persionId)){
//            //人员id
//            pstFindCond.astCondition[3]=new NETDEV_QUERY_INFO_S();
//            pstFindCond.astCondition[3].dwQueryType=79;
//            pstFindCond.astCondition[3].dwLogicFlag=0;
//            Common.stringToByteArray(persionId, pstFindCond.astCondition[3].szConditionData);
//                        else
//                        {
//                            PersonLibVector.add("unknow");
//                        }
//
//                        PersonLibVector.add(Common.byteArrayToString(stPersonInfo.szBirthday));
//
//                        PersonLibVector.add(Common.byteArrayToString(stPersonInfo.stRegionInfo.szNation));
//                        PersonLibVector.add(Common.byteArrayToString(stPersonInfo.stRegionInfo.szProvince));
//                        PersonLibVector.add(Common.byteArrayToString(stPersonInfo.stRegionInfo.szCity));
//
//                        if(stPersonInfo.udwIdentificationNum > 0)
//                        {
//                            if(stPersonInfo.stIdentificationInfo[0].udwType == NETDEV_ID_TYPE_E.NETDEV_CERTIFICATE_TYPE_ID)
//                            {
//                                PersonLibVector.add("Identity card");
//                            }
//                            else if(stPersonInfo.stIdentificationInfo[0].udwType == NETDEV_ID_TYPE_E.NETDEV_CERTIFICATE_TYPE_PASSPORT)
//                            {
//                                PersonLibVector.add("Passport");
//                            }
//                            else if(stPersonInfo.stIdentificationInfo[0].udwType == NETDEV_ID_TYPE_E.NETDEV_CERTIFICATE_TYPE_DRIVING_LICENSE)
//                            {
//                                PersonLibVector.add("Driving license");
//                            }
//                            else
//                            {
//                                PersonLibVector.add("other");
//                            }
//                            PersonLibVector.add(Common.byteArrayToString(stPersonInfo.stIdentificationInfo[0].szNumber));
//                        }
//
//                        if(stPersonInfo.udwIdentificationNum > 0){
//                            logger.info("人员-- udwPersonID:"+stPersonInfo.udwPersonID
//                                    +",szPersonName:"+Common.byteArrayToString(stPersonInfo.szPersonName)
//                                    +",udwGender:"+stPersonInfo.udwGender
//                                    +",szBirthday:"+Common.byteArrayToString(stPersonInfo.szBirthday)
//                                    +",szNation:"+Common.byteArrayToString(stPersonInfo.stRegionInfo.szNation)
//                                    +",szProvince:"+Common.byteArrayToString(stPersonInfo.stRegionInfo.szProvince)
//                                    +",szCity:"+Common.byteArrayToString(stPersonInfo.stRegionInfo.szCity)
//                                    +",udwType:"+stPersonInfo.stIdentificationInfo[0].udwType
//                                    +",szNumber:"+Common.byteArrayToString(stPersonInfo.stIdentificationInfo[0].szNumber));
//                        }else{
//                            logger.info("人员-- udwPersonID:"+stPersonInfo.udwPersonID
//                                    +",szPersonName:"+Common.byteArrayToString(stPersonInfo.szPersonName)
//                                    +",udwGender:"+stPersonInfo.udwGender
//                                    +",szBirthday:"+Common.byteArrayToString(stPersonInfo.szBirthday)
//                                    +",szNation:"+Common.byteArrayToString(stPersonInfo.stRegionInfo.szNation)
//                                    +",szProvince:"+Common.byteArrayToString(stPersonInfo.stRegionInfo.szProvince)
//                                    +",szCity:"+Common.byteArrayToString(stPersonInfo.stRegionInfo.szCity));
//                        }
//                    }
//                }
//                //关闭资源
//                bRet = NetDemo.netdevsdk.NETDEV_FindClosePersonInfoList(lpPersonFindHandle);
//                if(bRet == false)
//                {
//                    logger.info("关闭人员列表资源失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
//                }
//            }
//            if(stQueryInfo.udwOffset >= stQueryResultInfo.udwTotal)
//            {
//                break;
//            }
//        }
//    }
//
//    /**
//     * 4.25.14 人脸识别记录
//     */
//    public void queryPassRecord(String strBeginTime,String strEndTime,String getPersonPassAlarmSource) {
//        if(null == NetDemo.lpUserID)
//        {
//            logger.info("未登录,请先登录");
//            return;
//        }
//
//        if(false == Common.isValidDate(strBeginTime,NetDemo.DateFormat) ||false == Common.isValidDate(strEndTime, NetDemo.DateFormat))
//        {
//            logger.info("请输入开始时间结束时间");
//            return;
//        }
//
//        long get1=Common.date2TimeStamp(strBeginTime,NetDemo.DateFormat);
//        long get2=Common.date2TimeStamp(strEndTime, NetDemo.DateFormat);
//        if(get1>get2)
//        {
//            logger.info("开始时间不能大于结束时间");
//            return;
//        }
//        NETDEV_ALARM_LOG_COND_LIST_S stFindCond = new NETDEV_ALARM_LOG_COND_LIST_S();
//        stFindCond.dwPageRow = 16;
//        stFindCond.dwFirstRow = 0;
//        if(StringUtils.isBlank(getPersonPassAlarmSource))
//        {
//            logger.info("没有告警源");
//            stFindCond.dwCondSize = 5;
//            stFindCond.astCondition[0] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[1] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[2] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[3] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[4] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[0].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
//            stFindCond.astCondition[0].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_LESS;
//            Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(strBeginTime, NetDemo.DateFormat)), stFindCond.astCondition[0].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
//            stFindCond.astCondition[1].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
//            stFindCond.astCondition[1].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_GREATER;
//            Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(strEndTime, NetDemo.DateFormat)), stFindCond.astCondition[1].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
//            stFindCond.astCondition[2].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
//            stFindCond.astCondition[2].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_DESC_ORDER;
//            Common.stringToByteArray("", stFindCond.astCondition[2].szConditionData);
//
//            stFindCond.astCondition[3].dwQueryType = 57;
//            stFindCond.astCondition[3].dwLogicFlag = 0;
//            Common.stringToByteArray("1", stFindCond.astCondition[3].szConditionData);
//
//            stFindCond.astCondition[4].dwQueryType = 58;
//            stFindCond.astCondition[4].dwLogicFlag = 0;
//            Common.stringToByteArray("330103193303040742", stFindCond.astCondition[4].szConditionData);
//        }
//        else
//        {
//            stFindCond.dwCondSize = 4;
//            stFindCond.astCondition[0] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[1] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[2] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[3] = new NETDEV_QUERY_INFO_S();
//            stFindCond.astCondition[0].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
//            stFindCond.astCondition[0].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_LESS;
//            Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(strBeginTime, NetDemo.DateFormat)), stFindCond.astCondition[0].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
//            stFindCond.astCondition[1].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
//            stFindCond.astCondition[1].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_GREATER;
//            Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(strEndTime, NetDemo.DateFormat)), stFindCond.astCondition[1].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
//            stFindCond.astCondition[2].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
//            stFindCond.astCondition[2].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_DESC_ORDER;
//            Common.stringToByteArray("", stFindCond.astCondition[2].szConditionData);
//            stFindCond.astCondition[3].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_ALARMSRCNAME;
//            stFindCond.astCondition[3].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_DIM_QUERY;
//            Common.stringToByteArray(getPersonPassAlarmSource, stFindCond.astCondition[3].szConditionData);
//        }
//        NETDEV_SMART_ALARM_LOG_RESULT_INFO_S stResultInfo = new NETDEV_SMART_ALARM_LOG_RESULT_INFO_S();
//        boolean bRet = false;
//        while(true)
//        {
//            Pointer lpFindRecordHandlePointer = NetDemo.netdevsdk.NETDEV_FindFaceRecordDetailList(NetDemo.lpUserID, stFindCond, stResultInfo);
//            if(lpFindRecordHandlePointer != null)
//            {
//
//                while(true)
//                {
//                    logger.info("人脸数据stFindCond.dwFirstRow:"+stFindCond.dwFirstRow);
//                    NETDEV_FACE_RECORD_SNAPSHOT_INFO_S stRecordInfo = new NETDEV_FACE_RECORD_SNAPSHOT_INFO_S();
//                    stRecordInfo.stCompareInfo = new NETDEV_FACE_ALARM_CMP_INFO_S();
//                    stRecordInfo.stCompareInfo.stMemberInfo = new NETDEV_FACE_MEMBER_INFO_S();
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberRegionInfo = new NETDEV_FACE_MEMBER_REGION_INFO_S();
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberIDInfo = new NETDEV_FACE_MEMBER_ID_INFO_S();
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo = new NETDEV_FILE_INFO_S();
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo.udwSize = Common.NETDEMO_PICTURE_SIZE;
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo = new NETDEV_FILE_INFO_S();
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo.udwSize = Common.NETDEMO_PICTURE_SIZE;
//                    stRecordInfo.stCompareInfo.stSnapshotImage = new NETDEV_FACE_ALARM_SNAP_IMAGE_S();
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage = new NETDEV_FILE_INFO_S();
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage.udwSize = Common.NETDEMO_PICTURE_SIZE;
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage = new NETDEV_FILE_INFO_S();
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.udwSize = Common.NETDEMO_PICTURE_SIZE;
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stArea = new NETDEV_FACE_ALARM_IMAGE_AREA_S();
//                    stRecordInfo.stCompareInfo.pstPersonInfo = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                    bRet = NetDemo.netdevsdk.NETDEV_FindNextFaceRecordDetail(lpFindRecordHandlePointer, stRecordInfo);
//                    if(bRet == true)
//                    {
//                        logger.info("szMemberName="+Common.byteArrayToString(stRecordInfo.stCompareInfo.stMemberInfo.szMemberName));
//                        String strTime = Common.getDate();
//                        String strFileNameBig = NetDemo.strPicturePath  + "_" + "PassTime_"+ stRecordInfo.udwPassTime + "_" + "_" + strTime +"BigImage.jpg";
//                        String strFileNameSmall = NetDemo.strPicturePath + "_" + "PassTime_"+ stRecordInfo.udwPassTime + "_" + strTime +"SmallImage.jpg";
//                        Common.savePicture(stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.pcData, stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.udwSize, strFileNameSmall);
//                    }
//                    else
//                    {
//                        break;
//                    }
//                }
//                bRet = NetDemo.netdevsdk.NETDEV_FindCloseFaceRecordDetail(lpFindRecordHandlePointer);
//                if(bRet != true)
//                {
//                    logger.info("关闭人脸记录详情失败:{}", NetDemo.netdevsdk.NETDEV_GetLastError());
//                    return;
//                }
//                if(stResultInfo.udwTotal <= stFindCond.dwFirstRow)
//                {
//                    break;
//                }
//                stFindCond.dwFirstRow += stFindCond.dwPageRow;
//            }
//            else
//            {
//                String strPicPath = System.getProperty("user.dir").replaceAll("%20"," ") +File.separator +"Picture";
//                logger.info("查询结束.路径:"+strPicPath);
//                break;
//            }
//        }
//    }
//
//    /**
//     * 告警记录 //数据量较大,建议采用分页形式展示
//     * @param strBeginTime
//     */
//    public static void queryAlarmRecord(String strBeginTime,String strEndTime,Integer monitorType) {
//        if(null == NetDemo.lpUserID)
//        {
//            logger.info("未登录,请先登录");
//            return;
//        }
//        if(false == Common.isValidDate(strBeginTime, NetDemo.DateFormat) ||false == Common.isValidDate(strEndTime,NetDemo.DateFormat))
//        {
//            logger.info("Please check that the time format is correct.");
//            return;
//        }
//        long get1=Common.date2TimeStamp(strBeginTime,NetDemo.DateFormat);
//        long get2=Common.date2TimeStamp(strEndTime, NetDemo.DateFormat);
//        if(get1>get2) {
//            logger.info(" Start time can not more than end time");
//            return;
//        }
//        NETDEV_ALARM_LOG_COND_LIST_S stFindCond = new NETDEV_ALARM_LOG_COND_LIST_S();
//        stFindCond.dwPageRow = 16;
//        stFindCond.dwFirstRow = 0;
//        stFindCond.dwCondSize = 4;
//        stFindCond.astCondition[0] = new NETDEV_QUERY_INFO_S();
//        stFindCond.astCondition[1] = new NETDEV_QUERY_INFO_S();
//        stFindCond.astCondition[2] = new NETDEV_QUERY_INFO_S();
//        stFindCond.astCondition[3] = new NETDEV_QUERY_INFO_S();
//        stFindCond.astCondition[0].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_ALARMTYPE;
//        stFindCond.astCondition[0].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_EQUAL;
//        if(monitorType == 0)
//        {
//            Common.stringToByteArray("1018", stFindCond.astCondition[0].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
//        }
//        else if(monitorType == 1)
//        {
//            Common.stringToByteArray("1020", stFindCond.astCondition[0].szConditionData);   //NETDEV_ALARM_SMART_FACE_MISMATCH_LIST
//        }
//        stFindCond.astCondition[1].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
//        stFindCond.astCondition[1].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_LESS;
//        Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(strBeginTime, NetDemo.DateFormat)), stFindCond.astCondition[1].szConditionData);
//
//        stFindCond.astCondition[2].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
//        stFindCond.astCondition[2].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_NO_GREATER;
//        Common.stringToByteArray(String.valueOf(Common.date2TimeStamp(strEndTime, NetDemo.DateFormat)), stFindCond.astCondition[2].szConditionData);
//
//        stFindCond.astCondition[3].dwQueryType = NETDEV_QUERYCOND_TYPE_E.NETDEV_QUERYCOND_TIME;
//        stFindCond.astCondition[3].dwLogicFlag = NETDEV_QUERYCOND_LOGICTYPE_E.NETDEV_QUERYCOND_LOGIC_DESC_ORDER;
//        Common.stringToByteArray("", stFindCond.astCondition[3].szConditionData);   //NETDEV_ALARM_SMART_FACE_MATCH_LIST
//
//        NETDEV_SMART_ALARM_LOG_RESULT_INFO_S  stResultInfo = new NETDEV_SMART_ALARM_LOG_RESULT_INFO_S();
//        boolean bRet = false;
//        while(true)
//        {
//            logger.info("告警记录1");
//            Pointer lpFindRecordHandlePointer = NetDemo.netdevsdk.NETDEV_FindFaceRecordDetailList(NetDemo.lpUserID, stFindCond, stResultInfo);
//            if(lpFindRecordHandlePointer != null)
//            {
//                while(true)
//                {
//                    logger.info("人脸数据1");
//                    NETDEV_FACE_RECORD_SNAPSHOT_INFO_S stRecordInfo = new NETDEV_FACE_RECORD_SNAPSHOT_INFO_S();
//                    stRecordInfo.stCompareInfo = new NETDEV_FACE_ALARM_CMP_INFO_S();
//                    stRecordInfo.stCompareInfo.stMemberInfo = new NETDEV_FACE_MEMBER_INFO_S();
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberRegionInfo = new NETDEV_FACE_MEMBER_REGION_INFO_S();
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberIDInfo = new NETDEV_FACE_MEMBER_ID_INFO_S();
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo = new NETDEV_FILE_INFO_S();
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberImageInfo.udwSize = Common.NETDEMO_PICTURE_SIZE;
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo = new NETDEV_FILE_INFO_S();
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                    stRecordInfo.stCompareInfo.stMemberInfo.stMemberSemiInfo.udwSize = Common.NETDEMO_PICTURE_SIZE;
//
//                    stRecordInfo.stCompareInfo.stSnapshotImage = new NETDEV_FACE_ALARM_SNAP_IMAGE_S();
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage = new NETDEV_FILE_INFO_S();
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stBigImage.udwSize = Common.NETDEMO_PICTURE_SIZE;
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage = new NETDEV_FILE_INFO_S();
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.udwSize = Common.NETDEMO_PICTURE_SIZE;
//                    stRecordInfo.stCompareInfo.stSnapshotImage.stArea = new NETDEV_FACE_ALARM_IMAGE_AREA_S();
//
//                    stRecordInfo.stCompareInfo.pstPersonInfo = new Memory(Common.NETDEMO_PICTURE_SIZE);
//
//                    bRet = NetDemo.netdevsdk.NETDEV_FindNextFaceRecordDetail(lpFindRecordHandlePointer, stRecordInfo);
//                    if(bRet == true)
//                    {
//                        String strTime = Common.getDate();
////                        if(NetDemo.jComboBoxDeviceType.getSelectedIndex() == 1)
////                        {
//                            String strFileNameBig = NetDemo.strPicturePath + strTime +"BigImage.jpg";
//                            NETDEV_FILE_INFO_S stFileInfo = new NETDEV_FILE_INFO_S();
//                            stFileInfo.pcData = new Memory(Common.NETDEMO_PICTURE_SIZE);
//                            stFileInfo.udwSize = Common.NETDEMO_PICTURE_SIZE;
//                            bRet = NetDemo.netdevsdk.NETDEV_GetFaceRecordImageInfo(NetDemo.lpUserID, stRecordInfo.udwRecordID, 0, stFileInfo);
//                            if(bRet == true)
//                            {
//                                Common.savePicture(stFileInfo.pcData, stFileInfo.udwSize, strFileNameBig);
//                            }else {
//                                System.out.printf("Get picture failed failed,error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
//                            }
////                        }
//                        String strFileNameSmall = NetDemo.strPicturePath + strTime +"SmallImage.jpg";
//                        Common.savePicture(stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.pcData, stRecordInfo.stCompareInfo.stSnapshotImage.stSmallImage.udwSize, strFileNameSmall);
//                    }
//                    else
//                    {
//                        break;
//                    }
//                }
//                bRet = NetDemo.netdevsdk.NETDEV_FindCloseFaceRecordDetail(lpFindRecordHandlePointer);
//                if(bRet != true)
//                {
//                    logger.info("NETDEV_FindCloseFaceRecordDetail failed:"+NetDemo.netdevsdk.NETDEV_GetLastError());
//                    return;
//                }
//                if(stFindCond.dwFirstRow >= stResultInfo.udwTotal)
//                {
//                    break;
//                }
//                stFindCond.dwFirstRow += stFindCond.dwPageRow;
//            }
//            else
//            {   String strPicPath = System.getProperty("user.dir").replaceAll("%20"," ") + File.separator +"Picture";
//                logger.info("Query ended.The path:"+strPicPath);
//                break;
//            }
//        }
//    }
//
//    /**
//     * 门禁查询出入记录 对接设备没有门禁记录
//     */
//    public void searchAccessRecords(String startTime,String endTime,String persionId) {
//        if(null == NetDemo.lpUserID)
//        {
//            logger.info("未登录,请先登录");
//            return;
//        }
//        NETDEV_ALARM_LOG_COND_LIST_S pstFindCond=new NETDEV_ALARM_LOG_COND_LIST_S();
//        pstFindCond.dwPageRow=8;
//        pstFindCond.dwFirstRow=0;
//        pstFindCond.dwCondSize=3;
//        pstFindCond.astCondition[0]=new NETDEV_QUERY_INFO_S();
//        pstFindCond.astCondition[0].dwQueryType=4;
//        pstFindCond.astCondition[0].dwLogicFlag=3;
//        long get1=Common.date2TimeStamp(startTime, NetDemo.DateFormat);
//        String getStartTime=Long.toString(get1);
//        Common.stringToByteArray(getStartTime, pstFindCond.astCondition[0].szConditionData);
//        pstFindCond.astCondition[1]=new NETDEV_QUERY_INFO_S();
//        pstFindCond.astCondition[1].dwQueryType=4;
//        pstFindCond.astCondition[1].dwLogicFlag=4;
//        long get2=Common.date2TimeStamp(endTime, NetDemo.DateFormat);
//        if(get1>get2)
//        {
//            logger.info("开始时间不能大于结束时间");
//            return;
//        }
//        String getendtTime=Long.toString(get2);
//        Common.stringToByteArray(getendtTime, pstFindCond.astCondition[1].szConditionData);
//        pstFindCond.astCondition[2]=new NETDEV_QUERY_INFO_S();
//        pstFindCond.astCondition[2].dwQueryType=4;
//        pstFindCond.astCondition[2].dwLogicFlag=9;
//        Common.stringToByteArray(getendtTime, pstFindCond.astCondition[2].szConditionData);
//
//        logger.info("pstFindCond.astCondition.length:"+ pstFindCond.astCondition.length);
////        if(StringUtils.isNotBlank(persionId)){
////            //人员id
////            pstFindCond.astCondition[3]=new NETDEV_QUERY_INFO_S();
////            pstFindCond.astCondition[3].dwQueryType=79;
////            pstFindCond.astCondition[3].dwLogicFlag=0;
////            Common.stringToByteArray(persionId, pstFindCond.astCondition[3].szConditionData);
////        }
//
//        NETDEV_BATCH_OPERATE_BASIC_S pstResultInfo=new NETDEV_BATCH_OPERATE_BASIC_S();
//        pstResultInfo.udwOffset=0;
//        pstFindCond.write();
//        pstResultInfo.write();
//        Pointer lpFindHandle= NetDemo.netdevsdk.NETDEV_FindACSAttendanceLogList(NetDemo.lpUserID,pstFindCond,pstResultInfo);
//        if(lpFindHandle!=null) {
//            NETDEV_ACS_ATTENDANCE_LOG_INFO_S pstACSLogInfo=new NETDEV_ACS_ATTENDANCE_LOG_INFO_S();
//            pstACSLogInfo.stCompareInfo=new NETDEV_COMPARE_INFO_S();
//            pstACSLogInfo.stCompareInfo.stPersonImage=new NETDEV_FILE_INFO_S();
//            pstACSLogInfo.stCompareInfo.stPersonImage.pcData=new Memory(1048576);
//            pstACSLogInfo.stCompareInfo.stSnapshotImage=new NETDEV_FILE_INFO_S();
//            pstACSLogInfo.stCompareInfo.stSnapshotImage.pcData=new Memory(1048576);
//
//            logger.info("stSnapshotImage.szUrl="+Common.byteArrayToString(pstACSLogInfo.stCompareInfo.stSnapshotImage.szUrl));
//
//            pstACSLogInfo.stFaceAttr=new NETDEV_FACE_ATTR_S();
//            pstACSLogInfo.write();
//            boolean flag = true;
//            int i = 0;
//            NetDemo.getRowData=new Vector();
//            do {
//                boolean nextAcs= NetDemo.netdevsdk.NETDEV_FindNextACSAttendanceLog(lpFindHandle,pstACSLogInfo);
//                if(!nextAcs) {
//                    break;
//                }
//                pstACSLogInfo.read();
//                pstResultInfo.read();
////              分页数据
//                try {
//                    Vector data=new Vector();
//                    data.add(i+1);
//                    String szName=Common.byteArrayToString(pstACSLogInfo.szPersonName);
//                    data.add(szName);
//                    Long getTime=pstACSLogInfo.tTimeStamp;
//                    String new1=String.valueOf(getTime);
//                    String getNewDateTime=Common.timeStamp2Date(new1, NetDemo.DateFormat);
//                    String deptName=Common.byteArrayToString(pstACSLogInfo.szDoorName);
//
//                    int direct=pstACSLogInfo.udwDoorDirect;
//                    String getDirect=null;
//                    if(direct==0) {
//                        getDirect="in";
//                    }else if(direct==1) {
//                        getDirect="out";
//                    }else {
//                        getDirect="unknow";
//                    }
//
//                    data.add(getNewDateTime);
//                    data.add(deptName);
//                    data.add(getDirect);
//                    data.add(pstACSLogInfo.stFaceAttr.fTemperature);
//
//                    NetDemo.getRowData.add(data);
//
//                    logger.info("门禁记录-- szPersonName:"+Common.byteArrayToString(pstACSLogInfo.szPersonName)
//                            +",getNewDateTime:"+getNewDateTime
//                            +",deptName:"+deptName
//                            +",getDirect:"+getDirect
//                            +",fTemperature:"+pstACSLogInfo.stFaceAttr.fTemperature
//                    );
//                }catch(Exception eee) {
//                }i++;
//            }
//            while (flag && i < 8);
//
//        }
//        else
//        {
//            logger.info("未找到记录");
//            return;
//        }
//        NetDemo.netdevsdk.NETDEV_FindCloseACSAttendanceLogList(lpFindHandle);
//
//        int pageSize=0;
//        if(pstResultInfo.udwTotal>0) {
//            if(pstResultInfo.udwTotal%8==0) {
//                try {
//                    pageSize=pstResultInfo.udwTotal/8;
//                }catch(Exception m) {
//
//                }
//            }else {
//                try {
//                    pageSize=(pstResultInfo.udwTotal/8)+1;
//                }catch(Exception m) {
//
//                }
//            }
//        }else {
//            logger.info("没数据");
//            return;
//        }
//    }
//
//    /***************************sdk call back**************************************/
//
//    public static NETDEV_DISCOVERY_CALLBACK_PF cbDiscoveryCallBack = new NETDEV_DISCOVERY_CALLBACK_PF();
//    public static class NETDEV_DISCOVERY_CALLBACK_PF  implements NetDEVSDKLib.NETDEV_DISCOVERY_CALLBACK_PF {
//        @Override
//        public void invoke(NETDEV_DISCOVERY_DEVINFO_S pstDevInfo, Pointer lpUserData){
//
//            Vector<String> vector = new Vector<String>();
//            vector.add(Common.DevideTypeToString((int)pstDevInfo.enDevType));
//            vector.add(Common.utfToString(pstDevInfo.szDevAddr));
//            vector.add(String.valueOf(pstDevInfo.dwDevPort));
//            vector.add(Common.utfToString(pstDevInfo.szDevMac));
//            vector.add(Common.utfToString(pstDevInfo.szDevSerailNum));
//            vector.add(Common.utfToString(pstDevInfo.szManuFacturer));
//            logger.info("设备搜索回调-- enDevType:"+Common.DevideTypeToString((int)pstDevInfo.enDevType)
//                    +",szDevAddr:"+Common.utfToString(pstDevInfo.szDevAddr)
//                    +",dwDevPort:"+pstDevInfo.dwDevPort
//                    +",szDevMac:"+Common.utfToString(pstDevInfo.szDevMac)
//                    +",szDevSerailNum:"+Common.utfToString(pstDevInfo.szDevSerailNum)
//                    +",szManuFacturer:"+Common.utfToString(pstDevInfo.szManuFacturer));
//        }
//    }
//
//    public static  NETDEV_AlarmMessCallBack_PF_V30 cbAlarmMessCallBack = new NETDEV_AlarmMessCallBack_PF_V30();
//    public static class NETDEV_AlarmMessCallBack_PF_V30 implements NetDEVSDKLib.NETDEV_AlarmMessCallBack_PF_V30{
//        @Override
//        public void invoke(Pointer lpUserID, NETDEV_REPORT_INFO_S pstReportInfo, Pointer lpBuf, int dwBufLen,
//                           Pointer lpUserParam) {
//            if (NETDEV_REPORT_TYPE_E.NETDEV_REPORT_TYPE_ALARM == pstReportInfo.dwReportType) {
//                String strTime = Common.timeStamp2Date(Long.toString(pstReportInfo.stAlarmInfo.tAlarmTimeStamp),NetDemo.DateFormat);
//
//                Vector<String> vector = new Vector<String>();
//                vector.add(strTime);
//                String ChannelInfo = Integer.toString(pstReportInfo.stAlarmInfo.dwChannelID);
//                String AlarmSrc = Common.utfToString(pstReportInfo.stAlarmInfo.szAlarmSrc);
//                if (!AlarmSrc.isEmpty()) {
//                    ChannelInfo += "(";
//                    ChannelInfo += AlarmSrc;
//                    ChannelInfo += ")";
//                }
//                vector.add(ChannelInfo);
//                vector.add(Common.AlarmTypeToString(pstReportInfo.stAlarmInfo.dwAlarmType));
//                logger.info("告警信息--strTime:"+strTime+",ChannelInfo:" +ChannelInfo+ ",dwAlarmType:" + pstReportInfo.stAlarmInfo.dwAlarmType
//                        + ",dwAlarmLevel:" + pstReportInfo.stAlarmInfo.dwAlarmLevel);
//            }
//            else{
//                logger.info("event_info null");
//            }
//        }
//    }
//
//    public static NETDEV_FaceSnapshotCallBack_PF cbFaceSnapshotCallBack = new NETDEV_FaceSnapshotCallBack_PF();
//    public static class NETDEV_FaceSnapshotCallBack_PF implements NetDEVSDKLib.NETDEV_FaceSnapshotCallBack_PF{
//        @Override
//        public void invoke(Pointer lpPlayHandle, NETDEV_TMS_FACE_SNAPSHOT_PIC_INFO_S pstFaceSnapShotData, Pointer lpUserParam){
//            logger.info(pstFaceSnapShotData.udwPicBuffLen+"");
//
//            byte[] szDataBuf = new byte[pstFaceSnapShotData.udwPicBuffLen];
//            szDataBuf = pstFaceSnapShotData.pcPicBuff.getByteArray(0, pstFaceSnapShotData.udwPicBuffLen);
//
//            FileOutputStream fop = null;
//            File file;
//            try {
//                file = new File("./face.jpg");
//                fop = new FileOutputStream(file);
//                if (!file.exists()) {
//                    file.createNewFile();
//                }
//                fop.write(szDataBuf);
//                fop.flush();
//                fop.close();
//
//                logger.info("write Done");
//            } catch (IOException e2) {
//                e2.printStackTrace();
//            }
//        }
//    }
//
//    public static NETDEV_PersonAlarmMessCallBack_PF personAlarmMessCB =new NETDEV_PersonAlarmMessCallBack_PF();
//    public static class NETDEV_PersonAlarmMessCallBack_PF implements NetDEVSDKLib.NETDEV_PersonAlarmMessCallBack_PF
//    {
//
//        @Override
//        public void invoke(Pointer lpUserID, NETDEV_PERSON_EVENT_INFO_S pstAlarmData, Pointer lpUserData) {
//            // TODO Auto-generated method stub
//            String strTime = Common.getDate();
//            logger.info("Person AlarmTime:"+ pstAlarmData.udwTimestamp);
//            for(int i = 0; i < pstAlarmData.udwFaceInfoNum; i++)
//            {
//                logger.info("Person udwSimilarity:"+ pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.udwSimilarity);
//
//                //布控的图片
//                if(pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPersonInfo.udwImageNum > 0)
//                {
//                    String strFileName = NetDemo.strPicturePath + strTime +"bukong.jpg";
//                    Common.savePicture(pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPersonInfo.stImageInfo[0].stFileInfo.pcData, pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPersonInfo.stImageInfo[0].stFileInfo.udwSize, strFileName);
//                }
//
//                // 大图,一体机获取的方法,ipc/NVR直接写数据 */
//                {
//                    String strFileName = NetDemo.strPicturePath + strTime +"Person_Big.jpg";
//                    String iCmRet = Common.byteArrayToString(pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.szUrl);
//                    if(!iCmRet.equals(""))
//                    {
//                        Pointer pszUrl = new Memory(260);
//                        pszUrl.write(0, pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.szUrl, 0, 260);
//                        Pointer pszData = new Memory(pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.udwSize);
//                        NetDemo.netdevsdk.NETDEV_GetSystemPicture(lpUserID, pszUrl, pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.udwSize, pszData);
//
//                        Common.savePicture(pszData, pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.udwSize, strFileName);
//                    }
//                    else
//                    {
//                        Common.savePicture(pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.pcData, pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.udwSize, strFileName);
//                    }
//                }
//
//                //小图
//                {
//                    String strFileName = NetDemo.strPicturePath + strTime +"Person_Small.jpg";
//                    Common.savePicture(pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stFaceImage.pcData, pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stFaceImage.udwSize, strFileName);
//                }
//            }
//        }
        NETDEV_BATCH_OPERATE_BASIC_S pstResultInfo=new NETDEV_BATCH_OPERATE_BASIC_S();
        pstResultInfo.udwOffset=0;
        pstFindCond.write();
        pstResultInfo.write();
        Pointer lpFindHandle= NetDemo.netdevsdk.NETDEV_FindACSAttendanceLogList(NetDemo.lpUserID,pstFindCond,pstResultInfo);
        if(lpFindHandle!=null) {
            NETDEV_ACS_ATTENDANCE_LOG_INFO_S pstACSLogInfo=new NETDEV_ACS_ATTENDANCE_LOG_INFO_S();
            pstACSLogInfo.stCompareInfo=new NETDEV_COMPARE_INFO_S();
            pstACSLogInfo.stCompareInfo.stPersonImage=new NETDEV_FILE_INFO_S();
            pstACSLogInfo.stCompareInfo.stPersonImage.pcData=new Memory(1048576);
            pstACSLogInfo.stCompareInfo.stSnapshotImage=new NETDEV_FILE_INFO_S();
            pstACSLogInfo.stCompareInfo.stSnapshotImage.pcData=new Memory(1048576);
            logger.info("stSnapshotImage.szUrl="+Common.byteArrayToString(pstACSLogInfo.stCompareInfo.stSnapshotImage.szUrl));
            pstACSLogInfo.stFaceAttr=new NETDEV_FACE_ATTR_S();
            pstACSLogInfo.write();
            boolean flag = true;
            int i = 0;
            NetDemo.getRowData=new Vector();
            do {
                boolean nextAcs= NetDemo.netdevsdk.NETDEV_FindNextACSAttendanceLog(lpFindHandle,pstACSLogInfo);
                if(!nextAcs) {
                    break;
                }
                pstACSLogInfo.read();
                pstResultInfo.read();
//              分页数据
                try {
                    Vector data=new Vector();
                    data.add(i+1);
                    String szName=Common.byteArrayToString(pstACSLogInfo.szPersonName);
                    data.add(szName);
                    Long getTime=pstACSLogInfo.tTimeStamp;
                    String new1=String.valueOf(getTime);
                    String getNewDateTime=Common.timeStamp2Date(new1, NetDemo.DateFormat);
                    String deptName=Common.byteArrayToString(pstACSLogInfo.szDoorName);
                    int direct=pstACSLogInfo.udwDoorDirect;
                    String getDirect=null;
                    if(direct==0) {
                        getDirect="in";
                    }else if(direct==1) {
                        getDirect="out";
                    }else {
                        getDirect="unknow";
                    }
                    data.add(getNewDateTime);
                    data.add(deptName);
                    data.add(getDirect);
                    data.add(pstACSLogInfo.stFaceAttr.fTemperature);
                    NetDemo.getRowData.add(data);
                    logger.info("门禁记录-- szPersonName:"+Common.byteArrayToString(pstACSLogInfo.szPersonName)
                            +",getNewDateTime:"+getNewDateTime
                            +",deptName:"+deptName
                            +",getDirect:"+getDirect
                            +",fTemperature:"+pstACSLogInfo.stFaceAttr.fTemperature
                    );
                }catch(Exception eee) {
                }i++;
            }
            while (flag && i < 8);
        }
        else
        {
            logger.info("未找到记录");
            return;
        }
        NetDemo.netdevsdk.NETDEV_FindCloseACSAttendanceLogList(lpFindHandle);
        int pageSize=0;
        if(pstResultInfo.udwTotal>0) {
            if(pstResultInfo.udwTotal%8==0) {
                try {
                    pageSize=pstResultInfo.udwTotal/8;
                }catch(Exception m) {
                }
            }else {
                try {
                    pageSize=(pstResultInfo.udwTotal/8)+1;
                }catch(Exception m) {
                }
            }
        }else {
            logger.info("没数据");
            return;
        }
    }
    /***************************sdk call back**************************************/
    public static NETDEV_DISCOVERY_CALLBACK_PF cbDiscoveryCallBack = new NETDEV_DISCOVERY_CALLBACK_PF();
    public static class NETDEV_DISCOVERY_CALLBACK_PF  implements NetDEVSDKLib.NETDEV_DISCOVERY_CALLBACK_PF {
        @Override
        public void invoke(NETDEV_DISCOVERY_DEVINFO_S pstDevInfo, Pointer lpUserData){
            Vector<String> vector = new Vector<String>();
            vector.add(Common.DevideTypeToString((int)pstDevInfo.enDevType));
            vector.add(Common.utfToString(pstDevInfo.szDevAddr));
            vector.add(String.valueOf(pstDevInfo.dwDevPort));
            vector.add(Common.utfToString(pstDevInfo.szDevMac));
            vector.add(Common.utfToString(pstDevInfo.szDevSerailNum));
            vector.add(Common.utfToString(pstDevInfo.szManuFacturer));
            logger.info("设备搜索回调-- enDevType:"+Common.DevideTypeToString((int)pstDevInfo.enDevType)
                    +",szDevAddr:"+Common.utfToString(pstDevInfo.szDevAddr)
                    +",dwDevPort:"+pstDevInfo.dwDevPort
                    +",szDevMac:"+Common.utfToString(pstDevInfo.szDevMac)
                    +",szDevSerailNum:"+Common.utfToString(pstDevInfo.szDevSerailNum)
                    +",szManuFacturer:"+Common.utfToString(pstDevInfo.szManuFacturer));
        }
    }
    public static  NETDEV_AlarmMessCallBack_PF_V30 cbAlarmMessCallBack = new NETDEV_AlarmMessCallBack_PF_V30();
    public static class NETDEV_AlarmMessCallBack_PF_V30 implements NetDEVSDKLib.NETDEV_AlarmMessCallBack_PF_V30{
        @Override
        public void invoke(Pointer lpUserID, NETDEV_REPORT_INFO_S pstReportInfo, Pointer lpBuf, int dwBufLen,
                           Pointer lpUserParam) {
            if (NETDEV_REPORT_TYPE_E.NETDEV_REPORT_TYPE_ALARM == pstReportInfo.dwReportType) {
                String strTime = Common.timeStamp2Date(Long.toString(pstReportInfo.stAlarmInfo.tAlarmTimeStamp),NetDemo.DateFormat);
                Vector<String> vector = new Vector<String>();
                vector.add(strTime);
                String ChannelInfo = Integer.toString(pstReportInfo.stAlarmInfo.dwChannelID);
                String AlarmSrc = Common.utfToString(pstReportInfo.stAlarmInfo.szAlarmSrc);
                if (!AlarmSrc.isEmpty()) {
                    ChannelInfo += "(";
                    ChannelInfo += AlarmSrc;
                    ChannelInfo += ")";
                }
                vector.add(ChannelInfo);
                vector.add(Common.AlarmTypeToString(pstReportInfo.stAlarmInfo.dwAlarmType));
                logger.info("告警信息--strTime:"+strTime+",ChannelInfo:" +ChannelInfo+ ",dwAlarmType:" + pstReportInfo.stAlarmInfo.dwAlarmType
                        + ",dwAlarmLevel:" + pstReportInfo.stAlarmInfo.dwAlarmLevel);
            }
            else{
                logger.info("event_info null");
            }
        }
    }
    public static NETDEV_FaceSnapshotCallBack_PF cbFaceSnapshotCallBack = new NETDEV_FaceSnapshotCallBack_PF();
    public static class NETDEV_FaceSnapshotCallBack_PF implements NetDEVSDKLib.NETDEV_FaceSnapshotCallBack_PF{
        @Override
        public void invoke(Pointer lpPlayHandle, NETDEV_TMS_FACE_SNAPSHOT_PIC_INFO_S pstFaceSnapShotData, Pointer lpUserParam){
            logger.info(pstFaceSnapShotData.udwPicBuffLen+"");
            byte[] szDataBuf = new byte[pstFaceSnapShotData.udwPicBuffLen];
            szDataBuf = pstFaceSnapShotData.pcPicBuff.getByteArray(0, pstFaceSnapShotData.udwPicBuffLen);
            FileOutputStream fop = null;
            File file;
            try {
                file = new File("./face.jpg");
                fop = new FileOutputStream(file);
                if (!file.exists()) {
                    file.createNewFile();
                }
                fop.write(szDataBuf);
                fop.flush();
                fop.close();
                logger.info("write Done");
            } catch (IOException e2) {
                e2.printStackTrace();
            }
        }
    }
    public static NETDEV_PersonAlarmMessCallBack_PF personAlarmMessCB =new NETDEV_PersonAlarmMessCallBack_PF();
    public static class NETDEV_PersonAlarmMessCallBack_PF implements NetDEVSDKLib.NETDEV_PersonAlarmMessCallBack_PF
    {
        @Override
        public void invoke(Pointer lpUserID, NETDEV_PERSON_EVENT_INFO_S pstAlarmData, Pointer lpUserData) {
            // TODO Auto-generated method stub
            String strTime = Common.getDate();
            logger.info("Person AlarmTime:"+ pstAlarmData.udwTimestamp);
            for(int i = 0; i < pstAlarmData.udwFaceInfoNum; i++)
            {
                logger.info("Person udwSimilarity:"+ pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.udwSimilarity);
                //布控的图片
                if(pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPersonInfo.udwImageNum > 0)
                {
                    String strFileName = NetDemo.strPicturePath + strTime +"bukong.jpg";
                    Common.savePicture(pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPersonInfo.stImageInfo[0].stFileInfo.pcData, pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPersonInfo.stImageInfo[0].stFileInfo.udwSize, strFileName);
                }
                // 大图,一体机获取的方法,ipc/NVR直接写数据 */
                {
                    String strFileName = NetDemo.strPicturePath + strTime +"Person_Big.jpg";
                    String iCmRet = Common.byteArrayToString(pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.szUrl);
                    if(!iCmRet.equals(""))
                    {
                        Pointer pszUrl = new Memory(260);
                        pszUrl.write(0, pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.szUrl, 0, 260);
                        Pointer pszData = new Memory(pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.udwSize);
                        NetDemo.netdevsdk.NETDEV_GetSystemPicture(lpUserID, pszUrl, pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.udwSize, pszData);
                        Common.savePicture(pszData, pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.udwSize, strFileName);
                    }
                    else
                    {
                        Common.savePicture(pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.pcData, pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stPanoImage.udwSize, strFileName);
                    }
                }
                //小图
                {
                    String strFileName = NetDemo.strPicturePath + strTime +"Person_Small.jpg";
                    Common.savePicture(pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stFaceImage.pcData, pstAlarmData.stCtrlFaceInfo[i].stCompareInfo.stFaceImage.udwSize, strFileName);
                }
            }
        }
    }
}
//    }
//}

+ 15 - 15
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

@ -57,9 +57,9 @@ public class DeviceService {
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    private DPatientDeviceDao DPatientDeviceDao;
    @Autowired
    private DevicePatientHealthIndexDao healthIndexDao;
    private DDevicePatientHealthIndexDao healthIndexDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
@ -167,7 +167,7 @@ public class DeviceService {
                lat= Double.parseDouble(request.getParameter("lat"));
                lon= Double.parseDouble(request.getParameter("lon"));
            }
            List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
            List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(imei);
            if (devicePatientDeviceDos.size()>0){
                DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
                BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
@ -296,7 +296,7 @@ public class DeviceService {
                    }else{
                        return;
                    }
                    List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(deviceid);
                    List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(deviceid);
                    if (devicePatientDeviceDos.size()>0){
                        DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
                        BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
@ -354,7 +354,7 @@ public class DeviceService {
                    Double lat= null;
                    Double lon= null;
                    String address=null;
                    List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(deviceid);
                    List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(deviceid);
                    if (devicePatientDeviceDos.size()>0){
                        DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
                        BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
@ -445,7 +445,7 @@ public class DeviceService {
    public void byLocation(String imei,String time_begin,boolean is_reply,boolean is_track,String city,String address,double lon,double lat,String type) {
        try {
            if(StringUtils.isNotBlank(imei)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
                    BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
@ -511,7 +511,7 @@ public class DeviceService {
    public void byHeartRate(String imei,String time_begin,int heartrate,int theshold_heartrate_h,int theshold_heartrate_l) {
        try {
            if(StringUtils.isNotBlank(imei)) {
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size() > 0) {
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    BasePatientDO patientDO = patientDao.findById(devicePatientDevice.getUser());
@ -597,7 +597,7 @@ public class DeviceService {
    public void byBloodPressure(String imei,String time_begin,int dbp,int dbp_l,int sbp,int sbp_h) {
        try {
            if(StringUtils.isNotBlank(imei)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    BasePatientDO patientDO = patientDao.findById(devicePatientDevice.getUser());
@ -707,7 +707,7 @@ public class DeviceService {
    public void byX1Sleep(String imei,String time_begin,String time_end,Integer interval,Integer total,String deep_sleep,String light_sleep,String awake_time) {
        try {
            if(StringUtils.isNotBlank(imei)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size()>0){
                    Double deepSleep =Double.parseDouble(deep_sleep)*60 ;
                    Double lightSleep = Double.parseDouble(light_sleep)*60;
@ -744,7 +744,7 @@ public class DeviceService {
    public void bySteps(String imei,String time_begin,int value) {
        try {
            if(StringUtils.isNotBlank(imei)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size()>0){
                    BasePatientStepDo basePatientStepDo = new BasePatientStepDo();
                    basePatientStepDo.setPatient(devicePatientDeviceDos.get(0).getUser());
@ -769,7 +769,7 @@ public class DeviceService {
            ,Integer bloodoxygen,Integer bloodoxygen_h,Integer bloodoxygen_l) {
        try {
            if(StringUtils.isNotBlank(imei)) {
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size() > 0) {
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    BasePatientDO patientDO = patientDao.findById(devicePatientDevice.getUser());
@ -814,7 +814,7 @@ public class DeviceService {
                Integer upLongWarn=3; //起床预警时长
                Integer siestaLongWarn=5;//午睡预警时长
                Integer nightLongWarn=2;//起夜预警时长
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
                List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(device);
                if (devicePatientDeviceDos.size()>0){
                    Date timeDate = DateUtil.strToDate(time_begin);//当前时间
                    String dayTime = null;//检测日期
@ -1123,7 +1123,7 @@ public class DeviceService {
                              String efficiency,String score,String deepPer) {
        try {
            if(StringUtils.isNotBlank(device)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
                List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(device);
                if (devicePatientDeviceDos.size()>0){
                    String patient = devicePatientDeviceDos.get(0).getUser();
                    BaseSleepDeviceReport report = new BaseSleepDeviceReport();
@ -1160,7 +1160,7 @@ public class DeviceService {
    //睡眠带心率呼吸数据
    @Async
    public void sleepHealthIndex(String device,String heartrate,String breath,String time_begin) {
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
        List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(device);
        if (devicePatientDeviceDos.size() > 0) {
            Integer theshold_breath_h = 25;
            Integer theshold_breath_l = 8;
@ -1235,7 +1235,7 @@ public class DeviceService {
                String value = stepObj.getString("value").replace("\"]","").replace("[\"","");
                String time_begin = stepObj.getString("time_begin").replace("\"]","").replace("[\"","");
                if(StringUtils.isNotBlank(imei)){
                    List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                    List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(imei);
                    if (devicePatientDeviceDos.size()>0){
                        BasePatientStepDo basePatientStepDo = new BasePatientStepDo();
                        basePatientStepDo.setPatient(devicePatientDeviceDos.get(0).getUser());

+ 6 - 6
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceUploadService.java

@ -53,9 +53,9 @@ public class DeviceUploadService {
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    private DPatientDeviceDao DPatientDeviceDao;
    @Autowired
    private DevicePatientHealthIndexDao patientHealthIndexDao;
    private DDevicePatientHealthIndexDao patientHealthIndexDao;
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
@ -350,7 +350,7 @@ public class DeviceUploadService {
        if (deviceDetails != null || deviceDetails.size()!=0){
            deviceDetail = deviceDetails.get(0);
            if (deviceDetail.getGrantOrgCode() != null&& deviceDetail.getGrantOrgCode().equals("3502050300")){//
                List<DevicePatientDevice> patientDeviceList =  patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
                List<DevicePatientDevice> patientDeviceList =  DPatientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
                if (patientDeviceList != null&&patientDeviceList.size()==1) {
                    device = patientDeviceList.get(0);
                }else if(patientDeviceList != null&&patientDeviceList.size()==2){
@ -363,7 +363,7 @@ public class DeviceUploadService {
                }
            }else {
//                device = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn, type, userType);
                List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
                List<DevicePatientDevice> devices = DPatientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
                if (devices.size()>0){
                    device = devices.get(0);
                }else {
@ -618,7 +618,7 @@ public class DeviceUploadService {
                            com.alibaba.fastjson.JSONObject position = gpsUtil.Gps84_To_bd09(dulat,dulon);
                            dulat = position.getDouble("lat");
                            dulon = position.getDouble("lon");
                            List<DevicePatientDevice> patientDeviceList = patientDeviceDao.findByDeviceSn(sn);
                            List<DevicePatientDevice> patientDeviceList = DPatientDeviceDao.findByDeviceSn(sn);
                            DevicePatientDevice patientDevice = null;
                            if (patientDeviceList.size()>0){
                                patientDevice = patientDeviceList.get(0);
@ -689,7 +689,7 @@ public class DeviceUploadService {
                            }
                        }
                        List<DevicePatientDevice> patientDeviceList = patientDeviceDao.findByDeviceSn(sn);
                        List<DevicePatientDevice> patientDeviceList = DPatientDeviceDao.findByDeviceSn(sn);
                        if (patientDeviceList.size()>0){
                            DevicePatientDevice deviceDO = patientDeviceList.get(0);
                            BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());

+ 260 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/StDeviceService.java

@ -0,0 +1,260 @@
package com.yihu.jw.care.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.OnenetDeviceDao;
import com.yihu.jw.care.dao.device.OnenetReceiveRecordDao;
import com.yihu.jw.care.util.DeviceDataPushLogUtil;
import com.yihu.jw.care.util.SecurityOrderUtil;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.OnenetReceiveRecord;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
 * Created by yeshijie on 2024/4/18.
 */
@Service
public class StDeviceService {
    private static Logger logger = LoggerFactory.getLogger(StDeviceService.class);
    //文档地址 https://www.ctwing.cn/dyts/102#see
    //https://www.ctwing.cn/dyts/105#see
    //https://www.cityihealth.com/stdevice 消息推送测试地址
    //https://zhyzh.gongshu.gov.cn/device/stdevice/messageNotification
    //平台登录找华生扫码登录
    private static final String appId = "316072";
    private static final String appKey = "YHE629cXVn3";
    private static final String appSecret = "I4siCMtGdK";
    private static final String masterKey  = "I4siCMtGdK";
    private static final String domain = "2000478169.api.ctwing.cn";
    @Autowired
    private DeviceDataPushLogUtil dataPushLogUtil;
    @Autowired
    private OnenetDeviceDao onenetDeviceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private OnenetReceiveRecordDao onenetReceiveRecordDao;
    @Autowired
    private OnenetService onenetService;
    @Autowired
    private SecurityOrderUtil orderUtil;
    /**
     * 消息通知接收
     * @param str
     */
    @Async
    public void messageNotification(String str){
        if(StringUtils.isBlank(str)){
            return;
        }
        //{"msg":{"at":1630985527067,"imei":"868591057157041","type":1,"ds_id":"3200_0_5505","value":"001f0000041401000000000000005a1300000e01c6ffb1fffa00000e620245ca71","dev_id":768777611},"msg_signature":"qq8nsaH/QEUuDnjK+o8vgw==","nonce":"z8SlxYY%"}
        OnenetReceiveRecord record = new OnenetReceiveRecord();
        try {
            JSONObject jsonObject = JSON.parseObject(str);
            String deviceSn = jsonObject.getString("imei");
            if(StringUtils.isBlank(deviceSn)){
                deviceSn = jsonObject.getString("IMEI");
            }
            String messageType = jsonObject.getString("messageType");//消息类型
            Integer deviceStatus = 1;
            if("".equals(messageType)){
                deviceStatus = jsonObject.getInteger("eventType");//eventType 上线:1,下线:0
            }
            DeviceDetail deviceDetail = deviceDetailDao.findBySn(deviceSn);
            if(deviceDetail == null){
                logger.info("deviceDetail 设备不存在"+str);
                return;
            }
            boolean flag = false;
            String title = "";
            try {
                String categoryCode = deviceDetail.getCategoryCode();
                if("14".equals(categoryCode)){
                    title = "可燃气体探测器报警信息接收";
                    flag = deviceQi(messageType,deviceSn,jsonObject);
                }else if("15".equals(categoryCode)){
                    title = "烟探测器监测信息接收";
                    flag = deviceYan(messageType,deviceSn,jsonObject);
                }
            }catch (Exception e){
                e.printStackTrace();
            }
            dataPushLogUtil.savePushLog(deviceSn,str,title);
            dataPushLogUtil.updContactStatus(deviceSn,deviceStatus,flag);
            record.setContent(str);
            record.setStatus(1);
            record.setCreateTime(new Date());
        }catch (Exception e){
            e.printStackTrace();
            record.setStatus(2);
        }
        try {
            onenetReceiveRecordDao.save(record);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
     * 设备解析-气感
     */
    public boolean deviceQi(String messageType,String deviceSn, JSONObject jsonObject){
        boolean flag = false;
        //1 业务数据上报 data_report gas_sensor_state
        //2 信号数据上报 signal_report 1.rsrp 2.sinr 3.pci 4.ecl 5.cell_id
        //3 心跳 heartbeat
        //4 TY-业务数据上报(智慧社区) ty_data_report gas_sensor_state medium gas_value valve_state fan_state temperature battery_voltage battery_value
        Integer serviceId = jsonObject.getInteger("serviceId");
        long timestamp = jsonObject.getLong("timestamp");
        if("dataReport".equals(messageType)){
            //设备数据变化
            //燃气检测状态 gas_sensor_state 0:正常; 1:低浓度报警;2:高浓度报警
            if(serviceId == 4){
                JSONObject payload = jsonObject.getJSONObject("payload");
                //{"valve_state":3,"temperature":30,"medium":0,"gas_value":0,"gas_sensor_state":0,"fan_state":2,"battery_voltage":0.0,"battery_value":100}
                String time = DateUtil.stampToString(timestamp+"");
                //气感浓度
                Integer monitorValue = payload.getInteger("gas_value");
                Integer gas_sensor_state = payload.getInteger("gas_sensor_state");
                if(monitorValue>0){
                    String sql = "select count(*) from base_security_monitoring_order where device_sn = '"+deviceSn+"'" +
                            " and create_time>='"+ DateUtil.getNextMinute(-60)+"' ";
                    Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
                    if(count==0){
                        logger.info("气体浓度大于0触发报警,deviceSn:{}",deviceSn);
                        //1小时内不重复发起
                        JSONObject tmp = new JSONObject();
                        tmp.put("gas",monitorValue+"");
                        orderUtil.createSecurityOrder(deviceSn,null,new JSONObject(),null,6,"11","preventGasLeakage",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                        flag = true;
                    }
                }
                onenetService.addDeviceIndex(deviceSn,monitorValue+"",time,"1","%LEL");
                dataPushLogUtil.savePushLog(deviceSn,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"可燃气体探测器监测信息接收");
            }
            return flag;
        }
//        if("eventReport".equals(messageType)){
            //设备事件上报
            //eventType 事件类型,信息:1,警告:2,故障:3 int Y
//            int eventType = jsonObject.getInteger("eventType");
            //error_code 0:正常; 1:传感器故障;2:电池故障; 3:开机; 4:关机; 5:预热; 6:自检; 7:失效; 8:离线
            //1001 燃气检测状态告警 gas_sensor_state_report gas_sensor_state
            //1002 故障上报 error_code_report error_code
            //1003 电池低压告警 battery_voltage_low_alarm battery_voltage
//        }
        //其他信息暂时不处理
        return flag;
    }
    /**
     * 设备解析-烟感
     */
    public boolean deviceYan(String messageType,String deviceSn, JSONObject jsonObject){
        boolean flag = false;
        Integer serviceId = jsonObject.getInteger("serviceId");
        long timestamp = jsonObject.getLong("timestamp");
        if("dataReport".equals(messageType)){
            //1.smoke_state 2.smoke_value 3.battery_value 4.signalPower 5.snr 6.tx_Power 7.cell_ID
            if(serviceId==1){
                String time = DateUtil.stampToString(timestamp+"");
                JSONObject payload = jsonObject.getJSONObject("payload");
                //烟雾浓度
                Integer smokeValue =  payload.getInteger("smoke_value");
                if (smokeValue>=70){
                    String sql = " select count(*) from base_security_monitoring_order where device_sn = '"+deviceSn+"' " +
                            " and create_time>='"+DateUtil.getNextMinute(-60)+"' ";
                    Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
                    if(count==0){
                        logger.info("烟雾浓度大于70触发报警,deviceSn:{}",deviceSn);
                        JSONObject tmp = new JSONObject();
                        tmp.put("smoke",smokeValue+"");
                        tmp.put("temperature",null);
                        orderUtil.createSecurityOrder(deviceSn,null,new JSONObject(),null,7,"10","preventFire",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                        flag = true;
                    }
                }
                dataPushLogUtil.savePushLog(deviceSn,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"烟感探测器报警信息接收");
                onenetService.addDeviceIndex(deviceSn,smokeValue+"",time,"2","%");
            }
        }
        if("eventReport".equals(messageType)){
            if(serviceId==1003){
                String time = DateUtil.stampToString(timestamp+"");
                JSONObject payload = jsonObject.getJSONObject("payload");
                //烟雾浓度
                Integer smokeValue =  payload.getInteger("smoke_value");
                if (smokeValue>=70){
                    String sql = " select count(*) from base_security_monitoring_order where device_sn = '"+deviceSn+"' " +
                            " and create_time>='"+DateUtil.getNextMinute(-60)+"' ";
                    Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
                    if(count==0){
                        logger.info("烟雾浓度大于70触发报警,deviceSn:{}",deviceSn);
                        JSONObject tmp = new JSONObject();
                        tmp.put("smoke",smokeValue+"");
                        tmp.put("temperature",null);
                        orderUtil.createSecurityOrder(deviceSn,null,new JSONObject(),null,7,"10","preventFire",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
                        flag = true;
                    }
                }
                dataPushLogUtil.savePushLog(deviceSn,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"烟感探测器报警信息接收");
                onenetService.addDeviceIndex(deviceSn,smokeValue+"",time,"2","%");
            }
        }
        //其他信息暂时不处理
        return flag;
    }
     /**
     * 设备上下线
     */
    public void deviceOnlineOfflineReport(JSONObject json){
        //{"timestamp":1678263103563,"tenantId":"10000000","protocol":"lwm2m","productId":"1000000","messageType":"deviceOnlineOfflineReport","ipv4Address":"11.25.57.35","iccid":"undefined","eventType":1,"deviceId":"55f7b4da79f34c6cb1c5e34f00000000","imei":"868334030000000"}
        String deviceID = json.getString("deviceID");
        String imei = json.getString("imei");
        //eventType 上线:1,下线:0 int Y
        Integer deviceStatus = json.getInteger("eventType");
        dataPushLogUtil.savePushLog(imei,json.toJSONString(),"气感烟感探测器监测信息接收");
        dataPushLogUtil.updContactStatus(imei,deviceStatus,null);
    }
    /**
     * 设备事件上报
     */
    public void eventReport(JSONObject json){
        //{"tenantId":"1","productId":"10010208","deviceSn":"111qw","deviceId":"10010208111qw","messageType":"eventReport","imei":"xxx","imsi":"xx","timestamp":1554190965950,"eventType":1,"eventContent":{"m":44},"serviceId":1001,"protocol":"rdap"}
        //eventType 事件类型,信息:1,警告:2,故障:3 int Y
        //eventContent 事件上报数据 json Y
        String imei = json.getString("imei");
    }
    /**
     * 设备数据变化
     */
    public void dataReport(JSONObject json){
        //{"upPacketSN":-1,"deviceType":"","productId":"151***20","IMEI":"87439*****97353","deviceId":"5bcba*****f5472fb08a2090cd4e7158","protocol":"lwm2m","messageType":"dataReport","payload":{"current_temperature":-40,"current_humidity":0},"assocAssetId":"","tenantId":"9900000000*****","IMSI":"undefined","topic":"v1/up/ad19","upDataSN":-1,"serviceId":1,"timestamp":1667800228974}
        //payload 消息负载,非透传消息格式为payload:消息内容JSON;透传消息格式为payload:{"APPdata":"消息内容BASE64编码"} json Y
        String imei = json.getString("IMEI");
    }
}

+ 2 - 15
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java

@ -3,31 +3,21 @@ package com.yihu.jw.care.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.care.config.YsConfig;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.device.DPatientDeviceDao;
import com.yihu.jw.care.dao.device.YsConfigDao;
import com.yihu.jw.care.util.DeviceDataPushLogUtil;
import com.yihu.jw.care.util.SecurityOrderUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.YsConfigDo;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.exception.business.file_upload.*;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.encode.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.entity.ContentType;
import org.apache.http.message.BasicNameValuePair;
import org.csource.common.MyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -50,11 +40,8 @@ import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@ -69,7 +56,7 @@ public class YsDeviceService {
    @Value("${cloudCare.url}")
    private String cloudCareUrl;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    private DPatientDeviceDao DPatientDeviceDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired

+ 3 - 3
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/DeviceDataPushLogUtil.java

@ -3,7 +3,7 @@ package com.yihu.jw.care.util;
import com.yihu.jw.care.dao.device.BasePatientMonitorDataDao;
import com.yihu.jw.care.dao.device.DeviceDataPushLogDao;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.device.DPatientDeviceDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.BasePatientMonitorDataDO;
import com.yihu.jw.entity.care.device.DeviceDataPushLog;
@ -32,7 +32,7 @@ public class DeviceDataPushLogUtil {
    @Autowired
    private DeviceDataPushLogDao deviceDataPushLogDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    private DPatientDeviceDao DPatientDeviceDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
@ -54,7 +54,7 @@ public class DeviceDataPushLogUtil {
            pushLog.setData(data);
            pushLog.setApiName(apiName);
            pushLog.setCreateTime(new Date());
            List<DevicePatientDevice> devices= patientDeviceDao.findByDeviceSn(sn);
            List<DevicePatientDevice> devices= DPatientDeviceDao.findByDeviceSn(sn);
            if (devices.size()>0){
                DevicePatientDevice tmp = devices.get(0);
                BasePatientDO patientDO = patientDao.findById(tmp.getUser());

+ 3 - 3
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/DeviceLostMessageUtil.java

@ -1,6 +1,6 @@
package com.yihu.jw.care.util;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.device.DPatientDeviceDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
@ -24,7 +24,7 @@ public class DeviceLostMessageUtil {
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    private DPatientDeviceDao DPatientDeviceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
@ -41,7 +41,7 @@ public class DeviceLostMessageUtil {
            if (sendMessageBefore.size()>0){//删除之前的离线消息
                systemMessageDao.delete(sendMessageBefore);
            }
            List<DevicePatientDevice> pds =  patientDeviceDao.findByDeviceSn(id);
            List<DevicePatientDevice> pds =  DPatientDeviceDao.findByDeviceSn(id);
            if (pds.size()>0){
                DevicePatientDevice deviceDO = pds.get(0);
                String sql = "SELECT DISTINCT d.id,d.name from base_service_package_sign_record sr,base_service_package_record r,base_team_member m,base_doctor d  " +

+ 10 - 5
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/SecurityOrderUtil.java

@ -3,9 +3,10 @@ package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.care.dao.device.DPatientDeviceDao;
import com.yihu.jw.care.dao.device.DeviceSosLogDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.device.PatientSafeAreaDao;
import com.yihu.jw.care.service.StDeviceService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DeviceSosLogDO;
@ -19,6 +20,8 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.csource.common.MyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
@ -38,10 +41,12 @@ import java.util.Map;
@Component
public class SecurityOrderUtil {
    private static Logger logger = LoggerFactory.getLogger(SecurityOrderUtil.class);
    @Value("${cloudCare.url}")
    private String cloudCareUrl;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    private DPatientDeviceDao DPatientDeviceDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
@ -63,7 +68,7 @@ public class SecurityOrderUtil {
            String lat = "";
            String lon = "";
            String address=" ";
            List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(deviceSN);
            List<DevicePatientDevice> devicePatientDeviceDos = DPatientDeviceDao.findByDeviceSn(deviceSN);
            if (devicePatientDeviceDos.size()>0){
                DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
                if (null!=addressInfo){
@ -113,7 +118,7 @@ public class SecurityOrderUtil {
                jsonObject.put("patientName",patientDO.getName());
                jsonObject.put("patientPhone",patientDO.getMobile());
                jsonObject.put("serveDesc",serveDesc);
                jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
                jsonObject.put("hospital",hospital);
                jsonObject.put("serveAddress",address);
                jsonObject.put("serveLat",lat);
                jsonObject.put("serveLon",lon);
@ -131,7 +136,7 @@ public class SecurityOrderUtil {
                params.add(new BasicNameValuePair("warnStr", serveDesc));
                params.add(new BasicNameValuePair("orderSource", orderSource+""));
                String response = httpClientUtil.post(url, params,"UTF-8");
                System.out.println(response);
                logger.info(response);
            }
        }catch (Exception e){
            e.printStackTrace();