| | |
| | | package com.dy.pipIrrApp.workOrder; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrApp.workOrder.dto.DtoDeleteProResult; |
| | | import com.dy.pipIrrApp.workOrder.dto.DtoDeleteWorkOrder; |
| | | import com.dy.pipIrrApp.workOrder.mqtt.MqttClientConnectorPool; |
| | | import com.dy.pipIrrApp.workOrder.mqtt.MqttMsgSender; |
| | | import com.dy.pipIrrApp.workOrder.qo.QoWorkOrder; |
| | | import com.dy.pipIrrGlobal.pojoOp.OpeApproveResult; |
| | | import com.dy.pipIrrGlobal.pojoOp.OpeProcessingResult; |
| | |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.eclipse.paho.client.mqttv3.MqttClient; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.BindingResult; |
| | |
| | | @RequiredArgsConstructor |
| | | public class WorkOrderCtrl { |
| | | private final WorkOrderSv workOrderSv; |
| | | |
| | | @Value("${mqtt.broker}") |
| | | private String broker; |
| | | |
| | | @Value("${mqtt.username}") |
| | | private String username; |
| | | |
| | | @Value("${mqtt.password}") |
| | | private String password; |
| | | |
| | | @Value("${mqtt.topic}") |
| | | private String topic; |
| | | |
| | | @Value("${mqtt.qos}") |
| | | private Integer qos; |
| | | |
| | | /** |
| | | * 创建工单 |
| | |
| | | return BaseResponseUtils.buildErrorMsg("获取工单失败"); |
| | | } |
| | | |
| | | //if(!sendWorkOrder(voWorkOrder, workOrderId)) { |
| | | // return BaseResponseUtils.buildErrorMsg("工单推送失败"); |
| | | //} |
| | | if(!sendWorkOrder(voWorkOrder, workOrderId)) { |
| | | return BaseResponseUtils.buildErrorMsg("工单推送失败"); |
| | | } |
| | | |
| | | return BaseResponseUtils.buildSuccess(); |
| | | } |
| | | |
| | | /** |
| | | * 通过mosquitto发送巡检员ID及工单ID |
| | | * @param voWorkOrder 工单对象 |
| | | * @param workOrderId 工单ID |
| | | * @return |
| | | */ |
| | | public Boolean sendWorkOrder(VoWorkOrder voWorkOrder, Long workOrderId) { |
| | | //String message = JSON.toJSONString(voWorkOrder); |
| | | |
| | | JSONObject message_job = new JSONObject(); |
| | | message_job.put("inspectorId", voWorkOrder.getInspectorId().toString()); |
| | | message_job.put("workOrderId", workOrderId.toString()); |
| | | String message = JSON.toJSONString(message_job); |
| | | |
| | | MqttClient mqttClient = MqttClientConnectorPool.connectMQTT(broker, username, password); |
| | | MqttMsgSender sender = new MqttMsgSender(); |
| | | if (null != mqttClient){ |
| | | sender.sendMessage(mqttClient, topic, message, qos); |
| | | } else { |
| | | log.info("MqttClient为空,无法发送!"); |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 逻辑删除指定派单人的指定未删除工单 |
| | | * 先判断指定派单人、未删除的指定工单是否存在 |
| | | * @param deleteWorkOrder 删除工单传输类 |