feat(REQ-3300): 同步图纸绑定关系至图纸方

审批不通过和废止时同步取消绑定关系,提交审批时同步绑定关系
This commit is contained in:
chenwenjian 2025-02-20 17:12:31 +08:00
parent 51abbefa23
commit 8b4efdc2a2
4 changed files with 113 additions and 0 deletions

View File

@ -176,6 +176,8 @@ public class ProcessInstanceAllEventHandler extends BasicLogSupport implements P
// 取消当前主单据关联的其他单据的关联状态
changeRecordBillService.billRelationStatus(visaId, false);
// 取消图纸绑定关系
changeRecordService.syncDrawAnnotationUnBindRelation(visaId);
}
}

View File

@ -0,0 +1,45 @@
package cn.axzo.nanopart.visa.server.rpc;
import cn.axzo.nanopart.visa.server.utils.RpcUtil;
import cn.axzo.thor.client.enums.DrawingAnnotationBizEnum;
import cn.axzo.thor.client.feign.DrawingAnnotationApi;
import cn.axzo.thor.client.model.BindDrawingAnnotationDTO;
import cn.axzo.thor.client.model.UnbindDrawingAnnotationDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Set;
/**
* @author chenwenjian
* @version 1.0
* @date 2025/2/19 20:09
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class DrawingAnnotationApiGateway {
private final DrawingAnnotationApi drawingAnnotationApi;
public void bindBusiness(Long visasId, Set<Long> annotationIds) {
BindDrawingAnnotationDTO bindDrawingAnnotationDTO = BindDrawingAnnotationDTO.builder()
.drawingAnnotationIds(annotationIds)
.businessType(DrawingAnnotationBizEnum.VISA_CHANGE)
.businessId(String.valueOf(visasId))
.build();
RpcUtil.rpcCommonProcessor(()->drawingAnnotationApi.bindBusiness(bindDrawingAnnotationDTO),
"sync visa and drawing annotation bind relation to thor", bindDrawingAnnotationDTO);
}
public void unbindBusiness(Long visasId, Set<Long> annotationIds) {
UnbindDrawingAnnotationDTO unbindDrawingAnnotationDTO = UnbindDrawingAnnotationDTO.builder()
.drawingAnnotationIds(annotationIds)
.businessType(DrawingAnnotationBizEnum.VISA_CHANGE)
.businessId(String.valueOf(visasId))
.build();
RpcUtil.rpcCommonProcessor(()->drawingAnnotationApi.unbindBusiness(unbindDrawingAnnotationDTO),
"sync visa and drawing annotation unbind relation to thor", unbindDrawingAnnotationDTO);
}
}

View File

@ -134,4 +134,16 @@ public interface ChangeRecordService extends IService<ChangeRecord> {
*/
PageData<VisaSearchResp> list(VisaSearchReq req);
/**
* 同步图纸与变更签证单关联关系
* @param visaId 变更签证Id
*/
void syncDrawAnnotationBindRelation(Long visaId);
/**
* 同步图纸与变更签证单解除关联关系
* @param visaId 变更签证Id
*/
void syncDrawAnnotationUnBindRelation(Long visaId);
}

View File

@ -74,6 +74,7 @@ import cn.axzo.nanopart.visa.server.dto.VisaLogParam;
import cn.axzo.nanopart.visa.server.mapper.ChangeRecordDao;
import cn.axzo.nanopart.visa.server.rpc.ApolloConstructionAreaGateway;
import cn.axzo.nanopart.visa.server.rpc.ApolloTaskOrderApiGateway;
import cn.axzo.nanopart.visa.server.rpc.DrawingAnnotationApiGateway;
import cn.axzo.nanopart.visa.server.rpc.DrawingMajorGateway;
import cn.axzo.nanopart.visa.server.rpc.MsgCenterGateway;
import cn.axzo.nanopart.visa.server.rpc.OrganizationalUnitGateway;
@ -240,6 +241,8 @@ public class ChangeRecordServiceImpl extends ServiceImpl<ChangeRecordDao, Change
private RectifyApiGateway rectifyApiGateway;
@Resource
private ApolloTaskOrderApiGateway taskOrderApiGateway;
@Resource
private DrawingAnnotationApiGateway drawingAnnotationApiGateway;
/**
* 状态变更
@ -929,6 +932,31 @@ public class ChangeRecordServiceImpl extends ServiceImpl<ChangeRecordDao, Change
// 更新单据关联状态为 true
changeRecordBillService.billRelationStatus(visaId, true);
// 同步记录图纸绑定关系
syncDrawAnnotationBindRelation(visaId);
}
@Override
public void syncDrawAnnotationBindRelation(Long visaId) {
List<VisaChangeTempCreateReq.ChangeContextAndDescription> relationDrawAnnotation = getRelationDrawAnnotation(visaId);
if (CollectionUtils.isNotEmpty(relationDrawAnnotation)) {
Set<Long> annotationIds = relationDrawAnnotation.stream()
.map(VisaChangeTempCreateReq.ChangeContextAndDescription::getAnnotationId)
.collect(Collectors.toSet());
drawingAnnotationApiGateway.bindBusiness(visaId, annotationIds);
}
}
@Override
public void syncDrawAnnotationUnBindRelation(Long visaId) {
List<VisaChangeTempCreateReq.ChangeContextAndDescription> relationDrawAnnotation = getRelationDrawAnnotation(visaId);
if (CollectionUtils.isNotEmpty(relationDrawAnnotation)) {
Set<Long> annotationIds = relationDrawAnnotation.stream()
.map(VisaChangeTempCreateReq.ChangeContextAndDescription::getAnnotationId)
.collect(Collectors.toSet());
drawingAnnotationApiGateway.unbindBusiness(visaId, annotationIds);
}
}
private List<BpmnTaskDelegateAssigner> buildApprovers(List<VisaChangeApproveCreateReq.ApprovePersonInfo> approvePersonInfoList) {
@ -1537,6 +1565,8 @@ public class ChangeRecordServiceImpl extends ServiceImpl<ChangeRecordDao, Change
changeRecordBillService.deleteByVisaId(record.getId());
// 取消关联的图纸
deleteRelateDrawAnnotation(record.getId());
// 同步取消图纸关联至图纸方
syncDrawAnnotationUnBindRelation(record.getId());
}
/**
@ -1562,6 +1592,28 @@ public class ChangeRecordServiceImpl extends ServiceImpl<ChangeRecordDao, Change
return true;
}
/**
* 获取变更签证单关联的图纸
* @param visaId 变更签证Id
* @return 签证单关联的图纸批注
*/
private List<VisaChangeTempCreateReq.ChangeContextAndDescription> getRelationDrawAnnotation(Long visaId) {
List<ChangeRecordRelation> contentDescription = changeRecordRelationService.findByVisaAndVarName(visaId, VisaRelationFieldEnum.CONTENT_DESCRIPTION.name());
if (CollectionUtils.isNotEmpty(contentDescription)) {
return contentDescription.stream()
.map(item -> {
try {
return JSONObject.parseObject(item.getContent(), VisaChangeTempCreateReq.ChangeContextAndDescription.class);
} catch (Exception e) {
throw new ServiceException("发生内容说明解析失败");
}
})
.filter(item -> Objects.nonNull(item) && Objects.equals(item.getType(), 2))
.collect(Collectors.toList());
}
return Collections.emptyList();
}
private void validOperationPermission(Long visaId, Long personId, Long ouId, Long workspaceId) {
List<ChangeRecordConfirm> confirmUsers = changeRecordConfirmService.findByCondition(VisaConfirmDto.builder()
.visaId(visaId)
@ -1709,6 +1761,8 @@ public class ChangeRecordServiceImpl extends ServiceImpl<ChangeRecordDao, Change
changeRecordRelationService.deleteByVisaId(req.getVisaId(),
Arrays.asList(VisaRelationFieldEnum.ATTACHMENT, VisaRelationFieldEnum.CONTENT_DESCRIPTION));
changeRecordBillService.deleteByVisaId(req.getVisaId());
// 同步取消图纸关联至图纸方
syncDrawAnnotationUnBindRelation(record.getId());
}
/**