yumeng 3 years ago
parent
commit
661ad193d2

+ 32 - 17
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsVideoReportCtrl.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.report.controller;
 package cn.com.ctop.kuaishou.modules.report.controller;
 
 
 import cn.com.ctop.common.module.entity.UserCompany;
 import cn.com.ctop.common.module.entity.UserCompany;
+import cn.com.ctop.common.module.service.ISysUserService;
 import cn.com.ctop.common.module.service.IUserCompanyService;
 import cn.com.ctop.common.module.service.IUserCompanyService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
@@ -14,6 +15,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.AccountReportConstants;
 import org.jeecg.common.constant.AccountReportConstants;
+import org.jeecg.common.system.entity.SysUser;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.utils.JsonResourceUtil;
 import org.jeecg.common.utils.JsonResourceUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -61,6 +63,9 @@ public class KsVideoReportCtrl {
         return result;
         return result;
     }
     }
 
 
+    @Autowired
+    private ISysUserService sysUserService;
+
     @PostMapping("/list")
     @PostMapping("/list")
     public Result<PageInfo<JSONObject>> getListReport(@RequestBody JSONObject requestBody) {
     public Result<PageInfo<JSONObject>> getListReport(@RequestBody JSONObject requestBody) {
         Result<PageInfo<JSONObject>> result = new Result<>();
         Result<PageInfo<JSONObject>> result = new Result<>();
@@ -79,11 +84,17 @@ public class KsVideoReportCtrl {
             if (Check.isNull(filedAll)) {
             if (Check.isNull(filedAll)) {
                 throw new Exception("初始化查询 字段返回为空");
                 throw new Exception("初始化查询 字段返回为空");
             }
             }
+            String userId = requestBody.getString("userId");
+            if (Check.isNull(userId)) {
+                throw new Exception("用户id不能为空");
+            }
             Map<String, Object> requestMap = new HashMap<>();
             Map<String, Object> requestMap = new HashMap<>();
-            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-            String realname = sysUser.getRealname();
-            if (!"管理员".equals(realname) && !"吴睿刚".equals(realname)) {
-                UserCompany userCompany = companyService.getByUserId(sysUser.getId());
+            SysUser user = sysUserService.getById(userId);
+            if (Check.isNull(user)) {
+                throw new Exception("用户信息为空");
+            }
+            if (!"管理员".equals(user.getRealname()) && !"吴睿刚".equals(user.getRealname())) {
+                UserCompany userCompany = companyService.getByUserId(userId);
                 if (Check.isNull(userCompany)) {
                 if (Check.isNull(userCompany)) {
                     throw new Exception("公司信息为空");
                     throw new Exception("公司信息为空");
                 }
                 }
@@ -179,12 +190,27 @@ public class KsVideoReportCtrl {
             if (Check.isNull(endDate)) {
             if (Check.isNull(endDate)) {
                 throw new Exception("请输入查询结束时间");
                 throw new Exception("请输入查询结束时间");
             }
             }
+
+            String userId = requestBody.getString("userId");
+            if (Check.isNull(userId)) {
+                throw new Exception("用户id不能为空");
+            }
+            Map<String, Object> requestMap = new HashMap<>();
+            SysUser user = sysUserService.getById(userId);
+            if (Check.isNull(user)) {
+                throw new Exception("用户信息为空");
+            }
+            if (!"管理员".equals(user.getRealname()) && !"吴睿刚".equals(user.getRealname())) {
+                UserCompany userCompany = companyService.getByUserId(userId);
+                if (Check.isNull(userCompany)) {
+                    throw new Exception("公司信息为空");
+                }
+                requestMap.put("companyId", userCompany.getCompanyId());
+            }
             String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.getKuaishouVideoReportMap());
             String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.getKuaishouVideoReportMap());
-            //   System.err.println(filedAll);
             if (Check.isNull(filedAll)) {
             if (Check.isNull(filedAll)) {
                 throw new Exception("初始化查询 字段返回为空");
                 throw new Exception("初始化查询 字段返回为空");
             }
             }
-            Map<String, Object> requestMap = new HashMap<>();
             requestMap.put("filed", filedAll);
             requestMap.put("filed", filedAll);
             requestMap.put("startDate", startDate);
             requestMap.put("startDate", startDate);
             requestMap.put("endDate", endDate);
             requestMap.put("endDate", endDate);
@@ -212,17 +238,6 @@ public class KsVideoReportCtrl {
             if (!Check.isNull(requestBody.getString("channelType"))) {
             if (!Check.isNull(requestBody.getString("channelType"))) {
                 requestMap.put("channelType", requestBody.getString("channelType"));
                 requestMap.put("channelType", requestBody.getString("channelType"));
             }
             }
-            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-            String realname = sysUser.getRealname();
-            if (!"管理员".equals(realname) && !"吴睿刚".equals(realname)) {
-                UserCompany userCompany = companyService.getByUserId(sysUser.getId());
-                if (Check.isNull(userCompany)) {
-                    throw new Exception("公司信息为空");
-                }
-                requestMap.put("companyId", userCompany.getCompanyId());
-            }
-
-
             JSONArray columns2 = new JSONArray();
             JSONArray columns2 = new JSONArray();
             columns2.add(0, "materialName");
             columns2.add(0, "materialName");
             columns2.add(1, "signature");
             columns2.add(1, "signature");