fix(violation):修复违章记录添加逻辑和查询重复问题- 调整HjmViolationController中车辆编号校验逻辑的位置

- 在HjmViolationMapper.xml的关联查询中添加DISTINCT关键字去重
- 确保违章记录保存前进行车辆存在性验证
- 优化返回结果处理逻辑避免重复数据产生
This commit is contained in:
2025-10-30 11:42:39 +08:00
parent 8132aa3ab1
commit 3bb1e8f6ce
2 changed files with 9 additions and 9 deletions

View File

@@ -70,14 +70,14 @@ public class HjmViolationController extends BaseController {
User loginUser = getLoginUser(); User loginUser = getLoginUser();
if (loginUser != null) { if (loginUser != null) {
hjmViolation.setUserId(loginUser.getUserId()); hjmViolation.setUserId(loginUser.getUserId());
} final HjmCar car = hjmCarService.getByCode(hjmViolation.getCode());
final HjmCar car = hjmCarService.getByCode(hjmViolation.getCode()); if (ObjUtil.isEmpty(car)) {
if (ObjUtil.isEmpty(car)) { return fail("车辆编号不存在");
return fail("车辆编号不存在"); }
} if (hjmViolationService.save(hjmViolation)) {
if (hjmViolationService.save(hjmViolation)) { hjmViolationService.send(hjmViolation);
hjmViolationService.send(hjmViolation); return success("添加成功");
return success("添加成功"); }
} }
return fail("添加失败"); return fail("添加失败");
} }

View File

@@ -4,7 +4,7 @@
<!-- 关联查询sql --> <!-- 关联查询sql -->
<sql id="selectSql"> <sql id="selectSql">
SELECT a.*,b.image SELECT DISTINCT a.*,b.image
FROM hjm_violation a FROM hjm_violation a
LEFT JOIN hjm_car b ON a.code = b.code LEFT JOIN hjm_car b ON a.code = b.code
LEFT JOIN gxwebsoft_core.sys_organization c ON b.organization_id = c.organization_id LEFT JOIN gxwebsoft_core.sys_organization c ON b.organization_id = c.organization_id