aijinhui
2023-11-15 5fe02f6f3c1a9df1b6d86e87329137cd57de0d00
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarLockServiceImpl.java
@@ -12,6 +12,7 @@
import com.ruoyi.sy.mapper.ArdSyCarRtuMapper;
import com.ruoyi.sy.param.AddRtuParam;
import com.ruoyi.sy.param.LockTypeParam;
import com.ruoyi.sy.param.RtuTypeParam;
import com.ruoyi.sy.service.ArdSyCarLockService;
import com.ruoyi.sy.vo.CarVo;
import com.ruoyi.sy.vo.RtuVo;
@@ -196,21 +197,23 @@
    @Override
    public List<ArdSyCarLock> data(String msg) {
        String pattern = "0.00"; // 指定保留两位小数的格式
        DecimalFormat decimalFormat = new DecimalFormat(pattern); //
//        String pattern = "0.00"; // 指定保留两位小数的格式
//        DecimalFormat decimalFormat = new DecimalFormat(pattern); //
        JSONObject jsonObject = JSONObject.parseObject(msg);
        List<ArdSyCarLock> lockList = new ArrayList<>();
        ArdSyCarLock ardSyCarLock1 = new ArdSyCarLock();
        ardSyCarLock1.setRelay("A01");
        ardSyCarLock1.setRelayInfo(String.valueOf(jsonObject.getInteger("A01")));
//        ardSyCarLock1.setRelayInfo(String.valueOf(jsonObject.getInteger("A01")));
        ardSyCarLock1.setRelayInfo(jsonObject.getInteger("A01"));
        ardSyCarLock1.setCurrents("C01");
        ardSyCarLock1.setCurrentInfo(decimalFormat.format(jsonObject.getDouble("C01")));
//        ardSyCarLock1.setCurrentInfo(decimalFormat.format(jsonObject.getDouble("C01")));
        ardSyCarLock1.setCurrentInfo(jsonObject.getDouble("C01"));
        lockList.add(ardSyCarLock1);
        ArdSyCarLock ardSyCarLock2 = new ArdSyCarLock();
        ardSyCarLock2.setRelay("A02");
        ardSyCarLock2.setRelayInfo(String.valueOf(jsonObject.getInteger("A02")));
        ardSyCarLock2.setRelayInfo(jsonObject.getInteger("A02"));
        ardSyCarLock2.setCurrents("C02");
        ardSyCarLock2.setCurrentInfo(decimalFormat.format(jsonObject.getDouble("C02")));
        ardSyCarLock2.setCurrentInfo(jsonObject.getDouble("C02"));
        lockList.add(ardSyCarLock2);
        return lockList;
    }
@@ -228,25 +231,25 @@
    }
    @Override
    public AjaxResult seal(LockTypeParam lockTypeParam) {
    public AjaxResult seal(RtuTypeParam rtuTypeParam) {
        QueryWrapper<ArdSyCarRtu> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("carId",lockTypeParam.getCarId());
        queryWrapper.eq("carId",rtuTypeParam.getCarId());
        ArdSyCarRtu ardSyCarRtu = rtuMapper.selectOne(queryWrapper);
        MqttOnce mqttOnce = new MqttOnce();
        //1解封
        if(lockTypeParam.getType()==1){
        if(rtuTypeParam.getType()==1){
            Map<String,Object> map = new HashMap<>();
            map.put("A01", 110000);//导通第一路继电器
            map.put("A02", 110000);//导通第二路继电器
            map.put("res", String.valueOf(System.currentTimeMillis()));
            try {
                return AjaxResult.success(mqttOnce.publishCar(lockTypeParam.getCarId(),ardSyCarRtu.getTopicPublish(),String.valueOf(new com.alibaba.fastjson2.JSONObject(map)),"解封"));
                return AjaxResult.success(mqttOnce.publishCar(rtuTypeParam.getCarId(),ardSyCarRtu.getTopicPublish(),String.valueOf(new com.alibaba.fastjson2.JSONObject(map)),"解封"));
            } catch (MqttException e) {
                log.debug("解封指令发生失败"+e);
            }
        }
        //0施封
        if(lockTypeParam.getType()==0){
        if(rtuTypeParam.getType()==0){
            //锁开关状态
            int lockCloseNum = 0;
            //查询锁信息
@@ -254,9 +257,9 @@
            for (int j = 0; j < ardSyCarLocks.size(); j++) {
                ArdSyCarLock ardSyCarLock = ardSyCarLocks.get(j);
                String currents = ardSyCarLock.getCurrents();
                String currentInfo = ardSyCarLock.getCurrentInfo();
                Double currentInfo = ardSyCarLock.getCurrentInfo();
                //电流值为4.0是关锁状态
                if(currentInfo.equals(4.00)){
                if(currentInfo.equals(4.00) || currentInfo.equals(4)){
                    lockCloseNum += 1;
                }else {
                    String key = "";
@@ -275,7 +278,7 @@
                    }
                    while(true){
                        ArdSyCarLock ardSyCarLock1 = getCurrentInfo(ardSyCarRtu.getId(),currents);
                        String currentInfo1 = ardSyCarLock1.getCurrentInfo();
                        Double currentInfo1 = ardSyCarLock1.getCurrentInfo();
                        if(currentInfo1.equals(4.00)){
                            lockCloseNum +=1;
                            break;
@@ -289,7 +292,7 @@
                map.put("A02", 100000);//断开第二路继电器
                map.put("res", String.valueOf(System.currentTimeMillis()));
                try {
                    return AjaxResult.success(mqttOnce.publishCar(lockTypeParam.getCarId(),ardSyCarRtu.getTopicPublish(),String.valueOf(new com.alibaba.fastjson2.JSONObject(map)),"施封"));
                    return AjaxResult.success(mqttOnce.publishCar(rtuTypeParam.getCarId(),ardSyCarRtu.getTopicPublish(),String.valueOf(new com.alibaba.fastjson2.JSONObject(map)),"施封"));
                } catch (MqttException e) {
                    log.debug("施封指令发生失败"+e);
                }
@@ -304,12 +307,12 @@
        queryWrapper.eq("car_id",lockTypeParam.getCarId());
        ArdSyCarRtu ardSyCarRtu = rtuMapper.selectOne(queryWrapper);
        ArdSyCarLock ardSyCarLock = lockMapper.selectById(lockTypeParam.getLockId());
        String relay = ardSyCarLock.getRelayInfo();
        Integer relay = ardSyCarLock.getRelayInfo();
        if(relay.equals("1")){
            AjaxResult.error(0,"该锁处于解封状态,远程无法操控,请先执行施封操作!");
        }
        String key = "";
        String currentInfo = ardSyCarLock.getCurrentInfo();
        Double currentInfo = ardSyCarLock.getCurrentInfo();
        if(currentInfo.equals("C01")){
            key = "D03";
        }else if(currentInfo.equals("C02")){