From 92459e3e326488acae77e068c37eb4b96eae5ebf Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期三, 27 三月 2024 12:41:48 +0800
Subject: [PATCH] #周计划

---
 src/main/java/com/zy/crm/manager/controller/BIController.java |   80 +++++++++++++++++++++++++++++----------
 1 files changed, 59 insertions(+), 21 deletions(-)

diff --git a/src/main/java/com/zy/crm/manager/controller/BIController.java b/src/main/java/com/zy/crm/manager/controller/BIController.java
index 7f65669..911b619 100644
--- a/src/main/java/com/zy/crm/manager/controller/BIController.java
+++ b/src/main/java/com/zy/crm/manager/controller/BIController.java
@@ -2,9 +2,11 @@
 
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.annotations.ManagerAuth;
+import com.core.common.Cools;
 import com.core.common.R;
+import com.core.common.SpringUtils;
+import com.zy.crm.common.entity.UserYear;
 import com.zy.crm.common.web.BaseController;
-import com.zy.crm.manager.entity.ContractSales;
 import com.zy.crm.manager.entity.Plan;
 import com.zy.crm.manager.entity.PlanType;
 import com.zy.crm.manager.entity.ProcessPermissions;
@@ -14,14 +16,10 @@
 import com.zy.crm.system.entity.User;
 import com.zy.crm.system.service.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @RestController
 public class BIController extends BaseController {
@@ -36,23 +34,35 @@
     private ProcessPermissionsService processPermissionsService;
 
     @RequestMapping(value = "/pending/approval/auth")
-    @ManagerAuth
+    //@ManagerAuth
     public R get() {
         // 浼犲叆鐢ㄦ埛id鏌ヨ瑙勫垝鍗� 鍖哄垎锛岄�氳繃鍖哄垎鍑烘潵鐨勮鍒掑崟绫诲瀷鏌ヨ 瑙勫垝鐢宠鍗�
         //
+        PlanType planType = new PlanType();
+        planType.setType(2);
+        planType.setHostId(1L);
+        User planLeader = planTypeService.findPlanLeader(planType);
         EntityWrapper<Plan> wrapper = new EntityWrapper<>();
-        wrapper.setSqlSelect("user_id");
-        wrapper.eq("settle",2).eq("assistant_host_sign",0).groupBy("user_id");
+        wrapper.setSqlSelect("user_id","director","count(id) as count");
+        wrapper.eq("director",planLeader.getId()).eq("settle",1).eq("assistant_host_sign",0).groupBy("user_id,director");
         List<Map<String, Object>> maps = planService.selectMaps(wrapper);
+        for (Map<String, Object> map : maps) {
+            String user_id = map.get("user_id").toString();
+            UserService service = SpringUtils.getBean(UserService.class);
+            User user = service.selectById(user_id);
+            if (!Cools.isEmpty(user)) {
+                map.put("userId$",String.valueOf(user.getNickname()));
+            }
+        }
         return R.ok().add(maps);
     }
 
     @RequestMapping(value = "/pending/user/approval/auth")
-    @ManagerAuth
+    //@ManagerAuth
     public R getPlanByUser() {
         PlanType planType = new PlanType();
-        planType.setType(1);
-        planType.setType(1);
+        planType.setType(2);
+        planType.setHostId(1L);
         User planLeader = planTypeService.findPlanLeader(planType);
         List<User> users = userService.selectList(new EntityWrapper<User>().eq("dept_id", planLeader.getDeptId()));
         List<ProcessPermissions> processPermissionsList = processPermissionsService.selectList(new EntityWrapper<ProcessPermissions>().eq("process_memo", 101));
@@ -63,10 +73,17 @@
         List<Map<String, Object>> result = new ArrayList<>();
 
         for (User user:users){
+            if (user.getUsername().equals("鍛ㄥ澶�") || user.getUsername().equals("姊佹槍姘�")) {
+                continue;
+            }
             List<Plan> plans = planService.selctPlanListByDirector(user.getId());
             String userList = "";
             for (Plan plan:plans){
-                userList = userList+","+plan.getUserId$();
+                if (plans.indexOf(plan)==plans.size()-1){
+                    userList = userList+plan.getUserId$();
+                    continue;
+                }
+                userList = plan.getUserId$() +","+ userList;
             }
             int director = planService.selectCount(new EntityWrapper<Plan>().eq("director", user.getId()));
 
@@ -77,18 +94,39 @@
             map.put("anfme", director);
             result.add(map);
         }
+        return R.ok().add(result);
+    }
 
-//        List<PlanType> planTypes = planTypeService.selectList(new EntityWrapper<PlanType>().eq("type", "1").eq("host_id",1));
-//        for (PlanType planType2:planTypes){
-//
-//        }
 
-        // 浼犲叆鐢ㄦ埛id鏌ヨ瑙勫垝鍗� 鍖哄垎锛岄�氳繃鍖哄垎鍑烘潵鐨勮鍒掑崟绫诲瀷鏌ヨ 瑙勫垝鐢宠鍗�
-        //
+    @RequestMapping(value = "/pending/sum/auth")
+    //@ManagerAuth
+    public R getAllPlan() {
         EntityWrapper<Plan> wrapper = new EntityWrapper<>();
-        wrapper.setSqlSelect("user_id");
-        wrapper.eq("settle",2).eq("assistant_host_sign",0).groupBy("user_id");
+        wrapper.setSqlSelect("count(0) count","MONTH(create_time) month");
+        wrapper.groupBy("MONTH(create_time)");
         List<Map<String, Object>> maps = planService.selectMaps(wrapper);
         return R.ok().add(maps);
     }
+
+    @RequestMapping(value = "/user/sumyear/auth")
+    //@ManagerAuth
+    public R getUserYear() {
+        PlanType planType = new PlanType();
+        planType.setType(2);
+        planType.setHostId(1L);
+        User planLeader = planTypeService.findPlanLeader(planType);
+        List<User> users = userService.selectList(new EntityWrapper<User>().eq("dept_id", planLeader.getDeptId()));
+        List<Map<String, Object>> maps = new ArrayList<>();
+        for (User user : users) {
+            if (user.getUsername().equals("鍛ㄥ澶�") || user.getUsername().equals("姊佹槍姘�")) {
+                continue;
+            }
+            Map<String, Object> map = new HashMap<>();
+            map.put("user", user);
+            map.put("obj", planService.selectUserYear(user.getId()));
+            maps.add(map);
+        }
+        return R.ok().add(maps);
+    }
+
 }

--
Gitblit v1.9.1