| | |
| | | import com.highdatas.mdm.util.DbUtils;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.concurrent.atomic.AtomicInteger;
|
| | |
|
| | | /**
|
| | |
| | | * msgTopicName : 消息主题
|
| | | * msgTagName : 消息主题标签
|
| | | * msgKey : 消息key
|
| | | * msgBody : {"moduleName":"模块名称","form":"源系统","to":"目标系统","data":"weodfsdfwefsdfwefwef","total":"数据总量","version":"版本号","timestamp":"时间戳"}
|
| | | * msgBody : {"moduleName":"模块名称","from":"源系统","to":"目标系统","data":"weodfsdfwefsdfwefwef","total":"数据总量","version":"版本号","timestamp":"时间戳"}
|
| | | */
|
| | |
|
| | | private String msgTopicName;
|
| | |
|
| | | private String msgTagName;
|
| | | private String msgKey;
|
| | | private MsgBodyBean msgBody;
|
| | |
|
| | | private transient String logId;
|
| | | private transient String userId;
|
| | | private transient volatile AtomicInteger pageNo;
|
| | | private transient volatile AtomicInteger pageSize;
|
| | |
| | | private transient String maintainId;
|
| | | private Boolean increment;
|
| | |
|
| | | public String getLogId() {
|
| | | return logId;
|
| | | }
|
| | |
|
| | | public void setLogId(String logId) {
|
| | | this.logId = logId;
|
| | | }
|
| | |
|
| | | public String getMsgCode() {
|
| | | return msgTopicName + msgTagName + msgBody.version;
|
| | | return msgTopicName + msgTagName + userId + msgBody.version;
|
| | | }
|
| | |
|
| | | public AtomicInteger getPageNo() {
|
| | |
| | | }
|
| | |
|
| | | public void send2Mq() {
|
| | |
|
| | | String s = JSONObject.toJSONString(this);
|
| | | log.info(s);
|
| | | MqResult mqResult = DbUtils.mqClient.asyncProduce(this);
|
| | | SysDispenseLogs logByMqEntity = DbUtils.dispenseLogsService.getLogByMqEntity(this);
|
| | | MqResult mqResult = DbUtils.mqClient.syncProduce(this);
|
| | | SysDispenseLogs logByMqEntity = DbUtils.dispenseLogsService.selectById(this.getLogId());
|
| | | if (logByMqEntity == null) {
|
| | | return;
|
| | | }
|
| | | String code = mqResult.getCode();
|
| | | logByMqEntity.setPageNo(pageNo.get()).setMsgCode(code);
|
| | | if (!code.equalsIgnoreCase(Constant.SUCCESSCODE)) {
|
| | | logByMqEntity.setStatus("false");
|
| | | try{
|
| | | String code = mqResult.getCode();
|
| | | logByMqEntity.setKeyId(getMsgKey());
|
| | | logByMqEntity.setUserId(userId);
|
| | | logByMqEntity.setPageNo(pageNo.get()).setMsgCode(code);
|
| | | logByMqEntity.setPages(pages.get()).setTotal(totalSize.get()).setPageSize(pageSize.get());
|
| | | if (!code.equalsIgnoreCase(Constant.SUCCESSCODE)) {
|
| | | logByMqEntity.setStatus("false");
|
| | | }
|
| | | if (code.equalsIgnoreCase(Constant.SUCCESSCODE) && pageNo.get() == pages.get()) {
|
| | | logByMqEntity.setStatus("true");
|
| | | }
|
| | | MqResult.DataBean data = mqResult.getData();
|
| | | if (data != null) {
|
| | | String msgId = data.getMsgId();
|
| | | logByMqEntity.setMsgId(msgId);
|
| | | }
|
| | | Date createTime = logByMqEntity.getCreateTime();
|
| | | long schedule = new Date().getTime() - createTime.getTime();
|
| | | logByMqEntity.setSchedule(schedule);
|
| | | logByMqEntity.updateById();
|
| | | }
|
| | | if (code.equalsIgnoreCase(Constant.SUCCESSCODE) && pageNo.get() == pages.get()) {
|
| | | logByMqEntity.setStatus("true");
|
| | | catch (Exception e) {
|
| | | logByMqEntity.setErrorInfo(e.getMessage()).updateById();
|
| | | e.printStackTrace();
|
| | |
|
| | | }
|
| | | MqResult.DataBean data = mqResult.getData();
|
| | | if (data != null) {
|
| | | String msgId = data.getMsgId();
|
| | | logByMqEntity.setMsgId(msgId);
|
| | | }
|
| | | logByMqEntity.updateById();
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | public void setIncrement(Boolean increment) {
|
| | |
| | | public static class MsgBodyBean {
|
| | | /**
|
| | | * moduleName : 模块名称
|
| | | * form : 源系统
|
| | | * from : 源系统
|
| | | * to : 目标系统
|
| | | * data : weodfsdfwefsdfwefwef
|
| | | * total : 数据总量
|
| | |
| | | */
|
| | |
|
| | | private String moduleName;
|
| | | private String form;
|
| | | private String from;
|
| | | private String to;
|
| | | private String data;
|
| | | private int total;
|
| | |
| | |
|
| | | public MsgBodyBean() {
|
| | | this.moduleName = Constant.MasterDispense;
|
| | | this.form = Constant.Master;
|
| | | this.from = Constant.Master;
|
| | | this.timestamp = DbUtils.getNowDateStr();
|
| | | }
|
| | |
|
| | |
| | | this.moduleName = moduleName;
|
| | | }
|
| | |
|
| | | public String getForm() {
|
| | | return form;
|
| | | public String getFrom() {
|
| | | return from;
|
| | | }
|
| | |
|
| | | public void setForm(String form) {
|
| | | this.form = form;
|
| | | public void setFrom(String from) {
|
| | | this.from = from;
|
| | | }
|
| | |
|
| | | public String getTo() {
|