Commit c00d79af by manxiaoqiang

大后台定时任务

parent 22619666
...@@ -45,6 +45,14 @@ ...@@ -45,6 +45,14 @@
<office.username>root</office.username> <office.username>root</office.username>
<office.password>reyun123</office.password> <office.password>reyun123</office.password>
<tkio.url>jdbc:mysql://192.168.2.57:3306/trackingio?characterEncoding=utf-8</tkio.url>
<tkio.username>root</tkio.username>
<tkio.password>reyun123</tkio.password>
<track.url>jdbc:mysql://192.168.2.57:3306/track?characterEncoding=utf-8</track.url>
<track.username>root</track.username>
<track.password>reyun123</track.password>
<mail.host>smtp.exmail.qq.com</mail.host> <mail.host>smtp.exmail.qq.com</mail.host>
<mail.username>service1@reyun.com</mail.username> <mail.username>service1@reyun.com</mail.username>
<mail.password>XSW29ijn</mail.password> <mail.password>XSW29ijn</mail.password>
......
package common.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.math.BigInteger;
import java.util.Date;
@Entity
public class Account4Web {
private Long id;
private String email;
private String company;
private Date createDate;
private String status;
private String packageType;
private String pastDate;
private String track;
private String io;
private Integer backTime;
private String user;
private String tell;
private Integer money;
private Boolean ioStatus;
private Boolean trackStatus;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getPackageType() {
return packageType;
}
public void setPackageType(String packageType) {
this.packageType = packageType;
}
public String getPastDate() {
return pastDate;
}
public void setPastDate(String pastDate) {
this.pastDate = pastDate;
}
public String getTrack() {
return track;
}
public void setTrack(String track) {
this.track = track;
}
public String getIo() {
return io;
}
public void setIo(String io) {
this.io = io;
}
public Integer getBackTime() {
return backTime;
}
public void setBackTime(Integer backTime) {
this.backTime = backTime;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getTell() {
return tell;
}
public void setTell(String tell) {
this.tell = tell;
}
public Integer getMoney() {
return money;
}
public void setMoney(Integer money) {
this.money = money;
}
public Boolean getIoStatus() {
return ioStatus;
}
public void setIoStatus(Boolean ioStatus) {
this.ioStatus = ioStatus;
}
public Boolean getTrackStatus() {
return trackStatus;
}
public void setTrackStatus(Boolean trackStatus) {
this.trackStatus = trackStatus;
}
}
package common.repository;
import common.model.Account4Web;
import common.model.Auth;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;
@Transactional
public interface Account4WebRepository extends JpaRepository<Account4Web, Long> {
}
package tkio.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
@Entity
public class Account {
private Long id;
private String email;
private String password;
private String company;
private String name;
private String phone;
private String qq;
private String wechat;
private boolean isSuperUser;
private Long parent = 0L;
private Long rootParent;
private String isSpecialAccount;
//母账号:-1表示未审核,0表示禁用,1表示已审核;子账号:0表示禁用,1表示启用;总之:1表示用户可用状态;补充:-3表示未激活 -2 表示未开通
private int status;
private String pastDate;
private Date createTime = new Date();
//审核通过的时间
private Date pubDate;
private Long createAccount;
private Date modifyTime = new Date();
private Long modifyAccount;
private Boolean delFlag;
private Boolean isChannelPerson;
private String channelAccount;
//角色ID,对应role_auth表的ID。
private Long roleCategory;
private Long pricelevel;
private Long bussinessman;
private Long activeTime;
private Long forgetPwdTime;
//默认状态为空 false 忘记密码邮件发送后赋值; true 修改完密码之后赋值,表示完成修改密码操作,整个忘记密码流程结束
private Boolean forgetPwdStatus;
//默认状态为空 false 激活邮件发送后赋值; true 激活操作之后赋值,表示完成激活操作,整个激活流程结束,防止重复提交url
private Boolean activeStatus;
private int appSize;
private String remark;
//默认为空 false 非全渠道设置参数 true全渠道设置参数
private Boolean allChannelValidMatch;
private Boolean allChannelFakeMatch;
private Boolean allChannelBlackMatch;
//Transient
private String modifyAccountName;
private String createAccountName;
private String roleName;
private Long parentRole;
private String authStr;
private boolean isMasterLogin;
private List<UserLog> userLogList;
private List<Auth> authList;
private Boolean valid;
private String regIpAddr;
private String regIpLocation;
private Boolean verifyEmail = false;
private Boolean allowBehavior;
private Boolean isFlowRestrict;
private String modifyPricelevelTime;
private Boolean newContract;
public Boolean getFlowRestrict() {
return isFlowRestrict;
}
public void setFlowRestrict(Boolean flowRestrict) {
isFlowRestrict = flowRestrict;
}
public Boolean getAllowBehavior() {
return allowBehavior;
}
public void setAllowBehavior(Boolean allowBehavior) {
this.allowBehavior = allowBehavior;
}
public Account() {
super();
}
public Account(Long id, String email, String password, String company,
String name, String phone, String qq, boolean isSuperUser,
Long parent, String isSpecialAccount, int status, String pastDate,
Date createTime, Long createAccount, Date modifyTime,
Long modifyAccount, boolean delFlag) {
super();
this.id = id;
this.email = email;
this.password = password;
this.company = company;
this.name = name;
this.phone = phone;
this.qq = qq;
this.isSuperUser = isSuperUser;
this.parent = parent;
this.isSpecialAccount = isSpecialAccount;
this.status = status;
this.pastDate = pastDate;
this.createTime = createTime;
this.createAccount = createAccount;
this.modifyTime = modifyTime;
this.modifyAccount = modifyAccount;
this.delFlag = delFlag;
}
@Id
@GeneratedValue
public Long getId() {
return id;
}
public boolean getIsSuperUser() {
return isSuperUser;
}
public String getName() {
return name;
}
public String getPassword() {
return password;
}
public String getPhone() {
return phone;
}
public String getQq() {
return qq;
}
public Date getCreateTime() {
return createTime;
}
public void setCompany(String company) {
this.company = company;
}
public void setEmail(String email) {
this.email = email;
}
public String getCompany() {
return company;
}
public String getEmail() {
return email;
}
public void setId(Long id) {
this.id = id;
}
public void setIsSuperUser(boolean isSuperUser) {
this.isSuperUser = isSuperUser;
}
public void setName(String name) {
this.name = name;
}
public void setPassword(String password) {
this.password = password;
}
public void setPhone(String phone) {
this.phone = phone;
}
public void setQq(String qq) {
this.qq = qq;
}
public void setSuperUser(boolean isSuperUser) {
this.isSuperUser = isSuperUser;
}
public Long getParent() {
return parent;
}
public void setParent(Long parent) {
this.parent = parent;
}
public Long getRootParent() {
return rootParent;
}
public void setRootParent(Long rootParent) {
this.rootParent = rootParent;
}
public String getIsSpecialAccount() {
return isSpecialAccount;
}
public void setIsSpecialAccount(String isSpecialAccount) {
this.isSpecialAccount = isSpecialAccount;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getPastDate() {
return pastDate;
}
public void setPastDate(String pastDate) {
this.pastDate = pastDate;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Long getCreateAccount() {
return createAccount;
}
public void setCreateAccount(Long createAccount) {
this.createAccount = createAccount;
}
public Long getModifyAccount() {
return modifyAccount;
}
public void setModifyAccount(Long modifyAccount) {
this.modifyAccount = modifyAccount;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public Boolean getDelFlag() {
return delFlag;
}
public void setDelFlag(Boolean delFlag) {
this.delFlag = delFlag;
}
public Boolean getIsChannelPerson() {
return isChannelPerson;
}
public void setIsChannelPerson(Boolean isChannelPerson) {
this.isChannelPerson = isChannelPerson;
}
public String getChannelAccount() {
return channelAccount;
}
public void setChannelAccount(String channelAccount) {
this.channelAccount = channelAccount;
}
public String getWechat() {
return wechat;
}
public void setWechat(String wechat) {
this.wechat = wechat;
}
public Long getPricelevel() {
return pricelevel;
}
public void setPricelevel(Long pricelevel) {
this.pricelevel = pricelevel;
}
public Long getBussinessman() {
return bussinessman;
}
public void setBussinessman(Long bussinessman) {
this.bussinessman = bussinessman;
}
public Date getPubDate() {
return pubDate;
}
public void setPubDate(Date pubDate) {
this.pubDate = pubDate;
}
public Long getActiveTime() {
return activeTime;
}
public void setActiveTime(Long activeTime) {
this.activeTime = activeTime;
}
public Long getForgetPwdTime() {
return forgetPwdTime;
}
public void setForgetPwdTime(Long forgetPwdTime) {
this.forgetPwdTime = forgetPwdTime;
}
public Boolean getForgetPwdStatus() {
return forgetPwdStatus;
}
public void setForgetPwdStatus(Boolean forgetPwdStatus) {
this.forgetPwdStatus = forgetPwdStatus;
}
public Boolean getActiveStatus() {
return activeStatus;
}
public void setActiveStatus(Boolean activeStatus) {
this.activeStatus = activeStatus;
}
public Long getRoleCategory() {
return roleCategory;
}
public void setRoleCategory(Long roleCategory) {
this.roleCategory = roleCategory;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getModifyPricelevelTime() {
return modifyPricelevelTime;
}
public void setModifyPricelevelTime(String modifyPricelevelTime) {
this.modifyPricelevelTime = modifyPricelevelTime;
}
public Boolean getNewContract() {
return newContract;
}
public void setNewContract(Boolean newContract) {
this.newContract = newContract;
}
@Transient
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
@Transient
public Long getParentRole() {
return parentRole;
}
public void setParentRole(Long parentRole) {
this.parentRole = parentRole;
}
@Transient
public String getAuthStr() {
return authStr;
}
public void setAuthStr(String authStr) {
this.authStr = authStr;
}
@Transient
public List<UserLog> getUserLogList() {
return userLogList;
}
public void setUserLogList(List<UserLog> userLogList) {
this.userLogList = userLogList;
}
@Transient
public boolean getIsMasterLogin() {
return isMasterLogin;
}
public void setIsMasterLogin(boolean isMasterLogin) {
this.isMasterLogin = isMasterLogin;
}
@Transient
public List<Auth> getAuthList() {
return authList;
}
public void setAuthList(List<Auth> authList) {
this.authList = authList;
}
@Transient
public String getCreateAccountName() {
return createAccountName;
}
public void setCreateAccountName(String createAccountName) {
this.createAccountName = createAccountName;
}
@Transient
public String getModifyAccountName() {
return modifyAccountName;
}
public void setModifyAccountName(String modifyAccountName) {
this.modifyAccountName = modifyAccountName;
}
@Transient
public Boolean getValid() {
return valid;
}
public void setValid(Boolean valid) {
this.valid = valid;
}
@Transient
public int getAppSize()
{
return appSize;
}
public void setAppSize(int appSize)
{
this.appSize = appSize;
}
public Boolean getAllChannelValidMatch() {
return allChannelValidMatch;
}
public void setAllChannelValidMatch(Boolean allChannelValidMatch) {
this.allChannelValidMatch = allChannelValidMatch;
}
public Boolean getAllChannelFakeMatch() {
return allChannelFakeMatch;
}
public void setAllChannelFakeMatch(Boolean allChannelFakeMatch) {
this.allChannelFakeMatch = allChannelFakeMatch;
}
public Boolean getAllChannelBlackMatch() {
return allChannelBlackMatch;
}
public void setAllChannelBlackMatch(Boolean allChannelBlackMatch) {
this.allChannelBlackMatch = allChannelBlackMatch;
}
public String getRegIpAddr()
{
return regIpAddr;
}
public void setRegIpAddr(String regIpAddr)
{
this.regIpAddr = regIpAddr;
}
public String getRegIpLocation()
{
return regIpLocation;
}
public void setRegIpLocation(String regIpLocation)
{
this.regIpLocation = regIpLocation;
}
public Boolean getVerifyEmail()
{
return verifyEmail;
}
public void setVerifyEmail(Boolean verifyEmail)
{
this.verifyEmail = verifyEmail;
}
@Override
public String toString() {
return "Account{" +
"id=" + id +
", email='" + email + '\'' +
", password='" + password + '\'' +
", company='" + company + '\'' +
", name='" + name + '\'' +
", phone='" + phone + '\'' +
", qq='" + qq + '\'' +
", wechat='" + wechat + '\'' +
", isSuperUser=" + isSuperUser +
", parent=" + parent +
", isSpecialAccount='" + isSpecialAccount + '\'' +
", status=" + status +
", pastDate='" + pastDate + '\'' +
", createTime=" + createTime +
", pubDate=" + pubDate +
", createAccount=" + createAccount +
", modifyTime=" + modifyTime +
", modifyAccount=" + modifyAccount +
", delFlag=" + delFlag +
", roleCategory=" + roleCategory +
", authStr='" + authStr + '\'' +
", isChannelPerson=" + isChannelPerson +
", channelAccount='" + channelAccount + '\'' +
", userLogList=" + userLogList +
", isMasterLogin=" + isMasterLogin +
", pricelevel=" + pricelevel +
", bussinessman=" + bussinessman +
", activeTime=" + activeTime +
", forgetPwdTime=" + forgetPwdTime +
", forgetPwdStatus=" + forgetPwdStatus +
", activeStatus=" + activeStatus +
'}';
}
}
package tkio.model;
import java.math.BigInteger;
public class AccountRestrict4Web {
private String packageName;
private String originalName;
private BigInteger IOLimit;
private String pastDate;
private BigInteger TrackLimit;
private Long accountId;
private int priceLevel;
private int iOremainingDays;
private int trackRemainingDays;
private BigInteger TrackTotalFlow;
private BigInteger thisMonthIOFlow;
private Double trackRemainPercent;
private Double IORemainPercent;
private BigInteger lastMonthIOFlow;
private Boolean isFlowRestrict;
private Long packLevel;
private Boolean isTrackPastTimeNotified;
private Boolean isIOPastTimeNotified;
private Boolean isTrackFlowNotified;
private Boolean isIOFlowNotified;
private Boolean allowBehavior;
public Long getPackLevel() {
return packLevel;
}
public void setPackLevel(Long packLevel) {
this.packLevel = packLevel;
}
public Boolean getFlowRestrict() {
return isFlowRestrict;
}
public void setFlowRestrict(Boolean flowRestrict) {
isFlowRestrict = flowRestrict;
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public String getOriginalName() {
return originalName;
}
public void setOriginalName(String originalName) {
this.originalName = originalName;
}
public BigInteger getIOLimit() {
return IOLimit;
}
public void setIOLimit(BigInteger IOLimit) {
this.IOLimit = IOLimit;
}
public String getPastDate() {
return pastDate;
}
public void setPastDate(String pastDate) {
this.pastDate = pastDate;
}
public BigInteger getTrackLimit() {
return TrackLimit;
}
public void setTrackLimit(BigInteger trackLimit) {
TrackLimit = trackLimit;
}
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long accountId) {
this.accountId = accountId;
}
public int getPriceLevel() {
return priceLevel;
}
public void setPriceLevel(int priceLevel) {
this.priceLevel = priceLevel;
}
public int getiOremainingDays() {
return iOremainingDays;
}
public void setiOremainingDays(int iOremainingDays) {
this.iOremainingDays = iOremainingDays;
}
public int getTrackRemainingDays() {
return trackRemainingDays;
}
public void setTrackRemainingDays(int trackRemainingDays) {
this.trackRemainingDays = trackRemainingDays;
}
public BigInteger getTrackTotalFlow() {
return TrackTotalFlow;
}
public void setTrackTotalFlow(BigInteger trackTotalFlow) {
TrackTotalFlow = trackTotalFlow;
}
public BigInteger getThisMonthIOFlow() {
return thisMonthIOFlow;
}
public void setThisMonthIOFlow(BigInteger thisMonthIOFlow) {
this.thisMonthIOFlow = thisMonthIOFlow;
}
public Double getTrackRemainPercent() {
return trackRemainPercent;
}
public void setTrackRemainPercent(Double trackRemainPercent) {
this.trackRemainPercent = trackRemainPercent;
}
public Double getIORemainPercent() {
return IORemainPercent;
}
public void setIORemainPercent(Double IORemainPercent) {
this.IORemainPercent = IORemainPercent;
}
public BigInteger getLastMonthIOFlow() {
return lastMonthIOFlow;
}
public void setLastMonthIOFlow(BigInteger lastMonthIOFlow) {
this.lastMonthIOFlow = lastMonthIOFlow;
}
public Boolean getTrackPastTimeNotified() {
return isTrackPastTimeNotified;
}
public void setTrackPastTimeNotified(Boolean trackPastTimeNotified) {
isTrackPastTimeNotified = trackPastTimeNotified;
}
public Boolean getIOPastTimeNotified() {
return isIOPastTimeNotified;
}
public void setIOPastTimeNotified(Boolean IOPastTimeNotified) {
isIOPastTimeNotified = IOPastTimeNotified;
}
public Boolean getTrackFlowNotified() {
return isTrackFlowNotified;
}
public void setTrackFlowNotified(Boolean trackFlowNotified) {
isTrackFlowNotified = trackFlowNotified;
}
public Boolean getIOFlowNotified() {
return isIOFlowNotified;
}
public void setIOFlowNotified(Boolean IOFlowNotified) {
isIOFlowNotified = IOFlowNotified;
}
public Boolean getAllowBehavior() {
return allowBehavior;
}
public void setAllowBehavior(Boolean allowBehavior) {
this.allowBehavior = allowBehavior;
}
}
package tkio.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import java.util.Date;
@Entity
public class App {
private Long id;
@NotNull
private String name;
private String platform;
private String appGenre;
private String appGenreName;
private String gameGenre;
//private String gameCategory;
private String appkey;
private String url;
private Long account;
private boolean sync;
// private boolean isActive;
private Long origiApp;
private String bundleid;
private String token;
private String installtoken;
private boolean regedbutton;
private Date createTime = new Date();
private String createAccount;
private Date modifyTime = new Date();
private String modifyAccount;
private Boolean delFlag;
//是否同步DDB
private Boolean syncDdb;
private Long installNum;
private Long registerNum;
//是够是debug模式 true 是测试,false不是测试
private Boolean isDebug;
private Boolean trackAndIoBothExhaust;
private Boolean mainAccountExpire;
public App() {
super();
}
public App(String name, String platform, String appGenre, String gameGenre) {
this.name = name;
this.platform = platform;
this.appGenre = appGenre;
this.gameGenre = gameGenre;
}
public App(String name, String platform, String appGenre, String gameGenre,
Long account) {
this.name = name;
this.platform = platform;
this.appGenre = appGenre;
this.gameGenre = gameGenre;
this.account = account;
}
// public boolean isActive() {
// return isActive;
// }
//
// public void setActive(boolean isActive) {
// this.isActive = isActive;
// }
public Long getAccount() {
return account;
}
public String getAppGenre() {
return appGenre;
}
@Transient
public String getAppGenreName() {
return appGenreName;
}
public void setAppGenreName(String appGenreName) {
this.appGenreName = appGenreName;
}
public String getAppkey() {
return appkey;
}
public String getGameGenre() {
return gameGenre;
}
/* @Transient
public String getGameCategory() {
return gameCategory;
}
public void setGameCategory(String gameCategory) {
this.gameCategory = gameCategory;
}*/
@Id
@GeneratedValue
public Long getId() {
return id;
}
public String getName() {
return name;
}
public String getPlatform() {
return platform;
}
public String getUrl() {
return url;
}
public boolean isSync() {
return sync;
}
public void setAccount(Long account) {
this.account = account;
}
public void setAppGenre(String appGenre) {
this.appGenre = appGenre;
}
public void setAppkey(String appkey) {
this.appkey = appkey;
}
public void setGameGenre(String gameGenre) {
this.gameGenre = gameGenre;
}
public void setId(Long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public void setSync(boolean sync) {
this.sync = sync;
}
public void setUrl(String url) {
this.url = url;
}
public Long getOrigiApp() {
return origiApp;
}
public void setOrigiApp(Long origiApp) {
this.origiApp = origiApp;
}
public String getBundleid() {
return bundleid;
}
public void setBundleid(String bundleid) {
this.bundleid = bundleid;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public boolean isRegedbutton() {
return regedbutton;
}
public void setRegedbutton(boolean regedbutton) {
this.regedbutton = regedbutton;
}
public String getInstalltoken() {
return installtoken;
}
public void setInstalltoken(String installtoken) {
this.installtoken = installtoken;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreateAccount() {
return createAccount;
}
public void setCreateAccount(String createAccount) {
this.createAccount = createAccount;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public String getModifyAccount() {
return modifyAccount;
}
public void setModifyAccount(String modifyAccount) {
this.modifyAccount = modifyAccount;
}
public Boolean getDelFlag() {
return delFlag;
}
public void setDelFlag(Boolean delFlag) {
this.delFlag = delFlag;
}
public Boolean getIsDebug() {
return this.isDebug;
}
public void setIsDebug(Boolean isDebug) {
this.isDebug = isDebug;
}
public Boolean getSyncDdb() {
return syncDdb;
}
public void setSyncDdb(Boolean syncDdb) {
this.syncDdb = syncDdb;
}
@Transient
public Boolean getTrackAndIoBothExhaust() {
return trackAndIoBothExhaust;
}
public void setTrackAndIoBothExhaust(Boolean trackAndIoBothExhaust) {
this.trackAndIoBothExhaust = trackAndIoBothExhaust;
}
@Transient
public Boolean getMainAccountExpire() {
return mainAccountExpire;
}
public void setMainAccountExpire(Boolean mainAccountExpire) {
this.mainAccountExpire = mainAccountExpire;
}
@Transient
public Long getInstallNum() {
return installNum;
}
public void setInstallNum(Long installNum) {
this.installNum = installNum;
}
@Transient
public Long getRegisterNum() {
return registerNum;
}
public void setRegisterNum(Long registerNum) {
this.registerNum = registerNum;
}
@Override
public String toString() {
return "App [id=" + id + ", name=" + name + ", platform=" + platform
+ ", appGenre=" + appGenre + ", gameGenre=" + gameGenre
+ ", appkey=" + appkey + ", url=" + url + ", account="
+ account + ", sync=" + sync + ", origiApp=" + origiApp
+ ", bundleid=" + bundleid + ", token=" + token
+ ", installtoken=" + installtoken + ", regedbutton="
+ regedbutton + ", createTime=" + createTime
+ ", createAccount=" + createAccount + ", modifyTime="
+ modifyTime + ", modifyAccount=" + modifyAccount
+ ", delFlag=" + delFlag + "]";
}
}
package tkio.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
@Entity
public class Auth {
private Long id;
private Long roleCategory;
private String controlAuth;
private Long app;
private Long account;
private boolean retentionAuth;
private boolean payAuth;
private Long createAccount;
private Date createTime;
private Date modifyTime = new Date();
private String modifyAccount;
private Boolean status;
private Boolean isNatureOpen;
private Boolean campaign;
private Boolean topAuth;
//transient
private List<RoleAuthDetail> roleAuthDetailList;
private List<DataAuth> dataAuth;
public Auth() {
super();
}
public Auth(Long id, Long roleCategory, String controlAuth,
Long app, Long account) {
super();
this.id = id;
this.roleCategory = roleCategory;
this.controlAuth = controlAuth;
this.app = app;
this.account = account;
}
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getRoleCategory() {
return roleCategory;
}
public void setRoleCategory(Long roleCategory) {
this.roleCategory = roleCategory;
}
public String getControlAuth() {
return controlAuth;
}
public void setControlAuth(String controlAuth) {
this.controlAuth = controlAuth;
}
public Long getApp() {
return app;
}
public void setApp(Long app) {
this.app = app;
}
public Long getAccount() {
return account;
}
public void setAccount(Long account) {
this.account = account;
}
public boolean isRetentionAuth() {
return retentionAuth;
}
public void setRetentionAuth(boolean retentionAuth) {
this.retentionAuth = retentionAuth;
}
public boolean isPayAuth() {
return payAuth;
}
public void setPayAuth(boolean payAuth) {
this.payAuth = payAuth;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public String getModifyAccount() {
return modifyAccount;
}
public void setModifyAccount(String modifyAccount) {
this.modifyAccount = modifyAccount;
}
public Boolean getStatus() {
return status;
}
public void setStatus(Boolean status) {
this.status = status;
}
public Boolean getIsNatureOpen() {
return isNatureOpen;
}
public void setIsNatureOpen(Boolean isNatureOpen) {
this.isNatureOpen = isNatureOpen;
}
public Boolean getCampaign() {
return campaign;
}
public void setCampaign(Boolean campaign) {
this.campaign = campaign;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Long getCreateAccount() {
return createAccount;
}
public void setCreateAccount(Long createAccount) {
this.createAccount = createAccount;
}
public Boolean getTopAuth() {
return topAuth;
}
public void setTopAuth(Boolean topAuth) {
this.topAuth = topAuth;
}
@Transient
public List<RoleAuthDetail> getRoleAuthDetailList() {
return roleAuthDetailList;
}
public void setRoleAuthDetailList(List<RoleAuthDetail> roleAuthDetailList) {
this.roleAuthDetailList = roleAuthDetailList;
}
@Transient
public List<DataAuth> getDataAuth() {
return dataAuth;
}
public void setDataAuth(List<DataAuth> dataAuth) {
this.dataAuth = dataAuth;
}
@Override
public String toString() {
return "Auth [id=" + id + ", roleCategory=" + roleCategory
+ ", controlAuth=" + controlAuth + ", app=" + app
+ ", account=" + account + ", retentionAuth=" + retentionAuth
+ ", payAuth=" + payAuth + ", modifyTime=" + modifyTime
+ ", modifyAccount=" + modifyAccount + ", status=" + status
+ "]";
}
}
package tkio.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
@Entity
public class DataAuth {
private Long id;
private Long account;
private Long app;
private Long campaign;
private String campaignCode;
private Long channel;
private Boolean allCampaign;
private Date modifyTime = new Date();
private String modifyAccount;
private Boolean delFlag;
private Boolean channelPermit;//子账号渠道权限是否放开
//Transient
private List<Long> campaignList;
public DataAuth() {
super();
}
public DataAuth(Long id, Long app, Long campaign, String campaignCode,
Long channel, Boolean allCampaign,Boolean channelPermit) {
super();
this.id = id;
this.app = app;
this.campaign = campaign;
this.campaignCode = campaignCode;
this.channel = channel;
this.allCampaign = allCampaign;
this.channelPermit = channelPermit;
}
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getApp() {
return app;
}
public void setApp(Long app) {
this.app = app;
}
public Long getCampaign() {
return campaign;
}
public void setCampaign(Long campaign) {
this.campaign = campaign;
}
public String getCampaignCode() {
return campaignCode;
}
public void setCampaignCode(String campaignCode) {
this.campaignCode = campaignCode;
}
public Long getChannel() {
return channel;
}
public void setChannel(Long channel) {
this.channel = channel;
}
public Long getAccount() {
return account;
}
public void setAccount(Long account) {
this.account = account;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public String getModifyAccount() {
return modifyAccount;
}
public void setModifyAccount(String modifyAccount) {
this.modifyAccount = modifyAccount;
}
public Boolean getAllCampaign() {
return allCampaign;
}
public void setAllCampaign(Boolean allCampaign) {
this.allCampaign = allCampaign;
}
public Boolean getDelFlag() {
return delFlag;
}
public void setDelFlag(Boolean delFlag) {
this.delFlag = delFlag;
}
public Boolean getChannelPermit() {
return channelPermit;
}
public void setChannelPermit(Boolean channelPermit) {
this.channelPermit = channelPermit;
}
@Transient
public List<Long> getCampaignList() {
return campaignList;
}
public void setCampaignList(List<Long> campaignList) {
this.campaignList = campaignList;
}
}
package tkio.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class IsNotified {
private Long id;
private String type;
private Long accountId;
private Boolean isTrackTwoMonthNotified;
private Boolean isTrackOneMonthNotified;
private Boolean isTrackTenDaysNotified;
private Boolean isTrackOneDaysNotified;
private Boolean isTrackExpireNotified;
private Boolean isIoTwoMonthNotified;
private Boolean isIoOneMonthNotified;
private Boolean isIoTenDaysNotified;
private Boolean isIoOneDaysNotified;
private Boolean isIoExpireNotified;
private Boolean isTrackThirtyPercentNotified;
private Boolean isTrackTwentyPercentNotified;
private Boolean isTrackTenPercentNotified;
private Boolean isTrackFivePercentNotified;
private Boolean isTrackExhaustPercentNotified;
private Boolean isIoThirtyPercentNotified;
private Boolean isIoTwentyPercentNotified;
private Boolean isIoTenPercentNotified;
private Boolean isIoFivePercentNotified;
private Boolean isIoExhaustPercentNotified;
private Long previousPackageLevel;
private String firstDayOfThisMonth;
private Boolean thisMonthUpgradeLevel;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long accountId) {
this.accountId = accountId;
}
public Boolean getTrackOneMonthNotified() {
return isTrackOneMonthNotified;
}
public void setTrackOneMonthNotified(Boolean trackOneMonthNotified) {
isTrackOneMonthNotified = trackOneMonthNotified;
}
public Boolean getTrackTenDaysNotified() {
return isTrackTenDaysNotified;
}
public void setTrackTenDaysNotified(Boolean trackTenDaysNotified) {
isTrackTenDaysNotified = trackTenDaysNotified;
}
public Boolean getTrackOneDaysNotified() {
return isTrackOneDaysNotified;
}
public void setTrackOneDaysNotified(Boolean trackOneDaysNotified) {
isTrackOneDaysNotified = trackOneDaysNotified;
}
public Boolean getTrackExpireNotified() {
return isTrackExpireNotified;
}
public void setTrackExpireNotified(Boolean trackExpireNotified) {
isTrackExpireNotified = trackExpireNotified;
}
public Boolean getIoOneMonthNotified() {
return isIoOneMonthNotified;
}
public void setIoOneMonthNotified(Boolean ioOneMonthNotified) {
isIoOneMonthNotified = ioOneMonthNotified;
}
public Boolean getIoTenDaysNotified() {
return isIoTenDaysNotified;
}
public void setIoTenDaysNotified(Boolean ioTenDaysNotified) {
isIoTenDaysNotified = ioTenDaysNotified;
}
public Boolean getIoOneDaysNotified() {
return isIoOneDaysNotified;
}
public void setIoOneDaysNotified(Boolean ioOneDaysNotified) {
isIoOneDaysNotified = ioOneDaysNotified;
}
public Boolean getIoExpireNotified() {
return isIoExpireNotified;
}
public void setIoExpireNotified(Boolean ioExpireNotified) {
isIoExpireNotified = ioExpireNotified;
}
public Boolean getTrackThirtyPercentNotified() {
return isTrackThirtyPercentNotified;
}
public void setTrackThirtyPercentNotified(Boolean trackThirtyPercentNotified) {
isTrackThirtyPercentNotified = trackThirtyPercentNotified;
}
public Boolean getTrackTwentyPercentNotified() {
return isTrackTwentyPercentNotified;
}
public void setTrackTwentyPercentNotified(Boolean trackTwentyPercentNotified) {
isTrackTwentyPercentNotified = trackTwentyPercentNotified;
}
public Boolean getTrackTenPercentNotified() {
return isTrackTenPercentNotified;
}
public void setTrackTenPercentNotified(Boolean trackTenPercentNotified) {
isTrackTenPercentNotified = trackTenPercentNotified;
}
public Boolean getTrackFivePercentNotified() {
return isTrackFivePercentNotified;
}
public void setTrackFivePercentNotified(Boolean trackFivePercentNotified) {
isTrackFivePercentNotified = trackFivePercentNotified;
}
public Boolean getTrackExhaustPercentNotified() {
return isTrackExhaustPercentNotified;
}
public void setTrackExhaustPercentNotified(Boolean trackExhaustPercentNotified) {
isTrackExhaustPercentNotified = trackExhaustPercentNotified;
}
public Boolean getIoThirtyPercentNotified() {
return isIoThirtyPercentNotified;
}
public void setIoThirtyPercentNotified(Boolean ioThirtyPercentNotified) {
isIoThirtyPercentNotified = ioThirtyPercentNotified;
}
public Boolean getIoTwentyPercentNotified() {
return isIoTwentyPercentNotified;
}
public void setIoTwentyPercentNotified(Boolean ioTwentyPercentNotified) {
isIoTwentyPercentNotified = ioTwentyPercentNotified;
}
public Boolean getIoTenPercentNotified() {
return isIoTenPercentNotified;
}
public void setIoTenPercentNotified(Boolean ioTenPercentNotified) {
isIoTenPercentNotified = ioTenPercentNotified;
}
public Boolean getIoFivePercentNotified() {
return isIoFivePercentNotified;
}
public void setIoFivePercentNotified(Boolean ioFivePercentNotified) {
isIoFivePercentNotified = ioFivePercentNotified;
}
public Boolean getIoExhaustPercentNotified() {
return isIoExhaustPercentNotified;
}
public void setIoExhaustPercentNotified(Boolean ioExhaustPercentNotified) {
isIoExhaustPercentNotified = ioExhaustPercentNotified;
}
public Boolean getTrackTwoMonthNotified() {
return isTrackTwoMonthNotified;
}
public void setTrackTwoMonthNotified(Boolean trackTwoMonthNotified) {
isTrackTwoMonthNotified = trackTwoMonthNotified;
}
public Boolean getIoTwoMonthNotified() {
return isIoTwoMonthNotified;
}
public void setIoTwoMonthNotified(Boolean ioTwoMonthNotified) {
isIoTwoMonthNotified = ioTwoMonthNotified;
}
public Long getPreviousPackageLevel() {
return previousPackageLevel;
}
public void setPreviousPackageLevel(Long previousPackageLevel) {
this.previousPackageLevel = previousPackageLevel;
}
public String getFirstDayOfThisMonth() {
return firstDayOfThisMonth;
}
public void setFirstDayOfThisMonth(String firstDayOfThisMonth) {
this.firstDayOfThisMonth = firstDayOfThisMonth;
}
public Boolean getThisMonthUpgradeLevel() {
return thisMonthUpgradeLevel;
}
public void setThisMonthUpgradeLevel(Boolean thisMonthUpgradeLevel) {
this.thisMonthUpgradeLevel = thisMonthUpgradeLevel;
}
}
package tkio.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.math.BigInteger;
/**
* Created by song on 2017/10/19.
*/
@Entity
public class PackageType {
private Long id;
private String packageName;
private String originalName;
private BigInteger trackFlow;
private BigInteger ioFlow;
private Integer appNum;
/**
* 价格
*/
private BigDecimal price; //价格
/**
* 数据量
**/
private Integer dataSurlNum; //创建短链数
private Integer dataConversionFunnelNum; // 转化漏斗数
private Integer dataUserGroupNum; //用户分群数
/**
* 核心功能
**/
private String funcQueryElapsed; //查询速度
private String funcRealtime; //数据实时性
private Boolean funcInstallAttibution; //实时激活归因
private Boolean funcCustomRetainAnalysis; //自定义留存分析
private Boolean funcCustomConversionFunnel; //自定义漏斗
private Boolean funcCustomUserGroup; //自定义用户群
private Boolean funcMultiAnalysisAndOLAP; //多维分析和OLAP
/**
* 管理功能
**/
private Boolean funcMngAuth; //权限管理
private Boolean funcMngSubAccount; //子账号管理
private Boolean funcMngDefendCheatSetting; //防作弊参数设置
private Boolean funcMngUserAttibute;//用户属性管理
private Boolean funcMngAppEvent;//APP事件管理
private Boolean funcMngCampaign;//推广活动管理
private Boolean funcMngRealtimeCallback;//推广实时回调
/**
* 数据接入
*
* @return
*/
private Boolean integrateCatFront;//前端埋点
private Boolean integrateCatEnd;//后端埋点
private Boolean integrateRestAPI;//REST API
private Boolean integrateH5Page;//H5网页
private Boolean integratePCPage;//PC 网页
/**
* 平台功能
*
* @return
*/
private Boolean platformExport;//数据导出
private Integer platformUserProfile;//用户画像能力
private Boolean platformDataStore;//数据存储
private Boolean platformHive;//Hive访问数据
private Boolean platformPresto;//Presto访问数据
private Boolean platformCustomReport;//自定义报表设计
private Boolean platformServiceSupport; //7*24小时客户服务
private Boolean platformCustomDataAnalysis; //专属数据分析师
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getAppNum() {
return appNum;
}
public void setAppNum(Integer appNum) {
this.appNum = appNum;
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public String getOriginalName() {
return originalName;
}
public void setOriginalName(String originalName) {
this.originalName = originalName;
}
public BigInteger getTrackFlow() {
return trackFlow;
}
public void setTrackFlow(BigInteger trackFlow) {
this.trackFlow = trackFlow;
}
public BigInteger getIoFlow() {
return ioFlow;
}
public void setIoFlow(BigInteger ioFlow) {
this.ioFlow = ioFlow;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public Integer getDataSurlNum() {
return dataSurlNum;
}
public void setDataSurlNum(Integer dataSurlNum) {
this.dataSurlNum = dataSurlNum;
}
public Integer getDataConversionFunnelNum() {
return dataConversionFunnelNum;
}
public void setDataConversionFunnelNum(Integer dataConversionFunnelNum) {
this.dataConversionFunnelNum = dataConversionFunnelNum;
}
public Integer getDataUserGroupNum() {
return dataUserGroupNum;
}
public void setDataUserGroupNum(Integer dataUserGroupNum) {
this.dataUserGroupNum = dataUserGroupNum;
}
public String getFuncQueryElapsed() {
return funcQueryElapsed;
}
public void setFuncQueryElapsed(String funcQueryElapsed) {
this.funcQueryElapsed = funcQueryElapsed;
}
public String getFuncRealtime() {
return funcRealtime;
}
public void setFuncRealtime(String funcRealtime) {
this.funcRealtime = funcRealtime;
}
public Boolean getFuncInstallAttibution() {
return funcInstallAttibution;
}
public void setFuncInstallAttibution(Boolean funcInstallAttibution) {
this.funcInstallAttibution = funcInstallAttibution;
}
public Boolean getFuncCustomRetainAnalysis() {
return funcCustomRetainAnalysis;
}
public void setFuncCustomRetainAnalysis(Boolean funcCustomRetainAnalysis) {
this.funcCustomRetainAnalysis = funcCustomRetainAnalysis;
}
public Boolean getFuncCustomConversionFunnel() {
return funcCustomConversionFunnel;
}
public void setFuncCustomConversionFunnel(Boolean funcCustomConversionFunnel) {
this.funcCustomConversionFunnel = funcCustomConversionFunnel;
}
public Boolean getFuncCustomUserGroup() {
return funcCustomUserGroup;
}
public void setFuncCustomUserGroup(Boolean funcCustomUserGroup) {
this.funcCustomUserGroup = funcCustomUserGroup;
}
public Boolean getFuncMultiAnalysisAndOLAP() {
return funcMultiAnalysisAndOLAP;
}
public void setFuncMultiAnalysisAndOLAP(Boolean funcMultiAnalysisAndOLAP) {
this.funcMultiAnalysisAndOLAP = funcMultiAnalysisAndOLAP;
}
public Boolean getFuncMngAuth() {
return funcMngAuth;
}
public void setFuncMngAuth(Boolean funcMngAuth) {
this.funcMngAuth = funcMngAuth;
}
public Boolean getFuncMngSubAccount() {
return funcMngSubAccount;
}
public void setFuncMngSubAccount(Boolean funcMngSubAccount) {
this.funcMngSubAccount = funcMngSubAccount;
}
public Boolean getFuncMngDefendCheatSetting() {
return funcMngDefendCheatSetting;
}
public void setFuncMngDefendCheatSetting(Boolean funcMngDefendCheatSetting) {
this.funcMngDefendCheatSetting = funcMngDefendCheatSetting;
}
public Boolean getFuncMngUserAttibute() {
return funcMngUserAttibute;
}
public void setFuncMngUserAttibute(Boolean funcMngUserAttibute) {
this.funcMngUserAttibute = funcMngUserAttibute;
}
public Boolean getFuncMngAppEvent() {
return funcMngAppEvent;
}
public void setFuncMngAppEvent(Boolean funcMngAppEvent) {
this.funcMngAppEvent = funcMngAppEvent;
}
public Boolean getFuncMngCampaign() {
return funcMngCampaign;
}
public void setFuncMngCampaign(Boolean funcMngCampaign) {
this.funcMngCampaign = funcMngCampaign;
}
public Boolean getFuncMngRealtimeCallback() {
return funcMngRealtimeCallback;
}
public void setFuncMngRealtimeCallback(Boolean funcMngRealtimeCallback) {
this.funcMngRealtimeCallback = funcMngRealtimeCallback;
}
public Boolean getIntegrateCatFront() {
return integrateCatFront;
}
public void setIntegrateCatFront(Boolean integrateCatFront) {
this.integrateCatFront = integrateCatFront;
}
public Boolean getIntegrateCatEnd() {
return integrateCatEnd;
}
public void setIntegrateCatEnd(Boolean integrateCatEnd) {
this.integrateCatEnd = integrateCatEnd;
}
public Boolean getIntegrateRestAPI() {
return integrateRestAPI;
}
public void setIntegrateRestAPI(Boolean integrateRestAPI) {
this.integrateRestAPI = integrateRestAPI;
}
public Boolean getIntegrateH5Page() {
return integrateH5Page;
}
public void setIntegrateH5Page(Boolean integrateH5Page) {
this.integrateH5Page = integrateH5Page;
}
public Boolean getIntegratePCPage() {
return integratePCPage;
}
public void setIntegratePCPage(Boolean integratePCPage) {
this.integratePCPage = integratePCPage;
}
public Boolean getPlatformExport() {
return platformExport;
}
public void setPlatformExport(Boolean platformExport) {
this.platformExport = platformExport;
}
public Integer getPlatformUserProfile() {
return platformUserProfile;
}
public void setPlatformUserProfile(Integer platformUserProfile) {
this.platformUserProfile = platformUserProfile;
}
public Boolean getPlatformDataStore() {
return platformDataStore;
}
public void setPlatformDataStore(Boolean platformDataStore) {
this.platformDataStore = platformDataStore;
}
public Boolean getPlatformHive() {
return platformHive;
}
public void setPlatformHive(Boolean platformHive) {
this.platformHive = platformHive;
}
public Boolean getPlatformPresto() {
return platformPresto;
}
public void setPlatformPresto(Boolean platformPresto) {
this.platformPresto = platformPresto;
}
public Boolean getPlatformCustomReport() {
return platformCustomReport;
}
public void setPlatformCustomReport(Boolean platformCustomReport) {
this.platformCustomReport = platformCustomReport;
}
public Boolean getPlatformServiceSupport() {
return platformServiceSupport;
}
public void setPlatformServiceSupport(Boolean platformServiceSupport) {
this.platformServiceSupport = platformServiceSupport;
}
public Boolean getPlatformCustomDataAnalysis() {
return platformCustomDataAnalysis;
}
public void setPlatformCustomDataAnalysis(Boolean platformCustomDataAnalysis) {
this.platformCustomDataAnalysis = platformCustomDataAnalysis;
}
}
package tkio.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
@Entity
public class RoleAuth {
private Long id;
private Long roleCategory;
private String auth;
private Boolean payAuth;
private Boolean retentionAuth;
private Boolean isNatureOpen;
private Boolean topAuth;
private String roleName;
private Long createAccount;
private Date createTime;
private Long modifyAccount;
private Date modifyTime;
private Boolean delFlag;
//@Transient
private List<RoleAuthDetail> roleAuthDetails;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getRoleCategory() {
return roleCategory;
}
public void setRoleCategory(Long roleCategory) {
this.roleCategory = roleCategory;
}
public String getAuth() {
return auth;
}
public void setAuth(String auth) {
this.auth = auth;
}
public Boolean getPayAuth() {
return payAuth;
}
public void setPayAuth(Boolean payAuth) {
this.payAuth = payAuth;
}
public Boolean getRetentionAuth() {
return retentionAuth;
}
public void setRetentionAuth(Boolean retentionAuth) {
this.retentionAuth = retentionAuth;
}
public Boolean getIsNatureOpen() {
return isNatureOpen;
}
public void setIsNatureOpen(Boolean isNatureOpen) {
this.isNatureOpen = isNatureOpen;
}
public Boolean getTopAuth() {
return topAuth;
}
public void setTopAuth(Boolean topAuth) {
this.topAuth = topAuth;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public Long getCreateAccount() {
return createAccount;
}
public void setCreateAccount(Long createAccount) {
this.createAccount = createAccount;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Long getModifyAccount() {
return modifyAccount;
}
public void setModifyAccount(Long modifyAccount) {
this.modifyAccount = modifyAccount;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public Boolean getDelFlag() {
return delFlag;
}
public void setDelFlag(Boolean delFlag) {
this.delFlag = delFlag;
}
@Transient
public List<RoleAuthDetail> getRoleAuthDetails() {
return roleAuthDetails;
}
public void setRoleAuthDetails(List<RoleAuthDetail> roleAuthDetails) {
this.roleAuthDetails = roleAuthDetails;
}
@Override
public String toString() {
return "RoleAuth [id=" + id + ", roleCategory=" + roleCategory
+ ", auth=" + auth + "]";
}
}
package tkio.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
* Created by sunhao on 17/6/6.
* description:角色权限的详情
*/
@Entity
public class RoleAuthDetail {
private Long id;
private String auth;
private String authName;
private String parentAuth;
private int sort;
private Boolean view;
private Boolean edit;
private Long roleId;
public RoleAuthDetail() {}
public RoleAuthDetail(RoleAuthDetail roleAuthDetail) {
this.auth = roleAuthDetail.getAuth();
this.authName = roleAuthDetail.getAuthName();
this.parentAuth = roleAuthDetail.getParentAuth();
this.sort = roleAuthDetail.getSort();
this.view = roleAuthDetail.getView();
this.edit = roleAuthDetail.getEdit();
this.roleId = roleAuthDetail.getRoleId();
}
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAuth() {
return auth;
}
public void setAuth(String auth) {
this.auth = auth;
}
public String getAuthName() {
return authName;
}
public void setAuthName(String authName) {
this.authName = authName;
}
public String getParentAuth() {
return parentAuth;
}
public void setParentAuth(String parentAuth) {
this.parentAuth = parentAuth;
}
public int getSort() {
return sort;
}
public void setSort(int sort) {
this.sort = sort;
}
public Boolean getView() {
return view;
}
public void setView(Boolean view) {
this.view = view;
}
public Boolean getEdit() {
return edit;
}
public void setEdit(Boolean edit) {
this.edit = edit;
}
public Long getRoleId() {
return roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
}
package tkio.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class SalesManLeader {
private int id;
private String area;
private String email;
private String name;
private int leader;
@Id
@GeneratedValue
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getLeader() {
return leader;
}
public void setLeader(int leader) {
this.leader = leader;
}
}
package tkio.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.Date;
@Entity
public class UserLog {
private Long id;
private String type;
private String email;
private boolean isMasterLogin;
private String operaType;
@Column(length=2000)
private String operaContent;
private Date pubDate = new Date();
private String ds;
private Long app;
private String appName;
private String objectType;
private String ip;
private String location;
public UserLog() {
super();
}
public String getEmail() {
return email;
}
@Id
@GeneratedValue
public Long getId() {
return id;
}
public Date getPubDate() {
return pubDate;
}
public void setEmail(String email) {
this.email = email;
}
public void setId(Long id) {
this.id = id;
}
public void setPubDate(Date pubDate) {
this.pubDate = pubDate;
}
public String getOperaType() {
return operaType;
}
public void setOperaType(String operaType) {
this.operaType = operaType;
}
public String getOperaContent() {
return operaContent;
}
public void setOperaContent(String operaContent) {
this.operaContent = operaContent;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDs() {
return ds;
}
public void setDs(String ds) {
this.ds = ds;
}
public Long getApp() {
return app;
}
public void setApp(Long app) {
this.app = app;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getObjectType() {
return objectType;
}
public void setObjectType(String objectType) {
this.objectType = objectType;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public boolean isMasterLogin() {
return isMasterLogin;
}
public void setMasterLogin(boolean isMasterLogin) {
this.isMasterLogin = isMasterLogin;
}
@Override
public String toString()
{
return "UserLog{" +
"id=" + id +
", type='" + type + '\'' +
", email='" + email + '\'' +
", isMasterLogin=" + isMasterLogin +
", operaType='" + operaType + '\'' +
", operaContent='" + operaContent + '\'' +
", pubDate=" + pubDate +
", ds='" + ds + '\'' +
", app=" + app +
", appName='" + appName + '\'' +
", objectType='" + objectType + '\'' +
", ip='" + ip + '\'' +
", location='" + location + '\'' +
'}';
}
}
package tkio.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import tkio.model.Account;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
@Transactional
public interface AccountRepository extends JpaRepository<Account, Long> {
@Query(value = "select root_parent from account where id=?1", nativeQuery = true)
BigInteger findRootParentByAccountId(Long accountId);
@Query(value = "SELECT * from account where is_super_user is true and `status` = 1 and past_date > ?1", nativeQuery = true)
List<Account> findRootParentsUnPast(String today);
@Query(value = "SELECT * from account where is_super_user is true and `status` = 1 and past_date < ?1", nativeQuery = true)
List<Account> findRootParentsPast(String today);
}
package tkio.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import tkio.model.App;
import java.util.List;
public interface AppRepository extends JpaRepository<App, Long> {
@Query(value = "select * from app where account in (select id from account where parent = ?1 or id = ?1) and del_flag is not true", nativeQuery = true)
List<App> listAppByRootAccount(Long account);
@Query(value="select appkey from app where id = ?1",nativeQuery=true)
String findAppkeyById(Long id);
List<App> findByAccount(Long account);
@Query(value = "select * from app where account =?1 and bundleid = ?2 and del_flag is not true", nativeQuery = true)
App findByBundleidInNotDel(Long account, String bundleid);
@Query(value = "select * from app where account =?1 and name = ?2 and del_flag is not true", nativeQuery = true)
App findByNameNotDel(Long account, String name);
@Query(value = "select * from app where sync_ddb is false and del_flag is not true", nativeQuery = true)
List<App> findNotSyncAppDebug();
@Query(value = "select * from app where token = ?1 limit 1", nativeQuery = true)
App findOneByAppToken(String token);
@Query(value = "select * from app where id in ?1", nativeQuery = true)
List<App> findByIds(List<Long> ids);
@Query(value = "SELECT DISTINCT t2.* FROM campaign t0 JOIN channel t1 ON t0.channel = t1.id JOIN app t2 ON t0.app = t2.id WHERE t0.del_flag is not true and (t1.type!='ry_coop' or t1.type is NULL) and t1.category = 'ADVERTISING' and t2.id in ?1 and t2.platform = ?2 and t2.del_flag is not TRUE" , nativeQuery = true)
List<App> findAppsFromOnelink(List<Long> appids, String platform);
@Query(value = "SELECT DISTINCT t2.* FROM campaign t0 JOIN channel t1 ON t0.channel = t1.id JOIN app t2 ON t0.app = t2.id WHERE t0.del_flag is not true and (t1.type!='ry_coop' or t1.type is NULL) and t1.category = 'ADVERTISING' and t2.id = ?1" , nativeQuery = true)
App findAppFromOnelink(Long appid);
@Query(value = "select * from app where appkey in ?1", nativeQuery = true)
List<App> findByAppkeys(List<String> appkeys);
@Query(value = "select * from app a join auth b on a.id = b.app where b.account = ?1 and b.create_account in (select id from account where root_parent = ?2) ", nativeQuery = true)
List<App> findAuthAppByRootParent(Long subAccountId, Long rootParent);
@Query(value = "select * from app a join auth b on a.id = b.app where b.account = ?1 ", nativeQuery = true)
List<App> findAuthApp(Long subAccountId);
@Query(value="select platform from app where id = ?1",nativeQuery=true)
String findPlatformByAppId(Long appId);
@Query(value="select categoryname from category where categoryid=(select game_genre from app where id=?1);",nativeQuery=true)
String findGameCategoryByAppID(Long appId);
@Query(value="select categoryname from category where categoryid=(select app_genre from app where id=?1);",nativeQuery=true)
String findAppGenreNameByAppID(Long id);
@Query(value = "select DISTINCT a.* from app a right join data_auth d on a.id = d.app where d.account = ?1 and d.app in ?2 and d.channel = ?3 and (d.all_campaign is true or d.channel_permit is true)", nativeQuery = true)
List<App> listTotalAuthorizedApp(Long accountId, List<Long> appIdList, Long channelId);
@Query(value = "select create_account from app where appkey=?1", nativeQuery = true)
String findCreateAccountByAppkey(String appKey);
@Query(value = "select DISTINCT a.* from app a right join data_auth d on a.id = d.app where d.account = ?1 and d.channel = ?2 and (d.all_campaign is true or d.channel_permit is true)", nativeQuery = true)
List<App> listApps(Long accountId, Long channelId);
}
package tkio.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import tkio.model.IsNotified;
@Transactional
public interface IsNotifiedRepository extends JpaRepository<IsNotified, Long> {
@Query(value = "select * from is_notified where account_id=?1", nativeQuery = true)
IsNotified findIsNotifiedByAccountId(Long accountId);
@Modifying
@Transactional
@Query(value = "delete from is_notified where account_id=?1", nativeQuery = true)
int deleteByAccountId(Long accountId);
}
package tkio.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import tkio.model.PackageType;
public interface PackageTypeRepository extends JpaRepository<PackageType, Long> {
@Query(value = "select * from package_type where id=(select pricelevel from account where id=?1)", nativeQuery = true)
PackageType findPackageTypeByRootParent(Long rootParent);
@Query(value = "select * from package_type where id=?1", nativeQuery = true)
PackageType findPackageTypeByID(Long ID);
}
package tkio.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import tkio.model.SalesManLeader;
@Transactional
public interface SalesManLeaderRepository extends JpaRepository<SalesManLeader, Long> {
@Query(value = "select email from sales_man_leader where id=(select leader from sales_man_leader where id=?1)", nativeQuery = true)
String findLeaderByBussinessMan(Long bussinessMan);
}
package tkio.service;
import tkio.model.AccountRestrict4Web;
import java.math.BigInteger;
/**
* Created by song on 2017/10/19.
*/
public interface AccountFlowRestrictService {
AccountRestrict4Web findRestrictByAccount(Long accountId);
BigInteger getTotalNum(String createTime, String pastDate, String appids, String reportName, String sumType);
Boolean isTrackAndIoBothExhaust(Long accountId);
Boolean isTrackExhaust(Long accountId);
}
package tkio.service.impl;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import tkio.model.*;
import tkio.repository.*;
import tkio.service.AccountFlowRestrictService;
import util.Constant;
import util.DateUtil;
import util.HttpClientUtil;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Created by song on 2017/10/19.
*/
@Service
public class AccountFlowRestrictServiceImpl implements AccountFlowRestrictService {
@Autowired
private AppRepository appRepository;
@Autowired
private AccountRepository accountRepository;
@Autowired
private PackageTypeRepository packageTypeRepository;
@Autowired
private IsNotifiedRepository isNotifiedRepository;
@Autowired
private SalesManLeaderRepository salesManLeaderRepository;
@Override
public AccountRestrict4Web findRestrictByAccount(Long accountId) {
Long rootParent = accountRepository.findRootParentByAccountId(accountId).longValue();
AccountRestrict4Web accountRestrict4Web = new AccountRestrict4Web();
Account one = accountRepository.findOne(accountId);
List<App> apps = appRepository.listAppByRootAccount(rootParent);
Account rootAccount = accountRepository.findOne(rootParent);
String companyOrEmail = rootAccount.getCompany() != null ? rootAccount.getCompany() : rootAccount.getEmail();
IsNotified isNotifiedObject = isNotifiedRepository.findIsNotifiedByAccountId(rootParent);
boolean isTrackProduct = true;
boolean isIOProduct = rootAccount.getAllowBehavior();
StringBuffer appsStr = new StringBuffer();
for (App app : apps) {
appsStr = appsStr.append("\'" + app.getAppkey() + "\'" + ",");
}
String appids = "";
if (apps.size() != 0) {
appids = appsStr.substring(0, appsStr.length() - 1);
}
PackageType packageType = packageTypeRepository.findPackageTypeByRootParent(rootParent);
Boolean flowRestrict = rootAccount.getFlowRestrict();
String pastDate = rootAccount.getPastDate();
String trackBeginTime;
Date rootCreateTime = rootAccount.getCreateTime();
String createTime = DateUtil.format(rootCreateTime, "yyyy-MM-dd");
trackBeginTime = (rootAccount.getNewContract() != null && rootAccount.getNewContract()) ? rootAccount.getModifyPricelevelTime() : createTime;
Date currentDate = DateUtil.getCurrentDate();
String currentDateStr = DateUtil.getCurrentDateStr();
int remainingDays = DateUtil.daysBetween(currentDate, DateUtil.parseDate(pastDate)) + 1;
String salesManLeaderEmail = salesManLeaderRepository.findLeaderByBussinessMan(rootAccount.getBussinessman());
ArrayList<String> emailList = new ArrayList<>();
emailList.add(salesManLeaderEmail);
Date lastMonth = getLastMonth(1);
String firstDayOfLastMonth = DateUtil.getFirstDayOfMonth(lastMonth);
String lastDayOfLastMonth = DateUtil.getLastDayOfMonth(lastMonth);
String firstDayOfThisMonth = DateUtil.getFirstDayOfMonth(new Date());
BigInteger clickNum =new BigInteger("0");
BigInteger lastThreeDaysClickNum1=new BigInteger("0");
if(apps.size()>0) {
clickNum = getTotalNum(trackBeginTime, pastDate, appids, "account_track_flow_restrict", "click_sum");
//lastThreeDaysClickNum1 = getTotalNum(trackBeginTime, currentDateStr, appids, "account_track_three_days_flow_restrict", "click_sum");
}
//BigInteger lastThreeDaysClickNum = lastThreeDaysClickNum1.compareTo(new BigInteger("0")) != 0 ? lastThreeDaysClickNum1 : new BigInteger("1");
// int trackRemainDays = (int) Math.floor((packageType.getTrackFlow().doubleValue() - clickNum.doubleValue()) / ((lastThreeDaysClickNum.doubleValue() / 3)));
// double trackRemainPercent = 1.0 - clickNum.doubleValue() / packageType.getTrackFlow().doubleValue();
// DecimalFormat decimalFormat = new DecimalFormat("0%");
//String trackRemainPercent1 = decimalFormat.format(trackRemainPercent);
String IOBeginTime = (isNotifiedObject != null && isNotifiedObject.getThisMonthUpgradeLevel() != null && isNotifiedObject.getThisMonthUpgradeLevel()) ? rootAccount.getModifyPricelevelTime() : firstDayOfThisMonth;
BigInteger lastMonthEventNum=new BigInteger("0");
BigInteger thisMonthEventNum=new BigInteger("0");
BigInteger lastThreeDaysEventNum=new BigInteger("0");
if(apps.size()>0){
lastMonthEventNum = getTotalNum(firstDayOfLastMonth, lastDayOfLastMonth, appids, "account_io_flow_restrict", "event_sum");
thisMonthEventNum = getTotalNum(IOBeginTime, currentDateStr, appids, "account_io_flow_restrict", "event_sum");
lastThreeDaysEventNum = getTotalNum(IOBeginTime, currentDateStr, appids, "account_io_three_days_flow_restrict", "event_sum");
}
BigInteger lastMonthExceedNum = (lastMonthEventNum.subtract(packageType.getIoFlow()).compareTo(new BigInteger("0")) == 1) ? lastMonthEventNum.subtract(packageType.getIoFlow()) : new BigInteger("0");
if (isNotifiedObject != null && isNotifiedObject.getThisMonthUpgradeLevel() != null && isNotifiedObject.getThisMonthUpgradeLevel()) {
lastMonthExceedNum = new BigInteger("0");
}
double v = packageType.getIoFlow().doubleValue() * 1 - lastMonthExceedNum.doubleValue();
DecimalFormat decimalFormat1 = new DecimalFormat("0");
String format = decimalFormat1.format(v);
BigInteger thisMonthAvailableTotalFlow = new BigInteger(format);
BigInteger thisMonthRemainingFlow = thisMonthAvailableTotalFlow.subtract(thisMonthEventNum);
int IORemainDays = -1;
if (lastThreeDaysEventNum.compareTo(new BigInteger("1")) == 1) {
IORemainDays = (int) (Math.floor(Double.valueOf(thisMonthRemainingFlow.divide(lastThreeDaysEventNum.divide(new BigInteger("3"))).toString())));
}
double ioRemainPercent = thisMonthRemainingFlow.doubleValue() / thisMonthAvailableTotalFlow.doubleValue();
//String ioRemainPercent1 = decimalFormat.format(ioRemainPercent);
accountRestrict4Web.setPastDate(pastDate);
accountRestrict4Web.setPackageName(packageType.getPackageName());
accountRestrict4Web.setOriginalName(packageType.getOriginalName());
accountRestrict4Web.setIOLimit(packageType.getIoFlow());
accountRestrict4Web.setTrackLimit(packageType.getTrackFlow());
accountRestrict4Web.setThisMonthIOFlow(thisMonthEventNum);
accountRestrict4Web.setTrackTotalFlow(clickNum);
accountRestrict4Web.setAccountId(rootParent);
accountRestrict4Web.setPriceLevel(rootAccount.getPricelevel().intValue());
accountRestrict4Web.setLastMonthIOFlow(lastMonthEventNum);
accountRestrict4Web.setIORemainPercent(ioRemainPercent);
//accountRestrict4Web.setTrackRemainPercent(trackRemainPercent);
accountRestrict4Web.setiOremainingDays(IORemainDays);
//accountRestrict4Web.setTrackRemainingDays(trackRemainDays);
accountRestrict4Web.setPackLevel(new Long(packageType.getId()));
accountRestrict4Web.setFlowRestrict(flowRestrict);
accountRestrict4Web.setAllowBehavior(isIOProduct);
if ((packageType.getId() == 7 || packageType.getId() == 8 || packageType.getId() == 5)) {
accountRestrict4Web.setPackageName("包年套餐");
}
boolean ioFlag = true;
boolean ioStatus = true;
boolean trackFlag = true;
boolean trackStatus = true;
if (rootParent.equals(accountId)) {
if (!(packageType.getId() == 7 || packageType.getId() == 8 || packageType.getId() == 5) && flowRestrict) {
/**
* 不是超级用户,是包流量的用户
*/
if (isTrackProduct) {
boolean tenPercent = (packageType.getTrackFlow().doubleValue() * 0.9 <= clickNum.doubleValue()) && (packageType.getTrackFlow().doubleValue() * 0.95 > clickNum.doubleValue());
boolean exPercent = packageType.getTrackFlow().doubleValue() <= clickNum.doubleValue();
if (exPercent) {
ioFlag = false;
ioStatus = false;
}else if (tenPercent && (isNotifiedObject.getTrackTenPercentNotified() == null || !isNotifiedObject.getTrackTenPercentNotified())) {
ioStatus = false;
}
}
if (isIOProduct) {
boolean tenPercent = (thisMonthAvailableTotalFlow.doubleValue() * 0.9 <= thisMonthEventNum.doubleValue()) && (thisMonthAvailableTotalFlow.doubleValue() * 0.95 > thisMonthEventNum.doubleValue());
boolean exPercent = thisMonthAvailableTotalFlow.doubleValue() * 1 <= thisMonthEventNum.doubleValue();
if (exPercent) {
trackFlag = false;
trackStatus = false;
}else if (tenPercent && (isNotifiedObject.getIoTenPercentNotified() == null || !isNotifiedObject.getIoTenPercentNotified())) {
trackStatus = false;
}
}
//是否流量用尽
if(!ioFlag && !trackFlag){
accountRestrict4Web.setIOFlowNotified(false);
} else{
accountRestrict4Web.setIOFlowNotified(true);
}
accountRestrict4Web.setAllowBehavior(ioStatus);
accountRestrict4Web.setTrackFlowNotified(trackStatus);
}
}
return accountRestrict4Web;
}
/**
* 查询广告效果监控产品的点击量和行为分析产品的点击量的方法
*/
@Override
public BigInteger getTotalNum(String createTime, String pastDate, String appids, String reportName, String
sumType) {
Long appId = 1218L;
Map<String, String> conditions = new HashMap<String, String>();
conditions.put("appids", appids);
conditions.put("startdate", createTime);
conditions.put("enddate", pastDate);
conditions.put("datatype", "list");
conditions.put("iscache", "0");
String url = Constant.reportUrl + "/api/trackingio/" + reportName + "/" + appId;
String responseJson = HttpClientUtil.doHttpPostRequest(url, "trackingio", conditions);
//System.out.println(reportName + "===========================" + responseJson);
HashMap<String, String> resultValMap = new HashMap<>();
String click_sum = "";
String s = "";
try {
JSONObject jsonObject = new JSONObject(responseJson);
Iterator keys = jsonObject.keys();
while (keys.hasNext()) {
String key = (String) keys.next();
String value = jsonObject.getString(key);
resultValMap.put(key, value);
}
String val = resultValMap.get("val");
JSONArray jsonArray = new JSONArray(val);
JSONObject jsonObject1 = jsonArray.getJSONObject(0);
click_sum = jsonObject1.getString(sumType);
if (StringUtils.isEmpty(click_sum) || "0".equals(click_sum)) {
click_sum = "0";
}
Double aDouble = Double.valueOf(click_sum);
BigDecimal bigDecimal = new BigDecimal(aDouble);
s = bigDecimal.toPlainString();
//System.out.println(sumType + "=======================" + s);
} catch (JSONException e) {
e.printStackTrace();
}
return new BigInteger(s);
}
@Override
public Boolean isTrackAndIoBothExhaust(Long accountId) {
Long rootParent = accountRepository.findRootParentByAccountId(accountId).longValue();
List<App> apps = appRepository.listAppByRootAccount(rootParent);
Boolean isBothExhaust = false;
if (apps.size() != 0) {
Account rootAccount = accountRepository.findOne(rootParent);
StringBuffer appsStr = new StringBuffer();
for (App app : apps) {
appsStr = appsStr.append("\'" + app.getAppkey() + "\'" + ",");
}
String appids = appsStr.substring(0, appsStr.length() - 1);
/**
* 1.根据母帐号获取用户等级
*/
PackageType packageType = packageTypeRepository.findPackageTypeByRootParent(rootParent);
Boolean flowRestrict = rootAccount.getFlowRestrict();
String pastDate = rootAccount.getPastDate();
String trackBeginTime;
Date rootCreateTime = rootAccount.getCreateTime();
String createTime = DateUtil.format(rootCreateTime, "yyyy-MM-dd");
trackBeginTime = (rootAccount.getNewContract() != null && rootAccount.getNewContract()) ? rootAccount.getModifyPricelevelTime() : createTime;
String currentDateStr = DateUtil.getCurrentDateStr();
Date lastMonth = getLastMonth(1);
String firstDayOfLastMonth = DateUtil.getFirstDayOfMonth(lastMonth);
String lastDayOfLastMonth = DateUtil.getLastDayOfMonth(lastMonth);
String firstDayOfThisMonth = DateUtil.getFirstDayOfMonth(new Date());
BigInteger clickNum = getTotalNum(trackBeginTime, pastDate, appids, "account_track_flow_restrict", "click_sum");
IsNotified isNotifiedObject = isNotifiedRepository.findIsNotifiedByAccountId(rootParent);
String IOBeginTime = (isNotifiedObject != null && isNotifiedObject.getThisMonthUpgradeLevel() != null && isNotifiedObject.getThisMonthUpgradeLevel()) ? rootAccount.getModifyPricelevelTime() : firstDayOfThisMonth;
BigInteger lastMonthEventNum = getTotalNum(firstDayOfLastMonth, lastDayOfLastMonth, appids, "account_io_flow_restrict", "event_sum");
BigInteger thisMonthEventNum = getTotalNum(IOBeginTime, currentDateStr, appids, "account_io_flow_restrict", "event_sum");
BigInteger lastMonthExceedNum = (lastMonthEventNum.subtract(packageType.getIoFlow()).compareTo(new BigInteger("0")) == 1) ? lastMonthEventNum.subtract(packageType.getIoFlow()) : new BigInteger("0");
if (isNotifiedObject != null && isNotifiedObject.getThisMonthUpgradeLevel() != null && isNotifiedObject.getThisMonthUpgradeLevel()) {
lastMonthExceedNum = new BigInteger("0");
}
double v = packageType.getIoFlow().doubleValue() * 1 - lastMonthExceedNum.doubleValue();
DecimalFormat decimalFormat1 = new DecimalFormat("0");
String format = decimalFormat1.format(v);
BigInteger thisMonthAvailableTotalFlow = new BigInteger(format);
BigInteger thisMonthRemainingFlow = thisMonthAvailableTotalFlow.subtract(thisMonthEventNum);
if (!(packageType.getId() == 7 || packageType.getId() == 8 || packageType.getId() == 5) && flowRestrict) {
if (rootAccount.getAllowBehavior()) {
isBothExhaust = (packageType.getTrackFlow().doubleValue() - clickNum.doubleValue() < 0) && thisMonthRemainingFlow.doubleValue() < 0;
} else {
isBothExhaust = (packageType.getTrackFlow().doubleValue() - clickNum.doubleValue() < 0);
}
}
}
return isBothExhaust;
}
@Override
public Boolean isTrackExhaust(Long accountId) {
Long rootParent = accountRepository.findRootParentByAccountId(accountId).longValue();
List<App> apps = appRepository.listAppByRootAccount(rootParent);
Boolean isBothExhaust = false;
if (apps.size() != 0) {
Account rootAccount = accountRepository.findOne(rootParent);
StringBuffer appsStr = new StringBuffer();
for (App app : apps) {
appsStr = appsStr.append("\'" + app.getAppkey() + "\'" + ",");
}
String appids = appsStr.substring(0, appsStr.length() - 1);
/**
* 1.根据母帐号获取用户等级
*/
PackageType packageType = packageTypeRepository.findPackageTypeByRootParent(rootParent);
Boolean flowRestrict = rootAccount.getFlowRestrict();
String pastDate = rootAccount.getPastDate();
String trackBeginTime;
Date rootCreateTime = rootAccount.getCreateTime();
String createTime = DateUtil.format(rootCreateTime, "yyyy-MM-dd");
trackBeginTime = (rootAccount.getNewContract() != null && rootAccount.getNewContract()) ? rootAccount.getModifyPricelevelTime() : createTime;
BigInteger clickNum = getTotalNum(trackBeginTime, pastDate, appids, "account_track_flow_restrict", "click_sum");
if (!(packageType.getId() == 7 || packageType.getId() == 8 || packageType.getId() == 5) && flowRestrict) {
isBothExhaust = (packageType.getTrackFlow().doubleValue() - clickNum.doubleValue() < 0);
}
}
return isBothExhaust;
}
public Date getLastMonth(int i) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.MONTH, -i);
Date time = calendar.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String format = sdf.format(time);
calendar.setTime(new Date());
return time;
}
}
package tkio.task;
import common.model.Account4Web;
import common.repository.Account4WebRepository;
import org.springframework.beans.factory.annotation.Autowired;
import tkio.model.Account;
import tkio.model.AccountRestrict4Web;
import tkio.model.PackageType;
import tkio.repository.AccountRepository;
import tkio.repository.PackageTypeRepository;
import tkio.service.AccountFlowRestrictService;
import util.DateUtil;
import util.ValidateUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by mxq on 2017/12/25.
*/
public class AccountTask {
@Autowired
AccountRepository accountRepository;
@Autowired
Account4WebRepository account4WebRepository;
@Autowired
AccountFlowRestrictService accountFlowRestrictService;
@Autowired
private PackageTypeRepository packageTypeRepository;
public void task(){
List<Account4Web> list = new ArrayList<>();
//未过期的查询是否流量到期
List<Account> accountValidList = accountRepository.findRootParentsUnPast(DateUtil.getBeforeDays(1));
if(ValidateUtil.isValid(accountValidList)){
for(Account ac : accountValidList){
AccountRestrict4Web restrict4Web = accountFlowRestrictService.findRestrictByAccount(ac.getId());
Account4Web account4Web = new Account4Web();
account4Web.setEmail(ac.getEmail());
account4Web.setCompany(ac.getCompany());
account4Web.setCreateDate(ac.getCreateTime());
account4Web.setStatus(null == restrict4Web.getIOFlowNotified() ? "已激活" : (restrict4Web.getIOFlowNotified() ? "已激活" : "流量用尽"));
account4Web.setPackageType(restrict4Web.getPackageName());
account4Web.setPastDate(ac.getPastDate());
if (ac.getPricelevel().equals(7L) || ac.getPricelevel().equals(8L) || ac.getPricelevel().equals(5L)){
account4Web.setIo(restrict4Web.getThisMonthIOFlow().toString());
account4Web.setTrack(restrict4Web.getTrackTotalFlow().toString());
}else{
account4Web.setIo(restrict4Web.getThisMonthIOFlow() + "/" + restrict4Web.getIOLimit());
account4Web.setTrack(restrict4Web.getTrackTotalFlow() + "/" + restrict4Web.getTrackLimit());
}
account4Web.setIoStatus(restrict4Web.getAllowBehavior());
account4Web.setTrackStatus(restrict4Web.getTrackFlowNotified());
account4Web.setUser(ac.getBussinessman().toString());
list.add(account4Web);
}
}
//已过期的直接设置成过期
List<Account> pastAccountList = accountRepository.findRootParentsPast(DateUtil.getBeforeDays(0));
List<PackageType> packageTypeList = packageTypeRepository.findAll();
Map<Long, String> map = new HashMap<>();
for(PackageType pt : packageTypeList){
map.put(pt.getId(), pt.getPackageName());
}
if(ValidateUtil.isValid(pastAccountList)){
for(Account ac : pastAccountList){
Account4Web account4Web = new Account4Web();
account4Web.setEmail(ac.getEmail());
account4Web.setCompany(ac.getCompany());
account4Web.setCreateDate(ac.getCreateTime());
account4Web.setStatus("已过期");
account4Web.setPackageType(map.get(ac.getPricelevel()));
account4Web.setPastDate(ac.getPastDate());
account4Web.setIo("----");
account4Web.setTrack("----");
account4Web.setIoStatus(false);
account4Web.setTrackStatus(false);
account4Web.setUser(ac.getBussinessman().toString());
list.add(account4Web);
}
}
account4WebRepository.save(list);
}
}
...@@ -19,6 +19,8 @@ public class Constant { ...@@ -19,6 +19,8 @@ public class Constant {
public static List<String> mlist = Arrays.asList(mailList.split(",")); public static List<String> mlist = Arrays.asList(mailList.split(","));
public static String mailValidTime = mailBundle.getString("mail.valid_time"); public static String mailValidTime = mailBundle.getString("mail.valid_time");
public static ResourceBundle commonBundle = ResourceBundle.getBundle("common");
public static String reportUrl = commonBundle.getString("report.url");
......
package util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 日期转换工具
*/
public class DateUtil {
protected static Logger logger = LoggerFactory.getLogger(DateUtil.class);
public static final String C_DATE_DIVISION = "-";
public static final String C_TIME_PATTON_DEFAULT = "yyyy-MM-dd HH:mm:ss";
public static final String C_MIN_PATTON_DEFAULT = "yyyy-MM-dd HH:mm";
public static final String C_DATE_PATTON_DEFAULT = "yyyy-MM-dd";
public static final String C_YM_PATTON_DEFAULT = "yyyy-MM";
public static final String C_DATA_PATTON_YYYYMMDD = "yyyyMMdd";
public static final String C_DATA_PATTON_MM_DD = "MM-dd";
public static final String C_DATA_PATTON_MM = "MM";
public static final String C_DATA_PATTON_HH = "HH";
public static final String C_TIME_PATTON_HHMM = "HH:mm";
public static final String C_TIME_PATTON_HHMMSS = "HH:mm:ss";
public static final String C_TIME_PATTON_HHMMSSMM = "HH:MM:SS:MM";
public static final int C_ONE_SECOND = 1000;
public static final int C_ONE_MINUTE = 60 * C_ONE_SECOND;
public static final int C_ONE_HOUR = 60 * C_ONE_MINUTE;
public static final long C_ONE_DAY = 24L * C_ONE_HOUR;
/**
* Return the current date
*
* @return - DATE<br>
*/
public static Date getCurrentDate() {
Calendar cal = Calendar.getInstance();
Date currDate = cal.getTime();
return currDate;
}
/**
* Return the current date string
*
* @return - 产生的日期字符串<br>
*/
public static String getCurrentDateStr() {
Calendar cal = Calendar.getInstance();
Date currDate = cal.getTime();
return format(currDate);
}
/**
* Return the current date in the specified format
*
* @param strFormat
* @return
*/
public static String getCurrentDateStr(String strFormat) {
Calendar cal = Calendar.getInstance();
Date currDate = cal.getTime();
return format(currDate, strFormat);
}
/**
* Parse a string and return a date value
*
* @param dateValue
* @return
* @throws Exception
*/
public static Date parseDate(String dateValue) {
return parseDate(C_DATE_PATTON_DEFAULT, dateValue);
}
/**
* Parse a strign and return a datetime value
*
* @param dateValue
* @return
*/
public static Date parseDateTime(String dateValue) {
return parseDate(C_TIME_PATTON_DEFAULT, dateValue);
}
/**
* Parse a string and return the date value in the specified format
*
* @param strFormat
* @param dateValue
* @return
* @throws ParseException
* @throws Exception
*/
public static Date parseDate(String strFormat, String dateValue) {
if (dateValue == null)
return null;
if (strFormat == null)
strFormat = C_DATE_PATTON_DEFAULT;
SimpleDateFormat dateFormat = new SimpleDateFormat(strFormat);
Date newDate = null;
try {
newDate = dateFormat.parse(dateValue);
} catch (ParseException pe) {
newDate = null;
}
return newDate;
}
/**
* 将Timestamp类型的日期转换为系统参数定义的格式的字符串。
*
* @param aTs_Datetime
* 需要转换的日期。
* @return 转换后符合给定格式的日期字符串
*/
public static String format(Date aTs_Datetime) {
return format(aTs_Datetime, C_DATE_PATTON_DEFAULT);
}
public static String formatMin(Date aTs_Datetime) {
return format(aTs_Datetime, C_MIN_PATTON_DEFAULT);
}
/**
* 将Timestamp类型的日期转换为系统参数定义的格式的字符串。
*
* @param aTs_Datetime
* 需要转换的日期。
* @return 转换后符合给定格式的日期字符串
*/
public static String formatTime(Date aTs_Datetime) {
return format(aTs_Datetime, C_TIME_PATTON_DEFAULT);
}
/**
* 将Date类型的日期转换为系统参数定义的格式的字符串。
*
* @param aTs_Datetime
* @param as_Pattern
* @return
*/
public static String format(Date aTs_Datetime, String as_Pattern) {
if (aTs_Datetime == null || as_Pattern == null)
return null;
SimpleDateFormat dateFromat = new SimpleDateFormat();
dateFromat.applyPattern(as_Pattern);
return dateFromat.format(aTs_Datetime);
}
/**
* @param aTs_Datetime
* @param as_Format
* @return
*/
public static String formatTime(Date aTs_Datetime, String as_Format) {
if (aTs_Datetime == null || as_Format == null)
return null;
SimpleDateFormat dateFromat = new SimpleDateFormat();
dateFromat.applyPattern(as_Format);
return dateFromat.format(aTs_Datetime);
}
public static String getFormatTime(Date dateTime) {
return formatTime(dateTime, C_TIME_PATTON_HHMMSS);
}
public static String getFormatDate(Date dateTime) {
return formatTime(dateTime, C_DATE_PATTON_DEFAULT);
}
public static String getFormatTimeHHMM(Date dateTime) {
return formatTime(dateTime, C_TIME_PATTON_HHMM);
}
/**
* @param aTs_Datetime
* @param as_Pattern
* @return
*/
public static String format(Timestamp aTs_Datetime, String as_Pattern) {
if (aTs_Datetime == null || as_Pattern == null)
return null;
SimpleDateFormat dateFromat = new SimpleDateFormat();
dateFromat.applyPattern(as_Pattern);
return dateFromat.format(aTs_Datetime);
}
/**
* 取得指定日期N天后的日期
*
* @param date
* @param days
* @return
*/
public static Date addDays(Date date, int days) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DAY_OF_MONTH, days);
return cal.getTime();
}
public static Date addMin(Date date, int min) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.MINUTE, min);
return cal.getTime();
}
/**
* 计算两个日期之间相差的天数
*
* @param date1
* @param date2
* @return
*/
public static int daysBetween(Date date1, Date date2) {
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
long time1 = cal.getTimeInMillis();
cal.setTime(date2);
long time2 = cal.getTimeInMillis();
long between_days = (time2 - time1) / (1000 * 3600 * 24);
return Integer.parseInt(String.valueOf(between_days));
}
public static int daysBetween(String date1, String date2)
throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
cal.setTime(sdf.parse(date1));
long time1 = cal.getTimeInMillis();
cal.setTime(sdf.parse(date2));
long time2 = cal.getTimeInMillis();
long between_days = (time2 - time1) / (1000 * 3600 * 24);
return Integer.parseInt(String.valueOf(between_days));
}
/**
* 计算两个日期之间相差的分钟
*
* @param date1
* @param date2
* @return
*/
public static int minBetween(Date date1, Date date2) {
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
long time1 = cal.getTimeInMillis();
cal.setTime(date2);
long time2 = cal.getTimeInMillis();
long between_min = (time2 - time1) / (1000 * 60);
return Integer.parseInt(String.valueOf(between_min));
}
/**
* 计算两个日期之间相差的秒
*
* @param date1
* @param date2
* @return
*/
public static int secondBetween(Date date1, Date date2) {
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
long time1 = cal.getTimeInMillis();
cal.setTime(date2);
long time2 = cal.getTimeInMillis();
long between_sec = (time2 - time1) / 1000;
return Integer.parseInt(String.valueOf(between_sec));
}
public static int minsBetween(Date date2) {
Date date1 = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
long time1 = cal.getTimeInMillis();
cal.setTime(date2);
long time2 = cal.getTimeInMillis();
long between_min = (time2 - time1) / (1000 * 60);
return Integer.parseInt(String.valueOf(between_min));
}
/**
* 计算当前日期相对于"1977-12-01"的天数
*
* @param date
* @return
*/
public static long getRelativeDays(Date date) {
Date relativeDate = DateUtil.parseDate("yyyy-MM-dd", "1977-12-01");
return DateUtil.daysBetween(relativeDate, date);
}
public static Date getDateBeforTwelveMonth() {
String date = "";
Calendar cla = Calendar.getInstance();
cla.setTime(getCurrentDate());
int year = cla.get(Calendar.YEAR) - 1;
int month = cla.get(Calendar.MONTH) + 1;
if (month > 9) {
date = String.valueOf(year) + C_DATE_DIVISION
+ String.valueOf(month) + C_DATE_DIVISION + "01";
} else {
date = String.valueOf(year) + C_DATE_DIVISION + "0"
+ String.valueOf(month) + C_DATE_DIVISION + "01";
}
Date dateBefore = parseDate(date);
return dateBefore;
}
/**
* 传入时间字符串,加一天后返回Date
*
* @param date
* 时间 格式 YYYY-MM-DD
* @return
*/
public static Date addDate(String date, String pattern) {
if (date == null) {
return null;
}
Date tempDate = parseDate(pattern, date);
String year = format(tempDate, "yyyy");
String month = format(tempDate, "MM");
String day = format(tempDate, "dd");
GregorianCalendar calendar = new GregorianCalendar(
Integer.parseInt(year), Integer.parseInt(month) - 1,
Integer.parseInt(day));
calendar.add(GregorianCalendar.DATE, 1);
return calendar.getTime();
}
public static String dateToStr(long ll) {
// long hour=dd/3600000;
// long min=(dd%3600000)/60000;
// long sec=((dd%3600000)%60000)/1000;
// long mil=((dd%3600000)%60000)%1000;
double dd = ll;
String ss = String.valueOf(dd / 1000) + " 秒";
return ss;
}
public static int compare_date(String DATE1, String DATE2) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
try {
Date dt1 = df.parse(DATE1);
Date dt2 = df.parse(DATE2);
if (dt1.getTime() > dt2.getTime()) {
// System.out.println("DATE1 大于 DATE2");
return 1;
} else if (dt1.getTime() < dt2.getTime()) {
// System.out.println("DATE1 小于 DATE2");
return -1;
} else {
return 0;
}
} catch (Exception exception) {
logger.error(exception.getMessage());
}
return 0;
}
public static int compareDate(String dt1, String dt2) {
Date d1 = parseDate(null, dt1);
Date d2 = parseDate(null, dt2);
return compareDate(d1, d2);
}
public static int compareDate(Date dt1, Date dt2) {
try {
if (dt1.getTime() > dt2.getTime()) {
// //System.out.println("DATE1 大于 DATE2");
return 1;
} else if (dt1.getTime() < dt2.getTime()) {
// //System.out.println("DATE1 小于 DATE2");
return -1;
} else {
return 0;
}
} catch (Exception exception) {
logger.error(exception.getMessage());
}
return 0;
}
public static int compareD(Date dt1) {
Date dt2 = new Date();
try {
if (dt1.getTime() > dt2.getTime()) {
// //System.out.println("DATE1 大于 DATE2");
return 1;
} else if (dt1.getTime() < dt2.getTime()) {
// //System.out.println("DATE1 小于 DATE2");
return -1;
} else {
return 0;
}
} catch (Exception exception) {
logger.error(exception.getMessage());
}
return 1;
}
public static int getW(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (w == 0) {
w = 7;
}
return w;
}
// 取得yyyyMMdd字符串
public static String getYYYYMMDD() {
Date nowDate = new Date();
return format(nowDate, C_DATA_PATTON_YYYYMMDD);
}
public static String stringToString(String strTime, String formatType)
throws ParseException, ParseException {
SimpleDateFormat formatter = new SimpleDateFormat(formatType);
Date date = null;
date = formatter.parse(strTime);
return format(date);
}
// 取得yyyyWW(年加周)
public static String getYYYYWW(String dateStr) {
String yyyyWW = dateStr.substring(0, 4);
String MM = dateStr.substring(5, 7);
SimpleDateFormat dateFormat = new SimpleDateFormat(
C_DATE_PATTON_DEFAULT);
try {
Date date = dateFormat.parse(dateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setMinimalDaysInFirstWeek(4);
int w = calendar.get(Calendar.WEEK_OF_YEAR);
if (w == 0) {
w = 1;
}
String week = "";
if (w < 10) {
week = "0" + w;
} else {
week = "" + w;
}
if (MM.equals("12") && week.equals("01")) {
yyyyWW = String.valueOf(Integer.parseInt(yyyyWW) + 1);
} else if (MM.equals("01") && (week.equals("53") || week.equals("52"))) {
yyyyWW = String.valueOf(Integer.parseInt(yyyyWW) - 1);
}
yyyyWW = yyyyWW + week;
} catch (Exception e) {
logger.error(e.getMessage());
}
return yyyyWW;
}
// 取得yyyyWW(年加周)
public static String getYYYYW(String dateStr) {
String yyyyW = dateStr.substring(0, 4);
String MM = dateStr.substring(5, 7);
SimpleDateFormat dateFormat = new SimpleDateFormat(
C_DATE_PATTON_DEFAULT);
try {
Date date = dateFormat.parse(dateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.setMinimalDaysInFirstWeek(4);
calendar.setFirstDayOfWeek(Calendar.MONDAY);
int w = calendar.get(Calendar.WEEK_OF_YEAR);
if (w == 0) {
w = 1;
}
String week = "";
week = "" + w;
if (MM.equals("12") && week.equals("1")) {
yyyyW = String.valueOf(Integer.parseInt(yyyyW) + 1);
}
yyyyW = yyyyW + week;
} catch (Exception e) {
logger.error(e.getMessage());
}
return yyyyW;
}
// 取得yyyyWW(年加周)
public static String getYYYY_WW(String dateStr) {
String yyyyWW = dateStr.substring(0, 4);
SimpleDateFormat dateFormat = new SimpleDateFormat(
C_DATE_PATTON_DEFAULT);
try {
Date date = dateFormat.parse(dateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setMinimalDaysInFirstWeek(4);
int w = calendar.get(Calendar.WEEK_OF_YEAR);
String week = "";
if (w < 10) {
week = "0" + w;
} else {
week = "" + w;
}
yyyyWW = yyyyWW + "-" + week;
} catch (Exception e) {
logger.error(e.getMessage());
}
return yyyyWW;
}
public static String getYYYYMM(String dateStr) {
String yyyyMM = dateStr.substring(0, 4);
SimpleDateFormat dateFormat = new SimpleDateFormat(
C_DATE_PATTON_DEFAULT);
try {
Date date = dateFormat.parse(dateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int m = calendar.get(Calendar.MONTH) + 1;
String month = "";
if (m < 10) {
month = "0" + m;
} else {
month = "" + m;
}
yyyyMM = yyyyMM + month;
} catch (Exception e) {
logger.error(e.getMessage());
}
return yyyyMM;
}
public static String getMM(String dateStr) {
SimpleDateFormat dateFormat = new SimpleDateFormat(
C_DATE_PATTON_DEFAULT);
String month = "";
try {
Date date = dateFormat.parse(dateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int m = calendar.get(Calendar.MONTH) + 1;
if (m < 10) {
month = "0" + m;
} else {
month = "" + m;
}
} catch (Exception e) {
logger.error(e.getMessage());
}
return month;
}
public static String getYYYYM(String dateStr) {
String yyyyM = dateStr.substring(0, 4);
SimpleDateFormat dateFormat = new SimpleDateFormat(
C_DATE_PATTON_DEFAULT);
try {
Date date = dateFormat.parse(dateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int m = calendar.get(Calendar.MONTH) + 1;
String month = "";
month = "" + m;
yyyyM = yyyyM + month;
} catch (Exception e) {
logger.error(e.getMessage());
}
return yyyyM;
}
public static List<String> getDateInterval(String startDate, String endDate) {
SimpleDateFormat dateFormat = new SimpleDateFormat(
C_DATE_PATTON_DEFAULT);
List<String> dateIntervaList = new ArrayList<String>();
try {
dateIntervaList.add(startDate);
Date start = dateFormat.parse(startDate);
Date end = dateFormat.parse(endDate);
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(start);
Calendar endCalendar = Calendar.getInstance();
endCalendar.setTime(end);
Calendar tempCalendar = startCalendar;
tempCalendar.add(Calendar.DAY_OF_YEAR, 1);
while (tempCalendar.before(endCalendar)) {
dateIntervaList.add(dateFormat.format(tempCalendar.getTime()));
tempCalendar.add(Calendar.DAY_OF_YEAR, 1);
}
if (!startDate.equals(endDate)) {
dateIntervaList.add(endDate);
}
} catch (ParseException e) {
logger.error(e.getMessage());
}
return dateIntervaList;
}
public static int getWeek(Date date) {
Calendar c = new GregorianCalendar();
c.setFirstDayOfWeek(Calendar.MONDAY);
c.setMinimalDaysInFirstWeek(4);
c.setTime(date);
c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); // Monday
return c.get(Calendar.WEEK_OF_YEAR);
}
/**
* 返回某一天所在月的最后一天的日期
*/
public static String getLastDayOfMonth(Date date) {
Calendar c = convert(date);
int MaxDay = c.getActualMaximum(Calendar.DAY_OF_MONTH);
// 按你的要求设置时间
c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), MaxDay, 23, 59, 59);
return format(c.getTime());
}
/**
* 返回某一天所在月的第一天的日期
*/
public static String getFirstDayOfMonth(Date date) {
Calendar c = convert(date);
// 按你的要求设置时间
c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), 1, 23, 59, 59);
return format(c.getTime());
}
/**
* 将日期转换为日历
*
* @param date
* 日期
* @return 日历
*/
private static Calendar convert(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar;
}
public static boolean isLastDayOfMonth(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
if (c.get(Calendar.DATE) == c.getActualMaximum(Calendar.DAY_OF_MONTH)) {
return true;
} else {
return false;
}
}
public static String conditionFormat(String str) {
str = "'" + str.replaceAll(",", "','") + "'";
return str;
}
// 取得MM-dd字符串
public static String getMMDD() {
Date nowDate = new Date();
return format(nowDate, C_DATA_PATTON_MM_DD);
}
// 取得hh字符串
public static String getHH() {
Date nowDate = new Date();
return format(nowDate, C_DATA_PATTON_HH);
}
public static int getHH(String dateValue) {
Date date = parseDateTime(dateValue);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int hh = cal.get(Calendar.HOUR_OF_DAY);
return hh;
}
public static String addOneDay(String dateValue, String format) {
if (!"".equals(format)) {
return format(addDate(dateValue, format), format);
}
return format(addDate(dateValue, C_DATE_PATTON_DEFAULT),
C_DATE_PATTON_DEFAULT);
}
public static String getBeforeMonth() {
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(new Date());
startCalendar.add(Calendar.DAY_OF_YEAR, -30);
String beforeMonth = format(startCalendar.getTime(),
C_DATA_PATTON_YYYYMMDD);
return beforeMonth;
}
public static String getBeforeDays(int days) {
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(new Date());
startCalendar.add(Calendar.DAY_OF_YEAR, -days);
String beforeDays = format(startCalendar.getTime(),
C_DATE_PATTON_DEFAULT);
return beforeDays;
}
public static String getBeforeDays(String date, int days) {
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(parseDate(date));
startCalendar.add(Calendar.DAY_OF_YEAR, -days);
String beforeDays = format(startCalendar.getTime(),
C_DATE_PATTON_DEFAULT);
return beforeDays;
}
public static String getBeforeWeeks(int weeks) {
Calendar startCalendar = Calendar.getInstance();
startCalendar.setFirstDayOfWeek(Calendar.MONDAY);
startCalendar.setTime(new Date());
startCalendar.setMinimalDaysInFirstWeek(4);
startCalendar.add(Calendar.WEEK_OF_YEAR, -weeks);
String year = startCalendar.get(Calendar.YEAR) + "";
int w = startCalendar.get(Calendar.WEEK_OF_YEAR);
String week = "";
if (w < 10) {
week = "0" + w;
} else {
week = "" + w;
}
// System.out.println(year + week);
return year + week;
}
public static String getAfterWeeks(String dateStr, int weeks) {
SimpleDateFormat sdf = new SimpleDateFormat(C_DATE_PATTON_DEFAULT);
Date date = null;
try {
date = sdf.parse(dateStr);
} catch (ParseException e) {
logger.error(e.getMessage());
}
Calendar startCalendar = Calendar.getInstance();
startCalendar.setFirstDayOfWeek(Calendar.MONDAY);
startCalendar.setMinimalDaysInFirstWeek(4);
startCalendar.setTime(date);
if (weeks != 0) {
startCalendar.add(Calendar.WEEK_OF_YEAR, weeks);
String year = startCalendar.get(Calendar.YEAR) + "";
int w = startCalendar.get(Calendar.WEEK_OF_YEAR);
if (w < 10) {
return year + "0" + w;
} else {
return year + w;
}
} else {
return getYYYYWW(format(date));
}
}
public static String getBeforeWeeks(String end, int weeks) {
Calendar endCalendar = Calendar.getInstance();
int endyear = Integer.valueOf(end.substring(0, 4));
int endweek = Integer.valueOf(end.length() == 5 ? end.substring(4, 5)
: end.substring(4, 6));
endCalendar.setWeekDate(endyear, endweek, Calendar.MONDAY);
endCalendar.setMinimalDaysInFirstWeek(4);
endCalendar.add(Calendar.WEEK_OF_YEAR, -weeks);
String year = endCalendar.get(Calendar.YEAR) + "";
int w = endCalendar.get(Calendar.WEEK_OF_YEAR);
return year + w;
}
public static String getBeforeMonths(String end, int months) {
Calendar endCalendar = Calendar.getInstance();
int endyear = Integer.valueOf(end.substring(0, 4));
int endmonth = Integer.valueOf(end.length() == 5 ? end.substring(4, 5)
: end.substring(4, 6));
endCalendar.set(Calendar.YEAR, endyear);
endCalendar.set(Calendar.MONTH, endmonth);
if (months > 0) {
endCalendar.add(Calendar.MONTH, -months);
String year = endCalendar.get(Calendar.YEAR) + "";
int m = endCalendar.get(Calendar.MONTH);
if (m < 10) {
return year + "0" + m;
} else {
return year + m;
}
} else {
endCalendar.set(Calendar.MONTH, endmonth - 1);
System.out.println(format(endCalendar.getTime()));
return getYYYYMM(format(endCalendar.getTime()));
}
}
public static List<String> getWeeks(String start, String end) {
Calendar startCalendar = Calendar.getInstance();
int startyear = Integer.valueOf(start.substring(0, 4));
int startweek = Integer.valueOf(start.length() == 5 ? start.substring(
4, 5) : start.substring(4, 6));
startCalendar.setWeekDate(startyear, startweek, Calendar.MONDAY);
startCalendar.setMinimalDaysInFirstWeek(4);
Calendar endCalendar = Calendar.getInstance();
int endyear = Integer.valueOf(end.substring(0, 4));
int endweek = Integer.valueOf(end.length() == 5 ? end.substring(4, 5)
: end.substring(4, 6));
endCalendar.setWeekDate(endyear, endweek, Calendar.MONDAY);
endCalendar.setMinimalDaysInFirstWeek(4);
Calendar tempCalendar = startCalendar;
List<String> weeks = new ArrayList<String>();
SimpleDateFormat dateFormat = new SimpleDateFormat(
C_DATE_PATTON_DEFAULT);
if (startyear == 2016)
tempCalendar.add(Calendar.DAY_OF_YEAR, 7);
while (tempCalendar.before(endCalendar)) {
if (!weeks.contains(getYYYYWW(dateFormat.format(tempCalendar
.getTime()))))
weeks.add(getYYYYWW(dateFormat.format(tempCalendar.getTime())));
tempCalendar.add(Calendar.DAY_OF_YEAR, 7);
}
if (startCalendar.equals(endCalendar)) {
if (!weeks.contains(getYYYYWW(dateFormat.format(startCalendar
.getTime()))))
weeks.add(getYYYYWW(dateFormat.format(startCalendar.getTime())));
}
if (!weeks.contains(end)) {
weeks.add(end);
}
return weeks;
}
public static List<String> getMonths(String start, String end) {
Calendar startCalendar = Calendar.getInstance();
int startyear = Integer.valueOf(start.substring(0, 4));
int startmonth = Integer.valueOf(start.length() == 5 ? start.substring(
4, 5) : start.substring(4, 6));
startCalendar.set(Calendar.YEAR, startyear);
startCalendar.set(Calendar.MONTH, startmonth - 1);
Calendar endCalendar = Calendar.getInstance();
int endyear = Integer.valueOf(end.substring(0, 4));
int endmonth = Integer.valueOf(end.length() == 5 ? end.substring(4, 5)
: end.substring(4, 6));
endCalendar.set(Calendar.YEAR, endyear);
endCalendar.set(Calendar.MONTH, endmonth - 1);
Calendar tempCalendar = startCalendar;
List<String> months = new ArrayList<String>();
SimpleDateFormat dateFormat = new SimpleDateFormat(
C_DATE_PATTON_DEFAULT);
while (tempCalendar.before(endCalendar)) {
if (!months.contains(getYYYYMM(dateFormat.format(tempCalendar
.getTime()))))
months.add(getYYYYMM(dateFormat.format(tempCalendar.getTime())));
tempCalendar.add(Calendar.DAY_OF_YEAR,
tempCalendar.getActualMaximum(Calendar.DATE) - 1);
}
if (startCalendar.equals(endCalendar)) {
if (!months.contains(getYYYYMM(dateFormat.format(startCalendar
.getTime()))))
months.add(getYYYYMM(dateFormat.format(startCalendar.getTime())));
}
if (!months.contains(end)) {
months.add(end);
}
return months;
}
public static String getBeforeMonths(int months) {
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(new Date());
startCalendar.add(Calendar.MONTH, -months);
String year = startCalendar.get(Calendar.YEAR) + "";
int m = startCalendar.get(Calendar.MONTH);
m = m + 1;
String month = "";
if (m < 10) {
month = "0" + m;
} else {
month = "" + m;
}
// System.out.println(year + month);
return year + month;
}
public static String getAfterMonths(String dateStr, int months) {
Date date = DateUtil.parseDate(dateStr);
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(date);
int oldm = startCalendar.get(Calendar.MONTH);
logger.debug((oldm+1)+"");
logger.debug(startCalendar.get(Calendar.YEAR) + "");
startCalendar.add(Calendar.MONTH, months);
int m = startCalendar.get(Calendar.MONTH);
m = m + 1;
logger.debug(m+"");
String month = "";
if (m < 10) {
month = "0" + m;
} else {
month = "" + m;
}
logger.debug(startCalendar.get(Calendar.YEAR) + "");
String year = startCalendar.get(Calendar.YEAR) + "";
// System.out.println(year + month);
return year + month;
}
public static String convertWeekToDate(String dateStr) {
String year = dateStr.substring(0, 4);
String week = "";
if (dateStr.length() == 5) {
week = dateStr.substring(4, 5);
} else {
week = dateStr.substring(4, 6);
}
int w = Integer.valueOf(week);
int y = Integer.valueOf(year);
Calendar startCalendar = Calendar.getInstance();
startCalendar.setFirstDayOfWeek(Calendar.MONDAY);
startCalendar.set(Calendar.YEAR, y);
startCalendar.set(Calendar.WEEK_OF_YEAR, w);
startCalendar.setMinimalDaysInFirstWeek(4);
// String day=format(startCalendar.getTime(),C_DATA_PATTON_YYYYMMDD );
Date day = startCalendar.getTime();
String firstDay = format(getFirstDayOfWeek(day), C_DATE_PATTON_DEFAULT);
String lastDay = format(getLastDayOfWeek(day), C_DATE_PATTON_DEFAULT);
return firstDay + "至" + lastDay;
}
/**
* 获取某一周号的第一天.
*
* @param weekStr
* @return
*/
public static String getFirstDayOfWeek(String weekStr) {
String year = weekStr.substring(0, 4);
String week = "";
if (weekStr.length() == 5) {
week = weekStr.substring(4, 5);
} else {
week = weekStr.substring(4, 6);
}
int w = Integer.valueOf(week);
int y = Integer.valueOf(year);
Calendar startCalendar = Calendar.getInstance();
startCalendar.setFirstDayOfWeek(Calendar.MONDAY);
startCalendar.set(Calendar.YEAR, y);
startCalendar.set(Calendar.WEEK_OF_YEAR, w);
startCalendar.setMinimalDaysInFirstWeek(4);
// String day=format(startCalendar.getTime(),C_DATA_PATTON_YYYYMMDD );
Date day = startCalendar.getTime();
return format(getFirstDayOfWeek(day), C_DATE_PATTON_DEFAULT);
}
/**
* 获取某一周号的最后一天.
*
* @param weekStr
* @return
*/
public static String getLastDayOfWeek(String weekStr) {
String year = weekStr.substring(0, 4);
String week = "";
if (weekStr.length() == 5) {
week = weekStr.substring(4, 5);
} else {
week = weekStr.substring(4, 6);
}
int w = Integer.valueOf(week);
int y = Integer.valueOf(year);
Calendar startCalendar = Calendar.getInstance();
startCalendar.setFirstDayOfWeek(Calendar.MONDAY);
startCalendar.set(Calendar.YEAR, y);
startCalendar.set(Calendar.WEEK_OF_YEAR, w);
startCalendar.setMinimalDaysInFirstWeek(4);
// String day=format(startCalendar.getTime(),C_DATA_PATTON_YYYYMMDD );
Date day = startCalendar.getTime();
return format(getLastDayOfWeek(day), C_DATE_PATTON_DEFAULT);
}
/** */
/**
* 取得某天所在周的第一天
*
* @param date
* @return
*/
public static Date getFirstDayOfWeek(Date date) {
Calendar c = new GregorianCalendar();
c.setFirstDayOfWeek(Calendar.MONDAY);
c.setTime(date);
c.setMinimalDaysInFirstWeek(4);
c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek());
return c.getTime();
}
public static String getFirstDayStrOfWeek(Date date) {
return format(getFirstDayOfWeek(date));
}
public static String getLastDayStrOfWeek(Date date) {
return format(getLastDayOfWeek(date));
}
/** */
/**
* 取得某天所在周的最后一天
*
* @param date
* @return
*/
public static Date getLastDayOfWeek(Date date) {
Calendar c = new GregorianCalendar();
c.setFirstDayOfWeek(Calendar.MONDAY);
c.setTime(date);
c.setMinimalDaysInFirstWeek(4);
c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek() + 6);
return c.getTime();
}
/**
* 某一个月号第一天和最后一天
*
* @param date
* @return
*/
public static String getFirstday_Lastday_Month(String dateStr) {
String year = dateStr.substring(0, 4);
String month = "";
if (dateStr.length() == 5) {
month = dateStr.substring(4, 5);
} else {
month = dateStr.substring(4, 6);
}
int m = Integer.valueOf(month);
int y = Integer.valueOf(year);
Calendar startCalendar = Calendar.getInstance();
startCalendar.setFirstDayOfWeek(Calendar.MONDAY);
startCalendar.set(Calendar.YEAR, y);
startCalendar.set(Calendar.MONTH, m);
// String day=format(startCalendar.getTime(),C_DATA_PATTON_YYYYMMDD );
Date day = startCalendar.getTime();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.setTime(day);
calendar.add(Calendar.MONTH, -1);
Date theDate = calendar.getTime();
// 第一天
GregorianCalendar gcLast = (GregorianCalendar) Calendar.getInstance();
gcLast.setTime(theDate);
gcLast.set(Calendar.DAY_OF_MONTH, 1);
String day_first = df.format(gcLast.getTime());
// StringBuffer str = new
// StringBuffer().append(day_first).append(" 00:00:00");
// day_first = str.toString();
// 最后一天
calendar.add(Calendar.MONTH, 1); // 加一个月
calendar.set(Calendar.DATE, 1); // 设置为该月第一天
calendar.add(Calendar.DATE, -1); // 再减一天即为上个月最后一天
String day_last = df.format(calendar.getTime());
// StringBuffer endStr = new
// StringBuffer().append(day_last).append(" 23:59:59");
// day_last = endStr.toString();
return day_first + "至" + day_last;
}
/**
* 某一个月号第一天
*
* @param date
* @return
*/
public static String getFirstdayOfMonth(String monthno) {
String year = monthno.substring(0, 4);
String month = "";
// if (monthno.length() == 5) {
// month = monthno.substring(4, 5);
// } else {
// }
month = monthno.substring(4);
int m = Integer.valueOf(month);
int y = Integer.valueOf(year);
Calendar startCalendar = Calendar.getInstance();
startCalendar.setFirstDayOfWeek(Calendar.MONDAY);
startCalendar.set(Calendar.DATE,1);
startCalendar.set(Calendar.YEAR, y);
startCalendar.set(Calendar.MONTH, m);
// String day=format(startCalendar.getTime(),C_DATA_PATTON_YYYYMMDD );
Date day = startCalendar.getTime();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.setTime(day);
calendar.add(Calendar.MONTH, -1);
Date theDate = calendar.getTime();
// 第一天
GregorianCalendar gcLast = (GregorianCalendar) Calendar.getInstance();
gcLast.setTime(theDate);
gcLast.set(Calendar.DAY_OF_MONTH, 1);
String day_first = df.format(gcLast.getTime());
return day_first;
}
/**
* 某一个月号最后一天
*
* @param date
* @return
*/
public static String getLastdayOfMonth(String monthno) {
String year = monthno.substring(0, 4);
String month = "";
if (monthno.length() == 5) {
month = monthno.substring(4, 5);
} else {
month = monthno.substring(4, 6);
}
int m = Integer.valueOf(month);
int y = Integer.valueOf(year);
Calendar startCalendar = Calendar.getInstance();
startCalendar.setFirstDayOfWeek(Calendar.MONDAY);
startCalendar.set(Calendar.DATE,1);
startCalendar.set(Calendar.YEAR, y);
startCalendar.set(Calendar.MONTH, m);
// String day=format(startCalendar.getTime(),C_DATA_PATTON_YYYYMMDD );
Date day = startCalendar.getTime();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.setTime(day);
calendar.add(Calendar.MONTH, -1);
// 最后一天
calendar.add(Calendar.MONTH, 1); // 加一个月
calendar.set(Calendar.DATE, 1); // 设置为该月第一天
calendar.add(Calendar.DATE, -1); // 再减一天即为上个月最后一天
String day_last = df.format(calendar.getTime());
return day_last;
}
public static long getMillons(String hh, String mm) {
SimpleDateFormat sdf = new SimpleDateFormat(C_MIN_PATTON_DEFAULT);
sdf.setTimeZone(new SimpleTimeZone(SimpleTimeZone.UTC_TIME, "UTC"));
Date nowDate = new Date();
String date = format(nowDate, C_DATE_PATTON_DEFAULT);
date = date + " " + hh + ":" + mm;
// System.out.println(date);
Date date2=parseDate(C_MIN_PATTON_DEFAULT, date);
Date utcDate = null;
try {
utcDate = sdf.parse(date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return utcDate.getTime();
}
public static long getMillons(String date) {
SimpleDateFormat sdf = new SimpleDateFormat(C_DATA_PATTON_YYYYMMDD);
sdf.setTimeZone(new SimpleTimeZone(SimpleTimeZone.UTC_TIME, "UTC"));
Date utcDate = null;
try {
utcDate = sdf.parse(date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return utcDate.getTime();
}
public static Date getFirstRunTime(String time) {
long daySpan = 24L * 60 * 60 * 1000;
// 规定的每天时间15:33:30运行
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd '" + time
+ ":00:00'");
// 首次运行时间
Date startTime = null;
try {
startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(sdf
.format(new Date()));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// 如果今天的已经过了 首次运行时间就改为明天
if (System.currentTimeMillis() > startTime.getTime()) {
startTime = new Date(startTime.getTime() + daySpan);
}
return startTime;
}
public static List<String> getEveryWeek(String startDate, String endDate) {
List<String> wwSet = new ArrayList<String>();
List<String> everyday = getDateInterval(startDate, endDate);
String _yyyyww;
for (String date : everyday) {
_yyyyww = getYYYYWW(date);
// if (_yyyyww.substring(4, 5).equals("0")) {
// if (!wwSet.contains(getYYYYW(date)))
// wwSet.add(getYYYYW(date));
// } else {
// }
if (!wwSet.contains(_yyyyww))
wwSet.add(_yyyyww);
}
return wwSet;
}
// public static List<String> getEveryWeekBySE(String start, String end) {
//
// }
public static List<String> getEveryMonth(String startDate, String endDate) {
List<String> mmSet = new ArrayList<String>();
List<String> everyday = getDateInterval(startDate, endDate);
String _yyyymm;
for (String date : everyday) {
_yyyymm = getYYYYMM(date);
// if (_yyyymm.substring(4, 5).equals("0")) {
// if (!mmSet.contains(getYYYYM(date)))
// mmSet.add(getYYYYM(date));
// } else {
// }
if (!mmSet.contains(_yyyymm))
mmSet.add(_yyyymm);
}
return mmSet;
}
public static List<String> getTimeIntegval() {
List<String> timeList = new ArrayList<String>();
String _i, _j, _t;
for (int i = 0; i < 24; i++) {
if (i < 10) {
_i = "0" + i;
} else {
_i = i + "";
}
for (int j = 0; j < 60; j++) {
if (j % 5 == 0) {
if (j < 10) {
_j = "0" + j;
} else {
_j = j + "";
}
_t = _i + ":" + _j;
timeList.add(_t);
}
}
}
return timeList;
}
/**
* 当前时间点>=10,返回昨天;否则返回前天.
*
* @return 昨天或者前天.
*/
public static String getIDFAQueryDate() {
Date date = new Date();
int time = date.getHours();
if (time >= 10) {
return getBeforeDays(1);
} else {
return getBeforeDays(2);
}
}
private static DateFormat format = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
/**
* 得到UTC时间,类型为字符串,格式为"yyyy-MM-dd HH:mm"<br />
* 如果获取失败,返回null
*
* @return
*/
public static String getUTCTimeStr() {
StringBuilder UTCTimeBuffer = new StringBuilder();
// 1、取得本地时间:
Calendar cal = Calendar.getInstance();
// 2、取得时间偏移量:
int zoneOffset = cal.get(Calendar.ZONE_OFFSET);
// 3、取得夏令时差:
int dstOffset = cal.get(Calendar.DST_OFFSET);
// 4、从本地时间里扣除这些差量,即可以取得UTC时间:
cal.add(Calendar.MILLISECOND, -(zoneOffset + dstOffset));
System.out.println(cal.getTimeInMillis());
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int day = cal.get(Calendar.DAY_OF_MONTH);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
int seconds = cal.get(Calendar.SECOND);
UTCTimeBuffer.append(year).append("-").append(month).append("-")
.append(day);
UTCTimeBuffer.append(" ").append(hour).append(":").append(minute)
.append(":").append(seconds);
try {
format.parse(UTCTimeBuffer.toString());
return UTCTimeBuffer.toString();
} catch (ParseException e) {
logger.error(e.getMessage());
}
return null;
}
/**
* 得到UTC时间,类型为字符串,格式为"yyyy-MM-dd HH:mm"<br />
* 如果获取失败,返回null
*
* @return
*/
public static long getUTCTimeLong() {
StringBuilder UTCTimeBuffer = new StringBuilder();
// 1、取得本地时间:
Calendar cal = Calendar.getInstance();
// 2、取得时间偏移量:
int zoneOffset = cal.get(Calendar.ZONE_OFFSET);
// 3、取得夏令时差:
int dstOffset = cal.get(Calendar.DST_OFFSET);
// 4、从本地时间里扣除这些差量,即可以取得UTC时间:
cal.add(Calendar.MILLISECOND, -(zoneOffset + dstOffset));
return cal.getTimeInMillis();
}
/**
* 将UTC时间转换为东八区时间
*
* @param UTCTime
* @return
*/
public static String getLocalTimeFromUTC(String UTCTime) {
Date UTCDate = null;
String localTimeStr = null;
try {
UTCDate = format.parse(UTCTime);
format.setTimeZone(TimeZone.getTimeZone("GMT-8"));
localTimeStr = format.format(UTCDate);
} catch (ParseException e) {
logger.error(e.getMessage());
}
return localTimeStr;
}
/**
* 将UTC时间转换为东八区时间
*
* @param UTCTime
* @return
*/
public static String getLocalTimeFromUTC(long UTCTime) {
Date UTCDate = new Date(UTCTime);
String localTimeStr = null;
format.setTimeZone(TimeZone.getTimeZone("GMT-8"));
localTimeStr = format.format(UTCDate);
return localTimeStr;
}
/**
* 秒转化成天时分秒
*
* @param ms
* @return
*/
public static String formatTime(long ms) {
int ss = 1000;
int mi = ss * 60;
int hh = mi * 60;
int dd = hh * 24;
long day = ms / dd;
long hour = (ms - day * dd) / hh;
long minute = (ms - day * dd - hour * hh) / mi;
long second = (ms - day * dd - hour * hh - minute * mi) / ss;
long milliSecond = ms - day * dd - hour * hh - minute * mi - second
* ss;
String strDay = day < 10 ? "0" + day : "" + day; // 天
String strHour = hour < 10 ? "0" + hour : "" + hour;// 小时
String strMinute = minute < 10 ? "0" + minute : "" + minute;// 分钟
String strSecond = second < 10 ? "0" + second : "" + second;// 秒
String strMilliSecond = milliSecond < 10 ? "0" + milliSecond : ""
+ milliSecond;// 毫秒
strMilliSecond = milliSecond < 100 ? "0" + strMilliSecond : ""
+ strMilliSecond;
return strDay + " 天 " + strHour + " 时 " + strMinute + " 分钟 " + strSecond
+ " 秒";
}
public static String parseDateTimeByLong(Long time) {
Date date = new Date(time);
SimpleDateFormat sdf=new SimpleDateFormat(C_TIME_PATTON_DEFAULT);
return sdf.format(date);
}
public static void main(String[] args) {
// String UTCTimeStr = getUTCTimeStr() ;
// System.out.println(UTCTimeStr);
// System.out.println(getLocalTimeFromUTC(UTCTimeStr));
//
// System.out.println(getLocalTimeFromUTC(getUTCTimeLong()));
// System.out.println(getFirstDayOfMonth(parseDate("2016-02-03")));
// System.out.println(getLastDayOfMonth(parseDate("2016-02-03")));
//
// System.out.println(getFirstday_Lastday_Month("201602"));
// System.out.println(getFirstdayOfMonth("201602"));
// System.out.println(getLastdayOfMonth("201602"));
// long time = 1494066492782L;
// Date date = new Date(time);
// System.out.println(date);
//
// String newdate = DateUtil.format(date,DateUtil.C_TIME_PATTON_DEFAULT);
// System.out.println(newdate);
System.out.print(DateUtil.getBeforeDays("2017-03-31",-70));
}
}
package util;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class HttpClientUtil {
/**
* 日志处理类
*/
private static final Log log = LogFactory.getLog(HttpClientUtil.class);
// 读取超时
private final static int SOCKET_TIMEOUT = 60000;
// 连接超时
private final static int CONNECTION_TIMEOUT = 60000;
// 每个HOST的最大连接数量
private final static int MAX_CONN_PRE_HOST = 20;
// 连接池的最大连接数
private final static int MAX_CONN = 100;
// 连接池
private final static HttpConnectionManager httpConnectionManager;
static {
httpConnectionManager = new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = httpConnectionManager.getParams();
params.setConnectionTimeout(CONNECTION_TIMEOUT);
params.setSoTimeout(SOCKET_TIMEOUT);
params.setDefaultMaxConnectionsPerHost(MAX_CONN_PRE_HOST);
params.setMaxTotalConnections(MAX_CONN);
}
/**
* Http get请求,获取结果.
* @param url
* @param ip
* @return
*/
public static String doHttpGetRequest(String url, String ip) {
HttpClient httpClient = new HttpClient(httpConnectionManager);
resetRequestHeader(httpClient, ip);
HttpMethod method = new GetMethod(url);
String response = null;
try {
httpClient.executeMethod(method);
if (method.getStatusCode() == HttpStatus.SC_OK) {
response = method.getResponseBodyAsString();
}
} catch (IOException e) {
log.error("执行HTTP Get请求" + url + "时,发生异常!", e);
} finally {
method.releaseConnection();
}
return response;
}
public static String doHttpGetRequest4Mobile(String url, String ip) {
HttpClient httpClient = new HttpClient(httpConnectionManager);
resetRequestHeader4Mobile(httpClient, ip);
HttpMethod method = new GetMethod(url);
String response = null;
try {
httpClient.executeMethod(method);
if (method.getStatusCode() == HttpStatus.SC_OK) {
response = method.getResponseBodyAsString();
}
} catch (IOException e) {
log.error("执行HTTP Get请求" + url + "时,发生异常!", e);
} finally {
method.releaseConnection();
}
return response;
}
/**
* Http post请求,获取结果.
* @param url
* @param ip
* @return
*/
public static String doHttpPostRequest(String url, String ip, Map<String, String> params) {
long start = System.currentTimeMillis();
HttpClient httpClient = new HttpClient(httpConnectionManager);
httpClient.getHttpConnectionManager().getParams()
.setConnectionTimeout(300000);
httpClient.getHttpConnectionManager().getParams().setSoTimeout(300000);
resetRequestHeader(httpClient, ip);
PostMethod method = new PostMethod(url);
List<NameValuePair> list = new ArrayList<NameValuePair>();
for (String key : params.keySet()) {
NameValuePair pair = new NameValuePair(key, params.get(key));
list.add(pair);
}
method.setRequestBody(list.toArray(new NameValuePair[list.size()]));
String response = null;
try {
int status = httpClient.executeMethod(method);
response = method.getResponseBodyAsString();
} catch (IOException e) {
log.error("执行HTTP Post请求" + url + "时,发生异常!", e);
} finally {
method.releaseConnection();
}
long end = System.currentTimeMillis();
log.debug("---------------http's time to get data from report-------------------");
log.debug(start-end + "ms");
log.debug("---------------------------------------------------------------------");
return response;
}
/**
* Http post请求,获取结果.
* @param url
* @param ip
* @return
*/
public static String doHttpPostRequest(String url, String ip) {
long start = System.currentTimeMillis();
HttpClient httpClient = new HttpClient(httpConnectionManager);
httpClient.getHttpConnectionManager().getParams()
.setConnectionTimeout(300000);
httpClient.getHttpConnectionManager().getParams().setSoTimeout(300000);
resetRequestHeader(httpClient, ip);
PostMethod method = new PostMethod(url);
List<NameValuePair> list = new ArrayList<NameValuePair>();
String response = null;
try {
int status = httpClient.executeMethod(method);
response = method.getResponseBodyAsString();
} catch (IOException e) {
log.error("执行HTTP Post请求" + url + "时,发生异常!", e);
} finally {
method.releaseConnection();
}
long end = System.currentTimeMillis();
log.debug("---------------http's time to get data from report-------------------");
log.debug(start-end + "ms");
log.debug("---------------------------------------------------------------------");
return response;
}
/**
* 设置一下返回错误的通用提示,可以自定义格式.
* @param reason
* @return
*/
public static String returnError(String reason) {
StringBuffer buffer = new StringBuffer();
buffer.append("<?xml version=\"1.0\" encoding=\"GBK\"?>");
buffer.append("<Response>");
buffer.append("<Success>false</Success>");
buffer.append("<reason>");
buffer.append(reason);
buffer.append("</reason>");
buffer.append("</Response>");
return buffer.toString();
}
public final static String REQUEST_HEADER = "x-forwarded-for";
/**
* 将客户IP写入请求头
* 这个设置可以伪装IP请求,注意使用
* @param client
* @param ip
* @return
*/
public static void resetRequestHeader(HttpClient client, String ip) {
List<Header> headers = new ArrayList<Header>();
headers.add(new Header(REQUEST_HEADER, ip));
client.getHostConfiguration().getParams().setParameter(
"http.default-headers", headers);
client.getHostConfiguration().getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,"utf-8");
}
public static void resetRequestHeader4Mobile(HttpClient client, String ip) {
List<Header> headers = new ArrayList<Header>();
headers.add(new Header(REQUEST_HEADER, ip));
client.getHostConfiguration().getParams().setParameter(
"http.default-headers", headers);
client.getHostConfiguration().getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,"GBK");
}
public static boolean httpAWS(Map<String, String> args, String ip, String surl, String url) throws Exception {
String response = "";
for (int i=0; i<3; i++) {
response = HttpClientUtil.doHttpPostRequest(url, ip, args);
if (!StringUtil.isEmpty(response)) {
ObjectMapper objectMapper = new ObjectMapper();
Map res = objectMapper.readValue(response, Map.class);
if (res.containsKey("result") && res.get("result").equals("true")) {
log.info("success to "+args.get("method")+" AWS redis campaigninfo by surl:" + surl);
return true;
}
}
}
if (StringUtil.isEmpty(response)) {
MailUtils.sendSimpleEmail("Fail to "+args.get("method")+" AWS redis campaigninfo by surl:" + surl, new ObjectMapper().writeValueAsString(args), Constant.mlist);
return false;
}
return false;
}
public static void resetRequestHeader(HttpClient client, String ip, String cookie) {
List<Header> headers = new ArrayList<Header>();
headers.add(new Header(REQUEST_HEADER, ip));
headers.add(new Header("Cookie", cookie));
client.getHostConfiguration().getParams().setParameter(
"http.default-headers", headers);
// client.getHostConfiguration().getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,"utf-8");
}
public static ByteArrayOutputStream doHttpGetStreamRequest(String url, String ip, String cookie)
{
HttpClient httpClient = new HttpClient(httpConnectionManager);
resetRequestHeader(httpClient, ip, cookie);
HttpMethod method = new GetMethod(url);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream response = null;
try {
httpClient.executeMethod(method);
if (method.getStatusCode() == HttpStatus.SC_OK) {
response = method.getResponseBodyAsStream();
byte[] buffer = new byte[1024];
int len;
while ((len = response.read(buffer)) > -1 ) {
baos.write(buffer, 0, len);
}
baos.flush();
}
} catch (IOException e) {
log.error("执行HTTP Get请求" + url + "时,发生异常!", e);
} finally {
method.releaseConnection();
}
return baos;
}
public static Map<String,Object> doHttpGetHeaderAndBody(String url, String ip, String cookie)
{
HttpClient httpClient = new HttpClient(httpConnectionManager);
resetRequestHeader(httpClient, ip, cookie);
HttpMethod method = new GetMethod(url);
ByteArrayOutputStream baosHeader = new ByteArrayOutputStream();
ByteArrayOutputStream baosBody = new ByteArrayOutputStream();
InputStream responseBody = null;
InputStream responseHeader = null;
Map<String,Object> result = new HashMap<>();
try {
httpClient.executeMethod(method);
if (method.getStatusCode() == HttpStatus.SC_OK) {
responseBody = method.getResponseBodyAsStream();
byte[] buffer = new byte[1024];
int len;
while ((len = responseBody.read(buffer)) > -1 ) {
baosBody.write(buffer, 0, len);
}
baosBody.flush();
result.put("body",baosBody);
Header headers = method.getResponseHeader("Set-Cookie");
String value = headers.getValue();
result.put("cookie", value);
}
} catch (IOException e) {
log.error("执行HTTP Get请求" + url + "时,发生异常!", e);
} finally {
method.releaseConnection();
}
return result;
}
public static String doHttpPostRequest(String url, String ip, Map<String, String> params, String cookie) {
long start = System.currentTimeMillis();
HttpClient httpClient = new HttpClient(httpConnectionManager);
httpClient.getHttpConnectionManager().getParams()
.setConnectionTimeout(300000);
httpClient.getHttpConnectionManager().getParams().setSoTimeout(300000);
resetRequestHeader(httpClient, ip, cookie);
PostMethod method = new PostMethod(url);
List<NameValuePair> list = new ArrayList<NameValuePair>();
for (String key : params.keySet()) {
NameValuePair pair = new NameValuePair(key, params.get(key));
list.add(pair);
}
method.setRequestBody(list.toArray(new NameValuePair[list.size()]));
String response = null;
try {
int status = httpClient.executeMethod(method);
response = method.getResponseBodyAsString();
} catch (IOException e) {
log.error("执行HTTP Post请求" + url + "时,发生异常!", e);
} finally {
method.releaseConnection();
}
long end = System.currentTimeMillis();
log.debug("---------------http's time to get data from report-------------------");
log.debug(start-end + "ms");
log.debug("---------------------------------------------------------------------");
return response;
}
}
package util;
import com.google.common.base.Strings;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StringUtil {
private static final String URL_REGEX_PATTERN = "(http|https):\\/\\/[^\\s]+";
private static final String NAME_REGEX_PATTERN = "^[a-zA-Z0-9\\s\\.\\-\\u4E00-\\u9FA5]+$";
public static String[] toStrArray(String str) {
return str.split(",");
}
/*
* 判断是否为整数
*
* @param str 传入的字符串
*
* @return 是整数返回true,否则返回false
*/
public static boolean isInteger(String str) {
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
return pattern.matcher(str).matches();
}
/*
* 判断是否为浮点数,包括double和float
*
* @param str 传入的字符串
*
* @return 是浮点数返回true,否则返回false
*/
public static boolean isDouble(String str) {
Pattern pattern = Pattern.compile("^[-\\+]?[.\\d]*$");
return pattern.matcher(str).matches();
}
public static boolean isNumber(String string) {
return string.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$");
}
public static boolean isEmpty(String string) {
return string == null || "".equals(string);
}
public static String escapeString(String old) {
old = old.replace("'", "\\'");
return old;
}
public static void main(String[] args) {
String str = "点通";
String pattern = "([广点通])|([百分点])|([乱七八糟])";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(str);
System.out.println(m.group());
}
/**
* 随机获取user_agent
*
*/
public static String getUA() {
String[] _user_agent_pc = {
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 6.0)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)",
"Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0)",
"Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler 4.0)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; The World)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Avant Browser)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0)",
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Maxthon 2.0)",
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; TencentTraveler 4.0)",
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; The World)",
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; 360SE)",
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Avant Browser)",
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)",
"Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; Maxthon 2.0)",
"Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; TencentTraveler 4.0)",
"Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; The World)",
"Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; 360SE)",
"Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; Avant Browser)",
"Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/4.0)",
"Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)",
"Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler 4.0)",
"Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.1; The World)",
"Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)",
"Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0)",
"Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Maxthon 2.0)",
"Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; TencentTraveler 4.0)",
"Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; The World)",
"Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; 360SE)",
"Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Avant Browser)",
"Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Maxthon 2.0)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; TencentTraveler 4.0)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; The World)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; 360SE)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Avant Browser)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/4.0)",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:39.0) Gecko/20100101 Firefox/39.0",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0 Safari/535.11",
"Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50",
"Mozilla/5.0 (Windows NT 6.0; rv:2.0) Gecko/20100101 Firefox/4.0 Opera 12.14",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0) Opera 12.14",
"Mozilla/5.0 (Windows NT 5.1) Gecko/20100101 Firefox/14.0 Opera/12.0",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; de) Opera 11.51",
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0 Safari/537.36",
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36",
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36",
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2226.0 Safari/537.36",
"Mozilla/5.0 (Windows NT 6.4; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2225.0 Safari/537.36",
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2225.0 Safari/537.36",
"Mozilla/5.0 (MSIE 9.0; Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko QQBrowser/8.1.3886.400",
"Mozilla/5.0 (MSIE 9.0; Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko QQBrowser/8.2.3638.400",
"Mozilla/5.0 (MSIE 9.0; Windows NT 6.0; Trident/7.0; rv:11.0) like Gecko QQBrowser/8.3.4765.400",
"Mozilla/5.0 (MSIE 9.0; Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko QQBrowser/9.1.3471.400",
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; 2345Explorer 3.4.0.12519)",
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; 2345Explorer 3.5.0.12758)",
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; 2345Explorer 4.0.0.13120)",
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; 2345Explorer 4.2.0.13550)",
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; 2345Explorer 5.0.0.14004)",
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; 2345Explorer/6.1.0.8158)",
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; 2345Explorer/6.2.0.9202)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; UBrowser/5.0.1369.26)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; UBrowser/5.2.2603.1)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; UBrowser/5.4.4237.43)",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:34.0) Gecko/20100101 Firefox/34.0",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:36.0) Gecko/20100101 Firefox/36.0",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:37.0) Gecko/20100101 Firefox/37.0",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:38.0) Gecko/20100101 Firefox/38.0",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:39.0) Gecko/20100101 Firefox/39.0",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:40.0) Gecko/20100101 Firefox/40.0",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:41.0) Gecko/20100101 Firefox/41.0",
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/2.1.7.6 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.11 YYE/3.6 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.107 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.46 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2478.0 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2498.0 Safari/537.36",
"Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.8.131 Version/11.11",
"Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11",
"Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16",
"Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14",
"Opera/9.80 (Windows NT 6.1; WOW64; U; pt) Presto/2.10.229 Version/11.62",
"Opera/9.80 (Windows NT 6.0; U; pl) Presto/2.10.229 Version/11.62",
"Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; fr) Presto/2.9.168 Version/11.52",
"Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; de) Presto/2.9.168 Version/11.52",
"Opera/9.80 (Windows NT 5.1; U; en) Presto/2.9.168 Version/11.51",
"Opera/9.80 (Windows NT 6.1; U; es-ES) Presto/2.9.181 Version/12.00",
"Opera/9.80 (Windows NT 5.1; U; zh-sg) Presto/2.9.181 Version/12.00",
"Opera/12.0 (Windows NT 5.2;U;en)Presto/22.9.168 Version/12.00",
"Opera/12.0 (Windows NT 5.1;U;en)Presto/22.9.168 Version/12.00",
"Opera/12.80 (Windows NT 5.1; U; en) Presto/2.10.289 Version/12.02" };
int index = (int) (Math.random() * _user_agent_pc.length);
return _user_agent_pc[index];
}
public static String getSql(String attr, String values, String operator, String type,String tableAlias) {
StringBuilder eventSB = new StringBuilder();
if (attr.equals("_cid")) {
type = "number";
}
if (operator.contains("in")) {
if (type.contains("string") || type.contains("date")) {
String value = values.replace(",", "','");
eventSB.append(" ").append(tableAlias).append(attr).append(" ").append(operator).append("('").append(value).append("') ");
} else {
eventSB.append(tableAlias).append(attr).append(" ").append(operator).append("(").append(values).append(") ");
}
} else if (operator.contains("between")) {
if (type.contains("string") || type.contains("date")) {
String value = values.replace(",", "' and '");
eventSB.append(tableAlias).append(attr).append(" ").append(operator).append(" '").append(value).append("' ");
} else {
String value = values.replace(",", " and ");
eventSB.append(tableAlias).append(attr).append(" ").append(operator).append(" ").append(value).append(" ");
}
} else {
if (type.contains("string") || type.contains("date")) {
eventSB.append(tableAlias).append(attr).append(" ").append(operator).append(" '").append(values).append("' ");
} else {
eventSB.append(tableAlias).append(attr).append(" ").append(operator).append(" ").append(values).append(" ");
}
}
return eventSB.toString();
}
public static String conditionFormat(String str) {
str = "'" + str.replaceAll(",", "','") + "'";
return str;
}
/**
* URL校验
*/
public static boolean urlMatch(String str) {
Pattern pattern = Pattern.compile(URL_REGEX_PATTERN);
return pattern.matcher(str).matches();
}
/**
* 名字校验
*/
public static boolean nameMatch(String str) {
Pattern pattern = Pattern.compile(NAME_REGEX_PATTERN);
return pattern.matcher(str).matches();
}
/**
* 将Long List转换成String,逗号隔开
*/
public static String transList2String(List<Long> idList){
StringBuilder stringBuilder = new StringBuilder();
for(Long id : idList){
stringBuilder.append(id).append(",");
}
return stringBuilder.length() > 0 ? stringBuilder.deleteCharAt(stringBuilder.lastIndexOf(",")).toString() : stringBuilder.toString();
}
/**
* 将逗号分隔的string转换成Long的List
*/
public static List<Long> transString2LongList(String ids)
{
List<Long> resultList = new ArrayList<>();
String[] idArray = toStrArray(ids);
for (String id : idArray) {
try {
if (Strings.isNullOrEmpty(id)) {
continue;
}
resultList.add(Long.parseLong(id));
}
catch (Exception e) {
e.printStackTrace();
}
}
return resultList;
}
}
package util;
import org.json.JSONArray;
import org.json.JSONException;
import java.util.Collection;
import java.util.Map;
/**
* 校验工具类
* @author liruijie@reyun.com
* @date 2015年11月24日
*/
public class ValidateUtil {
/**
* 判断string是否有效
* @param str
* @return
*/
public static boolean isValid(String str) {
if (str == null || "".equals(str.trim())) {
return false;
}
return true;
}
/**
* 判断集合的有效性
* @param col
* @return
*/
@SuppressWarnings("rawtypes")
public static boolean isValid(Collection col) {
if (col == null || col.isEmpty()) {
return false;
}
return true;
}
/**
* 判断map的有效性
* @param map
* @return
*/
@SuppressWarnings("rawtypes")
public static boolean isValid(Map map) {
if (map == null || map.isEmpty()) {
return false;
}
return true;
}
/**
* 判断数组有效性
* @param arr
* @return
*/
public static boolean isValid(Object[] arr) {
if (arr == null || arr.length == 0) {
return false;
}
return true;
}
/**
* 判断对象有效性
* @param obj
* @return
*/
public static boolean isValid(Object obj) {
if (obj == null) {
return false;
}
return true;
}
public static boolean isValid(JSONArray obj) {
if (obj == null) {
return false;
}
if(obj.length()<1){
return false;
}
return true;
}
public static boolean validNotChinese(String str){
return str.matches("^[a-zA-Z0-9_][a-zA-Z0-9_-]*$");
}
public static void main(String[] args) throws JSONException {
String s = "[]";
JSONArray o = new JSONArray(s);
boolean valid = isValid(o);
System.out.println(valid);
}
}
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
<description>调度配置</description> <description>调度配置</description>
<!-- <bean id="autoSyncSurlTask" class="com.reyun.task.AutoSyncSurlTask"></bean>--> <bean id="tkioAccountTask" class="tkio.task.AccountTask"></bean>
<!-- <task:scheduled-tasks> <task:scheduled-tasks>
&lt;!&ndash;//定时同步短链数据(每5分钟执行一次)&ndash;&gt; <!--//定时同步短链数据(每5分钟执行一次)-->
<task:scheduled ref="autoSyncSurlTask" method="run" cron="0 */2 * * * ?"/> <task:scheduled ref="tkioAccountTask" method="task" cron="0 32 19 * * ?"/>
</task:scheduled-tasks>--> </task:scheduled-tasks>
</beans> </beans>
...@@ -49,6 +49,16 @@ ...@@ -49,6 +49,16 @@
<property name="username" value="${office.username}"/> <property name="username" value="${office.username}"/>
<property name="password" value="${office.password}"/> <property name="password" value="${office.password}"/>
</bean> </bean>
<bean id="tkioDataSource" parent="parentDataSource">
<property name="url" value="${tkio.url}"/>
<property name="username" value="${tkio.username}"/>
<property name="password" value="${tkio.password}"/>
</bean>
<bean id="trackDataSource" parent="parentDataSource">
<property name="url" value="${track.url}"/>
<property name="username" value="${track.username}"/>
<property name="password" value="${track.password}"/>
</bean>
<!-- JPA实体管理工厂的配置 --> <!-- JPA实体管理工厂的配置 -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
...@@ -86,6 +96,40 @@ ...@@ -86,6 +96,40 @@
<prop key="hibernate.connection.useUnicode">true</prop> <prop key="hibernate.connection.useUnicode">true</prop>
</props> </props>
</property> </property>
</bean>
<bean id="tkioEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="tkioDataSource"/>
<property name="packagesToScan" value="tkio.model"></property>
<property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"/>
<property name="jpaProperties">
<props>
<prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop><!-- none -->
<prop key="hibernate.connection.CharSet">utf8</prop>
<prop key="hibernate.connection.characterEncoding">utf8</prop>
<prop key="hibernate.connection.useUnicode">true</prop>
</props>
</property>
</bean>
<bean id="trackEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="trackDataSource"/>
<property name="packagesToScan" value="track.model"></property>
<property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"/>
<property name="jpaProperties">
<props>
<prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop><!-- none -->
<prop key="hibernate.connection.CharSet">utf8</prop>
<prop key="hibernate.connection.characterEncoding">utf8</prop>
<prop key="hibernate.connection.useUnicode">true</prop>
</props>
</property>
</bean> </bean>
<!--指定实现JPA的适配器 --> <!--指定实现JPA的适配器 -->
<bean id="hibernateJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <bean id="hibernateJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
...@@ -99,6 +143,12 @@ ...@@ -99,6 +143,12 @@
<bean id="officeTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <bean id="officeTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="officeEntityManagerFactory"/> <property name="entityManagerFactory" ref="officeEntityManagerFactory"/>
</bean> </bean>
<bean id="tkioTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="tkioEntityManagerFactory"/>
</bean>
<bean id="trackTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="trackEntityManagerFactory"/>
</bean>
<!-- Spring Data Jpa配置 --> <!-- Spring Data Jpa配置 -->
<jpa:repositories base-package="common.repository" <jpa:repositories base-package="common.repository"
...@@ -107,9 +157,19 @@ ...@@ -107,9 +157,19 @@
<jpa:repositories base-package="office.repository" <jpa:repositories base-package="office.repository"
repository-impl-postfix="Impl" transaction-manager-ref="officeTransactionManager" repository-impl-postfix="Impl" transaction-manager-ref="officeTransactionManager"
entity-manager-factory-ref="officeEntityManagerFactory"/> entity-manager-factory-ref="officeEntityManagerFactory"/>
<jpa:repositories base-package="tkio.repository"
repository-impl-postfix="Impl" transaction-manager-ref="tkioTransactionManager"
entity-manager-factory-ref="tkioEntityManagerFactory"/>
<jpa:repositories base-package="track.repository"
repository-impl-postfix="Impl" transaction-manager-ref="trackTransactionManager"
entity-manager-factory-ref="trackEntityManagerFactory"/>
<!-- 使用annotation定义事务 --> <!-- 使用annotation定义事务 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<tx:annotation-driven transaction-manager="officeTransactionManager" proxy-target-class="true"/> <tx:annotation-driven transaction-manager="officeTransactionManager" proxy-target-class="true"/>
<tx:annotation-driven transaction-manager="tkioTransactionManager" proxy-target-class="true"/>
<tx:annotation-driven transaction-manager="trackTransactionManager" proxy-target-class="true"/>
<tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes> <tx:attributes>
...@@ -130,6 +190,24 @@ ...@@ -130,6 +190,24 @@
<tx:method name="*" propagation="REQUIRED"/> <tx:method name="*" propagation="REQUIRED"/>
</tx:attributes> </tx:attributes>
</tx:advice> </tx:advice>
<tx:advice id="tkioTxAdvice" transaction-manager="tkioTransactionManager">
<tx:attributes>
<tx:method name="report*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="list*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="query*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<tx:advice id="trackTxAdvice" transaction-manager="trackTransactionManager">
<tx:attributes>
<tx:method name="report*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="list*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="query*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config expose-proxy="true"> <aop:config expose-proxy="true">
<aop:pointcut id="txPointcut" expression="execution(* common.service.*.*(..))"/> <aop:pointcut id="txPointcut" expression="execution(* common.service.*.*(..))"/>
...@@ -139,7 +217,14 @@ ...@@ -139,7 +217,14 @@
<aop:pointcut id="officetxPointcut" expression="execution(* office.service.*.*(..))"/> <aop:pointcut id="officetxPointcut" expression="execution(* office.service.*.*(..))"/>
<aop:advisor advice-ref="officeTxAdvice" pointcut-ref="officetxPointcut"/> <aop:advisor advice-ref="officeTxAdvice" pointcut-ref="officetxPointcut"/>
</aop:config> </aop:config>
<aop:config expose-proxy="true">
<aop:pointcut id="tkiotxPointcut" expression="execution(* tkio.service.*.*(..))"/>
<aop:advisor advice-ref="tkioTxAdvice" pointcut-ref="tkiotxPointcut"/>
</aop:config>
<aop:config expose-proxy="true">
<aop:pointcut id="tracktxPointcut" expression="execution(* track.service.*.*(..))"/>
<aop:advisor advice-ref="trackTxAdvice" pointcut-ref="tracktxPointcut"/>
</aop:config>
<!-- SpringMVC上传文件时,需要配置MultipartResolver处理器 --> <!-- SpringMVC上传文件时,需要配置MultipartResolver处理器 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
......
report.url=${report.url}
awsneed=${awsneed}
profile.table=${profile.table}
event.table=${event.table}
usergroup.table=${usergroup.table}
iscache=${iscache}
...@@ -8,3 +8,11 @@ default.dataSource.password=${default.datasource.password} ...@@ -8,3 +8,11 @@ default.dataSource.password=${default.datasource.password}
office.url=${office.url} office.url=${office.url}
office.username=${office.username} office.username=${office.username}
office.password=${office.password} office.password=${office.password}
tkio.url=${tkio.url}
tkio.username=${tkio.username}
tkio.password=${tkio.password}
track.url=${track.url}
track.username=${track.username}
track.password=${track.password}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment