Forráskód Böngészése

增加对工单状态变化的监听和处理

lixing 4 éve
szülő
commit
072430b009

+ 106 - 53
src/main/java/com/persagy/dmp/starter/alarm/communication/mq/JmsConfig.java

@@ -1,6 +1,8 @@
 package com.persagy.dmp.starter.alarm.communication.mq;
 
+import com.persagy.dmp.starter.alarm.communication.mq.model.DmpMessage;
 import com.persagy.dmp.starter.alarm.communication.netty.NettyAlarmMsgBaseHandler;
+import com.persagy.dmp.starter.alarm.service.OrderStateChangeService;
 import com.persagy.dmp.starter.alarm.util.StringUtil;
 import com.rabbitmq.client.Channel;
 import lombok.extern.slf4j.Slf4j;
@@ -11,6 +13,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import com.persagy.dmp.alarm.jms.model.OrderStateMessage;
+
+import java.io.IOException;
 
 /**
  * @description:报警定义消息通知
@@ -22,63 +27,111 @@ import org.springframework.context.annotation.Configuration;
 @Slf4j
 @Configuration
 public class JmsConfig {
+    @Autowired
+    OrderStateChangeService orderStateChangeService;
+
+    /**
+     * NettyAlarmMsgBaseHandler本身不进行ioc注入,这里注入的是他的子类。
+     * 子类在实际项目中创建,starter中没有实例。
+     */
+    @Autowired
+    private NettyAlarmMsgBaseHandler msgHandler;
+    /**
+     * 报警定义变化类型
+     */
+    private static final String ALARM_CONFIGS_CHANGE = "alarmConfigsChange";
+    /**
+     * 报警交换器
+     */
+    @Value("${dmp.alarm.exchange}")
+    private String dmpAlarmExchange;
+    /**
+     * 报警路由键
+     */
+    @Value("${dmp.alarm.routingKey}")
+    private String alarmRoutingKey;
+    /**
+     * 报警队列
+     */
+    @Value("${dmp.alarm.queue}")
+    private String alarmQueue;
+
+    /**
+     * 工单状态变化exchange, 下一期升级为对接集成框架
+     */
+    private String orderStateExchange = "workorder_state_publish_exchange";
+    /**
+     * 工单状态变化queue
+     */
+    private String orderStateQueue = "order_state_queue";
+
+
+    @Bean
+    public Queue alarmQueue() {
+        return new Queue(alarmQueue, true);
+    }
+
+    @Bean
+    public TopicExchange alarmExchange() {
+        return new TopicExchange(dmpAlarmExchange);
+    }
 
-	/**
-	 * NettyAlarmMsgBaseHandler本身不进行ioc注入,这里注入的是他的子类。
-	 * 子类在实际项目中创建,starter中没有实例。
-	 */
-	@Autowired
-	private NettyAlarmMsgBaseHandler msgHandler;
-	/**
-	 * 报警定义变化类型
-	 */
-	private static final String ALARM_CONFIGS_CHANGE = "alarmConfigsChange";
-	/**
-	 * 报警交换器
-	 */
-	@Value("${dmp.alarm.exchange}")
-	private String exchange;
-	/**
-	 * 报警路由键
-	 */
-	@Value("${dmp.alarm.routingKey}")
-	private String alarmRoutingKey;
-	/**
-	 * 报警队列
-	 */
-	@Value("${dmp.alarm.queue}")
-	private String alarmQueue;
+    @Bean
+    public Binding alarmBinding() {
+        return BindingBuilder.bind(alarmQueue()).to(alarmExchange()).with(alarmRoutingKey);
+    }
 
+    @Bean
+    public FanoutExchange orderStateExchange() {
+        return new FanoutExchange(orderStateExchange);
+    }
 
-	@Bean
-	public Queue queue() {
-		return new Queue(alarmQueue, true);
-	}
+    @Bean
+    public Queue orderStateQueue() {
+        return new Queue(orderStateQueue, true);
+    }
 
-	@Bean
-	public TopicExchange exchange() {
-		return new TopicExchange(exchange);
-	}
+    @Bean
+    public Binding orderStateBinding() {
+        return BindingBuilder.bind(orderStateQueue()).to(orderStateExchange());
+    }
 
-	@Bean
-	public Binding alarmBinding() {
-		return BindingBuilder.bind(queue()).to(exchange()).with(alarmRoutingKey);
-	}
+    @RabbitListener(queues = "order_state_queue")    //监听器监听指定的Queue
+    public void processOrderState(String message, Channel channel, Message msg) {
+        log.info("============================== Receive:" + message);
+        try {
+            OrderStateMessage orderStateMessage = StringUtil.transferItemToDTO(message, OrderStateMessage.class);
+            log.info("order_id: {}", orderStateMessage.getOrder_id());
+            log.info("order_state: {}", orderStateMessage.getOrder_state());
+            // 根据工单状态消息更新报警记录状态
+            orderStateChangeService.updateAlarmWhenOrderStateChange(orderStateMessage);
+            // 手动确认消息已消费
+            channel.basicAck(msg.getMessageProperties().getDeliveryTag(),false);
+        } catch (Exception e) {
+            log.error("工单状态消息消费失败: {}", e.getMessage());
+            try {
+                // 将消费失败的消息移除消息队列,避免重复消费
+                channel.basicReject(msg.getMessageProperties().getDeliveryTag(),false);
+            } catch (IOException ex) {
+                log.error("工单状态消息从队列中移除失败,{}", ex.getMessage());
+            }
+        }
+    }
 
-	@RabbitHandler
-	@RabbitListener(queues = "${dmp.alarm.queue}")
-	public void planQueues(String msg, Channel channel, Message message) throws Exception {
-		log.info("============================== Receive:" + msg);
-		DmpMessage dmpMessage = StringUtil.transferItemToDTO(msg, DmpMessage.class);
-		//报警定义变化
-		if(ALARM_CONFIGS_CHANGE.equals(dmpMessage.getType())){
-			log.info("================收到一条报警定义变化通知==============");
-			log.info(msg.toString());
-			try {
-				msgHandler.incrementSyncAlarmConfig(dmpMessage);
-			} catch (Exception e) {
-				log.error("error",e);
-			}
-		}
-	}
+    @RabbitHandler
+    @RabbitListener(queues = "${dmp.alarm.queue}")
+    public void planQueues(String msg, Channel channel, Message message) throws Exception {
+        log.info("============================== Receive:" + msg);
+        DmpMessage dmpMessage = StringUtil.transferItemToDTO(msg, DmpMessage.class);
+        //报警定义变化
+        if (ALARM_CONFIGS_CHANGE.equals(dmpMessage.getType())) {
+            log.info("================收到一条报警定义变化通知==============");
+            log.info(msg.toString());
+            try {
+                msgHandler.incrementSyncAlarmConfig(dmpMessage);
+            } catch (Exception e) {
+                log.error("error", e);
+            }
+        }
+    }
 }

+ 1 - 1
src/main/java/com/persagy/dmp/starter/alarm/communication/mq/DmpMessage.java

@@ -1,4 +1,4 @@
-package com.persagy.dmp.starter.alarm.communication.mq;
+package com.persagy.dmp.starter.alarm.communication.mq.model;
 
 import com.alibaba.fastjson.JSONObject;
 import lombok.Data;

+ 18 - 0
src/main/java/com/persagy/dmp/starter/alarm/communication/mq/model/OrderStateMessage.java

@@ -0,0 +1,18 @@
+package com.persagy.dmp.alarm.jms.model;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @description:
+ * @author: lixing
+ * @company: Persagy Technology Co.,Ltd
+ * @since: 2020/12/15 11:22 上午
+ * @version: V1.0
+ **/
+@Getter
+@Setter
+public class OrderStateMessage {
+    private String order_id;
+    private int order_state;
+}

+ 1 - 2
src/main/java/com/persagy/dmp/starter/alarm/communication/mq/sender/InstanceObjMessageSender.java

@@ -1,7 +1,6 @@
 package com.persagy.dmp.starter.alarm.communication.mq.sender;
 
-import com.alibaba.fastjson.JSONObject;
-import com.persagy.dmp.starter.alarm.communication.mq.DmpMessage;
+import com.persagy.dmp.starter.alarm.communication.mq.model.DmpMessage;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;

+ 1 - 1
src/main/java/com/persagy/dmp/starter/alarm/communication/mq/sender/MessageSender.java

@@ -1,7 +1,7 @@
 package com.persagy.dmp.starter.alarm.communication.mq.sender;
 
 import com.alibaba.fastjson.JSONObject;
-import com.persagy.dmp.starter.alarm.communication.mq.DmpMessage;
+import com.persagy.dmp.starter.alarm.communication.mq.model.DmpMessage;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;

+ 13 - 3
src/main/java/com/persagy/dmp/starter/alarm/communication/netty/NettyAlarmMsgBaseHandler.java

@@ -2,7 +2,7 @@ package com.persagy.dmp.starter.alarm.communication.netty;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.persagy.dmp.starter.alarm.communication.mq.DmpMessage;
+import com.persagy.dmp.starter.alarm.communication.mq.model.DmpMessage;
 import com.persagy.dmp.starter.alarm.service.NettyAlarmService;
 import com.persagy.dmp.starter.alarm.util.StringUtil;
 import io.netty.channel.Channel;
@@ -71,6 +71,7 @@ public class NettyAlarmMsgBaseHandler extends ChannelInboundHandlerAdapter {
 
     @Override
     public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
+        log.info("netty通道注册完成,ChannelHandlerContext信息:{}", ctx.toString());
         SocketAddress socketAddress = ctx.channel().remoteAddress();
         String remoteAddress = socketAddress.toString();
         System.out.println("--某个客户端绑定地址:" + remoteAddress + "--");
@@ -90,8 +91,14 @@ public class NettyAlarmMsgBaseHandler extends ChannelInboundHandlerAdapter {
     private void connected(NettyAlarmMessage nettyMessage, ChannelHandlerContext channelHandlerContext) {
         String source = nettyMessage.getSource();
         if (StringUtils.isEmpty(source)) {
+            if (socketChannelMap.size() > 0) {
+                throw new RuntimeException("已经有projectId!=0的边缘端连接到云端,本次连接失效");
+            }
             socketChannelMap.put(allProjects, channelHandlerContext.channel());
         } else {
+            if (socketChannelMap.get(allProjects) != null) {
+                throw new RuntimeException("已经有projectId=0的边缘端连接到云端,本次连接失效");
+            }
             String[] projectIds = source.split(",");
             // 一个项目只能对应一个channel
             for (String projectId : projectIds) {
@@ -118,9 +125,11 @@ public class NettyAlarmMsgBaseHandler extends ChannelInboundHandlerAdapter {
         JSONObject data = dataList.get(0);
         String projectId = data.getString("projectId");
         if (StringUtils.isEmpty(projectId)) {
-            projectId = "0";
+            data.put("projectId", 0);
+        } else {
+            data.put("projectId", projectId.split(","));
         }
-        data.put("projectId", projectId);
+
         data.put("userId", "system");
 
         JSONArray alarmConfigs = nettyAlarmService.queryAlarmConfig(data);
@@ -275,6 +284,7 @@ public class NettyAlarmMsgBaseHandler extends ChannelInboundHandlerAdapter {
      */
     @Override
     public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        log.error(cause.getMessage());
         cause.printStackTrace();
         ctx.close();
     }

+ 129 - 0
src/main/java/com/persagy/dmp/starter/alarm/service/BaseService.java

@@ -0,0 +1,129 @@
+package com.persagy.dmp.starter.alarm.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.persagy.dmp.starter.alarm.feign.AlarmUrlParam;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.util.CollectionUtils;
+
+/**
+ * @description: 提供一些基础方法
+ * @author: lixing
+ * @company: Persagy Technology Co.,Ltd
+ * @since: 2020/12/16 10:10 上午
+ * @version: V1.0
+ **/
+public class BaseService {
+    /**
+     * @description: 参数校验
+     * @param: obj
+     * @return: void
+     * @exception:
+     * @author: lixing
+     * @company: Persagy Technology Co.,Ltd
+     * @since: 2020/11/30 3:14 下午
+     * @version: V1.0
+     */
+    public void checkRequestParam(JSONObject obj) throws Exception {
+        String projectId = obj.getString("projectId");
+        String userId = obj.getString("userId");
+        String groupCode = obj.getString("groupCode");
+        if (StringUtils.isBlank(projectId)) {
+            throw new Exception("projectId不能为空");
+        } else if (StringUtils.isBlank(userId)) {
+            throw new Exception("userId不能为空");
+        } else if (StringUtils.isBlank(groupCode)) {
+            throw new Exception("groupCode不能为空");
+        }
+    }
+
+    /**
+     * @description: 获取request中的param
+     * @param: obj
+     * @return: com.persagy.dmp.starter.alarm.feign.AlarmUrlParam
+     * @exception:
+     * @author: lixing
+     * @company: Persagy Technology Co.,Ltd
+     * @since: 2020/11/30 3:14 下午
+     * @version: V1.0
+     */
+    public AlarmUrlParam getAlarmUrlParam(JSONObject obj) throws Exception {
+        String projectId = obj.getString("projectId");
+        // 如果projectId为空,设置为0,查询集团下所有项目的数据
+        if (StringUtils.isEmpty(projectId)) {
+            obj.put("projectId", "0");
+        }
+        // 如果projectId为多个项目(用逗号分隔), param中projectId传0
+        String[] projectIds = projectId.split(",");
+        if (projectIds.length > 1) {
+            obj.put("projectId", "0");
+        }
+        this.checkRequestParam(obj);
+
+        return new AlarmUrlParam(
+                obj.getString("userId"),
+                obj.getString("groupCode"),
+                projectId,
+                obj.getString("appId")
+        );
+    }
+
+    /**
+     * @description: 获取request中的body
+     * @param: obj
+     * @return: com.alibaba.fastjson.JSONObject
+     * @exception:
+     * @author: lixing
+     * @company: Persagy Technology Co.,Ltd
+     * @since: 2020/11/30 3:14 下午
+     * @version: V1.0
+     */
+    public JSONObject getRequestBody(JSONObject obj) throws Exception {
+        JSONObject requestBody = new JSONObject();
+        JSONObject criteria = (JSONObject) obj.clone();
+        criteria.remove("appId");
+        criteria.remove("userId");
+        if (!CollectionUtils.isEmpty(criteria.getJSONArray("orders"))) {
+            requestBody.put("orders", criteria.getJSONArray("orders"));
+            criteria.remove("orders");
+        }
+
+        if (!CollectionUtils.isEmpty(criteria.getJSONArray("withColumns"))) {
+            requestBody.put("withColumns", criteria.getJSONArray("withColumns"));
+            criteria.remove("withColumns");
+        }
+
+        if (criteria.containsKey("onlyCount")) {
+            requestBody.put("onlyCount", criteria.getBooleanValue("onlyCount"));
+            criteria.remove("onlyCount");
+        }
+
+        if (criteria.containsKey("page") && criteria.containsKey("size")) {
+            Integer page = criteria.getInteger("page");
+            Integer size = criteria.getInteger("size");
+            requestBody.put("page", page);
+            requestBody.put("size", size);
+            criteria.remove("page");
+            criteria.remove("size");
+        }
+        /* 如果查询条件中包含projectId,进行如下处理 */
+        String projectId = criteria.getString("projectId");
+        // 如果projectId为空或是0,从查询条件中移除
+        if (StringUtils.isEmpty(projectId) || "0".equals(projectId)) {
+            criteria.remove("projectId");
+        } else {
+            // 将projectId转换为数组,适配projectId为多个项目(用逗号分隔)的情况
+            String[] projectIds = projectId.split(",");
+            criteria.put("projectId", projectIds);
+        }
+
+        /* 如果查询条件中包含groupCode, 且groupCode = 0, 从查询条件中移除groupCode */
+        String groupCode = criteria.getString("groupCode");
+        // 如果projectId为空或是0,从查询条件中移除
+        if (StringUtils.isEmpty(groupCode) || "0".equals(groupCode)) {
+            criteria.remove("groupCode");
+        }
+
+        requestBody.put("criteria", criteria);
+        return requestBody;
+    }
+}

+ 2 - 110
src/main/java/com/persagy/dmp/starter/alarm/service/NettyAlarmService.java

@@ -3,12 +3,11 @@ package com.persagy.dmp.starter.alarm.service;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.persagy.dmp.starter.alarm.communication.mq.DmpMessage;
+import com.persagy.dmp.starter.alarm.communication.mq.model.DmpMessage;
 import com.persagy.dmp.starter.alarm.feign.AlarmUrlParam;
 import com.persagy.dmp.starter.alarm.feign.DmpResult;
 import com.persagy.dmp.starter.alarm.feign.client.AlarmClient;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.CollectionUtils;
 
@@ -25,118 +24,11 @@ import java.util.stream.Collectors;
  * @version: V1.0
  **/
 @Slf4j
-public abstract class NettyAlarmService {
+public abstract class NettyAlarmService extends BaseService{
     @Autowired
     AlarmClient alarmClient;
 
     /**
-     * @description: 参数校验
-     * @param: obj
-     * @return: void
-     * @exception:
-     * @author: lixing
-     * @company: Persagy Technology Co.,Ltd
-     * @since: 2020/11/30 3:14 下午
-     * @version: V1.0
-     */
-    public void checkRequestParam(JSONObject obj) throws Exception {
-        String projectId = obj.getString("projectId");
-        String userId = obj.getString("userId");
-        String groupCode = obj.getString("groupCode");
-        if (StringUtils.isBlank(projectId)) {
-            throw new Exception("projectId不能为空");
-        } else if (StringUtils.isBlank(userId)) {
-            throw new Exception("userId不能为空");
-        } else if (StringUtils.isBlank(groupCode)) {
-            throw new Exception("groupCode不能为空");
-        }
-    }
-
-    /**
-     * @description: 获取request中的param
-     * @param: obj
-     * @return: com.persagy.dmp.starter.alarm.feign.AlarmUrlParam
-     * @exception:
-     * @author: lixing
-     * @company: Persagy Technology Co.,Ltd
-     * @since: 2020/11/30 3:14 下午
-     * @version: V1.0
-     */
-    public AlarmUrlParam getAlarmUrlParam(JSONObject obj) throws Exception {
-        String projectId = obj.getString("projectId");
-        // 如果projectId为空,设置为0,查询集团下所有项目的数据
-        if (StringUtils.isEmpty(projectId)) {
-            obj.put("projectId", "0");
-        }
-        // 如果projectId为多个项目(用逗号分隔), param中projectId传0
-        String[] projectIds = projectId.split(",");
-        if (projectIds.length > 1) {
-            obj.put("projectId", "0");
-        }
-        this.checkRequestParam(obj);
-
-        return new AlarmUrlParam(
-                obj.getString("userId"),
-                obj.getString("groupCode"),
-                projectId,
-                obj.getString("appId")
-        );
-    }
-
-    /**
-     * @description: 获取request中的body
-     * @param: obj
-     * @return: com.alibaba.fastjson.JSONObject
-     * @exception:
-     * @author: lixing
-     * @company: Persagy Technology Co.,Ltd
-     * @since: 2020/11/30 3:14 下午
-     * @version: V1.0
-     */
-    public JSONObject getRequestBody(JSONObject obj) throws Exception {
-        JSONObject requestBody = new JSONObject();
-        JSONObject criteria = (JSONObject) obj.clone();
-        criteria.remove("appId");
-        criteria.remove("userId");
-        if (!CollectionUtils.isEmpty(criteria.getJSONArray("orders"))) {
-            requestBody.put("orders", criteria.getJSONArray("orders"));
-            criteria.remove("orders");
-        }
-
-        if (!CollectionUtils.isEmpty(criteria.getJSONArray("withColumns"))) {
-            requestBody.put("withColumns", criteria.getJSONArray("withColumns"));
-            criteria.remove("withColumns");
-        }
-
-        if (criteria.containsKey("onlyCount")) {
-            requestBody.put("onlyCount", criteria.getBooleanValue("onlyCount"));
-            criteria.remove("onlyCount");
-        }
-
-        if (criteria.containsKey("page") && criteria.containsKey("size")) {
-            Integer page = criteria.getInteger("page");
-            Integer size = criteria.getInteger("size");
-            requestBody.put("page", page);
-            requestBody.put("size", size);
-            criteria.remove("page");
-            criteria.remove("size");
-        }
-        /* 如果查询条件中包含projectId,进行如下处理 */
-        String projectId = criteria.getString("projectId");
-        // 如果projectId为空或是0,从查询条件中移除
-        if (StringUtils.isEmpty(projectId) || "0".equals(projectId)) {
-            criteria.remove("projectId");
-        } else {
-            // 将projectId转换为数组,适配projectId为多个项目(用逗号分隔)的情况
-            String[] projectIds = projectId.split(",");
-            criteria.put("projectId", projectIds);
-        }
-
-        requestBody.put("criteria", criteria);
-        return requestBody;
-    }
-
-    /**
      * @description: 查询报警定义
      * @param: data
      * @return: com.alibaba.fastjson.JSONArray

+ 109 - 0
src/main/java/com/persagy/dmp/starter/alarm/service/OrderStateChangeService.java

@@ -0,0 +1,109 @@
+package com.persagy.dmp.starter.alarm.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.persagy.dmp.alarm.jms.model.OrderStateMessage;
+import com.persagy.dmp.starter.alarm.feign.DmpResult;
+import com.persagy.dmp.starter.alarm.feign.client.AlarmClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+/**
+ * @description: 工单状态变化处理
+ * @author: lixing
+ * @company: Persagy Technology Co.,Ltd
+ * @since: 2020/12/16 9:45 上午
+ * @version: V1.0
+ **/
+@Service
+public class OrderStateChangeService extends BaseService {
+    @Autowired
+    private AlarmClient alarmClient;
+
+    /**
+     * @description: 当工单状态变化时,更新报警记录
+     * @param: orderStateMessage
+     * @return: void
+     * @exception:
+     * @author: lixing
+     * @company: Persagy Technology Co.,Ltd
+     * @since: 2020/12/16 10:24 上午
+     * @version: V1.0
+     */
+    public void updateAlarmWhenOrderStateChange(OrderStateMessage orderStateMessage) throws Exception {
+        // 根据工单状态获取对应的报警处理状态
+        Integer alarmTreatState = getAlarmTreatState(orderStateMessage.getOrder_state());
+        if (alarmTreatState == null) {
+            return;
+        }
+
+        // 根据工单id获取要修改的报警记录
+        JSONArray alarmRecords = getAlarmRecordsByOrderId(orderStateMessage.getOrder_id());
+        if (CollectionUtils.isEmpty(alarmRecords)) {
+            return;
+        }
+
+        // 更新报警记录状态
+        for (Object alarmRecord : alarmRecords) {
+            JSONObject alarmRecordObj = (JSONObject) alarmRecord;
+            alarmRecordObj.put("treatState", alarmTreatState);
+            alarmRecordObj.put("orderState", orderStateMessage.getOrder_state());
+            alarmRecordObj.put("userId", "system");
+            alarmClient.updateAlarmRecord(getAlarmUrlParam(alarmRecordObj), alarmRecordObj);
+        }
+    }
+
+    /**
+     * @description: 根据工单id获取对应的报警记录
+     * @param: orderId
+     * @return: JSONArray
+     * @exception:
+     * @author: lixing
+     * @company: Persagy Technology Co.,Ltd
+     * @since: 2020/12/16 10:16 上午
+     * @version: V1.0
+     */
+    private JSONArray getAlarmRecordsByOrderId(String orderId) throws Exception {
+        JSONObject queryBody = new JSONObject();
+        queryBody.put("orderId", orderId);
+        queryBody.put("userId", "system");
+        queryBody.put("projectId", "0");
+        queryBody.put("groupCode", "0");
+        queryBody.put("appId", "0");
+        DmpResult<JSONArray> alarmRecordDmpResult = alarmClient.queryAlarmRecord(getAlarmUrlParam(queryBody), getRequestBody(queryBody));
+        String resultSuccess = "success";
+        if (resultSuccess.equals(alarmRecordDmpResult.getResult())) {
+            return alarmRecordDmpResult.getData();
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * @description: 根据工单状态获取对应的报警处理状态
+     * @param: orderState 工单状态
+     * @return: java.lang.Integer
+     * @exception:
+     * @author: lixing
+     * @company: Persagy Technology Co.,Ltd
+     * @since: 2020/12/16 9:58 上午
+     * @version: V1.0
+     */
+    public Integer getAlarmTreatState(int orderState) {
+        int handling = 2, done = 3;
+        switch (orderState) {
+            case 4:
+            case 5:
+            case 6:
+                return handling;
+            case 7:
+            case 8:
+            case 9:
+            case 10:
+                return done;
+            default:
+                return null;
+        }
+    }
+}