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 | 121 ++++++++++++++++++++-------------------
1 files changed, 62 insertions(+), 59 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 6adbf8b..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;
@@ -20,6 +19,7 @@
import com.sandu.ximon.dao.domain.BroadcastV2TaskTerminal;
import com.sandu.ximon.dao.domain.IpVolumeFile;
import com.sandu.ximon.dao.domain.IpVolumeMission;
+import com.sandu.ximon.dao.enums.OrderByEnums;
import com.sandu.ximon.dao.mapper.IpVolumeMissionMapper;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
@@ -47,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();
@@ -94,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);
@@ -237,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);
@@ -333,49 +321,62 @@
/**
* 鍒犻櫎浠诲姟
*
- * @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);
+ }
}
- public List<IpVolumeMissionBo> missionList(BaseConditionVO baseConditionVO, String keyword, Integer order,Integer seq) {
+ public List<IpVolumeMissionBo> missionList(BaseConditionVO baseConditionVO, String keyword, Integer order, Integer seq) {
//鎺掑簭瀛楁
- String orderByResult = "create_time";
+ String orderByResult = "task_id";
//姝e簭銆佸�掑彊
String orderBySeq = "ASC";
if (order != null) {
switch (order) {
case 1:
- orderByResult = "create_time";
+ orderByResult = OrderByEnums.IP_VOLUME_MISSION_CREATE_TIME.getCode();
break;
default:
}
@@ -394,12 +395,14 @@
}
//鎺掑簭鏂瑰紡
String orderBy = orderByResult + " " + orderBySeq;
- PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), orderBy);
+ if (baseConditionVO != null) {
+ PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), orderBy);
+ }
List<IpVolumeMissionBo> ipVolumeMissionBos = new ArrayList<>();
LambdaQueryWrapper<IpVolumeMission> eq = Wrappers.lambdaQuery(IpVolumeMission.class);
- PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+
//涓嶆槸瓒呯
if (SecurityUtils.getClientId() != null) {
eq = eq.eq(IpVolumeMission::getUserId, SecurityUtils.getUserId()).or(w -> {
@@ -434,12 +437,12 @@
}
if (SecurityUtils.getClientId() != null) {
if (clientService.findClientId()) {
- if (byId.getUserId().equals(SecurityUtils.getUserId())) {
+ if (!byId.getUserId().equals(SecurityUtils.getUserId())) {
throw new BusinessException("浠诲姟褰掑睘閿欒");
}
} else {
- if (byId.getClientId().equals(SecurityUtils.getUserId())) {
+ if (!byId.getClientId().equals(SecurityUtils.getUserId()) && !byId.getUserId().equals(SecurityUtils.getUserId())) {
throw new BusinessException("浠诲姟褰掑睘閿欒");
}
}
--
Gitblit v1.9.3