From c007f0ca1785db093d48f4846cda82fe8e955765 Mon Sep 17 00:00:00 2001 From: kimi <kimi42345@gmail.com> Date: 星期三, 27 五月 2020 09:59:29 +0800 Subject: [PATCH] merage --- src/main/java/com/highdatas/mdm/util/pool/MqEntity.java | 72 ++++++++++++++++++++++++------------ 1 files changed, 48 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/highdatas/mdm/util/pool/MqEntity.java b/src/main/java/com/highdatas/mdm/util/pool/MqEntity.java index aa6a5c9..ad29dcc 100644 --- a/src/main/java/com/highdatas/mdm/util/pool/MqEntity.java +++ b/src/main/java/com/highdatas/mdm/util/pool/MqEntity.java @@ -6,6 +6,7 @@ import com.highdatas.mdm.util.DbUtils; import lombok.extern.slf4j.Slf4j; +import java.util.Date; import java.util.concurrent.atomic.AtomicInteger; /** @@ -21,14 +22,15 @@ * 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; @@ -39,9 +41,16 @@ 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() { @@ -142,28 +151,43 @@ } public void send2Mq() { + String s = JSONObject.toJSONString(this); log.info(s); MqResult mqResult = DbUtils.mqClient.syncProduce(this); - SysDispenseLogs logByMqEntity = DbUtils.dispenseLogsService.getLogByMqEntity(this); + SysDispenseLogs logByMqEntity = DbUtils.dispenseLogsService.selectById(this.getLogId()); if (logByMqEntity == null) { return; } - String code = mqResult.getCode(); - logByMqEntity.setPageNo(pageNo.get()).setMsgCode(code); - logByMqEntity.setPages(pages.get()).setTotal(totalSize.get()).setPageSize(pageSize.get()); - 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) { @@ -190,7 +214,7 @@ public static class MsgBodyBean { /** * moduleName : 妯″潡鍚嶇О - * form : 婧愮郴缁� + * from : 婧愮郴缁� * to : 鐩爣绯荤粺 * data : weodfsdfwefsdfwefwef * total : 鏁版嵁鎬婚噺 @@ -199,7 +223,7 @@ */ private String moduleName; - private String form; + private String from; private String to; private String data; private int total; @@ -208,7 +232,7 @@ public MsgBodyBean() { this.moduleName = Constant.MasterDispense; - this.form = Constant.Master; + this.from = Constant.Master; this.timestamp = DbUtils.getNowDateStr(); } @@ -220,12 +244,12 @@ 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() { -- Gitblit v1.8.0