package digital.laboratory.platform.inspection.listener;

import digital.laboratory.platform.inspection.event.AuditDataExecutionEvent;
import digital.laboratory.platform.inspection.service.TaskInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/***
 * 审核数据实验事件监听器 在审批数据成功后需要执行的方法
 */
@Slf4j
@Component
public class AuditDataExecutionEventListener implements ApplicationListener<AuditDataExecutionEvent> {

    @Resource
    private TaskInfoService taskInfoService;


    @Override
    public void onApplicationEvent(AuditDataExecutionEvent event) {
        log.info("审核数据 监听器执行中 ..........................");
        try {
            taskInfoService.createUploadItem(event.getSampleNoList());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
