package org.security.flow.business.delegate;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.security.flow.core.constant.ProcessConstant;
import org.security.ht.feign.IHtClient;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.SpringUtil;
import org.springframework.stereotype.Component;

@Slf4j
@Data
@Component
public class SendSccAlarmToDept implements JavaDelegate {
	@Override
	public void execute(DelegateExecution execution) {
		IHtClient htClient = SpringUtil.getBean(IHtClient.class);
		if (null == htClient) {
			throw new RuntimeException("找不到HtClient Bean！");
		}
		R result = htClient.sendAlarmNotice(execution.getVariable(ProcessConstant.BUSINESS_ID_KEY).toString());
		if (!result.isSuccess()) {
			throw new RuntimeException("推送警情至对应机构失败！");
		}
	}
}
