Commit 5874b982 by yangfangfang

Merge branch 'master' of git.minrow.com:reyun/saasio

parents 3dc35820 d23322f9
......@@ -70,6 +70,9 @@ public class LoginController
@Autowired
AuthService authService;
@Autowired
AccountFlowRestrictService accountFlowRestrictService;
@Autowired
PackageTypeRepository packageTypeRepository;
......@@ -85,6 +88,24 @@ public class LoginController
Account account = loginService.login(email, password);
if (account != null) {
if(!account.getRoleCategory().equals(5L)) {
Boolean trackAndIoBothExhaust = accountFlowRestrictService.isTrackAndIoBothExhaust(account.getId());
Long rootParent = accountRepository.findRootParentByAccountId(account.getId()).longValue();
Account rootAccount = accountRepository.findOne(rootParent);
if (trackAndIoBothExhaust) {
if (rootAccount.getAllowBehavior()) {
rtnMap.put("msg", "广告效果监控流量和行为分析流量均用尽!");
rtnMap.put("code", 211);
return ResultModel.OK(rtnMap);
} else {
rtnMap.put("msg", "广告效果监控流量已经用尽!");
rtnMap.put("code", 211);
return ResultModel.OK(rtnMap);
}
}
}
if (!account.getIsSuperUser()) {
//子账号
if (account.getStatus() == 0) {
......
package com.reyun.controller.manage;
import com.reyun.model.AccountRestrict4Web;
import com.reyun.repository.AccountRepository;
import com.reyun.repository.AccountRestrict4WebRepository;
import com.reyun.service.AccountFlowRestrictService;
import com.reyun.util.ResultModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
/**
* Created by song on 2017/10/19.
*/
@Controller
@RequestMapping("/mng/accountRestrict")
public class MngAccountFlowController {
@Autowired
private AccountRestrict4WebRepository accountRestrict4WebRepository;
@Autowired
private AccountRepository accountRepository;
@Autowired
private AccountFlowRestrictService accountFlowRestrictService;
@RequestMapping(value = "find/{accountId}", method = RequestMethod.GET)
@ResponseBody
public ResultModel list(@PathVariable Long accountId) {
long superAccountId = accountRepository.findRootParentByAccountId(accountId).longValue();
AccountRestrict4Web byAccountId = accountRestrict4WebRepository.findByAccountId(superAccountId);
if(byAccountId==null){
byAccountId = accountFlowRestrictService.RestrictFlowByAccountTask(accountId);
}
return ResultModel.OK(byAccountId);
}
@RequestMapping(value = "confirm", method = RequestMethod.POST)
@ResponseBody
public ResultModel confirm(@RequestBody AccountRestrict4Web resource) {
long superAccountId = accountRepository.findRootParentByAccountId(resource.getAccountId()).longValue();
AccountRestrict4Web byAccountId1 = accountRestrict4WebRepository.findByAccountId(superAccountId);
if(resource.getTrackPastTime()!=null && resource.getTrackPastTime()){
byAccountId1.setTrackPastTimeNotified(false);
}
if(resource.getIoPastTime()!=null && resource.getIoPastTime()){
byAccountId1.setIOPastTimeNotified(false);
}
if(resource.getTrackFlow()!=null && resource.getTrackFlow()){
byAccountId1.setTrackFlowNotified(false);
}
if(resource.getIoFlow()!=null && resource.getIoFlow() ){
byAccountId1.setIOFlowNotified(false);
}
accountRestrict4WebRepository.save(byAccountId1);
return ResultModel.OK();
}
}
package com.reyun.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.math.BigInteger;
@Entity
public class AccountRestrict4Web {
private Long id;
private String packageName;
private String originalName;
private BigInteger IOLimit;
......@@ -24,6 +30,21 @@ public class AccountRestrict4Web {
private Boolean isTrackFlowNotified;
private Boolean isIOFlowNotified;
private Boolean allowBehavior;
private Boolean superLevel;
private Boolean ioPastTime;
private Boolean trackPastTime;
private Boolean ioFlow;
private Boolean trackFlow;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getPackLevel() {
return packLevel;
......@@ -192,4 +213,48 @@ public class AccountRestrict4Web {
public void setAllowBehavior(Boolean allowBehavior) {
this.allowBehavior = allowBehavior;
}
public Boolean getSuperLevel() {
return superLevel;
}
public void setSuperLevel(Boolean superLevel) {
this.superLevel = superLevel;
}
@Transient
public Boolean getIoPastTime() {
return ioPastTime;
}
public void setIoPastTime(Boolean ioPastTime) {
this.ioPastTime = ioPastTime;
}
@Transient
public Boolean getTrackPastTime() {
return trackPastTime;
}
public void setTrackPastTime(Boolean trackPastTime) {
this.trackPastTime = trackPastTime;
}
@Transient
public Boolean getIoFlow() {
return ioFlow;
}
public void setIoFlow(Boolean ioFlow) {
this.ioFlow = ioFlow;
}
@Transient
public Boolean getTrackFlow() {
return trackFlow;
}
public void setTrackFlow(Boolean trackFlow) {
this.trackFlow = trackFlow;
}
}
package com.reyun.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;
}
}
......@@ -17,6 +17,7 @@ public class PackageType {
private BigInteger trackFlow;
private BigInteger ioFlow;
private Integer appNum;
private Boolean superLevel;
/**
* 价格
......@@ -375,4 +376,12 @@ public class PackageType {
public void setPlatformCustomDataAnalysis(Boolean platformCustomDataAnalysis) {
this.platformCustomDataAnalysis = platformCustomDataAnalysis;
}
public Boolean getSuperLevel() {
return superLevel;
}
public void setSuperLevel(Boolean superLevel) {
this.superLevel = superLevel;
}
}
......@@ -72,6 +72,8 @@ 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 status=1 and flow_restrict is TRUE and is_super_user is TRUE;", nativeQuery = true)
List<Account> findSuperAccount();
@Transactional
@Modifying
......
package com.reyun.repository;
import com.reyun.model.AccountRestrict4Web;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
/**
* Created by song on 2018/2/12.
*/
@Transactional
public interface AccountRestrict4WebRepository extends JpaRepository<AccountRestrict4Web, Long> {
@Query(value = "select * from account_restrict4web where account_id=?1", nativeQuery = true)
AccountRestrict4Web findByAccountId(Long account);
}
package com.reyun.repository;
import com.reyun.model.IsNotified;
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;
@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 com.reyun.service;
import com.reyun.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);
AccountRestrict4Web RestrictFlowByAccountTask(Long accountId);
}
package com.reyun.task;
import com.reyun.model.Account;
import com.reyun.repository.AccountRepository;
import com.reyun.service.AccountFlowRestrictService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by song on 2018/2/12.
*/
@Service
public class AutoCalculateFlow {
private static Logger logger = LoggerFactory.getLogger(AutoCalculateFlow.class);
@Autowired
AccountFlowRestrictService accountFlowRestrictService;
@Autowired
AccountRepository accountRepository;
public void run(){
try{
List<Account> superAccount = accountRepository.findSuperAccount();
for(Account account:superAccount){
//System.out.println("**********************************************\n\n");
accountFlowRestrictService.RestrictFlowByAccountTask(account.getId());
//System.out.println("**********************************************\n\n");
}
}catch(Exception e){
e.printStackTrace();
logger.info(e.getMessage());
}
}
}
......@@ -32,6 +32,16 @@ public class Constant {
public static String eventTable = commonBundle.getString("event.table");
public static String usergroupTable = commonBundle.getString("usergroup.table");
public static String accountCheckUrl = commonBundle.getString("account.check.url");
public static String reportUrl = commonBundle.getString("report.url");
public static String adminUrl = commonBundle.getString("admin.url");
public static String iscache = commonBundle.getString("iscache");
public static String receiverHost = commonBundle.getString("receiver.host");
public static String receiverPort = commonBundle.getString("receiver.port");
public static String reportExportTask = commonBundle.getString("report.export.task");
public static String appDebugTask = commonBundle.getString("app.debug.task");
public static String tkioUrl = commonBundle.getString("tkio.url");
public static String awsAccessKey = commonBundle.getString("aws.accesskey");
public static String awsSecretKey = commonBundle.getString("aws.secret");
......
......@@ -9,4 +9,9 @@
<description>调度配置</description>
<bean id="autoCalculateFlow" class="com.reyun.task.AutoCalculateFlow"></bean>
<task:scheduled-tasks>
<task:scheduled ref="autoCalculateFlow" method="run" cron="0 */10 * * * ?"/>
</task:scheduled-tasks>
</beans>
profile.table=${profile.table}
event.table=${event.table}
usergroup.table=${usergroup.table}
account.check.url=${account.check.url}
\ No newline at end of file
account.check.url=${account.check.url}
receiver.host=${receiver.host}
receiver.port=${receiver.port}
report.url=${report.url}
awsneed=${awsneed}
iscache=${iscache}
admin.url=${admin.url}
report.export.task=${report.export.task}
app.debug.task=${app.debug.task}
tkio.url=${tkio.url}
aws.accesskey=${aws.accesskey}
aws.secret=${aws.secret}
\ 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