nanjing-yancao-wuliuzhongxin
yiming 3 years ago
parent 1df6db5614
commit 67d3a94331

@ -1,20 +1,10 @@
package com.zhehekeji.web.controller;
import com.alibaba.fastjson.JSONObject;
import com.zhehekeji.common.util.HttpUtil;
import com.zhehekeji.core.pojo.Result;
import com.zhehekeji.core.util.Assert;
import com.zhehekeji.web.pojo.IndexVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
@Api(value = "AppCenterController", tags = "用户中心")
@RequestMapping(value = "/app")
@RestController(value = "AppCenterController")
@ -37,4 +27,6 @@ public class AppCenterController {
// }
// return result;
// }
}

@ -26,7 +26,7 @@ public class Decoder extends DelimiterBasedFrameDecoder {
private static final Logger tcpLogger = LoggerFactory.getLogger("tcp");
private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(7,21,30, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<>(20000));
private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5,15,30, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<>(20000));
private EmptyCheckService emptyCheckService;
@ -69,13 +69,13 @@ public class Decoder extends DelimiterBasedFrameDecoder {
@Override
public void run() {
String body = in.toString(Charset.forName("UTF-8"));
tcpLogger.info("client rece:{}",body);
tcpLogger.info("client:{}",body);
if(body.startsWith(HBTransmission.getHEADER())) {
//心跳
HBTransmission hbTransmission = new HBTransmission(body);
//回复客户端心跳
ctx.channel().writeAndFlush(hbTransmission.toString());
tcpLogger.info("client:{} heart", hbTransmission.getSRMNumber());
//tcpLogger.info("client:{} heart", hbTransmission.getSRMNumber());
in.release();
} else if(body.startsWith(TMTransmission.getHeader())){
//盘点指令

@ -17,7 +17,7 @@ public class Encoder extends MessageToByteEncoder<String> {
@Override
protected void encode(ChannelHandlerContext channelHandlerContext, String data, ByteBuf byteBuf) throws Exception {
data = data + ";";
tcpLogger.info(data);
tcpLogger.info("send to client:{}",data);
byteBuf.writeBytes(data.getBytes(StandardCharsets.UTF_8));
}
}

@ -33,7 +33,7 @@ public class KsecDecoder extends DelimiterBasedFrameDecoder {
private static String lastLotnum;
private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(7,21,30, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<>(20000));
//private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(7,21,30, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<>(20000));
private PlcService plcService;
@ -49,8 +49,8 @@ public class KsecDecoder extends DelimiterBasedFrameDecoder {
log.debug("no data");
return null;
}
KescRunnable kescRunnable = new KescRunnable(in,ctx,plcService);
threadPoolExecutor.execute(kescRunnable);
//KescRunnable kescRunnable = new KescRunnable(in,ctx,plcService);
//threadPoolExecutor.execute(kescRunnable);
return null;
}

@ -73,7 +73,7 @@ public class PTDecoder extends LineBasedFrameDecoder {
@Override
public void run() {
String body = in.toString(Charset.forName("UTF-8"));
tcpLogger.info("received from PT:{}",body);
tcpLogger.info("PT:{}",body);
PTData ptData = new PTData(body);
if(ptData.getType().equals(PTData.HEART_TYPE)){

@ -38,7 +38,7 @@ public class PTFilter extends ChannelInitializer<SocketChannel> {
//30秒发一次心跳
ph.addLast(new IdleStateHandler(0, 30, 0, TimeUnit.SECONDS));
ByteBuf byteBuf = Unpooled.copiedBuffer(">".getBytes());
ph.addLast(new PTDecoder(1000,false,true,emptyCheckService));
ph.addLast(new PTDecoder(1000,false,true,emptyCheckService,plcService));
ph.addLast(new PtEncoder());
ph.addLast(new PTNettyHandler(nettyClient));
}

Loading…
Cancel
Save