|
@@ -1,13 +1,17 @@
|
|
package com.phm.netty.server.handler;
|
|
package com.phm.netty.server.handler;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
+import com.phm.manage.domain.OrderConfig;
|
|
|
|
+import com.phm.manage.domain.common.CommonResult;
|
|
import com.phm.netty.constant.MsgConstant;
|
|
import com.phm.netty.constant.MsgConstant;
|
|
import com.phm.netty.domain.Message;
|
|
import com.phm.netty.domain.Message;
|
|
import com.phm.netty.enums.OrderEnum;
|
|
import com.phm.netty.enums.OrderEnum;
|
|
import com.phm.netty.service.IProcessService;
|
|
import com.phm.netty.service.IProcessService;
|
|
import com.phm.netty.utils.BitUtils;
|
|
import com.phm.netty.utils.BitUtils;
|
|
import com.phm.netty.utils.ChannelMap;
|
|
import com.phm.netty.utils.ChannelMap;
|
|
|
|
+import com.phm.netty.utils.JsonUtils;
|
|
import io.netty.channel.Channel;
|
|
import io.netty.channel.Channel;
|
|
import io.netty.channel.ChannelHandler;
|
|
import io.netty.channel.ChannelHandler;
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
@@ -18,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.annotation.PostConstruct;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description ByteArrayMessageHandler
|
|
* @Description ByteArrayMessageHandler
|
|
@@ -87,15 +92,27 @@ public class ByteArrayMessageHandler extends SimpleChannelInboundHandler<byte[]>
|
|
// 校时功能
|
|
// 校时功能
|
|
byteArrayMessageHandler.processService.timing(msg);
|
|
byteArrayMessageHandler.processService.timing(msg);
|
|
}
|
|
}
|
|
- if (OrderEnum.PARAMETER.getType() == type) {
|
|
|
|
|
|
+ if (OrderEnum.ORDER_CONFIG.getType() == type) {
|
|
// 参数传递
|
|
// 参数传递
|
|
- lastMsg = byteArrayMessageHandler.processService.getParameterConfig(msg);
|
|
|
|
|
|
+ List<OrderConfig> configList = byteArrayMessageHandler.processService.getParameterConfig(msg);
|
|
|
|
+ // 分批处理
|
|
|
|
+ List<List<OrderConfig>> batches = CollUtil.split(configList, 10);
|
|
|
|
+ Message msgParameter = new Message();
|
|
|
|
+ for (List<OrderConfig> batch : batches) {
|
|
|
|
+ msgParameter.setType(OrderEnum.ORDER_CONFIG.getType()).setData(JsonUtils.convertJson(CommonResult.success(batch)));
|
|
|
|
+ log.info("msgParameter==={}",msgParameter);
|
|
|
|
+ ctx.writeAndFlush(Message.msgToBytes(msgParameter));
|
|
|
|
+ }
|
|
|
|
+ // 结束传输标识
|
|
|
|
+ msgParameter.setType(OrderEnum.ORDER_CONFIG.getType()).setData(JsonUtils.convertJson(CommonResult.complete("{\"cmdId\":\"complete\"}")));
|
|
|
|
+ log.info("msgParameter end ==={}",msgParameter);
|
|
|
|
+ ctx.writeAndFlush(Message.msgToBytes(msgParameter));
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
if (ObjectUtil.isEmpty(lastMsg)) {
|
|
if (ObjectUtil.isEmpty(lastMsg)) {
|
|
log.info("Message数据为空");
|
|
log.info("Message数据为空");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- log.info("应答内容:{}", lastMsg);
|
|
|
|
// 转byte[] 返回消息
|
|
// 转byte[] 返回消息
|
|
ctx.writeAndFlush(Message.msgToBytes(lastMsg));
|
|
ctx.writeAndFlush(Message.msgToBytes(lastMsg));
|
|
}
|
|
}
|