主键自增
This commit is contained in:
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dromara.mica.mqtt.core.annotation.MqttServerFunction;
|
import org.dromara.mica.mqtt.core.annotation.MqttServerFunction;
|
||||||
@@ -116,6 +117,8 @@ public class CarMessageListener {
|
|||||||
public void ivs_result(String topic, Map<String, String> topicVars, byte[] message) throws Exception {
|
public void ivs_result(String topic, Map<String, String> topicVars, byte[] message) throws Exception {
|
||||||
String sn = topicVars.get("sn");
|
String sn = topicVars.get("sn");
|
||||||
log.info("接收到车辆识别消息 -> Topic: {}", topic);
|
log.info("接收到车辆识别消息 -> Topic: {}", topic);
|
||||||
|
CarParkItem carParkItem = carParkItemService.selectBySn(sn);
|
||||||
|
|
||||||
String data = new String(message, StandardCharsets.UTF_8);
|
String data = new String(message, StandardCharsets.UTF_8);
|
||||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
JSONObject payload = jsonObject.getJSONObject("payload");
|
JSONObject payload = jsonObject.getJSONObject("payload");
|
||||||
@@ -163,14 +166,15 @@ public class CarMessageListener {
|
|||||||
}
|
}
|
||||||
record.setSn(sn);
|
record.setSn(sn);
|
||||||
record.setUniqueNo(id);
|
record.setUniqueNo(id);
|
||||||
|
record.setParkId(carParkItem.getParkId());
|
||||||
record.setTriggerType(plateResult.getString("triggerType"));
|
record.setTriggerType(plateResult.getString("triggerType"));
|
||||||
record.setType(carBrand.getString("type"));
|
record.setType(carBrand.getString("type"));
|
||||||
carPassRecordService.save(record);
|
carPassRecordService.save(record);
|
||||||
|
|
||||||
//保存/删除在场数据
|
//保存/删除在场数据
|
||||||
CarParkItem carParkItem = carParkItemService.selectBySn(sn);
|
boolean isExist = carPassGatherService.exists(new QueryWrapper<CarPassGather>().eq("license", license));
|
||||||
//入场新增数据
|
//入场新增数据
|
||||||
if (StrUtil.equals(carParkItem.getWay(), "0")) {
|
if (StrUtil.equals(carParkItem.getWay(), "0") && !isExist) {
|
||||||
CarPassGather carPassGather = new CarPassGather();
|
CarPassGather carPassGather = new CarPassGather();
|
||||||
carPassGather.setLicense(license);
|
carPassGather.setLicense(license);
|
||||||
carPassGather.setParkId(carParkItem.getParkId());
|
carPassGather.setParkId(carParkItem.getParkId());
|
||||||
@@ -178,7 +182,7 @@ public class CarMessageListener {
|
|||||||
carPassGather.setJoinTime(record.getPassTime());
|
carPassGather.setJoinTime(record.getPassTime());
|
||||||
carPassGather.setSn(sn);
|
carPassGather.setSn(sn);
|
||||||
carPassGatherService.save(carPassGather);
|
carPassGatherService.save(carPassGather);
|
||||||
} else {//出场删除数据
|
} else if (StrUtil.equals(carParkItem.getWay(), "1") && isExist) {//出场删除数据
|
||||||
carPassGatherService.deleteByLicense(license);
|
carPassGatherService.deleteByLicense(license);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user