Compare commits
2 Commits
e19ef3003a
...
71f3810e51
Author | SHA1 | Date | |
---|---|---|---|
71f3810e51 | |||
fa835684d4 |
@ -224,6 +224,21 @@ public class PdfBoxQrCodeGenerator {
|
|||||||
// 二维码大小比例(页面宽高中较小值的20%)
|
// 二维码大小比例(页面宽高中较小值的20%)
|
||||||
private static final float QR_SIZE_RATIO = 0.2f;
|
private static final float QR_SIZE_RATIO = 0.2f;
|
||||||
|
|
||||||
|
// 二维码大小比例(页面宽高中较小值的20%)
|
||||||
|
private static final float QR_SIZE = 60.0f;
|
||||||
|
|
||||||
|
// 竖坐标
|
||||||
|
private static final float V_QR_X = 232.0f;
|
||||||
|
|
||||||
|
// 竖坐标
|
||||||
|
private static final float V_QR_Y = 679.5f;
|
||||||
|
|
||||||
|
// 横坐标
|
||||||
|
private static final float H_QR_X = 1116.5f;
|
||||||
|
|
||||||
|
// 横坐标
|
||||||
|
private static final float H_QR_Y = 34.0f;
|
||||||
|
|
||||||
public static ByteArrayOutputStream addQRCodeToPDFOnAllPages(String srcPdf, byte[] qrCodeBytes, boolean isChangeFile)
|
public static ByteArrayOutputStream addQRCodeToPDFOnAllPages(String srcPdf, byte[] qrCodeBytes, boolean isChangeFile)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
@ -256,6 +271,10 @@ public class PdfBoxQrCodeGenerator {
|
|||||||
int numberOfPages = pdfDoc.getNumberOfPages();
|
int numberOfPages = pdfDoc.getNumberOfPages();
|
||||||
|
|
||||||
for (int pageNum = 1; pageNum <= numberOfPages; pageNum++) {
|
for (int pageNum = 1; pageNum <= numberOfPages; pageNum++) {
|
||||||
|
if (pageNum == 1 && isChangeFile) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
PdfPage page = pdfDoc.getPage(pageNum);
|
PdfPage page = pdfDoc.getPage(pageNum);
|
||||||
|
|
||||||
// 获取页面的所有边界框信息
|
// 获取页面的所有边界框信息
|
||||||
@ -266,25 +285,33 @@ public class PdfBoxQrCodeGenerator {
|
|||||||
Rectangle visibleArea = (cropBox != null) ? cropBox : mediaBox;
|
Rectangle visibleArea = (cropBox != null) ? cropBox : mediaBox;
|
||||||
|
|
||||||
// 计算页面宽高中较小的值
|
// 计算页面宽高中较小的值
|
||||||
float minDimension = Math.min(visibleArea.getWidth(), visibleArea.getHeight());
|
// float minDimension = Math.min(visibleArea.getWidth(), visibleArea.getHeight());
|
||||||
|
|
||||||
// 动态计算二维码大小(页面宽高中较小值的20%)
|
// 动态计算二维码大小(页面宽高中较小值的20%)
|
||||||
float qrSize = minDimension * QR_SIZE_RATIO;
|
// float qrSize = minDimension * QR_SIZE_RATIO;
|
||||||
|
|
||||||
// 输出页面尺寸信息
|
// 输出页面尺寸信息
|
||||||
System.out.println("页面 " + pageNum + " 尺寸: " + visibleArea.getWidth() + "x" + visibleArea.getHeight());
|
// System.out.println("页面 " + pageNum + " 尺寸: " + visibleArea.getWidth() + "x" + visibleArea.getHeight());
|
||||||
System.out.println("页面 " + pageNum + " 二维码大小 (点): " + qrSize);
|
// System.out.println("页面 " + pageNum + " 二维码大小 (点): " + qrSize);
|
||||||
|
|
||||||
// 计算左上角的位置(PDF坐标系:原点在左下角)
|
// 计算左上角的位置(PDF坐标系:原点在左下角)
|
||||||
float qrX = visibleArea.getLeft() + MARGIN;
|
// float qrX = visibleArea.getLeft() + MARGIN;
|
||||||
float qrY = visibleArea.getTop() - qrSize - MARGIN;
|
// float qrY = visibleArea.getTop() - qrSize - MARGIN;
|
||||||
|
|
||||||
// 打印二维码位置信息
|
// 打印二维码位置信息
|
||||||
System.out.println("页面 " + pageNum + " 左上角二维码位置: x=" + qrX + ", y=" + qrY);
|
// System.out.println("页面 " + pageNum + " 左上角二维码位置: x=" + qrX + ", y=" + qrY);
|
||||||
|
float qrX;
|
||||||
|
float qrY;
|
||||||
|
if (visibleArea.getWidth() > visibleArea.getHeight()) {
|
||||||
|
qrX = H_QR_X;
|
||||||
|
qrY = H_QR_Y;
|
||||||
|
} else {
|
||||||
|
qrX = V_QR_X;
|
||||||
|
qrY = V_QR_Y;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// 使用Canvas API添加左上角二维码
|
// 使用Canvas API添加左上角二维码
|
||||||
addQRCodeWithCanvas(pdfDoc, page, qrCodeBytes, qrX, qrY, qrSize);
|
addQRCodeWithCanvas(pdfDoc, page, qrCodeBytes, qrX, qrY, QR_SIZE);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("在页面 " + pageNum + " 添加二维码时出错: " + e.getMessage());
|
System.err.println("在页面 " + pageNum + " 添加二维码时出错: " + e.getMessage());
|
||||||
|
@ -205,7 +205,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
|||||||
//给处理人发消息重新统计数据
|
//给处理人发消息重新统计数据
|
||||||
|
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
flwCommonService.sendCountMessage(task.getId());
|
flwCommonService.sendCountMessage(task);
|
||||||
}
|
}
|
||||||
// 只有办理或者退回的时候才执行消息通知和抄送
|
// 只有办理或者退回的时候才执行消息通知和抄送
|
||||||
if (TaskStatusEnum.PASS.getStatus().equals(flowParams.getHisStatus())
|
if (TaskStatusEnum.PASS.getStatus().equals(flowParams.getHisStatus())
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.workflow.service;
|
package org.dromara.workflow.service;
|
||||||
|
|
||||||
|
import org.dromara.warm.flow.core.entity.Task;
|
||||||
import org.dromara.workflow.domain.bo.FlowCopyBo;
|
import org.dromara.workflow.domain.bo.FlowCopyBo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -32,7 +33,7 @@ public interface IFlwCommonService {
|
|||||||
/**
|
/**
|
||||||
* 发送统计消息
|
* 发送统计消息
|
||||||
*/
|
*/
|
||||||
void sendCountMessage(Long taskId);
|
void sendCountMessage(Task task);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送抄送消息
|
* 发送抄送消息
|
||||||
|
@ -15,21 +15,30 @@ import org.dromara.common.sse.config.SseProperties;
|
|||||||
import org.dromara.common.sse.dto.SeeMessageContentDto;
|
import org.dromara.common.sse.dto.SeeMessageContentDto;
|
||||||
import org.dromara.common.sse.dto.SseMessageDto;
|
import org.dromara.common.sse.dto.SseMessageDto;
|
||||||
import org.dromara.common.sse.utils.SseMessageUtils;
|
import org.dromara.common.sse.utils.SseMessageUtils;
|
||||||
|
import org.dromara.warm.flow.core.FlowEngine;
|
||||||
|
import org.dromara.warm.flow.core.entity.Definition;
|
||||||
import org.dromara.warm.flow.core.entity.Node;
|
import org.dromara.warm.flow.core.entity.Node;
|
||||||
import org.dromara.warm.flow.core.entity.Task;
|
import org.dromara.warm.flow.core.entity.Task;
|
||||||
import org.dromara.warm.flow.core.enums.SkipType;
|
import org.dromara.warm.flow.core.enums.SkipType;
|
||||||
|
import org.dromara.warm.flow.core.service.DefService;
|
||||||
import org.dromara.warm.flow.core.service.NodeService;
|
import org.dromara.warm.flow.core.service.NodeService;
|
||||||
|
import org.dromara.warm.flow.core.service.UserService;
|
||||||
|
import org.dromara.warm.flow.orm.entity.FlowDefinition;
|
||||||
|
import org.dromara.warm.flow.orm.entity.FlowNode;
|
||||||
import org.dromara.warm.flow.orm.entity.FlowTask;
|
import org.dromara.warm.flow.orm.entity.FlowTask;
|
||||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||||
import org.dromara.workflow.common.enums.MessageTypeEnum;
|
import org.dromara.workflow.common.enums.MessageTypeEnum;
|
||||||
import org.dromara.workflow.domain.bo.FlowCopyBo;
|
import org.dromara.workflow.domain.bo.FlowCopyBo;
|
||||||
import org.dromara.workflow.service.IFlwCommonService;
|
import org.dromara.workflow.service.IFlwCommonService;
|
||||||
|
import org.dromara.workflow.service.IFlwDefinitionService;
|
||||||
import org.dromara.workflow.service.IFlwTaskAssigneeService;
|
import org.dromara.workflow.service.IFlwTaskAssigneeService;
|
||||||
import org.dromara.workflow.service.IFlwTaskService;
|
import org.dromara.workflow.service.IFlwTaskService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@ -59,9 +68,9 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
|
|||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
IFlwTaskAssigneeService taskAssigneeService = SpringUtils.getBean(IFlwTaskAssigneeService.class);
|
IFlwTaskAssigneeService taskAssigneeService = SpringUtils.getBean(IFlwTaskAssigneeService.class);
|
||||||
String processedBys = CollUtil.join(permissionList, StringUtils.SEPARATOR);
|
String processedBys = CollUtil.join(permissionList, StringUtils.SEPARATOR);
|
||||||
// 根据 processedBy 前缀判断处理人类型,分别获取用户列表
|
// 根据 processedBy 前缀判断处理人类型,分别获取用户列表
|
||||||
List<UserDTO> users = taskAssigneeService.fetchUsersByStorageIds(processedBys,null);
|
List<UserDTO> users = taskAssigneeService.fetchUsersByStorageIds(processedBys, null);
|
||||||
|
|
||||||
return StreamUtils.toList(users, userDTO -> String.valueOf(userDTO.getUserId()));
|
return StreamUtils.toList(users, userDTO -> String.valueOf(userDTO.getUserId()));
|
||||||
}
|
}
|
||||||
@ -75,7 +84,7 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
|
|||||||
* @param message 消息内容,为空则发送默认配置的消息内容
|
* @param message 消息内容,为空则发送默认配置的消息内容
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String flowName,String flowCode, Long instId, List<String> messageType, String message) {
|
public void sendMessage(String flowName, String flowCode, Long instId, List<String> messageType, String message) {
|
||||||
IFlwTaskService flwTaskService = SpringUtils.getBean(IFlwTaskService.class);
|
IFlwTaskService flwTaskService = SpringUtils.getBean(IFlwTaskService.class);
|
||||||
List<UserDTO> userList = new ArrayList<>();
|
List<UserDTO> userList = new ArrayList<>();
|
||||||
List<FlowTask> list = flwTaskService.selectByInstId(instId);
|
List<FlowTask> list = flwTaskService.selectByInstId(instId);
|
||||||
@ -126,11 +135,28 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void sendCountMessage(Long taskId) {
|
public void sendCountMessage(Task task) {
|
||||||
IFlwTaskService flwTaskService = SpringUtils.getBean(IFlwTaskService.class);
|
IFlwTaskService flwTaskService = SpringUtils.getBean(IFlwTaskService.class);
|
||||||
|
IFlwTaskAssigneeService flwTaskAssigneeService = SpringUtils.getBean(IFlwTaskAssigneeService.class);
|
||||||
|
|
||||||
|
DefService defService = FlowEngine.defService();
|
||||||
|
Definition definition = defService.getById(task.getDefinitionId());
|
||||||
|
|
||||||
|
FlowNode byNodeCode = flwTaskService.getByNodeCode(task.getNodeCode(), task.getDefinitionId());
|
||||||
|
String permissionFlag = byNodeCode.getPermissionFlag();
|
||||||
|
if(permissionFlag == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
permissionFlag = permissionFlag.replace("@@", ",");
|
||||||
|
String flowCode = definition.getFlowCode();
|
||||||
|
String projectId = flowCode.split("_")[0];
|
||||||
|
List<UserDTO> users = flwTaskAssigneeService.fetchUsersByStorageIds(permissionFlag, Long.valueOf(projectId));
|
||||||
|
|
||||||
|
|
||||||
List<UserDTO> userList = new ArrayList<>();
|
List<UserDTO> userList = new ArrayList<>();
|
||||||
List<UserDTO> users = flwTaskService.currentTaskAllUser(taskId);
|
|
||||||
if (CollUtil.isNotEmpty(users)) {
|
if (CollUtil.isNotEmpty(users)) {
|
||||||
userList.addAll(users);
|
userList.addAll(users);
|
||||||
}
|
}
|
||||||
@ -145,10 +171,9 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendCopyMessage(String flowName, String flowCode, List<FlowCopyBo> flowCopyList) {
|
public void sendCopyMessage(String flowName, String flowCode, List<FlowCopyBo> flowCopyList) {
|
||||||
if(CollUtil.isEmpty(flowCopyList)){
|
if (CollUtil.isEmpty(flowCopyList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SseMessageDto dto = new SseMessageDto();
|
SseMessageDto dto = new SseMessageDto();
|
||||||
|
Reference in New Issue
Block a user