完成报告上传功能
This commit is contained in:
@@ -78,7 +78,7 @@ public class ReportManageConroller {
|
||||
public ResponseMessage add(@RequestBody ReportVo vo) {
|
||||
ReportEntity entity = new ReportEntity();
|
||||
BeanUtils.copyProperties(vo, entity);
|
||||
String name = reportService.insert(entity);
|
||||
String name = reportService.insert(entity, vo.getLabelList());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("reportName", name);
|
||||
return Result.success(map);
|
||||
|
||||
@@ -54,22 +54,16 @@ public class ReportEntity {
|
||||
private String year;
|
||||
|
||||
/**
|
||||
* 标签1id
|
||||
* 报告涉密等级
|
||||
*/
|
||||
@TableField("labelOneId")
|
||||
private String labelOneId;
|
||||
@TableField("confidentialLevel")
|
||||
private String confidentialLevel;
|
||||
|
||||
/**
|
||||
* 标签2id
|
||||
* 隐私等级
|
||||
*/
|
||||
@TableField("labelTwoId")
|
||||
private String labelTwoId;
|
||||
|
||||
/**
|
||||
* 标签3id
|
||||
*/
|
||||
@TableField("labelThreeId")
|
||||
private String labelThreeId;
|
||||
@TableField("privacyLevel")
|
||||
private String privacyLevel;
|
||||
|
||||
/**
|
||||
* 文件id
|
||||
|
||||
@@ -15,10 +15,12 @@ public interface IReportService {
|
||||
|
||||
/**
|
||||
* 新增或编辑报告
|
||||
*
|
||||
* @param entity
|
||||
* @param labelList
|
||||
* @return 报告名称
|
||||
*/
|
||||
String insert(ReportEntity entity);
|
||||
String insert(ReportEntity entity, List<String> labelList);
|
||||
|
||||
/**
|
||||
* 报告列表展示
|
||||
|
||||
@@ -3,9 +3,11 @@ package com.adc.da.report.service.impl;
|
||||
import com.adc.da.login.util.CommonUtils;
|
||||
import com.adc.da.report.dao.mysql.FileDao;
|
||||
import com.adc.da.report.dao.mysql.ReportDao;
|
||||
import com.adc.da.report.dao.mysql.ReportLabelDao;
|
||||
import com.adc.da.report.dao.mysql.ReportUserDao;
|
||||
import com.adc.da.report.eo.FileEntity;
|
||||
import com.adc.da.report.eo.ReportEntity;
|
||||
import com.adc.da.report.eo.ReportLabelEntity;
|
||||
import com.adc.da.report.eo.ReportUserEntity;
|
||||
import com.adc.da.report.service.IReportService;
|
||||
import com.adc.da.report.util.*;
|
||||
@@ -18,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -28,7 +31,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -54,6 +56,9 @@ public class IReportServiceImpl implements IReportService {
|
||||
@Resource
|
||||
private ReportUserDao reportUserDao;
|
||||
|
||||
@Resource
|
||||
private ReportLabelDao reportLabelDao;
|
||||
|
||||
@Resource
|
||||
private FileDao fileDao;
|
||||
|
||||
@@ -71,15 +76,17 @@ public class IReportServiceImpl implements IReportService {
|
||||
|
||||
@Autowired
|
||||
private ObsBootUtil obsBootUtil;
|
||||
|
||||
/**
|
||||
* 新增或编辑报告
|
||||
*
|
||||
* @param entity
|
||||
* @param labelList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String insert(ReportEntity entity) {
|
||||
public String insert(ReportEntity entity, List<String> labelList) {
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
if (StringUtils.isEmpty(entity.getId())) {
|
||||
@@ -98,6 +105,12 @@ public class IReportServiceImpl implements IReportService {
|
||||
reportUserDao.insert(reportUserEntity);
|
||||
});
|
||||
|
||||
//插入报表标签关系表
|
||||
labelList.forEach((label) -> {
|
||||
ReportLabelEntity reportLabelEntity = new ReportLabelEntity(entity.getId(), label);
|
||||
reportLabelDao.insert(reportLabelEntity);
|
||||
});
|
||||
|
||||
CommonUtils.threadPoolExecutor().execute(() -> {
|
||||
//生成html
|
||||
try {
|
||||
@@ -128,6 +141,14 @@ public class IReportServiceImpl implements IReportService {
|
||||
reportUserDao.insert(reportUserEntity);
|
||||
});
|
||||
|
||||
//修改报表标签关系表(先删后增)
|
||||
reportLabelDao.deleteById(entity.getId());
|
||||
//插入报表标签关系表
|
||||
labelList.forEach((label) -> {
|
||||
ReportLabelEntity reportLabelEntity = new ReportLabelEntity(entity.getId(), label);
|
||||
reportLabelDao.insert(reportLabelEntity);
|
||||
});
|
||||
|
||||
CommonUtils.threadPoolExecutor().execute(() -> {
|
||||
String key = entity.getId() + "-" + entity.getFileId();
|
||||
Boolean hasKey = stringRedisTemplate.hasKey(key);
|
||||
@@ -201,7 +222,7 @@ public class IReportServiceImpl implements IReportService {
|
||||
? String.valueOf(Integer.parseInt(fileEntity.getFileSize()) / 1024) + "kb" : "0kb");
|
||||
c.setFileName(fileEntity.getFileName());
|
||||
List<String> userIdList = reportUserDao.selectList(
|
||||
new QueryWrapper<ReportUserEntity>().eq("reportId", c.getId()))
|
||||
new QueryWrapper<ReportUserEntity>().eq("reportId", c.getId()))
|
||||
.stream().map(ReportUserEntity::getUserId).collect(Collectors.toList());
|
||||
c.setReportUserIdList(userIdList);
|
||||
});
|
||||
@@ -279,12 +300,12 @@ public class IReportServiceImpl implements IReportService {
|
||||
*/
|
||||
public String createHtmlString(String fileId) throws Exception {
|
||||
FileEntity fileEntity = fileDao.selectById(fileId);
|
||||
String path = uploadFile + fileEntity.getSavePath();
|
||||
String path = uploadFile + fileEntity.getSavePath();
|
||||
FileOutputStream outputStream = new FileOutputStream(path);
|
||||
// 上传方式:阿里云:alioss 华为云:hwobs
|
||||
if (uploadType.equals("hwobs")){
|
||||
if (uploadType.equals("hwobs")) {
|
||||
obsBootUtil.getFileFromOBS(fileEntity.getSavePath(), outputStream);
|
||||
}else if (uploadType.equals("alioss")){
|
||||
} else if (uploadType.equals("alioss")) {
|
||||
ossClientUtil.getFileFromOSS(fileEntity.getSavePath(), outputStream);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.adc.da.report.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@@ -41,21 +42,6 @@ public class ReportVo {
|
||||
*/
|
||||
private String year;
|
||||
|
||||
/**
|
||||
* 标签1
|
||||
*/
|
||||
private String labelOneName;
|
||||
|
||||
/**
|
||||
* 标签2
|
||||
*/
|
||||
private String labelTwoName;
|
||||
|
||||
/**
|
||||
* 标签3
|
||||
*/
|
||||
private String labelThreeName;
|
||||
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
@@ -82,19 +68,19 @@ public class ReportVo {
|
||||
private List<String> reportUserIdList;
|
||||
|
||||
/**
|
||||
* 标签1id
|
||||
* 报告涉密等级
|
||||
*/
|
||||
private String labelOneId;
|
||||
private String confidentialLevel;
|
||||
|
||||
/**
|
||||
* 标签2id
|
||||
* 隐私等级
|
||||
*/
|
||||
private String labelTwoId;
|
||||
private String privacyLevel;
|
||||
|
||||
/**
|
||||
* 标签3id
|
||||
* 关联的标签id集合
|
||||
*/
|
||||
private String labelThreeId;
|
||||
private List<String> labelList;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
|
||||
Reference in New Issue
Block a user