| | |
| | | package com.ruoyi.sy.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.sy.domain.ArdSyCarRtu; |
| | | import com.ruoyi.sy.mapper.ArdSyCarRtuMapper; |
| | | import com.ruoyi.sy.service.ArdSyCarRtuService; |
| | | import com.ruoyi.utils.mqtt.MqttConsumer; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author Administrator |
| | |
| | | private ArdSyCarRtuMapper ardSyCarRtuMapper; |
| | | |
| | | @Override |
| | | public String allCarTopic() { |
| | | public String[] allCarTopic() { |
| | | List<ArdSyCarRtu> carRtus = ardSyCarRtuMapper.selectList(null); |
| | | List<String> list = new ArrayList<>(); |
| | | for (int i = 0; i < carRtus.size(); i++) { |
| | | list.add(carRtus.get(i).getTopicPublish()); |
| | | } |
| | | String[] topicArray = list.toArray(new String[list.size()]); |
| | | return Arrays.toString(topicArray); |
| | | return list.toArray(new String[list.size()]); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return ardSyCarRtuMapper.selectOne(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public String openLock(ArdSyCarRtu ardSyCarRtu) { |
| | | Map<String,Object> map = new HashMap<>(); |
| | | // map.put("A01", 110000);//导通第一路继电器 |
| | | // map.put("A02", 110000);//导通第二路继电器 |
| | | map.put("res", String.valueOf(System.currentTimeMillis())); |
| | | MqttConsumer.publish(ardSyCarRtu.getTopicSubscribe(), String.valueOf(new JSONObject(map))); |
| | | return "已发送开锁指令"; |
| | | } |
| | | |
| | | } |