
jizcode.netty.contract.RtDataFromServer Maven / Gradle / Ivy
package jizcode.netty.contract;
import jizcode.base.util.EncryptUtils;
import java.util.Date;
public class RtDataFromServer{
private Integer cmd;
private String ouCode;
private String json;
private long uniqueId;
public boolean oneway;
private RtDataFromServer(){
}
public static RtDataFromServer build(){
RtDataFromServer data = new RtDataFromServer();
Date date = new Date();
// 每三秒视为一次请求
//System.out.println(date.getTime());
long prefix = date.getTime() / 1000;
long suffix = prefix % 100 / 3;
prefix = prefix / 100;
prefix = prefix * 10 + suffix;
data.setUniqueId(prefix);
return data;
}
/**
* @return the uniqueId
*/
public long getUniqueId() {
return uniqueId;
}
/**
* @param uniqueId the uniqueId to set
*/
public void setUniqueId(long uniqueId) {
this.uniqueId = uniqueId;
}
/**
* @return the cmd
*/
public Integer getCmd() {
return cmd;
}
/**
* @return the json
*/
public String getJson() {
return json;
}
/**
* @param json the json to set
*/
public void setJson(String json) {
this.json = json;
}
/**
* @return the ouCode
*/
public String getOuCode() {
return ouCode;
}
/**
* @param ouCode the ouCode to set
*/
public void setOuCode(String ouCode) {
this.ouCode = ouCode;
}
/**
* @param cmd the cmd to set
*/
public void setCmd(Integer cmd) {
this.cmd = cmd;
}
private String md5;
public String getMd5() {
try {
if (this.md5 == null) {
this.md5 = EncryptUtils.md5X2(String.format("%d-%s-%d-%s",
this.cmd,
this.ouCode,
this.uniqueId,
this.json));
}
return md5;
}catch (Exception e) {
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy