package jnpf.personnels.msg;

import jnpf.util.RandomUtil;
import org.apache.rocketmq.common.message.MessageConst;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author: peng.hao
 * @create: 2025/9/15
 */
@Component
@EnableBinding(PersonnelsConsumerSourceBinder.class)
public class PersonnelsConsumerSourceMsg {

    @Resource
    private PersonnelsConsumerSourceBinder rocketMessageChannelBinder;



    public void sendMessage(String jsonString) {
        Message<String> msg = org.springframework.integration.support.MessageBuilder.withPayload(jsonString)
                .setHeader(MessageConst.PROPERTY_KEYS, RandomUtil.uuId())
                .build();
        rocketMessageChannelBinder.output().send(msg);
    }

    public void sendMessageSecondmentWithdrawal(String jsonString) {
        Message<String> msg = org.springframework.integration.support.MessageBuilder.withPayload(jsonString)
                .setHeader(MessageConst.PROPERTY_KEYS, RandomUtil.uuId())
                .build();
        rocketMessageChannelBinder.secondmentWithdrawal().send(msg);
    }

    /**
     * 提前结束
     * @param jsonString
     */
    public void sendMessageEarlyEnd(String jsonString) {
        Message<String> msg = org.springframework.integration.support.MessageBuilder.withPayload(jsonString)
                .setHeader(MessageConst.PROPERTY_KEYS, RandomUtil.uuId())
                .build();
       // rocketMessageChannelBinder.secondmentEarlyEnd().send(msg);
    }

    /**
     * 延长借调
     * @param jsonString
     */
    public void sendMessageExtend(String jsonString) {
        Message<String> msg = org.springframework.integration.support.MessageBuilder.withPayload(jsonString)
                .setHeader(MessageConst.PROPERTY_KEYS, RandomUtil.uuId())
                .build();
       // rocketMessageChannelBinder.secondmentDelay().send(msg);
    }

    public void sendMessageOnboarding(String jsonString) {
        Message<String> msg = org.springframework.integration.support.MessageBuilder.withPayload(jsonString)
                .setHeader(MessageConst.PROPERTY_KEYS, RandomUtil.uuId())
                .build();
        rocketMessageChannelBinder.OnboardingOutput().send(msg);
    }

    public void sendMessageOnboardingFail(String jsonString) {
        Message<String> msg = org.springframework.integration.support.MessageBuilder.withPayload(jsonString)
                .setHeader(MessageConst.PROPERTY_KEYS, RandomUtil.uuId())
                .build();
        rocketMessageChannelBinder.OnboardingFailOutput().send(msg);
    }


}
