fix: 优化批量提交逻辑

This commit is contained in:
tangwei 2026-05-06 16:45:49 +08:00
parent 232ae480b2
commit 0dc94cea5a
5 changed files with 28 additions and 13 deletions

View File

@ -202,7 +202,7 @@ public class FishDraftDataController {
} }
@PostMapping("/submitDraftsAll") @PostMapping("/submitDraftsAll")
@Operation(summary = "批量提交草稿") @Operation(summary = "批量提交当前用户全部草稿")
public ResponseResult submitDraftsAll() { public ResponseResult submitDraftsAll() {
List<FishDraftData> draft = fishDraftDataService.list(new LambdaQueryWrapper<FishDraftData>().eq(FishDraftData::getCreatedBy, SecurityUtils.getUserId()).eq(FishDraftData::getStatus, "DRAFT").select(FishDraftData::getId)); List<FishDraftData> draft = fishDraftDataService.list(new LambdaQueryWrapper<FishDraftData>().eq(FishDraftData::getCreatedBy, SecurityUtils.getUserId()).eq(FishDraftData::getStatus, "DRAFT").select(FishDraftData::getId));
List<String> ids = draft.stream().map(FishDraftData::getId).toList(); List<String> ids = draft.stream().map(FishDraftData::getId).toList();
@ -217,10 +217,22 @@ public class FishDraftDataController {
return result ? ResponseResult.success("审批通过") : ResponseResult.error("审批失败"); return result ? ResponseResult.success("审批通过") : ResponseResult.error("审批失败");
} }
@PostMapping("/batchApproveAll") // @PostMapping("/batchApproveAll")
@Operation(summary = "批量全部审批通过") // @Operation(summary = "批量全部审批通过")
public ResponseResult batchApproveAll(@RequestBody BatchApproveRequest request) { // public ResponseResult batchApproveAll(@RequestBody BatchApproveRequest request) {
List<FishDraftData> draft = fishDraftDataService.list(new LambdaQueryWrapper<FishDraftData>().eq(FishDraftData::getCreatedBy, SecurityUtils.getUserId()).eq(FishDraftData::getStatus, "PENDING").select(FishDraftData::getId)); // List<FishDraftData> draft = fishDraftDataService.list(new LambdaQueryWrapper<FishDraftData>().eq(FishDraftData::getCreatedBy, SecurityUtils.getUserId()).eq(FishDraftData::getStatus, "PENDING").select(FishDraftData::getId));
// List<String> ids = draft.stream().map(FishDraftData::getId).toList();
// boolean result = fishDraftDataService.batchApprove(ids, request.getApproveComment());
// return result ? ResponseResult.success("审批通过") : ResponseResult.error("审批失败");
// }
@PostMapping("/batchApproveByApprovalId")
@Operation(summary = "根据审批批次全部审批通过")
public ResponseResult batchApproveByApprovalId(@RequestBody BatchApproveRequest request) {
if (request.getApprovalIds().isEmpty()) {
return ResponseResult.error("请选择审批批次");
}
List<FishDraftData> draft = fishDraftDataService.list(new LambdaQueryWrapper<FishDraftData>().in(FishDraftData::getApprovalId, request.getApprovalIds()).eq(FishDraftData::getStatus, "PENDING").select(FishDraftData::getId));
List<String> ids = draft.stream().map(FishDraftData::getId).toList(); List<String> ids = draft.stream().map(FishDraftData::getId).toList();
boolean result = fishDraftDataService.batchApprove(ids, request.getApproveComment()); boolean result = fishDraftDataService.batchApprove(ids, request.getApproveComment());
return result ? ResponseResult.success("审批通过") : ResponseResult.error("审批失败"); return result ? ResponseResult.success("审批通过") : ResponseResult.error("审批失败");

View File

@ -15,6 +15,9 @@ public class BatchApproveRequest {
@Schema(description = "草稿数据ID列表") @Schema(description = "草稿数据ID列表")
private List<String> ids; private List<String> ids;
@Schema(description = "批次ID列表")
List<String> approvalIds;
@Schema(description = "审批意见") @Schema(description = "审批意见")
private String approveComment; private String approveComment;
} }

View File

@ -42,5 +42,5 @@ public interface SysUserDataScopeMapper extends BaseMapper<SysUserDataScope> {
/** /**
* 查询有效权限状态=1且在有效期内的 * 查询有效权限状态=1且在有效期内的
*/ */
List<SysUserDataScope> selectValidPermissions(@Param("userId") Long userId); List<SysUserDataScope> selectValidPermissions(@Param("userId") String userId);
} }

View File

@ -82,14 +82,14 @@ public class FishDraftDataServiceImpl extends ServiceImpl<FishDraftDataMapper, F
String ftp = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "ftp"); String ftp = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "ftp");
String direction = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "direction"); String direction = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "direction");
String status = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "status"); String status = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "status");
String TM = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "TM"); String STRDT = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "strdt");
String startTime=null; String startTime=null;
String endTime=null; String endTime=null;
String userId = (SecurityUtils.hasPermission("sjtb:edit-review") || "admin".equals(SecurityUtils.getCurrentUsername())) ?null:SecurityUtils.getUserId(); String userId = (SecurityUtils.hasPermission("sjtb:edit-review") || "admin".equals(SecurityUtils.getCurrentUsername())) ?null:SecurityUtils.getUserId();
// 如果 startTime endTime 为空尝试从 TM 字段解析 // 如果 startTime endTime 为空尝试从 TM 字段解析
if (StrUtil.isNotBlank(TM)&& TM.split( ",").length==2) { if (StrUtil.isNotBlank(STRDT)&& STRDT.split( ",").length==2) {
startTime=TM.split(",")[0]; startTime=STRDT.split(",")[0];
endTime=TM.split(",")[1]; endTime=STRDT.split(",")[1];
} }
Page<FishDraftDataVO> resultPage = fishDraftDataMapper.selectJoinPage(page, stcd, rstcd, baseId, direction, status, ftp, startTime, endTime,userId,hbrvcd,approvalId); Page<FishDraftDataVO> resultPage = fishDraftDataMapper.selectJoinPage(page, stcd, rstcd, baseId, direction, status, ftp, startTime, endTime,userId,hbrvcd,approvalId);
fillUserNames(resultPage.getRecords()); fillUserNames(resultPage.getRecords());
@ -306,7 +306,7 @@ public class FishDraftDataServiceImpl extends ServiceImpl<FishDraftDataMapper, F
return; return;
} }
List<SysUserDataScope> permissions = userDataScopeMapper.selectValidPermissions(Long.parseLong(userId)); List<SysUserDataScope> permissions = userDataScopeMapper.selectValidPermissions(userId);
if (permissions == null || permissions.isEmpty()) { if (permissions == null || permissions.isEmpty()) {
return; return;
} }

View File

@ -164,10 +164,10 @@
AND D.APPROVAL_ID = #{approvalId} AND D.APPROVAL_ID = #{approvalId}
</if> </if>
<if test="startTime != null and startTime != ''"> <if test="startTime != null and startTime != ''">
AND D.TM &gt;= TO_DATE(#{startTime}, 'yyyy-mm-dd hh24:mi:ss') AND D.STRDT &gt;= TO_DATE(#{startTime}, 'yyyy-mm-dd hh24:mi:ss')
</if> </if>
<if test="endTime != null and endTime != ''"> <if test="endTime != null and endTime != ''">
AND D.TM &lt;= TO_DATE(#{endTime}, 'yyyy-mm-dd hh24:mi:ss') AND D.STRDT &lt;= TO_DATE(#{endTime}, 'yyyy-mm-dd hh24:mi:ss')
</if> </if>
ORDER BY D.CREATED_AT DESC ORDER BY D.CREATED_AT DESC
</select> </select>