/*
package com.dxhy.core.task;

import com.dxhy.common.constant.DbConstant;
import com.dxhy.common.datasource.config.DynamicContextHolder;
import com.dxhy.core.job.entity.ScheduleJobEntity;
import com.dxhy.core.job.entity.TAcOrg;
import com.dxhy.core.job.service.EnterpriseControlRulesService;
import com.dxhy.core.job.service.ScheduleJobService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;

*/
/**
 * 发票对接规则引擎任务
 *//*

@Component("enterpriseControlRulesTask")
@Slf4j
public class EnterpriseControlRulesTask {

    @Resource
    private ScheduleJobService scheduleJobService;

    @Autowired
    private EnterpriseControlRulesService enterpriseControlRulesService;

    //增值税发票对接规则引擎
    public void vatInvoiceRules() {
        log.info("----------增值税发票对接规则引擎任务启动----------");
        DynamicContextHolder.push(DbConstant.BASICS_READ);
        ScheduleJobEntity scheduleJobEntity = scheduleJobService.queryByBeanName("enterpriseControlRulesTask", "vatInvoiceRules");
        if (scheduleJobEntity != null && "0".equals(scheduleJobEntity.getJobStatus())) {
            try {
                scheduleJobEntity.setJobStatus("1");
                DynamicContextHolder.push(DbConstant.BASICS_WRITE);
                scheduleJobService.updateById(scheduleJobEntity);
                //获取需要执行规则引擎的购方税号信息
                List<TAcOrg> taxNoList = enterpriseControlRulesService.getTaxNo();
                if (!CollectionUtils.isEmpty(taxNoList)) {
                    taxNoList.stream().forEach(taxInformation -> {
                        log.info("增值税发票对接规则引擎，税号信息taxNo{}", taxInformation.getTaxno());
                        enterpriseControlRulesService.vatInvoiceRules(taxInformation);
                    });
                }
                log.info("----------增值税发票对接规则引擎任务结束----------");
            } catch (Exception e) {
                log.error("增值税发票对接规则引擎异常,e:{}", e.getMessage());
            } finally {
                log.info("增值税发票对接规则引擎-----重置执行状态");
                scheduleJobEntity.setJobStatus("0");
                DynamicContextHolder.push(DbConstant.BASICS_WRITE);
                scheduleJobService.updateById(scheduleJobEntity);
            }
        }
    }

    //非增值税发票对接规则引擎
    public void notInvoiceRules() {
        log.info("----------非增值税发票对接规则引擎任务启动----------");
        DynamicContextHolder.push(DbConstant.BASICS_READ);
        ScheduleJobEntity scheduleJobEntity = scheduleJobService.queryByBeanName("enterpriseControlRulesTask", "notInvoiceRules");
        if (scheduleJobEntity != null && "0".equals(scheduleJobEntity.getJobStatus())) {
            try {
                scheduleJobEntity.setJobStatus("1");
                DynamicContextHolder.push(DbConstant.BASICS_WRITE);
                scheduleJobService.updateById(scheduleJobEntity);
                //获取需要执行规则引擎的购方税号信息
                List<TAcOrg> taxNoList = enterpriseControlRulesService.getTaxNo();
                if (!CollectionUtils.isEmpty(taxNoList)) {
                    taxNoList.stream().forEach(taxInformation -> {
                        log.info("非增值税发票对接规则引擎，税号信息taxNo{}", taxInformation.getTaxno());
                        enterpriseControlRulesService.notInvoiceRules(taxInformation);
                    });
                }
                log.info("----------非增值税发票对接规则引擎任务结束----------");
            } catch (Exception e) {
                log.error("非增值税发票对接规则引擎异常,e:{}", e.getMessage());
            } finally {
                log.info("非增值税发票对接规则引擎-----重置执行状态");
                scheduleJobEntity.setJobStatus("0");
                DynamicContextHolder.push(DbConstant.BASICS_WRITE);
                scheduleJobService.updateById(scheduleJobEntity);
            }
        }
    }
}
*/
