Merge remote-tracking branch 'origin/master'

This commit is contained in:
李京通 2025-06-09 18:57:13 +08:00
commit 763c3a5203
3 changed files with 139 additions and 23 deletions

View File

@ -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(@RequestBody 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<Long> 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<Long> 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<Long> userIds = new ArrayList<>();
userIds.add(2157L);
addLog(approvalProcess, userIds);
}
if (approvalStatus == 200) {
if (dto.getLeaderId() == null) {
throw new RuntimeException("请选择分管局领导");
}
approvalProcess.setApprovalStatus(300);
List<Long> userIds = new ArrayList<>();
userIds.add(dto.getLeaderId());
addLog(approvalProcess, userIds);
}
if (approvalStatus == 300) {
approvalProcess.setApprovalStatus(400);
List<Long> 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<Long> 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());

View File

@ -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;
}

View File

@ -72,6 +72,9 @@ public class gwglLog {
@ApiModelProperty("审核人部门id")
private Long checkDeptId;
@ApiModelProperty("审核人id")
private String checkUserId;
@ApiModelProperty("审批状态")
private Integer approvalStatus;