zhangnaisong
2024-07-02 9710740f1672fcaab74510ff5e8044c5fd0dafc8
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockServiceImpl.java
@@ -209,4 +209,67 @@
        //return Results.succeed(result0);
        return result0;
    }
    @Override
    public Map<String, Object> getLockByCarId(String carId, String usersId) {
        ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId);
        /*if(ardSyUser == null){
            return Results.error("没有挂接三一车辆用户");
        }*/
        List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT");
        String syURL = "";
        if(syURLResult.size() != 0){
            syURL = syURLResult.get(0).getConfigValue();
        }/*else{
            return Results.error("三一车辆地址未录入");
        }*/
        String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword());
        Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, ardSyUser.getUserId());
        String sessionId = (String) LogInResult.get("sessionId");
        List<ArdTankLock> ardTankLockList = ardTankLockMapper.getLockByCarId(carId);
        Map<String,Object> syResult = sYClient.getCarNearPositionByCarId(syURL, carId, ardSyUser.getUserId(), sessionId);
        Map<String,Object> resultMap = new HashMap();
        if(ardTankLockList.size() != 0){
            resultMap.put("carId",carId);
            if(((String)syResult.get("rspCode")).equals("1")){
                Map<String,Object> carMap = ((List<Map<String,Object>>)syResult.get("list")).get(0);
                resultMap.put("carPlate",carMap.get("carPlate"));
            }
        }else{
            resultMap.put("carId",carId);
            if(((String)syResult.get("rspCode")).equals("1")){
                Map<String,Object> carMap = ((List<Map<String,Object>>)syResult.get("list")).get(0);
                resultMap.put("carPlate",carMap.get("carPlate"));
            }
            resultMap.put("lockList",new ArrayList());
        }
        List<Map<String,Object>> result = new ArrayList();
        for(ArdTankLock ardTankLock : ardTankLockList){
            Map<String,Object> map = new HashMap();
            map.put("id",ardTankLock.getId());
            map.put("lockNum",ardTankLock.getLockNum());
            map.put("lockName",ardTankLock.getLockName());
            map.put("imgPositionTop",ardTankLock.getImgPositionTop());
            map.put("imgPositionLeft",ardTankLock.getImgPositionLeft());
            map.put("carId",ardTankLock.getCarId());
            map.put("enable",ardTankLock.getEnable());
            if(ardTankLock.getRestartState() == null){
                map.put("restartState","");
            }else{
                map.put("restartState",ardTankLock.getRestartState());
            }
            if(ardTankLock.getOnlineTime() == null){
                map.put("onlineTime","");
            }else{
                map.put("onlineTime",ardTankLock.getOnlineTime());
            }
            Map<String,Object> carMap = ((List<Map<String,Object>>)syResult.get("list")).get(0);
            map.put("carPlate",carMap.get("carPlate"));
            result.add(map);
        }
        resultMap.put("lockList",result);
        return resultMap;
    }
}