|
@@ -1,5 +1,7 @@
|
|
|
package com.greentech.gateservice.task;
|
|
|
|
|
|
+import com.greentech.gateservice.entity.GateOplog;
|
|
|
+import com.greentech.gateservice.mapper.GateOplogMapper;
|
|
|
import com.greentech.gateservice.util.LoginModule;
|
|
|
import com.netsdk.common.Res;
|
|
|
import com.netsdk.lib.NetSDKLib;
|
|
@@ -7,15 +9,25 @@ import com.netsdk.lib.ToolKits;
|
|
|
import com.sun.jna.Memory;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
+@RequestMapping("crud")
|
|
|
@Service
|
|
|
public class GateLogService {
|
|
|
+ GateOplogMapper gateOplogMapper;
|
|
|
+
|
|
|
@Scheduled(cron = "0 * * * * *")
|
|
|
public void syncLog() {
|
|
|
System.out.println("--开始执行日志查询同步任务--");
|
|
|
+ String format = "yyyy-MM-dd HH:mm:ss";
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat(format);
|
|
|
//获取前一小时
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
LocalDateTime startTime = now.minusHours(1);
|
|
@@ -74,11 +86,27 @@ public class GateLogService {
|
|
|
for (int i = 0; i < outNextParam.nRetRecordNum; i++) {
|
|
|
String szCardName = new String(rets[i].szCardName);
|
|
|
String openMethod = Res.string().getOpenMethods(rets[i].emMethod);
|
|
|
- System.out.println("人名:" + szCardName + "时间:" + rets[i].stuTime.toStringTime() + "开门方式" + openMethod);
|
|
|
+ System.out.println("人名:" + szCardName + "时间:" + rets[i].stuTime.toStringTimeEx() + "开门方式" + openMethod);
|
|
|
System.out.println("开门方向:"+rets[i].emDirection);
|
|
|
//bStatus 开门结果
|
|
|
- }
|
|
|
+ GateOplog opLog = new GateOplog();
|
|
|
+ opLog.setGateName("");
|
|
|
+ opLog.setProjectId(0);
|
|
|
+ opLog.setUserName(szCardName);
|
|
|
+ opLog.setEventType(openMethod);
|
|
|
+ opLog.setStatus("");
|
|
|
+ opLog.setSerialNum(new String(value.sSerialNumber));
|
|
|
|
|
|
+ Date d = new Date();
|
|
|
+ try {
|
|
|
+ d = sdf.parse(rets[i].stuTime.toStringTimeEx());
|
|
|
+ }catch (ParseException excep) {
|
|
|
+ System.err.println("解析时间发生错误: " + excep.getMessage());
|
|
|
+ }
|
|
|
+ opLog.setCreatedTime(d);
|
|
|
+ gateOplogMapper.insert(opLog);
|
|
|
+ }
|
|
|
+ //断开查询句柄
|
|
|
LoginModule.netsdk.CLIENT_FindRecordClose(outParam.lFindeHandle);
|
|
|
System.out.println("查询结束");
|
|
|
}
|