|
@@ -23,6 +23,7 @@ import com.smartsanitation.common.util.StringUtil;
|
|
|
import com.tidecloud.dataacceptance.entity.Advice;
|
|
|
import com.tidecloud.dataacceptance.entity.ConnectMsg;
|
|
|
import com.tidecloud.dataacceptance.entity.Device;
|
|
|
+import com.tidecloud.dataacceptance.entity.HrtStart;
|
|
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
import io.netty.buffer.Unpooled;
|
|
@@ -98,12 +99,47 @@ public class WatchServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
case "UPLOAD":
|
|
|
logger.info("device [{}] setting copy time success [{}]", deviceId, new Date());
|
|
|
break;
|
|
|
+ case "HRTSTART":
|
|
|
+ dataStorageHartstart(deviceId, msg);
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private void dataStorageHartstart(String deviceId, String msg) {
|
|
|
+ int startIndex = msg.indexOf("[");
|
|
|
+ int endIndex = msg.indexOf("]");
|
|
|
+ String data = msg.substring(startIndex + 1, endIndex);
|
|
|
+ String[] bodys = data.split(",");
|
|
|
+
|
|
|
+ HrtStart hrtStart = new HrtStart();
|
|
|
+ hrtStart.setDate(new Date());
|
|
|
+ hrtStart.setDeviceId(deviceId);
|
|
|
+ hrtStart.setHrtCount(getInteger(bodys[1]));
|
|
|
+ String deviceStr = HrtStart.buildHrtStart(hrtStart);
|
|
|
+
|
|
|
+ File path = new File(dataPath);
|
|
|
+ File[] listFiles = path.listFiles();
|
|
|
+ boolean isTouch = true;
|
|
|
+ for (File sonFile : listFiles) {
|
|
|
+ long len = sonFile.length();
|
|
|
+ if (len < TEN_M) {
|
|
|
+ // String fileName = dataPath + prefixName + new SimpleDateFormat("yyMMddHHmmss").format(new Date());
|
|
|
+ // File file = new File(fileName);
|
|
|
+ writeDevice2File(sonFile, deviceStr);
|
|
|
+ logger.info("正在写入数据: " + deviceStr);
|
|
|
+ isTouch = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isTouch) {
|
|
|
+ String fileName = dataPath + prefixName + new SimpleDateFormat("yyMMddHHmmss").format(new Date());
|
|
|
+ File file = new File(fileName);
|
|
|
+ writeDevice2File(file, deviceStr);
|
|
|
+ logger.info("满10M,创建新的文件 正在写入数据:" + deviceStr + "timestamp:" + new SimpleDateFormat("yyMMddHHmmss").format(new Date()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void manageLink(Channel channel, String deviceId) {
|
|
|
String channelId = UUID.randomUUID().toString();
|
|
|
manageChannelMap.put(channelId, channel);
|