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

import java.util.List;

import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;

import cn.hutool.core.collection.CollUtil;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDataDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDetailDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCCoefficientDataDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCCoefficientParameterDataDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCManagementDataDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCManagementParameterDataDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCManagementProjectDataDO;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayTaskDataMapper;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayTaskDetailMapper;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayTaskMapper;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessQCCoefficientDataMapper;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessQCCoefficientParameterDataMapper;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessQCManagementDataMapper;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessQCManagementParameterDataMapper;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessQCManagementProjectDataMapper;
import com.zt.plat.module.qms.business.bus.liteflow.slot.SampleTaskAssignContext;
import jakarta.annotation.Resource;

@LiteflowComponent(id = "sampleTaskAssignDataSaveOrUpdateCmp", name = "样品任务分配数据保存或更新")
public class SampleTaskAssignDataSaveOrUpdateCmp extends NodeComponent {
	
	@Resource
	private BusinessAssayTaskMapper businessAssayTaskMapper;
	
	@Resource
	private BusinessAssayTaskDetailMapper businessAssayTaskDetailMapper;
	
	@Resource
	private BusinessAssayTaskDataMapper businessAssayTaskDataMapper;
	
	@Resource
	private BusinessQCCoefficientDataMapper businessQCCoefficientDataMapper;
	
	@Resource
	private BusinessQCCoefficientParameterDataMapper  businessQCCoefficientParameterDataMapper;
	
	@Resource
	private BusinessQCManagementDataMapper businessQCManagementDataMapper;
	
	@Resource
	private BusinessQCManagementProjectDataMapper businessQCManagementProjectDataMapper;
	
	@Resource
	private BusinessQCManagementParameterDataMapper businessQCManagementParameterDataMapper;

	@Override
	public void process() throws Exception {
		SampleTaskAssignContext sampleTaskAssignContext = this.getContextBean(SampleTaskAssignContext.class);
		
		List<BusinessAssayTaskDO> savebusinessAssayTaskList = sampleTaskAssignContext.getSaveBusinessAssayTaskList();
		
		List<BusinessAssayTaskDO> updateBusinessAssayTaskList = sampleTaskAssignContext.getUpdateBusinessAssayTaskList();
		
		List<BusinessAssayTaskDetailDO> businessAssayTaskDetailList = sampleTaskAssignContext.getBusinessAssayTaskDetailList();
		
		List<BusinessAssayTaskDataDO> businessAssayTaskDataList = sampleTaskAssignContext.getBusinessAssayTaskDataList();
		
		List<BusinessQCCoefficientDataDO> businessQCCoefficientDataList = sampleTaskAssignContext.getBusinessQCCoefficientDataList();
		
		List<BusinessQCCoefficientParameterDataDO> businessQCCoefficientParameterDataList = sampleTaskAssignContext.getBusinessQCCoefficientParameterDataList();
		
		List<BusinessQCManagementDataDO> businessQCManagementDataDOList = sampleTaskAssignContext.getBusinessQCManagementDataDOList();
		
		List<BusinessQCManagementProjectDataDO> businessQCManagementProjectDataDOList = sampleTaskAssignContext.getBusinessQCManagementProjectDataDOList();
		
		List<BusinessQCManagementParameterDataDO> businessQCManagementParameterDataDOList = sampleTaskAssignContext.getBusinessQCManagementParameterDataDOList();
		
		if (CollUtil.isNotEmpty(savebusinessAssayTaskList)) {
			this.businessAssayTaskMapper.insertBatch(savebusinessAssayTaskList);
		}
		
		if (CollUtil.isNotEmpty(updateBusinessAssayTaskList)) {
			this.businessAssayTaskMapper.updateBatch(updateBusinessAssayTaskList);
		}

		if (CollUtil.isNotEmpty(businessAssayTaskDetailList)) {
			this.businessAssayTaskDetailMapper.insertBatch(businessAssayTaskDetailList);
		}
		
		if (CollUtil.isNotEmpty(businessAssayTaskDataList)) {
			this.businessAssayTaskDataMapper.updateBatch(businessAssayTaskDataList);
		}
		
		if (CollUtil.isNotEmpty(businessQCCoefficientDataList)) {
			this.businessQCCoefficientDataMapper.insertBatch(businessQCCoefficientDataList);
		}
		
		if (CollUtil.isNotEmpty(businessQCCoefficientParameterDataList)) {
			this.businessQCCoefficientParameterDataMapper.insertBatch(businessQCCoefficientParameterDataList);
		}
		
		if (CollUtil.isNotEmpty(businessQCManagementDataDOList)) {
			this.businessQCManagementDataMapper.insertBatch(businessQCManagementDataDOList);
		}
		
		if (CollUtil.isNotEmpty(businessQCManagementProjectDataDOList)) {
			this.businessQCManagementProjectDataMapper.insertBatch(businessQCManagementProjectDataDOList);
		}
		
		if (CollUtil.isNotEmpty(businessQCManagementParameterDataDOList)) {
			this.businessQCManagementParameterDataMapper.insertBatch(businessQCManagementParameterDataDOList);
		}
	}

}
