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.ApprovalProcess;
import com.ruoyi.database.domain.BaseAddressInfo; import com.ruoyi.database.domain.BaseAddressInfo;
import com.ruoyi.database.domain.BusinessTripApproval; 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.dto.ApprovaltDto;
import com.ruoyi.database.domain.gwglLog; import com.ruoyi.database.domain.gwglLog;
import com.ruoyi.database.service.ApprovalProcessService; import com.ruoyi.database.service.ApprovalProcessService;
@ -143,7 +144,7 @@ public class BusinessTripApprovalController extends BaseController {
approvalProcess.setApprovalStatus(1); approvalProcess.setApprovalStatus(1);
longs.add(user.getDept().getLeaderId()); longs.add(user.getDept().getLeaderId());
} }
addLog(approvalProcess,longs); addLog(approvalProcess, longs);
return toAjax(businessTripApprovalService.save(dto) return toAjax(businessTripApprovalService.save(dto)
&& approvalsProcessService.save(approvalProcess) && approvalsProcessService.save(approvalProcess)
); );
@ -242,30 +243,116 @@ public class BusinessTripApprovalController extends BaseController {
@ApiOperation("审批出差申请") @ApiOperation("审批出差申请")
@PostMapping("/approval") @PostMapping("/approval")
public AjaxResult approval(ApprovaltDto dto) { public AjaxResult approval(@RequestBody ApprovaltBusinessDto dto) {
SysUser user = getLoginUser().getUser(); SysUser user = getLoginUser().getUser();
Long id = dto.getId(); String uuid = dto.getUuid();
Integer state = dto.getState(); if (uuid == null) {
BusinessTripApproval businessTripApproval = businessTripApprovalService.getById(id); throw new RuntimeException("uuid不可为空");
businessTripApproval.setState(state); }
boolean result = businessTripApprovalService.updateById(businessTripApproval); if (dto.getState() == null) {
gwglLog gwglLog = new gwglLog(); throw new RuntimeException("请选择通过或者驳回");
gwglLog.setApplyNo(businessTripApproval.getApplyNo()); }
gwglLog.setDeptName(businessTripApproval.getDepartment()); gwglLog one = gwglLogService.lambdaQuery()
gwglLog.setUserId(businessTripApproval.getUserId()); .eq(gwglLog::getUuid, uuid)
gwglLog.setUserName(businessTripApproval.getUserName()); .orderByDesc(gwglLog::getCreateTime)
// gwglLog.setCreateTime(businessTripApproval.getCreateTime()); .last("LIMIT 1")
gwglLog.setReason(businessTripApproval.getReason()); .one();
gwglLog.setType(1); Integer checkState = one.getCheckState();
gwglLog.setApplyNo(businessTripApproval.getApplyNo()); if (checkState != 0) {
gwglLog.setChecker(user.getNickName()); throw new RuntimeException("记录已被处理");
gwglLog.setCheckTime(System.currentTimeMillis()); }
gwglLog.setCheckState(state); String checkUserId = one.getCheckUserId();
boolean result1 = gwglLogService.save(gwglLog); List<Long> longs = new ArrayList<>();
if (!result || !result1) { if (checkUserId != null) {
return AjaxResult.error("审批出差申请失败"); 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.setCheckState(0);
gwglLog.setUuid(approvalProcess.getUuid()); gwglLog.setUuid(approvalProcess.getUuid());
gwglLog.setApprovalStatus(approvalProcess.getApprovalStatus()); gwglLog.setApprovalStatus(approvalProcess.getApprovalStatus());
gwglLog.setCreateTime(System.currentTimeMillis() / 1000L);
SysUser user = new SysUser(); SysUser user = new SysUser();
StringBuilder name = new StringBuilder(); StringBuilder name = new StringBuilder();
StringBuilder ids = new StringBuilder();
for (Long userId : userIds) { for (Long userId : userIds) {
SysUser user1 = sysUserService.selectUserById(userId); SysUser user1 = sysUserService.selectUserById(userId);
if (name.length() > 0) { if (name.length() > 0) {
name.append(","); name.append(",");
} }
name.append(user1.getNickName()); name.append(user1.getNickName());
if (ids.length() > 0) {
ids.append(",");
} }
ids.append(user1.getUserId());
}
gwglLog.setCheckUserId(ids.toString());
gwglLog.setChecker(name.toString()); gwglLog.setChecker(name.toString());
if (user.getDept() != null) { if (user.getDept() != null) {
gwglLog.setCheckDeptName(user.getDept().getDeptName()); 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") @ApiModelProperty("审核人部门id")
private Long checkDeptId; private Long checkDeptId;
@ApiModelProperty("审核人id")
private String checkUserId;
@ApiModelProperty("审批状态") @ApiModelProperty("审批状态")
private Integer approvalStatus; private Integer approvalStatus;