[修改] 报告文件批量上传

This commit is contained in:
bupengxiang
2023-05-24 16:50:07 +08:00
parent 71ab3a0fd8
commit b0a47208c2
18 changed files with 372 additions and 101 deletions
@@ -5,10 +5,7 @@ import com.adc.da.login.util.UserUtils;
import com.adc.da.report.annotation.ReportLog; import com.adc.da.report.annotation.ReportLog;
import com.adc.da.report.dao.mysql.ReportDao; import com.adc.da.report.dao.mysql.ReportDao;
import com.adc.da.report.dao.mysql.ReportLogBookDao; import com.adc.da.report.dao.mysql.ReportLogBookDao;
import com.adc.da.report.eo.FileEntity; import com.adc.da.report.eo.*;
import com.adc.da.report.eo.LogEntity;
import com.adc.da.report.eo.ReportEntity;
import com.adc.da.report.eo.ReportLogBook;
import com.adc.da.report.service.IFileService; import com.adc.da.report.service.IFileService;
import com.adc.da.report.service.ILogService; import com.adc.da.report.service.ILogService;
import com.adc.da.report.service.IReportService; import com.adc.da.report.service.IReportService;
@@ -345,53 +342,7 @@ public class ReportManageConroller {
@ApiOperation(value = "详情||上传文件") @ApiOperation(value = "详情||上传文件")
@PostMapping("/uploadFile") @PostMapping("/uploadFile")
public ResponseMessage<Map<String, Object>> uploadFile(MultipartFile file) throws IOException { public ResponseMessage<Map<String, Object>> uploadFile(MultipartFile file) throws IOException {
Map<String, Object> resultMap = new HashMap(); Map<String, Object> resultMap = fileService.uploadFile(file);
//上传路径
//此路径映射到localhost
String path = uploadFile;
String realName = file.getOriginalFilename();
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String date = dateFormat.format(now);
Random r = new Random();
String num = "";
for (int i = 0; i < 3; i++) {
int s = r.nextInt(10);
num += String.valueOf(s);
}
//获取上传文件名
String fileName = file.getOriginalFilename();
String contentType = file.getContentType();
String ext = fileName.substring(fileName.lastIndexOf(".") + 1);
fileName = fileName.substring(0, fileName.lastIndexOf("."))+date + num + "." + ext;
log.info("fileName>>" + fileName);
try{
String result="";
// 上传方式:阿里云:alioss 华为云:hwobs
if ("hwobs".equals(uploadType)){
result = obsBootUtil.upload(file, fileName);
}else if ("alioss".equals(uploadType)) {
result = ossClientUtil.uploadFile2OSS(file.getInputStream(),fileName);
}else if ("local".equals(uploadType)) {
localFileUtil.saveFile(file.getInputStream(), fileName);
}
resultMap.put("key", date + num);
resultMap.put("value", path + "//" + fileName);
resultMap.put("name", realName);
}
catch (Exception e){
log.error(e.getMessage(),e);
}
FileEntity entity = new FileEntity();
entity.setContentType(contentType);
entity.setCreateTime(new Date());
entity.setFileName(realName);
entity.setFileType(ext);
entity.setFileSize(String.valueOf(file.getSize()));
entity.setFileId(date + num);
entity.setSavePath(fileName);
fileService.addFile(entity);
return Result.success(resultMap); return Result.success(resultMap);
} }
@@ -621,4 +572,15 @@ public class ReportManageConroller {
return Result.success(act); return Result.success(act);
} }
/**
* 删除文件
* @return
* @throws ParseException
*/
@ApiOperation("删除文件")
@PostMapping("/delFile")
public ResponseMessage delFile(@RequestBody ReportFile reportFile) throws Exception {
reportService.delFile(reportFile);
return Result.success();
}
} }
@@ -2,7 +2,11 @@ package com.adc.da.report.dao.mysql;
import com.adc.da.report.eo.ReportFile; import com.adc.da.report.eo.ReportFile;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
public interface ReportFileDao extends BaseMapper<ReportFile> { public interface ReportFileDao extends BaseMapper<ReportFile> {
void delByReportId(@Param("pageVO") ReportFile reportFile);
void actEndDelReport(@Param("pageVO")ReportFile reportFile1);
} }
@@ -68,7 +68,7 @@ public class ReportEntity {
/** /**
* 文件id * 文件id
*/ */
@TableField("fileId") @TableField(exist = false)
private String fileId; private String fileId;
/** /**
@@ -109,4 +109,7 @@ public class ReportEntity {
@TableField(exist = false) @TableField(exist = false)
private List<List<String>> labelList; private List<List<String>> labelList;
@TableField(exist = false)
private List<String> fileList;
} }
@@ -1,14 +1,54 @@
package com.adc.da.report.eo; package com.adc.da.report.eo;
import com.adc.da.login.util.UserUtils;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import java.util.List;
@Data @Data
@TableName("TS_REPORT_FILE")
public class ReportFile { public class ReportFile {
@TableField("id")
private String Id;
@TableField("report_id") @TableField("report_id")
private String reportId; private String reportId;
@TableField("file_id") @TableField("file_id")
private String fileId; private String fileId;
/**
* 状态 1 流程中 ,2 非流程中
*/
@TableField("state")
private Integer state;
@TableField("user_id")
private String userId;
@TableField(exist = false)
private List<String> rfIdList;
@TableField(exist = false)
private String fileName;
public ReportFile(String reportId){
this.reportId = reportId;
}
public ReportFile(String reportId,Integer state){
this.reportId = reportId;
this.state = state;
this.userId = UserUtils.getUserId();
}
public ReportFile(){
}
} }
@@ -128,10 +128,16 @@ public class TtReportManageAct {
@TableField("secrecy_last") @TableField("secrecy_last")
private Date secrecyLast; private Date secrecyLast;
@TableField("file_name") @TableField(exist = false)
private String rfId;
@TableField(exist = false)
private String fileName; private String fileName;
@TableField(exist = false) @TableField(exist = false)
private List<String> labelList; private List<String> labelList;
@TableField(exist = false)
private List<ReportFile> fileList;
} }
@@ -27,4 +27,6 @@ public interface IFileService {
FileEntity getFile(String fileId); FileEntity getFile(String fileId);
List<Map<String, Object>> batchUploadFile(MultipartFile[] files); List<Map<String, Object>> batchUploadFile(MultipartFile[] files);
Map<String, Object> uploadFile(MultipartFile file);
} }
@@ -0,0 +1,11 @@
package com.adc.da.report.service;
import com.adc.da.report.eo.ReportFile;
import com.baomidou.mybatisplus.extension.service.IService;
public interface IReportFileService extends IService<ReportFile> {
}
@@ -1,6 +1,7 @@
package com.adc.da.report.service; package com.adc.da.report.service;
import com.adc.da.report.eo.ReportEntity; import com.adc.da.report.eo.ReportEntity;
import com.adc.da.report.eo.ReportFile;
import com.adc.da.report.vo.ChangeUploaderVo; import com.adc.da.report.vo.ChangeUploaderVo;
import com.adc.da.report.vo.ReportQueryVo; import com.adc.da.report.vo.ReportQueryVo;
import com.adc.da.report.vo.ReportVo; import com.adc.da.report.vo.ReportVo;
@@ -95,4 +96,7 @@ public interface IReportService {
* @return * @return
*/ */
ResponseMessage changeUploader(ChangeUploaderVo changeUploaderVo); ResponseMessage changeUploader(ChangeUploaderVo changeUploaderVo);
void delFile(ReportFile reportFile);
} }
@@ -6,6 +6,7 @@ import com.adc.da.report.service.IFileService;
import com.adc.da.report.util.LocalFileUtil; import com.adc.da.report.util.LocalFileUtil;
import com.adc.da.report.util.OSSClientUtil; import com.adc.da.report.util.OSSClientUtil;
import com.adc.da.report.util.ObsBootUtil; import com.adc.da.report.util.ObsBootUtil;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@@ -121,4 +122,57 @@ public class IFileServiceImpl implements IFileService {
} }
return resultList; return resultList;
} }
@Override
@Synchronized
public Map<String, Object> uploadFile(MultipartFile file) {
Map<String, Object> resultMap = new HashMap();
//上传路径
//此路径映射到localhost
String path = uploadFile;
String realName = file.getOriginalFilename();
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String date = dateFormat.format(now);
Random r = new Random();
String num = "";
for (int i = 0; i < 3; i++) {
int s = r.nextInt(10);
num += String.valueOf(s);
}
//获取上传文件名
String fileName = file.getOriginalFilename();
String contentType = file.getContentType();
String ext = fileName.substring(fileName.lastIndexOf(".") + 1);
fileName = fileName.substring(0, fileName.lastIndexOf("."))+date + num + "." + ext;
log.info("fileName>>" + fileName);
try{
String result="";
// 上传方式:阿里云:alioss 华为云:hwobs
if ("hwobs".equals(uploadType)){
result = obsBootUtil.upload(file, fileName);
}else if ("alioss".equals(uploadType)) {
result = ossClientUtil.uploadFile2OSS(file.getInputStream(),fileName);
}else if ("local".equals(uploadType)) {
localFileUtil.saveFile(file.getInputStream(), fileName);
}
resultMap.put("id", date + num);
resultMap.put("value", path + "//" + fileName);
resultMap.put("name", realName);
}
catch (Exception e){
log.error(e.getMessage(),e);
}
FileEntity entity = new FileEntity();
entity.setContentType(contentType);
entity.setCreateTime(new Date());
entity.setFileName(realName);
entity.setFileType(ext);
entity.setFileSize(String.valueOf(file.getSize()));
entity.setFileId(date + num);
entity.setSavePath(fileName);
this.addFile(entity);
return resultMap;
}
} }
@@ -0,0 +1,16 @@
package com.adc.da.report.service.impl;
import com.adc.da.report.dao.mysql.ReportFileDao;
import com.adc.da.report.eo.ReportFile;
import com.adc.da.report.service.IReportFileService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class IReportFileServiceImpl extends ServiceImpl<ReportFileDao, ReportFile>
implements IReportFileService {
}
@@ -6,6 +6,7 @@ import com.adc.da.login.util.UserUtils;
import com.adc.da.report.constant.ReportConstants; import com.adc.da.report.constant.ReportConstants;
import com.adc.da.report.dao.mysql.FileDao; import com.adc.da.report.dao.mysql.FileDao;
import com.adc.da.report.dao.mysql.ReportDao; import com.adc.da.report.dao.mysql.ReportDao;
import com.adc.da.report.dao.mysql.ReportFileDao;
import com.adc.da.report.dao.mysql.ReportLabelDao; import com.adc.da.report.dao.mysql.ReportLabelDao;
import com.adc.da.report.eo.*; import com.adc.da.report.eo.*;
import com.adc.da.report.service.*; import com.adc.da.report.service.*;
@@ -128,6 +129,12 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
@Resource @Resource
private MenuEOService menuEOService; private MenuEOService menuEOService;
@Autowired
private IReportFileService iReportFileService;
@Autowired
private ReportFileDao reportFileDao;
@Override @Override
public void addOrUpdate(ReportEntity reportEntity) { public void addOrUpdate(ReportEntity reportEntity) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -143,6 +150,16 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
reportDao.insert(reportEntity); reportDao.insert(reportEntity);
} }
String reportId = reportEntity.getId(); String reportId = reportEntity.getId();
//文件
reportFileDao.delByReportId(new ReportFile(reportId,2));
List<ReportFile> reportFiles = new ArrayList<>();
for (String s : reportEntity.getFileList()) {
ReportFile reportFile = new ReportFile();
reportFile.setReportId(reportId);
reportFile.setFileId(s);
reportFiles.add(reportFile);
}
iReportFileService.saveBatch(reportFiles);
//插入报表标签关系表 //插入报表标签关系表
//修改报表标签关系表(先删后增) //修改报表标签关系表(先删后增)
iReportLabelService.deleteReportLabelByReportId(new String[]{reportId}); iReportLabelService.deleteReportLabelByReportId(new String[]{reportId});
@@ -156,13 +173,13 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
labelList.add(reportLabelEntity); labelList.add(reportLabelEntity);
} }
iReportLabelService.saveBatch(labelList); iReportLabelService.saveBatch(labelList);
//插入报表内容表 }
try { //插入报表内容表
iReportContentService.insertReportContent(reportId, reportEntity.getFileId()); try {
log.info("抽取报告内容"); iReportContentService.insertReportContent(reportId, reportEntity.getFileId());
} catch (IOException e) { log.info("抽取报告内容");
log.error("获取报告内容失败", e); } catch (IOException e) {
} log.error("获取报告内容失败", e);
} }
} }
@@ -181,6 +198,11 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
return Result.success("修改成功"); return Result.success("修改成功");
} }
@Override
public void delFile(ReportFile reportFile) {
reportFileDao.deleteBatchIds(reportFile.getRfIdList());
}
/** /**
* 新增或编辑报告 * 新增或编辑报告
* *
@@ -267,8 +289,6 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
reportLabelDao.insert(reportLabelEntity); reportLabelDao.insert(reportLabelEntity);
}); });
//TODO 插入报表内容表(先删后增)
//删除power_apply表中的对应权限 //删除power_apply表中的对应权限
iPowerApplyService.deleteByReportId(entity.getId()); iPowerApplyService.deleteByReportId(entity.getId());
@@ -530,7 +550,9 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
} }
list.getRecords().forEach(c -> { list.getRecords().forEach(c -> {
FileEntity fileEntity = Optional.ofNullable(fileDao.selectById(c.getFileId())).orElse(new FileEntity()); // TODO FILE c.getFileList
// FileEntity fileEntity = Optional.ofNullable(fileDao.selectById(c.getFileId())).orElse(new FileEntity());
FileEntity fileEntity = new FileEntity();
if (StringUtils.isEmpty(fileEntity.getFileType())) { if (StringUtils.isEmpty(fileEntity.getFileType())) {
c.setFileType(null); c.setFileType(null);
} }
@@ -556,7 +578,8 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
//文件大小 //文件大小
c.setFileSize(StringUtils.isNotEmpty(fileEntity.getFileSize()) c.setFileSize(StringUtils.isNotEmpty(fileEntity.getFileSize())
? String.valueOf(Integer.parseInt(fileEntity.getFileSize()) / 1024) + "kb" : "0kb"); ? String.valueOf(Integer.parseInt(fileEntity.getFileSize()) / 1024) + "kb" : "0kb");
c.setFileName(fileEntity.getFileName()); // TODO FILE
// c.setFileName(fileEntity.getFileName());
// List<String> userIdList = reportUserDao.selectList( // List<String> userIdList = reportUserDao.selectList(
// new QueryWrapper<ReportUserEntity>().eq("reportId", c.getId())) // new QueryWrapper<ReportUserEntity>().eq("reportId", c.getId()))
// .stream().map(ReportUserEntity::getUserId).collect(Collectors.toList()); // .stream().map(ReportUserEntity::getUserId).collect(Collectors.toList());
@@ -613,7 +636,9 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
}); });
list.getRecords().forEach(c -> { list.getRecords().forEach(c -> {
FileEntity fileEntity = Optional.ofNullable(fileDao.selectById(c.getFileId())).orElse(new FileEntity()); // TODO FILE c.getFileList
// FileEntity fileEntity = Optional.ofNullable(fileDao.selectById(c.getFileId())).orElse(new FileEntity());
FileEntity fileEntity = new FileEntity() ;
if (StringUtils.isEmpty(fileEntity.getFileType())) { if (StringUtils.isEmpty(fileEntity.getFileType())) {
c.setFileType(null); c.setFileType(null);
} }
@@ -639,7 +664,8 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
//文件大小 //文件大小
c.setFileSize(StringUtils.isNotEmpty(fileEntity.getFileSize()) c.setFileSize(StringUtils.isNotEmpty(fileEntity.getFileSize())
? String.valueOf(Integer.parseInt(fileEntity.getFileSize()) / 1024) + "kb" : "0kb"); ? String.valueOf(Integer.parseInt(fileEntity.getFileSize()) / 1024) + "kb" : "0kb");
c.setFileName(fileEntity.getFileName()); //TODO FILE
// c.setFileName(fileEntity.getFileName());
// List<String> userIdList = reportUserDao.selectList( // List<String> userIdList = reportUserDao.selectList(
// new QueryWrapper<ReportUserEntity>().eq("reportId", c.getId())) // new QueryWrapper<ReportUserEntity>().eq("reportId", c.getId()))
// .stream().map(ReportUserEntity::getUserId).collect(Collectors.toList()); // .stream().map(ReportUserEntity::getUserId).collect(Collectors.toList());
@@ -5,12 +5,15 @@ import cn.hutool.core.bean.BeanUtil;
import com.adc.da.login.util.UserUtils; import com.adc.da.login.util.UserUtils;
import com.adc.da.report.dao.mysql.PowerApplyDao; import com.adc.da.report.dao.mysql.PowerApplyDao;
import com.adc.da.report.dao.mysql.ReportDao; import com.adc.da.report.dao.mysql.ReportDao;
import com.adc.da.report.dao.mysql.ReportFileDao;
import com.adc.da.report.dao.mysql.TtReportManageActDao; import com.adc.da.report.dao.mysql.TtReportManageActDao;
import com.adc.da.report.eo.LogEntity; import com.adc.da.report.eo.LogEntity;
import com.adc.da.report.eo.ReportEntity; import com.adc.da.report.eo.ReportEntity;
import com.adc.da.report.eo.ReportFile;
import com.adc.da.report.eo.TtReportManageAct; import com.adc.da.report.eo.TtReportManageAct;
import com.adc.da.report.service.ILogService; import com.adc.da.report.service.ILogService;
import com.adc.da.report.service.IReportContentService; import com.adc.da.report.service.IReportContentService;
import com.adc.da.report.service.IReportFileService;
import com.adc.da.report.service.ITtReportManageActService; import com.adc.da.report.service.ITtReportManageActService;
import com.adc.da.report.vo.DeleteParamRequestVO; import com.adc.da.report.vo.DeleteParamRequestVO;
import com.adc.da.report.vo.TtReportManageActPageVO; import com.adc.da.report.vo.TtReportManageActPageVO;
@@ -29,6 +32,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID;
/** /**
* @author bu * @author bu
@@ -51,7 +55,11 @@ public class ITtReportManageActServiceImpl extends ServiceImpl<TtReportManageAct
@Resource @Resource
private IReportContentService iReportContentService; private IReportContentService iReportContentService;
@Autowired
private IReportFileService iReportFileService;
@Autowired
private ReportFileDao reportFileDao;
/** /**
* @param ttReportManageActPageVO * @param ttReportManageActPageVO
* @return <com.adc.da.report.entity.TtReportManageAct> * @return <com.adc.da.report.entity.TtReportManageAct>
@@ -152,6 +160,23 @@ public class ITtReportManageActServiceImpl extends ServiceImpl<TtReportManageAct
reportDao.updateById(reportEntity1); reportDao.updateById(reportEntity1);
reportLog(reportEntity.getName(),"编辑"); reportLog(reportEntity.getName(),"编辑");
} }
// 文件
ReportFile reportFile1 = new ReportFile();
reportFile1.setReportId(ttReportManageAct.getDataId());
reportFile1.setUserId(UserUtils.getUserId());
reportFileDao.actEndDelReport(reportFile1);
List<ReportFile> reportFiles = new ArrayList<>();
for (ReportFile reportFile : ttReportManageAct.getFileList()) {
reportFile.setId(UUID.randomUUID().toString().replace("-",""));
reportFile.setReportId(ttReportManageAct.getDataId());
// reportFile.setFileId(s);
reportFile.setState(2);
reportFile.setUserId(UserUtils.getUserId());
reportFiles.add(reportFile);
}
iReportFileService.saveBatch(reportFiles);
try { try {
iReportContentService.insertReportContent(ttReportManageAct.getDataId(), ttReportManageAct.getFileId()); iReportContentService.insertReportContent(ttReportManageAct.getDataId(), ttReportManageAct.getFileId());
log.info("抽取报告内容"); log.info("抽取报告内容");
@@ -1,5 +1,7 @@
package com.adc.da.report.vo; package com.adc.da.report.vo;
import com.adc.da.report.eo.ReportFile;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@@ -111,4 +113,8 @@ public class ReportDetailVo {
* 保密到期日期 * 保密到期日期
*/ */
private Date secrecyLast; private Date secrecyLast;
@TableField(exist = false)
private List<ReportFile> fileList;
} }
@@ -1,5 +1,7 @@
package com.adc.da.report.vo; package com.adc.da.report.vo;
import com.adc.da.report.eo.ReportFile;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
@@ -46,16 +48,6 @@ public class ReportVo {
*/ */
private String year; private String year;
/**
* 文件id
*/
private String fileId;
/**
* 文件名称
*/
private String fileName;
/** /**
* 文件类型 * 文件类型
*/ */
@@ -135,5 +127,6 @@ public class ReportVo {
private Integer isAct; private Integer isAct;
private String prcType; private String prcType;
@TableField(exist = false)
private List<ReportFile> fileList;
} }
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.adc.da.report.dao.mysql.ReportFileDao">
<delete id="actEndDelReport">
delete from ts_report_file
<where>
report_id = #{pageVO.reportId}
and ( state = 2 or (state = 1 AND user_id = #{pageVO.userId} ) )
</where>
</delete>
<delete id="delByReportId">
delete from ts_report_file
<where>
<if test="pageVO.reportId !=null and pageVO.reportId !=''">
AND report_id = #{pageVO.reportId}
</if>
<if test="pageVO.userId !=null and pageVO.userId !=''">
AND user_id = #{pageVO.userId}
</if>
<if test="pageVO.state !=null">
AND state = #{pageVO.state}
</if>
</where>
</delete>
</mapper>
@@ -1,15 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!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"> <mapper namespace="com.adc.da.report.dao.mysql.ReportDao">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.adc.da.report.vo.ReportDetailVo">
<result column="id" property="id" />
<result column="name" property="name" />
<result column="uploaderName" property="uploaderName" />
<result column="keycontent" property="keyContent" />
<result column="maincontent" property="mainContent" />
<result column="department" property="department" />
<result column="departmentName" property="departmentName" />
<result column="year" property="year" />
<result column="confidentialLevel" property="confidentialLevel" />
<result column="privacyLevel" property="privacyLevel" />
<result column="createUserId" property="createUserId" />
<result column="secrecy_last" property="secrecyLast" />
<collection property="fileList" ofType="com.adc.da.report.eo.ReportFile">
<result column="fileId" property="fileId" />
<result column="fileName" property="fileName" />
<result column="rfId" property="id" />
</collection>
</resultMap>
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultReportVoMap" type="com.adc.da.report.vo.ReportVo">
<result column="id" property="id" />
<result column="name" property="name" />
<result column="keycontent" property="keyContent" />
<result column="maincontent" property="mainContent" />
<result column="department" property="department" />
<result column="year" property="year" />
<result column="confidentialLevel" property="confidentialLevel" />
<result column="privacyLevel" property="privacyLevel" />
<result column="createUserId" property="createUserId" />
<result column="uploader" property="uploader" />
<result column="createDate" property="createDate" />
<result column="thumbUp" property="thumbUp" />
<result column="clicks" property="clicks" />
<result column="download" property="download" />
<result column="reportRating" property="reportRating" />
<result column="isAct" property="isAct" />
<collection property="fileList" ofType="com.adc.da.report.eo.ReportFile">
<result column="fileId" property="fileId" />
<result column="fileName" property="fileName" />
<result column="rfId" property="id" />
</collection>
</resultMap>
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="BaseColumnList"> <sql id="BaseColumnList">
id, name, keycontent, maincontent, department, year, fileId, confidentialLevel, privacyLevel, id, name, keycontent, maincontent, department, year, confidentialLevel, privacyLevel,
createUserId, createDate, updateDate, del_flag,secrecy_last createUserId, createDate, updateDate, del_flag,secrecy_last
</sql> </sql>
<sql id="BaseColumnValue"> <sql id="BaseColumnValue">
#{Vo.id},#{Vo.name},#{Vo.keycontent},#{Vo.maincontent},#{Vo.department},#{Vo.year},#{Vo.fileId}, #{Vo.id},#{Vo.name},#{Vo.keycontent},#{Vo.maincontent},#{Vo.department},#{Vo.year},
#{Vo.confidentialLevel},#{Vo.privacyLevel}, #{Vo.confidentialLevel},#{Vo.privacyLevel},
#{Vo.createUserId}, #{Vo.createUserId},
#{Vo.createDate},#{Vo.updateDate},#{Vo.del_flag}, #{Vo.createDate},#{Vo.updateDate},#{Vo.del_flag},
@@ -19,7 +65,7 @@
<insert id="saveReportAct"> <insert id="saveReportAct">
insert into TT_REPORT_MANAGE (<include refid="BaseColumnList"/>) insert into TT_REPORT_MANAGE (<include refid="BaseColumnList"/>)
value ( value (
#{Vo.dataId},#{Vo.name},#{Vo.keyContent},#{Vo.mainContent},#{Vo.department},#{Vo.year},#{Vo.fileId}, #{Vo.dataId},#{Vo.name},#{Vo.keyContent},#{Vo.mainContent},#{Vo.department},#{Vo.year},
#{Vo.confidentialLevel},#{Vo.privacyLevel}, #{Vo.confidentialLevel},#{Vo.privacyLevel},
#{Vo.createUserId}, #{Vo.createUserId},
#{Vo.createDate},#{Vo.updateDate},#{Vo.delFlag}, #{Vo.createDate},#{Vo.updateDate},#{Vo.delFlag},
@@ -45,7 +91,6 @@
eo.maincontent, eo.maincontent,
eo.DEPARTMENT, eo.DEPARTMENT,
eo.YEAR, eo.YEAR,
eo.fileid,
eo.confidentialLevel, eo.confidentialLevel,
eo.privacyLevel, eo.privacyLevel,
eo.createUserId, eo.createUserId,
@@ -91,7 +136,7 @@
</select> </select>
<select id="page" resultType="com.adc.da.report.vo.ReportVo"> <select id="page" resultMap="BaseResultReportVoMap">
SELECT SELECT
eo.id AS id, eo.id AS id,
@@ -100,7 +145,6 @@
eo.maincontent AS mainContent, eo.maincontent AS mainContent,
eo.DEPARTMENT AS department, eo.DEPARTMENT AS department,
eo.`YEAR` AS `year`, eo.`YEAR` AS `year`,
eo.fileid AS fileId,
eo.confidentialLevel AS confidentialLevel, eo.confidentialLevel AS confidentialLevel,
eo.privacyLevel AS privacyLevel, eo.privacyLevel AS privacyLevel,
eo.createUserId AS createUserId, eo.createUserId AS createUserId,
@@ -113,6 +157,8 @@
IF(bpn.id is null,1, IF(bpn.id is null,1,
IF(bpn.SUBMIT_STATUS = 1 and bpn.CREAT_USER = #{pageVO.usid} ,0,1) IF(bpn.SUBMIT_STATUS = 1 and bpn.CREAT_USER = #{pageVO.usid} ,0,1)
) as isAct ) as isAct
,
f.FILE_ID as fileId, f.file_name as fileName ,rf.id as rfId
FROM FROM
TT_REPORT_MANAGE eo TT_REPORT_MANAGE eo
LEFT JOIN ts_report_content rc ON eo.id = rc.report_id LEFT JOIN ts_report_content rc ON eo.id = rc.report_id
@@ -122,6 +168,8 @@
LEFT JOIN (SELECT report_id, COUNT(id) AS download FROM report_log_book WHERE type = 2 GROUP BY report_id) AS downloadCount ON eo.id = downloadCount.report_id LEFT JOIN (SELECT report_id, COUNT(id) AS download FROM report_log_book WHERE type = 2 GROUP BY report_id) AS downloadCount ON eo.id = downloadCount.report_id
LEFT JOIN ts_report_user_rating AS trur ON eo.id = trur.report_id LEFT JOIN ts_report_user_rating AS trur ON eo.id = trur.report_id
LEFT JOIN bus_process_name as bpn on bpn.data_id = eo.id and bpn.prc_type != '5' LEFT JOIN bus_process_name as bpn on bpn.data_id = eo.id and bpn.prc_type != '5'
LEFT JOIN ts_report_file rf on rf.report_id = eo.id and rf.state = 2
LEFT JOIN ts_file f on f.FILE_ID = rf.file_id
WHERE WHERE
eo.DEL_FLAG = 0 eo.DEL_FLAG = 0
<!--全文模糊搜索--> <!--全文模糊搜索-->
@@ -175,7 +223,6 @@
t.year, t.year,
t.name, t.name,
t.keycontent, t.keycontent,
t.fileId,
t.createDate, t.createDate,
t.department, t.department,
t.maincontent, t.maincontent,
@@ -274,7 +321,7 @@
</select> </select>
<select id="reportDetail" resultType="com.adc.da.report.vo.ReportDetailVo"> <select id="reportDetail" resultMap="BaseResultMap">
SELECT SELECT
rm.id AS id, rm.id AS id,
rm.name AS `name`, rm.name AS `name`,
@@ -284,18 +331,19 @@
rm.maincontent AS maincontent, rm.maincontent AS maincontent,
rm.department AS department, rm.department AS department,
rm.`year` AS `year`, rm.`year` AS `year`,
rm.fileId AS fileId,
f.file_name as fileName,
rm.confidentialLevel AS confidentialLevel, rm.confidentialLevel AS confidentialLevel,
rm.privacyLevel AS privacyLevel, rm.privacyLevel AS privacyLevel,
rm.secrecy_last AS secrecyLast rm.secrecy_last AS secrecyLast,
f.id as fileId, f.file_name as fileName ,rf.id as rfId
FROM `tt_report_manage` AS rm FROM `tt_report_manage` AS rm
LEFT JOIN ts_user AS u ON u.USID = rm.createUserId LEFT JOIN ts_user AS u ON u.USID = rm.createUserId
LEFT JOIN ts_org as org on org.id = rm.department LEFT JOIN ts_org as org on org.id = rm.department
LEFT JOIN ts_file as f on rm.fileId=f.file_id LEFT JOIN ts_report_file rf on rf.report_id = rm.id on rf.state = 2
LEFT JOIN ts_file f on f.FILE_ID = rf.file_id
WHERE rm.id = #{reportId} WHERE rm.id = #{reportId}
AND rm.del_flag = 0 AND rm.del_flag = 0
</select> </select>
<select id="selectDDL" resultType="com.adc.da.report.eo.ReportEntity"> <select id="selectDDL" resultType="com.adc.da.report.eo.ReportEntity">
SELECT * FROM tt_report_manage WHERE secrecy_last &lt;= NOW() SELECT * FROM tt_report_manage WHERE secrecy_last &lt;= NOW()
</select> </select>
@@ -15,7 +15,6 @@
<result column="department" property="department" /> <result column="department" property="department" />
<result column="departmentName" property="departmentName" /> <result column="departmentName" property="departmentName" />
<result column="year" property="year" /> <result column="year" property="year" />
<result column="fileId" property="fileId" />
<result column="confidentialLevel" property="confidentialLevel" /> <result column="confidentialLevel" property="confidentialLevel" />
<result column="privacyLevel" property="privacyLevel" /> <result column="privacyLevel" property="privacyLevel" />
<result column="createUserId" property="createUserId" /> <result column="createUserId" property="createUserId" />
@@ -23,7 +22,11 @@
<result column="updateDate" property="updateDate" /> <result column="updateDate" property="updateDate" />
<result column="del_flag" property="delFlag" /> <result column="del_flag" property="delFlag" />
<result column="secrecy_last" property="secrecyLast" /> <result column="secrecy_last" property="secrecyLast" />
<result column="file_name" property="fileName" /> <collection property="fileList" ofType="com.adc.da.report.eo.ReportFile">
<result column="fileId" property="fileId" />
<result column="fileName" property="fileName" />
<result column="rfId" property="id" />
</collection>
</resultMap> </resultMap>
<!--表名信息--> <!--表名信息-->
@@ -34,9 +37,9 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="BaseColumnList"> <sql id="BaseColumnList">
id, id,
task_id, prc_id, data_id,report_id ,name, keycontent, maincontent, department, year, fileId, confidentialLevel, task_id, prc_id, data_id,report_id ,name, keycontent, maincontent, department, year, confidentialLevel,
privacyLevel, createUserId, createDate, updateDate, del_flag privacyLevel, createUserId, createDate, updateDate, del_flag
,secrecy_last,file_name ,secrecy_last
</sql> </sql>
<!-- 查询条件 --> <!-- 查询条件 -->
@@ -71,9 +74,6 @@
<if test="pageVO.year !=null and pageVO.year !=''"> <if test="pageVO.year !=null and pageVO.year !=''">
AND year LIKE CONCAT(CONCAT('%',#{pageVO.year}),'%') AND year LIKE CONCAT(CONCAT('%',#{pageVO.year}),'%')
</if> </if>
<if test="pageVO.fileId !=null and pageVO.fileId !=''">
AND fileId LIKE CONCAT(CONCAT('%',#{pageVO.fileId}),'%')
</if>
<if test="pageVO.confidentialLevel !=null and pageVO.confidentialLevel !=''"> <if test="pageVO.confidentialLevel !=null and pageVO.confidentialLevel !=''">
AND confidentialLevel LIKE CONCAT(CONCAT('%',#{pageVO.confidentialLevel}),'%') AND confidentialLevel LIKE CONCAT(CONCAT('%',#{pageVO.confidentialLevel}),'%')
</if> </if>
@@ -135,10 +135,14 @@
a.id, a.id,
task_id, prc_id, data_id,report_id, name, keycontent, maincontent, department, task_id, prc_id, data_id,report_id, name, keycontent, maincontent, department,
org.LONG_NAME as departmentName, org.LONG_NAME as departmentName,
year, fileId, confidentialLevel, privacyLevel, createUserId, createDate, updateDate, del_flag year,f.id as fileId, f.file_name as fileName ,rf.id as rfId, confidentialLevel, privacyLevel, createUserId,
,secrecy_last,file_name createDate,
updateDate, del_flag
,secrecy_last
FROM <include refid="TableName"/> a FROM <include refid="TableName"/> a
LEFT JOIN ts_org org on a.department = org.id LEFT JOIN ts_org org on a.department = org.id
LEFT JOIN ts_report_file rf on rf.report_id = a.id on rf.state = 1
LEFT JOIN ts_file f on f.FILE_ID = rf.file_id
<where> <where>
data_id = #{dataId} data_id = #{dataId}
</where> </where>
@@ -148,10 +152,14 @@
a.id, a.id,
task_id, prc_id, data_id,report_id, name, keycontent, maincontent, department, task_id, prc_id, data_id,report_id, name, keycontent, maincontent, department,
org.LONG_NAME as departmentName, org.LONG_NAME as departmentName,
year, fileId, confidentialLevel, privacyLevel, createUserId, createDate, updateDate, del_flag year,f.id as fileId, f.file_name as fileName ,rf.id as rfId ,confidentialLevel, privacyLevel, createUserId,
,secrecy_last,file_name createDate,
updateDate, del_flag
,secrecy_last
FROM <include refid="TableName"/> a FROM <include refid="TableName"/> a
LEFT JOIN ts_org org on a.department = org.id LEFT JOIN ts_org org on a.department = org.id
LEFT JOIN ts_report_file rf on rf.report_id = a.id on rf.state = 1
LEFT JOIN ts_file f on f.FILE_ID = rf.file_id
<where> <where>
prc_id = #{prcId} prc_id = #{prcId}
</where> </where>
@@ -1,12 +1,16 @@
package com.adc.da.wkflow.business_activiti.service; package com.adc.da.wkflow.business_activiti.service;
import com.adc.da.login.util.UserUtils;
import com.adc.da.report.dao.mysql.PowerApplyActDao; import com.adc.da.report.dao.mysql.PowerApplyActDao;
import com.adc.da.report.dao.mysql.ReportFileDao;
import com.adc.da.report.dao.mysql.ReportLabelDao; import com.adc.da.report.dao.mysql.ReportLabelDao;
import com.adc.da.report.dao.mysql.TtReportManageActDao; import com.adc.da.report.dao.mysql.TtReportManageActDao;
import com.adc.da.report.eo.PowerApplyAct; import com.adc.da.report.eo.PowerApplyAct;
import com.adc.da.report.eo.ReportFile;
import com.adc.da.report.eo.ReportLabelEntity; import com.adc.da.report.eo.ReportLabelEntity;
import com.adc.da.report.eo.TtReportManageAct; import com.adc.da.report.eo.TtReportManageAct;
import com.adc.da.report.service.IPowerApplyActService; import com.adc.da.report.service.IPowerApplyActService;
import com.adc.da.report.service.IReportFileService;
import com.adc.da.report.service.IReportLabelService; import com.adc.da.report.service.IReportLabelService;
import com.adc.da.report.service.ITtReportManageActService; import com.adc.da.report.service.ITtReportManageActService;
import com.adc.da.util.exception.AdcDaBaseException; import com.adc.da.util.exception.AdcDaBaseException;
@@ -19,7 +23,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Service @Service
public class ActivitDefineService { public class ActivitDefineService {
@@ -42,7 +49,11 @@ public class ActivitDefineService {
private ReportLabelDao reportLabelDao; private ReportLabelDao reportLabelDao;
@Autowired @Autowired
private IReportLabelService iReportLabelService; private IReportLabelService iReportLabelService;
@Autowired
private IReportFileService iReportFileService;
@Autowired
private ReportFileDao reportFileDao;
//保存data数据 //保存data数据
public String saveOrUpdateDate(String prcType, String dataJson,String taskId,String prcId,String reportId) { public String saveOrUpdateDate(String prcType, String dataJson,String taskId,String prcId,String reportId) {
if (StringUtils.isBlank(reportId)){ if (StringUtils.isBlank(reportId)){
@@ -115,6 +126,18 @@ public class ActivitDefineService {
} }
iReportLabelService.saveBatch(labelList); iReportLabelService.saveBatch(labelList);
} }
// 文件
reportFileDao.delByReportId(new ReportFile(reportId,1));
List<ReportFile> reportFiles = new ArrayList<>();
for (ReportFile reportFile : ttReportManageAct.getFileList()) {
reportFile.setId(UUID.randomUUID().toString().replace("-",""));
reportFile.setReportId(ttReportManageAct.getDataId());
// reportFile.setFileId(s);
reportFile.setState(1);
reportFile.setUserId(UserUtils.getUserId());
reportFiles.add(reportFile);
}
iReportFileService.saveBatch(reportFiles);
}else if ("5".equals(prcType)){ }else if ("5".equals(prcType)){
// 编辑 // 编辑
TtReportManageAct ttReportManageAct = JSONObject.parseObject(dataJson, TtReportManageAct.class); TtReportManageAct ttReportManageAct = JSONObject.parseObject(dataJson, TtReportManageAct.class);
@@ -138,6 +161,18 @@ public class ActivitDefineService {
} }
iReportLabelService.saveBatch(labelList); iReportLabelService.saveBatch(labelList);
} }
// 文件
reportFileDao.delByReportId(new ReportFile(reportId,1));
List<ReportFile> reportFiles = new ArrayList<>();
for (ReportFile reportFile : ttReportManageAct.getFileList()) {
reportFile.setId(UUID.randomUUID().toString().replace("-",""));
reportFile.setReportId(ttReportManageAct.getDataId());
// reportFile.setFileId(s);
reportFile.setState(1);
reportFile.setUserId(UserUtils.getUserId());
reportFiles.add(reportFile);
}
iReportFileService.saveBatch(reportFiles);
}else { }else {
throw new AdcDaBaseException("没有流程类型"+prcType); throw new AdcDaBaseException("没有流程类型"+prcType);
} }