package com.gzzn.omms.msgexchangeapi.service; 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; public Boolean sendSchdGetMsg(Date startDate,Date endDate) { Long nowtime = System.currentTimeMillis(); //构造消息 MSG rqfdMsg = new MSGBuilder(). setMETA( new METABuilder() .setSNDR(SUBSYSTEMS.OSH5) .setTYPE(MESSAGETYPES.RQFD) .setSTYP(MESSAGESUBTYPES.NONE) .setDTTM(new BigInteger(nowtime.toString())) .build() ) .build(); RQFD rqfd = new RQFD(); if(null != startDate) { rqfd.setSTDB(getDateStr(startDate)); } if(null != endDate) { rqfd.setSTDE(getDateStr(endDate)); } rqfdMsg.setRQFD(rqfd); //发送消息到数据库 Cmoutmsg cmoutmsg = new Cmoutmsg(); cmoutmsg.setCoutmsgsDateInserted(new Date()); cmoutmsg.setCoutmsgsClobMsg(exchangeService.objectToXmlstr(rqfdMsg)); cmoutmsg.setRoutingid(SUBSYSTEMS.OSH5RQFD.name()); Cmoutmsg rtCmoutmsg = cmoutmsgDao.save(cmoutmsg); return rtCmoutmsg != null; } private String getDateStr(Date date) { return DateTimeUtil.gtFormatStr( date, "ddMMMyyHHmm", Locale.ENGLISH) .toUpperCase(); }//end function }