|
@@ -162,373 +162,12 @@ public class LampInputServerHandler extends ChannelInboundHandlerAdapter {
|
|
//获取保温箱配置
|
|
//获取保温箱配置
|
|
lampInputHandleService.getLampConfig(askText, idCode, ctx);
|
|
lampInputHandleService.getLampConfig(askText, idCode, ctx);
|
|
break;
|
|
break;
|
|
-// case "4":
|
|
|
|
-// //上传湿度数据
|
|
|
|
-// uploadHumi(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "5":
|
|
|
|
-// //氨气数据上传
|
|
|
|
-// uploadAmmonia(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "6":
|
|
|
|
-// //获取喷雾除臭配置
|
|
|
|
-// getSprayConfig(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "7":
|
|
|
|
-// //上报喷雾除臭状态
|
|
|
|
-// uploadSprayEquipStatus(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "8":
|
|
|
|
-// //水压
|
|
|
|
-// uploadWaterGege(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "9":
|
|
|
|
-// //PH
|
|
|
|
-// uploadPH(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "10":
|
|
|
|
-// //水表
|
|
|
|
-// uploadWaterMeter(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "11":
|
|
|
|
-// //电表
|
|
|
|
-// uploadElectricityMeter(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "12":
|
|
|
|
-// //获取设备开关
|
|
|
|
-// getSparySwitch(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "13":
|
|
|
|
-// //上报设备状态
|
|
|
|
-// getSparyStatus(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-//
|
|
|
|
-// case "14":
|
|
|
|
-// //获取报警使能
|
|
|
|
-// getAlarmConfig(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "15":
|
|
|
|
-// //短信发送
|
|
|
|
-// uploadSendMessage(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "16":
|
|
|
|
-// //声光报警短信
|
|
|
|
-// uploadAudibleAndVisualAlarmMessage(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "17":
|
|
|
|
-// //报警器打电话
|
|
|
|
-// uploadTelephoneAlarm(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "18":
|
|
|
|
-// //高温,低温报警参数请求
|
|
|
|
-// getTempThresholdConfig(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
-// case "19":
|
|
|
|
-// //平台消息推送
|
|
|
|
-// uploadPlatformMessagePushInfo(askText, idCode, ctx);
|
|
|
|
-// break;
|
|
|
|
default:
|
|
default:
|
|
System.out.println("==>未知命令");
|
|
System.out.println("==>未知命令");
|
|
log.error(">>当前数据为非法数据-未知命令>>" + askText);
|
|
log.error(">>当前数据为非法数据-未知命令>>" + askText);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-// //上报设备状态
|
|
|
|
-// private void getSparyStatus(String askText, String deviceCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>上报设备状态上传请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(deviceCode)) {
|
|
|
|
-// System.out.println("##上报设备状态上传请求-未注册设备 deviceCode=" + deviceCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// //上报设备状态
|
|
|
|
-// String answerText = "hm+118+13+1010101010101010+201702081523+6+end";
|
|
|
|
-// log.info(">>上报设备状态上传请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// //上报设备状态请求到消息队列
|
|
|
|
-//// producer.sendWaterGege(askText);
|
|
|
|
-// }
|
|
|
|
-// //获取设备开关
|
|
|
|
-// private void getSparySwitch(String askText, String deviceCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>获取设备开关上传请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(deviceCode)) {
|
|
|
|
-// System.out.println("##获取设备开关上传请求-未注册设备 deviceCode=" + deviceCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// //TODO 获取设备开关请求
|
|
|
|
-// String answerText = "hm+118+12+1010101010101010+6+end";
|
|
|
|
-// log.info(">>获取设备开关上传请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// //获取设备开关请求
|
|
|
|
-//// producer.sendWaterGege(askText);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //电表
|
|
|
|
-// private void uploadElectricityMeter(String askText, String deviceCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>电表上传请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(deviceCode)) {
|
|
|
|
-// System.out.println("##电表上传请求-未注册设备 deviceCode=" + deviceCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// //电表上传请求
|
|
|
|
-// String answerText = "hm+11+0+7+end";
|
|
|
|
-// log.info(">>电表上传请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// //电表请求到消息队列
|
|
|
|
-//// producer.sendWaterGege(askText);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //水表
|
|
|
|
-// private void uploadWaterMeter(String askText, String deviceCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>水表上传请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(deviceCode)) {
|
|
|
|
-// System.out.println("##水表上传请求-未注册设备 deviceCode=" + deviceCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// //水表上传请求
|
|
|
|
-// String answerText = "hm+10+0+7+end";
|
|
|
|
-// log.info(">>水表上传请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// //发送水表请求到消息队列
|
|
|
|
-//// producer.sendWaterGege(askText);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //PH
|
|
|
|
-// private void uploadPH(String askText, String deviceCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>PH上传请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(deviceCode)) {
|
|
|
|
-// System.out.println("##PH上传请求-未注册设备 deviceCode=" + deviceCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// //PH传请求
|
|
|
|
-// String answerText = "hm+9+0+7+end";
|
|
|
|
-// log.info(">>PH上传请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// //发送PH请求到消息队列
|
|
|
|
-//// producer.sendWaterGege(askText);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //水压
|
|
|
|
-// private void uploadWaterGege(String askText, String deviceCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>水压上传请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(deviceCode)) {
|
|
|
|
-// System.out.println("##水压上传请求-未注册设备 deviceCode=" + deviceCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// //水压上传请求
|
|
|
|
-// String answerText = "hm+8+0+7+end";
|
|
|
|
-// log.info(">>水压上传请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// //水压请求到消息队列
|
|
|
|
-// producer.sendWaterGege(askText);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //平台消息推送请求
|
|
|
|
-// private void uploadPlatformMessagePushInfo(String askText, String idCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>平台消息推送请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(idCode)) {
|
|
|
|
-// System.out.println("##平台消息推送请求-未注册设备 idCode=" + idCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// String answerText = "hm+19+0+2+end";
|
|
|
|
-// log.info(">>平台消息推送请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-//
|
|
|
|
-// //发送喷雾设备状态到消息队列
|
|
|
|
-// producer.sendPushMessageToMQ(askText);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //高温,低温报警参数请求
|
|
|
|
-// private void getTempThresholdConfig(String askText, String idCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>高温,低温报警参数请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(idCode)) {
|
|
|
|
-// System.out.println("##高温,低温报警参数请求-未注册设备 idCode=" + idCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// String threshold = tempThresholdService.getTempThresholdByDeviceCode(idCode);
|
|
|
|
-// String answerText = "hm+"+idCode+"+18+"+threshold+"+6+end";
|
|
|
|
-// log.info(">>高温,低温报警参数请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //报警器打电话请求
|
|
|
|
-// private void uploadTelephoneAlarm(String askText, String idCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>报警器打电话请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(idCode)) {
|
|
|
|
-// System.out.println("##报警器打电话请求-未注册设备 idCode=" + idCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// String answerText = "hm+17+0+2+end";
|
|
|
|
-// log.info(">>报警器打电话请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //声光报警短信发送请求
|
|
|
|
-// private void uploadAudibleAndVisualAlarmMessage(String askText, String idCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>声光报警短信发送请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(idCode)) {
|
|
|
|
-// System.out.println("##声光报警短信发送请求-未注册设备 idCode=" + idCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// String answerText = "hm+16+0+2+end";
|
|
|
|
-// log.info(">>声光报警短信发送请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //短信发送请求
|
|
|
|
-// private void uploadSendMessage(String askText, String idCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>短信发送请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(idCode)) {
|
|
|
|
-// System.out.println("##>短信发送请求-未注册设备 idCode=" + idCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// String answerText = "hm+15+0+2+end";
|
|
|
|
-// log.info(">>>短信发送请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //获取报警使能请求
|
|
|
|
-// private void getAlarmConfig(String askText, String idCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>获取报警使能请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(idCode)) {
|
|
|
|
-// System.out.println("##获取报警使能请求-未注册设备 idCode=" + idCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// //(声光报警、短信报警、语音报警) 1:关闭,2:打开
|
|
|
|
-// String answerText = "hm+"+idCode+"+14+2(111)2(111)2(111)2(111)2(111)+0+4+end";
|
|
|
|
-// log.info(">>获取报警使能请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //上报喷雾除臭状态请求
|
|
|
|
-// private void uploadSprayEquipStatus(String askText, String idCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>上报喷雾除臭状态请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(idCode)) {
|
|
|
|
-// System.out.println("##上报喷雾除臭状态请求-未注册设备 idCode=" + idCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// String answerText = "hm+" + idCode + "+7+6+end";
|
|
|
|
-// log.info(">>上报喷雾除臭状态请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// //发送喷雾设备状态到消息队列
|
|
|
|
-// producer.sendSprayEquipStatusToMQ(askText);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //获取喷雾除臭配置请求
|
|
|
|
-// private void getSprayConfig(String askText, String deviceCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>获取喷雾除臭配置请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(deviceCode)) {
|
|
|
|
-// System.out.println("##获取喷雾除臭配置请求-未注册设备 idCode=" + deviceCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// //读取设备注册信息
|
|
|
|
-// EnvDeviceRegisterEntity envDeviceRegisterEntity = deviceRegisterService.getDeviceRegisterByDeviceCode(deviceCode);
|
|
|
|
-// if (envDeviceRegisterEntity == null) {
|
|
|
|
-// log.error("该设备[" + deviceCode + "]未注册.");
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// java.sql.Date todayDate = new java.sql.Date(new java.util.Date().getTime());
|
|
|
|
-// Timestamp nowTimestamp = new Timestamp(new java.util.Date().getTime());
|
|
|
|
-// String farmCode = envDeviceRegisterEntity.getFarmCode();
|
|
|
|
-//
|
|
|
|
-// //读取喷雾配置表数据
|
|
|
|
-// JSONObject configJo = sprayConfigService.getSprayConfigByDeviceCode(deviceCode, farmCode);
|
|
|
|
-// int runMode = configJo.getInteger("runMode");
|
|
|
|
-// int deviceStatus = configJo.getInteger("deviceStatus");
|
|
|
|
-// int timeInterval = configJo.getInteger("timeInterval") * 60;
|
|
|
|
-// //读取定时时间配置表数据
|
|
|
|
-// String sprayTime = sprayTimeService.getSprayTimeByDeviceCode(deviceCode);
|
|
|
|
-//// String answerText = "hm+"+deviceCode+"+6+1+1+0101,60,10,10,0202,60,10,10,0303,60,10,10,0404,60,10,10+60+6+end";
|
|
|
|
-// String answerText = "hm+" + deviceCode + "+6+" + runMode + "+" + deviceStatus + "+" + sprayTime + "+" + timeInterval + "+6+end";
|
|
|
|
-// log.info("<<获取喷雾除臭配置请求-应答数据<<" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //氨气度上传请求
|
|
|
|
-// private void uploadAmmonia(String askText, String idCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>氨气度上传请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(idCode)) {
|
|
|
|
-// System.out.println("##氨气度上传请求-未注册设备 idCode=" + idCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// String answerText = "hm+5+0+8+end";
|
|
|
|
-// log.info(">>氨气度上传请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-//
|
|
|
|
-// //发送氨气请求到消息队列
|
|
|
|
-// producer.sendAmmoniaAskToMQ(askText);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //湿度度上传请求
|
|
|
|
-// private void uploadHumi(String askText, String idCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>湿度度上传请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(idCode)) {
|
|
|
|
-// System.out.println("##湿度度上传请求-未注册设备 idCode=" + idCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// String answerText = "hm+4+0+8+end";
|
|
|
|
-// log.info(">>湿度度上传请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// //发送湿度请求到消息队列
|
|
|
|
-// producer.sendHumiAskToMQ(askText);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// // 温度度上传
|
|
|
|
-// private void uploadTemp(String askText, String deviceCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>温度度上传请求 askText>>" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(deviceCode)) {
|
|
|
|
-// System.out.println("##温度度上传请求-未注册设备 deviceCode=" + deviceCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// //温度度上传请求
|
|
|
|
-// String answerText = "hm+3+0+7+end";
|
|
|
|
-// log.info(">>温度度上传请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// //发送温度请求到消息队列
|
|
|
|
-// producer.sendTempAskToMQ(askText);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //时间同步请求
|
|
|
|
-// private void getServerTime(String askText, String deviceCode, ChannelHandlerContext ctx) throws ParseException {
|
|
|
|
-// System.out.println("==>时间同步请求:" + askText);
|
|
|
|
-// if (!cmdProService.isEffectiveDevice(deviceCode)) {
|
|
|
|
-// System.out.println("##时间同步请求-未注册设备 idCode=" + deviceCode);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// String answerText = "hm+2+" + dateUtil.getNowText() + "+0+4+end";
|
|
|
|
-// log.info(">>时间同步请求-应答数据>>" + answerText);
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //获取远程设备编码
|
|
|
|
-// private void getDeviceCode(String askText, String idCode, ChannelHandlerContext ctx) {
|
|
|
|
-// System.out.println("==>获取远程设备编码请求:" + askText.trim());
|
|
|
|
-// //{读取设备编码}
|
|
|
|
-// String deviceCode = cmdProService.getDeviceCodeByChipId(idCode);
|
|
|
|
-// log.info("获取远程设备编码请求,芯片id>>" + idCode + " ,deviceCode>>" + deviceCode);
|
|
|
|
-// if (deviceCode == null) {
|
|
|
|
-// log.error("该设备未注册,已舍弃请求.");
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// String answerText = "hm+1+0+" + deviceCode + "+123+8+end";
|
|
|
|
-// log.info("<<获取远程设备编码请求-应答数据:" + answerText);
|
|
|
|
-// //{应答指令}
|
|
|
|
-// answerCmd(answerText, ctx);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
- //应答
|
|
|
|
- public void answerCmd(String answerText, ChannelHandlerContext ctx) {
|
|
|
|
- ctx.writeAndFlush(Unpooled.copiedBuffer(answerText.getBytes()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //检查无效耳标
|
|
|
|
- public boolean checkValidEarmark(String earmark) {
|
|
|
|
- if (earmark.trim().equalsIgnoreCase("ffffffffffffffff") || earmark.trim().equalsIgnoreCase("0000000000000000")) {
|
|
|
|
- return true;
|
|
|
|
- } else {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
//拆分粘包数据
|
|
//拆分粘包数据
|
|
public JSONArray parseAskCmdPackage(String text) {
|
|
public JSONArray parseAskCmdPackage(String text) {
|
|
String key = "end";
|
|
String key = "end";
|