package com.yifu.cloud.plus.v1.job.compont;


import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprArchivesProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @Author hgw
 * @Description 定时任务具体执行类
 * @Date 2022-11-24 15:03:14
 * @Param
 * @return
 **/
@Component(value = "archiveTask")
@Slf4j
@EnableConfigurationProperties(DaprArchivesProperties.class)
public class ArchiveTask {

	@Autowired
	private DaprArchivesProperties daprArchivesProperties;


	public void updateEmployeeAgeTask() {
		log.info("-------------每年1月1号刷新在职和离职人员的年龄信息-定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeeinfo/inner/updateEmployeeAgeTask", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每年1月1号刷新在职和离职人员的年龄信息-定时任务结束------------");
	}
	/**
	 * @Author hgw
	 * @Description 每月1号清理人员档案、项目档案的薪资状态
	 * @Date 2022-11-24 15:06:37
	 * @Param
	 **/
	public void everyMonthUpdateSalaryStatus() {
		log.info("-------------每月1号清理人员档案、项目档案的薪资状态-定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeeinfo/inner/everyMonthUpdateSalaryStatus", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每月1号清理人员档案、项目档案的薪资状态-定时任务结束------------");
	}

	/**
	 * @Author hgw
	 * @Description 每天更新人员档案、项目档案的过期合同为2不在用
	 * @Date 2022-11-24 15:06:37
	 * @Param
	 **/
	public void everyDayUpdateEmployeeContractStatus() {
		log.info("-------------每天更新人员档案、项目档案的过期合同为2不在用-定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeeinfo/inner/everyDayUpdateEmployeeContractStatus", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每天更新人员档案、项目档案的过期合同为2不在用-定时任务结束------------");
	}


	public void retireeRemind() {
		log.info("-------------每日凌晨1点人员退休提醒-定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeeretirement/inner/retireeRemind", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每日凌晨1点人员退休提醒-定时任务开始------------");
	}

	public void everyMonthUpdateRoster() {
		log.info("-------------每月26号更新人员花名册-定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/tpersonnelroster/inner/everyMonthUpdateRoster", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每月26号更新人员花名册-定时任务开始------------");
	}

	public void everyDayCreateComlpeteMonitor() {
		log.info("-------------每日刷新档案完整监控数据------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/tcompletemonitor/inner/createComlpeteMonitor", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每日刷新档案完整监控数据-定时任务开始------------");
	}

	public void pushWxContractConfrimMessage() {
		log.info("-------------每天9点推送合同待签订信息------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeecontractpre/inner/pushWxConfrimMessage", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每天9点推送合同待签订信息-定时任务开始------------");
	}

	public void pushDisConfrimContracts() {
		log.info("-------------每天15.00/15.20点推送合同待签订信息------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeecontractpre/inner/pushDisConfrimContracts", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每天15.00/15.20点推送合同待签订信息-定时任务开始------------");
	}

	public void everyDayCreateRiskMonitor() {
		log.info("-------------每日刷新运营风险管控数据------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/triskmonitor/inner/createRiskMonitor", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每日刷新运营风险管控数据-定时任务开始------------");
	}

	/**
	 * @Author fxj
	 * @Description 每天10点刷新合同续签待办信息到微信
	 * @Date 16:06 2025/8/15
	 * @Param
	 * @return
	**/
	public void everyDaypushContractAlertToWx() {
		log.info("-------------每天刷新合同续签待办信息到微信-定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/tempcontractalert/inner/pushContractAlertToWx","", Void.class, SecurityConstants.FROM_IN);
		log.info("-------------每天刷新合同续签待待办信息到微信-定时任务结束------------");
	}

	/**
	 * @Author huych
	 * @Description 每日晚23:00自动撤销超时电子签署任务
	 * @Date 2025-10-15
	 * @Param
	 * @return
	**/
	public void autoRevokeElectronicSignTask() {
		log.info("-------------每日晚23:00自动撤销超时电子签署任务-定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeecontractpre/inner/autoRevokeElectronicSign", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每日晚23:00自动撤销超时电子签署任务-定时任务结束------------");
	}

	/**
	 * @Author huych
	 * @Description 每日早9点通知前端客服前一日撤销电子签署情况
	 * @Date 2025-10-15
	 * @Param
	 * @return
	**/
	public void notifyRevokedElectronicSignTask() {
		log.info("-------------每日早9点通知前端客服前一日撤销电子签署情况-定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeecontractpre/inner/notifyRevokedElectronicSign", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每日早9点通知前端客服前一日撤销电子签署情况-定时任务结束------------");
	}

	/**
	 * @Author huych
	 * @Description 每日早9点电子签合同即将超期提醒
	 * @Date 2025-10-15
	 * @Param
	 * @return
	**/
	public void electronicSignExpiringReminderTask() {
		log.info("-------------每日早9点电子签合同即将超期提醒-定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeecontractpre/inner/electronicSignExpiringReminder", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每日早9点电子签合同即将超期提醒-定时任务结束------------");
	}

	/**
	 * @Author hgw
	 * @Description 每日定时获取法大大模板和详情
	 * @Date 2025-10-20 16:15:32
	 * @Param
	 **/
	public void everyDayGetFascTemplate() {
		log.info("-------------每日定时获取法大大模板和详情-定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/fasc/inner/everyDayGetFascTemplate", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每日定时获取法大大模板和详情-定时任务结束------------");
	}

	/**
	 * @Author fxj
	 * @Description 每天15、15：20 续签待办发起电子签自动发起任务
	 * @Date 15:25 2026/2/24
	**/
	public void pushDisConfrimContractsNew() {
		log.info("-------------每天11、15.00、15.20点续签待办发起电子签自动发起任务--定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeecontractprenew/inner/pushDisConfrimContracts", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每天11、15.00、15.20点续签待办发起电子签自动发起任务--定时任务截止------------");
	}

	/**
	 * @Author fxj
	 * @Description 每日晚23:00自动撤销超时电子签署任务(当前时间正好为合同开始日期一个月的数据)
	 * @Date 15:25 2026/2/24
	 **/
	public void autoRevokeElectronicSign() {
		log.info("-------------每日晚23:00自动撤销超时电子签署任务--定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeecontractprenew/inner/autoRevokeElectronicSign", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每日晚23:00自动撤销超时电子签署任务--定时任务截止------------");
	}

	/**
	 * @Author fxj
	 * @Description 每日早9点通知前端客服前一日撤销电子签署情况
	 * @Date 15:25 2026/2/24
	 **/
	public void notifyRevokedElectronicSign() {
		log.info("-------------每日早9点通知前端客服前一日撤销电子签署情况--定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeecontractprenew/inner/notifyRevokedElectronicSign", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每日早9点通知前端客服前一日撤销电子签署情况--定时任务截止------------");
	}

	/**
	 * @Author fxj
	 * @Description 每日早9点电子签合同即将超期提醒
	 * @Date 15:25 2026/2/24
	 **/
	public void electronicSignExpiringReminder() {
		log.info("-------------每日早9点电子签合同即将超期提醒--定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeecontractprenew/inner/electronicSignExpiringReminder", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每日早9点电子签合同即将超期提醒--定时任务截止------------");
	}

	/**
	 * @Author fxj
	 * @Description 每日9点统一推送续签确认信息
	 * @Date 15:25 2026/2/24
	 **/
	public void pushWxConfrimMessage() {
		log.info("-------------每日9点统一推送续签确认信息--定时任务开始------------");
		HttpDaprUtil.invokeMethodPost(daprArchivesProperties.getAppUrl(), daprArchivesProperties.getAppId(),
				"/temployeecontractprenew/inner/pushWxConfrimMessage", "", Object.class,
				SecurityConstants.FROM_IN);
		log.info("-------------每日9点统一推送续签确认信息--定时任务截止------------");
	}
}