|
@@ -0,0 +1,114 @@
|
|
|
|
+package cn.com.ctop.toutiao.modules.report.controller;
|
|
|
|
+
|
|
|
|
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceNewPlanReportService;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Created by JQ.bi on 2020.11.4
|
|
|
|
+ */
|
|
|
|
+@Slf4j
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/ctop/bytedance/newPlan")
|
|
|
|
+public class BytedanceNewPlanReportCtrl {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ IBytedanceNewPlanReportService newPlanReportService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新建计划、有效计划 chart数据
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/report/data")
|
|
|
|
+ public Result<Map<String, Object>> getNewPlanChartReport(@RequestBody JSONObject requestBody) {
|
|
|
|
+ Result<Map<String, Object>> resultBody = new Result<>();
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ JSONArray accountIds = requestBody.getJSONArray("accountIds");
|
|
|
|
+ //TODO 没有维护头条事业部负责人角色,增加判断
|
|
|
|
+ String userId = requestBody.getString("userId");
|
|
|
|
+ if (userId.equals("e9ca23d68d884d4ebb19d07889727dae")) {
|
|
|
|
+ accountIds = newPlanReportService.getAccountIdsByMedia();
|
|
|
|
+ } else {
|
|
|
|
+ if (!userId.isEmpty()) {
|
|
|
|
+ accountIds = newPlanReportService.getAccountIdsByUserId(userId);
|
|
|
|
+ }
|
|
|
|
+ if (accountIds.isEmpty()) {
|
|
|
|
+ return resultBody;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String startDate = requestBody.getString("startDate");
|
|
|
|
+ String endDate = requestBody.getString("endDate");
|
|
|
|
+ String target = requestBody.getString("target");
|
|
|
|
+ String order = requestBody.getString("order");
|
|
|
|
+ try {
|
|
|
|
+ JSONObject sumData = newPlanReportService.getSumNewPlanBy(accountIds, startDate, endDate);
|
|
|
|
+ List<JSONObject> chartData = newPlanReportService.getBytedanceNewPlanGroupByStatDate(accountIds, startDate, endDate);
|
|
|
|
+ List<JSONObject> listData = newPlanReportService.getBytedanceNewPlanGroupByAccount(accountIds, startDate, endDate, target, order);
|
|
|
|
+ result.put("sumData", sumData);
|
|
|
|
+ result.put("chartData", chartData);
|
|
|
|
+ result.put("listData", listData);
|
|
|
|
+ resultBody.setResult(result);
|
|
|
|
+ resultBody.setSuccess(true);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ resultBody.setSuccess(false);
|
|
|
|
+ }
|
|
|
|
+ return resultBody;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询素材报表表格数据
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/report/list")
|
|
|
|
+ public Result<List<JSONObject>> getListReport(@RequestBody JSONObject requestBody) {
|
|
|
|
+ Result<List<JSONObject>> result = new Result<>();
|
|
|
|
+
|
|
|
|
+ JSONArray accountIds = requestBody.getJSONArray("accountIds");
|
|
|
|
+ if (accountIds.isEmpty()) {
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ String startDate = requestBody.getString("startDate");
|
|
|
|
+ String endDate = requestBody.getString("endDate");
|
|
|
|
+ String target = requestBody.getString("target");
|
|
|
|
+ String order = requestBody.getString("order");
|
|
|
|
+ try {
|
|
|
|
+ List<JSONObject> listData = newPlanReportService.getBytedanceNewPlanGroupByAccount(accountIds, startDate, endDate, target, order);
|
|
|
|
+ result.setResult(listData);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询所有的快手运营
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/report/AllOperator")
|
|
|
|
+ public Result<List<JSONObject>> getAllOperator() {
|
|
|
|
+ Result<List<JSONObject>> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ List<JSONObject> listData = newPlanReportService.getAllOperator();
|
|
|
|
+ result.setResult(listData);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|