|
@@ -1,25 +1,32 @@
|
|
|
package com.om.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.om.entity.dto.DiaLogQueryPageDTO;
|
|
|
import com.om.entity.po.*;
|
|
|
import com.om.entity.vo.DiaLogQueryPageVO;
|
|
|
import com.om.entity.vo.DiaLogQueryVO;
|
|
|
+import com.om.exception.BadReqException;
|
|
|
import com.om.mapper.DiagnosticLogMapper;
|
|
|
import com.om.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.om.utils.HuaweiObsUtil;
|
|
|
import com.om.utils.Result;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import static com.om.constant.UploadConstant.DIAGNOSTIC_LOG_PREFIX;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 服务实现类
|
|
|
+ * 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
* @author bmmx
|
|
@@ -37,7 +44,8 @@ public class DiagnosticLogServiceImpl extends ServiceImpl<DiagnosticLogMapper, D
|
|
|
@Resource
|
|
|
private IClientService clientService;
|
|
|
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private HuaweiObsUtil obsUtil;
|
|
|
|
|
|
@Resource
|
|
|
private IVciInfoService vciInfoService;
|
|
@@ -52,16 +60,16 @@ public class DiagnosticLogServiceImpl extends ServiceImpl<DiagnosticLogMapper, D
|
|
|
LocalDateTime beginTime = dto.getBeginTime();
|
|
|
LocalDateTime endTime = dto.getEndTime();
|
|
|
User one = null;
|
|
|
- if (account!=null){
|
|
|
+ if (account != null) {
|
|
|
//根据用户名查询用户
|
|
|
- one = userService.lambdaQuery()
|
|
|
+ one = userService.lambdaQuery()
|
|
|
.eq(User::getUsername, account)
|
|
|
.one();
|
|
|
}
|
|
|
|
|
|
|
|
|
VciInfo vciInfo = null;
|
|
|
- if (vciSn!=null){
|
|
|
+ if (vciSn != null) {
|
|
|
//根据vciSn查询VCI
|
|
|
vciInfo = vciInfoService.lambdaQuery()
|
|
|
.eq(VciInfo::getVciNum, vciSn)
|
|
@@ -82,7 +90,7 @@ public class DiagnosticLogServiceImpl extends ServiceImpl<DiagnosticLogMapper, D
|
|
|
vo.setPages((int) page.getPages());
|
|
|
vo.setTotal((int) page.getTotal());
|
|
|
|
|
|
- if (account!=null||vciSn!=null||beginTime != null||endTime != null){
|
|
|
+ if (account != null || vciSn != null || beginTime != null || endTime != null) {
|
|
|
vo.setSearchCount(true);
|
|
|
}
|
|
|
|
|
@@ -111,12 +119,49 @@ public class DiagnosticLogServiceImpl extends ServiceImpl<DiagnosticLogMapper, D
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result batchDownload() {
|
|
|
- return null;
|
|
|
+ public Result batchDownload(List<Integer> ids) {
|
|
|
+ //根据id集合查询
|
|
|
+ List<DiagnosticLog> diagnosticLogs = this.listByIds(ids);
|
|
|
+
|
|
|
+ if (CollectionUtil.isEmpty(diagnosticLogs)){
|
|
|
+ throw new BadReqException("本页诊断文件异常");
|
|
|
+ }
|
|
|
+
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ int year = now.getYear();
|
|
|
+ int monthValue = now.getMonthValue();
|
|
|
+ int day = now.getDayOfMonth();
|
|
|
+
|
|
|
+ List<String> downloadUrls = new ArrayList<>();
|
|
|
+ String prefix = DIAGNOSTIC_LOG_PREFIX + "/" + year + "/" + monthValue + "/" + day;
|
|
|
+ for (DiagnosticLog diagnosticLog : diagnosticLogs) {
|
|
|
+ String nameLog = diagnosticLog.getNameLog();
|
|
|
+
|
|
|
+ //获取下载链接
|
|
|
+ String downloadUrl = obsUtil.getDownloadUrl(nameLog, prefix);
|
|
|
+ downloadUrls.add(downloadUrl);
|
|
|
+ }
|
|
|
+ return Result.ok(downloadUrls);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result downloadFile(DiagnosticLog diagnosticLog) {
|
|
|
- return null;
|
|
|
+ public Result downloadFile(Integer id) {
|
|
|
+ //根据id进行查询
|
|
|
+ DiagnosticLog diagnosticLog = this.getById(id);
|
|
|
+
|
|
|
+ if (BeanUtil.isEmpty(diagnosticLog)) {
|
|
|
+ throw new BadReqException("该诊断日志不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取文件名称
|
|
|
+ String nameLog = diagnosticLog.getNameLog();
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ int year = now.getYear();
|
|
|
+ int monthValue = now.getMonthValue();
|
|
|
+ int day = now.getDayOfMonth();
|
|
|
+ String prefix = DIAGNOSTIC_LOG_PREFIX + "/" + year + "/" + monthValue + "/" + day;
|
|
|
+ //获取下载链接
|
|
|
+ String downloadUrl = obsUtil.getDownloadUrl(nameLog, prefix);
|
|
|
+ return Result.ok(downloadUrl);
|
|
|
}
|
|
|
}
|