|
@@ -1,31 +1,23 @@
|
|
|
package com.phm.netty.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
-import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import com.phm.common.utils.bean.BeanUtils;
|
|
|
import com.phm.manage.domain.OrderConfig;
|
|
|
import com.phm.manage.domain.OrderInfo;
|
|
|
-import com.phm.manage.domain.common.OrderXmlVO;
|
|
|
+import com.phm.manage.domain.common.CommonResult;
|
|
|
import com.phm.manage.enums.OrderStatus;
|
|
|
import com.phm.manage.service.IOrderConfigService;
|
|
|
import com.phm.manage.service.IOrderInfoService;
|
|
|
import com.phm.manage.service.ISortieService;
|
|
|
-import com.phm.manage.util.XMLParserWithJAXB;
|
|
|
-import com.phm.netty.enums.MessageEnum;
|
|
|
+import com.phm.netty.domain.Message;
|
|
|
import com.phm.netty.enums.OrderEnum;
|
|
|
import com.phm.netty.service.IProcessService;
|
|
|
-import com.phm.netty.domain.Message;
|
|
|
-import com.phm.system.service.ISysDictDataService;
|
|
|
+import com.phm.netty.utils.JsonUtils;
|
|
|
import com.phm.system.service.ISysDictTypeService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Objects;
|
|
|
-
|
|
|
-import static com.phm.netty.enums.MessageEnum.GET_DATA_BY_ONBOARD;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* @Description ProcessService
|
|
@@ -34,6 +26,7 @@ import static com.phm.netty.enums.MessageEnum.GET_DATA_BY_ONBOARD;
|
|
|
*/
|
|
|
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class ProcessService implements IProcessService {
|
|
|
|
|
|
@Autowired
|
|
@@ -49,23 +42,52 @@ public class ProcessService implements IProcessService {
|
|
|
private IOrderConfigService orderConfigService;
|
|
|
|
|
|
@Override
|
|
|
- public Message orderHandle(Message message) {
|
|
|
- MessageEnum type = MessageEnum.getStructureEnum(message);
|
|
|
+ public Message orderHandle(Message message) throws Exception {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(message.getData());
|
|
|
String code = jsonObject.getString("id");
|
|
|
OrderConfig orderConfig = orderConfigService.selectOrderConfigByCode(code);
|
|
|
OrderInfo orderInfo = new OrderInfo();
|
|
|
orderInfo.setOrderName(orderConfig.getName());
|
|
|
orderInfo.setOrderType(orderConfig.getType());
|
|
|
- // set待执行状态
|
|
|
+ // 设置待执行状态
|
|
|
orderInfo.setStatus(OrderStatus.S_0.getCode());
|
|
|
orderInfoService.insertOrderInfo(orderInfo);
|
|
|
Message msg = new Message();
|
|
|
+ msg.setType(OrderEnum.RESPONSE.getType()).setData(JsonUtils.convertJson(CommonResult.success("{\"id\": " + code + "}")));
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Message timing(Message message) throws Exception {
|
|
|
+ log.info("校时功能");
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(message.getData());
|
|
|
+ String timestamp = jsonObject.getString("timestamp");
|
|
|
+ String osName = System.getProperty("os.name").toLowerCase();
|
|
|
try {
|
|
|
- msg.setType(OrderEnum.RESPONSE.getType()).setData(Message.successDate(code));
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
+ if (osName.contains("windows")) {
|
|
|
+ String date = timestamp.substring(0, 10);
|
|
|
+ String time = timestamp.substring(11);
|
|
|
+ Runtime.getRuntime().exec("cmd /c date " + date); // 修改应用服务器年月日
|
|
|
+ Runtime.getRuntime().exec("cmd /c time " + time);// 修改应用服务器时分秒
|
|
|
+ }
|
|
|
+ if (osName.contains("linux")) {
|
|
|
+ String[] command = {"date", "-s", timestamp};
|
|
|
+ Process pr = Runtime.getRuntime().exec(command);
|
|
|
+ pr.waitFor();
|
|
|
+ }
|
|
|
+ } catch (Exception exception) {
|
|
|
+ log.error(exception.getMessage());
|
|
|
}
|
|
|
+ Message msg = new Message();
|
|
|
+ msg.setType(OrderEnum.RESPONSE.getType()).setData(JsonUtils.convertJson(CommonResult.buildSuccess()));
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Message getParameterConfig(Message message) throws Exception {
|
|
|
+ List<OrderConfig> configs = orderConfigService.selectOrderConfigList(null);
|
|
|
+ Message msg = new Message();
|
|
|
+ msg.setType(OrderEnum.RESPONSE.getType()).setData(JsonUtils.convertJson(CommonResult.success(configs)));
|
|
|
return msg;
|
|
|
}
|
|
|
}
|