Merge branch 'lixuetao'

This commit is contained in:
bupengxiang
2023-05-25 15:28:22 +08:00
43 changed files with 1677 additions and 388 deletions
@@ -0,0 +1,46 @@
package com.adc.da.report;
import com.adc.da.report.constant.MessageTypeEnum;
import com.adc.da.report.eo.MessageEntity;
import com.adc.da.report.service.IMessageService;
import com.adc.da.util.utils.UUID;
import io.github.swagger2markup.GroupBy;
import io.github.swagger2markup.Language;
import io.github.swagger2markup.Swagger2MarkupConfig;
import io.github.swagger2markup.Swagger2MarkupConverter;
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
import io.github.swagger2markup.markup.builder.MarkupLanguage;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.net.URL;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class TestMessage {
@Resource
private IMessageService messageService;
@Test
public void testMessagePublish() {
MessageEntity messageEntity = new MessageEntity();
messageEntity.setMessageTitle("测试批量发送标题")
.setMessageType(MessageTypeEnum.SYSTEM_MESSAGE.getValue())
.setId(UUID.randomUUID10())
.setContent("测试测试最后一次")
.setDelFlag(0)
.setCreateUser("ZGGJP3N7FT")
.setCreateDate(new Date());
List<String> userIds = new ArrayList<>();
userIds.add("ZGGJP3N7FT");
messageService.publishMessage(messageEntity, false, userIds);
}
}
@@ -0,0 +1,23 @@
package com.adc.da.report.constant;
import io.swagger.models.auth.In;
/**
* @author: CaiHaohan
* @Date: 2023/5/23 15:17
* @Description:
*/
public class MessageConstants {
/**
* 消息状态 未读
*/
public static final Integer UNREAD = 0;
/**
* 消息状态 已读
*/
public static final Integer READ = 1;
}
@@ -0,0 +1,40 @@
package com.adc.da.report.constant;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* @author: CaiHaohan
* @Date: 2023/5/24 10:44
* @Description:
*/
public enum MessageTypeEnum {
/**
* 系统消息
*/
SYSTEM_MESSAGE(0, "系统消息");
/**
* 对应值
*/
private Integer code;
/**
* 描述
*/
private String desc;
MessageTypeEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer getValue() {
return code;
}
public String getDesc() {
return desc;
}
}
@@ -23,6 +23,15 @@ public class ReportConstants {
*/
public static final String NO_USER_PRIVACY_INVOLVED = "不涉及用户隐私";
/**
* 流程中
*/
public static final Integer IN_PROCESS = 1;
/**
* 不在流程中
*/
public static final Integer NOT_IN_PROCESS = 2;
}
@@ -0,0 +1,49 @@
package com.adc.da.report.controller;
import com.adc.da.report.service.IMessageService;
import com.adc.da.report.vo.MessageQueryVo;
import com.adc.da.report.vo.MessageVo;
import com.adc.da.util.http.ResponseMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
/**
* @Author caihaohan
* @Date 2021/11/9 13:46
*/
@Slf4j
@Api(tags = "站内信")
@RestController
@RequestMapping("/${restPath}/message")
public class MessageController {
@Resource
private IMessageService messageEntityService;
/**
* 站内信消息列表
* @return
*/
@ApiOperation("站内信消息列表")
@GetMapping("/list")
public ResponseMessage list(@Valid MessageQueryVo messageQueryVo) {
return messageEntityService.listByCurrentUser(messageQueryVo);
}
/**
* 全部已读
* @return
*/
@ApiOperation("全部已读接口")
@GetMapping("/allRead")
public ResponseMessage allRead() {
return messageEntityService.allRead();
}
}
@@ -5,10 +5,7 @@ import com.adc.da.login.util.UserUtils;
import com.adc.da.report.annotation.ReportLog;
import com.adc.da.report.dao.mysql.ReportDao;
import com.adc.da.report.dao.mysql.ReportLogBookDao;
import com.adc.da.report.eo.FileEntity;
import com.adc.da.report.eo.LogEntity;
import com.adc.da.report.eo.ReportEntity;
import com.adc.da.report.eo.ReportLogBook;
import com.adc.da.report.eo.*;
import com.adc.da.report.service.IFileService;
import com.adc.da.report.service.ILogService;
import com.adc.da.report.service.IReportService;
@@ -22,12 +19,14 @@ import com.adc.da.report.vo.ReportVo;
import com.adc.da.util.exception.AdcDaBaseException;
import com.adc.da.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import com.adc.da.util.utils.CollectionUtils;
import com.adc.da.util.utils.FileUtil;
import com.adc.da.util.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,11 +40,11 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.*;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.zip.ZipOutputStream;
import static com.adc.da.report.constant.ReportConstants.FILE_EXTENSIONS_PDF;
@@ -245,19 +244,20 @@ public class ReportManageConroller {
/**
* 获取报告预览
* @param id
* @param reportId
* @param fileId
* @return
*/
@ApiOperation("获取报告预览")
@GetMapping("/getReportHtml/{id}")
public ResponseMessage getReportHtml(@PathVariable("id") String id) {
String html = reportService.reportHtml(id);
@GetMapping("/getReportHtml")
public ResponseMessage getReportHtml(@RequestParam String reportId, @RequestParam String fileId) {
String html = reportService.reportHtml(reportId, fileId);
Map<String, Object> map = new HashMap<>();
map.put("content", html);
ReportLogBook reportLog = new ReportLogBook();
reportLog.setId(UUID.randomUUID().toString().replaceAll("-",""));
reportLog.setReportId(id);
reportLog.setReportId(reportId);
reportLog.setType(1);
reportLog.setUpdateTime(new Date());
reportLog.setUserId(UserUtils.getUserId());
@@ -298,31 +298,6 @@ public class ReportManageConroller {
return Result.success();
}
// TODO 测试完不需要的代码请删掉,然后再把这个TODO也删掉
/**
* 测试
*/
@ApiOperation("testtest")
@GetMapping("/test")
@Deprecated
public void ttt() {
stringRedisTemplate.boundValueOps("1121212").set("1212");
}
// TODO 测试完不需要的代码请删掉,然后再把这个TODO也删掉
@ApiOperation("testPath")
@GetMapping("/testPath")
@Deprecated
public ResponseMessage testPath() throws URISyntaxException {
HashMap<String, String> pathMap = new HashMap<>();
String jarPath = new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getParentFile().getPath();
String property = System.getProperty("user.dir");
pathMap.put("jarpath", jarPath);
pathMap.put("propertyPath", property);
return Result.success(pathMap);
}
/**
* 获取文件名
* @param fileId
@@ -344,57 +319,24 @@ public class ReportManageConroller {
@ApiOperation(value = "详情||上传文件")
@PostMapping("/uploadFile")
public ResponseMessage<Map<String, Object>> uploadFile(MultipartFile file) throws IOException {
Map<String, Object> resultMap = new HashMap();
//上传路径
//此路径映射到localhost
String path = uploadFile;
String realName = file.getOriginalFilename();
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String date = dateFormat.format(now);
Random r = new Random();
String num = "";
for (int i = 0; i < 3; i++) {
int s = r.nextInt(10);
num += String.valueOf(s);
}
//获取上传文件名
String fileName = file.getOriginalFilename();
String contentType = file.getContentType();
String ext = fileName.substring(fileName.lastIndexOf(".") + 1);
fileName = fileName.substring(0, fileName.lastIndexOf("."))+date + num + "." + ext;
log.info("fileName>>" + fileName);
try{
String result="";
// 上传方式:阿里云:alioss 华为云:hwobs
if ("hwobs".equals(uploadType)){
result = obsBootUtil.upload(file, fileName);
}else if ("alioss".equals(uploadType)) {
result = ossClientUtil.uploadFile2OSS(file.getInputStream(),fileName);
}else if ("local".equals(uploadType)) {
localFileUtil.saveFile(file.getInputStream(), fileName);
}
resultMap.put("key", date + num);
resultMap.put("value", path + "//" + fileName);
resultMap.put("name", realName);
}
catch (Exception e){
log.error(e.getMessage(),e);
}
FileEntity entity = new FileEntity();
entity.setContentType(contentType);
entity.setCreateTime(new Date());
entity.setFileName(realName);
entity.setFileType(ext);
entity.setFileSize(String.valueOf(file.getSize()));
entity.setFileId(date + num);
entity.setSavePath(fileName);
fileService.addFile(entity);
Map<String, Object> resultMap = fileService.uploadFile(file);
return Result.success(resultMap);
}
/**
* 批量上传文件
* @param files
* @return
* @throws IOException
*/
@ApiOperation(value = "批量上传文件")
@PostMapping("/batchUploadFile")
public ResponseMessage<List<Map<String, Object>>> batchUploadFile(@RequestParam("files") @ApiParam(value="上传文件",required=true) MultipartFile[] files) throws IOException {
List<Map<String, Object>> uploadFile = fileService.batchUploadFile(files);
return Result.success(uploadFile);
}
/**
* 上传图片
* @param file
@@ -466,64 +408,73 @@ public class ReportManageConroller {
}
// /**
// * 下载文件
// * @param response
// * @param fileId
// * @throws IOException
// */
// @ApiOperation(value = "|下载文件")
// @GetMapping("/download")
// public void downloadPic(HttpServletResponse response, String fileId) throws IOException {
//
// try {
// FileEntity entity = fileService.getFile(fileId);
// String fileName = entity.getFileName();
// String filename = URLEncoder.encode(fileName, "UTF-8");
// response.setHeader("Content-Disposition", "attachment;filename=" + filename);
// response.setContentType("application/x-download");
//// File file = new File(uploadFile, entity.getSavePath());
// // 上传方式:阿里云:alioss 华为云:hwobs
// if ("hwobs".equals(uploadType)){
// obsBootUtil.downFile(entity.getSavePath(), response);
// }else if ("alioss".equals(uploadType)){
// ossClientUtil.downloadFileFromOSS(entity.getSavePath(),response);
// }else if ("local".equals(uploadType)){
// localFileUtil.downFile(entity.getSavePath(), response);
// }
// if (FILE_EXTENSIONS_PDF.equalsIgnoreCase(FileUtil.getFileExtension(fileName))) {
// String text = "text";
// PdfUtil.addWatermarkToPdf(response, text);
// }
// } catch (Exception ex) {
// log.info(ex.getMessage(),ex);
// }
// }
/**
* 下载文件
* @param response
* @param fileId
* @param fileIds
* @throws IOException
*/
@ApiOperation(value = "|下载文件")
@GetMapping("/download")
public void downloadPic(HttpServletResponse response, String fileId,String repostId) throws IOException {
public void download(HttpServletResponse response, String[] fileIds, String reportId) throws IOException {
List<String> fileIdList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(fileIds)) {
fileIdList = Arrays.asList(fileIds);
}
if (StrUtil.isNotBlank(repostId)) {
if (StrUtil.isBlank(reportId)) {
throw new AdcDaBaseException("缺少报告id");
}
if (StrUtil.isNotBlank(reportId)) {
//校验权限
if (!reportService.isAllowDownload(UserUtils.getUserId(), repostId)) {
if (!reportService.isAllowDownload(UserUtils.getUserId(), reportId)) {
throw new AdcDaBaseException("无此报告下载权限");
}
}
response.setContentType("application/x-download");
//待下载的文件id List
List<String> downLoadFileIds;
//判断是从列表页面下载 还是预览页面下载
if (CollectionUtils.isEmpty(fileIdList)) {
//列表点击下载按钮
downLoadFileIds = fileService.getDownloadFileIds(reportId);
if (CollectionUtils.isEmpty(downLoadFileIds)) {
log.info("无法下载,原因可能是无可下载文件(xls/xlsx文件无法下载)");
String zipFileName = "empty.zip"; // 压缩文件名
try {
// 设置响应头信息
response.setContentType("application/zip");
response.setHeader("Content-Disposition", "attachment; filename=" + zipFileName);
// 创建空的ZipOutputStream
ZipOutputStream zipOutputStream = new ZipOutputStream(response.getOutputStream());
zipOutputStream.close();
return;
} catch (IOException e) {
e.printStackTrace();
}
}
} else {
//检测是否要下载Excel文件
if (fileService.hasExcelFileId(fileIdList)) {
throw new AdcDaBaseException("不可以下载Excel文件");
}
//预览点击下载按钮
downLoadFileIds = fileIdList;
}
//如果只下载一个文件,则不压缩
if (downLoadFileIds.size() == 1) {
String fileId = downLoadFileIds.get(0);
try {
FileEntity entity = fileService.getFile(fileId);
String fileName = entity.getFileName();
String filename = URLEncoder.encode(fileName, "UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=" + filename);
response.setContentType("application/x-download");
// 获取编码后的文件名
String encodedFileName = URLEncoder.encode(fileName, "UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=" + encodedFileName);
//PDF文件需要加水印
if (FILE_EXTENSIONS_PDF.equalsIgnoreCase(FileUtil.getFileExtension(fileName))) {
@@ -538,8 +489,8 @@ public class ReportManageConroller {
localFileUtil.getFileFromLocal(entity.getSavePath(), outputStream);
}
//给文件添加水印
waterMarkUtil.addWatermarkToPdf(new FileInputStream(path), response);
waterMarkUtil.addWatermarkToPdfAndWriteToResponse(new FileInputStream(path), response);
outputStream.close();
} else {
// 上传方式:阿里云:alioss 华为云:hwobs 本地:local
if ("hwobs".equals(uploadType)){
@@ -554,17 +505,60 @@ public class ReportManageConroller {
} catch (Exception ex) {
log.info(ex.getMessage(),ex);
}
if (StringUtils.isNotEmpty(repostId)){
} else {
List<String> filePaths = new ArrayList<>();
String reportName = reportDao.selectById(reportId).getName() + ".zip";
// 获取编码后的文件名
String encodedFileName = URLEncoder.encode(reportName, "UTF-8");
// 设置响应头信息
response.setContentType("application/zip");
response.setHeader("Content-Disposition", "attachment; filename=" + encodedFileName);
response.setHeader("Content-Transfer-Encoding", "binary");
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "no-store");
response.setHeader("Expires", "0");
for (String fileId : downLoadFileIds) {
try {
FileEntity entity = fileService.getFile(fileId);
String fileName = entity.getFileName();
String path = uploadFile + entity.getSavePath();
FileOutputStream outputStream = new FileOutputStream(path);
filePaths.add(path);
// 上传方式:阿里云:alioss 华为云:hwobs
if ("hwobs".equals(uploadType)) {
obsBootUtil.getFileFromOBS(entity.getSavePath(), outputStream);
} else if ("alioss".equals(uploadType)) {
ossClientUtil.getFileFromOSS(entity.getSavePath(), outputStream);
} else if ("local".equals(uploadType)) {
localFileUtil.getFileFromLocal(entity.getSavePath(), outputStream);
}
//PDF文件需要加水印
if (FILE_EXTENSIONS_PDF.equalsIgnoreCase(FileUtil.getFileExtension(fileName))) {
waterMarkUtil.savePdfToFile(new FileInputStream(path), path);
}
outputStream.close();
} catch (Exception ex) {
log.info(ex.getMessage(),ex);
}
}
//将文件压缩 写入Response
localFileUtil.compressFiles(filePaths, response);
}
if (StringUtils.isNotEmpty(reportId)){
ReportLogBook reportLog = new ReportLogBook();
reportLog.setId(UUID.randomUUID().toString().replaceAll("-",""));
reportLog.setReportId(repostId);
reportLog.setReportId(reportId);
reportLog.setType(2);
reportLog.setUpdateTime(new Date());
reportLog.setUserId(UserUtils.getUserId());
reportLogBookDao.insert(reportLog);
//报告日志管理
ReportEntity reportEntity = reportDao.selectById(repostId);
ReportEntity reportEntity = reportDao.selectById(reportId);
reportLog(reportEntity.getName(),"下载");
}
}
@@ -607,4 +601,15 @@ public class ReportManageConroller {
return Result.success(act);
}
/**
* 删除文件
* @return
* @throws ParseException
*/
@ApiOperation("删除文件")
@PostMapping("/delFile")
public ResponseMessage delFile(@RequestBody ReportFile reportFile) throws Exception {
reportService.delFile(reportFile);
return Result.success();
}
}
@@ -3,9 +3,12 @@ package com.adc.da.report.dao.mysql;
import com.adc.da.report.eo.FileEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* @Author doudxw
* @Date 2021/6/28 15:19
*/
public interface FileDao extends BaseMapper<FileEntity> {
List<String> getDownloadFileIds(String reportId);
}
@@ -0,0 +1,30 @@
package com.adc.da.report.dao.mysql;
import com.adc.da.report.eo.MessageEntity;
import com.adc.da.report.vo.MessageQueryVo;
import com.adc.da.report.vo.MessageVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
/**
* @author ThinkBook
* @description 针对表【ts_message】的数据库操作Mapper
* @createDate 2023-05-23 11:22:15
* @Entity com.adc.da.report.eo.MessageEntityEntity
*/
public interface MessageDao extends BaseMapper<MessageEntity> {
/**
* 根据当前用户展示站内信列表
* @param page
* @param messageVo
* @param userId
* @return
*/
IPage<MessageVo> listByUser(IPage<MessageVo> page, @Param("vo") MessageQueryVo messageVo, @Param("userId") String userId);
}
@@ -0,0 +1,18 @@
package com.adc.da.report.dao.mysql;
import com.adc.da.report.eo.ReportFile;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ReportFileDao extends BaseMapper<ReportFile> {
void delByReportId(@Param("pageVO") ReportFile reportFile);
void actEndDelReport(@Param("reportId")String reportId);
void updateState(@Param("reportId")String dataId);
List<ReportFile> selectByReport(@Param("pageVO")ReportFile reportFile);
}
@@ -0,0 +1,18 @@
package com.adc.da.report.dao.mysql;
import com.adc.da.report.eo.UserMessageEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author ThinkBook
* @description 针对表【ts_user_message】的数据库操作Mapper
* @createDate 2023-05-23 11:30:04
* @Entity com.adc.da.report.eo.UserMessage
*/
public interface UserMessageDao extends BaseMapper<UserMessageEntity> {
}
@@ -0,0 +1,70 @@
package com.adc.da.report.eo;
import com.adc.da.report.constant.MessageTypeEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
*
* @author Caihaohan
* @TableName ts_message
*/
@TableName(value ="ts_message")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class MessageEntity implements Serializable {
/**
* 主键id
*/
@TableId(value = "id")
private String id;
/**
* 标题
*/
@TableField(value = "message_title")
private String messageTitle;
/**
* 内容
*/
@TableField(value = "content")
private String content;
/**
* 消息类型
*/
@TableField(value = "message_type")
private Integer messageType;
/**
* 发布人
*/
@TableField(value = "createUser")
private String createUser;
/**
* 发布时间
*/
@TableField(value = "createDate")
private Date createDate;
/**
* 删除标记(0未删除 1已删除)
*/
@TableField(value = "del_flag")
private Integer delFlag;
@TableField(exist = false)
private static final long serialVersionUID = 1314298673425876932L;
}
@@ -68,7 +68,7 @@ public class ReportEntity {
/**
* 文件id
*/
@TableField("fileId")
@TableField(exist = false)
private String fileId;
/**
@@ -109,4 +109,7 @@ public class ReportEntity {
@TableField(exist = false)
private List<List<String>> labelList;
@TableField(exist = false)
private List<ReportFile> fileList;
}
@@ -0,0 +1,52 @@
package com.adc.da.report.eo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.List;
@Data
@TableName("TS_REPORT_FILE")
public class ReportFile {
@TableId(value = "id",type = IdType.INPUT)
private String id;
@TableField("report_id")
private String reportId;
@TableField("file_id")
private String fileId;
/**
* 状态 1 流程中 ,2 非流程中
*/
@TableField("state")
private Integer state;
@TableField(exist = false)
private List<String> rfIdList;
@TableField(exist = false)
private String fileName;
public ReportFile(String reportId){
this.reportId = reportId;
}
public ReportFile(String reportId,Integer state){
this.reportId = reportId;
this.state = state;
}
public ReportFile(){
}
}
@@ -94,7 +94,7 @@ public class TtReportManageAct {
/**
* 文件id
*/
@TableField("fileId")
@TableField(exist = false)
private String fileId;
@@ -128,10 +128,16 @@ public class TtReportManageAct {
@TableField("secrecy_last")
private Date secrecyLast;
@TableField("file_name")
@TableField(exist = false)
private String rfId;
@TableField(exist = false)
private String fileName;
@TableField(exist = false)
private List<String> labelList;
@TableField(exist = false)
private List<ReportFile> fileList;
}
@@ -0,0 +1,56 @@
package com.adc.da.report.eo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
*
* @author ThinkBook
* @TableName ts_user_message
*/
@TableName(value ="ts_user_message")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class UserMessageEntity implements Serializable {
/**
* 主键id
*/
@TableId(value = "id")
private String id;
/**
* 用户id
*/
@TableField(value = "user_id")
private String userId;
/**
* 站内信id
*/
@TableField(value = "message_id")
private String messageId;
/**
* 阅读状态(0代表未读,1代表已读)
*/
@TableField(value = "read_type")
private Integer readType;
/**
* 删除标记(0未删除 1已删除)
*/
@TableField(value = "del_flag")
private Integer delFlag;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}
@@ -2,6 +2,10 @@ package com.adc.da.report.service;
import com.adc.da.report.eo.FileEntity;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
/**
* @Author doudxw
@@ -22,4 +26,21 @@ public interface IFileService {
*/
FileEntity getFile(String fileId);
List<Map<String, Object>> batchUploadFile(MultipartFile[] files);
/**
* 判断传进来的fileIds里有没有Excel的fileId
* @param fileIds
* @return
*/
boolean hasExcelFileId(List<String> fileIds);
/**
* 根据报告id返回所有可以下载的文件id
* @param reportId
* @return
*/
List<String> getDownloadFileIds(String reportId);
Map<String, Object> uploadFile(MultipartFile file);
}
@@ -0,0 +1,36 @@
package com.adc.da.report.service;
import com.adc.da.report.eo.MessageEntity;
import com.adc.da.report.vo.MessageQueryVo;
import com.adc.da.util.http.ResponseMessage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @author ThinkBook
* @description 针对表【ts_message】的数据库操作Service
* @createDate 2023-05-23 11:22:15
*/
public interface IMessageService extends IService<MessageEntity> {
/**
* 返回当前用户的消息列表
* @return
*/
ResponseMessage listByCurrentUser(MessageQueryVo messageVo);
/**
* 全部已读接口
* @return
*/
ResponseMessage allRead();
/**
* 发布站内信(当用户数过多的时候谨慎使用发送给全部用户)
* @param message
* @param toAllUser
* @param userIds
*/
void publishMessage(MessageEntity message, boolean toAllUser, List<String> userIds);
}
@@ -3,7 +3,6 @@ package com.adc.da.report.service;
import com.adc.da.report.eo.ReportContentEntity;
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
@@ -18,7 +17,6 @@ public interface IReportContentService extends IService<ReportContentEntity> {
* 插入报告内容表
*
* @param reportId 报告id
* @param fileId 文件id
*/
void insertReportContent(String reportId, String fileId) throws IOException;
void insertReportContent(String reportId) throws IOException;
}
@@ -0,0 +1,11 @@
package com.adc.da.report.service;
import com.adc.da.report.eo.ReportFile;
import com.baomidou.mybatisplus.extension.service.IService;
public interface IReportFileService extends IService<ReportFile> {
}
@@ -1,6 +1,7 @@
package com.adc.da.report.service;
import com.adc.da.report.eo.ReportEntity;
import com.adc.da.report.eo.ReportFile;
import com.adc.da.report.vo.ChangeUploaderVo;
import com.adc.da.report.vo.ReportQueryVo;
import com.adc.da.report.vo.ReportVo;
@@ -41,10 +42,11 @@ public interface IReportService {
/**
* 获取报告htmlString
* @param id
* @param reportId
* @param fileId
* @return
*/
String reportHtml(String id);
String reportHtml(String reportId, String fileId);
IPage<ReportVo> addReportPage(ReportQueryVo vo) throws Exception;
@@ -95,4 +97,7 @@ public interface IReportService {
* @return
*/
ResponseMessage changeUploader(ChangeUploaderVo changeUploaderVo);
void delFile(ReportFile reportFile);
}
@@ -0,0 +1,13 @@
package com.adc.da.report.service;
import com.adc.da.report.eo.UserMessageEntity;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author ThinkBook
* @description 针对表【ts_user_message】的数据库操作Service
* @createDate 2023-05-23 11:30:04
*/
public interface IUserMessageService extends IService<UserMessageEntity> {
}
@@ -1,21 +1,53 @@
package com.adc.da.report.service.impl;
import com.adc.da.report.constant.ReportConstants;
import com.adc.da.report.dao.mysql.FileDao;
import com.adc.da.report.eo.FileEntity;
import com.adc.da.report.service.IFileService;
import javax.annotation.Resource;
import com.adc.da.report.util.LocalFileUtil;
import com.adc.da.report.util.OSSClientUtil;
import com.adc.da.report.util.ObsBootUtil;
import com.adc.da.util.utils.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @Author doudxw
* @Date 2021/11/8 15:00
*/
@Service
@Slf4j
public class IFileServiceImpl implements IFileService {
@Resource
private FileDao fileDao;
@Value("${uploadFile}")
private String uploadFile;
@Value("${picPath}")
private String picPath;
@Value("${uploadType}")
private String uploadType;
@Autowired
private ObsBootUtil obsBootUtil;
@Autowired
private LocalFileUtil localFileUtil;
@Resource
private OSSClientUtil ossClientUtil;
/**
* 添加文件
@@ -36,4 +68,137 @@ public class IFileServiceImpl implements IFileService {
FileEntity fileEntity = fileDao.selectById(fileId);
return fileEntity;
}
@Override
@Transactional
public List<Map<String, Object>> batchUploadFile(MultipartFile[] files) {
List<Map<String, Object>> resultList = new ArrayList<>();
for (MultipartFile file : files) {
Map<String, Object> resultMap = new HashMap();
//上传路径
//此路径映射到localhost
String path = uploadFile;
String realName = file.getOriginalFilename();
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String date = dateFormat.format(now);
Random r = new Random();
String num = "";
for (int i = 0; i < 3; i++) {
int s = r.nextInt(10);
num += String.valueOf(s);
}
//获取上传文件名
String fileName = file.getOriginalFilename();
String contentType = file.getContentType();
String ext = fileName.substring(fileName.lastIndexOf(".") + 1);
fileName = fileName.substring(0, fileName.lastIndexOf("."))+date + num + "." + ext;
log.info("fileName>>" + fileName);
try{
String result="";
// 上传方式:阿里云:alioss 华为云:hwobs
if ("hwobs".equals(uploadType)){
result = obsBootUtil.upload(file, fileName);
}else if ("alioss".equals(uploadType)) {
result = ossClientUtil.uploadFile2OSS(file.getInputStream(),fileName);
}else if ("local".equals(uploadType)) {
localFileUtil.saveFile(file.getInputStream(), fileName);
}
resultMap.put("key", date + num);
resultMap.put("value", path + "//" + fileName);
resultMap.put("name", realName);
resultList.add(resultMap);
}
catch (Exception e){
log.error(e.getMessage(),e);
}
FileEntity entity = new FileEntity();
entity.setContentType(contentType);
entity.setCreateTime(new Date());
entity.setFileName(realName);
entity.setFileType(ext);
entity.setFileSize(String.valueOf(file.getSize()));
entity.setFileId(date + num);
entity.setSavePath(fileName);
this.addFile(entity);
}
return resultList;
}
@Override
@Synchronized
public Map<String, Object> uploadFile(MultipartFile file) {
Map<String, Object> resultMap = new HashMap();
//上传路径
//此路径映射到localhost
String path = uploadFile;
String realName = file.getOriginalFilename();
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String date = dateFormat.format(now);
Random r = new Random();
String num = "";
for (int i = 0; i < 3; i++) {
int s = r.nextInt(10);
num += String.valueOf(s);
}
//获取上传文件名
String fileName = file.getOriginalFilename();
String contentType = file.getContentType();
String ext = fileName.substring(fileName.lastIndexOf(".") + 1);
fileName = fileName.substring(0, fileName.lastIndexOf("."))+date + num + "." + ext;
log.info("fileName>>" + fileName);
try{
String result="";
// 上传方式:阿里云:alioss 华为云:hwobs
if ("hwobs".equals(uploadType)){
result = obsBootUtil.upload(file, fileName);
}else if ("alioss".equals(uploadType)) {
result = ossClientUtil.uploadFile2OSS(file.getInputStream(),fileName);
}else if ("local".equals(uploadType)) {
localFileUtil.saveFile(file.getInputStream(), fileName);
}
resultMap.put("id", date + num);
resultMap.put("value", path + "//" + fileName);
resultMap.put("name", realName);
}
catch (Exception e){
log.error(e.getMessage(),e);
}
FileEntity entity = new FileEntity();
entity.setContentType(contentType);
entity.setCreateTime(new Date());
entity.setFileName(realName);
entity.setFileType(ext);
entity.setFileSize(String.valueOf(file.getSize()));
entity.setFileId(date + num);
entity.setSavePath(fileName);
this.addFile(entity);
return resultMap;
}
@Override
public boolean hasExcelFileId(List<String> fileIds) {
boolean hasExcelFileId = false;
LambdaQueryWrapper<FileEntity> fileEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
fileEntityLambdaQueryWrapper.in(FileEntity::getFileId, fileIds);
List<FileEntity> fileEntities = fileDao.selectList(fileEntityLambdaQueryWrapper);
if (CollectionUtils.isNotEmpty(fileEntities)) {
for (FileEntity fileEntity : fileEntities) {
if (ReportConstants.FILE_EXTENSIONS_XLS.equals(fileEntity.getFileType()) ||
ReportConstants.FILE_EXTENSIONS_XLSX.equals(fileEntity.getFileType())) {
hasExcelFileId = true;
break;
}
}
}
return hasExcelFileId;
}
@Override
public List<String> getDownloadFileIds(String reportId) {
return fileDao.getDownloadFileIds(reportId);
}
}
@@ -0,0 +1,108 @@
package com.adc.da.report.service.impl;
import com.adc.da.login.util.UserUtils;
import com.adc.da.report.constant.MessageConstants;
import com.adc.da.report.constant.MessageTypeEnum;
import com.adc.da.report.constant.ReportConstants;
import com.adc.da.report.dao.mysql.UserMessageDao;
import com.adc.da.report.eo.UserMessageEntity;
import com.adc.da.report.service.IUserMessageService;
import com.adc.da.report.vo.MessageQueryVo;
import com.adc.da.report.vo.MessageVo;
import com.adc.da.sys.dao.mysql.UserEODao;
import com.adc.da.sys.entity.UserEO;
import com.adc.da.sys.service.iservice.IUserEoService;
import com.adc.da.util.exception.AdcDaBaseException;
import com.adc.da.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import com.adc.da.util.utils.UUID;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.adc.da.report.eo.MessageEntity;
import com.adc.da.report.service.IMessageService;
import com.adc.da.report.dao.mysql.MessageDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author ThinkBook
* @description 针对表【ts_message】的数据库操作Service实现
* @createDate 2023-05-23 11:22:15
*/
@Service
public class IMessageServiceImpl extends ServiceImpl<MessageDao, MessageEntity>
implements IMessageService {
@Resource
private MessageDao messageDao;
@Resource
private IUserMessageService userMessageService;
@Resource
private UserEODao userEODao;
@Override
public ResponseMessage listByCurrentUser(MessageQueryVo messageVo) {
IPage<MessageVo> page = new Page<>();
page.setCurrent(messageVo.getPageNo());
page.setSize(messageVo.getPageSize());
IPage<MessageVo> list = messageDao.listByUser(page, messageVo, UserUtils.getUserId());
return Result.success(list);
}
@Override
public ResponseMessage allRead() {
LambdaUpdateWrapper<UserMessageEntity> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(UserMessageEntity::getReadType, MessageConstants.UNREAD);
wrapper.eq(UserMessageEntity::getUserId, UserUtils.getUserId());
wrapper.set(UserMessageEntity::getReadType, MessageConstants.READ);
userMessageService.update(wrapper);
return Result.success("全部已读");
}
@Override
@Transactional(rollbackFor = Exception.class)
public void publishMessage(MessageEntity message, boolean toAllUser, List<String> userIds) {
List<String> userEoIds = new ArrayList<>();
if (toAllUser) {
LambdaQueryWrapper<UserEO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UserEO::getDelFlag, 0);
List<UserEO> userEOS = userEODao.selectList(lambdaQueryWrapper);
if (userEOS != null) {
userEoIds = userEOS.stream().map(UserEO::getUsid).collect(Collectors.toList());
}
} else {
userEoIds = userIds;
if (userEoIds.isEmpty()) {
throw new AdcDaBaseException("无指定发送的用户,无法发送站内信");
}
}
//保存消息信息
save(message);
List<UserMessageEntity> userMessageEntities = new ArrayList<>();
userEoIds.forEach(userId -> {
UserMessageEntity userMessageEntity = new UserMessageEntity();
userMessageEntity.setId(UUID.randomUUID10())
.setUserId(userId)
.setMessageId(message.getId())
.setReadType(MessageConstants.UNREAD)
.setDelFlag(0);
userMessageEntities.add(userMessageEntity);
});
userMessageService.saveBatch(userMessageEntities);
}
}
@@ -1,19 +1,22 @@
package com.adc.da.report.service.impl;
import com.adc.da.report.dao.mysql.FileDao;
import com.adc.da.report.dao.mysql.ReportFileDao;
import com.adc.da.report.eo.FileEntity;
import com.adc.da.report.eo.ReportFile;
import com.adc.da.report.util.FileContentUtil;
import com.adc.da.report.util.LocalFileUtil;
import com.adc.da.report.util.OSSClientUtil;
import com.adc.da.report.util.ObsBootUtil;
import com.adc.da.util.utils.CollectionUtils;
import com.adc.da.util.utils.FileUtil;
import com.adc.da.util.utils.UUID;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.adc.da.report.eo.ReportContentEntity;
import com.adc.da.report.service.IReportContentService;
import com.adc.da.report.dao.mysql.ReportContentDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -22,6 +25,9 @@ import javax.annotation.Resource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author Caihaohan
@@ -51,9 +57,22 @@ public class IReportContentServiceImpl extends ServiceImpl<ReportContentDao, Rep
@Resource
private FileDao fileDao;
@Resource
private ReportFileDao reportFileDao;
@Override
@Transactional(rollbackFor = Exception.class)
public void insertReportContent(String reportId, String fileId) throws IOException {
public void insertReportContent(String reportId) throws IOException {
LambdaQueryWrapper<ReportFile> reportFileLambdaQueryWrapper = new LambdaQueryWrapper<>();
reportFileLambdaQueryWrapper.eq(ReportFile::getReportId, reportId);
reportFileLambdaQueryWrapper.eq(ReportFile::getState, 2);
List<ReportFile> reportFiles = reportFileDao.selectList(reportFileLambdaQueryWrapper);
List<String> fileIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(reportFiles)) {
fileIds = reportFiles.stream().map(ReportFile::getFileId).collect(Collectors.toList());
}
StringBuilder content = new StringBuilder();
for (String fileId : fileIds) {
//获取文件
FileEntity fileEntity = fileDao.selectById(fileId);
String path = uploadFile + fileEntity.getSavePath();
@@ -68,20 +87,22 @@ public class IReportContentServiceImpl extends ServiceImpl<ReportContentDao, Rep
}
File file = new File(path);
//解析出内容
String content = FileContentUtil.readFileContent(file);
//将内容存入
ReportContentEntity reportContent = query().eq("report_id", reportId).one();
if (reportContent == null) {
ReportContentEntity reportContentEntity = new ReportContentEntity(UUID.randomUUID10(), reportId, content);
save(reportContentEntity);
} else {
reportContent.setReportContent(content);
saveOrUpdate(reportContent);
}
content.append(FileContentUtil.readFileContent(file));
//将文件删除
outputStream.close();
FileUtil.deleteFile(path);
}
//将内容存入
ReportContentEntity reportContent = query().eq("report_id", reportId).one();
if (reportContent == null) {
ReportContentEntity reportContentEntity = new ReportContentEntity(UUID.randomUUID10(), reportId, content.toString());
save(reportContentEntity);
} else {
reportContent.setReportContent(content.toString());
saveOrUpdate(reportContent);
}
}
}
@@ -0,0 +1,16 @@
package com.adc.da.report.service.impl;
import com.adc.da.report.dao.mysql.ReportFileDao;
import com.adc.da.report.eo.ReportFile;
import com.adc.da.report.service.IReportFileService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class IReportFileServiceImpl extends ServiceImpl<ReportFileDao, ReportFile>
implements IReportFileService {
}
@@ -6,6 +6,7 @@ import com.adc.da.login.util.UserUtils;
import com.adc.da.report.constant.ReportConstants;
import com.adc.da.report.dao.mysql.FileDao;
import com.adc.da.report.dao.mysql.ReportDao;
import com.adc.da.report.dao.mysql.ReportFileDao;
import com.adc.da.report.dao.mysql.ReportLabelDao;
import com.adc.da.report.eo.*;
import com.adc.da.report.service.*;
@@ -22,6 +23,7 @@ import com.adc.da.sys.entity.RoleEO;
import com.adc.da.sys.entity.UserEO;
import com.adc.da.sys.service.MenuEOService;
import com.adc.da.sys.service.OrgEOService;
import com.adc.da.sys.util.BeanCopyUtils;
import com.adc.da.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import com.adc.da.util.utils.CollectionUtils;
@@ -128,6 +130,12 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
@Resource
private MenuEOService menuEOService;
@Autowired
private IReportFileService iReportFileService;
@Autowired
private ReportFileDao reportFileDao;
@Override
public void addOrUpdate(ReportEntity reportEntity) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -143,6 +151,17 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
reportDao.insert(reportEntity);
}
String reportId = reportEntity.getId();
//文件
reportFileDao.delByReportId(new ReportFile(reportId,2));
List<ReportFile> reportFiles = new ArrayList<>();
for (ReportFile reportFile : reportEntity.getFileList()) {
reportFile.setId(UUID.randomUUID().replace("-",""));
reportFile.setReportId(reportId);
// reportFile.setFileId(s);
reportFile.setState(2);
reportFiles.add(reportFile);
}
iReportFileService.saveBatch(reportFiles);
//插入报表标签关系表
//修改报表标签关系表(先删后增)
iReportLabelService.deleteReportLabelByReportId(new String[]{reportId});
@@ -156,14 +175,14 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
labelList.add(reportLabelEntity);
}
iReportLabelService.saveBatch(labelList);
}
//插入报表内容表
try {
iReportContentService.insertReportContent(reportId, reportEntity.getFileId());
iReportContentService.insertReportContent(reportId);
log.info("抽取报告内容");
} catch (IOException e) {
log.error("获取报告内容失败", e);
}
}
}
@@ -181,6 +200,11 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
return Result.success("修改成功");
}
@Override
public void delFile(ReportFile reportFile) {
reportFileDao.deleteBatchIds(reportFile.getRfIdList());
}
/**
* 新增或编辑报告
*
@@ -267,8 +291,6 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
reportLabelDao.insert(reportLabelEntity);
});
//TODO 插入报表内容表(先删后增)
//删除power_apply表中的对应权限
iPowerApplyService.deleteByReportId(entity.getId());
@@ -400,18 +422,18 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
/**
* 报告html
*
* @param id
* @param reportId
* @param fileId
* @return
*/
@Override
public String reportHtml(String id) {
public String reportHtml(String reportId, String fileId) {
try {
ReportEntity entity = reportDao.selectById(id);
String key = entity.getId() + "-" + entity.getFileId();
String key = reportId + fileId;
String html = stringRedisTemplate.boundValueOps(key).get();
//没有的话就生成
if (StrUtil.isBlank(html)) {
html = createHtmlString(entity.getFileId());
html = createHtmlString(fileId);
log.info("执行完成html" + html);
@@ -529,38 +551,38 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
});
}
list.getRecords().forEach(c -> {
FileEntity fileEntity = Optional.ofNullable(fileDao.selectById(c.getFileId())).orElse(new FileEntity());
if (StringUtils.isEmpty(fileEntity.getFileType())) {
c.setFileType(null);
}
//ppt文件
else if (ReportConstants.FILE_EXTENSIONS_PPT.equalsIgnoreCase(fileEntity.getFileType()) ||
ReportConstants.FILE_EXTENSIONS_PPTX.equalsIgnoreCase(fileEntity.getFileType())) {
c.setFileType("1");
}
//excel文件
else if (ReportConstants.FILE_EXTENSIONS_XLS.equalsIgnoreCase(fileEntity.getFileType()) ||
ReportConstants.FILE_EXTENSIONS_XLSX.equalsIgnoreCase(fileEntity.getFileType())) {
c.setFileType("2");
}
//pdf文件
else if (ReportConstants.FILE_EXTENSIONS_PDF.equalsIgnoreCase(fileEntity.getFileType())) {
c.setFileType("3");
}
//word文件
else {
c.setFileType("4");
}
//文件大小
c.setFileSize(StringUtils.isNotEmpty(fileEntity.getFileSize())
? String.valueOf(Integer.parseInt(fileEntity.getFileSize()) / 1024) + "kb" : "0kb");
c.setFileName(fileEntity.getFileName());
// list.getRecords().forEach(c -> {
// FileEntity fileEntity = Optional.ofNullable(fileDao.selectById(c.getFileId())).orElse(new FileEntity());
// if (StringUtils.isEmpty(fileEntity.getFileType())) {
// c.setFileType(null);
// }
// //ppt文件
// else if (ReportConstants.FILE_EXTENSIONS_PPT.equalsIgnoreCase(fileEntity.getFileType()) ||
// ReportConstants.FILE_EXTENSIONS_PPTX.equalsIgnoreCase(fileEntity.getFileType())) {
// c.setFileType("1");
// }
// //excel文件
// else if (ReportConstants.FILE_EXTENSIONS_XLS.equalsIgnoreCase(fileEntity.getFileType()) ||
// ReportConstants.FILE_EXTENSIONS_XLSX.equalsIgnoreCase(fileEntity.getFileType())) {
// c.setFileType("2");
// }
// //pdf文件
// else if (ReportConstants.FILE_EXTENSIONS_PDF.equalsIgnoreCase(fileEntity.getFileType())) {
// c.setFileType("3");
// }
// //word文件
// else {
// c.setFileType("4");
// }
//
// //文件大小
// c.setFileSize(StringUtils.isNotEmpty(fileEntity.getFileSize())
// ? 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()))
// .stream().map(ReportUserEntity::getUserId).collect(Collectors.toList());
});
// });
return list;
}
@@ -612,38 +634,38 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
}
});
list.getRecords().forEach(c -> {
FileEntity fileEntity = Optional.ofNullable(fileDao.selectById(c.getFileId())).orElse(new FileEntity());
if (StringUtils.isEmpty(fileEntity.getFileType())) {
c.setFileType(null);
}
//ppt文件
else if (ReportConstants.FILE_EXTENSIONS_PPT.equalsIgnoreCase(fileEntity.getFileType()) ||
ReportConstants.FILE_EXTENSIONS_PPTX.equalsIgnoreCase(fileEntity.getFileType())) {
c.setFileType("1");
}
//excel文件
else if (ReportConstants.FILE_EXTENSIONS_XLS.equalsIgnoreCase(fileEntity.getFileType()) ||
ReportConstants.FILE_EXTENSIONS_XLSX.equalsIgnoreCase(fileEntity.getFileType())) {
c.setFileType("2");
}
//pdf文件
else if (ReportConstants.FILE_EXTENSIONS_PDF.equalsIgnoreCase(fileEntity.getFileType())) {
c.setFileType("3");
}
//word文件
else {
c.setFileType("4");
}
//文件大小
c.setFileSize(StringUtils.isNotEmpty(fileEntity.getFileSize())
? String.valueOf(Integer.parseInt(fileEntity.getFileSize()) / 1024) + "kb" : "0kb");
c.setFileName(fileEntity.getFileName());
// list.getRecords().forEach(c -> {
// FileEntity fileEntity = Optional.ofNullable(fileDao.selectById(c.getFileId())).orElse(new FileEntity());
// if (StringUtils.isEmpty(fileEntity.getFileType())) {
// c.setFileType(null);
// }
// //ppt文件
// else if (ReportConstants.FILE_EXTENSIONS_PPT.equalsIgnoreCase(fileEntity.getFileType()) ||
// ReportConstants.FILE_EXTENSIONS_PPTX.equalsIgnoreCase(fileEntity.getFileType())) {
// c.setFileType("1");
// }
// //excel文件
// else if (ReportConstants.FILE_EXTENSIONS_XLS.equalsIgnoreCase(fileEntity.getFileType()) ||
// ReportConstants.FILE_EXTENSIONS_XLSX.equalsIgnoreCase(fileEntity.getFileType())) {
// c.setFileType("2");
// }
// //pdf文件
// else if (ReportConstants.FILE_EXTENSIONS_PDF.equalsIgnoreCase(fileEntity.getFileType())) {
// c.setFileType("3");
// }
// //word文件
// else {
// c.setFileType("4");
// }
//
// //文件大小
// c.setFileSize(StringUtils.isNotEmpty(fileEntity.getFileSize())
// ? 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()))
// .stream().map(ReportUserEntity::getUserId).collect(Collectors.toList());
});
// });
return list;
}
@@ -716,6 +738,22 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
@Override
public ResponseMessage reportDetail(String reportId) {
ReportDetailVo reportDetailVo = reportDao.reportDetail(reportId);
//设置文件信息
LambdaQueryWrapper<ReportFile> reportFileLambdaQueryWrapper = new LambdaQueryWrapper<>();
reportFileLambdaQueryWrapper.eq(ReportFile::getReportId, reportDetailVo.getId());
reportFileLambdaQueryWrapper.eq(ReportFile::getState, ReportConstants.NOT_IN_PROCESS);
List<ReportFile> reportFiles = reportFileDao.selectList(reportFileLambdaQueryWrapper);
List<String> fileIds = new ArrayList<>();
if (reportFiles != null) {
fileIds = reportFiles.stream().map(ReportFile::getFileId).collect(Collectors.toList());
}
if (CollectionUtils.isNotEmpty(fileIds)) {
List<FileEntity> fileEntities = fileDao.selectBatchIds(fileIds);
List<ReportFile> fileVos = BeanCopyUtils.copyBeanList(fileEntities, ReportFile.class);
reportDetailVo.setFileList(fileVos);
}
//设置部门名称
String department = reportDetailVo.getDepartment();
if (StrUtil.isNotBlank(department)) {
@@ -5,12 +5,14 @@ import cn.hutool.core.bean.BeanUtil;
import com.adc.da.login.util.UserUtils;
import com.adc.da.report.dao.mysql.PowerApplyDao;
import com.adc.da.report.dao.mysql.ReportDao;
import com.adc.da.report.dao.mysql.ReportFileDao;
import com.adc.da.report.dao.mysql.TtReportManageActDao;
import com.adc.da.report.eo.LogEntity;
import com.adc.da.report.eo.ReportEntity;
import com.adc.da.report.eo.TtReportManageAct;
import com.adc.da.report.service.ILogService;
import com.adc.da.report.service.IReportContentService;
import com.adc.da.report.service.IReportFileService;
import com.adc.da.report.service.ITtReportManageActService;
import com.adc.da.report.vo.DeleteParamRequestVO;
import com.adc.da.report.vo.TtReportManageActPageVO;
@@ -51,7 +53,11 @@ public class ITtReportManageActServiceImpl extends ServiceImpl<TtReportManageAct
@Resource
private IReportContentService iReportContentService;
@Autowired
private IReportFileService iReportFileService;
@Autowired
private ReportFileDao reportFileDao;
/**
* @param ttReportManageActPageVO
* @return <com.adc.da.report.entity.TtReportManageAct>
@@ -152,8 +158,12 @@ public class ITtReportManageActServiceImpl extends ServiceImpl<TtReportManageAct
reportDao.updateById(reportEntity1);
reportLog(reportEntity.getName(),"编辑");
}
// 文件
reportFileDao.actEndDelReport(ttReportManageAct.getDataId());
reportFileDao.updateState(ttReportManageAct.getDataId());
try {
iReportContentService.insertReportContent(ttReportManageAct.getDataId(), ttReportManageAct.getFileId());
iReportContentService.insertReportContent(ttReportManageAct.getDataId());
log.info("抽取报告内容");
} catch (IOException e) {
log.error("获取报告内容失败", e);
@@ -0,0 +1,22 @@
package com.adc.da.report.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.adc.da.report.eo.UserMessageEntity;
import com.adc.da.report.service.IUserMessageService;
import com.adc.da.report.dao.mysql.UserMessageDao;
import org.springframework.stereotype.Service;
/**
* @author ThinkBook
* @description 针对表【ts_user_message】的数据库操作Service实现
* @createDate 2023-05-23 11:30:04
*/
@Service
public class IUserMessageServiceImpl extends ServiceImpl<UserMessageDao, UserMessageEntity>
implements IUserMessageService {
}
@@ -5,11 +5,11 @@ import java.io.FileInputStream;
import java.io.IOException;
import com.adc.da.report.constant.ReportConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hslf.usermodel.HSLFShape;
import org.apache.poi.hslf.usermodel.HSLFSlide;
import org.apache.poi.hslf.usermodel.HSLFTextShape;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
@@ -22,7 +22,6 @@ import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.hslf.extractor.PowerPointExtractor;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
@@ -31,6 +30,7 @@ import org.apache.pdfbox.text.PDFTextStripper;
*
* @author caihaohan
*/
@Slf4j
public class FileContentUtil {
public static String readFileContent(File file) throws IOException {
@@ -39,7 +39,7 @@ public class FileContentUtil {
StringBuilder content = new StringBuilder();
FileInputStream fis = new FileInputStream(file);
try {
switch (fileExtension) {
case ReportConstants.FILE_EXTENSIONS_XLS:
HSSFWorkbook workbookXls = new HSSFWorkbook(fis);
@@ -87,7 +87,10 @@ public class FileContentUtil {
content = new StringBuilder(stripper.getText(document));
default:
}
} catch (Exception e) {
fis.close();
log.info("文件内容抽取失败,原因可能是上传的文件为空文件");
}
return content.toString();
}
@@ -10,6 +10,9 @@ import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* @author Caihaohan
@@ -24,6 +27,39 @@ public class LocalFileUtil {
@Value("${localFilePath}")
private String localFilePath;
public void compressFiles(List<String> filePaths, HttpServletResponse response) {
try {
// 创建输出流
OutputStream outputStream = response.getOutputStream();
ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);
byte[] buffer = new byte[1024];
for (String filePath : filePaths) {
File sourceFile = new File(filePath);
ZipEntry zipEntry = new ZipEntry(sourceFile.getName());
zipOutputStream.putNextEntry(zipEntry);
FileInputStream fileInputStream = new FileInputStream(sourceFile);
int len;
while ((len = fileInputStream.read(buffer)) > 0) {
zipOutputStream.write(buffer, 0, len);
}
fileInputStream.close();
zipOutputStream.closeEntry();
}
zipOutputStream.close();
System.out.println("文件成功压缩成ZIP格式并写入 HttpServletResponse");
} catch (IOException e) {
e.printStackTrace();
}
}
public void saveFile(InputStream fileInputStream, String fileName) throws IOException {
String path = localFilePath + fileName;
FileOutputStream fileOutputStream = new FileOutputStream(path);
@@ -21,6 +21,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.time.LocalDate;
@@ -52,10 +53,10 @@ public class WaterMarkUtil {
return configValue + " " + userName + " " + formattedDate;
}
public void addWatermarkToPdf(FileInputStream inputStream, HttpServletResponse response) throws IOException {
public PDDocument addWatermarkToPdf(FileInputStream inputStream) throws IOException {
String watermarkText = getWaterMarkConfig();
// 加载PDF文档
try (PDDocument document = PDDocument.load(inputStream)) {
PDDocument document = PDDocument.load(inputStream);
// 设置水印字体、字体大小、颜色和透明度
ClassPathResource fontResource = new ClassPathResource("fonts/SourceHanSerif-VF.ttf");
PDType0Font font = PDType0Font.load(document, fontResource.getInputStream());
@@ -90,11 +91,24 @@ public class WaterMarkUtil {
}
}
}
return document;
}
// 将处理后的PDF写入HTTP响应
public void savePdfToFile(FileInputStream inputStream, String outputPath) throws IOException {
PDDocument pdDocument = addWatermarkToPdf(inputStream);
try (FileOutputStream outputStream = new FileOutputStream(outputPath)) {
pdDocument.save(outputStream);
}
}
public void addWatermarkToPdfAndWriteToResponse(FileInputStream inputStream, HttpServletResponse response) throws IOException {
PDDocument document = addWatermarkToPdf(inputStream);
try (OutputStream outputStream = response.getOutputStream()) {
document.save(outputStream);
}
document.close();
}
}
}
@@ -0,0 +1,21 @@
package com.adc.da.report.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FileVo {
/**
* 文件主键id
*/
private String fileId;
/**
* 文件名
*/
private String fileName;
}
@@ -0,0 +1,41 @@
package com.adc.da.report.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
* @author: CaiHaohan
* @Date: 2023/5/23 14:14
* @Description:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MessageQueryVo {
/**
* 标题
*/
private String messageTitle;
/**
* 发布人姓名
*/
private String createUserName;
/**
* 页数
*/
@Min(1)
private int pageNo;
/**
* 每页数量
*/
@NotNull
private int pageSize;
}
@@ -0,0 +1,79 @@
package com.adc.da.report.vo;
import com.adc.da.report.constant.MessageTypeEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* @author: CaiHaohan
* @Date: 2023/5/23 11:54
* @Description:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class MessageVo {
/**
* 关系表的id
*/
private String id;
/**
* 标题
*/
private String messageTitle;
/**
* 内容
*/
private String content;
/**
* 消息类型
*/
private Integer messageType;
/**
* 消息类型
*/
private String messageTypeDesc;
/**
* 发布时间
*/
private Date createDate;
/**
* 创建用户id
*/
private String createUser;
/**
* 消息id
*/
private String messageId;
/**
* 阅读状态(0未读 1已读)
*/
private Integer readType;
public void setMessageType(Integer messageType) {
this.messageType = messageType;
switch (messageType) {
case 0:
this.messageTypeDesc = MessageTypeEnum.SYSTEM_MESSAGE.getDesc();
break;
default:
this.messageTypeDesc = "未知";
}
}
}
@@ -1,5 +1,7 @@
package com.adc.da.report.vo;
import com.adc.da.report.eo.ReportFile;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -65,13 +67,6 @@ public class ReportDetailVo {
*/
private String privacyLevel;
/**
* 文件id
*/
private String fileId;
private String fileName;
/**
* 创建人id
*/
@@ -111,4 +106,9 @@ public class ReportDetailVo {
* 保密到期日期
*/
private Date secrecyLast;
@TableField(exist = false)
private List<ReportFile> fileList;
}
@@ -1,5 +1,7 @@
package com.adc.da.report.vo;
import com.adc.da.report.eo.ReportFile;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.util.List;
@@ -46,16 +48,6 @@ public class ReportVo {
*/
private String year;
/**
* 文件id
*/
private String fileId;
/**
* 文件名称
*/
private String fileName;
/**
* 文件类型
*/
@@ -135,5 +127,6 @@ public class ReportVo {
private Integer isAct;
private String prcType;
@TableField(exist = false)
private List<ReportFile> fileList;
}
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.adc.da.report.dao.mysql.FileDao">
<select id="getDownloadFileIds" resultType="string">
SELECT
f.FILE_ID
FROM
`ts_file` AS f
LEFT JOIN ts_report_file AS rf ON f.FILE_ID = rf.file_id
WHERE
rf.report_id = #{reportId}
AND
f.FILE_TYPE != "xls"
AND
f.FILE_TYPE != "xlsx"
</select>
</mapper>
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.adc.da.report.dao.mysql.MessageDao">
<resultMap id="BaseResultMap" type="com.adc.da.report.eo.MessageEntity">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="content" column="content" jdbcType="VARCHAR"/>
<result property="messageType" column="message_type" jdbcType="TINYINT"/>
<result property="createDate" column="createDate" jdbcType="TIMESTAMP"/>
<result property="delFlag" column="del_flag" jdbcType="TINYINT"/>
</resultMap>
<sql id="Base_Column_List">
id,content,message_type,
createDate,del_flag
</sql>
<select id="listByUser" resultType="com.adc.da.report.vo.MessageVo">
SELECT
um.id AS Id,
um.user_id AS userId,
um.message_id AS messageId,
um.read_type AS readType,
m.message_title AS messageTitle,
m.content AS content,
m.message_type AS messageType,
m.createDate AS createDate,
m.createUser AS createUser
FROM
ts_user_message AS um
LEFT JOIN ts_message AS m ON um.message_id = m.id
LEFT JOIN ts_user AS u ON m.createUser = u.USID
WHERE
um.del_flag = 0
AND
um.user_id = #{userId}
<!--全文模糊搜索-->
<if test="vo.messageTitle !='' and vo.messageTitle != null">
AND m.message_title like CONCAT(CONCAT('%', #{vo.messageTitle}), '%')
</if>
<if test="vo.createUserName !='' and vo.createUserName != null">
AND u.USNAME like CONCAT(CONCAT('%', #{vo.createUserName}), '%')
</if>
ORDER BY
um.read_type ASC
</select>
</mapper>
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.adc.da.report.dao.mysql.ReportFileDao">
<update id="updateState">
update ts_report_file set state = 2
where report_id = #{reportId}
</update>
<delete id="actEndDelReport">
delete from ts_report_file
<where>
report_id = #{reportId}
and state = 2
</where>
</delete>
<delete id="delByReportId">
delete from ts_report_file
<where>
<if test="pageVO.reportId !=null and pageVO.reportId !=''">
AND report_id = #{pageVO.reportId}
</if>
<if test="pageVO.state !=null">
AND state = #{pageVO.state}
</if>
</where>
</delete>
<select id="selectByReport" resultType="com.adc.da.report.eo.ReportFile">
select rf.*,f.file_name as fileName from ts_report_file rf
LEFT JOIN ts_file f on f.FILE_ID = rf.file_id
<where>
<if test="pageVO.reportId !=null and pageVO.reportId !=''">
AND report_id = #{pageVO.reportId}
</if>
<if test="pageVO.state !=null">
AND state = #{pageVO.state}
</if>
</where>
</select>
</mapper>
@@ -1,15 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.adc.da.report.dao.mysql.ReportDao">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.adc.da.report.vo.ReportDetailVo">
<result column="id" property="id" />
<result column="name" property="name" />
<result column="uploaderName" property="uploaderName" />
<result column="keycontent" property="keyContent" />
<result column="maincontent" property="mainContent" />
<result column="department" property="department" />
<result column="departmentName" property="departmentName" />
<result column="year" property="year" />
<result column="confidentialLevel" property="confidentialLevel" />
<result column="privacyLevel" property="privacyLevel" />
<result column="createUserId" property="createUserId" />
<result column="secrecy_last" property="secrecyLast" />
<collection property="fileList" ofType="com.adc.da.report.eo.ReportFile">
<result column="fileId" property="fileId" />
<result column="fileName" property="fileName" />
<result column="rfId" property="id" />
</collection>
</resultMap>
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultReportVoMap" type="com.adc.da.report.vo.ReportVo">
<result column="id" property="id" />
<result column="name" property="name" />
<result column="keycontent" property="keyContent" />
<result column="maincontent" property="mainContent" />
<result column="department" property="department" />
<result column="year" property="year" />
<result column="confidentialLevel" property="confidentialLevel" />
<result column="privacyLevel" property="privacyLevel" />
<result column="createUserId" property="createUserId" />
<result column="uploader" property="uploader" />
<result column="createDate" property="createDate" />
<result column="thumbUp" property="thumbUp" />
<result column="clicks" property="clicks" />
<result column="download" property="download" />
<result column="reportRating" property="reportRating" />
<result column="isAct" property="isAct" />
<collection property="fileList" ofType="com.adc.da.report.eo.ReportFile">
<result column="fileId" property="fileId" />
<result column="fileName" property="fileName" />
<result column="rfId" property="id" />
</collection>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="BaseColumnList">
id, name, keycontent, maincontent, department, year, fileId, confidentialLevel, privacyLevel,
id, name, keycontent, maincontent, department, year, confidentialLevel, privacyLevel,
createUserId, createDate, updateDate, del_flag,secrecy_last
</sql>
<sql id="BaseColumnValue">
#{Vo.id},#{Vo.name},#{Vo.keycontent},#{Vo.maincontent},#{Vo.department},#{Vo.year},#{Vo.fileId},
#{Vo.id},#{Vo.name},#{Vo.keycontent},#{Vo.maincontent},#{Vo.department},#{Vo.year},
#{Vo.confidentialLevel},#{Vo.privacyLevel},
#{Vo.createUserId},
#{Vo.createDate},#{Vo.updateDate},#{Vo.del_flag},
@@ -19,7 +65,7 @@
<insert id="saveReportAct">
insert into TT_REPORT_MANAGE (<include refid="BaseColumnList"/>)
value (
#{Vo.dataId},#{Vo.name},#{Vo.keyContent},#{Vo.mainContent},#{Vo.department},#{Vo.year},#{Vo.fileId},
#{Vo.dataId},#{Vo.name},#{Vo.keyContent},#{Vo.mainContent},#{Vo.department},#{Vo.year},
#{Vo.confidentialLevel},#{Vo.privacyLevel},
#{Vo.createUserId},
#{Vo.createDate},#{Vo.updateDate},#{Vo.delFlag},
@@ -45,7 +91,6 @@
eo.maincontent,
eo.DEPARTMENT,
eo.YEAR,
eo.fileid,
eo.confidentialLevel,
eo.privacyLevel,
eo.createUserId,
@@ -91,7 +136,7 @@
</select>
<select id="page" resultType="com.adc.da.report.vo.ReportVo">
<select id="page" resultMap="BaseResultReportVoMap">
SELECT
eo.id AS id,
@@ -100,7 +145,6 @@
eo.maincontent AS mainContent,
eo.DEPARTMENT AS department,
eo.`YEAR` AS `year`,
eo.fileid AS fileId,
eo.confidentialLevel AS confidentialLevel,
eo.privacyLevel AS privacyLevel,
eo.createUserId AS createUserId,
@@ -113,6 +157,8 @@
IF(bpn.id is null,1,
IF(bpn.SUBMIT_STATUS = 1 and bpn.CREAT_USER = #{pageVO.usid} ,0,1)
) as isAct
,
f.FILE_ID as fileId, f.file_name as fileName ,rf.id as rfId
FROM
TT_REPORT_MANAGE eo
LEFT JOIN ts_report_content rc ON eo.id = rc.report_id
@@ -122,6 +168,8 @@
LEFT JOIN (SELECT report_id, COUNT(id) AS download FROM report_log_book WHERE type = 2 GROUP BY report_id) AS downloadCount ON eo.id = downloadCount.report_id
LEFT JOIN ts_report_user_rating AS trur ON eo.id = trur.report_id
LEFT JOIN bus_process_name as bpn on bpn.data_id = eo.id and bpn.prc_type != '5'
LEFT JOIN ts_report_file rf on rf.report_id = eo.id and rf.state = 2
LEFT JOIN ts_file f on f.FILE_ID = rf.file_id
WHERE
eo.DEL_FLAG = 0
<!--全文模糊搜索-->
@@ -175,7 +223,6 @@
t.year,
t.name,
t.keycontent,
t.fileId,
t.createDate,
t.department,
t.maincontent,
@@ -274,7 +321,7 @@
</select>
<select id="reportDetail" resultType="com.adc.da.report.vo.ReportDetailVo">
<select id="reportDetail" resultMap="BaseResultMap">
SELECT
rm.id AS id,
rm.name AS `name`,
@@ -284,18 +331,19 @@
rm.maincontent AS maincontent,
rm.department AS department,
rm.`year` AS `year`,
rm.fileId AS fileId,
f.file_name as fileName,
rm.confidentialLevel AS confidentialLevel,
rm.privacyLevel AS privacyLevel,
rm.secrecy_last AS secrecyLast
rm.secrecy_last AS secrecyLast,
f.FILE_ID as fileId, f.file_name as fileName ,rf.id as rfId
FROM `tt_report_manage` AS rm
LEFT JOIN ts_user AS u ON u.USID = rm.createUserId
LEFT JOIN ts_org as org on org.id = rm.department
LEFT JOIN ts_file as f on rm.fileId=f.file_id
LEFT JOIN ts_report_file rf on rf.report_id = rm.id and rf.state = 2
LEFT JOIN ts_file f on f.FILE_ID = rf.file_id
WHERE rm.id = #{reportId}
AND rm.del_flag = 0
</select>
<select id="selectDDL" resultType="com.adc.da.report.eo.ReportEntity">
SELECT * FROM tt_report_manage WHERE secrecy_last &lt;= NOW()
</select>
@@ -15,7 +15,6 @@
<result column="department" property="department" />
<result column="departmentName" property="departmentName" />
<result column="year" property="year" />
<result column="fileId" property="fileId" />
<result column="confidentialLevel" property="confidentialLevel" />
<result column="privacyLevel" property="privacyLevel" />
<result column="createUserId" property="createUserId" />
@@ -23,7 +22,11 @@
<result column="updateDate" property="updateDate" />
<result column="del_flag" property="delFlag" />
<result column="secrecy_last" property="secrecyLast" />
<result column="file_name" property="fileName" />
<collection property="fileList" ofType="com.adc.da.report.eo.ReportFile">
<result column="fileId" property="fileId" />
<result column="fileName" property="fileName" />
<result column="rfId" property="id" />
</collection>
</resultMap>
<!--表名信息-->
@@ -34,9 +37,9 @@
<!-- 通用查询结果列 -->
<sql id="BaseColumnList">
id,
task_id, prc_id, data_id,report_id ,name, keycontent, maincontent, department, year, fileId, confidentialLevel,
task_id, prc_id, data_id,report_id ,name, keycontent, maincontent, department, year, confidentialLevel,
privacyLevel, createUserId, createDate, updateDate, del_flag
,secrecy_last,file_name
,secrecy_last
</sql>
<!-- 查询条件 -->
@@ -71,9 +74,6 @@
<if test="pageVO.year !=null and pageVO.year !=''">
AND year LIKE CONCAT(CONCAT('%',#{pageVO.year}),'%')
</if>
<if test="pageVO.fileId !=null and pageVO.fileId !=''">
AND fileId LIKE CONCAT(CONCAT('%',#{pageVO.fileId}),'%')
</if>
<if test="pageVO.confidentialLevel !=null and pageVO.confidentialLevel !=''">
AND confidentialLevel LIKE CONCAT(CONCAT('%',#{pageVO.confidentialLevel}),'%')
</if>
@@ -133,12 +133,16 @@
<select id="selectByDataId" resultMap="BaseResultMap">
SELECT
a.id,
task_id, prc_id, data_id,report_id, name, keycontent, maincontent, department,
task_id, prc_id, data_id,a.report_id, name, keycontent, maincontent, department,
org.LONG_NAME as departmentName,
year, fileId, confidentialLevel, privacyLevel, createUserId, createDate, updateDate, del_flag
,secrecy_last,file_name
year,f.FILE_ID as fileId, f.file_name as fileName ,rf.id as rfId, confidentialLevel, privacyLevel, createUserId,
createDate,
updateDate, a.del_flag
,secrecy_last
FROM <include refid="TableName"/> a
LEFT JOIN ts_org org on a.department = org.id
LEFT JOIN ts_report_file rf on rf.report_id = a.data_id and rf.state = 1
LEFT JOIN ts_file f on f.FILE_ID = rf.file_id
<where>
data_id = #{dataId}
</where>
@@ -146,12 +150,16 @@
<select id="selectByPrcId" resultMap="BaseResultMap">
SELECT
a.id,
task_id, prc_id, data_id,report_id, name, keycontent, maincontent, department,
task_id, prc_id, data_id,a.report_id, name, keycontent, maincontent, department,
org.LONG_NAME as departmentName,
year, fileId, confidentialLevel, privacyLevel, createUserId, createDate, updateDate, del_flag
,secrecy_last,file_name
year,f.FILE_ID as fileId, f.file_name as fileName ,rf.id as rfId ,confidentialLevel, privacyLevel, createUserId,
createDate,
updateDate, a.del_flag
,secrecy_last
FROM <include refid="TableName"/> a
LEFT JOIN ts_org org on a.department = org.id
LEFT JOIN ts_report_file rf on rf.report_id = a.data_id and rf.state = 1
LEFT JOIN ts_file f on f.FILE_ID = rf.file_id
<where>
prc_id = #{prcId}
</where>
@@ -1,12 +1,15 @@
package com.adc.da.wkflow.business_activiti.service;
import com.adc.da.report.dao.mysql.PowerApplyActDao;
import com.adc.da.report.dao.mysql.ReportFileDao;
import com.adc.da.report.dao.mysql.ReportLabelDao;
import com.adc.da.report.dao.mysql.TtReportManageActDao;
import com.adc.da.report.eo.PowerApplyAct;
import com.adc.da.report.eo.ReportFile;
import com.adc.da.report.eo.ReportLabelEntity;
import com.adc.da.report.eo.TtReportManageAct;
import com.adc.da.report.service.IPowerApplyActService;
import com.adc.da.report.service.IReportFileService;
import com.adc.da.report.service.IReportLabelService;
import com.adc.da.report.service.ITtReportManageActService;
import com.adc.da.util.exception.AdcDaBaseException;
@@ -19,7 +22,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Service
public class ActivitDefineService {
@@ -42,7 +48,11 @@ public class ActivitDefineService {
private ReportLabelDao reportLabelDao;
@Autowired
private IReportLabelService iReportLabelService;
@Autowired
private IReportFileService iReportFileService;
@Autowired
private ReportFileDao reportFileDao;
//保存data数据
public String saveOrUpdateDate(String prcType, String dataJson,String taskId,String prcId,String reportId) {
if (StringUtils.isBlank(reportId)){
@@ -115,6 +125,17 @@ public class ActivitDefineService {
}
iReportLabelService.saveBatch(labelList);
}
// 文件
reportFileDao.delByReportId(new ReportFile(reportId,1));
List<ReportFile> reportFiles = new ArrayList<>();
for (ReportFile reportFile : ttReportManageAct.getFileList()) {
reportFile.setId(UUID.randomUUID().toString().replace("-",""));
reportFile.setReportId(ttReportManageAct.getDataId());
// reportFile.setFileId(s);
reportFile.setState(1);
reportFiles.add(reportFile);
}
iReportFileService.saveBatch(reportFiles);
}else if ("5".equals(prcType)){
// 编辑
TtReportManageAct ttReportManageAct = JSONObject.parseObject(dataJson, TtReportManageAct.class);
@@ -138,6 +159,17 @@ public class ActivitDefineService {
}
iReportLabelService.saveBatch(labelList);
}
// 文件
reportFileDao.delByReportId(new ReportFile(reportId,1));
List<ReportFile> reportFiles = new ArrayList<>();
for (ReportFile reportFile : ttReportManageAct.getFileList()) {
reportFile.setId(UUID.randomUUID().toString().replace("-",""));
reportFile.setReportId(ttReportManageAct.getDataId());
// reportFile.setFileId(s);
reportFile.setState(1);
reportFiles.add(reportFile);
}
iReportFileService.saveBatch(reportFiles);
}else {
throw new AdcDaBaseException("没有流程类型"+prcType);
}
@@ -2,11 +2,9 @@ package com.adc.da.wkflow.business_activiti.task;
import cn.hutool.core.util.StrUtil;
import com.adc.da.login.util.UserUtils;
import com.adc.da.report.dao.mysql.PowerApplyActDao;
import com.adc.da.report.dao.mysql.ReportDao;
import com.adc.da.report.dao.mysql.TreeLabelDao;
import com.adc.da.report.dao.mysql.TtReportManageActDao;
import com.adc.da.report.dao.mysql.*;
import com.adc.da.report.eo.ReportEntity;
import com.adc.da.report.eo.ReportFile;
import com.adc.da.report.eo.TtReportManageAct;
import com.adc.da.report.vo.PowerApplyActPageVO;
import com.adc.da.sys.service.iservice.IUserEoService;
@@ -87,6 +85,9 @@ public class TodoTaskController {
@Autowired
private TtReportManageActDao ttReportManageActDao;
@Autowired
private ReportFileDao reportFileDao;
@Autowired
private ReportDao reportDao;
@@ -619,6 +620,12 @@ public class TodoTaskController {
}else {
ttReportManageAct = ttReportManageActDao.selectByPrcId(pId);
}
// 为空说明流程已经结束
if (ttReportManageAct.getFileList().size() == 0){
List<ReportFile> reportFiles =
reportFileDao.selectByReport(new ReportFile(ttReportManageAct.getDataId(),2));
ttReportManageAct.setFileList(reportFiles);
}
List<String> labelList = treeLableDao.selectIdByReport(ttReportManageAct.getDataId());
ttReportManageAct.setLabelList(labelList);
String string = JSONArray.toJSONString(ttReportManageAct);
@@ -633,6 +640,12 @@ public class TodoTaskController {
}else {
ttReportManageAct = ttReportManageActDao.selectByPrcId(pId);
}
// 为空说明流程已经结束
if (ttReportManageAct.getFileList().size() == 0){
List<ReportFile> reportFiles =
reportFileDao.selectByReport(new ReportFile(ttReportManageAct.getDataId(),2));
ttReportManageAct.setFileList(reportFiles);
}
List<String> labelList = treeLableDao.selectIdByReport(ttReportManageAct.getDataId());
ttReportManageAct.setLabelList(labelList);
String string = JSONArray.toJSONString(ttReportManageAct);