From 51a551a7f8eae7654f973d45cd2fa2952774673d Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Fri, 07 Aug 2026 10:56:55 +0800
Subject: [PATCH] perf(task): 优化巡查任务审核性能并添加详细日志记录
---
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwPoliceStationServiceImpl.java | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwPoliceStationServiceImpl.java b/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwPoliceStationServiceImpl.java
index f2abfe6..513e044 100644
--- a/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwPoliceStationServiceImpl.java
+++ b/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/service/impl/FwPoliceStationServiceImpl.java
@@ -17,6 +17,7 @@
package org.sxkj.fw.area.service.impl;
import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.StringUtil;
import org.sxkj.common.utils.HeaderUtils;
import org.sxkj.fw.area.entity.FwPoliceStationEntity;
@@ -26,6 +27,7 @@
import org.sxkj.fw.area.mapper.FwPoliceStationMapper;
import org.sxkj.fw.area.service.IFwPoliceStationService;
import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
@@ -71,18 +73,24 @@
@Override
public boolean save(FwPoliceStationEntity fwPoliceStation) {
+ // 校验派出所名称唯一性
+ checkStationNameUnique(fwPoliceStation.getStationName(), null);
fillCreateFields(fwPoliceStation);
return super.save(fwPoliceStation);
}
@Override
public boolean updateById(FwPoliceStationEntity fwPoliceStation) {
+ // 校验派出所名称唯一性(排除当前记录)
+ checkStationNameUnique(fwPoliceStation.getStationName(), fwPoliceStation.getId());
fillUpdateFields(fwPoliceStation);
return super.updateById(fwPoliceStation);
}
@Override
public boolean saveOrUpdate(FwPoliceStationEntity fwPoliceStation) {
+ // 校验派出所名称唯一性
+ checkStationNameUnique(fwPoliceStation.getStationName(), fwPoliceStation.getId());
if (fwPoliceStation.getId() == null) {
fillCreateFields(fwPoliceStation);
} else {
@@ -91,6 +99,29 @@
return super.saveOrUpdate(fwPoliceStation);
}
+ /**
+ * 校验派出所名称唯一性
+ *
+ * @param stationName 派出所名称
+ * @param excludeId 排除的ID(更新时使用,排除当前记录)
+ * @throws RuntimeException 当名称已存在时抛出异常
+ */
+ private void checkStationNameUnique(String stationName, Long excludeId) {
+ if (StringUtil.isBlank(stationName)) {
+ return;
+ }
+ LambdaQueryWrapper<FwPoliceStationEntity> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.eq(FwPoliceStationEntity::getStationName, stationName);
+ queryWrapper.eq(FwPoliceStationEntity::getIsDeleted, BladeConstant.DB_NOT_DELETED);
+ if (excludeId != null) {
+ queryWrapper.ne(FwPoliceStationEntity::getId, excludeId);
+ }
+ long count = count(queryWrapper);
+ if (count > 0) {
+ throw new RuntimeException("派出所名称 '" + stationName + "' 已存在");
+ }
+ }
+
private void fillCreateFields(FwPoliceStationEntity fwPoliceStation) {
// 创建/更新基础审计字段统一设置
Long userId = AuthUtil.getUserId();
--
Gitblit v1.9.3