1.设备注册接入优化
2.波形文件接收、解析功能调整
This commit is contained in:
@@ -12,8 +12,16 @@ import com.njcn.access.enums.AccessEnum;
|
||||
import com.njcn.access.enums.TypeEnum;
|
||||
import com.njcn.access.pojo.dto.ReqAndResDto;
|
||||
import com.njcn.access.pojo.dto.mqtt.MqttClientDto;
|
||||
import com.njcn.access.service.ICsEquipmentDeliveryService;
|
||||
import com.njcn.access.service.impl.CsDeviceServiceImpl;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import io.lettuce.core.protocol.CompleteableCommand;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.Credentials;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
@@ -26,15 +34,15 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Array;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
@@ -42,6 +50,7 @@ import java.util.stream.Collectors;
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@SpringBootTest(classes = AccessBootApplication.class)
|
||||
@Slf4j
|
||||
public class AppTest
|
||||
{
|
||||
/**
|
||||
@@ -56,6 +65,35 @@ public class AppTest
|
||||
@Resource
|
||||
private MqttPublisher publisher;
|
||||
|
||||
@Resource
|
||||
private FileStorageUtil fileStorageUtil;
|
||||
|
||||
@Resource
|
||||
private ICsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||
|
||||
@Resource
|
||||
private CsDeviceServiceImpl csDeviceService;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Test
|
||||
public void lossTest() {
|
||||
String nDid = "0008C0A801C8";
|
||||
Integer status = csEquipmentDeliveryService.queryEquipmentByndid(nDid).getRunStatus();
|
||||
if (!Objects.isNull(status) && Objects.equals(status,AccessEnum.ONLINE.getCode())){
|
||||
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(2);
|
||||
ScheduledFuture<?> runnableFuture = executor.scheduleAtFixedRate(() -> {
|
||||
log.info("定时发送接入请求...");
|
||||
Integer status2 = csEquipmentDeliveryService.queryEquipmentByndid(nDid).getRunStatus();
|
||||
if (Objects.equals(status2,AccessEnum.OFFLINE.getCode())){
|
||||
throw new BusinessException(CommonResponseEnum.SUCCESS);
|
||||
}
|
||||
}, 1, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
@@ -69,49 +107,43 @@ public class AppTest
|
||||
// String key = String.valueOf(IdUtil.getSnowflake().nextId());
|
||||
// System.out.println("key==:" + key);
|
||||
|
||||
List<CsLinePO> csLinePoList = new ArrayList<>();
|
||||
CsLinePO po1 = new CsLinePO();
|
||||
po1.setPosition("1");
|
||||
CsLinePO po2= new CsLinePO();
|
||||
po2.setPosition("2");
|
||||
CsLinePO po3= new CsLinePO();
|
||||
po3.setPosition("3");
|
||||
CsLinePO po4= new CsLinePO();
|
||||
po4.setPosition("1");
|
||||
// List<CsLinePO> csLinePoList = new ArrayList<>();
|
||||
// CsLinePO po1 = new CsLinePO();
|
||||
// po1.setPosition("1");
|
||||
// CsLinePO po2= new CsLinePO();
|
||||
// po2.setPosition("2");
|
||||
// CsLinePO po3= new CsLinePO();
|
||||
// po3.setPosition("3");
|
||||
// CsLinePO po4= new CsLinePO();
|
||||
// po4.setPosition("1");
|
||||
//
|
||||
// csLinePoList.add(po1);
|
||||
// csLinePoList.add(po2);
|
||||
// csLinePoList.add(po3);
|
||||
// csLinePoList.add(po4);
|
||||
// List<String> l = csLinePoList.stream().map(CsLinePO::getPosition).collect(Collectors.toList());
|
||||
// System.out.println("l===:" + l);
|
||||
// List<String> lineList = l.stream().filter(e-> Collections.frequency(l,e) > 1).distinct().collect(Collectors.toList());
|
||||
// System.out.println("lineList==:" + lineList);
|
||||
|
||||
csLinePoList.add(po1);
|
||||
csLinePoList.add(po2);
|
||||
csLinePoList.add(po3);
|
||||
csLinePoList.add(po4);
|
||||
List<String> l = csLinePoList.stream().map(CsLinePO::getPosition).collect(Collectors.toList());
|
||||
System.out.println("l===:" + l);
|
||||
List<String> lineList = l.stream().filter(e-> Collections.frequency(l,e) > 1).distinct().collect(Collectors.toList());
|
||||
System.out.println("lineList==:" + lineList);
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// String text = "TkosUFEsMTk5OQ0KNiw2QSwwRA0KMSxBz+C159G5LEEstefRuSxWLDAuMDYyMjU2LDAuMDAwMDAwLDAuMDAwMDAwLC0zMjc2NywzMjc2NywzODAsMzgwLFMNCjIsQs/gtefRuSxCLLXn0bksViwwLjA2MjI1NiwwLjAwMDAwMCwwLjAwMDAwMCwtMzI3NjcsMzI3NjcsMzgwLDM4MCxTDQozLEPP4LXn0bksQyy159G5LFYsMC4wNjIyNTYsMC4wMDAwMDAsMC4wMDAwMDAsLTMyNzY3LDMyNzY3LDM4MCwzODAsUw0KNCxBz+C158H3LEEstefB9yxBLDAuMDE1MjU5LDAuMDAwMDAwLDAuMDAwMDAwLC0zMjc2NywzMjc2NywyMDAsNSxTDQo1LELP4LXnwfcsQiy158H3LEEsMC4wMTUyNTksMC4wMDAwMDAsMC4wMDAwMDAsLTMyNzY3LDMyNzY3LDIwMCw1LFMNCjYsQ8/gtefB9yxDLLXnwfcsQSwwLjAxNTI1OSwwLjAwMDAwMCwwLjAwMDAwMCwtMzI3NjcsMzI3NjcsMjAwLDUsUw0KNTANCjENCjEyODAwLDcxNjgNCjA1LzA5LzIwMjMsMTU6NTQ6MDIuMTM2MDAwDQowNS8wOS8yMDIzLDE1OjU0OjAyLjIzNjAwMA0KQklOQVJZDQoxDQo=";
|
||||
// byte[] byteArray = Base64.getDecoder().decode(text);
|
||||
// InputStream inputStream = new ByteArrayInputStream(byteArray);
|
||||
// fileStorageUtil.uploadStreamSpecifyName(inputStream, "configuration/","xuyang.cfg");
|
||||
// try {
|
||||
// String username = "ac760c62395cecec";
|
||||
// String password = "k0vGfe5xOE2Bl4DCF73uahcknvcwoKOEDPnOkMvuSBB";
|
||||
//
|
||||
// OkHttpClient client = new OkHttpClient();
|
||||
//
|
||||
// Request request = new Request.Builder()
|
||||
// .url("http://192.168.1.18:18083/api/v5/clients/access-boot123456")
|
||||
// .header("Content-Type", "application/json")
|
||||
// .header("Authorization", Credentials.basic(username, password))
|
||||
// .build();
|
||||
//
|
||||
// Response response = client.newCall(request).execute();
|
||||
// response.body();
|
||||
// String res = Objects.requireNonNull(response.body()).string();
|
||||
//
|
||||
// Gson gson = new Gson();
|
||||
// MqttClientDto mqttClientDto = gson.fromJson(res, new TypeToken<MqttClientDto>(){}.getType());
|
||||
// System.out.println("mqttClientDto==:" + mqttClientDto.isConnected());
|
||||
//
|
||||
// inputStream.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
// 要计算CRC32的数据
|
||||
String data = "Hello, World!";
|
||||
CRC32 crc32 = new CRC32();
|
||||
crc32.update(data.getBytes());
|
||||
long crc32Value = crc32.getValue();
|
||||
// 将CRC32校验值转换为16进制字符串
|
||||
String crc32Str = String.format("%08X", crc32Value);
|
||||
System.out.println("CRC32校验值为: " + crc32Str);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user