增加定时消息表CMINMSGS已经处理数据 转 历史表操作
This commit is contained in:
@@ -3,6 +3,7 @@ package com.gzzn.omms.msgexchangeapi.dao;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
|
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
|
||||||
@@ -15,4 +16,6 @@ public interface CminmsgDao extends CrudRepository<Cminmsg, Long> {
|
|||||||
public List<Cminmsg> findByCminmsgsDateReceivedAfterOrderByCminmsgsDateReceived(Date date);
|
public List<Cminmsg> findByCminmsgsDateReceivedAfterOrderByCminmsgsDateReceived(Date date);
|
||||||
|
|
||||||
public List<Cminmsg> findByCminmsgsIdGreaterThanAndCminmsgsDateProcessedIsNull(Long id);
|
public List<Cminmsg> findByCminmsgsIdGreaterThanAndCminmsgsDateProcessedIsNull(Long id);
|
||||||
|
|
||||||
|
public List<Cminmsg> findByCminmsgsDateProcessedIsNotNullAndCminmsgsDateReceivedBefore(Date date,Pageable pageable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.gzzn.omms.msgexchangeapi.dao;
|
||||||
|
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
|
import com.gzzn.omms.msgexchangeapi.entity.CminmsgHst;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public interface CminmsgHstDao extends CrudRepository<CminmsgHst, Long> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
package com.gzzn.omms.msgexchangeapi.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The persistent class for the CMINMSGS_HST database table.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name="CMINMSGS_HST")
|
||||||
|
public class CminmsgHst implements Serializable {
|
||||||
|
private static final long serialVersionUID = 2L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name="CMINMSGS_ID")
|
||||||
|
private long cminmsgsId;
|
||||||
|
|
||||||
|
@Lob
|
||||||
|
@Column(name="CMINMSGS_CLOB_MSG")
|
||||||
|
private String cminmsgsClobMsg;
|
||||||
|
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
@Column(name="CMINMSGS_DATE_PROCESSED")
|
||||||
|
private Date cminmsgsDateProcessed;
|
||||||
|
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
@Column(name="CMINMSGS_DATE_RECEIVED")
|
||||||
|
private Date cminmsgsDateReceived;
|
||||||
|
|
||||||
|
@Column(name="CMINMSGS_STATUS")
|
||||||
|
private String cminmsgsStatus;
|
||||||
|
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
@Column(name="CMINMSGS_SUBSYSTEM_DATE_SENT")
|
||||||
|
private Date cminmsgsSubsystemDateSent;
|
||||||
|
|
||||||
|
@Column(name="CMINMSGS_SUBSYSTEM_NAME")
|
||||||
|
private String cminmsgsSubsystemName;
|
||||||
|
|
||||||
|
@Column(name="CMINMSGS_SUBSYSTEM_SEQUENCE")
|
||||||
|
private int cminmsgsSubsystemSequence;
|
||||||
|
|
||||||
|
@Column(name="CMINMSGS_SUBSYSTEM_SUBTYPE")
|
||||||
|
private String cminmsgsSubsystemSubtype;
|
||||||
|
|
||||||
|
@Column(name="CMINMSGS_SUBSYSTEM_TYPE")
|
||||||
|
private String cminmsgsSubsystemType;
|
||||||
|
|
||||||
|
public CminmsgHst() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCminmsgsId() {
|
||||||
|
return this.cminmsgsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCminmsgsId(long cminmsgsId) {
|
||||||
|
this.cminmsgsId = cminmsgsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCminmsgsClobMsg() {
|
||||||
|
return this.cminmsgsClobMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCminmsgsClobMsg(String cminmsgsClobMsg) {
|
||||||
|
this.cminmsgsClobMsg = cminmsgsClobMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCminmsgsDateProcessed() {
|
||||||
|
return this.cminmsgsDateProcessed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCminmsgsDateProcessed(Date cminmsgsDateProcessed) {
|
||||||
|
this.cminmsgsDateProcessed = cminmsgsDateProcessed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCminmsgsDateReceived() {
|
||||||
|
return this.cminmsgsDateReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCminmsgsDateReceived(Date cminmsgsDateReceived) {
|
||||||
|
this.cminmsgsDateReceived = cminmsgsDateReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCminmsgsStatus() {
|
||||||
|
return this.cminmsgsStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCminmsgsStatus(String cminmsgsStatus) {
|
||||||
|
this.cminmsgsStatus = cminmsgsStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCminmsgsSubsystemDateSent() {
|
||||||
|
return this.cminmsgsSubsystemDateSent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCminmsgsSubsystemDateSent(Date cminmsgsSubsystemDateSent) {
|
||||||
|
this.cminmsgsSubsystemDateSent = cminmsgsSubsystemDateSent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCminmsgsSubsystemName() {
|
||||||
|
return this.cminmsgsSubsystemName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCminmsgsSubsystemName(String cminmsgsSubsystemName) {
|
||||||
|
this.cminmsgsSubsystemName = cminmsgsSubsystemName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCminmsgsSubsystemSequence() {
|
||||||
|
return this.cminmsgsSubsystemSequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCminmsgsSubsystemSequence(int cminmsgsSubsystemSequence) {
|
||||||
|
this.cminmsgsSubsystemSequence = cminmsgsSubsystemSequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCminmsgsSubsystemSubtype() {
|
||||||
|
return this.cminmsgsSubsystemSubtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCminmsgsSubsystemSubtype(String cminmsgsSubsystemSubtype) {
|
||||||
|
this.cminmsgsSubsystemSubtype = cminmsgsSubsystemSubtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCminmsgsSubsystemType() {
|
||||||
|
return this.cminmsgsSubsystemType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCminmsgsSubsystemType(String cminmsgsSubsystemType) {
|
||||||
|
this.cminmsgsSubsystemType = cminmsgsSubsystemType;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.gzzn.omms.msgexchangeapi.scheduled;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import com.gzzn.omms.msgexchangeapi.dao.CminmsgDao;
|
||||||
|
import com.gzzn.omms.msgexchangeapi.dao.CminmsgHstDao;
|
||||||
|
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
|
||||||
|
import com.gzzn.omms.msgexchangeapi.entity.CminmsgHst;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cminmsgs 消息转历史
|
||||||
|
* @author zhouxiunai
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
//@Async
|
||||||
|
public class CminmsgsHisScheduled {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CminmsgHstDao cminmsgHstDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CminmsgDao cminmsgDao;
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(CminmsgsHisScheduled.class);
|
||||||
|
|
||||||
|
//@Scheduled(cron = "${scheduled.cminmsgHisCron}")
|
||||||
|
public void scheduled()
|
||||||
|
{
|
||||||
|
logger.info("开始cminmsgs消息转历史..");
|
||||||
|
|
||||||
|
Date dateNow = new Date();
|
||||||
|
List<Cminmsg> lsCminmsg = null;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
lsCminmsg = cminmsgDao.findByCminmsgsDateProcessedIsNotNullAndCminmsgsDateReceivedBefore
|
||||||
|
(
|
||||||
|
dateNow,new PageRequest(0,100)); //
|
||||||
|
|
||||||
|
if(!CollectionUtils.isEmpty(lsCminmsg))
|
||||||
|
{
|
||||||
|
//插入历史表
|
||||||
|
List<CminmsgHst> lsCminmsgHst = new ArrayList();
|
||||||
|
for(Cminmsg cminmsg : lsCminmsg)
|
||||||
|
{
|
||||||
|
CminmsgHst cminmsgHst = new CminmsgHst();
|
||||||
|
BeanUtils.copyProperties(cminmsg, cminmsgHst);
|
||||||
|
lsCminmsgHst.add(cminmsgHst);
|
||||||
|
}
|
||||||
|
cminmsgHstDao.save(lsCminmsgHst);
|
||||||
|
|
||||||
|
//从原始表删除
|
||||||
|
cminmsgDao.delete(lsCminmsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while(!CollectionUtils.isEmpty(lsCminmsg));
|
||||||
|
|
||||||
|
logger.info("结束本次cminmsgs消息转历史..");
|
||||||
|
}//end shceduled
|
||||||
|
}
|
||||||
@@ -64,6 +64,8 @@ scheduled:
|
|||||||
corePoolSize: 10
|
corePoolSize: 10
|
||||||
maxPoolSize: 50
|
maxPoolSize: 50
|
||||||
queueCapacity: 10
|
queueCapacity: 10
|
||||||
|
# 每日凌晨3:00 cminmsg 已处理数据转历史
|
||||||
|
cminmsgHisCron: 0 52 21 * * ?
|
||||||
#计入历史航班数据的条件
|
#计入历史航班数据的条件
|
||||||
hstCondition:
|
hstCondition:
|
||||||
#航班到达超过多久则成为历史航班数据(单位:秒)
|
#航班到达超过多久则成为历史航班数据(单位:秒)
|
||||||
|
|||||||
@@ -18,6 +18,6 @@ public class RedisServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void removeFlightInfo()
|
public void removeFlightInfo()
|
||||||
{
|
{
|
||||||
redisService.del(Arrays.asList("FlightInfo:"));
|
redisService.del(Arrays.asList("flightInfo:"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.gzzn.omms.msgexchangeapi.scheduled;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class CminmsgsHisScheduledTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CminmsgsHisScheduled cminmsgsHisScheduled;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRun()
|
||||||
|
{
|
||||||
|
cminmsgsHisScheduled.scheduled();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.gzzn.omms.msgexchangeapi.service;
|
||||||
|
|
||||||
|
public class CmoutmsgServiceImplTest {
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user