2025-06-07 13:59:48 +08:00
|
|
|
|
package com.ruoyi.business.controller;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
2025-06-09 14:38:59 +08:00
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
2025-06-07 13:59:48 +08:00
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
|
import com.ruoyi.database.domain.ApprovalProcess;
|
2025-06-09 11:10:23 +08:00
|
|
|
|
import com.ruoyi.database.domain.BusinessTripApproval;
|
|
|
|
|
import com.ruoyi.database.domain.NonWorkingDayDrinkingReport;
|
|
|
|
|
import com.ruoyi.database.domain.PoliceLeaveApproval;
|
2025-06-07 13:59:48 +08:00
|
|
|
|
import com.ruoyi.database.service.ApprovalProcessService;
|
2025-06-09 11:10:23 +08:00
|
|
|
|
import com.ruoyi.database.service.BusinessTripApprovalService;
|
|
|
|
|
import com.ruoyi.database.service.NonWorkingDayDrinkingReportService;
|
|
|
|
|
import com.ruoyi.database.service.PoliceLeaveApprovalService;
|
2025-06-09 14:38:59 +08:00
|
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
2025-06-07 13:59:48 +08:00
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
2025-06-09 15:50:24 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
2025-06-07 13:59:48 +08:00
|
|
|
|
|
2025-06-07 16:54:04 +08:00
|
|
|
|
import java.time.Instant;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.ZoneId;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
2025-06-09 14:38:59 +08:00
|
|
|
|
import java.util.ArrayList;
|
2025-06-07 13:59:48 +08:00
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description ApprovalProcessController
|
|
|
|
|
* @Author lijingtong
|
|
|
|
|
* @Date 2025-06-07
|
|
|
|
|
*/
|
|
|
|
|
@Api(tags = "审批单")
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/ApprovalProcess")
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class ApprovalProcessController extends BaseController {
|
|
|
|
|
|
|
|
|
|
private final ApprovalProcessService approvalsProcessService;
|
2025-06-09 11:10:23 +08:00
|
|
|
|
private final BusinessTripApprovalService businessTripApprovalService;
|
|
|
|
|
private final NonWorkingDayDrinkingReportService nonWorkingDayDrinkingReportService;
|
|
|
|
|
private final PoliceLeaveApprovalService policeLeaveApprovalService;
|
2025-06-09 14:38:59 +08:00
|
|
|
|
private final ISysUserService sysUserService;
|
2025-06-07 13:59:48 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/list")
|
|
|
|
|
@ApiOperation("查询列表")
|
2025-06-09 15:50:24 +08:00
|
|
|
|
public TableDataInfo list(@RequestBody ApprovalProcess approvalProcess) {
|
2025-06-09 19:15:00 +08:00
|
|
|
|
// startPage();
|
2025-06-07 13:59:48 +08:00
|
|
|
|
QueryWrapper<ApprovalProcess> queryWrapper = new QueryWrapper<>(approvalProcess);
|
2025-06-08 15:38:27 +08:00
|
|
|
|
queryWrapper.orderByDesc("create_time");
|
2025-06-09 11:55:44 +08:00
|
|
|
|
if (approvalProcess.getTimeType() != null) {
|
|
|
|
|
if (approvalProcess.getTimeType() == 1) {
|
2025-06-09 19:22:21 +08:00
|
|
|
|
queryWrapper.le("create_time", System.currentTimeMillis() - 3 * 24 * 60 * 60 * 1000);
|
2025-06-09 11:55:44 +08:00
|
|
|
|
} else if (approvalProcess.getTimeType() == 2) {
|
2025-06-09 19:22:21 +08:00
|
|
|
|
queryWrapper.le("create_time", System.currentTimeMillis() - 7 * 24 * 60 * 60 * 1000);
|
2025-06-09 11:55:44 +08:00
|
|
|
|
} else if (approvalProcess.getTimeType() == 3) {
|
2025-06-09 19:22:21 +08:00
|
|
|
|
queryWrapper.le("create_time", System.currentTimeMillis() - 30 * 24 * 60 * 60 * 1000);
|
2025-06-09 11:55:44 +08:00
|
|
|
|
}
|
2025-06-09 11:10:56 +08:00
|
|
|
|
}
|
2025-06-09 11:55:44 +08:00
|
|
|
|
|
2025-06-09 14:41:17 +08:00
|
|
|
|
if (approvalProcess.getSubmitterId() != null){
|
|
|
|
|
queryWrapper.eq("submitter_id", getLoginUser().getUserId());
|
|
|
|
|
}
|
2025-06-07 13:59:48 +08:00
|
|
|
|
List<ApprovalProcess> list = approvalsProcessService.list(queryWrapper);
|
2025-06-07 16:54:04 +08:00
|
|
|
|
|
|
|
|
|
for (ApprovalProcess process : list) {
|
|
|
|
|
|
|
|
|
|
// 如果创建时间为当天的时间
|
|
|
|
|
if (process.getCreateTime() > System.currentTimeMillis() - 24 * 60 * 60 * 1000) {
|
|
|
|
|
// 一分钟之内,显示刚刚
|
|
|
|
|
// 模拟获取创建时间戳(这里以当前时间戳减去一定值为例,实际应替换为 process.getCreateTime() )
|
|
|
|
|
long createTime = process.getCreateTime();
|
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
String result;
|
|
|
|
|
if (createTime > currentTime - 60 * 1000) {
|
|
|
|
|
result = "刚刚";
|
|
|
|
|
process.setShowTime(result);
|
|
|
|
|
} else if (createTime <= currentTime - 60 * 1000 && createTime > currentTime - 30 * 60 * 1000) {
|
|
|
|
|
long minutes = (currentTime - createTime) / (60 * 1000);
|
|
|
|
|
result = minutes + "分钟前";
|
|
|
|
|
process.setShowTime(result);
|
|
|
|
|
} else if (createTime <= currentTime - 30 * 60 * 1000 && createTime > currentTime - 60 * 60 * 1000) {
|
|
|
|
|
result = "半小时前";
|
|
|
|
|
process.setShowTime(result);
|
|
|
|
|
} else if (createTime <= currentTime - 60 * 60 * 1000) {
|
|
|
|
|
long hours = (currentTime - createTime) / (60 * 60 * 1000);
|
|
|
|
|
result = hours + "小时前";
|
|
|
|
|
process.setShowTime(result);
|
|
|
|
|
} else {
|
|
|
|
|
result = "时间计算异常";
|
|
|
|
|
process.setShowTime(result);
|
|
|
|
|
}
|
|
|
|
|
/*Long createTime = process.getCreateTime();
|
|
|
|
|
Instant instant = Instant.ofEpochMilli(createTime);
|
|
|
|
|
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.of("Asia/Shanghai"));
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
|
|
String formattedTime = localDateTime.format(formatter);
|
|
|
|
|
process.setShowTime(formattedTime);*/
|
|
|
|
|
} else if (process.getCreateTime() > System.currentTimeMillis() - 24 * 60 * 60 * 1000 && process.getCreateTime() < System.currentTimeMillis() - 2 * 24 * 60 * 60 * 1000) {
|
|
|
|
|
// 超过一天不大于两天,显示“昨天”
|
|
|
|
|
process.setShowTime("昨天");
|
|
|
|
|
} else {
|
|
|
|
|
// 超过两天显示年月日时分秒
|
|
|
|
|
Long createTime = process.getCreateTime();
|
|
|
|
|
Instant instant = Instant.ofEpochMilli(createTime);
|
|
|
|
|
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.of("Asia/Shanghai"));
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd");
|
|
|
|
|
String formattedTime = localDateTime.format(formatter);
|
|
|
|
|
process.setShowTime(formattedTime);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-07 13:59:48 +08:00
|
|
|
|
return getDataTable(list);
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-07 16:54:04 +08:00
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
Long createTime = 1749279303395L;
|
|
|
|
|
Instant instant = Instant.ofEpochMilli(createTime);
|
|
|
|
|
|
|
|
|
|
// 2. 转换为本地时区(如北京时间 UTC+8)
|
|
|
|
|
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.of("Asia/Shanghai"));
|
|
|
|
|
|
|
|
|
|
// 3. 定义日期时间格式
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
|
|
|
|
|
|
|
// 4. 格式化为字符串
|
|
|
|
|
String formattedTime = localDateTime.format(formatter);
|
|
|
|
|
System.out.println(formattedTime);
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-07 13:59:48 +08:00
|
|
|
|
@ApiOperation("根据编号查")
|
2025-06-07 15:14:44 +08:00
|
|
|
|
@PostMapping("/getByApprovalNo/{id}")
|
|
|
|
|
public TableDataInfo getByApprovalNo(@PathVariable String id) {
|
2025-06-07 13:59:48 +08:00
|
|
|
|
List<ApprovalProcess> list = approvalsProcessService.lambdaQuery()
|
2025-06-07 15:14:44 +08:00
|
|
|
|
.like(ApprovalProcess::getApprovalNo, id)
|
2025-06-08 15:38:27 +08:00
|
|
|
|
.orderByDesc(ApprovalProcess::getCreateTime)
|
2025-06-07 13:59:48 +08:00
|
|
|
|
.list();
|
|
|
|
|
return getDataTable(list);
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-08 13:05:48 +08:00
|
|
|
|
|
|
|
|
|
@ApiOperation("根据用户id查")
|
2025-06-09 11:55:44 +08:00
|
|
|
|
@PostMapping("/getByuserId")
|
2025-06-09 11:10:56 +08:00
|
|
|
|
public TableDataInfo getByuserId(ApprovalProcess approvalProcess) {
|
2025-06-08 13:05:48 +08:00
|
|
|
|
List<ApprovalProcess> list = approvalsProcessService.lambdaQuery()
|
2025-06-09 11:10:56 +08:00
|
|
|
|
.eq(ApprovalProcess::getSubmitterId, approvalProcess.getSubmitterId())
|
|
|
|
|
.eq(approvalProcess.getApprovalStatus() != null, ApprovalProcess::getApprovalStatus, approvalProcess.getApprovalStatus())
|
|
|
|
|
.eq(approvalProcess.getCcName() != null, ApprovalProcess::getCcName, approvalProcess.getCcName())
|
|
|
|
|
.eq(approvalProcess.getProcessTitle() != null, ApprovalProcess::getProcessTitle, approvalProcess.getProcessTitle())
|
2025-06-09 11:55:44 +08:00
|
|
|
|
.eq(approvalProcess.getSubmitterName() != null, ApprovalProcess::getSubmitterName, approvalProcess.getSubmitterName())
|
|
|
|
|
.eq(approvalProcess.getTimeType() != null, ApprovalProcess::getTimeType, approvalProcess.getTimeType())
|
2025-06-08 15:38:27 +08:00
|
|
|
|
.orderByDesc(ApprovalProcess::getCreateTime)
|
2025-06-08 13:05:48 +08:00
|
|
|
|
.list();
|
2025-06-09 11:10:56 +08:00
|
|
|
|
|
|
|
|
|
for (ApprovalProcess process : list) {
|
|
|
|
|
|
|
|
|
|
// 如果创建时间为当天的时间
|
|
|
|
|
if (process.getCreateTime() > System.currentTimeMillis() - 24 * 60 * 60 * 1000) {
|
|
|
|
|
// 一分钟之内,显示刚刚
|
|
|
|
|
// 模拟获取创建时间戳(这里以当前时间戳减去一定值为例,实际应替换为 process.getCreateTime() )
|
|
|
|
|
long createTime = process.getCreateTime();
|
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
String result;
|
|
|
|
|
if (createTime > currentTime - 60 * 1000) {
|
|
|
|
|
result = "刚刚";
|
|
|
|
|
process.setShowTime(result);
|
|
|
|
|
} else if (createTime <= currentTime - 60 * 1000 && createTime > currentTime - 30 * 60 * 1000) {
|
|
|
|
|
long minutes = (currentTime - createTime) / (60 * 1000);
|
|
|
|
|
result = minutes + "分钟前";
|
|
|
|
|
process.setShowTime(result);
|
|
|
|
|
} else if (createTime <= currentTime - 30 * 60 * 1000 && createTime > currentTime - 60 * 60 * 1000) {
|
|
|
|
|
result = "半小时前";
|
|
|
|
|
process.setShowTime(result);
|
|
|
|
|
} else if (createTime <= currentTime - 60 * 60 * 1000) {
|
|
|
|
|
long hours = (currentTime - createTime) / (60 * 60 * 1000);
|
|
|
|
|
result = hours + "小时前";
|
|
|
|
|
process.setShowTime(result);
|
|
|
|
|
} else {
|
|
|
|
|
result = "时间计算异常";
|
|
|
|
|
process.setShowTime(result);
|
|
|
|
|
}
|
|
|
|
|
/*Long createTime = process.getCreateTime();
|
|
|
|
|
Instant instant = Instant.ofEpochMilli(createTime);
|
|
|
|
|
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.of("Asia/Shanghai"));
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
|
|
String formattedTime = localDateTime.format(formatter);
|
|
|
|
|
process.setShowTime(formattedTime);*/
|
|
|
|
|
} else if (process.getCreateTime() > System.currentTimeMillis() - 24 * 60 * 60 * 1000 && process.getCreateTime() < System.currentTimeMillis() - 2 * 24 * 60 * 60 * 1000) {
|
|
|
|
|
// 超过一天不大于两天,显示“昨天”
|
|
|
|
|
process.setShowTime("昨天");
|
|
|
|
|
} else {
|
|
|
|
|
// 超过两天显示年月日时分秒
|
|
|
|
|
Long createTime = process.getCreateTime();
|
|
|
|
|
Instant instant = Instant.ofEpochMilli(createTime);
|
|
|
|
|
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.of("Asia/Shanghai"));
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd");
|
|
|
|
|
String formattedTime = localDateTime.format(formatter);
|
|
|
|
|
process.setShowTime(formattedTime);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-08 13:05:48 +08:00
|
|
|
|
return getDataTable(list);
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-07 15:14:44 +08:00
|
|
|
|
@ApiOperation("根据id查")
|
|
|
|
|
@PostMapping("/getById/{id}")
|
|
|
|
|
public AjaxResult getById(@PathVariable Long id) {
|
2025-06-09 11:10:23 +08:00
|
|
|
|
ApprovalProcess byId = approvalsProcessService.getById(id);
|
|
|
|
|
Integer matterType = byId.getMatterType();
|
2025-06-09 11:55:44 +08:00
|
|
|
|
if (matterType == 2) {
|
2025-06-09 11:10:23 +08:00
|
|
|
|
BusinessTripApproval one = businessTripApprovalService.lambdaQuery()
|
|
|
|
|
.eq(BusinessTripApproval::getUuid, byId.getUuid())
|
|
|
|
|
.last("LIMIT 1")
|
|
|
|
|
.one();
|
|
|
|
|
one.setDestinationIdCn(byId.getBusinessTripDestination());
|
2025-06-09 14:38:59 +08:00
|
|
|
|
String togUserIds = one.getTogUserIds();
|
|
|
|
|
if (togUserIds != null && !"".equals(togUserIds)){
|
|
|
|
|
List<SysUser> userList = new ArrayList<>();
|
|
|
|
|
if (togUserIds.contains(",")){
|
|
|
|
|
String[] split = togUserIds.split(",");
|
|
|
|
|
for (String s : split) {
|
|
|
|
|
s = s.trim(); // 移除首尾空格
|
|
|
|
|
if (!s.isEmpty()) {
|
|
|
|
|
SysUser user = sysUserService.selectUserById(Long.parseLong(togUserIds));
|
|
|
|
|
userList.add(user);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
one.setTogUserList(userList);
|
|
|
|
|
}else {
|
|
|
|
|
SysUser user = sysUserService.selectUserById(Long.parseLong(togUserIds));
|
|
|
|
|
userList.add(user);
|
|
|
|
|
one.setTogUserList(userList);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-09 11:10:23 +08:00
|
|
|
|
return AjaxResult.success(one);
|
|
|
|
|
}
|
2025-06-09 11:55:44 +08:00
|
|
|
|
if (matterType == 3) {
|
2025-06-09 11:10:23 +08:00
|
|
|
|
PoliceLeaveApproval one = policeLeaveApprovalService.lambdaQuery()
|
|
|
|
|
.eq(PoliceLeaveApproval::getUuid, byId.getUuid())
|
|
|
|
|
.last("LIMIT 1")
|
|
|
|
|
.one();
|
|
|
|
|
return AjaxResult.success(one);
|
|
|
|
|
}
|
2025-06-09 11:55:44 +08:00
|
|
|
|
if (matterType == 4) {
|
2025-06-09 11:10:23 +08:00
|
|
|
|
NonWorkingDayDrinkingReport one = nonWorkingDayDrinkingReportService.lambdaQuery()
|
|
|
|
|
.eq(NonWorkingDayDrinkingReport::getUuid, byId.getUuid())
|
|
|
|
|
.last("LIMIT 1")
|
|
|
|
|
.one();
|
|
|
|
|
return AjaxResult.success(one);
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success(null);
|
2025-06-07 13:59:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|