|
@@ -24,6 +24,7 @@ import com.ytpm.middle.view.DashboardRevenueVO;
|
|
|
import com.ytpm.middle.view.DashboardRiskVO;
|
|
import com.ytpm.middle.view.DashboardRiskVO;
|
|
|
import com.ytpm.middle.view.DashboardTopCountVo;
|
|
import com.ytpm.middle.view.DashboardTopCountVo;
|
|
|
import com.ytpm.middle.view.UserRankingListVO;
|
|
import com.ytpm.middle.view.UserRankingListVO;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
@@ -38,6 +39,7 @@ import java.util.Map;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
@RefreshScope
|
|
@RefreshScope
|
|
|
public class CountServiceImpl implements CountService {
|
|
public class CountServiceImpl implements CountService {
|
|
@@ -74,7 +76,13 @@ public class CountServiceImpl implements CountService {
|
|
|
BigDecimal resultAdCount = new BigDecimal(0);
|
|
BigDecimal resultAdCount = new BigDecimal(0);
|
|
|
BigDecimal resultRevenue = new BigDecimal(0);
|
|
BigDecimal resultRevenue = new BigDecimal(0);
|
|
|
for (Map.Entry<String, String> entry : serveMap.entrySet()) {
|
|
for (Map.Entry<String, String> entry : serveMap.entrySet()) {
|
|
|
- Object o = feignInvoker.invoke(entry.getKey(), "getAdCount",entry.getValue());
|
|
|
|
|
|
|
+ Object o;
|
|
|
|
|
+ try {
|
|
|
|
|
+ o = feignInvoker.invoke(entry.getKey(), "getAdCount",entry.getValue());
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
JSONObject object = JSONObject.parseObject(JSON.toJSONString(o));
|
|
JSONObject object = JSONObject.parseObject(JSON.toJSONString(o));
|
|
|
resultAdCount = resultAdCount.add(object.getBigDecimal("adCount"));
|
|
resultAdCount = resultAdCount.add(object.getBigDecimal("adCount"));
|
|
|
resultRevenue = resultRevenue.add(object.getBigDecimal("expectRevenue"));
|
|
resultRevenue = resultRevenue.add(object.getBigDecimal("expectRevenue"));
|
|
@@ -111,8 +119,16 @@ public class CountServiceImpl implements CountService {
|
|
|
DashboardRankingListVO rankingVO = new DashboardRankingListVO();
|
|
DashboardRankingListVO rankingVO = new DashboardRankingListVO();
|
|
|
List<AppRankingListVO> appRankingList = new ArrayList<>();
|
|
List<AppRankingListVO> appRankingList = new ArrayList<>();
|
|
|
List<UserRankingListVO> userRankingList = new ArrayList<>();
|
|
List<UserRankingListVO> userRankingList = new ArrayList<>();
|
|
|
|
|
+ boolean hasError = false;
|
|
|
for (String serve : serveList) {
|
|
for (String serve : serveList) {
|
|
|
- Object o = feignInvoker.invoke(serve,"queryRankingList",sortBy,rankingLimit);
|
|
|
|
|
|
|
+ Object o;
|
|
|
|
|
+ try{
|
|
|
|
|
+ o = feignInvoker.invoke(serve,"queryRankingList",sortBy,rankingLimit);
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
|
|
+ hasError = true;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
DashboardRankingListVO vo = JSONObject.parseObject(JSON.toJSONString(o), DashboardRankingListVO.class);
|
|
DashboardRankingListVO vo = JSONObject.parseObject(JSON.toJSONString(o), DashboardRankingListVO.class);
|
|
|
appRankingList.addAll(vo.getAppRankingList());
|
|
appRankingList.addAll(vo.getAppRankingList());
|
|
|
userRankingList.addAll(vo.getUserRankingList());
|
|
userRankingList.addAll(vo.getUserRankingList());
|
|
@@ -126,7 +142,9 @@ public class CountServiceImpl implements CountService {
|
|
|
.reversed()).limit(5).collect(Collectors.toList()));
|
|
.reversed()).limit(5).collect(Collectors.toList()));
|
|
|
rankingVO.setAppRankingList(appRankingList.stream().sorted(Comparator.comparing(AppRankingListVO::getTotalRevenue)
|
|
rankingVO.setAppRankingList(appRankingList.stream().sorted(Comparator.comparing(AppRankingListVO::getTotalRevenue)
|
|
|
.reversed()).limit(5).collect(Collectors.toList()));
|
|
.reversed()).limit(5).collect(Collectors.toList()));
|
|
|
- redisUtil.setTimeOutMinutesStr(RANKING_KEY+sortBy, JSON.toJSONString(rankingVO),rankingExpire);
|
|
|
|
|
|
|
+ if(!hasError){
|
|
|
|
|
+ redisUtil.setTimeOutMinutesStr(RANKING_KEY+sortBy, JSON.toJSONString(rankingVO),rankingExpire);
|
|
|
|
|
+ }
|
|
|
return rankingVO;
|
|
return rankingVO;
|
|
|
}
|
|
}
|
|
|
|
|
|