zhangnaisong
2024-07-22 6bc1206774770deb0b2df12ab24b4628e1f399eb
电磁锁状态查询修改及若依生成文件提交
已添加10个文件
已修改8个文件
1613 ■■■■■ 文件已修改
ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankLock.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankLockAutoProcessLog.java 219 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankLockState.java 187 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplSerialPort.java 370 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankLockAutoProcessLogMapper.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankLockMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankLockStateMapper.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/service/IArdTankLockAutoProcessLogService.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/service/IArdTankLockStateService.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockAutoProcessLogServiceImpl.java 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockProcessLogServiceImpl.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockServiceImpl.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockStateServiceImpl.java 100 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/resources/mapper/sy/ArdTankLockAutoProcessLogMapper.xml 118 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/resources/mapper/sy/ArdTankLockMapper.xml 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/resources/mapper/sy/ArdTankLockStateMapper.xml 113 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java
@@ -1,5 +1,6 @@
package com.ruoyi.sy.controller;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -18,6 +19,7 @@
import com.ruoyi.sy.gps31.PushClientImplSerialPort;
import com.ruoyi.sy.param.ArdSyCarParam;
import com.ruoyi.sy.service.IArdTankAbnormalParkAlarmService;
import com.ruoyi.sy.service.IArdTankLockService;
import com.ruoyi.sy.service.impl.ArdTankLockServiceImpl;
import com.ruoyi.sy.vo.ArdSyCarVo;
import com.ruoyi.sy.domain.ArdSyUser;
@@ -34,6 +36,9 @@
import com.ruoyi.utils.result.Results;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -79,6 +84,9 @@
    @Autowired
    private IArdTankAbnormalParkAlarmService ardTankAbnormalParkAlarmService;
    @Autowired
    private IArdTankLockService ardTankLockService;
    @Resource
    private SYClient sYClient;
@@ -154,7 +162,7 @@
                    public void run() {
                        SysConfig config = new SysConfig();
                        config.setConfigKey("syCarPT");
                        List<SysConfig> sysConfigResult = ((SysConfigServiceImpl) SpringUtils.getBean("sysConfigServiceImpl")).selectConfigList(config);
                        List<SysConfig> sysConfigResult = sysConfigService.selectConfigList(config);
                        String syURL = "";
                        if(sysConfigResult.size() == 0){
@@ -168,7 +176,7 @@
                        String finalSyURL = syURL;
                        List<ArdTankLock> result = ((ArdTankLockServiceImpl)SpringUtils.getBean("ardTankLockServiceImpl")).getArdTankLockAll();//查询全部电磁锁
                        List<ArdTankLock> result = ardTankLockService.getArdTankLockAll();//查询全部电磁锁
                        for(ArdTankLock ardTankLock : result){
                            Thread LockThread = new Thread(finalSyURL){
                                @Override
@@ -186,7 +194,7 @@
                                    String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "01" + checkNum + "%22%7D";
                                    sYClient.sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId);
                                    sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId);
                                }
                            };
                            LockThread.start();
@@ -196,7 +204,7 @@
                thread.start();
            }
        };
        //lockStateTimer.scheduleAtFixedRate(lockStateTask,date,1000);
        lockStateTimer.scheduleAtFixedRate(lockStateTask,date,2500);
    }
    /**
@@ -570,4 +578,32 @@
        }
    }
    public Map<String,Object> sendCmd(String syURL,String userId,String carId,Integer cmdId,String cmd,String paramsStr,String sessionId){
        OkHttpClient okHttpClient = new OkHttpClient();
        Request request = new Request.Builder()
                .url(syURL + "/gps-web/api/send_cmd.jsp?params="+paramsStr+"&userId="+userId+"&carId="+carId+"&cmdId="+cmdId+"&cmd="+cmd+"&sessionId="+sessionId)
                .build();
        //System.out.println("url = " + syURL + "/gps-web/api/send_cmd.jsp?params="+paramsStr+"&userId="+userId+"&carId="+carId+"&cmdId="+cmdId+"&cmd="+cmd+"&sessionId="+sessionId);
        Response response = null;
        try {
            response = okHttpClient.newCall(request).execute();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        okhttp3.ResponseBody responseBody = response.body();
        try {
            String message = responseBody.string();// å“åº”体
            Map<String,Object> map = (Map<String, Object>) JSON.parse(message);
            return map;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return new HashMap();
        }
    }
}
ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankLock.java
@@ -50,6 +50,8 @@
    @Excel(name = "在线时间")
    private String onlineTime;
    private ArdTankLockState ardTankLockState;
    public void setId(String id) 
    {
        this.id = id;
@@ -132,6 +134,14 @@
        return onlineTime;
    }
    public ArdTankLockState getArdTankLockState() {
        return ardTankLockState;
    }
    public void setArdTankLockState(ArdTankLockState ardTankLockState) {
        this.ardTankLockState = ardTankLockState;
    }
    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankLockAutoProcessLog.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,219 @@
package com.ruoyi.sy.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
 * ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—å¯¹è±¡ ard_tank_lock_auto_process_log
 *
 * @author ard
 * @date 2024-07-12
 */
public class ArdTankLockAutoProcessLog extends BaseEntity
{
    private static final long serialVersionUID = 1L;
    /** ä¸»é”® */
    private String id;
    /** é”ä¸»é”® */
    @Excel(name = "锁主键")
    private String lockId;
    /** é”ç¼–号 */
    @Excel(name = "锁编号")
    private String lockNum;
    /** ä¸‰ä¸€è½¦è¾†ä¸»é”® */
    @Excel(name = "三一车辆主键")
    private String carId;
    /** è½¦ç‰Œå· */
    @Excel(name = "车牌号")
    private String carPlate;
    /** ç”µå­å›´æ ä¸»é”® */
    @Excel(name = "电子围栏主键")
    private String wallId;
    /** ç”µå­å›´æ åç§° */
    @Excel(name = "电子围栏名称")
    private String wallName;
    /** ç”µå­å›´æ ç±»åž‹ */
    @Excel(name = "电子围栏类型")
    private String wallType;
    /** æ“ä½œ */
    @Excel(name = "操作")
    private String process;
    /** æ“ä½œåŽŸå›  */
    @Excel(name = "操作原因")
    private String processReason;
    /** ç»åº¦ */
    @Excel(name = "经度")
    private String longitude;
    /** çº¬åº¦ */
    @Excel(name = "纬度")
    private String latitude;
    /** é€Ÿåº¦ */
    @Excel(name = "速度")
    private String velocity;
    /** æ“ä½œæ—¶é—´ */
    @Excel(name = "操作时间")
    private String processTime;
    public void setId(String id)
    {
        this.id = id;
    }
    public String getId()
    {
        return id;
    }
    public void setLockId(String lockId)
    {
        this.lockId = lockId;
    }
    public String getLockId()
    {
        return lockId;
    }
    public void setLockNum(String lockNum)
    {
        this.lockNum = lockNum;
    }
    public String getLockNum()
    {
        return lockNum;
    }
    public void setCarId(String carId)
    {
        this.carId = carId;
    }
    public String getCarId()
    {
        return carId;
    }
    public void setCarPlate(String carPlate)
    {
        this.carPlate = carPlate;
    }
    public String getCarPlate()
    {
        return carPlate;
    }
    public void setWallId(String wallId)
    {
        this.wallId = wallId;
    }
    public String getWallId()
    {
        return wallId;
    }
    public void setWallName(String wallName)
    {
        this.wallName = wallName;
    }
    public String getWallName()
    {
        return wallName;
    }
    public void setWallType(String wallType)
    {
        this.wallType = wallType;
    }
    public String getWallType()
    {
        return wallType;
    }
    public void setProcess(String process)
    {
        this.process = process;
    }
    public String getProcess()
    {
        return process;
    }
    public void setProcessReason(String processReason)
    {
        this.processReason = processReason;
    }
    public String getProcessReason()
    {
        return processReason;
    }
    public void setLongitude(String longitude)
    {
        this.longitude = longitude;
    }
    public String getLongitude()
    {
        return longitude;
    }
    public void setLatitude(String latitude)
    {
        this.latitude = latitude;
    }
    public String getLatitude()
    {
        return latitude;
    }
    public void setVelocity(String velocity)
    {
        this.velocity = velocity;
    }
    public String getVelocity()
    {
        return velocity;
    }
    public void setProcessTime(String processTime)
    {
        this.processTime = processTime;
    }
    public String getProcessTime()
    {
        return processTime;
    }
    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("lockId", getLockId())
            .append("lockNum", getLockNum())
            .append("carId", getCarId())
            .append("carPlate", getCarPlate())
            .append("wallId", getWallId())
            .append("wallName", getWallName())
            .append("wallType", getWallType())
            .append("process", getProcess())
            .append("processReason", getProcessReason())
            .append("longitude", getLongitude())
            .append("latitude", getLatitude())
            .append("velocity", getVelocity())
            .append("processTime", getProcessTime())
            .toString();
    }
}
ard-work/src/main/java/com/ruoyi/sy/domain/ArdTankLockState.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,187 @@
package com.ruoyi.sy.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
 * ç½è½¦é”çŠ¶æ€å¯¹è±¡ ard_tank_lock_state
 *
 * @author ard
 * @date 2024-07-18
 */
public class ArdTankLockState extends BaseEntity
{
    private static final long serialVersionUID = 1L;
    /** ä¸»é”® */
    private String id;
    /** é”ä¸»é”® */
    @Excel(name = "锁主键")
    private String lockId;
    /** é”ç¼–号 */
    @Excel(name = "锁编号")
    private String lockNum;
    /** é”çŠ¶æ€ */
    @Excel(name = "锁状态")
    private String lockState;
    /** ä½ç½®çŠ¶æ€ */
    @Excel(name = "位置状态")
    private String lockPositionState;
    /** å¤–壳状态 */
    @Excel(name = "外壳状态")
    private String lockShellState;
    /** é‡å¯çŠ¶æ€ï¼šå¼€æˆ–å…³ */
    @Excel(name = "重启状态:开或关")
    private String restartState;
    /** ç”µæ± ç”µåŽ‹ */
    @Excel(name = "电池电压")
    private String batterVoltage;
    /** ç”µæºç”µåŽ‹ */
    @Excel(name = "电源电压")
    private String powerVoltage;
    /** ä¸Šä¼ æ—¶é—´ */
    @Excel(name = "上传时间")
    private String uploadTime;
    /** å”¯ä¸€æ ‡è®° */
    @Excel(name = "唯一标记")
    private String uniqueMark;
    private Boolean lockStateMark;
    public void setId(String id)
    {
        this.id = id;
    }
    public String getId()
    {
        return id;
    }
    public void setLockId(String lockId)
    {
        this.lockId = lockId;
    }
    public String getLockId()
    {
        return lockId;
    }
    public void setLockNum(String lockNum)
    {
        this.lockNum = lockNum;
    }
    public String getLockNum()
    {
        return lockNum;
    }
    public void setLockState(String lockState)
    {
        this.lockState = lockState;
    }
    public String getLockState()
    {
        return lockState;
    }
    public void setLockPositionState(String lockPositionState)
    {
        this.lockPositionState = lockPositionState;
    }
    public String getLockPositionState()
    {
        return lockPositionState;
    }
    public void setLockShellState(String lockShellState)
    {
        this.lockShellState = lockShellState;
    }
    public String getLockShellState()
    {
        return lockShellState;
    }
    public void setRestartState(String restartState)
    {
        this.restartState = restartState;
    }
    public String getRestartState()
    {
        return restartState;
    }
    public void setBatterVoltage(String batterVoltage)
    {
        this.batterVoltage = batterVoltage;
    }
    public String getBatterVoltage()
    {
        return batterVoltage;
    }
    public void setPowerVoltage(String powerVoltage)
    {
        this.powerVoltage = powerVoltage;
    }
    public String getPowerVoltage()
    {
        return powerVoltage;
    }
    public void setUploadTime(String uploadTime)
    {
        this.uploadTime = uploadTime;
    }
    public String getUploadTime()
    {
        return uploadTime;
    }
    public void setUniqueMark(String uniqueMark)
    {
        this.uniqueMark = uniqueMark;
    }
    public String getUniqueMark()
    {
        return uniqueMark;
    }
    public Boolean getLockStateMark() {
        return lockStateMark;
    }
    public void setLockStateMark(Boolean lockStateMark) {
        this.lockStateMark = lockStateMark;
    }
    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("lockId", getLockId())
            .append("lockNum", getLockNum())
            .append("lockState", getLockState())
            .append("lockPositionState", getLockPositionState())
            .append("lockShellState", getLockShellState())
            .append("restartState", getRestartState())
            .append("batterVoltage", getBatterVoltage())
            .append("powerVoltage", getPowerVoltage())
            .append("uploadTime", getUploadTime())
            .append("uniqueMark", getUniqueMark())
            .toString();
    }
}
ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java
@@ -383,7 +383,7 @@
                        ((ArdTankAbnormalParkAlarmServiceImpl)SpringUtils.getBean("ardTankAbnormalParkAlarmServiceImpl")).insertArdTankAbnormalParkAlarm(gpsMap);
                    }
                };
                tankCarParkingAlarmThread.start();
                //tankCarParkingAlarmThread.start();
                /*Thread autoProcessThread = new Thread(){//自动操控线程
                    @Override
ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplSerialPort.java
@@ -14,24 +14,30 @@
import com.gps31.push.util.MapUtil;
import com.ruoyi.common.core.domain.entity.SysConfig;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.sy.domain.ArdSyCarLock;
import com.ruoyi.sy.domain.ArdSyCarRtu;
import com.ruoyi.sy.domain.ArdTankLock;
import com.ruoyi.sy.domain.ArdTankLockState;
import com.ruoyi.sy.service.ArdSyCarLockService;
import com.ruoyi.sy.service.ArdSyCarRtuService;
import com.ruoyi.sy.service.impl.ArdSyCarDayServiceImpl;
import com.ruoyi.sy.service.impl.ArdSyCarServiceImpl;
import com.ruoyi.sy.service.impl.ArdTankAbnormalParkAlarmServiceImpl;
import com.ruoyi.sy.service.impl.ArdTankLockServiceImpl;
import com.ruoyi.sy.service.impl.*;
import com.ruoyi.system.service.impl.SysConfigServiceImpl;
import com.ruoyi.utils.forest.SYClient;
import com.ruoyi.utils.qymqtt.newM.EmqClient;
import com.ruoyi.utils.qymqtt.newM.QosEnum;
import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.paho.client.mqttv3.MqttException;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@@ -41,73 +47,20 @@
 * @author chencq
 * @version 1.0
 */
@Slf4j(topic = "mqttCar")
public class PushClientImplSerialPort extends PushClient implements Runnable {
//    private static final Log log = LogFactory.getLog(PushClientImplPosition.class);
    private static final Log log = LogFactory.getLog(PushClientImplSerialPort.class);
    private String ip;
    private static String ip;
    private String userId;
    private static String userId;
    private String password;
    private Timer lockStateTimer;
    private static String password;
    public PushClientImplSerialPort(String ip, String userId, String password) {
        this.ip = ip;
        this.userId = userId;
        this.password = password;
        /*Date date = new Date();
        this.lockStateTimer = new Timer();//定时获取各个锁的状态
        TimerTask lockStateTask =new TimerTask(){
            @Override
            public void run(){
                SysConfig config = new SysConfig();
                config.setConfigKey("syCarPT");
                List<SysConfig> sysConfigResult = ((SysConfigServiceImpl)SpringUtils.getBean("sysConfigServiceImpl")).selectConfigList(config);
                String syURL = "";
                if(sysConfigResult.size() == 0){//三一车辆加入开关
                    return;
                }else{
                    syURL = sysConfigResult.get(0).getConfigValue();
                }
                String passwordMd5 = DigestUtils.md5Hex(password);
                Map<String, Object> LogInResult = ((SYClient)SpringUtils.getBean("sYClient")).logIn(syURL, passwordMd5, userId);
                String sessionId = (String) LogInResult.get("sessionId");
                String finalSyURL = syURL;
                Thread thread = new Thread(finalSyURL){
                    @Override
                    public void run() {
                        List<ArdTankLock> result = ((ArdTankLockServiceImpl)SpringUtils.getBean("ardTankLockServiceImpl")).getArdTankLockAll();//查询全部电磁锁
                        for(ArdTankLock ardTankLock : result){
                            //Thread LockThread = new Thread(finalSyURL){
                                String lockNumHead = ardTankLock.getLockNum().substring(0,2);
                                String lockNumTail = ardTankLock.getLockNum().substring(2,4);
                                //计算校验
                                String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16) + Integer.parseInt(lockNumTail, 16) + Integer.parseInt("01", 16));
                                if(checkNum.length() == 1){
                                    checkNum = "0" + checkNum;
                                }else if(checkNum.length() > 2){
                                    checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length());
                                }
                                String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "01" + checkNum + "%22%7D";
                               //Map<String,Object> result = ((SYClient)SpringUtils.getBean("sYClient")).sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId);
                            //};
                            //LockThread.start();
                        }
                    }
                };
                thread.start();
            }
        };
        lockStateTimer.scheduleAtFixedRate(lockStateTask,date,1000);*/
    }
    public PushClientImplSerialPort() {
@@ -151,8 +104,238 @@
             */
        }else if("0401".equals(pushMsg.getCmd())) {//透传消息
            Map<String,Object> dataMap = pushMsg.getJsonMap();
            String carName = MapUtil.getStrVal(dataMap, "carName","");//获取车牌号
            //String carName = MapUtil.getStrVal(dataMap, "carName","");//获取车牌号
            //log.error(String.format("   ---->收到透传数据:%s",JSON.toJSONString(dataMap)));
            Thread thread = new Thread(){
                @Override
                public void run() {
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    Date now = new Date();
                    try {
                        String data = (String) dataMap.get("data");
                        String lockNum = data.substring(0, 4);
                        String code = data.substring(4, 6);
                        if(code.equals("01")){//功能码01为锁实时状态
                            String lockState = data.substring(6, 8);
                            String lockPositionState = data.substring(8, 10);
                            String lockShellState = data.substring(10, 12);
                            String restartState = data.substring(12, 14);
                            String batterVoltage = data.substring(14, 18);
                            String powerVoltage = data.substring(18, 22);
                            String time = data.substring(22, 34);
                            //计算时间
                            String year = time.substring(0, 2);
                            String month = time.substring(2, 4);
                            String day = time.substring(4, 6);
                            String hour = time.substring(6, 8);
                            String minute = time.substring(8, 10);
                            String second = time.substring(10, 12);
                            Integer yearNum = Integer.parseInt(year, 16);
                            if(yearNum <= 9){
                                time = "200" + yearNum + "-";
                            }else{
                                time = "20" + yearNum + "-";
                            }
                            Integer monthNum = Integer.parseInt(month, 16);
                            if(monthNum <= 9){
                                time = time + "0" + monthNum + "-";
                            }else{
                                time = time + monthNum + "-";
                            }
                            Integer dayNum = Integer.parseInt(day, 16);
                            if(dayNum <= 9){
                                time = time + "0" + dayNum + " ";
                            }else{
                                time = time + dayNum + " ";
                            }
                            Integer hourNum = Integer.parseInt(hour, 16);
                            if(hourNum <= 9){
                                time = time + "0" + hourNum + ":";
                            }else{
                                time = time + hourNum + ":";
                            }
                            Integer minuteNum = Integer.parseInt(minute, 16);
                            if(minuteNum <= 9){
                                time = time + "0" + minuteNum + ":";
                            }else{
                                time = time + minuteNum + ":";
                            }
                            Integer secondNum = Integer.parseInt(second, 16);
                            if(secondNum <= 9){
                                time = time + "0" + secondNum;
                            }else{
                                time = time + secondNum;
                            }
                            ArdTankLock ardTankLock = new ArdTankLock();
                            ardTankLock.setLockNum(lockNum);
                            List<ArdTankLock> ardTankLockResult = ((ArdTankLockServiceImpl)SpringUtils.getBean("ardTankLockServiceImpl")).selectArdTankLockList(ardTankLock);
                            if(ardTankLockResult.isEmpty()){//锁没有录入则返回
                                return;
                            }
                            long cha = now.getTime() - sdf.parse(time).getTime();
                            System.out.println("////////////////");
                            System.out.println(time);
                            System.out.println(cha);
                            /*if(Math.abs(cha) >= 5 * 1000){
                                //时间校准
                                String url = "http://" + ip + ":9999";
                                String passwordMd5 = DigestUtils.md5Hex(password);
                                Map<String, Object> LogInResult = loginIn(url, userId, passwordMd5);
                                String sessionId = (String) LogInResult.get("sessionId");
                                //获取时间并拆分年月日时分秒
                                String nowTime = sdf.format(now);
                                String nowYear = nowTime.substring(2,4);
                                System.out.println(nowYear);
                                String nowMonth = nowTime.substring(5,7);
                                System.out.println(nowMonth);
                                String nowDay = nowTime.substring(8,10);
                                System.out.println(nowDay);
                                String nowHour = nowTime.substring(11,13);
                                System.out.println(nowHour);
                                String nowMinute = nowTime.substring(14,16);
                                System.out.println(nowMinute);
                                String nowSecond = nowTime.substring(17,19);
                                System.out.println(nowSecond);
                                String nowYearHex = Integer.toHexString(Integer.parseInt(nowYear));
                                if(nowYearHex.length() == 1){
                                    nowYearHex = "0" + nowYearHex;
                                }
                                System.out.println(nowYearHex);
                                String nowMonthHex = Integer.toHexString(Integer.parseInt(nowMonth));
                                if(nowMonthHex.length() == 1){
                                    nowMonthHex = "0" + nowMonthHex;
                                }
                                System.out.println(nowMonthHex);
                                String nowDayHex = Integer.toHexString(Integer.parseInt(nowDay));
                                if(nowDayHex.length() == 1){
                                    nowDayHex = "0" + nowDayHex;
                                }
                                System.out.println(nowDayHex);
                                String nowHourHex = Integer.toHexString(Integer.parseInt(nowHour));
                                if(nowHourHex.length() == 1){
                                    nowHourHex = "0" + nowHourHex;
                                }
                                System.out.println(nowHourHex);
                                String nowMinuteHex = Integer.toHexString(Integer.parseInt(nowMinute));
                                if(nowMinuteHex.length() == 1){
                                    nowMinuteHex = "0" + nowMinuteHex;
                                }
                                System.out.println(nowMinuteHex);
                                String nowSecondHex = Integer.toHexString(Integer.parseInt(nowSecond));
                                if(nowSecondHex.length() == 1){
                                    nowSecondHex = "0" + nowSecondHex;
                                }
                                System.out.println(nowSecondHex);
                                //16进制时间
                                String timeHex = nowYearHex + nowMonthHex + nowDayHex + nowHourHex + nowMinuteHex + nowSecondHex;
                                System.out.println(timeHex);
                                String lockNumHead = ardTankLockResult.get(0).getLockNum().substring(0,2);
                                String lockNumTail = ardTankLockResult.get(0).getLockNum().substring(2,4);
                                //计算校验
                                String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16) + Integer.parseInt(lockNumTail, 16) + Integer.parseInt("08", 16) +
                                        Integer.parseInt(nowYearHex, 16) + Integer.parseInt(nowMonthHex, 16) + Integer.parseInt(nowDayHex, 16) +
                                        Integer.parseInt(nowHourHex, 16) + Integer.parseInt(nowMinuteHex, 16) + Integer.parseInt(nowSecondHex, 16));
                                System.out.println(checkNum);
                                if(checkNum.length() == 1){
                                    checkNum = "0" + checkNum;
                                }else if(checkNum.length() > 2){
                                    checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length());
                                }
                                System.out.println(checkNum);
                                String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "08" + timeHex + checkNum + "%22%7D";
                                System.out.println(ardTankLock.getLockNum() + "08" + timeHex + checkNum);
                                sendCmd(url,userId,ardTankLockResult.get(0).getCarId(),199,"DataDownTransfer", paramsStr,sessionId);
                            }else{*/
                                ArdTankLockState ardTankLockState = new ArdTankLockState();
                                ardTankLockState.setId(IdUtils.simpleUUID());
                                ardTankLockState.setLockId(ardTankLockResult.get(0).getId());
                                ardTankLockState.setLockNum(lockNum);
                                switch (lockState) {//锁芯状态
                                    case "01": ardTankLockState.setLockState("开锁状态");break;
                                    case "02": ardTankLockState.setLockState("关锁状态");break;
                                    case "03": ardTankLockState.setLockState("异常状态");break;
                                    default:
                                        break;
                                }
                                switch (lockPositionState) {//位置状态
                                    case "01": ardTankLockState.setLockPositionState("正常");break;
                                    case "02": ardTankLockState.setLockPositionState("异常");break;
                                    default:
                                        break;
                                }
                                switch (lockShellState) {//外壳状态
                                    case "01": ardTankLockState.setLockShellState("正常");break;
                                    case "02": ardTankLockState.setLockShellState("异常");break;
                                    default:
                                        break;
                                }
                                switch (restartState) {//复位状态
                                    case "01": ardTankLockState.setRestartState("开锁状态");break;
                                    case "02": ardTankLockState.setRestartState("关锁状态");break;
                                    default:
                                        break;
                                }
                                Number batterVoltageNum = Integer.parseInt(batterVoltage,16) * 0.1;
                                String batterVoltageStr = String.valueOf(batterVoltageNum);
                                if(batterVoltageStr.length() > 4){
                                    batterVoltageStr = batterVoltageStr.substring(0,4);
                                }
                                if(batterVoltageStr.contains(".")){//四舍五入
                                    String decimalPart = batterVoltageStr.split("\\.")[1];
                                    if(Integer.parseInt(decimalPart) > 5){
                                        batterVoltageStr = batterVoltageStr.split("\\.")[0] + ".5";
                                    }else if(Integer.parseInt(decimalPart) <= 5){
                                        batterVoltageStr = batterVoltageStr.split("\\.")[0] + ".0";
                                    }
                                }else{
                                    batterVoltageStr = batterVoltageStr + ".0";
                                }
                                ardTankLockState.setBatterVoltage(batterVoltageStr);
                                Number powerVoltageNum = Integer.parseInt(powerVoltage,16) * 0.1;
                                String powerVoltageStr = String.valueOf(powerVoltageNum);
                                if(powerVoltageStr.length() > 4){
                                    powerVoltageStr = powerVoltageStr.substring(0,4);
                                }
                                if(powerVoltageStr.contains(".")){//四舍五入
                                    String decimalPart = powerVoltageStr.split("\\.")[1];
                                    if(Integer.parseInt(decimalPart) > 5){
                                        powerVoltageStr = powerVoltageStr.split("\\.")[0] + ".5";
                                    }else if(Integer.parseInt(decimalPart) <= 5){
                                        powerVoltageStr = powerVoltageStr.split("\\.")[0] + ".0";
                                    }
                                }else{
                                    powerVoltageStr = powerVoltageStr + ".0";
                                }
                                ardTankLockState.setPowerVoltage(powerVoltageStr);
                                String uniqueMark = lockNum + "," + lockState + "," + lockPositionState + "," + lockShellState
                                        + "," + restartState + "," + batterVoltageStr + "," + powerVoltageStr;
                                ardTankLockState.setUploadTime(time);
                                ardTankLockState.setUniqueMark(uniqueMark);
                                ((ArdTankLockStateServiceImpl)SpringUtils.getBean("ardTankLockStateServiceImpl")).insertOrUpdateArdTankLockState(ardTankLockState);
                            //}
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                        return;//强转失败返回
                    }
                }
            };
            thread.start();
            /**
             *
             * è¯·åŠ å…¥ä¸‰æ–¹é›†æˆæ–¹çš„ä¸šåŠ¡é€»è¾‘
@@ -164,7 +347,7 @@
    public void sendMassage() {
        try {
            PushClientImplSerialPort client = new PushClientImplSerialPort();
            client.setLog(true);//是否打印明文
            client.setLog(false);//是否打印明文
            client.setHost(this.ip);//服务器IP
            client.setPort(10100);//服务器端口
            client.setUserName(this.userId);//系统用户名
@@ -185,4 +368,65 @@
        sendMassage();
    }
    public static Map<String,Object> loginIn(String syURL,String userId,String password){//登录
        OkHttpClient okHttpClient = new OkHttpClient();
        String passwordMd5 = DigestUtils.md5Hex(password);
        Request request = new Request.Builder()
                .url(syURL + "/gps-web/api/login.jsp?"+"password="+passwordMd5+"&userId="+userId+"&loginType=user&loginWay=interface&loginLang=zh_CN")
                .build();
        Response response = null;
        try {
            response = okHttpClient.newCall(request).execute();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        response.headers(); //响应头
        okhttp3.ResponseBody responseBody = response.body();
        try {
            String message = responseBody.string();// å“åº”体
            Map<String,Object> map = (Map<String, Object>) JSON.parse(message);
            map.put("passwordMd5", passwordMd5);
            //System.out.println(message);
            return map;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return new HashMap();
        }
    }
    public Map<String,Object> sendCmd(String syURL,String userId,String carId,Integer cmdId,String cmd,String paramsStr,String sessionId){
        OkHttpClient okHttpClient = new OkHttpClient();
        Request request = new Request.Builder()
                .url(syURL + "/gps-web/api/send_cmd.jsp?params="+paramsStr+"&userId="+userId+"&carId="+carId+"&cmdId="+cmdId+"&cmd="+cmd+"&sessionId="+sessionId)
                .build();
        //System.out.println("url = " + syURL + "/gps-web/api/send_cmd.jsp?params="+paramsStr+"&userId="+userId+"&carId="+carId+"&cmdId="+cmdId+"&cmd="+cmd+"&sessionId="+sessionId);
        Response response = null;
        try {
            response = okHttpClient.newCall(request).execute();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        okhttp3.ResponseBody responseBody = response.body();
        try {
            String message = responseBody.string();// å“åº”体
            Map<String,Object> map = (Map<String, Object>) JSON.parse(message);
            return map;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return new HashMap();
        }
    }
}
ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankLockAutoProcessLogMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,61 @@
package com.ruoyi.sy.mapper;
import java.util.List;
import com.ruoyi.sy.domain.ArdTankLockAutoProcessLog;
/**
 * ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—Mapper接口
 *
 * @author ard
 * @date 2024-07-12
 */
public interface ArdTankLockAutoProcessLogMapper
{
    /**
     * æŸ¥è¯¢ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     *
     * @param id ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—ä¸»é”®
     * @return ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     */
    public ArdTankLockAutoProcessLog selectArdTankLockAutoProcessLogById(String id);
    /**
     * æŸ¥è¯¢ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—åˆ—è¡¨
     *
     * @param ardTankLockAutoProcessLog ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     * @return ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—é›†åˆ
     */
    public List<ArdTankLockAutoProcessLog> selectArdTankLockAutoProcessLogList(ArdTankLockAutoProcessLog ardTankLockAutoProcessLog);
    /**
     * æ–°å¢žç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     *
     * @param ardTankLockAutoProcessLog ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     * @return ç»“æžœ
     */
    public int insertArdTankLockAutoProcessLog(ArdTankLockAutoProcessLog ardTankLockAutoProcessLog);
    /**
     * ä¿®æ”¹ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     *
     * @param ardTankLockAutoProcessLog ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     * @return ç»“æžœ
     */
    public int updateArdTankLockAutoProcessLog(ArdTankLockAutoProcessLog ardTankLockAutoProcessLog);
    /**
     * åˆ é™¤ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     *
     * @param id ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—ä¸»é”®
     * @return ç»“æžœ
     */
    public int deleteArdTankLockAutoProcessLogById(String id);
    /**
     * æ‰¹é‡åˆ é™¤ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     *
     * @param ids éœ€è¦åˆ é™¤çš„æ•°æ®ä¸»é”®é›†åˆ
     * @return ç»“æžœ
     */
    public int deleteArdTankLockAutoProcessLogByIds(String[] ids);
}
ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankLockMapper.java
@@ -81,4 +81,6 @@
    public Long selectArdTankLockTotalByCarIdList(@Param("carIdList") List<String> carIdList);
    public int deleteArdTankLockAndWallByCarIds(@Param("carIds") List<String> carIds);
    public String getIdByLockNum(String lockNum);
}
ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankLockStateMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,63 @@
package com.ruoyi.sy.mapper;
import java.util.List;
import com.ruoyi.sy.domain.ArdTankLockState;
/**
 * ç½è½¦é”çŠ¶æ€Mapper接口
 *
 * @author ard
 * @date 2024-07-18
 */
public interface ArdTankLockStateMapper
{
    /**
     * æŸ¥è¯¢ç½è½¦é”çŠ¶æ€
     *
     * @param id ç½è½¦é”çŠ¶æ€ä¸»é”®
     * @return ç½è½¦é”çŠ¶æ€
     */
    public ArdTankLockState selectArdTankLockStateById(String id);
    /**
     * æŸ¥è¯¢ç½è½¦é”çŠ¶æ€åˆ—è¡¨
     *
     * @param ardTankLockState ç½è½¦é”çŠ¶æ€
     * @return ç½è½¦é”çŠ¶æ€é›†åˆ
     */
    public List<ArdTankLockState> selectArdTankLockStateList(ArdTankLockState ardTankLockState);
    /**
     * æ–°å¢žç½è½¦é”çŠ¶æ€
     *
     * @param ardTankLockState ç½è½¦é”çŠ¶æ€
     * @return ç»“æžœ
     */
    public int insertArdTankLockState(ArdTankLockState ardTankLockState);
    /**
     * ä¿®æ”¹ç½è½¦é”çŠ¶æ€
     *
     * @param ardTankLockState ç½è½¦é”çŠ¶æ€
     * @return ç»“æžœ
     */
    public int updateArdTankLockState(ArdTankLockState ardTankLockState);
    /**
     * åˆ é™¤ç½è½¦é”çŠ¶æ€
     *
     * @param id ç½è½¦é”çŠ¶æ€ä¸»é”®
     * @return ç»“æžœ
     */
    public int deleteArdTankLockStateById(String id);
    /**
     * æ‰¹é‡åˆ é™¤ç½è½¦é”çŠ¶æ€
     *
     * @param ids éœ€è¦åˆ é™¤çš„æ•°æ®ä¸»é”®é›†åˆ
     * @return ç»“æžœ
     */
    public int deleteArdTankLockStateByIds(String[] ids);
    public int insertOrUpdateArdTankLockState(ArdTankLockState ardTankLockState);
}
ard-work/src/main/java/com/ruoyi/sy/service/IArdTankLockAutoProcessLogService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,61 @@
package com.ruoyi.sy.service;
import java.util.List;
import com.ruoyi.sy.domain.ArdTankLockAutoProcessLog;
/**
 * ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—Service接口
 *
 * @author ard
 * @date 2024-07-12
 */
public interface IArdTankLockAutoProcessLogService
{
    /**
     * æŸ¥è¯¢ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     *
     * @param id ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—ä¸»é”®
     * @return ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     */
    public ArdTankLockAutoProcessLog selectArdTankLockAutoProcessLogById(String id);
    /**
     * æŸ¥è¯¢ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—åˆ—è¡¨
     *
     * @param ardTankLockAutoProcessLog ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     * @return ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—é›†åˆ
     */
    public List<ArdTankLockAutoProcessLog> selectArdTankLockAutoProcessLogList(ArdTankLockAutoProcessLog ardTankLockAutoProcessLog);
    /**
     * æ–°å¢žç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     *
     * @param ardTankLockAutoProcessLog ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     * @return ç»“æžœ
     */
    public int insertArdTankLockAutoProcessLog(ArdTankLockAutoProcessLog ardTankLockAutoProcessLog);
    /**
     * ä¿®æ”¹ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     *
     * @param ardTankLockAutoProcessLog ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     * @return ç»“æžœ
     */
    public int updateArdTankLockAutoProcessLog(ArdTankLockAutoProcessLog ardTankLockAutoProcessLog);
    /**
     * æ‰¹é‡åˆ é™¤ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     *
     * @param ids éœ€è¦åˆ é™¤çš„罐车锁自动操控日志主键集合
     * @return ç»“æžœ
     */
    public int deleteArdTankLockAutoProcessLogByIds(String[] ids);
    /**
     * åˆ é™¤ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—ä¿¡æ¯
     *
     * @param id ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—ä¸»é”®
     * @return ç»“æžœ
     */
    public int deleteArdTankLockAutoProcessLogById(String id);
}
ard-work/src/main/java/com/ruoyi/sy/service/IArdTankLockStateService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,63 @@
package com.ruoyi.sy.service;
import java.util.List;
import com.ruoyi.sy.domain.ArdTankLockState;
/**
 * ç½è½¦é”çŠ¶æ€Service接口
 *
 * @author ard
 * @date 2024-07-18
 */
public interface IArdTankLockStateService
{
    /**
     * æŸ¥è¯¢ç½è½¦é”çŠ¶æ€
     *
     * @param id ç½è½¦é”çŠ¶æ€ä¸»é”®
     * @return ç½è½¦é”çŠ¶æ€
     */
    public ArdTankLockState selectArdTankLockStateById(String id);
    /**
     * æŸ¥è¯¢ç½è½¦é”çŠ¶æ€åˆ—è¡¨
     *
     * @param ardTankLockState ç½è½¦é”çŠ¶æ€
     * @return ç½è½¦é”çŠ¶æ€é›†åˆ
     */
    public List<ArdTankLockState> selectArdTankLockStateList(ArdTankLockState ardTankLockState);
    /**
     * æ–°å¢žç½è½¦é”çŠ¶æ€
     *
     * @param ardTankLockState ç½è½¦é”çŠ¶æ€
     * @return ç»“æžœ
     */
    public int insertArdTankLockState(ArdTankLockState ardTankLockState);
    /**
     * ä¿®æ”¹ç½è½¦é”çŠ¶æ€
     *
     * @param ardTankLockState ç½è½¦é”çŠ¶æ€
     * @return ç»“æžœ
     */
    public int updateArdTankLockState(ArdTankLockState ardTankLockState);
    /**
     * æ‰¹é‡åˆ é™¤ç½è½¦é”çŠ¶æ€
     *
     * @param ids éœ€è¦åˆ é™¤çš„罐车锁状态主键集合
     * @return ç»“æžœ
     */
    public int deleteArdTankLockStateByIds(String[] ids);
    /**
     * åˆ é™¤ç½è½¦é”çŠ¶æ€ä¿¡æ¯
     *
     * @param id ç½è½¦é”çŠ¶æ€ä¸»é”®
     * @return ç»“æžœ
     */
    public int deleteArdTankLockStateById(String id);
    public int insertOrUpdateArdTankLockState(ArdTankLockState ardTankLockState);
}
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockAutoProcessLogServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,92 @@
package com.ruoyi.sy.service.impl;
import java.util.List;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.sy.mapper.ArdTankLockAutoProcessLogMapper;
import com.ruoyi.sy.domain.ArdTankLockAutoProcessLog;
import com.ruoyi.sy.service.IArdTankLockAutoProcessLogService;
/**
 * ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—Service业务层处理
 *
 * @author ard
 * @date 2024-07-12
 */
@Service
public class ArdTankLockAutoProcessLogServiceImpl implements IArdTankLockAutoProcessLogService {
    @Autowired
    private ArdTankLockAutoProcessLogMapper ardTankLockAutoProcessLogMapper;
    /**
     * æŸ¥è¯¢ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     *
     * @param id ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—ä¸»é”®
     * @return ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     */
    @Override
    public ArdTankLockAutoProcessLog selectArdTankLockAutoProcessLogById(String id) {
        return ardTankLockAutoProcessLogMapper.selectArdTankLockAutoProcessLogById(id);
    }
    /**
     * æŸ¥è¯¢ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—åˆ—è¡¨
     *
     * @param ardTankLockAutoProcessLog ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     * @return ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     */
    @Override
    public List<ArdTankLockAutoProcessLog> selectArdTankLockAutoProcessLogList(ArdTankLockAutoProcessLog ardTankLockAutoProcessLog) {
        return ardTankLockAutoProcessLogMapper.selectArdTankLockAutoProcessLogList(ardTankLockAutoProcessLog);
    }
    /**
     * æ–°å¢žç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     *
     * @param ardTankLockAutoProcessLog ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     * @return ç»“æžœ
     */
    @Override
    public int insertArdTankLockAutoProcessLog(ArdTankLockAutoProcessLog ardTankLockAutoProcessLog) {
                ardTankLockAutoProcessLog.setId(IdUtils.simpleUUID());
            return ardTankLockAutoProcessLogMapper.insertArdTankLockAutoProcessLog(ardTankLockAutoProcessLog);
    }
    /**
     * ä¿®æ”¹ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     *
     * @param ardTankLockAutoProcessLog ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     * @return ç»“æžœ
     */
    @Override
    public int updateArdTankLockAutoProcessLog(ArdTankLockAutoProcessLog ardTankLockAutoProcessLog) {
        return ardTankLockAutoProcessLogMapper.updateArdTankLockAutoProcessLog(ardTankLockAutoProcessLog);
    }
    /**
     * æ‰¹é‡åˆ é™¤ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—
     *
     * @param ids éœ€è¦åˆ é™¤çš„罐车锁自动操控日志主键
     * @return ç»“æžœ
     */
    @Override
    public int deleteArdTankLockAutoProcessLogByIds(String[] ids) {
        return ardTankLockAutoProcessLogMapper.deleteArdTankLockAutoProcessLogByIds(ids);
    }
    /**
     * åˆ é™¤ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—ä¿¡æ¯
     *
     * @param id ç½è½¦é”è‡ªåŠ¨æ“æŽ§æ—¥å¿—ä¸»é”®
     * @return ç»“æžœ
     */
    @Override
    public int deleteArdTankLockAutoProcessLogById(String id) {
        return ardTankLockAutoProcessLogMapper.deleteArdTankLockAutoProcessLogById(id);
    }
}
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockProcessLogServiceImpl.java
@@ -1,9 +1,11 @@
package com.ruoyi.sy.service.impl;
import java.awt.geom.Point2D;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.domain.entity.SysConfig;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.sy.domain.ArdSyUser;
@@ -15,6 +17,9 @@
import com.ruoyi.system.mapper.SysConfigMapper;
import com.ruoyi.utils.forest.SYClient;
import com.ruoyi.utils.gps.GeoTools;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -200,10 +205,11 @@
                String paramsStr = lockNum + "02" + process + checkNum;
                paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + paramsStr + "%22%7D";
                Map<String,Object> result = sYClient.sendCmd(syURL, ardSyUser.getUserId(), carId, 199, "DataDownTransfer", paramsStr, sessionId);
                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 ardTankLockProcessLog = new ArdTankLockProcessLog();
                    ardTankLockProcessLog.setId(IdUtils.simpleUUID());
                    ardTankLockProcessLog.setLockId(lockId);
                    ardTankLockProcessLog.setLockNum(lockNum);
@@ -220,7 +226,7 @@
                    ardTankLockProcessLog.setLongitude(lng);
                    ardTankLockProcessLog.setLatitude(lat);
                    ardTankLockProcessLog.setProcessTime(this.sdf.format(new Date()));
                    ardTankLockProcessLogMapper.insertArdTankLockProcessLog(ardTankLockProcessLog);
                    ardTankLockProcessLogMapper.insertArdTankLockProcessLog(ardTankLockProcessLog);*/
                    return "发送成功";
                }else{
                    return "发送失败";
@@ -231,4 +237,32 @@
            }
        }
    }
    public Map<String,Object> sendCmd(String syURL,String userId,String carId,Integer cmdId,String cmd,String paramsStr,String sessionId){
        OkHttpClient okHttpClient = new OkHttpClient();
        Request request = new Request.Builder()
                .url(syURL + "/gps-web/api/send_cmd.jsp?params="+paramsStr+"&userId="+userId+"&carId="+carId+"&cmdId="+cmdId+"&cmd="+cmd+"&sessionId="+sessionId)
                .build();
        //System.out.println("url = " + syURL + "/gps-web/api/send_cmd.jsp?params="+paramsStr+"&userId="+userId+"&carId="+carId+"&cmdId="+cmdId+"&cmd="+cmd+"&sessionId="+sessionId);
        Response response = null;
        try {
            response = okHttpClient.newCall(request).execute();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        okhttp3.ResponseBody responseBody = response.body();
        try {
            String message = responseBody.string();// å“åº”体
            Map<String,Object> map = (Map<String, Object>) JSON.parse(message);
            return map;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return new HashMap();
        }
    }
}
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockServiceImpl.java
@@ -6,6 +6,7 @@
import com.ruoyi.common.core.domain.entity.SysConfig;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.sy.domain.ArdSyUser;
import com.ruoyi.sy.domain.ArdTankLockState;
import com.ruoyi.sy.mapper.ArdSyUserMapper;
import com.ruoyi.sy.mapper.ArdTankWallLockMapper;
import com.ruoyi.sy.mapper.ArdTankWallLockTemporaryMapper;
@@ -264,6 +265,23 @@
            }else{
                map.put("onlineTime",ardTankLock.getOnlineTime());
            }
            if(ardTankLock.getArdTankLockState() != null){//电磁锁状态
                map.put("ardTankLockState",ardTankLock.getArdTankLockState());
            }else{
                ArdTankLockState ardTankLockState = new ArdTankLockState();
                ardTankLockState.setId("");
                ardTankLockState.setLockId("");
                ardTankLockState.setLockNum("");
                ardTankLockState.setLockState("");
                ardTankLockState.setLockPositionState("");
                ardTankLockState.setLockShellState("");
                ardTankLockState.setRestartState("");
                ardTankLockState.setBatterVoltage("");
                ardTankLockState.setPowerVoltage("");
                ardTankLockState.setUploadTime("");
                ardTankLockState.setUniqueMark("");
                map.put("ardTankLockState",ardTankLockState);
            }
            Map<String,Object> carMap = ((List<Map<String,Object>>)syResult.get("list")).get(0);
            map.put("carPlate",carMap.get("carPlate"));
            result.add(map);
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockStateServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,100 @@
package com.ruoyi.sy.service.impl;
import java.util.List;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.sy.mapper.ArdTankLockStateMapper;
import com.ruoyi.sy.domain.ArdTankLockState;
import com.ruoyi.sy.service.IArdTankLockStateService;
import javax.annotation.Resource;
/**
 * ç½è½¦é”çŠ¶æ€Service业务层处理
 *
 * @author ard
 * @date 2024-07-18
 */
@Service
public class ArdTankLockStateServiceImpl implements IArdTankLockStateService {
    @Resource
    private ArdTankLockStateMapper ardTankLockStateMapper;
    /**
     * æŸ¥è¯¢ç½è½¦é”çŠ¶æ€
     *
     * @param id ç½è½¦é”çŠ¶æ€ä¸»é”®
     * @return ç½è½¦é”çŠ¶æ€
     */
    @Override
    public ArdTankLockState selectArdTankLockStateById(String id) {
        return ardTankLockStateMapper.selectArdTankLockStateById(id);
    }
    /**
     * æŸ¥è¯¢ç½è½¦é”çŠ¶æ€åˆ—è¡¨
     *
     * @param ardTankLockState ç½è½¦é”çŠ¶æ€
     * @return ç½è½¦é”çŠ¶æ€
     */
    @Override
    public List<ArdTankLockState> selectArdTankLockStateList(ArdTankLockState ardTankLockState) {
        return ardTankLockStateMapper.selectArdTankLockStateList(ardTankLockState);
    }
    /**
     * æ–°å¢žç½è½¦é”çŠ¶æ€
     *
     * @param ardTankLockState ç½è½¦é”çŠ¶æ€
     * @return ç»“æžœ
     */
    @Override
    public int insertArdTankLockState(ArdTankLockState ardTankLockState) {
                ardTankLockState.setId(IdUtils.simpleUUID());
            return ardTankLockStateMapper.insertArdTankLockState(ardTankLockState);
    }
    /**
     * ä¿®æ”¹ç½è½¦é”çŠ¶æ€
     *
     * @param ardTankLockState ç½è½¦é”çŠ¶æ€
     * @return ç»“æžœ
     */
    @Override
    public int updateArdTankLockState(ArdTankLockState ardTankLockState) {
        return ardTankLockStateMapper.updateArdTankLockState(ardTankLockState);
    }
    /**
     * æ‰¹é‡åˆ é™¤ç½è½¦é”çŠ¶æ€
     *
     * @param ids éœ€è¦åˆ é™¤çš„罐车锁状态主键
     * @return ç»“æžœ
     */
    @Override
    public int deleteArdTankLockStateByIds(String[] ids) {
        return ardTankLockStateMapper.deleteArdTankLockStateByIds(ids);
    }
    /**
     * åˆ é™¤ç½è½¦é”çŠ¶æ€ä¿¡æ¯
     *
     * @param id ç½è½¦é”çŠ¶æ€ä¸»é”®
     * @return ç»“æžœ
     */
    @Override
    public int deleteArdTankLockStateById(String id) {
        return ardTankLockStateMapper.deleteArdTankLockStateById(id);
    }
    @Override
    public int insertOrUpdateArdTankLockState(ArdTankLockState ardTankLockState) {
        int result = ardTankLockStateMapper.insertOrUpdateArdTankLockState(ardTankLockState);
        return result;
    }
}
ard-work/src/main/resources/mapper/sy/ArdTankLockAutoProcessLogMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.sy.mapper.ArdTankLockAutoProcessLogMapper">
    <resultMap type="ArdTankLockAutoProcessLog" id="ArdTankLockAutoProcessLogResult">
        <result property="id"    column="id"    />
        <result property="lockId"    column="lock_id"    />
        <result property="lockNum"    column="lock_num"    />
        <result property="carId"    column="car_id"    />
        <result property="carPlate"    column="car_plate"    />
        <result property="wallId"    column="wall_id"    />
        <result property="wallName"    column="wall_name"    />
        <result property="wallType"    column="wall_type"    />
        <result property="process"    column="process"    />
        <result property="processReason"    column="process_reason"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="velocity"    column="velocity"    />
        <result property="processTime"    column="process_time"    />
    </resultMap>
    <sql id="selectArdTankLockAutoProcessLogVo">
        select id, lock_id, lock_num, car_id, car_plate, wall_id, wall_name, wall_type, process, process_reason, longitude, latitude, velocity, process_time from ard_tank_lock_auto_process_log
    </sql>
    <select id="selectArdTankLockAutoProcessLogList" parameterType="ArdTankLockAutoProcessLog" resultMap="ArdTankLockAutoProcessLogResult">
        <include refid="selectArdTankLockAutoProcessLogVo"/>
        <where>
            <if test="lockId != null  and lockId != ''"> and lock_id = #{lockId}</if>
            <if test="lockNum != null  and lockNum != ''"> and lock_num = #{lockNum}</if>
            <if test="carId != null  and carId != ''"> and car_id = #{carId}</if>
            <if test="carPlate != null  and carPlate != ''"> and car_plate = #{carPlate}</if>
            <if test="wallId != null  and wallId != ''"> and wall_id = #{wallId}</if>
            <if test="wallName != null  and wallName != ''"> and wall_name like '%'||#{wallName}||'%'</if>
            <if test="wallType != null  and wallType != ''"> and wall_type = #{wallType}</if>
            <if test="process != null  and process != ''"> and process = #{process}</if>
            <if test="processReason != null  and processReason != ''"> and process_reason = #{processReason}</if>
            <if test="longitude != null  and longitude != ''"> and longitude = #{longitude}</if>
            <if test="latitude != null  and latitude != ''"> and latitude = #{latitude}</if>
            <if test="velocity != null  and velocity != ''"> and velocity = #{velocity}</if>
            <if test="processTime != null  and processTime != ''"> and process_time = #{processTime}</if>
        </where>
    </select>
    <select id="selectArdTankLockAutoProcessLogById" parameterType="String" resultMap="ArdTankLockAutoProcessLogResult">
        <include refid="selectArdTankLockAutoProcessLogVo"/>
        where id = #{id}
    </select>
    <insert id="insertArdTankLockAutoProcessLog" parameterType="ArdTankLockAutoProcessLog">
        insert into ard_tank_lock_auto_process_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="lockId != null">lock_id,</if>
            <if test="lockNum != null">lock_num,</if>
            <if test="carId != null">car_id,</if>
            <if test="carPlate != null">car_plate,</if>
            <if test="wallId != null">wall_id,</if>
            <if test="wallName != null">wall_name,</if>
            <if test="wallType != null">wall_type,</if>
            <if test="process != null">process,</if>
            <if test="processReason != null">process_reason,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="velocity != null">velocity,</if>
            <if test="processTime != null">process_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="lockId != null">#{lockId},</if>
            <if test="lockNum != null">#{lockNum},</if>
            <if test="carId != null">#{carId},</if>
            <if test="carPlate != null">#{carPlate},</if>
            <if test="wallId != null">#{wallId},</if>
            <if test="wallName != null">#{wallName},</if>
            <if test="wallType != null">#{wallType},</if>
            <if test="process != null">#{process},</if>
            <if test="processReason != null">#{processReason},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="velocity != null">#{velocity},</if>
            <if test="processTime != null">#{processTime},</if>
         </trim>
    </insert>
    <update id="updateArdTankLockAutoProcessLog" parameterType="ArdTankLockAutoProcessLog">
        update ard_tank_lock_auto_process_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="lockId != null">lock_id = #{lockId},</if>
            <if test="lockNum != null">lock_num = #{lockNum},</if>
            <if test="carId != null">car_id = #{carId},</if>
            <if test="carPlate != null">car_plate = #{carPlate},</if>
            <if test="wallId != null">wall_id = #{wallId},</if>
            <if test="wallName != null">wall_name = #{wallName},</if>
            <if test="wallType != null">wall_type = #{wallType},</if>
            <if test="process != null">process = #{process},</if>
            <if test="processReason != null">process_reason = #{processReason},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="velocity != null">velocity = #{velocity},</if>
            <if test="processTime != null">process_time = #{processTime},</if>
        </trim>
        where id = #{id}
    </update>
    <delete id="deleteArdTankLockAutoProcessLogById" parameterType="String">
        delete from ard_tank_lock_auto_process_log where id = #{id}
    </delete>
    <delete id="deleteArdTankLockAutoProcessLogByIds" parameterType="String">
        delete from ard_tank_lock_auto_process_log where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
ard-work/src/main/resources/mapper/sy/ArdTankLockMapper.xml
@@ -16,6 +16,32 @@
        <result property="onlineTime"    column="online_time"    />
    </resultMap>
    <resultMap type="ArdTankLock" id="ArdTankLockWithStateResult">
        <result property="id"    column="id"    />
        <result property="lockNum"    column="lock_num"    />
        <result property="lockName"    column="lock_name"    />
        <result property="imgPositionTop"    column="img_position_top"    />
        <result property="imgPositionLeft"    column="img_position_left"    />
        <result property="carId"    column="car_id"    />
        <result property="enable"    column="enable"    />
        <result property="restartState"    column="restart_state"    />
        <result property="onlineTime"    column="online_time"    />
        <association property="ardTankLockState" javaType="com.ruoyi.sy.domain.ArdTankLockState">
            <result property="id"    column="sid"    />
            <result property="lockId"    column="lock_id"    />
            <result property="lockNum"    column="slock_num"    />
            <result property="lockState"    column="lock_state"    />
            <result property="lockPositionState"    column="lock_position_state"    />
            <result property="lockShellState"    column="lock_shell_state"    />
            <result property="restartState"    column="srestart_state"    />
            <result property="batterVoltage"    column="batter_voltage"    />
            <result property="powerVoltage"    column="power_voltage"    />
            <result property="uploadTime"    column="upload_time"    />
            <result property="uniqueMark"    column="unique_mark"    />
            <result property="lockStateMark"    column="lock_state_mark"    />
        </association>
    </resultMap>
    <sql id="selectArdTankLockVo">
        select id, lock_num, lock_name, img_position_top, img_position_left, car_id, enable, restart_state, online_time from ard_tank_lock
    </sql>
@@ -108,8 +134,22 @@
        </foreach >
    </insert>
    <select id="getLockByCarId" resultMap="ArdTankLockResult" parameterType="java.lang.String">
        select * from ard_tank_lock atl where car_id = #{carId} order by atl.lock_num
    <select id="getLockByCarId" resultMap="ArdTankLockWithStateResult" parameterType="java.lang.String">
        select atl.id,atl.lock_num,atl.lock_name,atl.img_position_top,
        atl.img_position_left,atl.car_id,atl.enable,atl.restart_state,
        atl.online_time,atls.id as sid,atls.lock_id,atls.lock_num as slock_num,
        atls.lock_state,atls.lock_position_state,atls.lock_shell_state,
        atls.restart_state as srestart_state,atls.batter_voltage,
        atls.power_voltage,atls.upload_time,atls.unique_mark,
        case atls.lock_state
        when '关锁状态' then false
        when '异常状态' then false
        when '开锁状态' then true
        end as lock_state_mark
        from ard_tank_lock atl
        left join ard_tank_lock_state atls on atl."id" = atls.lock_id
        where car_id = #{carId} order by atls.upload_time desc,atl.lock_num
        limit 1
    </select>
    <delete id="deleteLockByCarId" parameterType="java.lang.String">
@@ -160,4 +200,8 @@
            #{carId}
        </foreach>
    </delete>
    <select id="getIdByLockNum" resultType="java.lang.String" parameterType="java.lang.String">
        select id from ard_tank_lock atl where atl.lock_num = #{lockNum}
    </select>
</mapper>
ard-work/src/main/resources/mapper/sy/ArdTankLockStateMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.sy.mapper.ArdTankLockStateMapper">
    <resultMap type="ArdTankLockState" id="ArdTankLockStateResult">
        <result property="id"    column="id"    />
        <result property="lockId"    column="lock_id"    />
        <result property="lockNum"    column="lock_num"    />
        <result property="lockState"    column="lock_state"    />
        <result property="lockPositionState"    column="lock_position_state"    />
        <result property="lockShellState"    column="lock_shell_state"    />
        <result property="restartState"    column="restart_state"    />
        <result property="batterVoltage"    column="batter_voltage"    />
        <result property="powerVoltage"    column="power_voltage"    />
        <result property="uploadTime"    column="upload_time"    />
        <result property="uniqueMark"    column="unique_mark"    />
    </resultMap>
    <sql id="selectArdTankLockStateVo">
        select id, lock_id, lock_num, lock_state, lock_position_state, lock_shell_state, restart_state, batter_voltage, power_voltage, upload_time, unique_mark from ard_tank_lock_state
    </sql>
    <select id="selectArdTankLockStateList" parameterType="ArdTankLockState" resultMap="ArdTankLockStateResult">
        <include refid="selectArdTankLockStateVo"/>
        <where>
            <if test="lockId != null  and lockId != ''"> and lock_id = #{lockId}</if>
            <if test="lockNum != null  and lockNum != ''"> and lock_num = #{lockNum}</if>
            <if test="lockState != null  and lockState != ''"> and lock_state = #{lockState}</if>
            <if test="lockPositionState != null  and lockPositionState != ''"> and lock_position_state = #{lockPositionState}</if>
            <if test="lockShellState != null  and lockShellState != ''"> and lock_shell_state = #{lockShellState}</if>
            <if test="restartState != null  and restartState != ''"> and restart_state = #{restartState}</if>
            <if test="batterVoltage != null  and batterVoltage != ''"> and batter_voltage = #{batterVoltage}</if>
            <if test="powerVoltage != null  and powerVoltage != ''"> and power_voltage = #{powerVoltage}</if>
            <if test="uploadTime != null  and uploadTime != ''"> and upload_time = #{uploadTime}</if>
            <if test="uniqueMark != null  and uniqueMark != ''"> and unique_mark = #{uniqueMark}</if>
        </where>
    </select>
    <select id="selectArdTankLockStateById" parameterType="String" resultMap="ArdTankLockStateResult">
        <include refid="selectArdTankLockStateVo"/>
        where id = #{id}
    </select>
    <insert id="insertArdTankLockState" parameterType="ArdTankLockState">
        insert into ard_tank_lock_state
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="lockId != null">lock_id,</if>
            <if test="lockNum != null">lock_num,</if>
            <if test="lockState != null">lock_state,</if>
            <if test="lockPositionState != null">lock_position_state,</if>
            <if test="lockShellState != null">lock_shell_state,</if>
            <if test="restartState != null">restart_state,</if>
            <if test="batterVoltage != null">batter_voltage,</if>
            <if test="powerVoltage != null">power_voltage,</if>
            <if test="uploadTime != null">upload_time,</if>
            <if test="uniqueMark != null">unique_mark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="lockId != null">#{lockId},</if>
            <if test="lockNum != null">#{lockNum},</if>
            <if test="lockState != null">#{lockState},</if>
            <if test="lockPositionState != null">#{lockPositionState},</if>
            <if test="lockShellState != null">#{lockShellState},</if>
            <if test="restartState != null">#{restartState},</if>
            <if test="batterVoltage != null">#{batterVoltage},</if>
            <if test="powerVoltage != null">#{powerVoltage},</if>
            <if test="uploadTime != null">#{uploadTime},</if>
            <if test="uniqueMark != null">#{uniqueMark},</if>
         </trim>
    </insert>
    <update id="updateArdTankLockState" parameterType="ArdTankLockState">
        update ard_tank_lock_state
        <trim prefix="SET" suffixOverrides=",">
            <if test="lockId != null">lock_id = #{lockId},</if>
            <if test="lockNum != null">lock_num = #{lockNum},</if>
            <if test="lockState != null">lock_state = #{lockState},</if>
            <if test="lockPositionState != null">lock_position_state = #{lockPositionState},</if>
            <if test="lockShellState != null">lock_shell_state = #{lockShellState},</if>
            <if test="restartState != null">restart_state = #{restartState},</if>
            <if test="batterVoltage != null">batter_voltage = #{batterVoltage},</if>
            <if test="powerVoltage != null">power_voltage = #{powerVoltage},</if>
            <if test="uploadTime != null">upload_time = #{uploadTime},</if>
            <if test="uniqueMark != null">unique_mark = #{uniqueMark},</if>
        </trim>
        where id = #{id}
    </update>
    <delete id="deleteArdTankLockStateById" parameterType="String">
        delete from ard_tank_lock_state where id = #{id}
    </delete>
    <delete id="deleteArdTankLockStateByIds" parameterType="String">
        delete from ard_tank_lock_state where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <insert id="insertOrUpdateArdTankLockState" parameterType="ArdTankLockState" >
        insert into ard_tank_lock_state (id, lock_id, lock_num, lock_state, lock_position_state, lock_shell_state,
                                         restart_state, batter_voltage, power_voltage, upload_time, unique_mark)
        values (#{id,jdbcType=VARCHAR},#{lockId,jdbcType=VARCHAR},#{lockNum,jdbcType=VARCHAR},#{lockState,jdbcType=VARCHAR},
                #{lockPositionState,jdbcType=VARCHAR},#{lockShellState,jdbcType=VARCHAR},#{restartState,jdbcType=VARCHAR},
                #{batterVoltage,jdbcType=VARCHAR},#{powerVoltage,jdbcType=VARCHAR},#{uploadTime,jdbcType=VARCHAR},
                #{uniqueMark,jdbcType=VARCHAR})
            on conflict(unique_mark) do update set upload_time=#{uploadTime,jdbcType=VARCHAR}
    </insert>
</mapper>