feat(REQ-7125) - 处理文档模型数据清晰
This commit is contained in:
parent
498dbcb580
commit
787cc567f1
@ -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;
|
||||
}
|
||||
|
||||
@ -90,4 +90,9 @@ public class ExtAxModelDoc extends BaseEntity<ExtAxModelDoc> {
|
||||
* 租户 ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 代运营模板通过公共模板同步过来的文档关联的公共文档 id
|
||||
*/
|
||||
private Long originDocId;
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user