kimi
2020-05-27 c007f0ca1785db093d48f4846cda82fe8e955765
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,27 +151,43 @@
    }
    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) {
@@ -189,7 +214,7 @@
    public static class MsgBodyBean {
        /**
         * moduleName : 模块名称
         * form : 源系统
         * from : 源系统
         * to : 目标系统
         * data : weodfsdfwefsdfwefwef
         * total : 数据总量
@@ -198,7 +223,7 @@
         */
        private String moduleName;
        private String form;
        private String from;
        private String to;
        private String data;
        private int total;
@@ -207,7 +232,7 @@
        public MsgBodyBean() {
            this.moduleName = Constant.MasterDispense;
            this.form = Constant.Master;
            this.from = Constant.Master;
            this.timestamp = DbUtils.getNowDateStr();
        }
@@ -219,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() {