|
@@ -7,7 +7,11 @@ import com.netsdk.common.Res;
|
|
|
import com.netsdk.lib.NetSDKLib;
|
|
|
import com.netsdk.lib.ToolKits;
|
|
|
import com.sun.jna.Memory;
|
|
|
+import lombok.Data;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
@@ -19,11 +23,18 @@ import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
|
|
|
@RequestMapping("crud")
|
|
|
+@Data
|
|
|
+@Component
|
|
|
@Service
|
|
|
public class GateLogService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
GateOplogMapper gateOplogMapper;
|
|
|
|
|
|
- @Scheduled(cron = "0 * * * * *")
|
|
|
+ @Value("${customer.project}")
|
|
|
+ private int project;
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0 * * * *")
|
|
|
public void syncLog() {
|
|
|
System.out.println("--开始执行日志查询同步任务--");
|
|
|
String format = "yyyy-MM-dd HH:mm:ss";
|
|
@@ -32,9 +43,9 @@ public class GateLogService {
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
LocalDateTime startTime = now.minusHours(1);
|
|
|
NetSDKLib.NET_TIME s = new NetSDKLib.NET_TIME();
|
|
|
- s.setTime(startTime.getYear(),startTime.getMonthValue(),startTime.getDayOfMonth(),0,0,0);
|
|
|
+ s.setTime(startTime.getYear(),startTime.getMonthValue(),startTime.getDayOfMonth(),startTime.getHour(),0,0);
|
|
|
NetSDKLib.NET_TIME e = new NetSDKLib.NET_TIME();
|
|
|
- e.setTime(startTime.getYear(),startTime.getMonthValue(),startTime.getDayOfMonth(),23,59,59);
|
|
|
+ e.setTime(startTime.getYear(),startTime.getMonthValue(),startTime.getDayOfMonth(),startTime.getHour(),59,59);
|
|
|
|
|
|
synchronized(LoginModule.lock){
|
|
|
for (NetSDKLib.LLong key : LoginModule.m_stDeviceInfo.keySet()) {
|
|
@@ -82,6 +93,7 @@ public class GateLogService {
|
|
|
System.out.println("CLIENT_FindNextRecord success!");
|
|
|
ToolKits.GetPointerDataToStructArr(outNextParam.pRecordList, rets);
|
|
|
|
|
|
+ System.out.println("开始时间:"+s.toStringTimeEx() + "结束时间:"+e.toStringTimeEx());
|
|
|
System.out.println("查询到的结果数量:"+outNextParam.nRetRecordNum+"最大数量:"+outNextParam.nMaxRecordNum);
|
|
|
for (int i = 0; i < outNextParam.nRetRecordNum; i++) {
|
|
|
String szCardName = new String(rets[i].szCardName);
|
|
@@ -91,10 +103,16 @@ public class GateLogService {
|
|
|
//bStatus 开门结果
|
|
|
GateOplog opLog = new GateOplog();
|
|
|
opLog.setGateName("");
|
|
|
- opLog.setProjectId(0);
|
|
|
+ opLog.setProjectId(project);
|
|
|
opLog.setUserName(szCardName);
|
|
|
opLog.setEventType(openMethod);
|
|
|
- opLog.setStatus("");
|
|
|
+ if (rets[i].emDirection == NetSDKLib.NET_ENUM_DIRECTION_ACCESS_CTL.NET_ENUM_DIRECTION_ENTRY) {
|
|
|
+ opLog.setStatus("进门");
|
|
|
+ } else if (rets[i].emDirection == NetSDKLib.NET_ENUM_DIRECTION_ACCESS_CTL.NET_ENUM_DIRECTION_EXIT) {
|
|
|
+ opLog.setStatus("出门");
|
|
|
+ } else {
|
|
|
+ opLog.setStatus("");
|
|
|
+ }
|
|
|
opLog.setSerialNum(new String(value.sSerialNumber));
|
|
|
|
|
|
Date d = new Date();
|
|
@@ -104,6 +122,10 @@ public class GateLogService {
|
|
|
System.err.println("解析时间发生错误: " + excep.getMessage());
|
|
|
}
|
|
|
opLog.setCreatedTime(d);
|
|
|
+ opLog.setCheckType("");
|
|
|
+ byte isDelete = 0;
|
|
|
+ opLog.setIsDelete(isDelete);
|
|
|
+
|
|
|
gateOplogMapper.insert(opLog);
|
|
|
}
|
|
|
//断开查询句柄
|