package com.zt.plat.module.qms.business.bus.liteflow.sample.entrust;

import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import com.zt.plat.module.qms.business.bus.liteflow.param.SampleFlowParam;
import com.zt.plat.module.qms.business.bus.liteflow.slot.SampleEntrustContext;
import com.zt.plat.module.qms.business.bus.service.SampleFlowService;
import com.zt.plat.module.qms.enums.QmsCommonConstant;

import jakarta.annotation.Resource;

@LiteflowComponent(id = "sampleEntrustReceiveDataCmp", name = "中心接收样品委托的样品数据")
public class SampleEntrustReceiveDataCmp extends NodeComponent {
	
	@Resource
	private SampleFlowService sampleFlowService;

	@Override
	public void process() throws Exception {
		SampleEntrustContext sampleEntrustContext = this.getContextBean(SampleEntrustContext.class);
		SampleFlowParam sampleFlowParam = new SampleFlowParam();
		sampleFlowParam.setCurrentSampleFlowKey(QmsCommonConstant.FLOW_NODE_CENTER_RECEIVE);
		sampleFlowParam.setSampleSourceType(2);
		sampleFlowParam.setSampleFlowInfoList(sampleEntrustContext.getSampleFlowInfoList());
		sampleFlowService.sampleFlow(sampleFlowParam);
	}

	@Override
	public boolean isAccess() {
		SampleEntrustContext sampleEntrustContext = this.getContextBean(SampleEntrustContext.class);
		if (sampleEntrustContext.getIsReceiveSample().equals(1)) {
			return true;
		}
		return false;
	}

}
