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