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.framework.common.exception.ServiceException;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSampleEntrustRegistrationDO;
import com.zt.plat.module.qms.business.bus.liteflow.slot.SampleEntrustContext;
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigEntrustSourceDO;
import com.zt.plat.module.qms.enums.QmsCommonConstant;

/**
 * 样品委托检查
 */
@LiteflowComponent(id = "sampleEntrustCheckCmp", name = "样品委托检查")
public class SampleEntrustCheckCmp extends NodeComponent {

	@Override
	public void process() throws Exception {
		//获取样品委托上下文
		SampleEntrustContext sampleEntrustContext = this.getContextBean(SampleEntrustContext.class);
		//获取样品委托单
		BusinessSampleEntrustRegistrationDO sampleEntrustRegistration = sampleEntrustContext.getSampleEntrustRegistration();
		
		
		if (sampleEntrustRegistration.getConfigEntrustSourceId() == null) {
			throw new ServiceException(1_032_100_000, "委托来源id不允许为空");
		}
//		ConfigEntrustSourceDO configEntrustSource = sampleEntrustContext.getConfigEntrustSourceById(sampleEntrustRegistration.getConfigEntrustSourceId());
		ConfigEntrustSourceDO configEntrustSource = sampleEntrustContext.getConfigEntrustSource();
		if (configEntrustSource == null) {
			throw new ServiceException(1_032_100_000, "委托来源id不正确");
		}
		
		sampleEntrustRegistration.setDataCheckStatus(QmsCommonConstant.SUCCESS);

	}

}
