package com.ruoyi.task.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.imports.PatentPubImportUtils;
import com.ruoyi.reportpub.service.IDPatentPubInfoService;
import com.ruoyi.system.service.IBladeRegionService;
import com.ruoyi.system.service.IDIpcTypeService;
import com.ruoyi.task.PatentSyncTask;


@Service("patentSyncTask")
public class PatentSyncTaskImpl implements PatentSyncTask {
	
	private static final Logger logger=LoggerFactory.getLogger(PatentSyncTaskImpl.class);
	
	@Autowired
	private RuoYiConfig ruoYiConfig;
	@Autowired
	private IDPatentPubInfoService dPatentPubInfoService;
	@Autowired
	private IBladeRegionService bladeRegionService;
	@Autowired
	private IDIpcTypeService dIpcTypeService;
	
	@Override
	public void syncPubPatent() {
		String beginDate="20210101";
		try {
			logger.debug("同步公开专利定时任务开始。。。");
			if (ruoYiConfig.getAutoImpPub()) {
				PatentPubImportUtils.impByIprd(ruoYiConfig, dPatentPubInfoService, dIpcTypeService, bladeRegionService, beginDate);
			}else {
				logger.warn("跳过同步公开专利任务");
			}
			
		} catch (Exception e) {
			logger.error("同步公开专利定时任务失败,"+e.getMessage(),e);
			throw new RuntimeException(e);
		}
	}

}
