From e55c8b0a92eb9715edd90c31dfd4de51a47b588b Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期五, 04 十一月 2022 17:40:08 +0800
Subject: [PATCH] changes

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/IpVolumeMissionService.java |  106 ++++++++++++++++++++++++++--------------------------
 1 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/IpVolumeMissionService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/IpVolumeMissionService.java
index b8da591..63bc00f 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/IpVolumeMissionService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/IpVolumeMissionService.java
@@ -7,7 +7,6 @@
 import com.sandu.common.execption.BusinessException;
 import com.sandu.common.object.BaseConditionVO;
 import com.sandu.common.service.impl.BaseServiceImpl;
-import com.sandu.ximon.admin.minio.entity.MinIoConstant;
 import com.sandu.ximon.admin.param.IpVolumeMissionParam;
 import com.sandu.ximon.admin.security.SecurityUtils;
 import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
@@ -48,6 +47,18 @@
 
 
     public boolean addMission(IpVolumeMissionParam missionparam) {
+
+        List<Integer> fileIds = missionparam.getFileIds();
+        List<IpVolumeFile> ipVolumeFiles = ipVolumeFileService.listByIds(fileIds);
+        ipVolumeFiles.forEach(file -> {
+            if (SecurityUtils.getClientId() != null) {
+                //闈炶秴绠$敤鎴�
+                if (!SecurityUtils.getUserId().equals(file.getClientId()) && !SecurityUtils.getUserId().equals(file.getUserId())) {
+                    //鐢ㄦ埛id鍜屽鎴穒d閮戒笉鍖归厤
+                    throw new BusinessException("鏂囦欢褰掑睘寮傚父,鍒涘缓浠诲姟澶辫触");
+                }
+            }
+        });
 
         String taskName = missionparam.getMissionName();
 
@@ -95,24 +106,11 @@
             if (fileEntity == null) {
                 throw new BusinessException("fileId涓�" + fileId + "鐨勬枃浠朵笉瀛樺湪");
             }
-            if (fileEntity.getUserId() == null && fileEntity.getClientId() != null) {
-                fileEntity.setUserId(fileEntity.getClientId());
-            }
-            String absolutePath;
-            absolutePath = MinIoConstant.getAbsolutePath(
-                    MinIoConstant.BROADCAST_FILE.getBucketName() + fileEntity.getUserId(),
-                    fileEntity.getFileName()
-            );
-            if (fileEntity.getUserId() == null && fileEntity.getClientId() == null) {
-                absolutePath = MinIoConstant.getAbsolutePath(
-                        MinIoConstant.ADMIN_BROADCAST_FILE.getBucketName(),
-                        fileEntity.getFileName()
-                );
-            }
+
             taskMediaFileVO.setI(i);
             i++;
             taskMediaFileVO.setT(0);
-            taskMediaFileVO.setN(absolutePath);
+            taskMediaFileVO.setN(fileEntity.getFileUrl());
             taskMediaFileVO.setS(BigInteger.valueOf(fileEntity.getOriginSize()));
 
             taskMediaFileVOS.add(taskMediaFileVO);
@@ -238,22 +236,11 @@
             taskFileEntity.setFileId(fileId);
 
             IpVolumeFile fileEntity = ipVolumeFileService.getById(fileId);
-            String absolutePath;
-            absolutePath = MinIoConstant.getAbsolutePath(
-                    MinIoConstant.BROADCAST_FILE.getBucketName() + fileEntity.getUserId(),
-                    fileEntity.getFileName()
-            );
-            if (fileEntity.getUserId() == null && fileEntity.getClientId() == null) {
-                absolutePath = MinIoConstant.getAbsolutePath(
-                        MinIoConstant.ADMIN_BROADCAST_FILE.getBucketName(),
-                        fileEntity.getFileName()
-                );
-            }
 
             taskMediaFileVO.setI(i);
             i++;
             taskMediaFileVO.setT(0);
-            taskMediaFileVO.setN(absolutePath);
+            taskMediaFileVO.setN(fileEntity.getFileUrl());
             taskMediaFileVO.setS(BigInteger.valueOf(fileEntity.getOriginSize()));
 
             taskMediaFileVOS.add(taskMediaFileVO);
@@ -334,35 +321,48 @@
     /**
      * 鍒犻櫎浠诲姟
      *
-     * @param taskId
+     * @param taskIds
      * @return0锛氭垚鍔� 1锛氫换鍔′笉澶勪簬绌洪棽鐘舵�� 2:鏈嶅姟鍣ㄥ垹闄ゅけ璐�
      */
-    public Integer deleteMission(Integer taskId) {
-        Integer del = TaskAPIUtils.delTask(taskId);
-        if (del == 0) {
-            IpVolumeMission byId = getById(taskId);
-            if (byId == null) {
-                return -1;
-            }
-            removeById(taskId);
-            broadcastV2TaskFileService.deleteByTaskId(taskId);
-            broadcastV2TaskTerminalService.deleteByTaskId(taskId);
+    public Integer deleteMission(List<Integer> taskIds) {
+        //鍒犻櫎澶辫触鐨勯泦鍚�
+        List<Integer> delIds = new ArrayList<Integer>();
+        if (!taskIds.isEmpty()) {
+            taskIds.forEach(taskId -> {
+                Integer del = TaskAPIUtils.delTask(taskId);
+                if (del == 0) {
+                    IpVolumeMission byId = getById(taskId);
+                    if (byId == null) {
+                        return;
+                    }
+                    removeById(taskId);
+                    broadcastV2TaskFileService.deleteByTaskId(taskId);
+                    broadcastV2TaskTerminalService.deleteByTaskId(taskId);
 //            broadcastV2TaskTerminalService.removeById(taskId);
+                } else {
+                    delIds.add(taskId);
+                }
+
+                /**
+                 * IP闊虫煴浠诲姟鍒犻櫎 鏃ュ織璁板綍寮�濮�
+                 */
+                String content = "{鍒犻櫎鐨勪换鍔D锛�" + taskId
+                        + "锛屼换鍔″垹闄ょ粨鏋滐細" + del
+                        + " }";
+                StoreOperationRecordsUtils.storeOperationData(null, null, "IP闊虫煴浠诲姟鍒犻櫎", content);
+                /**
+                 * IP闊虫煴浠诲姟鍒犻櫎 鏃ュ織璁板綍缁撴潫
+                 */
+            });
+        } else {
+            throw new BusinessException("浠诲姟id涓嶈兘涓虹┖");
         }
 
-        /**
-         * IP闊虫煴浠诲姟鍒犻櫎 鏃ュ織璁板綍寮�濮�
-         */
-        String content = "{鍒犻櫎鐨勪换鍔D锛�" + taskId
-                + "锛屼换鍔″垹闄ょ粨鏋滐細" + del
-                + " }";
-        StoreOperationRecordsUtils.storeOperationData(null, null, "IP闊虫煴浠诲姟鍒犻櫎", content);
-        /**
-         * IP闊虫煴浠诲姟鍒犻櫎 鏃ュ織璁板綍缁撴潫
-         */
-
-
-        return del;
+        if (delIds.isEmpty()) {
+            return 0;
+        } else {
+            throw new BusinessException("閮ㄥ垎鍒犻櫎澶辫触,澶辫触鐨勯泦鍚堜负:" + delIds);
+        }
     }
 
 
@@ -442,7 +442,7 @@
                 }
 
             } else {
-                if (!byId.getClientId().equals(SecurityUtils.getUserId())&&!byId.getUserId().equals(SecurityUtils.getUserId())) {
+                if (!byId.getClientId().equals(SecurityUtils.getUserId()) && !byId.getUserId().equals(SecurityUtils.getUserId())) {
                     throw new BusinessException("浠诲姟褰掑睘閿欒");
                 }
             }

--
Gitblit v1.9.3