|
@@ -1,8 +1,11 @@
|
|
|
package com.jpsoft.smart.lapi.handler;
|
|
|
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.jpsoft.smart.config.OSSConfig;
|
|
|
import com.jpsoft.smart.lapi.dto.PersonVerification;
|
|
|
+import com.jpsoft.smart.lapi.dto.PersonVerificationResponseInfo;
|
|
|
import com.jpsoft.smart.modules.base.entity.PersonInfo;
|
|
|
import com.jpsoft.smart.modules.base.service.PersonDeviceFilterLogService;
|
|
|
import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
|
|
@@ -11,11 +14,16 @@ import com.jpsoft.smart.modules.common.utils.LApiUtil;
|
|
|
import com.jpsoft.smart.modules.common.utils.OSSUtil;
|
|
|
import com.jpsoft.smart.modules.sys.entity.SysLog;
|
|
|
import com.jpsoft.smart.modules.sys.service.SysLogService;
|
|
|
+import io.netty.buffer.ByteBuf;
|
|
|
+import io.netty.buffer.Unpooled;
|
|
|
import io.netty.channel.ChannelHandler;
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
|
import io.netty.channel.SimpleChannelInboundHandler;
|
|
|
+import io.netty.handler.codec.http.*;
|
|
|
+import io.netty.util.CharsetUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.joda.time.DateTime;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -51,6 +59,13 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
|
|
|
@Autowired
|
|
|
private SysLogService sysLogService;
|
|
|
|
|
|
+ private final String X_FRAME_OPTIONS = "X-Frame-Options";
|
|
|
+ private final String SAMEORIGIN = "SAMEORIGIN";
|
|
|
+ private final String JSON_PLAIN = "application/json";
|
|
|
+ private final String CONTENT_LENGTH = "Content-Length";
|
|
|
+ private final String CONTENT_TYPE = "Content-Type";
|
|
|
+ private final String CONNECTION = "Connection";
|
|
|
+
|
|
|
@Override
|
|
|
protected void channelRead0(ChannelHandlerContext ctx, PersonVerification personVerification) throws Exception {
|
|
|
new Thread(()->{
|
|
@@ -88,10 +103,7 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
|
|
|
JSONObject faceImageJson = faceJson.getJSONObject("FaceImage");
|
|
|
|
|
|
//匹配状态信息
|
|
|
- JSONObject libMatInfoListJson = new JSONObject();
|
|
|
- if (StringUtils.isNotBlank(jsonObject.getStr("LibMatInfoList").substring(1,jsonObject.getStr("LibMatInfoList").length()-1))){
|
|
|
- libMatInfoListJson = new JSONObject(jsonObject.getStr("LibMatInfoList").substring(1,jsonObject.getStr("LibMatInfoList").length()-1));
|
|
|
- }
|
|
|
+ JSONObject libMatInfoListJson = jsonObject.getJSONArray("LibMatInfoList").getJSONObject(0);
|
|
|
|
|
|
//匹配人员信息
|
|
|
JSONObject matchPersonInfo = new JSONObject();
|
|
@@ -100,12 +112,15 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
|
|
|
}
|
|
|
|
|
|
log.warn("人员记录写入");
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
HashMap map = new HashMap<>();
|
|
|
map.put("deviceNo",deviceNo);
|
|
|
map.put("temperature",temperature);
|
|
|
map.put("libMatInfoListJson",libMatInfoListJson);
|
|
|
map.put("matchPersonInfo",matchPersonInfo);
|
|
|
+ map.put("recordTime",sdf.format(date));
|
|
|
+
|
|
|
log.warn(map.toString());
|
|
|
|
|
|
SysLog sysLog = new SysLog();
|
|
@@ -164,5 +179,32 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
|
|
|
}
|
|
|
|
|
|
log.warn("===人员记录异步处理 end===");
|
|
|
+
|
|
|
+ //返回数据
|
|
|
+ try {
|
|
|
+ log.warn("===人员记录回包处理 end===");
|
|
|
+ PersonVerificationResponseInfo responseInfo = new PersonVerificationResponseInfo();
|
|
|
+
|
|
|
+ responseInfo.getResponse().setResponseURL("/LAPI/V1.0/PACS/Controller/Event/Notifications");
|
|
|
+ responseInfo.getResponse().setStatusCode(0);
|
|
|
+ responseInfo.getResponse().setStatusString("Succeed");
|
|
|
+ responseInfo.getResponse().getData().setRecordID(libMatInfoListJson.getInt("ID"));
|
|
|
+ responseInfo.getResponse().getData().setTime(DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
|
|
|
+
|
|
|
+ String json = JSONUtil.toJsonStr(responseInfo);
|
|
|
+
|
|
|
+ FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, Unpooled.wrappedBuffer(json.getBytes("UTF-8")));
|
|
|
+ response.headers().set(CONTENT_LENGTH, response.content().readableBytes());
|
|
|
+ response.headers().set(CONTENT_TYPE, JSON_PLAIN);
|
|
|
+ response.headers().set(CONNECTION, HttpHeaderValues.CLOSE);
|
|
|
+ response.headers().set(X_FRAME_OPTIONS, SAMEORIGIN);
|
|
|
+
|
|
|
+ ctx.channel().writeAndFlush(response);
|
|
|
+
|
|
|
+ log.warn("===人员记录回包结束 end===");
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+ }
|
|
|
}
|
|
|
}
|