2018-11-28 16:22:33 +08:00
|
|
|
package com.gzzn.omms.msgexchangeapi.runner;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.boot.CommandLineRunner;
|
|
|
|
|
|
2018-12-03 15:27:53 +08:00
|
|
|
import com.gzzn.omms.msgexchangeapi.dao.CmoutmsgDao;
|
|
|
|
|
import com.gzzn.omms.msgexchangeapi.entity.Cmoutmsg;
|
|
|
|
|
import com.gzzn.omms.msgexchangeapi.entity.msg.rqfd.RefdMsg;
|
|
|
|
|
import com.gzzn.omms.msgexchangeapi.entity.msg.rqfd.RefdMsgBody;
|
|
|
|
|
import com.gzzn.omms.msgexchangeapi.redis.dao.ContextDao;
|
|
|
|
|
import com.gzzn.omms.msgexchangeapi.redis.entity.Context;
|
2018-11-28 16:22:33 +08:00
|
|
|
import com.gzzn.omms.msgexchangeapi.service.IExchangeService;
|
|
|
|
|
import com.gzzn.omms.msgexchangeapi.utils.DateTimeUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class AppRunner implements CommandLineRunner {
|
|
|
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(AppRunner.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private CmoutmsgDao cmoutmsgDao;
|
|
|
|
|
|
2018-11-29 13:33:46 +08:00
|
|
|
@Autowired
|
|
|
|
|
private ContextDao contextDao;
|
|
|
|
|
|
2018-11-28 16:22:33 +08:00
|
|
|
@Autowired
|
|
|
|
|
private IExchangeService exchangeService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void run(String... args) throws Exception {
|
2018-11-29 13:33:46 +08:00
|
|
|
//构造消息
|
|
|
|
|
Date nowDate = new Date();
|
2018-11-28 16:22:33 +08:00
|
|
|
Cmoutmsg cmoutmsg = new Cmoutmsg();
|
|
|
|
|
RefdMsgBody body = new RefdMsgBody();
|
|
|
|
|
body.setStdb(
|
|
|
|
|
DateTimeUtil.gtFormatStr(
|
2018-11-29 13:33:46 +08:00
|
|
|
nowDate,
|
2018-11-28 16:22:33 +08:00
|
|
|
"ddMMMyyHHmm",
|
|
|
|
|
Locale.ENGLISH)
|
|
|
|
|
.toUpperCase()
|
|
|
|
|
);
|
|
|
|
|
RefdMsg msg = new RefdMsg();
|
|
|
|
|
msg.setRefd(body);
|
|
|
|
|
cmoutmsg.setCminmsgsClobMsg(exchangeService.objectToXmlstr(msg));
|
|
|
|
|
cmoutmsg.setCminmsgsStatus("VALID");
|
|
|
|
|
|
|
|
|
|
cmoutmsgDao.save(cmoutmsg);
|
2018-11-29 13:33:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
Context isWaitSchd = new Context();
|
|
|
|
|
isWaitSchd.setKey(Context.KEY_ISWAITSCHD); //等待返回日计划状态
|
|
|
|
|
isWaitSchd.setValue("true");
|
|
|
|
|
contextDao.save(isWaitSchd);
|
|
|
|
|
|
|
|
|
|
//初始化消息进度
|
|
|
|
|
Context msgProgress = new Context();
|
|
|
|
|
msgProgress.setKey(Context.KEY_MSGPROGRESS);
|
|
|
|
|
msgProgress.setValue( DateTimeUtil.gtFormatStr(
|
|
|
|
|
nowDate,
|
|
|
|
|
"yyyy-MM-dd hh:mm:ss",
|
|
|
|
|
Locale.ENGLISH)
|
|
|
|
|
);
|
|
|
|
|
contextDao.save(msgProgress);
|
2018-11-28 16:22:33 +08:00
|
|
|
}//end function run
|
|
|
|
|
}
|