javaweb project get access UOB credit card records

1, download the official UOB network equipment sdk_java64, address: https: //www.dahuatech.com/service/downloadlists/836.html
2, there are examples of SDK, to make use of UOB packaged things, acquiring an access card used in recording the following java class:
    COM / NETSDK / lib
        NetSDKLib.java
        ToolKits.java
        in Utils.java
    COM / NETSDK / Demo / Module1
        LoginModule.java
   
    I thought com.netsdk.demo.module.GateModule.java which will have ready access to records of access card implementation, but unfortunately did not. Than painted gourd dipper, wrote a.
   
3, the introduction libs / jna.jar in their spring boot project.
    <dependency>
      <groupId>com.dahua</groupId>
      <artifactId>jna</artifactId>
      <version>1.0</version>
      <scope>system</scope>
      <systemPath>${project.basedir}/lib/jna.jar</systemPath>
    </dependency>
 
    dll file in the libs / win64 UOB libraries, run-time to read, there are ways to read in the Utils.java,
    can follow a path which is stored in its own path corresponds to the item. My project is spring boot, put on the same level libs file src file to start the project folder.
    Web-len
        -src
        -libs
            -win64
4, UOB pit: Notes document and class, are stated access credit card records can be retrieved through the period, but some do not support access control equipment, will give you all the all the records;
    note LoginModule initialization method init, for javaweb project is concerned, when the service starts, the initialization time on the line, followed by a direct call to login, logout methods can be,
    do not call the init method multiple times, so java memory will be ringing off the hook, so I started doing that the (depressed) ...... there is a credit card records of the time is not Beijing, but the district 0:00
    time, so they wanted to get to plus 8 hours is Beijing time.
5, when using maven package, if missed jna.jar, on the spring-boot-maven-plugin in pom.xml plus <includeSystemScope> true </ includeSystemScope>
    follows:
<plugins>
  <plugin>
    <the groupId > org.springframework.boot </ the groupId>
    <the artifactId> Boot-Spring-Maven-plugin </ the artifactId>
    <Configuration>
      <includeSystemScope> to true </ includeSystemScope>
    </ Configuration>
  </ plugin>
</ plugins>
 
6, GateModule.java Code
package com.dahua.module;
import com.dahua.lib.NetSDKLib;
import com.dahua.lib.ToolKits;
import com.sun.jna.Memory;
{class GateModule public
    / **
         * query credit card records, acquiring a query handler
     * @param findCondition query
     * @return
     * /
    public static NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARDREC [] findRecords (NetSDKLib.NET_TIME the startTime, endTime NetSDKLib.NET_TIME) {
        // inbound interface reference
        NetSDKLib.FIND_RECORD_ACCESSCTLCARDREC_CONDITION_EX findCondition new new NetSDKLib.FIND_RECORD_ACCESSCTLCARDREC_CONDITION_EX = ();
        findCondition.bCardNoEnable = 0;
        findCondition.stStartTime the startTime =;
        findCondition.stEndTime = endTime;
        // inbound interface parameters CLIENT_FindRecord
        NetSDKLib.NET_IN_FIND_RECORD_PARAM stIn = new NetSDKLib.NET_IN_FIND_RECORD_PARAM();
        stIn.emType = NetSDKLib.EM_NET_RECORD_TYPE.NET_RECORD_ACCESSCTLCARDREC_EX;
        stIn.pQueryCondition = findCondition.getPointer();
       
        // CLIENT_FindRecord 接口出参
        NetSDKLib.NET_OUT_FIND_RECORD_PARAM stOut = new NetSDKLib.NET_OUT_FIND_RECORD_PARAM();
        findCondition.write ();
       
        NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARDREC [] = new new pstRecordEx NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARDREC [0];
        // Get Query handle
        IF (LoginModule.netsdk.CLIENT_FindRecord (LoginModule.m_hLoginHandle, STIN, Stout, 5000)) {
            findCondition.read ( );
           
            // for memory applications, assuming 2,000 credit card records
            int nFindCount = 2000;
            NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARDREC [] = new new pstRecord NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARDREC [nFindCount];
            for (int I = 0; I <nFindCount; I ++) {
                pstRecord [ I] = new new NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARDREC ();
            }
           
            NetSDKLib.NET_IN_FIND_NEXT_RECORD_PARAM stNextIn = new NetSDKLib.NET_IN_FIND_NEXT_RECORD_PARAM();
            stNextIn.lFindeHandle = stOut.lFindeHandle;
            stNextIn.nFileCount = nFindCount;
           
            NetSDKLib.NET_OUT_FIND_NEXT_RECORD_PARAM stNextOut = new NetSDKLib.NET_OUT_FIND_NEXT_RECORD_PARAM();
            stNextOut.nMaxRecordNum = nFindCount;
            // 申请内存
            stNextOut.pRecordList = new Memory(pstRecord[0].dwSize * nFindCount);
            stNextOut.pRecordList.clear(pstRecord[0].dwSize * nFindCount);
           
            // 将数组内存拷贝给指针
            ToolKits.SetStructArrToPointerData(pstRecord, stNextOut.pRecordList);
           
            if(LoginModule.netsdk.CLIENT_FindNextRecord(stNextIn, stNextOut, 5000)) {
                if(stNextOut.nRetRecordNum == 0) {
                    return pstRecordEx;
                }
                // Get the card information
                ToolKits.GetPointerDataToStructArr (stNextOut.pRecordList, pstRecord);
                       
                // obtain useful information
                pstRecordEx = new new NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARDREC [stNextOut.nRetRecordNum];
                for (int I = 0; I <stNextOut.nRetRecordNum; I ++) {
                    pstRecordEx [I] = new new NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARDREC ();
                    pstRecordEx [I] = pstRecord [I];
                }
            }
           
            LoginModule.netsdk.CLIENT_FindRecordClose (stOut.lFindeHandle);
        }
        return pstRecordEx;
    }
}
 
7, is called
Boolean In Flag = LoginModule.login (hall.getGateIp (), 37777, "ADMIN", "123456");
IF (In Flag) {
    // search completion time: the current time
    Date endDateTime = calendar.getTime ();
    endTime = new new NetSDKLib.NET_TIME NetSDKLib.NET_TIME ();
    endTime.setTime (Calendar.get (Calendar.YEAR), Calendar.get (the Calendar.MONTH) +. 1, Calendar.get (Calendar.DATE), Calendar.get (Calendar .HOUR), Calendar.get (Calendar.MINUTE), Calendar.get (Calendar.SECOND));
   
    // Get the search start time: the current time - 5 minutes
    Calendar.add (Calendar.MINUTE, -5);
    a Date = the startDateTime calendar.getTime ();
    NetSDKLib.NET_TIME new new NetSDKLib.NET_TIME the startTime = ();
    startTime.setTime (calendar.get (Calendar.YEAR), calendar.get (Calendar.MONTH) + 1, calendar.get (Calendar.DATE), calendar.get (Calendar.HOUR), calendar.get (Calendar.MINUTE) , Calendar.get (Calendar.SECOND));
   
    NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARDREC [] = cardRecords GateModule.findRecords (the startTime, endTime);
   
    for (NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARDREC cardRecord: cardRecords) {
        // card
        String cardNo = new String (cardRecord.szCardNo) .trim ();
        // If the card status is not correct, or the key to open the door, no data entry
        IF (cardRecord.bStatus. 1 || = "00000000" .equals (cardNo)!) {
            Continue;
        }
        // time conversion card GMT +8 hours
        Date stuTime = DateUtil.convertStringToDate(cardRecord.stuTime.toStringTimeEx(), "yyyy-MM-dd HH:mm:ss");
        Calendar stuCalendar = DateUtil.getCalendar(stuTime);
        stuCalendar.add(Calendar.HOUR, 8);
    }
}

Guess you like

Origin www.cnblogs.com/black-and-white/p/11992933.html