|
@@ -3,7 +3,6 @@ package org.jeecg.ctop.material.service.impl;
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
@@ -26,7 +25,6 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.lang.reflect.Type;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.text.DecimalFormat;
|
|
@@ -51,7 +49,6 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
@Resource
|
|
|
MaterialStareMapper materialStareMapper;
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* @param mediaType 媒体类型 1-头条 2-快手
|
|
|
* @param type 查询类型 1-汇总 2-运营个人
|
|
@@ -202,9 +199,46 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
add(userId);
|
|
|
}};
|
|
|
|
|
|
+
|
|
|
+ //查询用户角色
|
|
|
+ String roleCode = materialStareMapper.getRoleCodeByUserId(userId);
|
|
|
+ //判断是否运营相关角色,并获取媒体类型
|
|
|
+ if (!Check.isNull(roleCode)) {
|
|
|
+ if ("touTiaoOperationManager".equals(roleCode)) {
|
|
|
+ mediaType = "1";
|
|
|
+ } else if ("kuaishouOperationManager".equals(roleCode)) {
|
|
|
+ mediaType = "2";
|
|
|
+ } else if (roleCode.toLowerCase().contains("perat")) {
|
|
|
+ String leaderRoleCode = materialStareMapper.getOperatLeaderRole(userId);
|
|
|
+ if (!Check.isNull(leaderRoleCode)) {
|
|
|
+ if ("touTiaoOperationManager".equals(leaderRoleCode)) {
|
|
|
+ mediaType = "1";
|
|
|
+ } else if ("kuaishouOperationManager".equals(leaderRoleCode)) {
|
|
|
+ mediaType = "2";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return Result.successMsg("非运营相关角色,不显示数据", "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//头条
|
|
|
if (StringUtils.equals(mediaType, "1")) {
|
|
|
- return Result.successMsg("暂无头条数据。", null);
|
|
|
+ //查询一天数据时 查询时报
|
|
|
+ if (stratDate == endDate) {
|
|
|
+ Map resultMap = new HashMap<>();
|
|
|
+ //时报
|
|
|
+ List<Map> todayList = materialStareMapper.getBytedanceCostHourlyByUserIdList(stratDate, endDate, userSet);
|
|
|
+ long time = DateUtils.getDateInteger(DateUtils.addDayParse(Long.toString(endDate), -1));
|
|
|
+ List<Map> yesterdayList = materialStareMapper.getBytedanceCostHourlyByUserIdList(time, time, userSet);
|
|
|
+ resultMap.put("todayList", todayList);
|
|
|
+ resultMap.put("yesterdayList", yesterdayList);
|
|
|
+ return Result.successMsg("查询运营个人-时报-汇总。", resultMap);
|
|
|
+ }
|
|
|
+ //多天 数据
|
|
|
+ // 日报
|
|
|
+ List<Map> dailyList = materialStareMapper.getBytedanceCostDailyByUserIdList(stratDate, endDate, userSet);
|
|
|
+ return Result.successMsg("查询运营个人-日报-汇总成功。", dailyList);
|
|
|
}
|
|
|
//快手
|
|
|
if (StringUtils.equals(mediaType, "2")) {
|
|
@@ -342,6 +376,100 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Result kuaiShouOperateDateTotalPersonal(String mediaType, String startTime, String endTime, String userId) {
|
|
|
+ if ("1".equals(mediaType)) {
|
|
|
+ return bytedanceOperateDateTotalPersonal(startTime, endTime, userId);
|
|
|
+ } else {
|
|
|
+ Map resultMap = new HashMap();
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0.00%");
|
|
|
+
|
|
|
+ long stratDate = DateUtils.getDateInteger(startTime);
|
|
|
+ long endDate = DateUtils.getDateInteger(endTime);
|
|
|
+
|
|
|
+ try {
|
|
|
+ Set<String> userSet = new HashSet<String>() {{
|
|
|
+ add(userId);
|
|
|
+ }};
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
+ // ==>> 20220202
|
|
|
+ String now = sdf.format(new Date());
|
|
|
+ long nowDate = Long.valueOf(now);
|
|
|
+ int nowHour = DateUtils.getNowHour();
|
|
|
+ //昨天时间
|
|
|
+ long time = DateUtils.getDateInteger(DateUtils.addDayParse(now, -1));
|
|
|
+
|
|
|
+ //当天总消耗
|
|
|
+ JSONObject jsonObjectNow = materialStareMapper.getKuaiShouTotalCost(nowDate, nowDate, nowHour, userSet);
|
|
|
+ resultMap.put("todayCost", Check.isNull(jsonObjectNow.getString("totalCost")) ? "0" : jsonObjectNow.getString("totalCost"));
|
|
|
+ //昨天同时段总消耗
|
|
|
+ JSONObject jsonObjectYesterday = materialStareMapper.getKuaiShouTotalCost(time, time, nowHour, userSet);
|
|
|
+
|
|
|
+ //今日同比 = (今天总消耗 - 昨天总消耗 ) / 昨天总消耗
|
|
|
+ Double d = new Double("0");
|
|
|
+ if (!Check.isNull(jsonObjectNow.getString("totalCost")) && !Check.isNull(jsonObjectYesterday.getString("totalCost"))) {
|
|
|
+ d = (Double.valueOf(jsonObjectNow.getString("totalCost"))
|
|
|
+ - Double.valueOf(jsonObjectYesterday.getString("totalCost")))
|
|
|
+ / Double.valueOf(jsonObjectYesterday.getString("totalCost"));
|
|
|
+ }
|
|
|
+ resultMap.put("todayCompare", decimalFormat.format(d));
|
|
|
+
|
|
|
+ //所选时段消耗
|
|
|
+ JSONObject timeNowCost = materialStareMapper.getKuaiShouTotalCostDaily(stratDate, endDate, userSet);
|
|
|
+ resultMap.put("timeCost", Check.isNull(timeNowCost.getString("totalCost")) ? "0" : timeNowCost.getString("totalCost"));
|
|
|
+ //上阶段时间
|
|
|
+ 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 timeLastCost = materialStareMapper.getKuaiShouTotalCostDaily(lastTimeStart, lastTimeEnd, userSet);
|
|
|
+ //环比 = (当前总消耗 - 上阶段总消耗 ) / 上阶段总消耗
|
|
|
+ Double timeCompare = new Double("0");
|
|
|
+ if (!Check.isNull(timeNowCost.getString("totalCost")) && !Check.isNull(timeLastCost.getString("totalCost"))) {
|
|
|
+ timeCompare = (Double.valueOf(timeNowCost.getString("totalCost")) - Double.valueOf(timeLastCost.getString("totalCost"))) / Double.valueOf(timeLastCost.getString("totalCost"));
|
|
|
+ }
|
|
|
+
|
|
|
+ resultMap.put("timeCompare", decimalFormat.format(timeCompare));
|
|
|
+
|
|
|
+ //当前月份的框返 和 激励
|
|
|
+ // 当前月份第一天
|
|
|
+ long monthFirstDay = Long.valueOf(DateUtils.getFirstDayByMonth());
|
|
|
+ //框返 激励
|
|
|
+ JSONObject nowMonthCost = materialStareMapper.getKuaiShouAccountCharged(monthFirstDay, nowDate, userSet);
|
|
|
+
|
|
|
+
|
|
|
+ resultMap.put("directCharged", Check.isNull(nowMonthCost) ? "0" : nowMonthCost.getString("directCharged"));//框返
|
|
|
+ resultMap.put("contractCharged", Check.isNull(nowMonthCost) ? "0" : nowMonthCost.getString("contractCharged"));//激励
|
|
|
+
|
|
|
+ //当前月消耗
|
|
|
+ JSONObject monthCost = materialStareMapper.getKuaiShouAccountCostMonth(userId, monthFirstDay, nowDate);
|
|
|
+ resultMap.put("monthCost", Check.isNull(monthCost) ? "0" : monthCost.getString("cost"));
|
|
|
+
|
|
|
+ //用户
|
|
|
+ JSONObject userName = materialStareMapper.getKuaiShouUserByUserId(userId);
|
|
|
+ resultMap.put("userName", Check.isNull(userName) ? "-" : userName.getString("userName"));
|
|
|
+
|
|
|
+
|
|
|
+ //公司 组内排名
|
|
|
+ //用户所属公司id
|
|
|
+ String companyId = materialStareMapper.getUserCompanyByUserId(userId);
|
|
|
+ //组内排名
|
|
|
+ List<JSONObject> groupRankList = materialStareMapper.getKuaiShouPersonalGroupRank(monthFirstDay, nowDate, companyId);
|
|
|
+ resultMap.put("userRankTotalNum", groupRankList.size());//排名总数
|
|
|
+ for (JSONObject group : groupRankList) {
|
|
|
+ if (group.getString("user_id").equals(userId)) {
|
|
|
+ resultMap.put("userIdRank", group.getString("serialNumber"));//排名
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return Result.successMsg("查询运营个人数据成功", resultMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Result bytedanceOperateDateTotalPersonal(String startTime, String endTime, String userId) {
|
|
|
Map resultMap = new HashMap();
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("0.00%");
|
|
|
|
|
@@ -362,10 +490,10 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
long time = DateUtils.getDateInteger(DateUtils.addDayParse(now, -1));
|
|
|
|
|
|
//当天总消耗
|
|
|
- JSONObject jsonObjectNow = materialStareMapper.getKuaiShouTotalCost(nowDate, nowDate, nowHour, userSet);
|
|
|
- resultMap.put("todayCost", Check.isNull(jsonObjectNow.getString("totalCost")) ? "0" : jsonObjectNow.getString("totalCost"));
|
|
|
+ JSONObject jsonObjectNow = materialStareMapper.getBytedanceTotalCost(nowDate, nowDate, nowHour, userSet);
|
|
|
+ resultMap.put("todayCost", jsonObjectNow.getString("totalCost"));
|
|
|
//昨天同时段总消耗
|
|
|
- JSONObject jsonObjectYesterday = materialStareMapper.getKuaiShouTotalCost(time, time, nowHour, userSet);
|
|
|
+ JSONObject jsonObjectYesterday = materialStareMapper.getBytedanceTotalCost(time, time, nowHour, userSet);
|
|
|
|
|
|
//今日同比 = (今天总消耗 - 昨天总消耗 ) / 昨天总消耗
|
|
|
Double d = new Double("0");
|
|
@@ -377,7 +505,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
resultMap.put("todayCompare", decimalFormat.format(d));
|
|
|
|
|
|
//所选时段消耗
|
|
|
- JSONObject timeNowCost = materialStareMapper.getKuaiShouTotalCostDaily(stratDate, endDate, userSet);
|
|
|
+ JSONObject timeNowCost = materialStareMapper.getBytedanceTotalCostDaily(stratDate, endDate, userSet);
|
|
|
resultMap.put("timeCost", Check.isNull(timeNowCost.getString("totalCost")) ? "0" : timeNowCost.getString("totalCost"));
|
|
|
//上阶段时间
|
|
|
Map<String, String> lastTime = DateUtils.getStartEndTime(startTime, endTime);
|
|
@@ -385,27 +513,20 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
|
|
|
|
|
|
//上阶段消耗
|
|
|
- JSONObject timeLastCost = materialStareMapper.getKuaiShouTotalCostDaily(lastTimeStart, lastTimeEnd, userSet);
|
|
|
+ JSONObject timeLastCost = materialStareMapper.getBytedanceTotalCostDaily(lastTimeStart, lastTimeEnd, userSet);
|
|
|
//环比 = (当前总消耗 - 上阶段总消耗 ) / 上阶段总消耗
|
|
|
Double timeCompare = new Double("0");
|
|
|
if (!Check.isNull(timeNowCost.getString("totalCost")) && !Check.isNull(timeLastCost.getString("totalCost"))) {
|
|
|
timeCompare = (Double.valueOf(timeNowCost.getString("totalCost")) - Double.valueOf(timeLastCost.getString("totalCost"))) / Double.valueOf(timeLastCost.getString("totalCost"));
|
|
|
}
|
|
|
-
|
|
|
resultMap.put("timeCompare", decimalFormat.format(timeCompare));
|
|
|
|
|
|
//当前月份的框返 和 激励
|
|
|
// 当前月份第一天
|
|
|
long monthFirstDay = Long.valueOf(DateUtils.getFirstDayByMonth());
|
|
|
- //框返 激励
|
|
|
- JSONObject nowMonthCost = materialStareMapper.getKuaiShouAccountCharged(monthFirstDay, nowDate, userSet);
|
|
|
-
|
|
|
-
|
|
|
- resultMap.put("directCharged", Check.isNull(nowMonthCost) ? "0" : nowMonthCost.getString("directCharged"));//框返
|
|
|
- resultMap.put("contractCharged", Check.isNull(nowMonthCost) ? "0" : nowMonthCost.getString("contractCharged"));//激励
|
|
|
|
|
|
//当前月消耗
|
|
|
- JSONObject monthCost = materialStareMapper.getKuaiShouAccountCostMonth(userId, monthFirstDay, nowDate);
|
|
|
+ JSONObject monthCost = materialStareMapper.getBytedanceAccountCostMonth(userId, monthFirstDay, nowDate);
|
|
|
resultMap.put("monthCost", Check.isNull(monthCost) ? "0" : monthCost.getString("cost"));
|
|
|
|
|
|
//用户
|
|
@@ -417,14 +538,13 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
//用户所属公司id
|
|
|
String companyId = materialStareMapper.getUserCompanyByUserId(userId);
|
|
|
//组内排名
|
|
|
- List<JSONObject> groupRankList = materialStareMapper.getKuaiShouPersonalGroupRank(monthFirstDay, nowDate, companyId);
|
|
|
+ List<JSONObject> groupRankList = materialStareMapper.getBytedancePersonalGroupRank(monthFirstDay, nowDate, companyId);
|
|
|
resultMap.put("userRankTotalNum", groupRankList.size());//排名总数
|
|
|
for (JSONObject group : groupRankList) {
|
|
|
if (group.getString("user_id").equals(userId)) {
|
|
|
resultMap.put("userIdRank", group.getString("serialNumber"));//排名
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|