|
@@ -1,5 +1,10 @@
|
|
|
package com.phm.netty.controller;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.phm.manage.domain.SortieParameter;
|
|
|
+import com.phm.manage.enums.DataTypeEnum;
|
|
|
+import com.phm.manage.service.ISortieParameterService;
|
|
|
import com.phm.netty.domain.UdpRequest;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -15,6 +20,8 @@ import com.phm.netty.client.NettyUdpClient;
|
|
|
import com.phm.netty.domain.Message;
|
|
|
import com.phm.netty.enums.OrderEnum;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @Description NettyUdpClientController
|
|
|
* @Author WGK
|
|
@@ -24,6 +31,9 @@ import com.phm.netty.enums.OrderEnum;
|
|
|
@Anonymous
|
|
|
@RequestMapping("/udp")
|
|
|
public class NettyUdpClientController extends BaseController {
|
|
|
+ @Autowired
|
|
|
+ private ISortieParameterService sortieParameterService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private NettyUdpClient udpClient;
|
|
|
|
|
@@ -46,6 +56,9 @@ public class NettyUdpClientController extends BaseController {
|
|
|
*/
|
|
|
@GetMapping("/simulation/{sortieNo}")
|
|
|
public CommonResult<String> getSimulationInfo(@PathVariable("sortieNo") String sortieNo) {
|
|
|
+ if (StrUtil.isBlank(sortieNo)) {
|
|
|
+ return CommonResult.error("架次号不能为空");
|
|
|
+ }
|
|
|
// TODO 需要确定参数
|
|
|
Message message = new Message();
|
|
|
message.setType(OrderEnum.ORDER_CONFIG.getType()).setTarget("GPHM").setSource("SPHM")
|
|
@@ -53,6 +66,9 @@ public class NettyUdpClientController extends BaseController {
|
|
|
UdpRequest request = new UdpRequest();
|
|
|
request.setSortieNo(sortieNo);
|
|
|
request.setSourceType(0);
|
|
|
+ if (this.checkSortieNo(request)) {
|
|
|
+ return CommonResult.error(sortieNo + " 架次的数链仿真数据已存在,请重新选择。");
|
|
|
+ }
|
|
|
// udp客户端,向服务端发送获取数据请求服务
|
|
|
udpClient.bind(simulationHost, simulationPort, Message.msgToBytes(message), request);
|
|
|
return CommonResult.buildSuccess();
|
|
@@ -65,6 +81,9 @@ public class NettyUdpClientController extends BaseController {
|
|
|
*/
|
|
|
@GetMapping("/airborne/{sortieNo}")
|
|
|
public CommonResult<String> getAirborneInfo(@PathVariable("sortieNo") String sortieNo) {
|
|
|
+ if (StrUtil.isBlank(sortieNo)) {
|
|
|
+ return CommonResult.error("架次号不能为空");
|
|
|
+ }
|
|
|
// TODO 这里入参需要确定
|
|
|
Message message = new Message();
|
|
|
message.setType(OrderEnum.ORDER_CONFIG.getType()).setTarget("GPHM").setSource("SPHM").setData(
|
|
@@ -73,8 +92,20 @@ public class NettyUdpClientController extends BaseController {
|
|
|
UdpRequest request = new UdpRequest();
|
|
|
request.setSortieNo(sortieNo);
|
|
|
request.setSourceType(1);
|
|
|
+ if (this.checkSortieNo(request)) {
|
|
|
+ return CommonResult.error(sortieNo + " 架次的机载PHM数据已存在,请重新选择。");
|
|
|
+ }
|
|
|
// udp客户端,向服务端发送获取数据请求服务
|
|
|
udpClient.bind(airborneHost, airbornePort, Message.msgToBytes(message), request);
|
|
|
return CommonResult.buildSuccess();
|
|
|
}
|
|
|
+
|
|
|
+ private boolean checkSortieNo(UdpRequest request) {
|
|
|
+ SortieParameter parameter = new SortieParameter();
|
|
|
+ parameter.setSortieNo(request.getSortieNo()).setSource(request.getSourceType())
|
|
|
+ .setType(DataTypeEnum.SOURCE_DATA.getType());
|
|
|
+ List<SortieParameter> list = sortieParameterService.selectSortieParameterList(parameter);
|
|
|
+ // 查看架次数据是否存在,已存在直接返回
|
|
|
+ return CollectionUtil.isNotEmpty(list);
|
|
|
+ }
|
|
|
}
|