From fa3737fbe1a83ccf9e8ad8c6c8e81483f987ab5b Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期三, 08 十一月 2023 13:51:41 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/crm/manager/controller/PlanController.java |   81 +++++++++++++++++++++++++++-------------
 1 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/src/main/java/com/zy/crm/manager/controller/PlanController.java b/src/main/java/com/zy/crm/manager/controller/PlanController.java
index 61a96cd..0cd26b0 100644
--- a/src/main/java/com/zy/crm/manager/controller/PlanController.java
+++ b/src/main/java/com/zy/crm/manager/controller/PlanController.java
@@ -55,8 +55,11 @@
     private OrderService orderService;
     @Autowired
     private SmsCodeService smsCodeService;
+    @Autowired
+    private ProcessPermissionsService processPermissionsService;
 
     String PZH=" 鈥斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�� ";
+    Integer PBN = 6;
 
 
     @GetMapping(value = "/plan/{id}/auth")
@@ -87,10 +90,22 @@
                   @RequestParam(required = false) String condition,
                   @RequestParam(required = false, value = "dept_id") Long deptId,
                   @RequestParam(required = false, value = "user_id") Long userId) {
+        Long director = null;
+        if (deptId==null && userId == null){
+            if (getRole().getId()==3){
+                userId = getUserId();
+            }else if (getRole().getId()==2){
+                deptId = getDeptId();
+                userId = null;
+            }
+            director = getUserId();
+        }
+
         return R.ok(planService.getPage(new Page<>(curr, limit)
                 , getHostId()
                 , deptId == null ? null : String.valueOf(deptId)
-                , userId == null ? getUserId() : userId
+                , userId
+                , director
                 , condition)
         );
     }
@@ -242,31 +257,23 @@
 
     @RequestMapping(value = "/plan/insert/file/auth")
 //    @ManagerAuth
-    public R insertFile(@RequestParam("planId") String planId,@RequestParam MultipartFile file){
-        try{
-            InputStream inputStream = file.getInputStream();
-            // 鑾峰彇鏂囦欢鐨勫唴瀹圭被鍨�
-            String contentType = file.getContentType();
-            String suffix = getFileSuffix(file.getOriginalFilename());
-            String url = ossService.upload(inputStream, suffix,contentType);
-//            String url = "http://tjdt.oss-cn-hangzhou.aliyuncs.com/"+file.getOriginalFilename();
-            String[] names = url.split("com/");
-            String name= names[1];
+    public R insertFile(@RequestParam("planId") String planId, @RequestParam("filename") String filename, @RequestParam("filesize") Long filesize) {
+        try {
+//            InputStream inputStream = file.getInputStream();
+//            // 鑾峰彇鏂囦欢鐨勫唴瀹圭被鍨�
+//            String contentType = file.getContentType();
+//            String url = ossService.upload(inputStream, file.getOriginalFilename(), contentType);
+////            String url = "http://tjdt.oss-cn-hangzhou.aliyuncs.com/"+file.getOriginalFilename();
+//            String[] names = url.split("com/");
+//            String name= names[1];
+
+
             String[] split = planId.split("-");
             int id = Integer.parseInt(split[1]);
-            planService.increasePlanUrl(id,url,name,file.getSize());
-
-            /*String[] split = planId.split("-");
-            int id = Integer.parseInt(split[1]);
-            System.out.println("---寮�濮�---");
-            String savePath = "D:/crm/plan/file/"+id+"/"; // 鎸囧畾淇濆瓨鏂囦欢鐨勮矾寰�
-            try{
-                FileSaveExampleUtil.saveFile(file, savePath);
-            }catch (Exception e){
-                return R.error();
-            }*/
+            String url = "http://zhongyang-ftpserver.oss-cn-hangzhou.aliyuncs.com/" + filename;
+            planService.increasePlanUrl(id, url, filename, filesize);
             return R.ok();
-        }catch (Exception e){
+        } catch (Exception e) {
             System.out.println(e);
             return R.error();
         }
@@ -299,11 +306,14 @@
     @RequestMapping(value = "/plan/view/file/auth")
 //    @ManagerAuth
     public R viewFile(@RequestParam("planId") String planId){
+        List<FileSaveExampleUtil.FileDTO> fileDTOS = new ArrayList<>();
+        if (Cools.isEmpty(planId)){
+            return R.ok(fileDTOS);
+        }
         int id = Integer.parseInt(planId);
 //        String savePath = "D:/crm/plan/file/"+id+"/"; // 鎸囧畾淇濆瓨鏂囦欢鐨勮矾寰�
         try{
             List<Integer> ids = planService.selectPlanUrlId(id);
-            List<FileSaveExampleUtil.FileDTO> fileDTOS = new ArrayList<>();
             for (int id2 : ids){
                 String url = planService.selectPlanUrlPlanIdUrl(id2);
                 String name = planService.selectPlanUrlPlanIdName(id2);
@@ -598,6 +608,8 @@
         plan.setStep(1);
         plan.setSettle(1);
         plan.setSettleMsg(JSON.toJSONString(planDtoList));
+        plan.setUpdateBy(getUserId());
+        plan.setUpdateTime(now);
         planService.updateById(plan);
         return R.ok("鍥為��鎴愬姛");
     }
@@ -624,6 +636,11 @@
         List<User> users = userService.selectList(new EntityWrapper<User>().eq("dept_id", planLeader.getDeptId()));
         List<KeyValueVo> vos = new ArrayList<>();
         users.forEach(item -> vos.add(new KeyValueVo(String.valueOf(item.getNickname()), item.getId())));
+        if (planType.getType().equals(2)){
+            ProcessPermissions processPermissions= processPermissionsService.selectOne(new EntityWrapper<ProcessPermissions>().eq("process_memo", 101).eq("process", "1-1"));//2锛氭牳浠锋祦绋�
+            User manager = userService.selectById(processPermissions.getUserId());       // 鑾峰彇鏍镐环娴佺▼鑺傜偣1纭浜�
+            vos.add(new KeyValueVo(String.valueOf(manager.getNickname()), manager.getId()));
+        }
         return R.ok().add(vos);
     }
 
@@ -675,13 +692,23 @@
         wrapper.like("name", condition);
         wrapper.eq("status",1);
 
-        int type =1;
-        if (getUser().getNickname().equals("鏉庝笘璞�2绾�")){
-            type=2;
+        List<ProcessPermissions> processPermissionsList = processPermissionsService.selectList(new EntityWrapper<ProcessPermissions>().eq("process_memo", 4).or().eq("process_memo", 5));//2锛氭牳浠锋祦绋�
+        int type =0;
+        for (ProcessPermissions processPermissions:processPermissionsList){
+            if (getUserId().equals(processPermissions.getUserId())){
+                type=PBN-processPermissions.getProcessMemo();
+                break;
+            }
+        }
+        if (type==0){
+            return R.error("浣犱笉鏄牳浠峰憳,鏃犳潈鎺ヤ换鍔�");
         }
 
         List<Long> typeList = new ArrayList<>();
         List<PlanType> planTypes = planTypeService.selectList(new EntityWrapper<PlanType>().eq("type", type));
+        if (Cools.isEmpty(planTypes) || planTypes.size()==0){
+            return R.ok();
+        }
         for (PlanType planType : planTypes){
             typeList.add(planType.getId());
         }

--
Gitblit v1.9.1