package com.ruoyi.process.aspect;
|
|
import com.ruoyi.inspect.pojo.InsOrder;
|
import com.ruoyi.process.service.InspectionOrderService;
|
import lombok.extern.slf4j.Slf4j;
|
import org.aspectj.lang.annotation.AfterReturning;
|
import org.aspectj.lang.annotation.Aspect;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
|
/**
|
* 成品下单和报告流程完成后,同步检验委托单中的衍生信息。
|
*
|
* cnas-process 依赖 inspect-server,因此通过切面监听,避免 inspect-server
|
* 反向依赖过程要求模块。
|
*/
|
@Aspect
|
@Component
|
@Slf4j
|
public class InspectionOrderSyncAspect {
|
|
@Resource
|
private InspectionOrderService inspectionOrderService;
|
|
@AfterReturning(value = "execution(* com.ruoyi.inspect.service.impl.InsOrderServiceImpl.upInsOrderOfState(..)) && args(insOrder)")
|
public void syncEntrustCode(InsOrder insOrder) {
|
if (insOrder == null || !Integer.valueOf(1).equals(insOrder.getState())) {
|
return;
|
}
|
try {
|
inspectionOrderService.syncEntrustCode(insOrder.getId());
|
} catch (Exception e) {
|
log.error("同步检验委托单委托编号失败,成品下单ID:{}", insOrder.getId(), e);
|
}
|
}
|
|
@AfterReturning(value = "execution(* com.ruoyi.inspect.service.impl.InsReportServiceImpl.ratifyReport(..)) && args(reportId, isRatify, ratifyTell)")
|
public void syncReportFile(Integer reportId, Integer isRatify, String ratifyTell) {
|
if (!Integer.valueOf(1).equals(isRatify)) {
|
return;
|
}
|
try {
|
inspectionOrderService.syncReportFile(reportId);
|
} catch (Exception e) {
|
// 报告批准不能因委托单附件同步失败而回滚,保留日志供后续重试。
|
log.error("同步检验委托单报告失败,报告ID:{}", reportId, e);
|
}
|
}
|
}
|