zhangnaisong
2024-08-01 2799314298467be9ed68d9e19891e35cb3c3edad
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockProcessLogServiceImpl.java
@@ -6,6 +6,7 @@
import java.util.*;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysConfig;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.sy.domain.ArdSyUser;
@@ -59,6 +60,8 @@
    private SYClient sYClient;
    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private Map<String,Timer> timerMap = new HashMap();
    /**
     * 查询罐车锁操控日志
@@ -129,7 +132,7 @@
    }
    @Override
    public String processArdTankLockByLockId(String userId, String username, Map<String,String> para) {
    public AjaxResult processArdTankLockByLockId(String userId, String username, Map<String,String> para) {
        String lockId = para.get("lockId");
        String lockNum = para.get("lockNum");
        String carId = para.get("carId");
@@ -139,19 +142,19 @@
        //判断使能
        ArdTankLock ardTankLock = ardTankLockMapper.selectArdTankLockById(lockId);
        if(ardTankLock.getEnable().equals("false")){
            return "该锁使能关闭,无法操控";
            return AjaxResult.error("该锁使能关闭,无法操控");
        }
        ArdSyUser ardSyUser = ardSyUserMapper.userById(userId);
        if(ardSyUser == null){
            return "未挂接三一账号";
            return AjaxResult.error("未挂接三一账号");
        }
        List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT");
        String syURL = "";
        if(syURLResult.size() != 0){
            syURL = syURLResult.get(0).getConfigValue();
        }else{
            return "三一平台未录入";
            return AjaxResult.error("三一平台未录入");
        }
        String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword());
        Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, ardSyUser.getUserId());
@@ -164,13 +167,13 @@
        if(((String)syResult.get("rspCode")).equals("1")){
            Map<String,Object> carMap = ((List<Map<String,Object>>)syResult.get("list")).get(0);
            if(Integer.parseInt((String)carMap.get("speed")) != 0){
                return "车辆正在行驶中";
                return AjaxResult.error("车辆正在行驶中");
            }
            lng = (String) carMap.get("lng");
            lat = (String) carMap.get("lat");
            carPlate = (String) carMap.get("carName");
        }else{
            return "三一平台报错";
            return AjaxResult.error("三一平台报错");
        }
        List<ArdTankWall> ardTankWallList = ardTankWallMapper.getArdTankWallProcessByLockId(lockId);//查询锁挂接的全部需要动作的电子围栏
@@ -184,10 +187,10 @@
                    pts.add(new Point2D.Double(Double.parseDouble(wallpoiArro[j]), Double.parseDouble(wallpoiArro[j+1])));
                }
                if(GeoTools.IsPtInPoly(point, pts)){//在任意电子围栏内,不报警
                    return "当前车辆正处在" + ardTankWall.getWallName() + "中";
                    return AjaxResult.error("当前车辆正处在" + ardTankWall.getWallName() + "中");
                }
            }
            return "当前车辆正处在电子围栏外";
            return AjaxResult.error("当前车辆正处在电子围栏外");
        }else{
            try{
                String lockNumHead = lockNum.substring(0,2);
@@ -205,10 +208,7 @@
                String paramsStr = lockNum + "02" + process + checkNum;
                paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + paramsStr + "%22%7D";
                System.out.println(paramsStr);
                Map<String,Object> result = sendCmd(syURL, ardSyUser.getUserId(), carId, 199, "DataDownTransfer", paramsStr, sessionId);
                System.out.println("111111111111");
                System.out.println(result);
                if(((String)result.get("rspCode")).equals("0")){
                    ArdTankLockProcessLog ardTankLockProcessLog = new ArdTankLockProcessLog();
                    ardTankLockProcessLog.setId(IdUtils.simpleUUID());
@@ -228,13 +228,31 @@
                    ardTankLockProcessLog.setLatitude(lat);
                    ardTankLockProcessLog.setProcessTime(this.sdf.format(new Date()));
                    ardTankLockProcessLogMapper.insertArdTankLockProcessLog(ardTankLockProcessLog);
                    return "发送成功";
                    return AjaxResult.success("发送成功");
                }else if(((String)result.get("rspCode")).equals("-6")){
                    return AjaxResult.error("找不到车辆");
                }else if(((String)result.get("rspCode")).equals("-5")){
                    return AjaxResult.error("找不到用户");
                }else if(((String)result.get("rspCode")).equals("-4")){
                    return AjaxResult.error("找不到指令");
                }else if(((String)result.get("rspCode")).equals("-3")){
                    return AjaxResult.error("指令发送超时");
                }else if(((String)result.get("rspCode")).equals("-2")){
                    return AjaxResult.error("离线待发");
                }else if(((String)result.get("rspCode")).equals("-1")){
                    return AjaxResult.error("车辆离线");
                }else if(((String)result.get("rspCode")).equals("1")){
                    return AjaxResult.error("发送失败");
                }else if(((String)result.get("rspCode")).equals("2")){
                    return AjaxResult.error("消息有误");
                }else if(((String)result.get("rspCode")).equals("3")){
                    return AjaxResult.error("不支持");
                }else{
                    return "发送失败";
                    return AjaxResult.error("其他原因发送失败");
                }
            }catch(Exception e){
                e.printStackTrace();
                return "发送失败";
                return AjaxResult.error("发送失败" + e.toString());
            }
        }
    }