fix:盖章bug

This commit is contained in:
dzc committed 2025-07-04 17:07:25 +08:00
1 parent e8b242f43a
commit cc194793ef
3 files changed
+28 -6

No files matched your search

@@ -21,8 +21,10 @@ import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.resolver.ParamResolver;
import com.bsd.pjcloud.common.data.tenant.TenantContextHolder;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.flow.task.api.feign.RemoteFlowEngineService;
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordAssignUserParamDto;
import com.bsd.pjcloud.flow.task.dto.TaskParamDto;
import com.bsd.pjcloud.wallet.api.constant.WalletBizRechargeEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletRechargeInvoiceStatusEnum;
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeBindInvoiceDto;
@@ -81,6 +83,7 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
private final RemoteUserService remoteUserService;
private final RemoteDeptService remoteDeptService;
private final RemoteFileService remoteFileService;
private final RemoteFlowEngineService flowEngineService;
private final RemoteWalletSettingService remoteWalletSettingService;
/**
@@ -92,6 +95,11 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
if (ObjectUtil.isEmpty(detail)) throw new RuntimeException("查询不到发票");
baseMapper.update(new LambdaUpdateWrapper<WalletRechargeInvoiceEntity>()
.set(WalletRechargeInvoiceEntity::getPicUrl, null)
.set(WalletRechargeInvoiceEntity::getApplyTime, null)
.set(WalletRechargeInvoiceEntity::getProcessId, null)
.set(WalletRechargeInvoiceEntity::getProcessStatus, null)
.set(WalletRechargeInvoiceEntity::getProcessTime, null)
.set(WalletRechargeInvoiceEntity::getStampPicUrl, null)
.eq(WalletRechargeInvoiceEntity::getId, id)
);
}
@@ -255,6 +263,12 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
UserInfo userInfo = remoteUserService.getByUserId(detail.getApplyUserId()).getData();
throw new RuntimeException("用户<" + userInfo.getSysUser().getName() + ">创建的发票已经" + WalletRechargeInvoiceStatusEnum.codeOf(detail.getStatus()).getDesc() + "不能删除");
}
// 如果是审批中就取消审批
if (ObjectUtil.equals(detail.getProcessStatus(), TaskCheckStatusEnum.PADDING.getCode())) {
TaskParamDto dto = new TaskParamDto();
dto.setProcessInstanceIdList(List.of(detail.getProcessId()));
flowEngineService.stopProcessInstance(dto).getData();
}
// 删除申请记录
baseMapper.deleteById(v);
// 删除申请记录条目
@@ -376,26 +390,31 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
// 开始盖章
String picUrl = String.format("%s%s", imageBaseUrl, invoice.getPicUrl());
File receiptStamp = FileUtil.file("image/receiptStamp.png");
// 发票底图宽高 6615 x 3591
int baseMapWidth = 6615, baseMapHeight = 3591;
// 发票底图宽高 3969 x 2154
int baseMapWidth = 3969, baseMapHeight = 2154;
// 盖章图片宽高
int stampWidth = 1000, stampHeight = 1000;
int stampOrgWidth = 600, stampOrgHeight = 600;
int stampWidth = 500, stampHeight = 500;
try {
// 读取底图
BufferedImage baseImage = ImageIO.read(new URL(picUrl));
// 读取盖章图片
BufferedImage stampImage = ImageIO.read(receiptStamp);
stampImage.getScaledInstance(stampWidth, stampHeight, Image.SCALE_SMOOTH);
// 创建新的图像上下文
Graphics2D g2d = baseImage.createGraphics();
// 设置抗锯齿
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int x = (int) (stampWidth + baseMapWidth * 0.15 - 50);
int y = baseMapHeight - stampHeight - 100;
int x = (int) (stampWidth + baseMapWidth * 0.15 + 80);
int y = baseMapHeight - stampHeight - 50;
g2d.drawImage(stampImage, x, y, stampWidth, stampHeight, null);
g2d.dispose();
String newPicUrl = invoice.getPicUrl().replaceFirst("(\\.\\w+)$", "_stamped$1");
File tempFile = File.createTempFile(newPicUrl, ".png");
ImageIO.write(baseImage, "PNG", tempFile);
// 保存到本地用于测试
// ImageIO.write(baseImage, "PNG", new File("test.png"));
// 上传图片
MultipartFile multipartFile = new MockMultipartFile("file", newPicUrl, "image/png", new FileInputStream(tempFile));
R upload = remoteFileService.innerUpload(multipartFile, null, null, null);
@@ -35,9 +35,12 @@
<if test="dto.status != null">
and a.status = #{dto.status}
</if>
<if test="dto.processStatus != null">
<if test="dto.processStatus != null and dto.processStatus != '' and dto.processStatus != 99 ">
and a.process_status = #{dto.processStatus}
</if>
<if test="dto.processStatus != null and dto.processStatus != '' and dto.processStatus == 99 ">
and a.process_id is null
</if>
<if test="dto.deptOrUser != null and dto.deptOrUser != '' ">
and a.dept_or_user like concat('%', #{dto.deptOrUser}, '%')
</if>