From 8d24f79c0e6dedee7a4beea9662207b5e30e1a73 Mon Sep 17 00:00:00 2001 From: hanrenchun Date: Mon, 9 Jun 2025 18:39:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessTripApprovalController.java | 140 +++++++++++++++--- .../domain/dto/ApprovaltBusinessDto.java | 19 +++ .../com/ruoyi/database/domain/gwglLog.java | 3 + 3 files changed, 139 insertions(+), 23 deletions(-) create mode 100644 gather-app/src/main/java/com/ruoyi/database/domain/dto/ApprovaltBusinessDto.java diff --git a/gather-app/src/main/java/com/ruoyi/business/controller/BusinessTripApprovalController.java b/gather-app/src/main/java/com/ruoyi/business/controller/BusinessTripApprovalController.java index f8d596f..b7281d7 100644 --- a/gather-app/src/main/java/com/ruoyi/business/controller/BusinessTripApprovalController.java +++ b/gather-app/src/main/java/com/ruoyi/business/controller/BusinessTripApprovalController.java @@ -13,6 +13,7 @@ import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.database.domain.ApprovalProcess; import com.ruoyi.database.domain.BaseAddressInfo; import com.ruoyi.database.domain.BusinessTripApproval; +import com.ruoyi.database.domain.dto.ApprovaltBusinessDto; import com.ruoyi.database.domain.dto.ApprovaltDto; import com.ruoyi.database.domain.gwglLog; import com.ruoyi.database.service.ApprovalProcessService; @@ -143,7 +144,7 @@ public class BusinessTripApprovalController extends BaseController { approvalProcess.setApprovalStatus(1); longs.add(user.getDept().getLeaderId()); } - addLog(approvalProcess,longs); + addLog(approvalProcess, longs); return toAjax(businessTripApprovalService.save(dto) && approvalsProcessService.save(approvalProcess) ); @@ -242,30 +243,116 @@ public class BusinessTripApprovalController extends BaseController { @ApiOperation("审批出差申请") @PostMapping("/approval") - public AjaxResult approval(ApprovaltDto dto) { + public AjaxResult approval(ApprovaltBusinessDto dto) { SysUser user = getLoginUser().getUser(); - Long id = dto.getId(); - Integer state = dto.getState(); - BusinessTripApproval businessTripApproval = businessTripApprovalService.getById(id); - businessTripApproval.setState(state); - boolean result = businessTripApprovalService.updateById(businessTripApproval); - gwglLog gwglLog = new gwglLog(); - gwglLog.setApplyNo(businessTripApproval.getApplyNo()); - gwglLog.setDeptName(businessTripApproval.getDepartment()); - gwglLog.setUserId(businessTripApproval.getUserId()); - gwglLog.setUserName(businessTripApproval.getUserName()); -// gwglLog.setCreateTime(businessTripApproval.getCreateTime()); - gwglLog.setReason(businessTripApproval.getReason()); - gwglLog.setType(1); - gwglLog.setApplyNo(businessTripApproval.getApplyNo()); - gwglLog.setChecker(user.getNickName()); - gwglLog.setCheckTime(System.currentTimeMillis()); - gwglLog.setCheckState(state); - boolean result1 = gwglLogService.save(gwglLog); - if (!result || !result1) { - return AjaxResult.error("审批出差申请失败"); + String uuid = dto.getUuid(); + if (uuid == null) { + throw new RuntimeException("uuid不可为空"); + } + if (dto.getState() == null) { + throw new RuntimeException("请选择通过或者驳回"); + } + gwglLog one = gwglLogService.lambdaQuery() + .eq(gwglLog::getUuid, uuid) + .orderByDesc(gwglLog::getCreateTime) + .last("LIMIT 1") + .one(); + Integer checkState = one.getCheckState(); + if (checkState != 0) { + throw new RuntimeException("记录已被处理"); + } + String checkUserId = one.getCheckUserId(); + List longs = new ArrayList<>(); + if (checkUserId != null) { + if (checkUserId.contains(",")) { + String[] split = checkUserId.split(","); + for (String s : split) { + longs.add(Long.parseLong(s)); + } + } else { + longs.add(Long.parseLong(checkUserId)); + } + } + if (longs.isEmpty() || !longs.contains(user.getUserId())) { + throw new RuntimeException("当前用户无法操作"); + } + ApprovalProcess approvalProcess = approvalsProcessService.lambdaQuery() + .eq(ApprovalProcess::getUuid, uuid) + .last("LIMIT 1") + .one(); + BusinessTripApproval businessTripApproval = businessTripApprovalService.lambdaQuery() + .eq(BusinessTripApproval::getUuid,uuid) + .last("LIMIT 1") + .one(); + Integer approvalStatus = approvalProcess.getApprovalStatus(); + + if (dto.getState() == 1) { + if (approvalStatus == 1) { + List userIds = new ArrayList<>(); + if (businessTripApproval.getHasOffcialCar() == 1) { + approvalProcess.setApprovalStatus(100); + userIds.add(2165L); + } else { + approvalProcess.setApprovalStatus(400); + userIds.add(1660L); + userIds.add(1661L); + } + addLog(approvalProcess, userIds); + } + if (approvalStatus == 100) { + if (dto.getDriverName() == null) { + throw new RuntimeException("驾驶员姓名不可为空"); + } + if (dto.getPlateNo() == null) { + throw new RuntimeException("车牌号不可为空"); + } + approvalProcess.setApprovalStatus(200); + List userIds = new ArrayList<>(); + userIds.add(2157L); + addLog(approvalProcess, userIds); + } + if (approvalStatus == 200) { + if (dto.getLeaderId() == null) { + throw new RuntimeException("请选择分管局领导"); + } + approvalProcess.setApprovalStatus(300); + List userIds = new ArrayList<>(); + userIds.add(dto.getLeaderId()); + addLog(approvalProcess, userIds); + } + if (approvalStatus == 300) { + approvalProcess.setApprovalStatus(400); + List userIds = new ArrayList<>(); + userIds.add(1660L); + userIds.add(1661L); + addLog(approvalProcess, userIds); + } + if (approvalStatus == 400) { + approvalProcess.setApprovalStatus(500); + } + one.setCheckState(dto.getState()); + one.setCheckTime(System.currentTimeMillis() / 1000L); + one.setReason(dto.getReason()); + boolean updateById = gwglLogService.updateById(one); + boolean updateById1 = approvalsProcessService.updateById(approvalProcess); + return toAjax(updateById1 && updateById); + } else if (dto.getState() == 2) { + if (dto.getReason() == null) { + throw new RuntimeException("驳回意见不可为空"); + } + approvalProcess.setApprovalStatus(0); + one.setCheckState(dto.getState()); + one.setCheckTime(System.currentTimeMillis() / 1000L); + one.setReason(dto.getReason()); + List userIds = new ArrayList<>(); + userIds.add(approvalProcess.getSubmitterId()); + addLog(approvalProcess, userIds); + boolean updateById = gwglLogService.updateById(one); + boolean updateById1 = approvalsProcessService.updateById(approvalProcess); + return toAjax(updateById1 && updateById); + } else { + throw new RuntimeException("处理结果参数不正确"); } - return AjaxResult.success("审批出差申请成功"); } @@ -276,15 +363,22 @@ public class BusinessTripApprovalController extends BaseController { gwglLog.setCheckState(0); gwglLog.setUuid(approvalProcess.getUuid()); gwglLog.setApprovalStatus(approvalProcess.getApprovalStatus()); + gwglLog.setCreateTime(System.currentTimeMillis() / 1000L); SysUser user = new SysUser(); StringBuilder name = new StringBuilder(); + StringBuilder ids = new StringBuilder(); for (Long userId : userIds) { SysUser user1 = sysUserService.selectUserById(userId); if (name.length() > 0) { name.append(","); } name.append(user1.getNickName()); + if (ids.length() > 0) { + ids.append(","); + } + ids.append(user1.getUserId()); } + gwglLog.setCheckUserId(ids.toString()); gwglLog.setChecker(name.toString()); if (user.getDept() != null) { gwglLog.setCheckDeptName(user.getDept().getDeptName()); diff --git a/gather-app/src/main/java/com/ruoyi/database/domain/dto/ApprovaltBusinessDto.java b/gather-app/src/main/java/com/ruoyi/database/domain/dto/ApprovaltBusinessDto.java new file mode 100644 index 0000000..5eba50b --- /dev/null +++ b/gather-app/src/main/java/com/ruoyi/database/domain/dto/ApprovaltBusinessDto.java @@ -0,0 +1,19 @@ +package com.ruoyi.database.domain.dto; + +import lombok.Data; + +@Data +public class ApprovaltBusinessDto { + + private String uuid; + + private Integer state; + + private String reason; + + private String driverName; + + private String plateNo; + + private Long leaderId; +} diff --git a/gather-app/src/main/java/com/ruoyi/database/domain/gwglLog.java b/gather-app/src/main/java/com/ruoyi/database/domain/gwglLog.java index 3034196..9d1586c 100644 --- a/gather-app/src/main/java/com/ruoyi/database/domain/gwglLog.java +++ b/gather-app/src/main/java/com/ruoyi/database/domain/gwglLog.java @@ -72,6 +72,9 @@ public class gwglLog { @ApiModelProperty("审核人部门id") private Long checkDeptId; + @ApiModelProperty("审核人id") + private String checkUserId; + @ApiModelProperty("审批状态") private Integer approvalStatus; From 61f768d8a985700785f1a780742ca64225e41210 Mon Sep 17 00:00:00 2001 From: hanrenchun Date: Mon, 9 Jun 2025 18:39:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/controller/BusinessTripApprovalController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gather-app/src/main/java/com/ruoyi/business/controller/BusinessTripApprovalController.java b/gather-app/src/main/java/com/ruoyi/business/controller/BusinessTripApprovalController.java index b7281d7..4929a35 100644 --- a/gather-app/src/main/java/com/ruoyi/business/controller/BusinessTripApprovalController.java +++ b/gather-app/src/main/java/com/ruoyi/business/controller/BusinessTripApprovalController.java @@ -243,7 +243,7 @@ public class BusinessTripApprovalController extends BaseController { @ApiOperation("审批出差申请") @PostMapping("/approval") - public AjaxResult approval(ApprovaltBusinessDto dto) { + public AjaxResult approval(@RequestBody ApprovaltBusinessDto dto) { SysUser user = getLoginUser().getUser(); String uuid = dto.getUuid(); if (uuid == null) {