//package xiaoqu.home.open.task;
//
//import java.util.Date;
//import java.util.List;
//
//import org.frameworkset.elasticsearch.boot.BBossESStarter;
//import org.frameworkset.elasticsearch.client.ClientInterface;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//
//import lombok.extern.slf4j.Slf4j;
//import xiaoqu.home.open.model.auto.HardwareLog;
//import xiaoqu.home.open.model.auto.HardwareOldTestLog;
//import xiaoqu.home.open.model.auto.PaperUseLog;
//import xiaoqu.home.open.model.auto.ReadCountSave;
//import xiaoqu.home.open.service.IHardwareLogService;
//import xiaoqu.home.open.service.IPaperUseLogService;
//import xiaoqu.home.open.service.impl.HardwareOldTestLogServiceImpl;
//import xiaoqu.home.open.service.impl.ReadCountSaveServiceImpl;
//
//@Component
//@Slf4j(topic = "task")
//public class ScheduledTask2 {
//
//	@Autowired
//	private BBossESStarter bbossESStarter;
//	@Autowired
//	private HardwareOldTestLogServiceImpl hardwareOldTestLogServiceImpl;
//	@Autowired
//	private ReadCountSaveServiceImpl readCountSaveServiceImpl;
//	@Autowired
//	private IHardwareLogService hardwareLogServiceImpl;
//
//	@Scheduled(cron = "0/1 * * * * ?")
//	public void mqttMessageDown() {
//		ClientInterface clientUtil = bbossESStarter.getRestClient();
//		ReadCountSave readCountSave = readCountSaveServiceImpl.getById(1);
//		long readCount = readCountSave.getReadcount();
//		QueryWrapper<HardwareOldTestLog> wrappersQ = Wrappers.query();
//		wrappersQ.gt("id", readCount);
//		wrappersQ.last("limit 10000");
//		wrappersQ.orderByAsc("id");
//		long maxId = readCount;
//		List<HardwareOldTestLog> list = hardwareOldTestLogServiceImpl.list(wrappersQ);
//		if (list.size() > 0) {
//			maxId = list.get(list.size()-1).getId();
//			log.info("本次最大ID=" + maxId);
//			clientUtil.addDocuments("hardware_old_test_log",list);
//			readCountSave.setReadcount(maxId);
//			readCountSave.setReadtime(new Date());
//			readCountSaveServiceImpl.updateById(readCountSave);
//		}
//	}
//	@Scheduled(cron = "0/1 * * * * ?")
//	public void HardwareLog() {
//		ClientInterface clientUtil = bbossESStarter.getRestClient();
//		ReadCountSave readCountSave = readCountSaveServiceImpl.getById(2);
//		long readCount = readCountSave.getReadcount();
//		QueryWrapper<HardwareLog> wrappersQ = Wrappers.query();
//		wrappersQ.gt("id", readCount);
//		wrappersQ.last("limit 10000");
//		wrappersQ.orderByAsc("id");
//		long maxId = readCount;
//		List<HardwareLog> list = hardwareLogServiceImpl.list(wrappersQ);
//		if (list.size() > 0) {
//			maxId = list.get(list.size()-1).getId();
//			log.info("本次最大ID=" + maxId);
//			log.info(clientUtil.addDocuments("hardwarelog_new",list));
//			readCountSave.setReadcount(maxId);
//			readCountSave.setReadtime(new Date());
//			readCountSaveServiceImpl.updateById(readCountSave);
//		}
//	}
//	@Autowired
//	private IPaperUseLogService paperUseLogServiceImpl;
//
//	@Scheduled(cron = "0/1 * * * * ?")
//	public void PaperUseLog() {
//		ClientInterface clientUtil = bbossESStarter.getRestClient();
//		ReadCountSave readCountSave = readCountSaveServiceImpl.getById(3);
//		long readCount = readCountSave.getReadcount();
//		QueryWrapper<PaperUseLog> wrappersQ = Wrappers.query();
//		wrappersQ.gt("id", readCount);
//		wrappersQ.last("limit 10000");
//		wrappersQ.orderByAsc("id");
//		long maxId = readCount;
//		List<PaperUseLog> list = paperUseLogServiceImpl.list(wrappersQ);
//		if (list.size() > 0) {
//			maxId = list.get(list.size()-1).getId();
//			log.info("本次最大ID=" + maxId);
//			log.info(clientUtil.addDocuments("paperuselog",list));
//			readCountSave.setReadcount(maxId);
//			readCountSave.setReadtime(new Date());
//			readCountSaveServiceImpl.updateById(readCountSave);
//		}
//	}
//	
//}
