Merge branch 'feature/REQ-7125' into dev

This commit is contained in:
wangli 2026-03-04 15:45:33 +08:00
commit 2a4720ffbb
4 changed files with 97 additions and 2 deletions

View File

@ -118,4 +118,9 @@ public class DocCreateDTO implements Serializable {
@ApiModelProperty(value = "租户 ID")
@Builder.Default
private String tenantId = NO_TENANT_ID;
/**
* 代运营模板通过公共模板同步过来的文档关联的公共文档 id
*/
@ApiModelProperty(value = "公共模板该文档的 ID")
private Long originDocId;
}

View File

@ -90,4 +90,9 @@ public class ExtAxModelDoc extends BaseEntity<ExtAxModelDoc> {
* 租户 ID
*/
private String tenantId;
/**
* 代运营模板通过公共模板同步过来的文档关联的公共文档 id
*/
private Long originDocId;
}

View File

@ -583,7 +583,9 @@ public class BpmnProcessModelController implements ProcessModelApi {
if (Objects.isNull(response) || !Objects.equals(response.getCode(), 200)) {
throw new WorkflowEngineException(MODEL_FILE_CLONE_ERROR, Objects.isNull(response) ? "网络异常" : response.getMsg());
}
DocCreateDTO newDoc = BeanMapper.copyBean(originDoc, DocCreateDTO.class);
DocCreateDTO newDoc = BeanMapper.copyBean(originDoc, DocCreateDTO.class, (s, t) -> {
t.setOriginDocId(s.getId());
});
newDoc.setFileRelationId(response.getData());
newDoc.setTag("");
if (docModelInfo != null) {
@ -604,7 +606,9 @@ public class BpmnProcessModelController implements ProcessModelApi {
if (Objects.isNull(response) || Objects.equals(response.getCode(), 200)) {
throw new WorkflowEngineException(MODEL_FILE_CLONE_ERROR, Objects.isNull(response) ? "网络异常" : response.getMsg());
}
DocCreateDTO newDoc = BeanMapper.copyBean(originDoc, DocCreateDTO.class);
DocCreateDTO newDoc = BeanMapper.copyBean(originDoc, DocCreateDTO.class, (s, t) -> {
t.setOriginDocId(s.getId());
});
newDoc.setFileRelationId(response.getData().getResponses().get(0).getSrcFileKey());
newDoc.setTag("");
if (docModelInfo != null) {

View File

@ -0,0 +1,81 @@
package cn.axzo.workflow.server.xxljob;
import cn.axzo.infra.xxl220to250.IJobHandler;
import cn.axzo.workflow.common.enums.BusinessTypeEnum;
import cn.axzo.workflow.common.model.request.category.CategorySearchDTO;
import cn.axzo.workflow.common.model.response.category.CategoryItemVO;
import cn.axzo.workflow.core.repository.entity.ExtAxModelDoc;
import cn.axzo.workflow.core.repository.mapper.ExtAxModelDocMapper;
import cn.axzo.workflow.core.service.CategoryService;
import cn.axzo.workflow.core.service.ExtAxModelDocService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 模板关联文档的数据清洗
*
* @author wangli
* @since 2025-09-05 11:19
*/
@Component
@RequiredArgsConstructor
@Slf4j
public class ModelDocDataJobHandler extends IJobHandler {
private final CategoryService categoryService;
private final ExtAxModelDocService modelDocService;
private final ExtAxModelDocMapper extAxModelDocMapper;
@XxlJob("modelDocDataJobHandler")
@Override
public ReturnT<String> execute(String param) throws Exception {
CategorySearchDTO categorySearchDto = new CategorySearchDTO();
categorySearchDto.setBusinessType(BusinessTypeEnum.SIGN);
List<CategoryItemVO> processDefinitionKeys = categoryService.list(categorySearchDto);
if (CollectionUtils.isEmpty(processDefinitionKeys)) {
XxlJobHelper.log("没有签字业务");
return ReturnT.SUCCESS;
}
for (CategoryItemVO key : processDefinitionKeys) {
List<ExtAxModelDoc> docs = modelDocService.querySetting(key.getValue(), null);
List<ExtAxModelDoc> commonDocs = docs.stream().filter(i -> Objects.equals(i.getTenantId(), "")).collect(Collectors.toList());
if (CollectionUtils.isEmpty(commonDocs)) {
continue;
}
Map<String, Long> tagToOriginIdMap = commonDocs.stream()
.filter(i -> StringUtils.hasText(i.getTag()))
.collect(Collectors.toMap(ExtAxModelDoc::getTag, ExtAxModelDoc::getId, (oldVal, newVal) -> oldVal));
Map<String, List<ExtAxModelDoc>> tenantDocMap = docs.stream().filter(i -> StringUtils.hasText(i.getTenantId())).collect(Collectors.groupingBy(ExtAxModelDoc::getTenantId));
for (List<ExtAxModelDoc> tenantDocs : tenantDocMap.values()) {
for (ExtAxModelDoc tenantDoc : tenantDocs) {
if (StringUtils.hasText(tenantDoc.getTag()) && tagToOriginIdMap.containsKey(tenantDoc.getTag())) {
Long originDocId = tagToOriginIdMap.get(tenantDoc.getTag());
if (!Objects.equals(tenantDoc.getOriginDocId(), originDocId)) {
ExtAxModelDoc updateEntity = new ExtAxModelDoc();
updateEntity.setId(tenantDoc.getId());
updateEntity.setOriginDocId(originDocId);
extAxModelDocMapper.updateById(updateEntity);
XxlJobHelper.log("Updated docId={} with originDocId={}", tenantDoc.getId(), originDocId);
}
}
}
}
}
return ReturnT.SUCCESS;
}
}