初始化
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.adc.da.report.annotation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/10 13:24
|
||||
*/
|
||||
@Target({ java.lang.annotation.ElementType.METHOD })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ReportLog {
|
||||
String description();
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.adc.da.report.aspect;
|
||||
|
||||
import com.adc.da.login.util.CommonUtils;
|
||||
import com.adc.da.report.annotation.ReportLog;
|
||||
import com.adc.da.report.eo.LogEntity;
|
||||
import com.adc.da.report.service.ILogService;
|
||||
import com.adc.da.report.vo.ReportVo;
|
||||
import com.adc.da.sys.entity.UserEO;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.utils.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/10 13:18
|
||||
*/
|
||||
@Aspect
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ReportLogAspect {
|
||||
|
||||
@Resource
|
||||
private ILogService logService;
|
||||
|
||||
//@Pointcut("@annotation(com.adc.da.report.annotation.ReportLog)")
|
||||
@Pointcut(value = "(execution(* com.adc.da.report.controller.*.*(..)))")
|
||||
public void poput() {
|
||||
log.info("初始化切面完成");
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@Around(value = "poput()")
|
||||
public Object doArround(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
|
||||
Object obj = joinPoint.proceed();
|
||||
Object[] args = joinPoint.getArgs();
|
||||
String name = joinPoint.getSignature().getName();
|
||||
Class cs = joinPoint.getTarget().getClass();
|
||||
//获取类中的所有方法
|
||||
Method[] method = cs.getDeclaredMethods();
|
||||
//遍历方法
|
||||
for (Method method1 : method) {
|
||||
ReportLog reportLog = method1.getAnnotation(ReportLog.class);
|
||||
//如果是当前方法,并且方法上有ReportLog注解
|
||||
if (reportLog != null && method1.getName().equals(name)) {
|
||||
String description = reportLog.description();
|
||||
ResponseMessage returnValue = (ResponseMessage) obj;
|
||||
//判断是否正确返回
|
||||
if (returnValue.isOk()) {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
LogEntity entity = new LogEntity();
|
||||
|
||||
String account = Optional.ofNullable(CommonUtils.getUserInfo()).orElse(new UserEO()).getAccount();
|
||||
account = StringUtils.isEmpty(account) ? "未知用户" : account;
|
||||
entity.setAccount(account);
|
||||
entity.setClassName(cs.getName());
|
||||
entity.setOperateTime(format.format(new Date()));
|
||||
entity.setMethod(name);
|
||||
|
||||
entity.setUsid(CommonUtils.getUserId());
|
||||
//新增或者编辑操作
|
||||
if ("新增或编辑".equals(description)) {
|
||||
Map<String, String> map = (Map<String, String>) returnValue.getData();
|
||||
String reportName = map.get("reportName");
|
||||
entity.setReportName(reportName);
|
||||
ReportVo vo = (ReportVo) args[0];
|
||||
if (StringUtils.isNotEmpty(vo.getId())) {
|
||||
entity.setDescription("新增");
|
||||
} else {
|
||||
entity.setDescription("编辑");
|
||||
}
|
||||
logService.insert(entity);
|
||||
}
|
||||
//删除操作
|
||||
else {
|
||||
List<String> list = (List<String>) returnValue.getData();
|
||||
entity.setDescription(description);
|
||||
list.forEach(c -> {
|
||||
entity.setReportName(c);
|
||||
logService.insert(entity);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.adc.da.report.controller;
|
||||
|
||||
import com.adc.da.report.annotation.ReportLog;
|
||||
import com.adc.da.report.eo.LabelEntity;
|
||||
import com.adc.da.report.service.ILabelService;
|
||||
import com.adc.da.report.vo.LabelAllVo;
|
||||
import com.adc.da.report.vo.LabelVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.http.Result;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 13:46
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "标签管理")
|
||||
@RequestMapping("/${restPath}/label")
|
||||
public class LabelManageController {
|
||||
|
||||
|
||||
@Resource
|
||||
private ILabelService labelService;
|
||||
|
||||
/**
|
||||
* 新增或编辑标签
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("新增或编辑标签")
|
||||
@PostMapping("/add")
|
||||
public ResponseMessage add(@Valid @RequestBody LabelVo vo){
|
||||
LabelEntity entity=new LabelEntity();
|
||||
BeanUtils.copyProperties(vo,entity);
|
||||
labelService.insert(entity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation("上移|下移|置顶|置尾")
|
||||
@PostMapping("/move")
|
||||
public ResponseMessage move(String id,String type,String moveType){
|
||||
labelService.move(id,type,moveType);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签列表
|
||||
* @return
|
||||
* @throws ExecutionException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@ApiOperation("标签列表")
|
||||
@GetMapping("/list")
|
||||
public ResponseMessage list() throws ExecutionException, InterruptedException {
|
||||
Map<String, Object> list = labelService.list();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@ApiOperation("标签删除|单个")
|
||||
@PostMapping("/delete/{id}")
|
||||
public ResponseMessage delete(@PathVariable("id")String id){
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
String status="0";
|
||||
boolean isDelete = labelService.delete(id);
|
||||
if(!isDelete){
|
||||
status="1";
|
||||
}
|
||||
map.put("status",status);
|
||||
return Result.success(map);
|
||||
}
|
||||
|
||||
@ApiOperation("标签批量保存")
|
||||
@PostMapping("/save")
|
||||
public ResponseMessage save(@RequestBody LabelAllVo vo){
|
||||
labelService.save(vo);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.adc.da.report.controller;
|
||||
|
||||
import com.adc.da.report.service.ILogService;
|
||||
import com.adc.da.report.vo.LogVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.http.Result;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/10 14:00
|
||||
*/
|
||||
@Api(tags = "报告日志管理")
|
||||
@RequestMapping("/${restPath}/reportLog")
|
||||
@RestController
|
||||
public class ReportLogController {
|
||||
|
||||
@Resource
|
||||
private ILogService logService;
|
||||
|
||||
/**
|
||||
* 日志列表
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param doName
|
||||
* @param reportName
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
@ApiOperation("日志列表")
|
||||
@GetMapping("/list")
|
||||
public ResponseMessage list(int pageNo,int pageSize,String doName,String reportName
|
||||
,String startDate,String endDate) throws ParseException {
|
||||
|
||||
IPage<LogVo> list = logService.list(pageNo, pageSize, doName, reportName, startDate, endDate);
|
||||
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
package com.adc.da.report.controller;
|
||||
|
||||
import com.adc.da.report.annotation.ReportLog;
|
||||
import com.adc.da.report.eo.FileEntity;
|
||||
import com.adc.da.report.eo.ReportEntity;
|
||||
import com.adc.da.report.service.IFileService;
|
||||
import com.adc.da.report.service.IReportService;
|
||||
import com.adc.da.report.util.OSSClientUtil;
|
||||
import com.adc.da.report.vo.ReportQueryVo;
|
||||
import com.adc.da.report.vo.ReportVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.http.Result;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/4 14:26
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "报告管理")
|
||||
@RequestMapping("/${restPath}/report")
|
||||
public class ReportManageConroller {
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Value("${uploadFile}")
|
||||
private String uploadFile;
|
||||
|
||||
@Value("${picPath}")
|
||||
private String picPath;
|
||||
|
||||
@Resource
|
||||
private IFileService fileService;
|
||||
|
||||
@Resource
|
||||
private IReportService reportService;
|
||||
|
||||
@Resource
|
||||
private OSSClientUtil ossClientUtil;
|
||||
|
||||
|
||||
/**
|
||||
* 新增或编辑报告
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("新增或编辑报告")
|
||||
@PostMapping("/add")
|
||||
@ReportLog(description = "新增或编辑")
|
||||
public ResponseMessage add(@RequestBody ReportVo vo) {
|
||||
ReportEntity entity = new ReportEntity();
|
||||
BeanUtils.copyProperties(vo, entity);
|
||||
String name = reportService.insert(entity);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("reportName", name);
|
||||
return Result.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 报告列表
|
||||
* @param vo
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@ApiOperation("报告列表")
|
||||
@PostMapping("/list")
|
||||
public ResponseMessage list(@RequestBody ReportQueryVo vo) throws Exception {
|
||||
IPage<ReportVo> list = reportService.list(vo);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除报告
|
||||
* @param ids id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("删除报告")
|
||||
@PostMapping("/delete")
|
||||
@ReportLog(description = "删除")
|
||||
public ResponseMessage delete(String ids) {
|
||||
List<String> nameList = reportService.delete(ids);
|
||||
return Result.success(nameList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取报告日期列表
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@ApiOperation("获取报告日期列表")
|
||||
@GetMapping("/reportDateList")
|
||||
public ResponseMessage reportDateList() throws Exception {
|
||||
List<String> reportDateList = reportService.getReportDateList();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("list", reportDateList);
|
||||
return Result.success(map);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取报告预览
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("获取报告预览")
|
||||
@GetMapping("/getReportHtml/{id}")
|
||||
public ResponseMessage getReportHtml(@PathVariable("id") String id) {
|
||||
String html = reportService.reportHtml(id);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("content", html);
|
||||
return Result.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试
|
||||
*/
|
||||
@ApiOperation("testtest")
|
||||
@GetMapping("/test")
|
||||
@Deprecated
|
||||
public void ttt() {
|
||||
stringRedisTemplate.boundValueOps("1121212").set("1212");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param file
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@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=ossClientUtil.uploadFile2OSS(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);
|
||||
return Result.success(resultMap);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
* @param file
|
||||
* @param request
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@ApiOperation(value = "上传图片")
|
||||
@PostMapping("/uploadPicFile")
|
||||
public ResponseMessage<Map<String, Object>> uploadPicFile(MultipartFile file, HttpServletRequest request) throws IOException {
|
||||
|
||||
try (InputStream input = file.getInputStream()) {
|
||||
Map<String, Object> resultMap = new HashMap();
|
||||
String path = uploadFile;//此路径映射到localhost
|
||||
File files = new File(path);
|
||||
String realName = file.getOriginalFilename();
|
||||
if (!files.exists()) {
|
||||
files.mkdirs();
|
||||
}
|
||||
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.split("\\.")[1];
|
||||
fileName = date + num + "." + ext;
|
||||
log.info("fileName>>" + fileName);
|
||||
File dirFile = new File(path, fileName);
|
||||
log.info("dir.exists()>>" + dirFile.exists());
|
||||
if (!dirFile.exists()) {
|
||||
boolean newFile = dirFile.createNewFile();
|
||||
if(!newFile){
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
try (OutputStream output = new FileOutputStream(dirFile)) {
|
||||
byte[] bt = new byte[1024 * 1024];
|
||||
int len = 0;
|
||||
while ((len = input.read(bt)) != -1) {
|
||||
output.write(bt, 0, len);
|
||||
}
|
||||
resultMap.put("key", date + num);
|
||||
resultMap.put("value", picPath + "/" + fileName);
|
||||
resultMap.put("name", realName);
|
||||
FileEntity entity = new FileEntity();
|
||||
entity.setContentType(contentType);
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setFileName(realName);
|
||||
entity.setFileSize(String.valueOf(file.getSize()));
|
||||
entity.setFileId(date + num);
|
||||
entity.setSavePath(picPath + "/" + fileName);
|
||||
fileService.addFile(entity);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return Result.success(resultMap);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
* @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());
|
||||
ossClientUtil.downloadFileFromOSS(entity.getSavePath(),response);
|
||||
|
||||
} catch (Exception ex) {
|
||||
log.info(ex.getMessage(),ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.adc.da.report.dao.mysql;
|
||||
|
||||
import com.adc.da.report.eo.FileEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/6/28 15:19
|
||||
*/
|
||||
public interface FileDao extends BaseMapper<FileEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.adc.da.report.dao.mysql;
|
||||
|
||||
import com.adc.da.report.eo.LabelEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 13:53
|
||||
*/
|
||||
public interface LabelDao extends BaseMapper<LabelEntity> {
|
||||
|
||||
int getMaxNum(@Param("type")String type);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.adc.da.report.dao.mysql;
|
||||
|
||||
import com.adc.da.report.eo.LogEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/10 13:55
|
||||
*/
|
||||
public interface LogDao extends BaseMapper<LogEntity> {
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.adc.da.report.dao.mysql;
|
||||
|
||||
import com.adc.da.report.eo.ReportEntity;
|
||||
import com.adc.da.report.vo.ReportQueryVo;
|
||||
import com.adc.da.report.vo.ReportVo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 08:35
|
||||
*/
|
||||
public interface ReportDao extends BaseMapper<ReportEntity> {
|
||||
|
||||
/**
|
||||
* 报告列表
|
||||
* @param page
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
IPage<ReportVo> list(IPage page, @Param("Vo") ReportQueryVo vo);
|
||||
|
||||
/**
|
||||
* 报告日期列表
|
||||
* @param usid
|
||||
* @return
|
||||
*/
|
||||
List<String> getReportDateList(@Param("usid")String usid);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.adc.da.report.dao.mysql;
|
||||
|
||||
import com.adc.da.report.eo.ReportUserEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 09:03
|
||||
*/
|
||||
public interface ReportUserDao extends BaseMapper<ReportUserEntity> {
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
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.Date;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/6/28 14:32
|
||||
*/
|
||||
@Data
|
||||
@TableName("TS_FILE")
|
||||
public class FileEntity {
|
||||
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
@TableId(value = "FILE_ID",type = IdType.INPUT)
|
||||
private String fileId;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@TableField("CONTENT_TYPE")
|
||||
private String contentType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("CREATE_TIME")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
@TableField("FILE_NAME")
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文件后缀
|
||||
*/
|
||||
@TableField("FILE_TYPE")
|
||||
private String fileType;
|
||||
|
||||
/**
|
||||
* 存储路径
|
||||
*/
|
||||
@TableField("SAVE_PATH")
|
||||
private String savePath;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("USER_ID")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
@TableField("FILE_SIZE")
|
||||
private String fileSize;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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 lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 13:49
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("TS_LABEL")
|
||||
public class LabelEntity {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id",type = IdType.INPUT)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 标签名
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 标签类型
|
||||
*/
|
||||
@TableField("type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
@TableField("parentId")
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("createDate")
|
||||
private String createDate;
|
||||
|
||||
@TableField("orderNum")
|
||||
private int orderNum;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
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.Date;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/10 13:49
|
||||
*/
|
||||
@Data
|
||||
@TableName("TS_LOG")
|
||||
public class LogEntity {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "ID",type = IdType.AUTO)
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
@TableField("ACCOUNT")
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 类名
|
||||
*/
|
||||
@TableField("CLASS_NAME")
|
||||
private String className;
|
||||
|
||||
/**
|
||||
* 操作
|
||||
*/
|
||||
@TableField("DESCRIPTION")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 方法名
|
||||
*/
|
||||
@TableField("METHOD")
|
||||
private String method;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
@TableField("OPERATE_TIME")
|
||||
private String operateTime;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@TableField("START_TIME")
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@TableField("END_TIME")
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 浏览器
|
||||
*/
|
||||
@TableField("BROWSER")
|
||||
private String browser;
|
||||
|
||||
/**
|
||||
* ipaddress
|
||||
*/
|
||||
@TableField("IP_ADDRESS")
|
||||
private String ipAddress;
|
||||
|
||||
/**
|
||||
* 用户姓名
|
||||
*/
|
||||
@TableField("USER_NAME")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("USID")
|
||||
private String usid;
|
||||
|
||||
/**
|
||||
* 报告名称
|
||||
*/
|
||||
@TableField("REPORTNAME")
|
||||
private String reportName;
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
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.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 08:16
|
||||
*/
|
||||
@Data
|
||||
@TableName("TT_REPORT_MANAGE")
|
||||
public class ReportEntity {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id",type = IdType.INPUT)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 报告名
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 关键字
|
||||
*/
|
||||
@TableField("keycontent")
|
||||
private String keyContent;
|
||||
|
||||
/**
|
||||
* 主要内容
|
||||
*/
|
||||
@TableField("maincontent")
|
||||
private String mainContent;
|
||||
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
@TableField("department")
|
||||
private String department;
|
||||
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
@TableField("year")
|
||||
private String year;
|
||||
|
||||
/**
|
||||
* 标签1id
|
||||
*/
|
||||
@TableField("labelOneId")
|
||||
private String labelOneId;
|
||||
|
||||
/**
|
||||
* 标签2id
|
||||
*/
|
||||
@TableField("labelTwoId")
|
||||
private String labelTwoId;
|
||||
|
||||
/**
|
||||
* 标签3id
|
||||
*/
|
||||
@TableField("labelThreeId")
|
||||
private String labelThreeId;
|
||||
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
@TableField("fileId")
|
||||
private String fileId;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField("createUserId")
|
||||
private String createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("createDate")
|
||||
private String createDate;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField("updateDate")
|
||||
private String updateDate;
|
||||
|
||||
/**
|
||||
* 删除标志
|
||||
*/
|
||||
@TableField("del_flag")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 用户id列表
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<String> reportUserIdList;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.adc.da.report.eo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 08:58
|
||||
*/
|
||||
@Data
|
||||
@TableName("TR_REPORT_USER")
|
||||
public class ReportUserEntity {
|
||||
|
||||
/**
|
||||
* 报告id
|
||||
*/
|
||||
@TableField("reportId")
|
||||
private String reportId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("userId")
|
||||
private String userId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.adc.da.report.service;
|
||||
|
||||
|
||||
import com.adc.da.report.eo.FileEntity;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/8/2 14:09
|
||||
*/
|
||||
public interface IFileService {
|
||||
|
||||
/**
|
||||
* 新增文件
|
||||
* @param entity
|
||||
*/
|
||||
void addFile(FileEntity entity);
|
||||
|
||||
/**
|
||||
* 根据文件id获取文件
|
||||
* @param fileId
|
||||
* @return
|
||||
*/
|
||||
FileEntity getFile(String fileId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.adc.da.report.service;
|
||||
|
||||
import com.adc.da.report.eo.LabelEntity;
|
||||
import com.adc.da.report.vo.LabelAllVo;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 13:53
|
||||
*/
|
||||
public interface ILabelService {
|
||||
|
||||
/**
|
||||
* 插入或编辑标签
|
||||
* @param entity
|
||||
*/
|
||||
void insert(LabelEntity entity);
|
||||
|
||||
/**
|
||||
* 标签列表展示
|
||||
* @return
|
||||
* @throws ExecutionException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
Map<String,Object> list() throws ExecutionException, InterruptedException;
|
||||
|
||||
/**
|
||||
* 标签删除
|
||||
* @param id
|
||||
*/
|
||||
boolean delete(String id);
|
||||
|
||||
void save(LabelAllVo vo);
|
||||
|
||||
void move(String id,String type,String moveType);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.adc.da.report.service;
|
||||
|
||||
import com.adc.da.report.eo.LogEntity;
|
||||
import com.adc.da.report.vo.LogVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/10 13:57
|
||||
*/
|
||||
public interface ILogService {
|
||||
|
||||
/**
|
||||
* 插入日志
|
||||
* @param entity
|
||||
*/
|
||||
void insert(LogEntity entity);
|
||||
|
||||
/**
|
||||
* 日志列表
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param doName
|
||||
* @param reportName
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
IPage<LogVo> list(int pageNo,int pageSize,String doName,String reportName
|
||||
,String startDate,String endDate) throws ParseException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.adc.da.report.service;
|
||||
|
||||
import com.adc.da.report.eo.ReportEntity;
|
||||
import com.adc.da.report.vo.ReportQueryVo;
|
||||
import com.adc.da.report.vo.ReportVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 08:37
|
||||
*/
|
||||
public interface IReportService {
|
||||
|
||||
/**
|
||||
* 新增或编辑报告
|
||||
* @param entity
|
||||
* @return 报告名称
|
||||
*/
|
||||
String insert(ReportEntity entity);
|
||||
|
||||
/**
|
||||
* 报告列表展示
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
IPage<ReportVo> list(ReportQueryVo vo) throws Exception;
|
||||
|
||||
/**
|
||||
* 删除报告
|
||||
* @param ids
|
||||
*/
|
||||
List<String> delete(String ids);
|
||||
|
||||
/**
|
||||
* 获取日期列表
|
||||
* @return
|
||||
*/
|
||||
List<String> getReportDateList() throws Exception;
|
||||
|
||||
/**
|
||||
* 获取报告htmlString
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
String reportHtml(String id);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.adc.da.report.service.impl;
|
||||
|
||||
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 org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/8 15:00
|
||||
*/
|
||||
@Service
|
||||
public class IFileServiceImpl implements IFileService {
|
||||
|
||||
@Resource
|
||||
private FileDao fileDao;
|
||||
|
||||
|
||||
/**
|
||||
* 添加文件
|
||||
* @param entity
|
||||
*/
|
||||
@Override
|
||||
public void addFile(FileEntity entity) {
|
||||
fileDao.insert(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件id获取文件
|
||||
* @param fileId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public FileEntity getFile(String fileId) {
|
||||
FileEntity fileEntity = fileDao.selectById(fileId);
|
||||
return fileEntity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,330 @@
|
||||
package com.adc.da.report.service.impl;
|
||||
|
||||
import com.adc.da.login.util.CommonUtils;
|
||||
import com.adc.da.report.dao.mysql.LabelDao;
|
||||
import com.adc.da.report.dao.mysql.ReportDao;
|
||||
import com.adc.da.report.eo.LabelEntity;
|
||||
import com.adc.da.report.eo.ReportEntity;
|
||||
import com.adc.da.report.service.ILabelService;
|
||||
import com.adc.da.report.vo.LabelAllVo;
|
||||
import com.adc.da.report.vo.LabelVo;
|
||||
import com.adc.da.sys.vo.LabelReturnVo;
|
||||
import com.adc.da.util.exception.AdcDaBaseException;
|
||||
import com.adc.da.util.utils.StringUtils;
|
||||
import com.adc.da.util.utils.UUID;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 13:58
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ILabelServiceImpl implements ILabelService {
|
||||
|
||||
@Resource
|
||||
private LabelDao labelDao;
|
||||
|
||||
@Resource
|
||||
private ReportDao reportDao;
|
||||
|
||||
/**
|
||||
* 新增或编辑标签
|
||||
*
|
||||
* @param entity
|
||||
*/
|
||||
@Override
|
||||
public void insert(LabelEntity entity) {
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
if (!"0".equals(entity.getParentId())) {
|
||||
int count = labelDao.selectCount(new QueryWrapper<LabelEntity>()
|
||||
.eq("id", entity.getParentId()));
|
||||
if (count == 0) {
|
||||
throw new AdcDaBaseException("父标签不存在");
|
||||
}
|
||||
|
||||
}
|
||||
if (StringUtils.isEmpty(entity.getId())) {
|
||||
entity.setId(UUID.randomUUID10());
|
||||
entity.setCreateDate(format.format(new Date()));
|
||||
if (!"0".equals(entity.getParentId())) {
|
||||
int maxNum = labelDao.getMaxNum(entity.getType());
|
||||
entity.setOrderNum(maxNum + 1);
|
||||
}
|
||||
labelDao.insert(entity);
|
||||
} else {
|
||||
LabelEntity labelEntity = labelDao.selectById(entity.getId());
|
||||
entity.setOrderNum(labelEntity.getOrderNum());
|
||||
labelDao.updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签列表
|
||||
*
|
||||
* @return
|
||||
* @throws ExecutionException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> list() throws ExecutionException, InterruptedException {
|
||||
//找到三类标签
|
||||
List<LabelReturnVo> lableList = CommonUtils.getLableList();
|
||||
|
||||
CompletableFuture[] completableFuture = new CompletableFuture[lableList.size()];
|
||||
|
||||
Map<String, Object> reMap = new ConcurrentHashMap<>();
|
||||
|
||||
//标签类型遍历
|
||||
for (int i = 0; i < lableList.size(); i++) {
|
||||
|
||||
int j = i;
|
||||
|
||||
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
||||
String value = lableList.get(j).getValue();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
//父标签
|
||||
LabelEntity entity = labelDao.selectOne(new QueryWrapper<LabelEntity>()
|
||||
.eq("type", value).eq("parentId", "0"));
|
||||
//标签大类的名称
|
||||
map.put("name", entity.getName());
|
||||
map.put("id", entity.getId());
|
||||
map.put("type", entity.getType());
|
||||
map.put("parentId", "0");
|
||||
|
||||
|
||||
//父标签下所有的子标签
|
||||
List<LabelEntity> childList = labelDao.selectList(
|
||||
new QueryWrapper<LabelEntity>().eq("parentId", entity.getId()).orderByAsc("orderNum"));
|
||||
List<Map<String, Object>> child = childList.stream().map(c -> {
|
||||
Map<String, Object> detailmap = new HashMap<>();
|
||||
detailmap.put("id", c.getId());
|
||||
detailmap.put("name", c.getName());
|
||||
detailmap.put("type", c.getType());
|
||||
//标签是否被使用
|
||||
detailmap.put("status", isBeUsed(c.getId()));
|
||||
detailmap.put("parentId", c.getParentId());
|
||||
return detailmap;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
map.put("childList", child);
|
||||
reMap.put(lableList.get(j).getName(), map);
|
||||
log.info(lableList.get(j).getName() + "---------执行完成-------");
|
||||
}, CommonUtils.threadPoolExecutor());
|
||||
|
||||
completableFuture[i] = future;
|
||||
|
||||
}
|
||||
CompletableFuture.allOf(completableFuture).get();
|
||||
return reMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标签
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean delete(String id) {
|
||||
LabelEntity labelEntity = labelDao.selectById(id);
|
||||
int currentNum = labelEntity.getOrderNum();
|
||||
int maxNum=labelDao.getMaxNum(labelEntity.getType());
|
||||
List<LabelEntity> labelList = labelDao.selectList(new QueryWrapper<LabelEntity>().gt("orderNum", currentNum)
|
||||
.le("orderNum", maxNum));
|
||||
for (LabelEntity entity : labelList) {
|
||||
entity.setOrderNum(entity.getOrderNum()-1);
|
||||
labelDao.updateById(entity);
|
||||
}
|
||||
labelDao.delete(new QueryWrapper<LabelEntity>().eq("id", id));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存标签
|
||||
*
|
||||
* @param vo
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(LabelAllVo vo) {
|
||||
|
||||
List<String> allIdList = new ArrayList<>();
|
||||
|
||||
//更新所有的父标签
|
||||
vo.getLabelList().forEach(c -> {
|
||||
LabelEntity entity = new LabelEntity();
|
||||
BeanUtils.copyProperties(c, entity);
|
||||
labelDao.updateById(entity);
|
||||
//更新子标签
|
||||
List<String> idList = childListSave(c.getChildList());
|
||||
allIdList.add(entity.getId());
|
||||
allIdList.addAll(idList);
|
||||
});
|
||||
|
||||
//删除标签
|
||||
labelDao.delete(new QueryWrapper<LabelEntity>().notIn("id", allIdList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 子标签更新
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
private List<String> childListSave(List<LabelVo> list) {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
List<String> idList = new ArrayList<>();
|
||||
list.forEach(c -> {
|
||||
LabelEntity entity = new LabelEntity();
|
||||
BeanUtils.copyProperties(c, entity);
|
||||
if (StringUtils.isEmpty(entity.getId())) {
|
||||
entity.setId(UUID.randomUUID10());
|
||||
entity.setCreateDate(format.format(new Date()));
|
||||
if (!"0".equals(entity.getParentId())) {
|
||||
int maxNum = labelDao.getMaxNum(entity.getType());
|
||||
entity.setOrderNum(maxNum + 1);
|
||||
}
|
||||
labelDao.insert(entity);
|
||||
} else {
|
||||
LabelEntity labelEntity = labelDao.selectById(entity.getId());
|
||||
entity.setOrderNum(labelEntity.getOrderNum());
|
||||
labelDao.updateById(entity);
|
||||
}
|
||||
idList.add(entity.getId());
|
||||
});
|
||||
return idList;
|
||||
}
|
||||
|
||||
private String isBeUsed(String labelId) {
|
||||
int count = reportDao.selectCount(new QueryWrapper<ReportEntity>().eq("labelOneId", labelId)
|
||||
.or(c -> c.eq("labelTwoId", labelId).or(f -> f.eq("labelThreeId", labelId))));
|
||||
if (count > 0) {
|
||||
return "1";
|
||||
} else {
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void move(String id, String type, String moveType) {
|
||||
synchronized (this) {
|
||||
switch (moveType) {
|
||||
//上移
|
||||
case "up":
|
||||
up(id,type);
|
||||
break;
|
||||
//下移
|
||||
case "down":
|
||||
down(id,type);
|
||||
break;
|
||||
//置顶
|
||||
case "top":
|
||||
top(id,type);
|
||||
break;
|
||||
//置尾
|
||||
case "last":
|
||||
last(id,type);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上移
|
||||
* @param id
|
||||
* @param type
|
||||
*/
|
||||
private void up(String id, String type){
|
||||
LabelEntity labelEntity = labelDao.selectById(id);
|
||||
if(!"1".equals(labelEntity.getOrderNum())){
|
||||
int currentNum=labelEntity.getOrderNum();
|
||||
int preNum=labelEntity.getOrderNum()-1;
|
||||
LabelEntity preEntity = labelDao.selectOne(new QueryWrapper<LabelEntity>().eq("type", type)
|
||||
.eq("orderNum", preNum));
|
||||
//将当前数据上移
|
||||
labelEntity.setOrderNum(preNum);
|
||||
labelDao.updateById(labelEntity);
|
||||
|
||||
//将原先数据下移一位
|
||||
preEntity.setOrderNum(currentNum);
|
||||
labelDao.updateById(preEntity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下移
|
||||
* @param id
|
||||
* @param type
|
||||
*/
|
||||
private void down(String id, String type){
|
||||
LabelEntity labelEntity = labelDao.selectById(id);
|
||||
int maxNum = labelDao.getMaxNum(type);
|
||||
if(maxNum!=labelEntity.getOrderNum()){
|
||||
int nextNum=labelEntity.getOrderNum()+1;
|
||||
int currentNum=labelEntity.getOrderNum();
|
||||
|
||||
//将原先数据上移一位
|
||||
|
||||
LabelEntity nextEntity = labelDao.selectOne(new QueryWrapper<LabelEntity>().eq("type", type)
|
||||
.eq("orderNum", nextNum));
|
||||
nextEntity.setOrderNum(currentNum);
|
||||
labelDao.updateById(nextEntity);
|
||||
|
||||
//将当前数据下移
|
||||
labelEntity.setOrderNum(nextNum);
|
||||
labelDao.updateById(labelEntity);
|
||||
}
|
||||
}
|
||||
|
||||
private void top(String id, String type){
|
||||
LabelEntity labelEntity = labelDao.selectById(id);
|
||||
int currentNum = labelEntity.getOrderNum();
|
||||
List<LabelEntity> labelList = labelDao.selectList(new QueryWrapper<LabelEntity>().lt("orderNum", currentNum)
|
||||
.gt("orderNum", 0).eq("type", type).orderByAsc("orderNum"));
|
||||
|
||||
for (int i = 0; i < labelList.size(); i++) {
|
||||
LabelEntity entity = labelList.get(i);
|
||||
entity.setOrderNum(i+2);
|
||||
labelDao.updateById(entity);
|
||||
}
|
||||
|
||||
labelEntity.setOrderNum(1);
|
||||
labelDao.updateById(labelEntity);
|
||||
}
|
||||
|
||||
private void last(String id, String type){
|
||||
LabelEntity labelEntity = labelDao.selectById(id);
|
||||
int currentNum = labelEntity.getOrderNum();
|
||||
int maxNum = labelDao.getMaxNum(type);
|
||||
List<LabelEntity> labelList = labelDao.selectList(new QueryWrapper<LabelEntity>().le("orderNum", maxNum)
|
||||
.gt("orderNum", currentNum).eq("type", type).orderByAsc("orderNum"));
|
||||
|
||||
for (int i = 0; i < labelList.size(); i++) {
|
||||
LabelEntity entity = labelList.get(i);
|
||||
entity.setOrderNum(entity.getOrderNum()-1);
|
||||
labelDao.updateById(entity);
|
||||
}
|
||||
|
||||
labelEntity.setOrderNum(maxNum);
|
||||
labelDao.updateById(labelEntity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.adc.da.report.service.impl;
|
||||
|
||||
import com.adc.da.report.dao.mysql.LogDao;
|
||||
import com.adc.da.report.eo.LogEntity;
|
||||
import com.adc.da.report.service.ILogService;
|
||||
import com.adc.da.report.vo.LogVo;
|
||||
import com.adc.da.util.utils.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/10 13:59
|
||||
*/
|
||||
@Service
|
||||
public class ILogServiceImpl implements ILogService {
|
||||
|
||||
@Resource
|
||||
private LogDao logDao;
|
||||
|
||||
/**
|
||||
* 添加报告日志
|
||||
*
|
||||
* @param entity
|
||||
*/
|
||||
@Override
|
||||
public void insert(LogEntity entity) {
|
||||
logDao.insert(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 报告日志列表
|
||||
*
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param doName
|
||||
* @param reportName
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public IPage<LogVo> list(int pageNo, int pageSize, String doName, String reportName
|
||||
, String startDate, String endDate) {
|
||||
IPage page = new Page<>();
|
||||
page.setSize(pageSize);
|
||||
page.setCurrent(pageNo);
|
||||
|
||||
//初始化wrapper
|
||||
QueryWrapper<LogEntity> wrapper = new QueryWrapper();
|
||||
|
||||
|
||||
if (StringUtils.isNotEmpty(doName)) {
|
||||
//操作名称分割
|
||||
String[] doList = doName.split(",");
|
||||
//遍历名称
|
||||
switch (doList.length) {
|
||||
case 1:
|
||||
wrapper.and(c -> c.like("DESCRIPTION", doList[0]));
|
||||
break;
|
||||
case 2:
|
||||
wrapper.and(c -> c.like("DESCRIPTION", doList[0]).or().like("DESCRIPTION", doList[1]));
|
||||
break;
|
||||
case 3:
|
||||
wrapper.and(c -> c.like("DESCRIPTION", doList[0]).or()
|
||||
.like("DESCRIPTION", doList[1]).or().like("DESCRIPTION", doList[2]));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//报告名称
|
||||
if (StringUtils.isNotEmpty(reportName)) {
|
||||
wrapper.and(c -> c.like("REPORTNAME", reportName));
|
||||
}
|
||||
//开始时间
|
||||
if (StringUtils.isNotEmpty(startDate)) {
|
||||
wrapper.and(c -> c.ge("OPERATE_TIME", startDate));
|
||||
}
|
||||
|
||||
//结束时间
|
||||
if (StringUtils.isNotEmpty(endDate)) {
|
||||
wrapper.and(c -> c.le("OPERATE_TIME", endDate + "23:59:59"));
|
||||
}
|
||||
//操作时间排序
|
||||
wrapper.orderByDesc("OPERATE_TIME");
|
||||
|
||||
IPage<LogEntity> pageList = logDao.selectPage(page, wrapper);
|
||||
|
||||
IPage<LogVo> retuPage = new Page<>();
|
||||
BeanUtils.copyProperties(pageList, retuPage);
|
||||
//返回值映射vo
|
||||
List<LogVo> voList = pageList.getRecords().stream().map(c -> {
|
||||
LogVo vo = new LogVo();
|
||||
BeanUtils.copyProperties(c, vo);
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
retuPage.setRecords(voList);
|
||||
return retuPage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
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.ReportUserDao;
|
||||
import com.adc.da.report.eo.FileEntity;
|
||||
import com.adc.da.report.eo.ReportEntity;
|
||||
import com.adc.da.report.eo.ReportUserEntity;
|
||||
import com.adc.da.report.service.IReportService;
|
||||
import com.adc.da.report.util.*;
|
||||
import com.adc.da.report.vo.ReportQueryVo;
|
||||
import com.adc.da.report.vo.ReportVo;
|
||||
import com.adc.da.util.utils.FileUtil;
|
||||
import com.adc.da.util.utils.StringUtils;
|
||||
import com.adc.da.util.utils.UUID;
|
||||
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.Value;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
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;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 08:37
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IReportServiceImpl implements IReportService {
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
private ReportDao reportDao;
|
||||
|
||||
@Resource
|
||||
private ReportUserDao reportUserDao;
|
||||
|
||||
@Resource
|
||||
private FileDao fileDao;
|
||||
|
||||
@Value("${uploadFile}")
|
||||
private String uploadFile;
|
||||
|
||||
@Value("${IPANDPORT}")
|
||||
private String ipAddress;
|
||||
|
||||
@Resource
|
||||
private OSSClientUtil ossClientUtil;
|
||||
|
||||
/**
|
||||
* 新增或编辑报告
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String insert(ReportEntity entity) {
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
if (StringUtils.isEmpty(entity.getId())) {
|
||||
entity.setId(UUID.randomUUID10());
|
||||
entity.setCreateDate(format.format(new Date()));
|
||||
entity.setCreateUserId(CommonUtils.getUserId());
|
||||
entity.setDelFlag("0");
|
||||
entity.setUpdateDate(format.format(new Date()));
|
||||
reportDao.insert(entity);
|
||||
|
||||
//插入用户关系表
|
||||
entity.getReportUserIdList().forEach(c -> {
|
||||
ReportUserEntity reportUserEntity = new ReportUserEntity();
|
||||
reportUserEntity.setReportId(entity.getId());
|
||||
reportUserEntity.setUserId(c);
|
||||
reportUserDao.insert(reportUserEntity);
|
||||
});
|
||||
|
||||
CommonUtils.threadPoolExecutor().execute(() -> {
|
||||
//生成html
|
||||
try {
|
||||
String htmlString = createHtmlString(entity.getFileId());
|
||||
|
||||
log.info("执行完成html" + htmlString);
|
||||
|
||||
//key:报告id-文件id
|
||||
String key = entity.getId() + "-" + entity.getFileId();
|
||||
stringRedisTemplate.boundValueOps(key).set(htmlString);
|
||||
log.info(key + "已经存好");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
entity.setUpdateDate(format.format(new Date()));
|
||||
reportDao.updateById(entity);
|
||||
reportUserDao.delete(new QueryWrapper<ReportUserEntity>()
|
||||
.eq("reportId", entity.getId()));
|
||||
|
||||
//插入用户关系表
|
||||
entity.getReportUserIdList().forEach(c -> {
|
||||
ReportUserEntity reportUserEntity = new ReportUserEntity();
|
||||
reportUserEntity.setReportId(entity.getId());
|
||||
reportUserEntity.setUserId(c);
|
||||
reportUserDao.insert(reportUserEntity);
|
||||
});
|
||||
|
||||
CommonUtils.threadPoolExecutor().execute(() -> {
|
||||
String key = entity.getId() + "-" + entity.getFileId();
|
||||
Boolean hasKey = stringRedisTemplate.hasKey(key);
|
||||
if (!hasKey) {
|
||||
String htmlString = null;
|
||||
try {
|
||||
htmlString = createHtmlString(entity.getFileId());
|
||||
stringRedisTemplate.boundValueOps(key).set(htmlString);
|
||||
log.info(key + "已经更新");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
} else {
|
||||
log.info(key + "存在不需要更新");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 报告列表
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public IPage<ReportVo> list(ReportQueryVo vo) throws Exception {
|
||||
|
||||
IPage<ReportEntity> page = new Page<>();
|
||||
page.setCurrent(vo.getPageNo());
|
||||
page.setSize(vo.getPageSize());
|
||||
|
||||
//判断是不是管理员
|
||||
boolean admin = CommonUtils.isAdmin();
|
||||
if (admin) {
|
||||
vo.setUsid(null);
|
||||
} else {
|
||||
vo.setUsid(CommonUtils.getUserId());
|
||||
}
|
||||
|
||||
|
||||
IPage<ReportVo> list = reportDao.list(page, vo);
|
||||
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 ("ppt".equals(fileEntity.getFileType().toLowerCase()) || "pptx".equals(fileEntity.getFileType())) {
|
||||
c.setFileType("1");
|
||||
}
|
||||
//excel文件
|
||||
else if ("xls".equals(fileEntity.getFileType().toLowerCase()) || "xlsx".equals(fileEntity.getFileType())) {
|
||||
c.setFileType("2");
|
||||
}
|
||||
//pdf文件
|
||||
else if ("pdf".equals(fileEntity.getFileType().toLowerCase())) {
|
||||
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());
|
||||
c.setReportUserIdList(userIdList);
|
||||
});
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 报告删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<String> delete(String ids) {
|
||||
List<String> nameList = new ArrayList<>();
|
||||
String[] idList = ids.split(",");
|
||||
for (String id : idList) {
|
||||
ReportEntity entity = reportDao.selectById(id);
|
||||
entity.setDelFlag("1");
|
||||
reportDao.updateById(entity);
|
||||
//删除redis中的key
|
||||
String key = entity.getId() + "-" + entity.getFileId();
|
||||
stringRedisTemplate.delete(key);
|
||||
log.info(key + "已经删除");
|
||||
nameList.add(entity.getName());
|
||||
}
|
||||
return nameList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 报告日期列表
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public List<String> getReportDateList() throws Exception {
|
||||
String userId = CommonUtils.getUserId();
|
||||
boolean admin = CommonUtils.isAdmin();
|
||||
if (admin) {
|
||||
userId = null;
|
||||
}
|
||||
return reportDao.getReportDateList(userId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 报告html
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String reportHtml(String id) {
|
||||
try {
|
||||
ReportEntity entity = reportDao.selectById(id);
|
||||
String key = entity.getId() + "-" + entity.getFileId();
|
||||
String html = stringRedisTemplate.boundValueOps(key).get();
|
||||
return html;
|
||||
} catch (Exception ex) {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建htmlstring
|
||||
*
|
||||
* @param fileId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String createHtmlString(String fileId) throws Exception {
|
||||
FileEntity fileEntity = fileDao.selectById(fileId);
|
||||
String path = uploadFile + fileEntity.getSavePath();
|
||||
FileOutputStream outputStream = new FileOutputStream(path);
|
||||
ossClientUtil.getFileFromOSS(fileEntity.getSavePath(), outputStream);
|
||||
|
||||
String html = null;
|
||||
switch (fileEntity.getFileType()) {
|
||||
//03excel
|
||||
case "xls":
|
||||
html = ExcelUtil.excel03Html(new FileInputStream(path));
|
||||
break;
|
||||
//07excel
|
||||
case "xlsx":
|
||||
html = ExcelUtil.excel07Html(new FileInputStream(path));
|
||||
break;
|
||||
//03word
|
||||
case "doc":
|
||||
html = WordUtil.doc2pdf(new FileInputStream(path), uploadFile, ipAddress);
|
||||
break;
|
||||
//07word
|
||||
case "docx":
|
||||
html = WordUtil.doc2pdf(new FileInputStream(path), uploadFile, ipAddress);
|
||||
break;
|
||||
//03ppt
|
||||
case "ppt":
|
||||
html = PptUtil.doPpt2003toImage(new FileInputStream(path), uploadFile, ipAddress);
|
||||
break;
|
||||
//07ppt
|
||||
case "pptx":
|
||||
html = PptUtil.doPpt2007toImage(new FileInputStream(path), uploadFile, ipAddress);
|
||||
break;
|
||||
//pdf
|
||||
case "pdf":
|
||||
html = PdfUtil.pdfStreamToPng(new FileInputStream(path), uploadFile, ipAddress);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
FileUtil.deleteFile(path);
|
||||
return html;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.adc.da.report.util;
|
||||
|
||||
import cn.afterturn.easypoi.cache.manager.POICacheManager;
|
||||
import cn.afterturn.easypoi.excel.ExcelXorHtmlUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExcelToHtmlParams;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/11 10:06
|
||||
*/
|
||||
public class ExcelUtil {
|
||||
|
||||
private ExcelUtil(){
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
/**
|
||||
* 07 版本EXCEL预览
|
||||
* @param filePath
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws InvalidFormatException
|
||||
*/
|
||||
public static String excel07Html(InputStream inputStream) throws IOException, InvalidFormatException {
|
||||
ExcelToHtmlParams params = new ExcelToHtmlParams(WorkbookFactory.create(
|
||||
inputStream));
|
||||
return ExcelXorHtmlUtil.excelToHtml(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 03 版本EXCEL预览
|
||||
* @param filePath
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws InvalidFormatException
|
||||
*/
|
||||
public static String excel03Html(InputStream inputStream) throws IOException, InvalidFormatException {
|
||||
ExcelToHtmlParams params = new ExcelToHtmlParams(WorkbookFactory.create(
|
||||
inputStream));
|
||||
return ExcelXorHtmlUtil.excelToHtml(params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
package com.adc.da.report.util;
|
||||
|
||||
import com.adc.da.util.exception.AdcDaBaseException;
|
||||
import com.adc.da.util.utils.DateUtils;
|
||||
import com.adc.da.util.utils.StringUtils;
|
||||
import com.aliyun.oss.ClientException;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.OSSException;
|
||||
import com.aliyun.oss.model.*;
|
||||
import lombok.Data;
|
||||
import lombok.extern.log4j.Log4j;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName: Hematopathy
|
||||
* @Package: com.jeeplus.oss.utils
|
||||
* @ClassName: OSSUtil
|
||||
* @Author: MC
|
||||
* @Description: ${description}
|
||||
* @Date: 2019/11/16 0016 10:34
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
@Data
|
||||
@Slf4j
|
||||
public class OSSClientUtil {
|
||||
@Value("${aliyun.OSS.endpoint}")
|
||||
private String endpoint;
|
||||
@Value("${aliyun.OSS.accessKeyId}")
|
||||
private String accessKeyId;
|
||||
@Value("${aliyun.OSS.accessKeySecret}")
|
||||
private String accessKeySecret;
|
||||
//空间
|
||||
@Value("${aliyun.OSS.bucketName}")
|
||||
private String bucketName;
|
||||
//文件存储目录
|
||||
@Value("${uploadFile}")
|
||||
private String filedir;
|
||||
|
||||
|
||||
/**
|
||||
* 上传到OSS服务器 如果同名文件会覆盖服务器上的
|
||||
*
|
||||
* @param instream 文件流
|
||||
* @param fileName 文件名称 包括后缀名
|
||||
* @return 出错返回"" ,唯一MD5数字签名
|
||||
*/
|
||||
public String uploadFile2OSS(InputStream instream, String fileName) {
|
||||
|
||||
// 创建OSSClient实例。
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
PutObjectResult putObjectResult = new PutObjectResult();
|
||||
try {
|
||||
putObjectResult = ossClient.putObject(bucketName, fileName, instream);
|
||||
} catch (OSSException oe) {
|
||||
System.out.println("Caught an OSSException, which means your request made it to OSS, "
|
||||
+ "but was rejected with an error response for some reason.");
|
||||
System.out.println("Error Message:" + oe.getErrorMessage());
|
||||
System.out.println("Error Code:" + oe.getErrorCode());
|
||||
System.out.println("Request ID:" + oe.getRequestId());
|
||||
System.out.println("Host ID:" + oe.getHostId());
|
||||
throw new AdcDaBaseException("OSS连接失败: "+ oe.getErrorMessage());
|
||||
} catch (ClientException ce) {
|
||||
System.out.println("Caught an ClientException, which means the client encountered "
|
||||
+ "a serious internal problem while trying to communicate with OSS, "
|
||||
+ "such as not being able to access the network.");
|
||||
System.out.println("Error Message:" + ce.getMessage());
|
||||
throw new AdcDaBaseException("OSS连接失败,请检查网络");
|
||||
} finally {
|
||||
if (ossClient != null) {
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
return putObjectResult.getRequestId();
|
||||
}
|
||||
|
||||
public void downloadFileFromOSS(String objectName,HttpServletResponse response) throws IOException {
|
||||
// 创建OSSClient实例。
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
PutObjectResult putObjectResult = new PutObjectResult();
|
||||
try {
|
||||
// 调用ossClient.getObject返回一个OSSObject实例,该实例包含文件内容及文件元信息。
|
||||
OSSObject ossObject = ossClient.getObject(bucketName, objectName);
|
||||
// 调用ossObject.getObjectContent获取文件输入流,可读取此输入流获取其内容。
|
||||
InputStream content = ossObject.getObjectContent();
|
||||
if (content != null) {
|
||||
byte[] bt = new byte[1024 * 1024];
|
||||
int len = 0;
|
||||
while ((len = content.read(bt)) != -1) {
|
||||
response.getOutputStream().write(bt, 0, len);
|
||||
}
|
||||
// 数据读取完成后,获取的流必须关闭,否则会造成连接泄漏,导致请求无连接可用,程序无法正常工作。
|
||||
content.close();
|
||||
response.getOutputStream().close();
|
||||
}
|
||||
} catch (OSSException oe) {
|
||||
System.out.println("Caught an OSSException, which means your request made it to OSS, "
|
||||
+ "but was rejected with an error response for some reason.");
|
||||
System.out.println("Error Message:" + oe.getErrorMessage());
|
||||
System.out.println("Error Code:" + oe.getErrorCode());
|
||||
System.out.println("Request ID:" + oe.getRequestId());
|
||||
System.out.println("Host ID:" + oe.getHostId());
|
||||
throw new AdcDaBaseException("OSS连接失败: "+ oe.getErrorMessage());
|
||||
} catch (ClientException ce) {
|
||||
System.out.println("Caught an ClientException, which means the client encountered "
|
||||
+ "a serious internal problem while trying to communicate with OSS, "
|
||||
+ "such as not being able to access the network.");
|
||||
System.out.println("Error Message:" + ce.getMessage());
|
||||
throw new AdcDaBaseException("OSS连接失败,请检查网络");
|
||||
|
||||
} finally {
|
||||
if (ossClient != null) {
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getFileFromOSS(String objectName,FileOutputStream outputStream) throws IOException {
|
||||
// 创建OSSClient实例。
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
PutObjectResult putObjectResult = new PutObjectResult();
|
||||
try {
|
||||
// 调用ossClient.getObject返回一个OSSObject实例,该实例包含文件内容及文件元信息。
|
||||
OSSObject ossObject = ossClient.getObject(bucketName, objectName);
|
||||
// 调用ossObject.getObjectContent获取文件输入流,可读取此输入流获取其内容。
|
||||
InputStream content = ossObject.getObjectContent();
|
||||
if (content != null) {
|
||||
byte[] bt = new byte[1024 * 1024];
|
||||
int len = 0;
|
||||
while ((len = content.read(bt)) != -1) {
|
||||
outputStream.write(bt, 0, len);
|
||||
}
|
||||
// 数据读取完成后,获取的流必须关闭,否则会造成连接泄漏,导致请求无连接可用,程序无法正常工作。
|
||||
content.close();
|
||||
outputStream.close();
|
||||
}
|
||||
} catch (OSSException oe) {
|
||||
System.out.println("Caught an OSSException, which means your request made it to OSS, "
|
||||
+ "but was rejected with an error response for some reason.");
|
||||
System.out.println("Error Message:" + oe.getErrorMessage());
|
||||
System.out.println("Error Code:" + oe.getErrorCode());
|
||||
System.out.println("Request ID:" + oe.getRequestId());
|
||||
System.out.println("Host ID:" + oe.getHostId());
|
||||
throw new AdcDaBaseException("OSS连接失败: "+ oe.getErrorMessage());
|
||||
} catch (ClientException ce) {
|
||||
System.out.println("Caught an ClientException, which means the client encountered "
|
||||
+ "a serious internal problem while trying to communicate with OSS, "
|
||||
+ "such as not being able to access the network.");
|
||||
System.out.println("Error Message:" + ce.getMessage());
|
||||
throw new AdcDaBaseException("OSS连接失败,请检查网络");
|
||||
} finally {
|
||||
if (ossClient != null) {
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Description: 判断OSS服务文件上传时文件的contentType
|
||||
*
|
||||
* @param FilenameExtension 文件后缀
|
||||
* @return String
|
||||
*/
|
||||
public static String getcontentType(String FilenameExtension) {
|
||||
if (FilenameExtension.equalsIgnoreCase(".bmp")) {
|
||||
return "image/bmp";
|
||||
}
|
||||
if (FilenameExtension.equalsIgnoreCase(".gif")) {
|
||||
return "image/gif";
|
||||
}
|
||||
if (FilenameExtension.equalsIgnoreCase(".jpeg") ||
|
||||
FilenameExtension.equalsIgnoreCase(".jpg") ||
|
||||
FilenameExtension.equalsIgnoreCase(".png")) {
|
||||
return "image/jpeg";
|
||||
}
|
||||
if (FilenameExtension.equalsIgnoreCase(".html")) {
|
||||
return "text/html";
|
||||
}
|
||||
if (FilenameExtension.equalsIgnoreCase(".txt")) {
|
||||
return "text/plain";
|
||||
}
|
||||
if (FilenameExtension.equalsIgnoreCase(".vsd")) {
|
||||
return "application/vnd.visio";
|
||||
}
|
||||
if (FilenameExtension.equalsIgnoreCase(".pptx") ||
|
||||
FilenameExtension.equalsIgnoreCase(".ppt")) {
|
||||
return "application/vnd.ms-powerpoint";
|
||||
}
|
||||
if (FilenameExtension.equalsIgnoreCase(".docx") ||
|
||||
FilenameExtension.equalsIgnoreCase(".doc")) {
|
||||
return "application/msword";
|
||||
}
|
||||
if (FilenameExtension.equalsIgnoreCase(".xml")) {
|
||||
return "text/xml";
|
||||
}
|
||||
return "image/jpeg";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得url链接
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public String getUrl(String key, OSS ossClient) {
|
||||
// 设置URL过期时间为10年 3600l* 1000*24*365*10
|
||||
Date nowDate = new Date();
|
||||
long time = nowDate.getTime();
|
||||
Date expiration = new Date(time + 3600L * 1000 * 24 * 365 * 10);
|
||||
// 生成URL
|
||||
URL url = ossClient.generatePresignedUrl(bucketName, key, expiration);
|
||||
if (url != null) {
|
||||
return url.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除某个Object
|
||||
* http://127.0.0.1:8080/a/oss/del?url= sys/2019-11-16MC11:34:52.png
|
||||
*
|
||||
* @param bucketUrl
|
||||
* @return
|
||||
*/
|
||||
public boolean deleteObject(String bucketUrl, OSS ossClient) {
|
||||
// try {
|
||||
// boolean b = ossClient.doesObjectExist(bucketName, bucketUrl);
|
||||
// System.out.println("查询文件是否存在:"+b + "=================================");
|
||||
// if(!b){
|
||||
// System.out.println("Error: OSS file not find,file:{} ===============");
|
||||
// return false;
|
||||
// }
|
||||
// // 删除Object.
|
||||
// ossClient.deleteObject(bucketName, bucketUrl);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return false;
|
||||
// } finally {
|
||||
// this.destory(ossClient);
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 删除多个Object
|
||||
// *
|
||||
// * @param bucketUrls
|
||||
// * @return
|
||||
// */
|
||||
// public boolean deleteObjects(List<String> bucketUrls,OSS ossClient) {
|
||||
// try {
|
||||
// // 删除Object.
|
||||
// DeleteObjectsResult deleteObjectsResult = ossClient.deleteObjects(new DeleteObjectsRequest(bucketName).withKeys(bucketUrls));
|
||||
// List<String> deletedObjects = deleteObjectsResult.getDeletedObjects();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.adc.da.report.util;
|
||||
|
||||
import com.adc.da.util.utils.UUID;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.rendering.PDFRenderer;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class PdfUtil {
|
||||
|
||||
|
||||
private PdfUtil(){
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
/**
|
||||
* 截取pdf成图片
|
||||
* @param inputStream
|
||||
* @param targetPath
|
||||
* @param ipAddress
|
||||
* @return
|
||||
*/
|
||||
public static String pdfStreamToPng( InputStream inputStream,String targetPath,String ipAddress) {
|
||||
|
||||
try(PDDocument doc=PDDocument.load( inputStream)) {
|
||||
PDFRenderer renderer = new PDFRenderer(doc);
|
||||
List<String> list=new ArrayList<>();
|
||||
int pageCount = doc.getNumberOfPages();
|
||||
BufferedImage image = null;
|
||||
log.info("开始时间"+System.currentTimeMillis());
|
||||
String fileName = UUID.randomUUID10();
|
||||
for (int i = 0; i < pageCount; i++) {
|
||||
image = renderer.renderImage(i, 2.0f);
|
||||
image.flush();
|
||||
|
||||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||
ImageOutputStream imOut;
|
||||
imOut = ImageIO.createImageOutputStream(bs);
|
||||
ImageIO.write(image, "png", imOut);
|
||||
|
||||
try(ByteArrayInputStream byteInputStream = new ByteArrayInputStream(bs.toByteArray());){
|
||||
File ff=new File(targetPath+"/"+fileName);
|
||||
if(!ff.exists()){
|
||||
ff.mkdirs();
|
||||
}
|
||||
File uploadFile = new File(targetPath+"/"+fileName+"/"+i+".png");
|
||||
try(FileOutputStream fops = new FileOutputStream(uploadFile);){
|
||||
fops.write(readInputStream(byteInputStream));
|
||||
}
|
||||
catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
list.add(ipAddress+"api/home/pic"+"/"+fileName+"/"+i+".png");
|
||||
}
|
||||
catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
log.info("结束时间"+System.currentTimeMillis());
|
||||
|
||||
String htmlByBase64 = createHtmlByImg(list);
|
||||
return htmlByBase64;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static String createHtmlByImg(List<String> baseList) {
|
||||
// 输入HTML文件内容
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("<!doctype html>\r\n");
|
||||
buffer.append("<head>\r\n");
|
||||
buffer.append("<meta charset=\"UTF-8\">\r\n");
|
||||
buffer.append("</head>\r\n");
|
||||
buffer.append("<body style=\"background-color:gray;\">\r\n");
|
||||
buffer.append("<style>\r\n");
|
||||
buffer.append("img {background-color:#fff; text-align:center; width:100%; max-width:100%;margin-top:6px;}\r\n");
|
||||
buffer.append("</style>\r\n");
|
||||
for(int i=0;i<baseList.size();i++){
|
||||
buffer.append("<img src="+baseList.get(i)+" />");
|
||||
}
|
||||
|
||||
buffer.append("</body></html>");
|
||||
try {
|
||||
return buffer.toString();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// public static void main(String[] args) throws IOException {
|
||||
// pdfStreamToPng("/Users/sxh/00000000000000000产品决策文件及代码/111.pdf","/Users/sxh/EPR/test/",null);
|
||||
// }
|
||||
|
||||
|
||||
public static byte[] readInputStream(InputStream inStream) throws Exception {
|
||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024*1024];
|
||||
int len = 0;
|
||||
while ((len = inStream.read(buffer)) != -1) {
|
||||
outStream.write(buffer, 0, len);
|
||||
}
|
||||
inStream.close();
|
||||
return outStream.toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
package com.adc.da.report.util;
|
||||
|
||||
import com.adc.da.util.utils.UUID;
|
||||
import lombok.Data;
|
||||
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.HSLFSlideShow;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
import org.apache.poi.sl.usermodel.Shape;
|
||||
import org.apache.poi.xslf.usermodel.*;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/10/26 10:04
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class PptUtil {
|
||||
|
||||
private PptUtil(){
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ppt2003转图片
|
||||
* @param inputStream
|
||||
* @param targetPath
|
||||
* @param ipAddress
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String doPpt2003toImage(InputStream inputStream,String targetPath,String ipAddress) throws Exception {
|
||||
|
||||
try(FileInputStream is = (FileInputStream) inputStream) {
|
||||
HSLFSlideShow ppt =new HSLFSlideShow(is);
|
||||
Dimension pgsize = ppt.getPageSize();
|
||||
List<HSLFSlide> slides = ppt.getSlides();
|
||||
|
||||
double scale = 3;
|
||||
|
||||
int width = (int) (pgsize.width * scale);
|
||||
int height = (int) (pgsize.height * scale);
|
||||
|
||||
List<String> baseList=new ArrayList<>();
|
||||
String fileName = UUID.randomUUID10();
|
||||
for (int i = 0; i < slides.size(); i++) {
|
||||
|
||||
List<HSLFShape> shapes = slides.get(i).getShapes();
|
||||
for (Shape shape : shapes) {
|
||||
if (shape instanceof TextShape) {
|
||||
TextShape sh = (TextShape) shape;
|
||||
List<TextParagraph> textParagraphs = sh.getTextParagraphs();
|
||||
for (TextParagraph xslfTextParagraph : textParagraphs) {
|
||||
List<TextRun> textRuns = xslfTextParagraph.getTextRuns();
|
||||
for (TextRun xslfTextRun : textRuns) {
|
||||
xslfTextRun.setFontFamily("宋体");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BufferedImage img = new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
Graphics2D graphics = img.createGraphics();
|
||||
graphics.setPaint(Color.white);
|
||||
graphics.fill(new Rectangle2D.Float(0, 0, width, height));
|
||||
|
||||
// 最核心的代码
|
||||
graphics.scale(scale, scale);
|
||||
|
||||
slides.get(i).draw(graphics);
|
||||
|
||||
|
||||
try(ByteArrayOutputStream bs = new ByteArrayOutputStream();){
|
||||
ImageOutputStream imOut=ImageIO.createImageOutputStream(bs);
|
||||
ImageIO.write(img, "png", imOut);
|
||||
|
||||
File ff=new File(targetPath+fileName);
|
||||
if(!ff.exists()){
|
||||
ff.mkdirs();
|
||||
}
|
||||
File uploadFile = new File(targetPath+fileName+"/"+i+".png");
|
||||
|
||||
try( InputStream byteInputStream = new ByteArrayInputStream(bs.toByteArray());
|
||||
FileOutputStream fops = new FileOutputStream(uploadFile)){
|
||||
fops.write(readInputStream(byteInputStream));
|
||||
}
|
||||
catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
baseList.add(ipAddress+"api/home/pic"+"/"+fileName+"/"+i+".png");
|
||||
|
||||
}
|
||||
catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
String html = createHtmlByImg(baseList);
|
||||
return html;
|
||||
} catch (FileNotFoundException e) {
|
||||
log.error(e.getMessage(),e);
|
||||
return "";
|
||||
} catch (IOException e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ppt2007转图片
|
||||
* @param inputStream
|
||||
* @param targetPath
|
||||
* @param ipAddress
|
||||
* @return
|
||||
*/
|
||||
public static String doPpt2007toImage(InputStream inputStream,String targetPath,String ipAddress) {
|
||||
try( FileInputStream is=(FileInputStream)inputStream;) {
|
||||
XMLSlideShow xmlSlideShow = new XMLSlideShow(is);
|
||||
// 获取大小
|
||||
Dimension pgsize = xmlSlideShow.getPageSize();
|
||||
// 获取幻灯片
|
||||
List<XSLFSlide> slides = xmlSlideShow.getSlides();
|
||||
double scale = 3;
|
||||
|
||||
int width = (int) (pgsize.width * scale);
|
||||
int height = (int) (pgsize.height * scale);
|
||||
|
||||
List<String> baseList=new ArrayList<>();
|
||||
String fileName = UUID.randomUUID10();
|
||||
for (int i = 0 ; i < slides.size() ; i++) {
|
||||
// 解决乱码问题
|
||||
List<XSLFShape> shapes = slides.get(i).getShapes();
|
||||
for (XSLFShape shape : shapes) {
|
||||
if (shape instanceof XSLFTextShape) {
|
||||
XSLFTextShape sh = (XSLFTextShape) shape;
|
||||
List<XSLFTextParagraph> textParagraphs = sh.getTextParagraphs();
|
||||
for (XSLFTextParagraph xslfTextParagraph : textParagraphs) {
|
||||
List<XSLFTextRun> textRuns = xslfTextParagraph.getTextRuns();
|
||||
for (XSLFTextRun xslfTextRun : textRuns) {
|
||||
xslfTextRun.setFontFamily("宋体");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(shape instanceof XSLFTable){
|
||||
XSLFTable sh=(XSLFTable) shape;
|
||||
List<XSLFTableRow> rows = sh.getRows();
|
||||
rows.forEach(c->{
|
||||
List<XSLFTableCell> cells = c.getCells();
|
||||
cells.forEach(a->{
|
||||
List<XSLFTextParagraph> textParagraphs = a.getTextParagraphs();
|
||||
for (XSLFTextParagraph xslfTextParagraph : textParagraphs) {
|
||||
List<XSLFTextRun> textRuns = xslfTextParagraph.getTextRuns();
|
||||
for (XSLFTextRun xslfTextRun : textRuns) {
|
||||
xslfTextRun.setFontFamily("宋体");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//根据幻灯片大小生成图片
|
||||
BufferedImage img = new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D graphics = img.createGraphics();
|
||||
graphics.setPaint(Color.white);
|
||||
graphics.fill(new Rectangle2D.Float(0, 0, width,height));
|
||||
// 最核心的代码
|
||||
graphics.scale(scale, scale);
|
||||
|
||||
slides.get(i).draw(graphics);
|
||||
|
||||
try(ByteArrayOutputStream bs = new ByteArrayOutputStream();){
|
||||
ImageOutputStream imOut=ImageIO.createImageOutputStream(bs);
|
||||
ImageIO.write(img, "png", imOut);
|
||||
|
||||
File ff=new File(targetPath+"/"+fileName);
|
||||
if(!ff.exists()){
|
||||
ff.mkdirs();
|
||||
}
|
||||
File uploadFile = new File(targetPath+"/"+fileName+"/"+i+".png");
|
||||
|
||||
try( InputStream byteInputStream = new ByteArrayInputStream(bs.toByteArray());
|
||||
FileOutputStream fops = new FileOutputStream(uploadFile)){
|
||||
fops.write(readInputStream(byteInputStream));
|
||||
}
|
||||
catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
baseList.add(ipAddress+"api/home/pic"+"/"+fileName+"/"+i+".png");
|
||||
|
||||
}
|
||||
catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
System.out.print("PPT转换成图片 成功!");
|
||||
return createHtmlByImg(baseList);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
// log.error("PPT转换成图片 发生异常!", e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
// public static void main(String[] args) {
|
||||
// System.out.println(doPpt2007toImage("/Users/sxh/00000000000000000产品决策文件及代码/1111.pptx",null,null));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 创建图片拼接html
|
||||
* @param baseList
|
||||
* @return
|
||||
*/
|
||||
private static String createHtmlByImg(List<String> baseList) {
|
||||
// 输入HTML文件内容
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("<!doctype html>\r\n");
|
||||
buffer.append("<head>\r\n");
|
||||
buffer.append("<meta charset=\"UTF-8\">\r\n");
|
||||
buffer.append("</head>\r\n");
|
||||
buffer.append("<body style=\"background-color:gray;\">\r\n");
|
||||
buffer.append("<style>\r\n");
|
||||
buffer.append("img {background-color:#fff; text-align:center; width:100%; max-width:100%;margin-top:6px;}\r\n");
|
||||
buffer.append("</style>\r\n");
|
||||
for(int i=0;i<baseList.size();i++){
|
||||
buffer.append("<img src="+baseList.get(i)+" />");
|
||||
}
|
||||
|
||||
buffer.append("</body></html>");
|
||||
try {
|
||||
return buffer.toString();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static byte[] readInputStream(InputStream inStream) throws Exception {
|
||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int len = 0;
|
||||
while ((len = inStream.read(buffer)) != -1) {
|
||||
outStream.write(buffer, 0, len);
|
||||
}
|
||||
inStream.close();
|
||||
return outStream.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.adc.da.report.util;
|
||||
|
||||
import com.adc.da.util.utils.FileUtil;
|
||||
import com.adc.da.util.utils.UUID;
|
||||
import com.aspose.words.Document;
|
||||
import com.aspose.words.FontSettings;
|
||||
import com.aspose.words.License;
|
||||
import com.aspose.words.PdfSaveOptions;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/10 15:50
|
||||
*/
|
||||
@Slf4j
|
||||
public class WordUtil {
|
||||
|
||||
private WordUtil() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
private static boolean getLicense() {
|
||||
boolean result = false;
|
||||
try {
|
||||
|
||||
ClassPathResource resource = new ClassPathResource("license.xml");
|
||||
InputStream is = resource.getInputStream();
|
||||
License aposeLic = new License();
|
||||
aposeLic.setLicense(is);
|
||||
result = true;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String doc2pdf(InputStream inputStream, String targetPath, String ipAddress) {
|
||||
// 验证License 若不验证则转化出的pdf文档会有水印产生
|
||||
if (!getLicense()) {
|
||||
return "";
|
||||
}
|
||||
long old = System.currentTimeMillis();
|
||||
String outPath = targetPath + UUID.randomUUID10() + ".pdf";
|
||||
// 新建一个空白pdf文档
|
||||
File file = new File(outPath);
|
||||
try (FileOutputStream os = new FileOutputStream(file)) {
|
||||
Document doc = new Document(inputStream); // Address是将要被转化的word文档
|
||||
PdfSaveOptions options = new PdfSaveOptions();
|
||||
options.setExportDocumentStructure(true);
|
||||
|
||||
/*
|
||||
全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF,
|
||||
EPUB, XPS, SWF 相互转换
|
||||
*/
|
||||
doc.save(os, options);
|
||||
|
||||
FontSettings.setFontsFolder("/usr/share/fonts/windows", false);
|
||||
|
||||
//pdf转html
|
||||
String s = PdfUtil.pdfStreamToPng(new FileInputStream(file), targetPath, ipAddress);
|
||||
long now = System.currentTimeMillis();
|
||||
//转化用时
|
||||
log.info("pdf转换成功,共耗时:" + ((now - old) / 1000.0) + "秒");
|
||||
FileUtil.deleteFile(outPath);
|
||||
return s;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.adc.da.report.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/15 15:01
|
||||
*/
|
||||
@Data
|
||||
public class LabelAllDetailVo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 标签名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 子类
|
||||
*/
|
||||
private List<LabelVo> childList;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.adc.da.report.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/15 10:36
|
||||
*/
|
||||
@Data
|
||||
public class LabelAllVo {
|
||||
|
||||
/**
|
||||
* 标签树
|
||||
*/
|
||||
private List<LabelAllDetailVo> labelList;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.adc.da.report.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 13:54
|
||||
*/
|
||||
@Data
|
||||
public class LabelVo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 标签名称
|
||||
*/
|
||||
@NotBlank(message = "名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@NotBlank(message = "类型不能为空")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
private String parentId;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.adc.da.report.vo;
|
||||
|
||||
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.Date;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/10 13:49
|
||||
*/
|
||||
@Data
|
||||
public class LogVo {
|
||||
|
||||
private int id;
|
||||
|
||||
private String account;
|
||||
|
||||
private String className;
|
||||
|
||||
private String description;
|
||||
|
||||
private String method;
|
||||
|
||||
private String operateTime;
|
||||
|
||||
private String usid;
|
||||
|
||||
private String reportName;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.adc.da.report.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 16:01
|
||||
*/
|
||||
@Data
|
||||
public class ReportQueryVo {
|
||||
|
||||
/**
|
||||
* 页数
|
||||
*/
|
||||
private int pageNo;
|
||||
|
||||
/**
|
||||
* 每页数量
|
||||
*/
|
||||
private int pageSize;
|
||||
|
||||
/**
|
||||
* 搜索内容
|
||||
*/
|
||||
private String keyContent;
|
||||
|
||||
/**
|
||||
* 标签1
|
||||
*/
|
||||
private List<String> labelOneId;
|
||||
|
||||
/**
|
||||
* 标签2
|
||||
*/
|
||||
private List<String> labelTwoId;
|
||||
|
||||
/**
|
||||
* 标签3
|
||||
*/
|
||||
private List<String> labelThreeId;
|
||||
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
private List<String> year;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String usid;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.adc.da.report.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 09:16
|
||||
*/
|
||||
@Data
|
||||
public class ReportVo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 关键字
|
||||
*/
|
||||
private String keyContent;
|
||||
|
||||
/**
|
||||
* 主要内容
|
||||
*/
|
||||
private String mainContent;
|
||||
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
private String department;
|
||||
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
private String year;
|
||||
|
||||
/**
|
||||
* 标签1
|
||||
*/
|
||||
private String labelOneName;
|
||||
|
||||
/**
|
||||
* 标签2
|
||||
*/
|
||||
private String labelTwoName;
|
||||
|
||||
/**
|
||||
* 标签3
|
||||
*/
|
||||
private String labelThreeName;
|
||||
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
private String fileId;
|
||||
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String fileType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createDate;
|
||||
|
||||
/**
|
||||
* 报告用户id
|
||||
*/
|
||||
private List<String> reportUserIdList;
|
||||
|
||||
/**
|
||||
* 标签1id
|
||||
*/
|
||||
private String labelOneId;
|
||||
|
||||
/**
|
||||
* 标签2id
|
||||
*/
|
||||
private String labelTwoId;
|
||||
|
||||
/**
|
||||
* 标签3id
|
||||
*/
|
||||
private String labelThreeId;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
private String fileSize;
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<License>
|
||||
<Data>
|
||||
<Products>
|
||||
<Product>Aspose.Total for Java</Product>
|
||||
<Product>Aspose.Words for Java</Product>
|
||||
</Products>
|
||||
<EditionType>Enterprise</EditionType>
|
||||
<SubscriptionExpiry>20991231</SubscriptionExpiry>
|
||||
<LicenseExpiry>20991231</LicenseExpiry>
|
||||
<SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber>
|
||||
</Data>
|
||||
<Signature>sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=</Signature>
|
||||
</License>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?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.LabelDao">
|
||||
|
||||
<select id="getMaxNum" parameterType="string" resultType="int">
|
||||
select max(t.orderNum) from TS_LABEL t where type=#{type}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,127 @@
|
||||
<?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">
|
||||
|
||||
|
||||
<select id="list" parameterType="com.adc.da.report.vo.ReportQueryVo" resultType="com.adc.da.report.vo.ReportVo">
|
||||
|
||||
select t1.id,t1.labelOneId,t1.labelTwoId,t1.labelThreeId,t1.labelOneName,t1.labelTwoName,t1.labelThreeName,t1.name,t1.year,t1.keyContent,t1.mainContent
|
||||
,t1.department,date_format(t1.updateDate,'%Y-%m-%d') createDate,t1.fileId
|
||||
from(
|
||||
|
||||
(
|
||||
select distinct b1.*,(case when b3.name is null then '-' else b3.name end) labelOneName
|
||||
,(case when b4.name is null then '-' else b4.name end) labelTwoName
|
||||
,(case when b5.name is null then '-' else b5.name end) labelThreeName from
|
||||
(select * from TT_REPORT_MANAGE )b1
|
||||
left join TR_REPORT_USER b2 on b1.id=b2.reportId
|
||||
left join TS_LABEL b3 on b1.labelOneId=b3.id
|
||||
left join TS_LABEL b4 on b1.labelTwoId=b4.id
|
||||
left join TS_LABEL b5 on b1.labelThreeId=b5.id
|
||||
where b1.del_flag='0' and(b3.name is null or b4.name is null or b5.name is null )
|
||||
|
||||
<!--文本搜索-->
|
||||
<if test="Vo.keyContent !=null and Vo.keyContent !=''">
|
||||
and (b1.name like "%"#{Vo.keyContent}"%" or b1.keycontent like "%"#{Vo.keyContent}"%"
|
||||
or b1.maincontent like "%"#{Vo.keyContent}"%" or b1.department like "%"#{Vo.keyContent}"%")
|
||||
</if>
|
||||
|
||||
<!--年份搜索-->
|
||||
<if test="Vo.year !=null and Vo.year.size() >0">
|
||||
and b1.year in
|
||||
<foreach collection="Vo.year" item="year" open="(" separator="," close=")">
|
||||
#{year}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<!--标签搜索-->
|
||||
<if test="Vo.labelOneId !=null and Vo.labelOneId.size() >0">
|
||||
and b1.labelOneId in
|
||||
<foreach collection="Vo.labelOneId" item="labelOneId" open="(" separator="," close=")">
|
||||
#{labelOneId}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="Vo.labelTwoId !=null and Vo.labelTwoId.size() >0">
|
||||
and b1.labelTwoId in
|
||||
<foreach collection="Vo.labelTwoId" item="labelTwoId" open="(" separator="," close=")">
|
||||
#{labelTwoId}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="Vo.labelThreeId !=null and Vo.labelThreeId.size() >0">
|
||||
and b1.labelThreeId in
|
||||
<foreach collection="Vo.labelThreeId" item="labelThreeId" open="(" separator="," close=")">
|
||||
#{labelThreeId}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="Vo.usid !=null and Vo.usid !=''">
|
||||
and b2.userId=#{Vo.usid}
|
||||
</if>
|
||||
|
||||
ORDER BY updateDate desc limit 999999999
|
||||
)
|
||||
UNION ALL
|
||||
(select distinct a1.* ,a3.name labelOneName,a4.name labelTwoName,a5.name labelThreeName from(select * from TT_REPORT_MANAGE ) a1
|
||||
left join TR_REPORT_USER a2 on a1.id=a2.reportId
|
||||
left join TS_LABEL a3 on a1.labelOneId=a3.id
|
||||
left join TS_LABEL a4 on a1.labelTwoId=a4.id
|
||||
left join TS_LABEL a5 on a1.labelThreeId=a5.id
|
||||
where a1.del_flag='0' and (a3.name is not null and a4.name is not null and a5.name is not null )
|
||||
<!--文本搜索-->
|
||||
<if test="Vo.keyContent !=null and Vo.keyContent !=''">
|
||||
and (a1.name like "%"#{Vo.keyContent}"%" or a1.keycontent like "%"#{Vo.keyContent}"%"
|
||||
or a1.maincontent like "%"#{Vo.keyContent}"%" or a1.department like "%"#{Vo.keyContent}"%" )
|
||||
</if>
|
||||
|
||||
<!--年份搜索-->
|
||||
<if test="Vo.year !=null and Vo.year.size >0">
|
||||
and a1.year in
|
||||
<foreach collection="Vo.year" item="year" open="(" separator="," close=")">
|
||||
#{year}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<!--标签搜索-->
|
||||
<if test="Vo.labelOneId !=null and Vo.labelOneId.size() >0">
|
||||
and a1.labelOneId in
|
||||
<foreach collection="Vo.labelOneId" item="labelOneId" open="(" separator="," close=")">
|
||||
#{labelOneId}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="Vo.labelTwoId !=null and Vo.labelTwoId.size() >0">
|
||||
and a1.labelTwoId in
|
||||
<foreach collection="Vo.labelTwoId" item="labelTwoId" open="(" separator="," close=")">
|
||||
#{labelTwoId}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="Vo.labelThreeId !=null and Vo.labelThreeId.size() >0">
|
||||
and a1.labelThreeId in
|
||||
<foreach collection="Vo.labelThreeId" item="labelThreeId" open="(" separator="," close=")">
|
||||
#{labelThreeId}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="Vo.usid !=null and Vo.usid !=''">
|
||||
and a2.userId=#{Vo.usid}
|
||||
</if>
|
||||
ORDER BY updateDate desc limit 999999999)
|
||||
)t1
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getReportDateList" parameterType="string" resultType="string">
|
||||
select distinct year from TT_REPORT_MANAGE t1
|
||||
left join TR_REPORT_USER t2 on t1.id=t2.reportId
|
||||
where del_flag='0'
|
||||
<if test="usid !='' and usid !=null">
|
||||
and t2.userId=#{usid}
|
||||
</if>
|
||||
ORDER BY year DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user