| | |
| | | @PostMapping("/onOff") |
| | | @ApiOperation("远程开锁") |
| | | public AjaxResult onOff(@RequestBody LockTypeParam lockTypeParam) throws MqttException { |
| | | return AjaxResult.success(ardSyCarLockService.onOff(lockTypeParam)); |
| | | return ardSyCarLockService.onOff(lockTypeParam); |
| | | } |
| | | |
| | | @PostMapping("/seal") |
| | | @ApiOperation("远程封印") |
| | | public AjaxResult seal(@RequestBody RtuTypeParam rtuTypeParam) { |
| | | return AjaxResult.success(ardSyCarLockService.seal(rtuTypeParam)); |
| | | return ardSyCarLockService.seal(rtuTypeParam); |
| | | } |
| | | |
| | | @GetMapping("/lockIng") |
| | |
| | | if(fengType==0){ |
| | | //锁开关状态 |
| | | int lockCloseNum = 0; |
| | | String mapString1 = "{\"A01\":100000,\"A02\":100000,\"res\":\""+String.valueOf(System.currentTimeMillis())+"\"}"; |
| | | System.out.println("自动施封:"+mapString1); |
| | | EmqClient emqClient1 = new EmqClient(carId+"mqttPublish"+UUID.randomUUID()); |
| | | emqClient1.connect(); |
| | | emqClient1.publish(ardSyCarRtu.getTopicPublish(),mapString1, QosEnum.QoS2,false); |
| | | //如果不是施封状态,则发送施封命令 |
| | | if(ardSyCarLocks.get(0).getRelayInfo()!=null){ |
| | | if(ardSyCarLocks.get(0).getRelayInfo()==1){ |
| | |
| | | // map.put("A02", 100000);//断开第二路继电器 |
| | | // map.put("res", String.valueOf(System.currentTimeMillis())); |
| | | // String mapString = com.alibaba.fastjson.JSON.toJSONString(map); |
| | | String mapString = "{\"A01\":100000,\"A02\":100000,\"res\":\""+String.valueOf(System.currentTimeMillis())+"\"}"; |
| | | System.out.println("自动施封:"+mapString); |
| | | EmqClient emqClient = new EmqClient(carId+"mqttPublish"+UUID.randomUUID()); |
| | | emqClient.connect(); |
| | | emqClient.publish(ardSyCarRtu.getTopicPublish(),mapString, QosEnum.QoS2,false); |
| | | log.debug("车辆"+carId+"施封命令发送成功!"); |
| | | // mqttOnce.publishCar(carId,ardSyCarRtu.getTopicPublish(),String.valueOf(new JSONObject(map)),"施封"); |
| | | } |
| | |
| | | /** |
| | | * @author Administrator |
| | | */ |
| | | @Slf4j |
| | | @Slf4j(topic = "mqttCar") |
| | | @Service |
| | | public class ArdSyCarLockServiceImpl implements ArdSyCarLockService { |
| | | |
| | |
| | | int lockCloseNum = 0; |
| | | //查询锁信息 |
| | | List<ArdSyCarLock> ardSyCarLocks = carLock(ardSyCarRtu.getId()); |
| | | String mapString1 = "{\"A01\":100000,\"A02\":100000,\"res\":\""+String.valueOf(System.currentTimeMillis())+"\"}"; |
| | | System.out.println("施封:"+mapString1); |
| | | EmqClient emqClient1 = new EmqClient(rtuTypeParam.getCarId()+"mqttPublish"+UUID.randomUUID()); |
| | | emqClient1.connect(); |
| | | emqClient1.publish(ardSyCarRtu.getTopicPublish(),mapString1, QosEnum.QoS2,false); |
| | | for (int j = 0; j < ardSyCarLocks.size(); j++) { |
| | | ArdSyCarLock ardSyCarLock = ardSyCarLocks.get(j); |
| | | String currents = ardSyCarLock.getCurrents(); |
| | |
| | | emqClient.connect(); |
| | | emqClient.publish(ardSyCarRtu.getTopicPublish(),mapString, QosEnum.QoS2,false); |
| | | // mqttOnce.publishCar("carId",ardSyCarRtu.getTopicPublish(),String.valueOf(new com.alibaba.fastjson2.JSONObject(map)),"开锁:"+currents); |
| | | // long startTime = System.currentTimeMillis(); // 获取循环开始时间 |
| | | // long endTime = startTime + 30000; // 设置循环结束时间为开始时间加上5秒钟 |
| | | while(true){ |
| | | ArdSyCarLock ardSyCarLock1 = getCurrentInfo(ardSyCarRtu.getId(),currents); |
| | | Double currentInfo1 = ardSyCarLock1.getCurrentInfo(); |
| | |
| | | // map.put("A02", 100000);//断开第二路继电器 |
| | | // map.put("res", String.valueOf(System.currentTimeMillis())); |
| | | // String mapString = JSON.toJSONString(map); |
| | | String mapString = "{\"A01\":100000,\"A02\":100000,\"res\":\""+String.valueOf(System.currentTimeMillis())+"\"}"; |
| | | System.out.println("施封:"+mapString); |
| | | EmqClient emqClient = new EmqClient(rtuTypeParam.getCarId()+"mqttPublish"+UUID.randomUUID()); |
| | | emqClient.connect(); |
| | | emqClient.publish(ardSyCarRtu.getTopicPublish(),mapString, QosEnum.QoS2,false); |
| | | return AjaxResult.success("施封命令发生成功!"); |
| | | // return AjaxResult.success(mqttOnce.publishCar(rtuTypeParam.getCarId(),ardSyCarRtu.getTopicPublish(),String.valueOf(new com.alibaba.fastjson2.JSONObject(map)),"施封")); |
| | | } |
| | |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | @Slf4j |
| | | @Slf4j(topic = "mqttCar") |
| | | @Component |
| | | public class AutoMqtt { |
| | | |
| | |
| | | |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.sy.service.ArdSyCarRtuService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.eclipse.paho.client.mqttv3.IMqttClient; |
| | | import org.eclipse.paho.client.mqttv3.MqttClient; |
| | | import org.eclipse.paho.client.mqttv3.MqttClientPersistence; |
| | |
| | | import org.eclipse.paho.client.mqttv3.MqttMessage; |
| | | import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; |
| | | |
| | | @Slf4j(topic = "mqttCar") |
| | | public class EmqClient { |
| | | |
| | | private IMqttClient mqttClient; |
| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | |
| | | @Slf4j |
| | | @Slf4j(topic = "mqttCar") |
| | | public class MessageCallback implements MqttCallback { |
| | | |
| | | private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | |
| | | <select id="lockList" parameterType="String" resultType="com.ruoyi.sy.domain.ArdSyCarLock"> |
| | | SELECT id,currents,rtu_id,current_info,relay,img_position_left,img_position_top,relay_info,lock_name FROM ard_sy_car_lock |
| | | WHERE rtu_id = #{rtuId} |
| | | WHERE rtu_id = #{rtuId} order by id |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | rongCloud: info |
| | | cmd: info |
| | | uav: info |
| | | sy: info |
| | | sy: debug |
| | | mqttCar: debug |
| | | ## knife4j配置 |
| | | knife4j: |
| | | # knife4j增强功能,开启后下面参数才生效 |
| | |
| | | endpoint: http://192.168.2.15:9001 |
| | | accessKey: admin |
| | | secretKey: xzx12345 |
| | | path: G:/DATA |
| | | path: D:/DATA |
| | | #流媒体转码服务器 |
| | | mediamtx: |
| | | enabled: true |