|
@@ -1,14 +1,20 @@
|
|
|
package com.phm.netty.service.impl;
|
|
|
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
-import com.alibaba.fastjson2.JSONObject;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.phm.common.config.PHMConfig;
|
|
|
import com.phm.manage.domain.OrderConfig;
|
|
|
import com.phm.manage.domain.OrderInfo;
|
|
|
+import com.phm.manage.domain.SortieParameter;
|
|
|
import com.phm.manage.domain.common.CommonResult;
|
|
|
import com.phm.manage.enums.OrderStatus;
|
|
|
+import com.phm.manage.service.IDataDownResultService;
|
|
|
import com.phm.manage.service.IOrderConfigService;
|
|
|
import com.phm.manage.service.IOrderInfoService;
|
|
|
+import com.phm.manage.service.ISortieParameterService;
|
|
|
import com.phm.manage.service.ISortieService;
|
|
|
+import com.phm.manage.util.CsvUtils;
|
|
|
import com.phm.netty.domain.Message;
|
|
|
import com.phm.netty.enums.OrderEnum;
|
|
|
import com.phm.netty.service.IProcessService;
|
|
@@ -18,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -42,11 +49,17 @@ public class ProcessService implements IProcessService {
|
|
|
@Autowired
|
|
|
private IOrderConfigService orderConfigService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IDataDownResultService resultService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISortieParameterService sortieParameterService;
|
|
|
+
|
|
|
@Override
|
|
|
public Message orderHandle(Message message) throws Exception {
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(message.getData());
|
|
|
- String orderBatchId = jsonObject.getString("id");
|
|
|
- String orderCode = jsonObject.getString("orderCode");
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(message.getData());
|
|
|
+ String orderBatchId = jsonObject.getStr("id");
|
|
|
+ String orderCode = jsonObject.getStr("orderCode");
|
|
|
OrderConfig orderConfig = orderConfigService.selectOrderConfigByCode(orderCode);
|
|
|
// 保存要执行的指令信息
|
|
|
OrderInfo orderInfo = new OrderInfo();
|
|
@@ -58,16 +71,16 @@ public class ProcessService implements IProcessService {
|
|
|
orderInfo.setStatus(OrderStatus.S_0.getCode());
|
|
|
orderInfoService.insertOrderInfo(orderInfo);
|
|
|
Message msg = new Message();
|
|
|
- msg.setType(OrderEnum.RESPONSE.getType())
|
|
|
- .setData(JsonUtils.convertJson(CommonResult.success("{\"id\": " + orderBatchId + ",orderCode:" + orderCode + "}")));
|
|
|
+ msg.setType(OrderEnum.RESPONSE.getType()).setData(
|
|
|
+ JsonUtils.convertJson(CommonResult.success("{\"id\": " + orderBatchId + ",orderCode:" + orderCode + "}")));
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void timing(Message message) throws Exception {
|
|
|
log.info("校时功能");
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(message.getData());
|
|
|
- String timestamp = jsonObject.getString("timestamp");
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(message.getData());
|
|
|
+ String timestamp = jsonObject.getStr("timestamp");
|
|
|
String osName = System.getProperty("os.name").toLowerCase();
|
|
|
try {
|
|
|
if (osName.contains("windows")) {
|
|
@@ -93,12 +106,41 @@ public class ProcessService implements IProcessService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<String> proData(Message message) throws Exception {
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(message.getData());
|
|
|
- String cmdId = jsonObject.getString("cmdid");
|
|
|
- String params = jsonObject.getString("params");
|
|
|
- JSONArray jsonArray = new JSONArray(params);
|
|
|
- // 解析数据集合,保存 TODO
|
|
|
+ public List<String> handleData(Message message) throws Exception {
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(message.getData());
|
|
|
+ short type = message.getType();
|
|
|
+ // TODO mock参数数据
|
|
|
+ String dataJson =
|
|
|
+ "[{\"参数一\":0.1079,\"参数三\":0.6007,\"参数二\":0.0116,\"参数五\":0.0689,\"参数四\":1.1915,\"时间\":\"2022/6/3013:08\"},{\"参数一\":0.8088,\"参数三\":2.9169,\"参数二\":0.6541,\"参数五\":0.6229,\"参数四\":5.5326,\"时间\":\"2022/6/3013:09\"},\t{\"参数一\":0.9088,\"参数三\":2.7169,\"参数二\":0.0541,\"参数五\":0.4229,\"参数四\":3.5326,\"时间\":\"2022/6/3013:10\"}]";
|
|
|
+ String sortieNo = "JC000001121";
|
|
|
+ log.info("msg---:{}", message);
|
|
|
+ // 数链仿真系统获取数据
|
|
|
+ if (OrderEnum.SIMULATION.getType() != type) {
|
|
|
+ String cmdId = jsonObject.getStr("cmdid");
|
|
|
+ String params = jsonObject.getStr("params");
|
|
|
+ JSONArray jsonArray = JSONUtil.parseArray(dataJson);
|
|
|
+ // TODO 参数存放位置
|
|
|
+ String parameterDataPath =
|
|
|
+ PHMConfig.getCsvFilePath() + CsvUtils.PARAMETER_DATA_PATH + sortieNo + CsvUtils.CSV_TYPE;
|
|
|
+ CsvUtils.jsonToFileCsv(dataJson, parameterDataPath);
|
|
|
+ JSONObject obj = jsonArray.getJSONObject(0);
|
|
|
+ List<SortieParameter> parameterList = new ArrayList<>();
|
|
|
+ // 遍历JSONObject的所有键
|
|
|
+ for (String key : obj.keySet()) {
|
|
|
+ parameterList.add(new SortieParameter("sortieNo", key, parameterDataPath));
|
|
|
+ }
|
|
|
+ CsvUtils.jsonToFileCsv(params, "");
|
|
|
+ // 解析数据集合,保存 TODO 参数数据映射表PHM_SORTIE_PARAMETER
|
|
|
+ parameterList.forEach(parameter -> sortieParameterService.insertSortieParameter(parameter));
|
|
|
+ // 数据
|
|
|
+ log.info("数链仿真系统获取数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 机载PHM获取数据
|
|
|
+ if (OrderEnum.AIRBORNE.getType() != type) {
|
|
|
+ // 数据
|
|
|
+ log.info("机载PHM获取数据");
|
|
|
+ }
|
|
|
|
|
|
return null;
|
|
|
}
|