|
|
@@ -68,6 +68,8 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
public Result kuaiShousumData(String mediaType, String type, String startTime, String endTime, String userId) {
|
|
|
long stratDate = DateUtils.getDateInteger(startTime);
|
|
|
long endDate = DateUtils.getDateInteger(endTime);
|
|
|
+ long nowDate = DateUtils.getDateInteger(DateUtils.getDate("yyyy-MM-dd"));
|
|
|
+ boolean currentDayOnly = isCurrentDayOnly(stratDate, endDate, nowDate);
|
|
|
//查询当前人员所有下级
|
|
|
Set<String> operatorUserIds = getAffiliateId(userId);
|
|
|
//头条
|
|
|
@@ -76,7 +78,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
//汇总
|
|
|
if (StringUtils.equals(type, "1")) {
|
|
|
//查询一天数据时 查询时报
|
|
|
- if (stratDate == endDate) {
|
|
|
+ if (currentDayOnly) {
|
|
|
Map resultMap = new HashMap<>();
|
|
|
//时报
|
|
|
List<Map> todayList = materialStareMapper.getBytedanceCostHourlyByUserIdList(stratDate, endDate, operatorUserIds);
|
|
|
@@ -94,7 +96,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
|
|
|
//运营个人
|
|
|
if (StringUtils.equals(type, "2")) {
|
|
|
- if (stratDate == endDate) {
|
|
|
+ if (currentDayOnly) {
|
|
|
//时报 消耗前5
|
|
|
List<JSONObject> userList = materialStareMapper.getBytedanceCostByTop5HourList(stratDate, endDate, operatorUserIds);
|
|
|
List<Map> resultList = new ArrayList<>();
|
|
|
@@ -132,7 +134,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
//汇总
|
|
|
if (StringUtils.equals(type, "1")) {
|
|
|
//查询一天数据时 查询时报
|
|
|
- if (stratDate == endDate) {
|
|
|
+ if (currentDayOnly) {
|
|
|
Map resultMap = new HashMap<>();
|
|
|
//时报
|
|
|
List<Map> todayList = materialStareMapper.getKuaiShouCostHourlyByUserIdList(stratDate, endDate, operatorUserIds);
|
|
|
@@ -149,7 +151,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
|
|
|
//运营个人
|
|
|
} else if (StringUtils.equals(type, "2")) {
|
|
|
- if (stratDate == endDate) {
|
|
|
+ if (currentDayOnly) {
|
|
|
//时报 消耗前5
|
|
|
List<JSONObject> userList = materialStareMapper.getKuaiShouCostByTop5HourList(stratDate, endDate, operatorUserIds);
|
|
|
List<Map> resultList = new ArrayList<>();
|
|
|
@@ -184,7 +186,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
}
|
|
|
if (StringUtils.equals(mediaType, "16")) {
|
|
|
if (StringUtils.equals(type, "1")) {
|
|
|
- if (stratDate == endDate) {
|
|
|
+ if (currentDayOnly) {
|
|
|
Map resultMap = new HashMap<>();
|
|
|
List<Map> todayList = materialStareMapper.getAdqCostHourlyByUserIdList(stratDate, endDate, operatorUserIds);
|
|
|
long time = DateUtils.getDateInteger(DateUtils.addDayParse(Long.toString(endDate), -1));
|
|
|
@@ -197,7 +199,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
return Result.successMsg("查询-腾讯-日报-汇总成功。", dailyList);
|
|
|
}
|
|
|
if (StringUtils.equals(type, "2")) {
|
|
|
- if (stratDate == endDate) {
|
|
|
+ if (currentDayOnly) {
|
|
|
List<JSONObject> userList = materialStareMapper.getAdqCostByTop5HourList(stratDate, endDate, operatorUserIds);
|
|
|
List<Map> resultList = new ArrayList<>();
|
|
|
for (JSONObject jsonObject : userList) {
|
|
|
@@ -245,6 +247,8 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
|
|
|
long stratDate = DateUtils.getDateInteger(startTime);
|
|
|
long endDate = DateUtils.getDateInteger(endTime);
|
|
|
+ long nowDate = DateUtils.getDateInteger(DateUtils.getDate("yyyy-MM-dd"));
|
|
|
+ boolean currentDayOnly = isCurrentDayOnly(stratDate, endDate, nowDate);
|
|
|
Set<String> userSet = new HashSet<String>() {{
|
|
|
add(userId);
|
|
|
}};
|
|
|
@@ -275,7 +279,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
//头条
|
|
|
if (StringUtils.equals(mediaType, "1")) {
|
|
|
//查询一天数据时 查询时报
|
|
|
- if (stratDate == endDate) {
|
|
|
+ if (currentDayOnly) {
|
|
|
Map resultMap = new HashMap<>();
|
|
|
//时报
|
|
|
List<Map> todayList = materialStareMapper.getBytedanceCostHourlyByUserIdList(stratDate, endDate, userSet);
|
|
|
@@ -293,7 +297,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
//快手
|
|
|
if (StringUtils.equals(mediaType, "2")) {
|
|
|
//查询一天数据时 查询时报
|
|
|
- if (stratDate == endDate) {
|
|
|
+ if (currentDayOnly) {
|
|
|
Map resultMap = new HashMap<>();
|
|
|
//时报
|
|
|
List<Map> todayList = materialStareMapper.getKuaiShouCostHourlyByUserIdList(stratDate, endDate, userSet);
|
|
|
@@ -309,7 +313,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
return Result.successMsg("查询运营个人-日报-汇总成功。", dailyList);
|
|
|
}
|
|
|
if (StringUtils.equals(mediaType, "16")) {
|
|
|
- if (stratDate == endDate) {
|
|
|
+ if (currentDayOnly) {
|
|
|
Map resultMap = new HashMap<>();
|
|
|
List<Map> todayList = materialStareMapper.getAdqCostHourlyByUserIdList(stratDate, endDate, userSet);
|
|
|
long time = DateUtils.getDateInteger(DateUtils.addDayParse(Long.toString(endDate), -1));
|
|
|
@@ -359,27 +363,38 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
|
|
|
long endDate = Long.valueOf(DateUtils.getDateInteger(endTime));
|
|
|
boolean currentDay = startDate == endDate && startDate == nowDate;
|
|
|
+ Map<String, String> lastTime = DateUtils.getStartEndTime(startTime, endTime);
|
|
|
+ long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
|
|
|
+ long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
|
|
|
JSONObject projectUserSummary = materialStareMapper.getBytedanceOperateProjectUserSummary(startDate, endDate, operatorUserIds);
|
|
|
JSONObject sectionSummary = currentDay
|
|
|
? materialStareMapper.getBytedanceTotalCost(startDate, endDate, nowHour, operatorUserIds)
|
|
|
: materialStareMapper.getBytedanceOperateSummary(startDate, endDate, operatorUserIds);
|
|
|
- JSONObject compareSummary = materialStareMapper.getOperateTodayYesterdaySummary(
|
|
|
- "application.bytedance_advertiser_report_hourly_dw",
|
|
|
- "stat_datetime",
|
|
|
- "cost",
|
|
|
- "hour",
|
|
|
- nowDate,
|
|
|
- nowDate,
|
|
|
- nowHour,
|
|
|
- time,
|
|
|
- operatorUserIds
|
|
|
- );
|
|
|
- double todayCost = getJsonDouble(compareSummary, "todayCost");
|
|
|
- resultMap.put("todayCost", todayCost);
|
|
|
- double yesterdayCost = getJsonDouble(compareSummary, "yesterdayCost");
|
|
|
- resultMap.put("compare", formatRate(todayCost, yesterdayCost, decimalFormat));
|
|
|
Double tCost = getJsonDouble(sectionSummary, "totalCost");
|
|
|
resultMap.put("sectionCost", tCost);
|
|
|
+ if (currentDay) {
|
|
|
+ JSONObject compareSummary = materialStareMapper.getOperateTodayYesterdaySummary(
|
|
|
+ "application.bytedance_advertiser_report_hourly_dw",
|
|
|
+ "stat_datetime",
|
|
|
+ "cost",
|
|
|
+ "hour",
|
|
|
+ nowDate,
|
|
|
+ nowDate,
|
|
|
+ nowHour,
|
|
|
+ time,
|
|
|
+ operatorUserIds
|
|
|
+ );
|
|
|
+ double todayCost = getJsonDouble(compareSummary, "todayCost");
|
|
|
+ resultMap.put("todayCost", todayCost);
|
|
|
+ double yesterdayCost = getJsonDouble(compareSummary, "yesterdayCost");
|
|
|
+ resultMap.put("compare", formatRate(todayCost, yesterdayCost, decimalFormat));
|
|
|
+ } else {
|
|
|
+ JSONObject periodSummary = materialStareMapper.getBytedancePeriodCostSummary(startDate, endDate, lastTimeStart, lastTimeEnd, operatorUserIds);
|
|
|
+ double currentCost = getJsonDouble(periodSummary, "currentCost");
|
|
|
+ double lastCost = getJsonDouble(periodSummary, "lastCost");
|
|
|
+ resultMap.put("todayCost", currentCost);
|
|
|
+ resultMap.put("compare", formatRate(currentCost, lastCost, decimalFormat));
|
|
|
+ }
|
|
|
int activeUserNum = getJsonInt(projectUserSummary, "userNum");
|
|
|
Double userAverageAccount = safeDivide(getJsonDouble(sectionSummary, "accountNum"), activeUserNum);
|
|
|
Double userAveragecost = safeDivide(tCost, activeUserNum);
|
|
|
@@ -394,29 +409,40 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
|
|
|
long endDate = Long.valueOf(DateUtils.getDateInteger(endTime));
|
|
|
boolean currentDay = startDate == endDate && startDate == nowDate;
|
|
|
+ Map<String, String> lastTime = DateUtils.getStartEndTime(startTime, endTime);
|
|
|
+ long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
|
|
|
+ long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
|
|
|
JSONObject summary = currentDay
|
|
|
? materialStareMapper.getKuaiShouTotalCost(startDate, endDate, nowHour, operatorUserIds)
|
|
|
: materialStareMapper.getKuaiShouOperateSummary(startDate, endDate, operatorUserIds);
|
|
|
JSONObject projectUserSummary = currentDay
|
|
|
? materialStareMapper.getKuaiShouOperateProjectUserSummary(startDate, endDate, nowHour, operatorUserIds)
|
|
|
: materialStareMapper.getKuaiShouOperateSummary(startDate, endDate, operatorUserIds);
|
|
|
- JSONObject compareSummary = materialStareMapper.getOperateTodayYesterdaySummary(
|
|
|
- "application.kuaishou_account_report_hourly_dw",
|
|
|
- "stat_date",
|
|
|
- "charge",
|
|
|
- "hour",
|
|
|
- nowDate,
|
|
|
- nowDate,
|
|
|
- nowHour,
|
|
|
- time,
|
|
|
- operatorUserIds
|
|
|
- );
|
|
|
- double todayCost = getJsonDouble(compareSummary, "todayCost");
|
|
|
- resultMap.put("todayCost", todayCost);
|
|
|
- double yesterdayCost = getJsonDouble(compareSummary, "yesterdayCost");
|
|
|
- resultMap.put("compare", formatRate(todayCost, yesterdayCost, decimalFormat));
|
|
|
double sectionCost = getJsonDouble(summary, "totalCost");
|
|
|
resultMap.put("sectionCost", sectionCost);
|
|
|
+ if (currentDay) {
|
|
|
+ JSONObject compareSummary = materialStareMapper.getOperateTodayYesterdaySummary(
|
|
|
+ "application.kuaishou_account_report_hourly_dw",
|
|
|
+ "stat_date",
|
|
|
+ "charge",
|
|
|
+ "hour",
|
|
|
+ nowDate,
|
|
|
+ nowDate,
|
|
|
+ nowHour,
|
|
|
+ time,
|
|
|
+ operatorUserIds
|
|
|
+ );
|
|
|
+ double todayCost = getJsonDouble(compareSummary, "todayCost");
|
|
|
+ resultMap.put("todayCost", todayCost);
|
|
|
+ double yesterdayCost = getJsonDouble(compareSummary, "yesterdayCost");
|
|
|
+ resultMap.put("compare", formatRate(todayCost, yesterdayCost, decimalFormat));
|
|
|
+ } else {
|
|
|
+ JSONObject periodSummary = materialStareMapper.getKuaiShouPeriodCostSummary(startDate, endDate, lastTimeStart, lastTimeEnd, operatorUserIds);
|
|
|
+ double currentCost = getJsonDouble(periodSummary, "currentCost");
|
|
|
+ double lastCost = getJsonDouble(periodSummary, "lastCost");
|
|
|
+ resultMap.put("todayCost", currentCost);
|
|
|
+ resultMap.put("compare", formatRate(currentCost, lastCost, decimalFormat));
|
|
|
+ }
|
|
|
int activeUserNum = getJsonInt(projectUserSummary, "userNum");
|
|
|
Double userAverageAccount = safeDivide(getJsonDouble(summary, "accountNum"), activeUserNum);
|
|
|
Double userAveragecost = safeDivide(sectionCost, activeUserNum);
|
|
|
@@ -426,20 +452,31 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
resultMap.put("projectNum", String.valueOf(getJsonInt(projectUserSummary, "projectNum")));
|
|
|
}
|
|
|
if (mediaType.equals("16")) {
|
|
|
- JSONObject jsonObjectNow = materialStareMapper.getAdqTotalCost(nowDate, nowDate, nowHour, operatorUserIds);
|
|
|
- double todayCost = getJsonDouble(jsonObjectNow, "totalCost");
|
|
|
- resultMap.put("todayCost", todayCost);
|
|
|
- JSONObject jsonObjectYesterday = materialStareMapper.getAdqTotalCost(time, time, nowHour, operatorUserIds);
|
|
|
- double yesterdayCost = getJsonDouble(jsonObjectYesterday, "totalCost");
|
|
|
- resultMap.put("compare", formatRate(todayCost, yesterdayCost, decimalFormat));
|
|
|
long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
|
|
|
long endDate = Long.valueOf(DateUtils.getDateInteger(endTime));
|
|
|
boolean currentDay = startDate == endDate && startDate == nowDate;
|
|
|
+ Map<String, String> lastTime = DateUtils.getStartEndTime(startTime, endTime);
|
|
|
+ long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
|
|
|
+ long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
|
|
|
JSONObject totalCost = currentDay
|
|
|
? materialStareMapper.getAdqTotalCost(startDate, endDate, nowHour, operatorUserIds)
|
|
|
: materialStareMapper.getAdqTotalCostDaily(startDate, endDate, operatorUserIds);
|
|
|
Double tCost = getJsonDouble(totalCost, "totalCost");
|
|
|
resultMap.put("sectionCost", tCost);
|
|
|
+ if (currentDay) {
|
|
|
+ JSONObject jsonObjectNow = materialStareMapper.getAdqTotalCost(nowDate, nowDate, nowHour, operatorUserIds);
|
|
|
+ double todayCost = getJsonDouble(jsonObjectNow, "totalCost");
|
|
|
+ resultMap.put("todayCost", todayCost);
|
|
|
+ JSONObject jsonObjectYesterday = materialStareMapper.getAdqTotalCost(time, time, nowHour, operatorUserIds);
|
|
|
+ double yesterdayCost = getJsonDouble(jsonObjectYesterday, "totalCost");
|
|
|
+ resultMap.put("compare", formatRate(todayCost, yesterdayCost, decimalFormat));
|
|
|
+ } else {
|
|
|
+ JSONObject periodSummary = materialStareMapper.getAdqPeriodCostSummary(startDate, endDate, lastTimeStart, lastTimeEnd, operatorUserIds);
|
|
|
+ double currentCost = getJsonDouble(periodSummary, "currentCost");
|
|
|
+ double lastCost = getJsonDouble(periodSummary, "lastCost");
|
|
|
+ resultMap.put("todayCost", currentCost);
|
|
|
+ resultMap.put("compare", formatRate(currentCost, lastCost, decimalFormat));
|
|
|
+ }
|
|
|
Double userAverageAccount = safeDivide(getJsonDouble(totalCost, "accountNum"), safeSize(operatorUserIds));
|
|
|
Double userAveragecost = safeDivide(tCost, safeSize(operatorUserIds));
|
|
|
DecimalFormat df = new DecimalFormat("#.000");
|
|
|
@@ -502,7 +539,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
resultMap.put("todayCost", todayCost);
|
|
|
resultMap.put("todayCompare", formatRate(todayCost, yesterdayCost, decimalFormat));
|
|
|
|
|
|
- boolean currentDayOnly = stratDate == endDate && endDate == nowDate;
|
|
|
+ boolean currentDayOnly = isCurrentDayOnly(stratDate, endDate, nowDate);
|
|
|
double timeCost;
|
|
|
double lastCost;
|
|
|
if (currentDayOnly) {
|
|
|
@@ -566,7 +603,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
resultMap.put("todayCost", todayCost);
|
|
|
resultMap.put("todayCompare", formatRate(todayCost, yesterdayCost, decimalFormat));
|
|
|
|
|
|
- boolean currentDayOnly = stratDate == endDate && endDate == nowDate;
|
|
|
+ boolean currentDayOnly = isCurrentDayOnly(stratDate, endDate, nowDate);
|
|
|
double timeCost;
|
|
|
double lastCost;
|
|
|
if (currentDayOnly) {
|
|
|
@@ -625,7 +662,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
resultMap.put("todayCost", todayCost);
|
|
|
resultMap.put("todayCompare", formatRate(todayCost, yesterdayCost, decimalFormat));
|
|
|
|
|
|
- boolean currentDayOnly = stratDate == endDate && endDate == nowDate;
|
|
|
+ boolean currentDayOnly = isCurrentDayOnly(stratDate, endDate, nowDate);
|
|
|
double timeCost;
|
|
|
double lastCost;
|
|
|
if (currentDayOnly) {
|
|
|
@@ -687,7 +724,6 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
|
|
|
|
|
|
long now = Long.valueOf(DateUtils.getDateInteger(DateUtils.getDate("yyyy-MM-dd")));
|
|
|
-
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
List<KuaiShouOperateVo> listOperate = loadOperatePageData(mediaType, startDate, entDate, now, operatorUserIds);
|
|
|
enrichOperateList(listOperate, mediaType, startDate, entDate, now, lastTimeStart, lastTimeEnd, decimalFormat);
|
|
|
@@ -767,6 +803,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
Set<String> operatorUserIds = getAffiliateId(userId);
|
|
|
long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
|
|
|
long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
|
|
|
+ boolean currentDayOnly = isCurrentDayOnly(startDate, entDate, now);
|
|
|
Map<String, String> lastTime = DateUtils.getStartEndTime(startTime, endTime);
|
|
|
long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
|
|
|
long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
|
|
|
@@ -779,7 +816,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
parameterMap.put("startEqually", DateUtils.getDateInteger(DateUtils.addDayParse(String.valueOf(DateUtils.getDateInteger(startTime)), -7)));
|
|
|
parameterMap.put("endEqually", DateUtils.getDateInteger(DateUtils.addDayParse(String.valueOf(DateUtils.getDateInteger(endTime)), -7)));
|
|
|
if ("1".equals(mediaType)) {
|
|
|
- if (startDate == now || entDate == now) {
|
|
|
+ if (currentDayOnly) {
|
|
|
parameterMap.put("tableName", "application.bytedance_advertiser_report_hourly_dw");
|
|
|
parameterMap.put("hour", DateUtils.getNowHour());
|
|
|
} else {
|
|
|
@@ -787,7 +824,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
parameterMap.remove("hour");
|
|
|
}
|
|
|
} else {
|
|
|
- if (startDate == now || entDate == now) {
|
|
|
+ if (currentDayOnly) {
|
|
|
parameterMap.put("tableName", "application.kuaishou_account_report_hourly_dw");
|
|
|
parameterMap.put("hour", DateUtils.getNowHour());
|
|
|
} else {
|
|
|
@@ -860,6 +897,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
//2022-02-15 ==>> 20220215
|
|
|
long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
|
|
|
long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
|
|
|
+ boolean currentDayOnly = isCurrentDayOnly(startDate, entDate, now);
|
|
|
|
|
|
//计算环比 时间值 上阶段时间 以及 两个日期之间的 间隔天数
|
|
|
Map<String, String> lastTime = DateUtils.getStartEndTime(startTime, endTime);
|
|
|
@@ -886,7 +924,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
//当天
|
|
|
int newUnitNumNow = 0;
|
|
|
int trustUnitNum = 0;
|
|
|
- if (startDate == now || entDate == now) {
|
|
|
+ if (currentDayOnly) {
|
|
|
|
|
|
//查询当天数据
|
|
|
|
|
|
@@ -967,7 +1005,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
//当天
|
|
|
int newUnitNumNow = 0;
|
|
|
int trustUnitNum = 0;
|
|
|
- if (startDate == now || entDate == now) {
|
|
|
+ if (currentDayOnly) {
|
|
|
//查询 当天有效 上新计划 上新组
|
|
|
JSONObject newEffect = materialStareMapper.getKuaiShouAccountNowBaseByUserId(null, projectInfo.getProjectId(), null, now, now);
|
|
|
newUnitNumNow = Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum");//组
|
|
|
@@ -1541,6 +1579,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
|
|
|
|
|
|
long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
|
|
|
+ boolean currentDayOnly = isCurrentDayOnly(startDate, entDate, nowDate);
|
|
|
|
|
|
//计算环比 时间值 上阶段时间 以及 两个日期之间的 间隔天数
|
|
|
Map<String, String> lastTime = DateUtils.getStartEndTime(startTime, endTime);
|
|
|
@@ -1599,7 +1638,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
Map<String, KuaiShouOperateVo> currentOperateMap = toOperateUserMap(loadOperateDataByMedia(mediaType, daysBetween, startDate, entDate, allActiveUserIds));
|
|
|
Map<String, KuaiShouOperateVo> yearOnYearOperateMap = toOperateUserMap(loadOperateDataByMedia(mediaType, daysBetween, lastTimeStart, lastTimeEnd, allActiveUserIds));
|
|
|
Map<String, JSONObject> historyBaseMap = loadUserBaseMapByMedia(mediaType, allActiveUserIds, startDate, entDate);
|
|
|
- Map<String, JSONObject> todayBaseMap = (startDate == nowDate || entDate == nowDate) ? loadTodayUserBaseMapByMedia(mediaType, allActiveUserIds, nowDate) : new HashMap<>();
|
|
|
+ Map<String, JSONObject> todayBaseMap = currentDayOnly ? loadTodayUserBaseMapByMedia(mediaType, allActiveUserIds, nowDate) : new HashMap<>();
|
|
|
for (KuaiShouOperateGroupVo groupVo : operationList) {
|
|
|
//下级员工
|
|
|
Set<String> allAffiliateUserIds = affiliateMap.computeIfAbsent(groupVo.getUserId(), this::getAffiliateId);
|
|
|
@@ -1678,6 +1717,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
|
|
|
long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
|
|
|
long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
|
|
|
+ boolean currentDayOnly = isCurrentDayOnly(startDate, entDate, nowDate);
|
|
|
//计算环比 时间值 上阶段时间 以及 两个日期之间的 间隔天数
|
|
|
Map<String, String> lastTime = DateUtils.getStartEndTime(startTime, endTime);
|
|
|
long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
|
|
|
@@ -1686,14 +1726,18 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
//查询用户角色
|
|
|
String roleCode = materialStareMapper.getRoleCodeByUserId(userId);
|
|
|
|
|
|
- //所有运营经理 1-头条 2-快手
|
|
|
+ //所有运营经理 1-头条 2-快手 16-腾讯
|
|
|
+ List<KuaiShouOperateGroupVo> allOperationManagerList;
|
|
|
String roleCodeName = "";
|
|
|
if (mediaType.equals("1")) {
|
|
|
roleCodeName = "touTiaoOperationManager";
|
|
|
+ allOperationManagerList = materialStareMapper.getOperationManagerUser(roleCodeName);
|
|
|
+ } else if (mediaType.equals("16")) {
|
|
|
+ allOperationManagerList = dashboardQuerySupport.getTencentOperationManagers();
|
|
|
} else {
|
|
|
roleCodeName = "kuaishouOperationManager";
|
|
|
+ allOperationManagerList = materialStareMapper.getOperationManagerUser(roleCodeName);
|
|
|
}
|
|
|
- List<KuaiShouOperateGroupVo> allOperationManagerList = materialStareMapper.getOperationManagerUser(roleCodeName);
|
|
|
List<String> allManagerList = allOperationManagerList.stream().map(KuaiShouOperateGroupVo::getUserId).collect(Collectors.toList());
|
|
|
|
|
|
List<KuaiShouOperateGroupVo> operationManagerList = new ArrayList<>();
|
|
|
@@ -1716,18 +1760,25 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
Result.successMsg("运营组列表数据查询成功。", null);
|
|
|
}
|
|
|
|
|
|
+ List<String> managerIds = operationManagerList.stream().map(KuaiShouOperateGroupVo::getUserId).collect(Collectors.toList());
|
|
|
+ Map<String, Set<String>> activeTeamMemberMap = mediaType.equals("16")
|
|
|
+ ? dashboardQuerySupport.getOperateTeamMembers(mediaType, managerIds, startDate, entDate)
|
|
|
+ : new HashMap<>();
|
|
|
+
|
|
|
for (KuaiShouOperateGroupVo groupVo : operationManagerList) {
|
|
|
//下级员工
|
|
|
//Set<String> operatorUserIds = getAffiliateId(groupVo.getUserId());
|
|
|
|
|
|
//运营经理下的下级员工
|
|
|
- Set<String> operatorUserIds = materialStareMapper.getAllOperatorsByLearderId(groupVo.getUserId());
|
|
|
+ Set<String> operatorUserIds = mediaType.equals("16")
|
|
|
+ ? activeTeamMemberMap.get(groupVo.getUserId())
|
|
|
+ : materialStareMapper.getAllOperatorsByLearderId(groupVo.getUserId());
|
|
|
|
|
|
|
|
|
//有消耗的账户
|
|
|
if (mediaType.equals("1")) {
|
|
|
operatorUserIds = materialStareMapper.getBytedanceAllOperators(null, DateUtils.getDateInteger(startTime).longValue(), DateUtils.getDateInteger(endTime).longValue(), operatorUserIds);
|
|
|
- } else {
|
|
|
+ } else if (mediaType.equals("2")) {
|
|
|
operatorUserIds = materialStareMapper.getKuaiShouAllOperators(null, DateUtils.getDateInteger(startTime).longValue(), DateUtils.getDateInteger(endTime).longValue(), operatorUserIds);
|
|
|
}
|
|
|
|
|
|
@@ -1744,15 +1795,21 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
List<KuaiShouOperateVo> listOperate = new ArrayList<>();
|
|
|
|
|
|
if (mediaType.equals("1")) {
|
|
|
- if (daysBetween <= 1) {
|
|
|
+ if (currentDayOnly) {
|
|
|
//时报
|
|
|
listOperate = materialStareMapper.getBytedanceOperateInfoHourly(startDate, entDate, getCurrentHourSafe(), operatorUserIds);
|
|
|
} else {
|
|
|
|
|
|
listOperate = materialStareMapper.getBytedanceOperateInfo(startDate, entDate, operatorUserIds);
|
|
|
}
|
|
|
+ } else if (mediaType.equals("16")) {
|
|
|
+ if (currentDayOnly) {
|
|
|
+ listOperate = materialStareMapper.getAdqOperateInfoHourly(startDate, entDate, getCurrentHourSafe(), operatorUserIds);
|
|
|
+ } else {
|
|
|
+ listOperate = materialStareMapper.getAdqOperateInfo(startDate, entDate, operatorUserIds);
|
|
|
+ }
|
|
|
} else {
|
|
|
- if (daysBetween <= 1) {
|
|
|
+ if (currentDayOnly) {
|
|
|
listOperate = materialStareMapper.getKuaiShouOperateInfoHourly(startDate, entDate, getCurrentHourSafe(), operatorUserIds);
|
|
|
} else {
|
|
|
listOperate = materialStareMapper.getKuaiShouOperateInfo(startDate, entDate, operatorUserIds);
|
|
|
@@ -1784,6 +1841,8 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
List<KuaiShouOperateVo> yearOnYearInfo = new ArrayList<>();
|
|
|
if (mediaType.equals("1")) {
|
|
|
yearOnYearInfo = materialStareMapper.getBytedanceOperateInfo(lastTimeStart, lastTimeEnd, operatorUserIds);
|
|
|
+ } else if (mediaType.equals("16")) {
|
|
|
+ yearOnYearInfo = materialStareMapper.getAdqOperateInfo(lastTimeStart, lastTimeEnd, operatorUserIds);
|
|
|
} else {
|
|
|
yearOnYearInfo = materialStareMapper.getKuaiShouOperateInfo(lastTimeStart, lastTimeEnd, operatorUserIds);
|
|
|
}
|
|
|
@@ -1798,7 +1857,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
|
|
|
//当天
|
|
|
int newUnitNumNow = 0;
|
|
|
- if (startDate == nowDate || entDate == nowDate) {
|
|
|
+ if (currentDayOnly) {
|
|
|
JSONObject newEffect = new JSONObject();
|
|
|
if (mediaType.equals("1")) {
|
|
|
//查询 当天有效 上新计划 上新组
|
|
|
@@ -1806,7 +1865,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
Integer unitNum = Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum");//组
|
|
|
Integer unitNum1 = Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum2");//组
|
|
|
newUnitNumNow = Math.addExact(unitNum, unitNum1);
|
|
|
- } else {
|
|
|
+ } else if (mediaType.equals("2")) {
|
|
|
//查询 当天有效 上新计划 上新组
|
|
|
newEffect = materialStareMapper.getKuaiShouAccountNowBaseByUserId(operatorUserIds, null, null, nowDate, nowDate);
|
|
|
newUnitNumNow = Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum");//组
|
|
|
@@ -1819,7 +1878,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
Integer unitNum1 = Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum2");//组
|
|
|
newUnitNumNow = Math.addExact(unitNum, unitNum1);
|
|
|
groupVo.setNewProjectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newCpdProjectNum"));
|
|
|
- } else {
|
|
|
+ } else if (mediaType.equals("2")) {
|
|
|
//查询 历史上新组
|
|
|
JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(operatorUserIds, null, null, startDate, entDate);
|
|
|
newUnitNumNow = Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum") + newUnitNumNow;
|
|
|
@@ -1866,8 +1925,9 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
parameterMap.put("userIds", operatorUserIds);
|
|
|
parameterMap.put("startEqually", DateUtils.getDateInteger(DateUtils.addDayParse(String.valueOf(DateUtils.getDateInteger(startTime)), -7)));
|
|
|
parameterMap.put("endEqually", DateUtils.getDateInteger(DateUtils.addDayParse(String.valueOf(DateUtils.getDateInteger(endTime)), -7)));
|
|
|
+ boolean currentDayOnly = isCurrentDayOnly(startDate, entDate, now);
|
|
|
if (mediaType.equals("1")) {
|
|
|
- if (startDate == now || entDate == now) {
|
|
|
+ if (currentDayOnly) {
|
|
|
parameterMap.put("tableName", "application.bytedance_advertiser_report_hourly_dw");
|
|
|
parameterMap.put("hour", DateUtils.getNowHour());
|
|
|
} else {
|
|
|
@@ -1876,7 +1936,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
}
|
|
|
}
|
|
|
if (mediaType.equals("2")) {
|
|
|
- if (startDate == now || entDate == now) {
|
|
|
+ if (currentDayOnly) {
|
|
|
parameterMap.put("tableName", "application.kuaishou_account_report_hourly_dw");
|
|
|
parameterMap.put("hour", DateUtils.getNowHour());
|
|
|
} else {
|
|
|
@@ -2152,19 +2212,20 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
}
|
|
|
|
|
|
private List<KuaiShouOperateVo> loadOperatePageData(String mediaType, long startDate, long endDate, long nowDate, Set<String> userIds) {
|
|
|
+ boolean currentDayOnly = isCurrentDayOnly(startDate, endDate, nowDate);
|
|
|
if ("1".equals(mediaType)) {
|
|
|
- if (startDate == nowDate) {
|
|
|
+ if (currentDayOnly) {
|
|
|
return materialStareMapper.getBytedanceOperateInfoHourly(nowDate, nowDate, getCurrentHourSafe(), userIds);
|
|
|
}
|
|
|
return materialStareMapper.getBytedanceOperateInfo(startDate, endDate, userIds);
|
|
|
}
|
|
|
if ("16".equals(mediaType)) {
|
|
|
- if (startDate == nowDate) {
|
|
|
+ if (currentDayOnly) {
|
|
|
return materialStareMapper.getAdqOperateInfoHourly(nowDate, nowDate, getCurrentHourSafe(), userIds);
|
|
|
}
|
|
|
return materialStareMapper.getAdqOperateInfo(startDate, endDate, userIds);
|
|
|
}
|
|
|
- if (startDate == nowDate) {
|
|
|
+ if (currentDayOnly) {
|
|
|
return materialStareMapper.getKuaiShouOperateInfoHourly(nowDate, nowDate, getCurrentHourSafe(), userIds);
|
|
|
}
|
|
|
return materialStareMapper.getKuaiShouOperateInfo(startDate, endDate, userIds);
|
|
|
@@ -2181,7 +2242,8 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
.collect(Collectors.toSet());
|
|
|
Map<String, KuaiShouOperateVo> yearOnYearMap = toOperateUserMap(loadOperatePageData(mediaType, lastTimeStart, lastTimeEnd, nowDate, userIds));
|
|
|
Map<String, JSONObject> historyBaseMap = loadUserBaseMapByMedia(mediaType, userIds, startDate, endDate);
|
|
|
- Map<String, JSONObject> todayBaseMap = (startDate == nowDate || endDate == nowDate)
|
|
|
+ boolean currentDayOnly = isCurrentDayOnly(startDate, endDate, nowDate);
|
|
|
+ Map<String, JSONObject> todayBaseMap = currentDayOnly
|
|
|
? loadTodayUserBaseMapByMedia(mediaType, userIds, nowDate)
|
|
|
: new HashMap<>();
|
|
|
for (KuaiShouOperateVo operate : listOperate) {
|
|
|
@@ -2228,24 +2290,30 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
if (userIds == null || userIds.isEmpty()) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
+ long nowDate = DateUtils.getDateInteger(DateUtils.getDate("yyyy-MM-dd"));
|
|
|
+ boolean currentDayOnly = isCurrentDayOnly(startDate, endDate, nowDate);
|
|
|
if ("1".equals(mediaType)) {
|
|
|
- if (daysBetween != null && daysBetween <= 1) {
|
|
|
+ if (currentDayOnly) {
|
|
|
return materialStareMapper.getBytedanceOperateInfoHourly(startDate, endDate, getCurrentHourSafe(), userIds);
|
|
|
}
|
|
|
return materialStareMapper.getBytedanceOperateInfo(startDate, endDate, userIds);
|
|
|
}
|
|
|
if ("16".equals(mediaType)) {
|
|
|
- if (daysBetween != null && daysBetween <= 1) {
|
|
|
+ if (currentDayOnly) {
|
|
|
return materialStareMapper.getAdqOperateInfoHourly(startDate, endDate, getCurrentHourSafe(), userIds);
|
|
|
}
|
|
|
return materialStareMapper.getAdqOperateInfo(startDate, endDate, userIds);
|
|
|
}
|
|
|
- if (daysBetween != null && daysBetween <= 1) {
|
|
|
+ if (currentDayOnly) {
|
|
|
return materialStareMapper.getKuaiShouOperateInfoHourly(startDate, endDate, getCurrentHourSafe(), userIds);
|
|
|
}
|
|
|
return materialStareMapper.getKuaiShouOperateInfo(startDate, endDate, userIds);
|
|
|
}
|
|
|
|
|
|
+ private boolean isCurrentDayOnly(long startDate, long endDate, long nowDate) {
|
|
|
+ return startDate == endDate && startDate == nowDate;
|
|
|
+ }
|
|
|
+
|
|
|
private Map<String, KuaiShouOperateVo> toOperateUserMap(List<KuaiShouOperateVo> rows) {
|
|
|
Map<String, KuaiShouOperateVo> result = new LinkedHashMap<>();
|
|
|
if (rows == null || rows.isEmpty()) {
|