package com.gzzn.omms.msgexchangeapi.scheduled; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import com.gzzn.omms.msgexchangeapi.dao.CminmsgDao; import com.gzzn.omms.msgexchangeapi.dao.CminmsgHstDao; import com.gzzn.omms.msgexchangeapi.service.ICminmsgHstService; /** * cminmsgs 消息转历史 * @author zhouxiunai * */ @Component @Async public class CminmsgsHisScheduled { @Autowired ICminmsgHstService cminmsgHstService; @Autowired CminmsgDao cminmsgDao; @Autowired private CminmsgHstDao cminmsgHstdDao; private static Logger logger = LoggerFactory.getLogger(CminmsgsHisScheduled.class); @Scheduled(cron = "${scheduled.cminmsgHisCron}") public void scheduled() { logger.info("开始cminmsgs消息转历史.."); cminmsgHstdDao.moveToHistory(); // List lsCminmsg = null; // do // { // Date dateNow = new Date(); // lsCminmsg = cminmsgDao.findByCminmsgsDateProcessedIsNotNullAndCminmsgsDateReceivedBefore // ( // dateNow,new PageRequest(0,300) // ); // if(CollectionUtils.isEmpty(lsCminmsg)) // { // continue; // } // List successLs = cminmsgHstService.insert( // cminmsgHstService.toCminmsgHstLs(lsCminmsg) // ); // //从原始表删除成功列表 // if(!CollectionUtils.isEmpty(successLs)) // { // List waitDeleteLs = successLs.stream() // .map(node->{ // Cminmsg cminmsg = new Cminmsg(); // BeanUtils.copyProperties(node, cminmsg); // return cminmsg; // }) // .collect(Collectors.toList()); // cminmsgDao.delete(waitDeleteLs); // } // } // while(!CollectionUtils.isEmpty(lsCminmsg)); logger.info("结束本次cminmsgs消息转历史.."); }//end shceduled }