Files
msgexchange-api/src/main/java/com/gzzn/omms/msgexchangeapi/service/CmoutmsgServiceImpl.java
T

78 lines
2.3 KiB
Java
Raw Normal View History

package com.gzzn.omms.msgexchangeapi.service;
2018-12-29 17:30:43 +08:00
import java.math.BigInteger;
import java.util.Date;
import java.util.Locale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gzzn.omms.msgexchangeapi.dao.CmoutmsgDao;
import com.gzzn.omms.msgexchangeapi.entity.Cmoutmsg;
import com.gzzn.omms.msgexchangeapi.entity.msg.MESSAGESUBTYPES;
import com.gzzn.omms.msgexchangeapi.entity.msg.MESSAGETYPES;
import com.gzzn.omms.msgexchangeapi.entity.msg.MSG;
import com.gzzn.omms.msgexchangeapi.entity.msg.RQFD;
import com.gzzn.omms.msgexchangeapi.entity.msg.SUBSYSTEMS;
import com.gzzn.omms.msgexchangeapi.entity.msg.builder.METABuilder;
import com.gzzn.omms.msgexchangeapi.entity.msg.builder.MSGBuilder;
import com.gzzn.omms.msgexchangeapi.service.exchange.IExchangeService;
import com.gzzn.omms.msgexchangeapi.utils.DateTimeUtil;
@Service
public class CmoutmsgServiceImpl implements ICmoutmsgService {
@Autowired
private IExchangeService exchangeService;
@Autowired
private CmoutmsgDao cmoutmsgDao;
2018-12-19 13:47:05 +08:00
public Boolean sendSchdGetMsg(Date startDate,Date endDate)
{
2018-12-29 17:30:43 +08:00
Long nowtime = System.currentTimeMillis();
//构造消息
MSG rqfdMsg = new MSGBuilder().
setMETA(
new METABuilder()
2018-12-29 17:30:43 +08:00
.setSNDR(SUBSYSTEMS.OSH5)
.setTYPE(MESSAGETYPES.RQFD)
.setSTYP(MESSAGESUBTYPES.NONE)
2018-12-29 17:30:43 +08:00
.setDTTM(new BigInteger(nowtime.toString()))
.build()
)
.build();
RQFD rqfd = new RQFD();
2018-12-19 13:47:05 +08:00
if(null != startDate)
{
rqfd.setSTDB(getDateStr(startDate));
}
if(null != endDate)
{
rqfd.setSTDE(getDateStr(endDate));
}
rqfdMsg.setRQFD(rqfd);
//发送消息到数据库
Cmoutmsg cmoutmsg = new Cmoutmsg();
2018-12-29 17:30:43 +08:00
cmoutmsg.setCoutmsgsDateInserted(new Date());
cmoutmsg.setCoutmsgsClobMsg(exchangeService.objectToXmlstr(rqfdMsg));
2019-01-03 15:22:02 +08:00
cmoutmsg.setRoutingid(SUBSYSTEMS.OSH5RQFD.name());
Cmoutmsg rtCmoutmsg = cmoutmsgDao.save(cmoutmsg);
return rtCmoutmsg != null;
}
2018-12-19 13:47:05 +08:00
private String getDateStr(Date date)
{
return DateTimeUtil.gtFormatStr(
date,
"ddMMMyyHHmm",
Locale.ENGLISH)
.toUpperCase();
}//end function
}