Explorar el Código

新上监控获取运营列表接口修改

zhouzeyu@c-top.com.cn hace 3 años
padre
commit
8997e0614d

+ 18 - 8
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewGroupReportCtrl.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.report.controller;
 
+import cn.com.ctop.common.module.service.ISysRoleExtService;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.kuaishou.modules.report.service.IKsNewGroupReportService;
@@ -8,14 +9,13 @@ import cn.com.ctop.kuaishou.modules.report.service.NewMonitorService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.annotations.Param;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
 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 org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -42,6 +42,9 @@ public class KsNewGroupReportCtrl {
     @Autowired
     NewMonitorService newMonitorService;
 
+    @Resource
+    private ISysRoleExtService sysRoleService;
+
     /**
      * 新建计划、有效计划 chart数据
      */
@@ -157,14 +160,21 @@ public class KsNewGroupReportCtrl {
             log.error(e.getMessage());
         }
     }
-    /**
+    /*
      * 查询所有的快手运营
      */
-    @PostMapping("/report/AllOperator")
-    public Result<List<JSONObject>> getAllOperator() {
+    @GetMapping("/report/AllOperator")
+    public Result<List<JSONObject>> getAllOperator(@Param("userId")String userId,@Param("userName")String userName) {
         Result<List<JSONObject>> result = new Result<>();
+        List<JSONObject> listData=new ArrayList<>();
         try {
-            List<JSONObject> listData = newPlanReportService.getAllOperator();
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            if (roleCode != null && roleCode.equals("admin")) {
+                listData = newPlanReportService.getAllOperator();
+            }else {
+                listData=newMonitorService.getOperator(userId,userName);
+            }
+
             result.setResult(listData);
             result.setSuccess(true);
         } catch (Exception e) {

+ 21 - 18
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/NewMonitorMapper.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
+import cn.com.ctop.kuaishou.modules.report.entity.NewMonitorInfo;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Mapper;
@@ -14,39 +15,41 @@ public interface NewMonitorMapper {
 
     List<Long> getAllAccountId();
 
-    List<Map> getKuaiShouGroup(@Param("date")String date,@Param("accountId")String accountId);
+    List<Map> getKuaiShouGroup(@Param("date") String date, @Param("accountId") String accountId);
 
-    List<Map> getKuaiShouCampaign(@Param("date")String date,@Param("accountId")String accountId);
+    List<Map> getKuaiShouCampaign(@Param("date") String date, @Param("accountId") String accountId);
 
-    List<Map> getTouTiaoCampaign(@Param("date")String date,@Param("accountId")String accountId);
+    List<Map> getTouTiaoCampaign(@Param("date") String date, @Param("accountId") String accountId);
 
-    BigDecimal getGroupCharge(@Param("unitId")String unitId, @Param("afterDate")String afterDate);
+    BigDecimal getGroupCharge(@Param("unitId") String unitId, @Param("afterDate") String afterDate);
 
-    BigDecimal getCampaignCharge(@Param("campaignId")String campaignId,@Param("afterDate")String afterDate);
+    BigDecimal getCampaignCharge(@Param("campaignId") String campaignId, @Param("afterDate") String afterDate);
 
-    BigDecimal getCampaignChargeTouTiao(@Param("campaignId")String campaignId,@Param("afterDate")String afterDate);
+    BigDecimal getCampaignChargeTouTiao(@Param("campaignId") String campaignId, @Param("afterDate") String afterDate);
 
-    void saveMonitorGroup(@Param("accountId")String accountId,@Param("accountName")String accountName,@Param("operatingName")String operatingName,@Param("unitId")String unitId,@Param("createTime")String createTime,@Param("projectType")String projectType,@Param("effective")String effective);
+    void saveMonitorGroup(@Param("accountId") String accountId, @Param("accountName") String accountName, @Param("operatingName") String operatingName, @Param("unitId") String unitId, @Param("createTime") String createTime, @Param("projectType") String projectType, @Param("effective") String effective);
 
-    void saveMonitorCampaign(@Param("accountId")String accountId,@Param("accountName")String accountName,@Param("operatingName")String operatingName,@Param("campaignId")String campaignId,@Param("createTime")String createTime,@Param("projectType")String projectType,@Param("effective")String effective);
+    void saveMonitorCampaign(@Param("accountId") String accountId, @Param("accountName") String accountName, @Param("operatingName") String operatingName, @Param("campaignId") String campaignId, @Param("createTime") String createTime, @Param("projectType") String projectType, @Param("effective") String effective);
 
-    String  getMonitorGroupByUnitId(@Param("unitId")String unitId);
+    String getMonitorGroupByUnitId(@Param("unitId") String unitId);
 
-    String  getMonitorPlanByCampaignId(@Param("campaignId")String campaignId);
+    String getMonitorPlanByCampaignId(@Param("campaignId") String campaignId);
 
-    void  updateMonitorGroupByUnitId(@Param("unitId")String unitId,@Param("effective")String effective);
+    void updateMonitorGroupByUnitId(@Param("unitId") String unitId, @Param("effective") String effective);
 
-    void  updateMonitorPlanByCampaignId(@Param("campaignId")String campaignId,@Param("effective")String effective);
+    void updateMonitorPlanByCampaignId(@Param("campaignId") String campaignId, @Param("effective") String effective);
 
-    List<JSONObject> getKuaiShouGroupMessage(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate);
+    List<JSONObject> getKuaiShouGroupMessage(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
-    JSONObject getKuaiShouGroupSum(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate);
+    JSONObject getKuaiShouGroupSum(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
-    List<JSONObject> getKuaiShouGroupMessageGroup(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate,@Param("group")String group);
+    List<JSONObject> getKuaiShouGroupMessageGroup(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("group") String group);
 
-    List<JSONObject> getPlanMessage(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate,@Param("project")String project);
+    List<JSONObject> getPlanMessage(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("project") String project);
 
-    JSONObject getPlanSum(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate,@Param("project")String project);
+    JSONObject getPlanSum(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("project") String project);
 
-    List<JSONObject> getPlanMessageGroup(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate,@Param("group")String group,@Param("project")String project);
+    List<JSONObject> getPlanMessageGroup(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("group") String group, @Param("project") String project);
+
+    List<NewMonitorInfo> getOperator(@Param("userId") String userId);
 }

+ 18 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/NewMonitorMapper.xml

@@ -1,6 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.NewMonitorMapper">
+    <resultMap id="BaseResultMap" type="cn.com.ctop.kuaishou.modules.report.entity.NewMonitorInfo">
+        <id  column="id"  property="user_id" />
+        <result column="realname" property="user_name"/>
+        <result column="leader_id" property="parent_id"/>
+        <collection property="children" ofType="cn.com.ctop.kuaishou.modules.report.entity.NewMonitorInfo"
+                    select="cn.com.ctop.kuaishou.modules.report.mapper.NewMonitorMapper.getOperator" column="id">
+        </collection>
+    </resultMap>
+
+    <select id="getOperator" resultMap="BaseResultMap"  parameterType="String">
+        SELECT id,realname,leader_id
+        FROM sys_user
+        WHERE leader_id=#{userId};
+    </select>
 
     <select id="getAllAccountId" resultType="Long">
         SELECT DISTINCT t.account_id  as 'accountId' from ctop_user_allocation t
@@ -75,11 +89,11 @@
         (#{accountId},#{accountName},#{operatingName},#{campaignId},#{createTime},#{projectType},#{effective})
     </insert>
 
-    <select id="getMonitorGroupByUnitId" resultType="int" >
+    <select id="getMonitorGroupByUnitId" resultType="String" >
         select  t.effective from ctop_new_monitor_group t where t.unit_id=#{unitId}
     </select>
 
-    <select id="getMonitorPlanByCampaignId" resultType="int" >
+    <select id="getMonitorPlanByCampaignId" resultType="String" >
         select  t.effective from ctop_new_monitor_campaign t where t.campaign_id=#{campaignId}
     </select>
 
@@ -164,4 +178,6 @@
         </choose>
     </select>
 
+
+
 </mapper>

+ 6 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/NewMonitorService.java

@@ -9,15 +9,17 @@ import java.util.List;
 public interface NewMonitorService {
     public Result synchronousMonitor(String type);
 
-    List<JSONObject> getKuaiShouGroupMessage(JSONArray array, String startDate, String endDate,String target);
+    List<JSONObject> getKuaiShouGroupMessage(JSONArray array, String startDate, String endDate, String target);
 
     JSONObject getKuaiShouGroupSum(JSONArray array, String startDate, String endDate);
 
     List<JSONObject> getKuaiShouGroupMessageGroup(JSONArray array, String startDate, String endDate);
 
-    List<JSONObject> getPlanMessage(JSONArray array, String startDate, String endDate,String target,String project);
+    List<JSONObject> getPlanMessage(JSONArray array, String startDate, String endDate, String target, String project);
 
-    JSONObject getPlanSum(JSONArray array, String startDate, String endDate,String project);
+    JSONObject getPlanSum(JSONArray array, String startDate, String endDate, String project);
 
-    List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate,String project);
+    List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate, String project);
+
+    List<JSONObject> getOperator(String userId, String userName);
 }

+ 38 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/NewMonitorServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.report.service.impl;
 
+import cn.com.ctop.kuaishou.modules.report.entity.NewMonitorInfo;
 import cn.com.ctop.kuaishou.modules.report.mapper.NewMonitorMapper;
 import cn.com.ctop.kuaishou.modules.report.service.NewMonitorService;
 import com.alibaba.fastjson.JSONArray;
@@ -62,7 +63,7 @@ public class NewMonitorServiceImpl implements NewMonitorService {
                                     BigDecimal groupCharge = newMonitorMapper.getGroupCharge(unitId, afterTime);
                                     //大于500为有效广告组
                                     String effective = "0";
-                                    if (groupCharge != null && groupCharge.compareTo(new BigDecimal(500)) ==1 ) {
+                                    if (groupCharge != null && groupCharge.compareTo(new BigDecimal(500)) == 1) {
                                         //有效
                                         effective = "1";
                                     }
@@ -106,7 +107,7 @@ public class NewMonitorServiceImpl implements NewMonitorService {
                                     BigDecimal campaignCharge = newMonitorMapper.getCampaignCharge(campaignId, afterTime);
                                     //大于500为有效广告计划
                                     String effective = "0";
-                                    if (campaignCharge != null && campaignCharge.compareTo(new BigDecimal(500)) ==1) {
+                                    if (campaignCharge != null && campaignCharge.compareTo(new BigDecimal(500)) == 1) {
                                         //有效
                                         effective = "1";
                                     }
@@ -148,7 +149,7 @@ public class NewMonitorServiceImpl implements NewMonitorService {
                                     BigDecimal campaignCharge = newMonitorMapper.getCampaignChargeTouTiao(campaignId, afterTime);
                                     //大于500为有效广告计划
                                     String effective = "0";
-                                    if (campaignCharge != null && campaignCharge.compareTo(new BigDecimal(500)) ==1) {
+                                    if (campaignCharge != null && campaignCharge.compareTo(new BigDecimal(500)) == 1) {
                                         //有效
                                         effective = "1";
                                     }
@@ -251,4 +252,38 @@ public class NewMonitorServiceImpl implements NewMonitorService {
 
         return planGroupMessageGroup;
     }
+
+    @Override
+    public List<JSONObject> getOperator(String userId, String userName) {
+        List<JSONObject> list = new ArrayList<>();
+        JSONObject ob = new JSONObject();
+        ob.put("user_id", userId);
+        ob.put("user_name", userName);
+        list.add(ob);
+        try {
+            if (userId != null) {
+                List<NewMonitorInfo> operator = newMonitorMapper.getOperator(userId);
+                list.addAll(getAllNode(operator));
+            }
+        } catch (Exception e) {
+            log.info("查询失败:{}", e.toString());
+        }
+        return list;
+    }
+
+    List<JSONObject> getAllNode(List<NewMonitorInfo> operator) {
+        List<JSONObject> objects = new ArrayList<>();
+        if (!operator.isEmpty()) {
+            for (NewMonitorInfo newMonitorInfo : operator) {
+                JSONObject js = new JSONObject();
+                js.put("user_id", newMonitorInfo.getUser_id());
+                js.put("user_name", newMonitorInfo.getUser_name());
+                objects.add(js);
+                if (newMonitorInfo.getChildren() != null && newMonitorInfo.getChildren().size() > 0) {
+                    objects.addAll(getAllNode(newMonitorInfo.getChildren()));
+                }
+            }
+        }
+        return objects;
+    }
 }