feat(REQ-3300) - 完善申请用印逻辑

This commit is contained in:
wangli 2025-02-25 13:48:58 +08:00
parent 2d85d1e3f2
commit 53738a66ef

View File

@ -55,6 +55,7 @@ import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.groovy.util.Maps;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -444,13 +445,7 @@ public class ChangeRecordRelationServiceImpl extends ServiceImpl<ChangeRecordRel
AssertUtil.notNull(visa, "变洽签单据不存在");
// 创建电子签合同
createContract(req, visa);
ChangeRecordRelation recipientRelation = new ChangeRecordRelation();
Map<Long, String> essRecipientIdMap = new HashMap<>();
recipientRelation.setVisaId(visa.getId());
recipientRelation.setVarName(ESS_RECIPIENT_ID_MAP.name());
recipientRelation.setVarType(VisaRelationVarTypeEnum.JSON.getType());
recipientRelation.setContent(JSON.toJSONString(essRecipientIdMap));
Map<Long, String> essRecipientIdMap = createContract(req, visa);
// 用印申请信息
List<ChangeRecordRelation> relations = req.getRequestStamps().stream().map(i -> {
@ -466,6 +461,15 @@ public class ChangeRecordRelationServiceImpl extends ServiceImpl<ChangeRecordRel
return stamp;
}).collect(Collectors.toList());
if (Objects.nonNull(essRecipientIdMap)) {
// 记录单位与其在合同中的签章位置
ChangeRecordRelation recipientRelation = new ChangeRecordRelation();
recipientRelation.setVisaId(visa.getId());
recipientRelation.setVarName(ESS_RECIPIENT_ID_MAP.name());
recipientRelation.setVarType(VisaRelationVarTypeEnum.JSON.getType());
recipientRelation.setContent(JSON.toJSONString(essRecipientIdMap));
}
// 打印生成的 PDF 文件信息
if (Objects.nonNull(req.getPdfFile())) {
ChangeRecordRelation relation = new ChangeRecordRelation();
@ -481,8 +485,10 @@ public class ChangeRecordRelationServiceImpl extends ServiceImpl<ChangeRecordRel
saveBatch(relations);
}
private void createContract(VisaRequestStampReq req, ChangeRecord visa) {
if (!StringUtils.hasText(visa.getContractId())) {
private Map<Long, String> createContract(VisaRequestStampReq req, ChangeRecord visa) {
if (StringUtils.hasText(visa.getContractId())) {
return null;
}
CreateContractByFileRequest createContractRequest = new CreateContractByFileRequest();
CreateContractByFile pdfFile = new CreateContractByFile();
pdfFile.setContractName(visa.getTopic());
@ -509,7 +515,13 @@ public class ChangeRecordRelationServiceImpl extends ServiceImpl<ChangeRecordRel
AssertUtil.notNull(contract, "腾讯电子签合同创建失败");
visa.setContractId(contract.getEssContractId());
changeRecordService.updateById(visa);
Map<Long, String> essRecipientIdMap = new HashMap<>();
for (int i = 0; i < req.getRequestStamps().size(); i++) {
essRecipientIdMap.put(req.getRequestStamps().get(i).getOuId(), contract.getEssRecipientIds().get(i));
}
return essRecipientIdMap;
}
public static String downloadFileAndConvertToBase64(String fileUrl) throws IOException {
@ -557,7 +569,7 @@ public class ChangeRecordRelationServiceImpl extends ServiceImpl<ChangeRecordRel
create.setVariables(Maps.of(
WORKFLOW_VAR_STAMP_OU_ID, model.getOuId(),
WORKFLOW_VAR_STAMP_TYPE, model.getSealType().name(),
WORKFLOW_VAR_STAMP_RECIPIENT, essRecipientIdMap.getOrDefault(model.getOuId(), "")
WORKFLOW_VAR_STAMP_RECIPIENT, MapUtils.emptyIfNull(essRecipientIdMap).getOrDefault(model.getOuId(), "")
));
return workflowGateway.processInstanceCreate(create);
}