package com.zt.plat.module.qms.mq.consumer;

import com.zt.plat.module.qms.resource.material.constant.MaterialConstants;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.stereotype.Component;

import com.zt.plat.module.qms.business.bus.controller.vo.BusinessSampleEntrustRegistrationExtendRespVO;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessSampleEntrustRegistrationMapper;
import com.zt.plat.module.qms.enums.QmsCommonConstant;
import com.zt.plat.module.qms.mq.SampleEntrustRegistrationAssayCompleteMessage;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;

/**
 * <b>SampleEntrustRegistrationAssayCompleteConsumer</b>
 * 样品委托登记分析完成消费
 */
@Slf4j
@Component
@RocketMQMessageListener(
        topic = SampleEntrustRegistrationAssayCompleteMessage.TOPIC,
        consumerGroup = SampleEntrustRegistrationAssayCompleteMessage.TOPIC + "_CONSUMER"
)
public class SampleEntrustRegistrationAssayCompleteConsumer implements RocketMQListener<SampleEntrustRegistrationAssayCompleteMessage> {
	@Resource
	private RocketMQTemplate rocketMQTemplate;
	@Resource
	private BusinessSampleEntrustRegistrationMapper businessSampleEntrustRegistrationMapper;

	@Override
	public void onMessage(SampleEntrustRegistrationAssayCompleteMessage message) {
        log.info("委托登记分析完成[onMessage][消息内容({})]", message.toString());
        Long businessSampleEntrustRegistrationId = message.getBusinessSampleEntrustRegistrationId();
        //委托登记信息
        BusinessSampleEntrustRegistrationExtendRespVO businessSampleEntrustRegistration = businessSampleEntrustRegistrationMapper.selectExtendById(businessSampleEntrustRegistrationId);
        
        switch (businessSampleEntrustRegistration.getConfigEntrustSourceKey()) {
		case QmsCommonConstant.ENTRUST_SOURCE_JYWT: //检验委托
			// 物料验收
			rocketMQTemplate.syncSend(MaterialConstants.MQ_TOPIC_MATERIAL_ACCEPT_ASSAY_COMPLETE, message);
			break;
		case QmsCommonConstant.ENTRUST_SOURCE_XNT_TEMPORARY: //西南铜临时样
			
			break;

		default:
			break;
		}
        
        
	}

}
