From 08ddfad4530a014094c06fe68b8c2d9a0753403a Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Wed, 05 Aug 2026 14:09:29 +0800
Subject: [PATCH] fix(gd): 修复线索事件查询中的SQL语法错误
---
drone-service/drone-gd/src/main/java/org/sxkj/gd/orderdata/service/impl/GdSupplyDemandServiceImpl.java | 70 ++++++++++++++++------------------
1 files changed, 33 insertions(+), 37 deletions(-)
diff --git a/drone-service/drone-gd/src/main/java/org/sxkj/gd/orderdata/service/impl/GdSupplyDemandServiceImpl.java b/drone-service/drone-gd/src/main/java/org/sxkj/gd/orderdata/service/impl/GdSupplyDemandServiceImpl.java
index 6d0635b..3f64131 100644
--- a/drone-service/drone-gd/src/main/java/org/sxkj/gd/orderdata/service/impl/GdSupplyDemandServiceImpl.java
+++ b/drone-service/drone-gd/src/main/java/org/sxkj/gd/orderdata/service/impl/GdSupplyDemandServiceImpl.java
@@ -22,6 +22,7 @@
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
@@ -41,6 +42,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
/**
* 供需需求信息表 服务实现类
@@ -59,7 +61,7 @@
private static final String STATUS_APPLY = "1";
private static final String STATUS_APPROVED = "2";
private static final String STATUS_REJECTED = "3";
-
+
/**
* 审核状态常量:0-待审核、1-审核通过、2-审核拒绝
*/
@@ -72,7 +74,12 @@
@Override
public IPage<GdSupplyDemandVO> selectGdSupplyDemandPage(IPage<GdSupplyDemandVO> page, GdSupplyDemandPageParam gdSupplyDemand) {
- return page.setRecords(baseMapper.selectGdSupplyDemandPage(page, gdSupplyDemand, buildDeptIdList()));
+ List<Long> deptList = new ArrayList<>();
+ if (!AuthUtil.isAdministrator()) {
+ deptList = SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId()));
+ }
+ gdSupplyDemand.setDeptList(deptList);
+ return page.setRecords(baseMapper.selectGdSupplyDemandPage(page, gdSupplyDemand));
}
@Override
@@ -85,7 +92,11 @@
if (Func.isEmpty(gdSupplyDemand)) {
throw new ServiceException("需求参数不能为空");
}
- GdSupplyDemandEntity detail = baseMapper.selectGdSupplyDemandDetail(gdSupplyDemand, buildDeptIdList());
+ List<Long> deptList = new ArrayList<>();
+ if (!AuthUtil.isAdministrator()) {
+ deptList = SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId()));
+ }
+ GdSupplyDemandEntity detail = baseMapper.selectGdSupplyDemandDetail(gdSupplyDemand, deptList);
if (detail == null) {
throw new ServiceException("未查询到数据");
}
@@ -94,47 +105,48 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public boolean submitSupplyDemand(GdSupplyDemandEntity gdSupplyDemand) {
+ public boolean submitSupplyDemand(GdSupplyDemandDTO gdSupplyDemand) {
if (Func.isEmpty(gdSupplyDemand)) {
throw new ServiceException("需求参数不能为空");
}
-
+ GdSupplyDemandEntity supplyDemand = Objects.requireNonNull(BeanUtil.copy(gdSupplyDemand, GdSupplyDemandEntity.class));
+
// 获取前端传入的需求状态
- String demandStatus = gdSupplyDemand.getDemandStatus();
+ String demandStatus = supplyDemand.getDemandStatus();
if (StringUtil.isBlank(demandStatus)) {
throw new ServiceException("需求状态不能为空");
}
-
+
// 校验状态值有效性
if (!STATUS_DRAFT.equals(demandStatus) && !STATUS_APPLY.equals(demandStatus)) {
throw new ServiceException("需求状态值无效,仅支持 0(草稿) 或 1(申请中)");
}
-
- boolean isInsert = Func.isEmpty(gdSupplyDemand.getId());
+
+ boolean isInsert = Func.isEmpty(supplyDemand.getId());
Long userId = AuthUtil.getUserId();
Long deptId = Long.valueOf(AuthUtil.getDeptId());
- gdSupplyDemand.setUpdateUser(userId);
-
+ supplyDemand.setUpdateUser(userId);
+
boolean saved;
if (isInsert) {
- gdSupplyDemand.setCreateUser(userId);
- gdSupplyDemand.setCreateDept(deptId);
- saved = baseMapper.insertGdSupplyDemand(gdSupplyDemand) > 0;
+ supplyDemand.setCreateUser(userId);
+ supplyDemand.setCreateDept(deptId);
+ saved = baseMapper.insertGdSupplyDemand(supplyDemand) > 0;
} else {
- saved = baseMapper.updateGdSupplyDemand(gdSupplyDemand) > 0;
+ saved = baseMapper.updateGdSupplyDemand(supplyDemand) > 0;
}
-
+
if (!saved) {
return false;
}
-
+
// 仅当状态为"申请中"(1)时才创建审核记录
if (STATUS_APPLY.equals(demandStatus)) {
- GdSupplyDemandEntity supplyDemand = loadSupplyDemandForAudit(gdSupplyDemand.getId());
- GdSupplyDemandAuditEntity auditEntity = buildAuditEntity(supplyDemand, AUDIT_PENDING, null);
+ GdSupplyDemandEntity auditDemand = loadSupplyDemandForAudit(supplyDemand.getId());
+ GdSupplyDemandAuditEntity auditEntity = buildAuditEntity(auditDemand, AUDIT_PENDING, null);
return gdSupplyDemandAuditService.saveSupplyDemandAudit(auditEntity);
}
-
+
// 状态为"草稿"(0)时直接返回成功
return true;
}
@@ -222,27 +234,11 @@
}
GdSupplyDemandDTO query = new GdSupplyDemandDTO();
query.setId(demandId);
- GdSupplyDemandEntity detail = baseMapper.selectGdSupplyDemandDetail(query, buildDeptIdList());
+ GdSupplyDemandEntity detail = baseMapper.selectGdSupplyDemandDetail(query, SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId())));
if (detail == null) {
throw new ServiceException("需求数据不存在");
}
return detail;
- }
-
- private List<Long> buildDeptIdList() {
- if (AuthUtil.isAdministrator()) {
- return null;
- }
- Long deptId = Long.valueOf(AuthUtil.getDeptId());
- List<Long> deptIdList = SysCache.getDeptChildIds(deptId);
- List<Long> result = new ArrayList<>();
- if (Func.isNotEmpty(deptIdList)) {
- result.addAll(deptIdList);
- }
- if (!result.contains(deptId)) {
- result.add(deptId);
- }
- return result;
}
@Override
--
Gitblit v1.9.3