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

import java.util.ArrayList;
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.BusinessAssayParameterDataDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayProjectDataDO;
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.BusinessAssayTaskParameterDataDO;
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.dataobject.BusinessSampleEntrustUnStandardProjectDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSubParentSampleAssessmentDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSubSampleAssessmentDO;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayParameterDataMapper;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayProjectDataMapper;
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.BusinessAssayTaskParameterDataMapper;
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.dal.mapper.BusinessSampleEntrustUnStandardProjectMapper;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessSubParentSampleAssessmentMapper;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessSubSampleAssessmentMapper;
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 BusinessSubParentSampleAssessmentMapper businessSubParentSampleAssessmentMapper;
	
	@Resource
	private BusinessSubSampleAssessmentMapper businessSubSampleAssessmentMapper;
	
	@Resource
	private BusinessAssayTaskParameterDataMapper businessAssayTaskParameterDataMapper;
	
	@Resource
	private BusinessAssayProjectDataMapper businessAssayProjectDataMapper;
	
	@Resource
	private BusinessAssayParameterDataMapper businessAssayParameterDataMapper;
	
	@Resource
	private BusinessSampleEntrustUnStandardProjectMapper businessSampleEntrustUnStandardProjectMapper;
	
	@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<BusinessSubParentSampleAssessmentDO> saveBusinessSubParentSampleAssessmentList = sampleTaskAssignContext.getSaveBusinessSubParentSampleAssessmentList();
		
		List<BusinessSubSampleAssessmentDO> saveBusinessSubSampleAssessmentList = sampleTaskAssignContext.getSaveBusinessSubSampleAssessmentList();
		
		List<BusinessAssayTaskDO> savebusinessAssayTaskList = sampleTaskAssignContext.getSaveBusinessAssayTaskList();
		
		List<BusinessAssayTaskDO> updateBusinessAssayTaskList = sampleTaskAssignContext.getUpdateBusinessAssayTaskList();
		
		List<BusinessAssayTaskDetailDO> businessAssayTaskDetailList = sampleTaskAssignContext.getBusinessAssayTaskDetailList();
		
		List<BusinessAssayTaskDataDO> saveBusinessAssayTaskDataList = sampleTaskAssignContext.getSaveBusinessAssayTaskDataList();
		
		List<BusinessAssayTaskDataDO> businessAssayTaskDataList = sampleTaskAssignContext.getBusinessAssayTaskDataList();
		
		List<BusinessAssayTaskParameterDataDO> saveBusinessAssayTaskParameterDataList = sampleTaskAssignContext.getSaveBusinessAssayTaskParameterDataList();
		
		List<BusinessAssayProjectDataDO> saveBusinessAssayProjectDataList = sampleTaskAssignContext.getSaveBusinessAssayProjectDataList();
		
		List<BusinessAssayParameterDataDO> saveBusinessAssayParameterDataList = sampleTaskAssignContext.getSaveBusinessAssayParameterDataList();
		
		List<BusinessSampleEntrustUnStandardProjectDO> saveBusinessSampleEntrustUnStandardProjectList = sampleTaskAssignContext.getSaveBusinessSampleEntrustUnStandardProjectList();
		
		List<BusinessSampleEntrustUnStandardProjectDO> updateBusinessSampleEntrustUnStandardProjectList = sampleTaskAssignContext.getUpdateBusinessSampleEntrustUnStandardProjectList();
		
		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();
		

		//需要删除的分析任务
		List<Long> removeAssayTaskDataIdList = sampleTaskAssignContext.getRemoveAssayTaskDataIdList();

		//需要删除的分析任务参数
		List<Long> removeAssayTaskParameterDataIdList = sampleTaskAssignContext.getRemoveAssayTaskParameterDataIdList();

		//需要删除的分析任务检测项目
		List<Long> removeAssayProjectIdList = sampleTaskAssignContext.getRemoveAssayProjectIdList();
		
		//需要删除的分析任务检测项目参数
		List<Long> removeAssayParameterIdList = sampleTaskAssignContext.getRemoveAssayParameterIdList();

		//需要删除的子样判定
		List<Long> removeSubSampleAssessmentIdList = sampleTaskAssignContext.getRemoveSubParentSampleAssessmentIdList();

		//需要删除的分样判定
		List<Long> removeSubParentSampleAssessmentIdList = sampleTaskAssignContext.getRemoveSubParentSampleAssessmentIdList();
		
		if (CollUtil.isNotEmpty(saveBusinessSubParentSampleAssessmentList)) {
			this.businessSubParentSampleAssessmentMapper.insertBatch(saveBusinessSubParentSampleAssessmentList);
		}
		
		if (CollUtil.isNotEmpty(saveBusinessSubSampleAssessmentList)) {
			this.businessSubSampleAssessmentMapper.insertBatch(saveBusinessSubSampleAssessmentList);
		}
		
		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(saveBusinessAssayTaskDataList)) {
			this.businessAssayTaskDataMapper.insertBatch(saveBusinessAssayTaskDataList);
		}
		
		if (CollUtil.isNotEmpty(businessAssayTaskDataList)) {
			this.businessAssayTaskDataMapper.updateBatch(businessAssayTaskDataList);
		}
		
		if (CollUtil.isNotEmpty(saveBusinessAssayTaskParameterDataList)) {
			this.businessAssayTaskParameterDataMapper.insertBatch(saveBusinessAssayTaskParameterDataList);
		}
		
		if (CollUtil.isNotEmpty(saveBusinessAssayProjectDataList)) {
			this.businessAssayProjectDataMapper.insertBatch(saveBusinessAssayProjectDataList);
		}
		
		if (CollUtil.isNotEmpty(saveBusinessAssayParameterDataList)) {
			this.businessAssayParameterDataMapper.insertBatch(saveBusinessAssayParameterDataList);
		}
		
		if (CollUtil.isNotEmpty(saveBusinessSampleEntrustUnStandardProjectList)) {
			this.businessSampleEntrustUnStandardProjectMapper.insertBatch(saveBusinessSampleEntrustUnStandardProjectList);
		}
		
		if (CollUtil.isNotEmpty(updateBusinessSampleEntrustUnStandardProjectList)) {
			this.businessSampleEntrustUnStandardProjectMapper.updateBatch(updateBusinessSampleEntrustUnStandardProjectList);
		}
		
		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);
		}
		
		if (CollUtil.isNotEmpty(removeAssayTaskDataIdList)) {
			this.businessAssayTaskDataMapper.deleteByIds(removeAssayTaskDataIdList);
		}
		
		if (CollUtil.isNotEmpty(removeAssayTaskParameterDataIdList)) {
			this.businessAssayTaskParameterDataMapper.deleteByIds(removeAssayTaskParameterDataIdList);
		}
		
		if (CollUtil.isNotEmpty(removeAssayProjectIdList)) {
			this.businessAssayProjectDataMapper.deleteByIds(removeAssayProjectIdList);
		}
		
		if (CollUtil.isNotEmpty(removeAssayParameterIdList)) {
			this.businessAssayParameterDataMapper.deleteByIds(removeAssayParameterIdList);
		}
		
		if (CollUtil.isNotEmpty(removeSubSampleAssessmentIdList)) {
			this.businessSubSampleAssessmentMapper.deleteByIds(removeSubSampleAssessmentIdList);
		}
		
		if (CollUtil.isNotEmpty(removeSubParentSampleAssessmentIdList)) {
			this.businessSubParentSampleAssessmentMapper.deleteByIds(removeSubParentSampleAssessmentIdList);
		}
		
	}

}
