|
@@ -1,14 +1,17 @@
|
|
|
package com.jpsoft.smart.lapi.handler;
|
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.jpsoft.smart.modules.lapi.channel.LapiAttrKeys;
|
|
|
import com.jpsoft.smart.modules.lapi.channel.LapiChannel;
|
|
|
import com.jpsoft.smart.lapi.dto.HeartReportInfo;
|
|
|
import com.jpsoft.smart.modules.base.service.DeviceInfoService;
|
|
|
import com.jpsoft.smart.modules.sys.entity.SysLog;
|
|
|
import com.jpsoft.smart.modules.sys.service.SysLogService;
|
|
|
+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 lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.joda.time.DateTime;
|
|
@@ -18,6 +21,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.net.SocketAddress;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
@@ -99,6 +103,34 @@ public class HeartReportHandler extends SimpleChannelInboundHandler<HeartReportI
|
|
|
|
|
|
activeLapiChannelMap.put(deviceNo, lapiChannel);
|
|
|
}
|
|
|
+
|
|
|
+ //返回数据
|
|
|
+ try {
|
|
|
+ log.warn("===心跳记录回包处理 start===");
|
|
|
+ Map<String,Object> responseInfo = new HashMap<>();
|
|
|
+ Map<String,Object> dataMap = new HashMap<>();
|
|
|
+
|
|
|
+ dataMap.put("Time",DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
|
|
|
+
|
|
|
+ responseInfo.put("ResponseURL","/LAPI/V1.0/PACS/Controller/HeartReportInfo");
|
|
|
+ responseInfo.put("Code", 0);
|
|
|
+ responseInfo.put("Data",dataMap);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|