主键自增

This commit is contained in:
zc
2026-04-30 15:40:37 +08:00
parent 90003d79c5
commit 4c41f6f77e

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
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 {
String sn = topicVars.get("sn");
log.info("接收到车辆识别消息 -> Topic: {}", topic);
CarParkItem carParkItem = carParkItemService.selectBySn(sn);
String data = new String(message, StandardCharsets.UTF_8);
JSONObject jsonObject = JSONObject.parseObject(data);
JSONObject payload = jsonObject.getJSONObject("payload");
@@ -163,14 +166,15 @@ public class CarMessageListener {
}
record.setSn(sn);
record.setUniqueNo(id);
record.setParkId(carParkItem.getParkId());
record.setTriggerType(plateResult.getString("triggerType"));
record.setType(carBrand.getString("type"));
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.setLicense(license);
carPassGather.setParkId(carParkItem.getParkId());
@@ -178,7 +182,7 @@ public class CarMessageListener {
carPassGather.setJoinTime(record.getPassTime());
carPassGather.setSn(sn);
carPassGatherService.save(carPassGather);
} else {//出场删除数据
} else if (StrUtil.equals(carParkItem.getWay(), "1") && isExist) {//出场删除数据
carPassGatherService.deleteByLicense(license);
}
}