|
@@ -12,25 +12,36 @@ import cn.cslg.report.common.utils.Response;
|
|
|
import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
|
|
|
import cn.cslg.report.entity.AssoFollowUpFile;
|
|
|
import cn.cslg.report.entity.FollowUp;
|
|
|
+import cn.cslg.report.entity.SystemFile;
|
|
|
import cn.cslg.report.exception.XiaoShiException;
|
|
|
import cn.cslg.report.mapper.FollowUpMapper;
|
|
|
+import cn.cslg.report.service.AssoFollowUpFileService;
|
|
|
import cn.cslg.report.service.IFollowUpService;
|
|
|
import cn.cslg.report.service.business.ReportFileService;
|
|
|
+import cn.cslg.report.service.file.FileManagerService;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 后续事项的Service层实现类
|
|
|
+ *
|
|
|
* @Author xiexiang
|
|
|
* @Date 2023/4/1
|
|
|
*/
|
|
@@ -40,8 +51,12 @@ import java.util.List;
|
|
|
public class FollowUpServiceImpl implements IFollowUpService {
|
|
|
private final FollowUpMapper followUpMapper;
|
|
|
private final ReportFileService reportFileService;
|
|
|
+ private final AssoFollowUpFileService assoFollowUpFileService;
|
|
|
+ private final FileManagerService fileManagerService;
|
|
|
private final CacheUtils cacheUtils;
|
|
|
private final LoginUtils loginUtils;
|
|
|
+ @Value("${FileSource}")
|
|
|
+ private Integer fileSource;
|
|
|
|
|
|
/**
|
|
|
* 新增后续事项
|
|
@@ -52,13 +67,13 @@ public class FollowUpServiceImpl implements IFollowUpService {
|
|
|
public void add(List<FollowUpDTO> followUps) {
|
|
|
log.info("开始处理【新增后续事项】的业务,参数为:{}", followUps);
|
|
|
FollowUp followUp = new FollowUp();
|
|
|
- for(FollowUpDTO followUpDTO:followUps){
|
|
|
- if(followUpDTO.getFollowUpName() == null){
|
|
|
+ for (FollowUpDTO followUpDTO : followUps) {
|
|
|
+ if (followUpDTO.getFollowUpName() == null) {
|
|
|
log.info("后续事项名称不可为空");
|
|
|
}
|
|
|
}
|
|
|
//判断传入列表不为空
|
|
|
- if (followUps != null && followUps.size() > 0 ) {
|
|
|
+ if (followUps != null && followUps.size() > 0) {
|
|
|
//遍历传入列表
|
|
|
for (int i = 0; i < followUps.size(); i++) {
|
|
|
//DTO赋值给后续事项表实体类
|
|
@@ -78,7 +93,8 @@ public class FollowUpServiceImpl implements IFollowUpService {
|
|
|
log.info("数据入后续事项表失败,{}", message);
|
|
|
throw new XiaoShiException(message);
|
|
|
}
|
|
|
- }log.info("新增后续事项完成");
|
|
|
+ }
|
|
|
+ log.info("新增后续事项完成");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -88,7 +104,7 @@ public class FollowUpServiceImpl implements IFollowUpService {
|
|
|
* @param followUpUpdateDTOList 修改后续事项的前端传输DTO数据对象
|
|
|
*/
|
|
|
@Override
|
|
|
- public void update(List<FollowUpUpdateDTO> followUpUpdateDTOList){
|
|
|
+ public void update(List<FollowUpUpdateDTO> followUpUpdateDTOList) {
|
|
|
log.info("开始处理【修改后续事项】的业务,参数为:{}", followUpUpdateDTOList);
|
|
|
//DTO赋值给后续事项表实体类
|
|
|
FollowUp followUp = new FollowUp();
|
|
@@ -104,7 +120,8 @@ public class FollowUpServiceImpl implements IFollowUpService {
|
|
|
String message = "第" + i + "条失败";
|
|
|
log.info("修改后续事项表数据失败,{}", message);
|
|
|
}
|
|
|
- }log.info("修改后续事项完成");
|
|
|
+ }
|
|
|
+ log.info("修改后续事项完成");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -114,31 +131,90 @@ public class FollowUpServiceImpl implements IFollowUpService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据报告id查询
|
|
|
+ * 根据报告id查询后续事项列表
|
|
|
*
|
|
|
* @param queryFUEntity
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<FollowUpVO> findAllByPage(QueryFUEntity queryFUEntity){
|
|
|
+ public List<FollowUpVO> findAllByPage(QueryFUEntity queryFUEntity) throws IOException {
|
|
|
PageHelper.startPage(queryFUEntity.getCurrent(), queryFUEntity.getSize());
|
|
|
+ //分页查询出后续事项列表
|
|
|
List<FollowUpVO> followUpVOS = followUpMapper.query(queryFUEntity.getReportId());
|
|
|
+ if (followUpVOS != null && followUpVOS.size() > 0) {
|
|
|
+ //过滤出后续事项ids
|
|
|
+ List<Integer> followUpIds = followUpVOS.stream().map(FollowUpVO::getId).collect(Collectors.toList());
|
|
|
+ //查询出后续事项ids对应的后续事项和文件关联数据
|
|
|
+ List<AssoFollowUpFile> assoFollowUpFiles = assoFollowUpFileService.list(new LambdaQueryWrapper<AssoFollowUpFile>().in(AssoFollowUpFile::getFollowUpId, followUpIds));
|
|
|
+ if (assoFollowUpFiles != null && assoFollowUpFiles.size() > 0) {
|
|
|
+ //过滤出文件ids
|
|
|
+ List<Integer> fileIds = assoFollowUpFiles.stream().map(AssoFollowUpFile::getFileId).collect(Collectors.toList());
|
|
|
+ //调用文件系统获取文件信息接口,获得文件systemFiles
|
|
|
+ String res = fileManagerService.getSystemFileFromFMS(fileIds);
|
|
|
+ List<SystemFile> systemFiles = JSONArray.parseArray(res, SystemFile.class);
|
|
|
+
|
|
|
+ ArrayList<FilesVO> files = new ArrayList<>();
|
|
|
+ //遍历后续事项文件关联数据assoFollowUpFiles与文件systemFiles,装载文件信息files
|
|
|
+ assoFollowUpFiles.forEach(assoFollowUpFile -> {
|
|
|
+ systemFiles.forEach(systemFile -> {
|
|
|
+ if (systemFile.getId().equals(assoFollowUpFile.getFileId())) {
|
|
|
+ FilesVO fileVO = new FilesVO();
|
|
|
+ fileVO.setFollowUpId(assoFollowUpFile.getFollowUpId()); //文件信息中装载后续事项id
|
|
|
+ fileVO.setFileId(systemFile.getId());
|
|
|
+ fileVO.setName(systemFile.getOriginalName().substring(0, systemFile.getOriginalName().lastIndexOf(".")));
|
|
|
+ fileVO.setUrl(systemFile.getFilePath().substring(systemFile.getFilePath().indexOf("file") + 4));
|
|
|
+ fileVO.setUId(systemFile.getCreateId());
|
|
|
+ fileVO.setSuffix(systemFile.getFilePath().substring(systemFile.getFilePath().lastIndexOf(".") + 1));
|
|
|
+ fileVO.setFileName(systemFile.getFileName());
|
|
|
+ fileVO.setUpdateTime(systemFile.getUpdateTime());
|
|
|
+ files.add(fileVO);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ //遍历后续事项followUpVOS和上一步装载的文件信息files,装载后续事项的文件
|
|
|
+ followUpVOS.forEach(followUpVO -> {
|
|
|
+ ArrayList<FilesVO> filesVOS = new ArrayList<>();
|
|
|
+ files.forEach(file -> {
|
|
|
+ if (file.getFollowUpId().equals(followUpVO.getId())) {
|
|
|
+ file.setFollowUpId(null); //再去除文件信息中的后续事项id
|
|
|
+ filesVOS.add(file);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ followUpVO.setFilesVOs(filesVOS);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return followUpVOS;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据ids删除许可记录数据
|
|
|
+ * 根据ids删除后续事项
|
|
|
*
|
|
|
- * @param ids
|
|
|
+ * @param ids 后续事项ids
|
|
|
*/
|
|
|
@Override
|
|
|
- public void delete(List<Integer> ids) {
|
|
|
- log.info("开始处理【删除许可记录】的业务,参数为:{}", ids);
|
|
|
- if (ids != null) {
|
|
|
- followUpMapper.delete(ids);
|
|
|
- log.info("产品删除完成");
|
|
|
- } else {
|
|
|
- log.info("删除产品失败,产品不存在");
|
|
|
+ public void delete(List<Integer> ids) throws IOException {
|
|
|
+ log.info("开始处理【删除后续事项】的业务,参数为:{}", ids);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<AssoFollowUpFile> wrapper = new LambdaQueryWrapper<AssoFollowUpFile>().in(AssoFollowUpFile::getFollowUpId, ids);
|
|
|
+ //查询出这些后续事项对应的文件
|
|
|
+ List<AssoFollowUpFile> assoFollowUpFiles = assoFollowUpFileService.list(wrapper);
|
|
|
+
|
|
|
+ if (assoFollowUpFiles != null && assoFollowUpFiles.size() > 0) {
|
|
|
+ //删除文件(调用文件系统删除文件接口)
|
|
|
+ List<Integer> fileIds = assoFollowUpFiles.stream().map(AssoFollowUpFile::getFileId).collect(Collectors.toList());
|
|
|
+ fileManagerService.deleteFileFromFMS(fileIds);
|
|
|
+ //删除后续事项与文件关联数据
|
|
|
+ assoFollowUpFileService.remove(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ //删除所有后续事项
|
|
|
+ followUpMapper.delete(ids);
|
|
|
+
|
|
|
+ log.info("后续事项删除完成");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -148,13 +224,13 @@ public class FollowUpServiceImpl implements IFollowUpService {
|
|
|
* @param files
|
|
|
*/
|
|
|
@Override
|
|
|
- public void register(RegisterDTO register, List<MultipartFile> files) throws ParseException {
|
|
|
+ public void register(RegisterDTO register, List<MultipartFile> files) throws ParseException, IOException {
|
|
|
//获取当前时间
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
|
|
|
String date = dateFormat.format(new Date());//date为当前时间 是String类型的时间
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
Date finishTime = simpleDateFormat.parse(date);//转换为Date类型
|
|
|
- System.out.println("等级结果当前完成时间"+ finishTime);
|
|
|
+ System.out.println("等级结果当前完成时间" + finishTime);
|
|
|
FollowUp followUp = new FollowUp();
|
|
|
//从registerDTO中取出后续事项id进行对应的操作
|
|
|
followUp.setId(register.getFollowUpId());
|
|
@@ -174,49 +250,56 @@ public class FollowUpServiceImpl implements IFollowUpService {
|
|
|
//根据后续事项id查询关联表找出所有fileId
|
|
|
List<Integer> fileIdS = followUpMapper.queryFileIdByFollowUpId(followUpId);
|
|
|
//判断第二次登记结果时候文件数量
|
|
|
- List<FilesVO> filesVOs= register.getFilesVOs();
|
|
|
- if(filesVOs != null){//传入不为空
|
|
|
+ List<FilesVO> filesVOs = register.getFilesVOs();
|
|
|
+ if (filesVOs != null) {//传入不为空
|
|
|
//遍历前端传入数据,取得fileId的集合ids
|
|
|
List<Integer> ids = new ArrayList<>();
|
|
|
- for(FilesVO filesVO:filesVOs){
|
|
|
+ for (FilesVO filesVO : filesVOs) {
|
|
|
int id = filesVO.getFileId();
|
|
|
ids.add(id);
|
|
|
}
|
|
|
//定义一个list存放需要删除的fileId
|
|
|
List<Integer> deleteIds = new ArrayList<>();
|
|
|
//遍历数据库中存在的fileId
|
|
|
- for(Integer fileId : fileIdS){
|
|
|
- if(ids.contains(fileId) != true){//不为true,就是没有,需要删除
|
|
|
+ for (Integer fileId : fileIdS) {
|
|
|
+ if (ids.contains(fileId) != true) {//不为true,就是没有,需要删除
|
|
|
deleteIds.add(fileId);
|
|
|
}
|
|
|
}
|
|
|
- if(deleteIds.size()>0) {
|
|
|
+ if (deleteIds.size() > 0) {
|
|
|
followUpMapper.deleteAssoId(followUpId, deleteIds);
|
|
|
log.info("多余关联附件删除完成");
|
|
|
+ //删除文件(调用文件系统删除文件接口)
|
|
|
+ fileManagerService.deleteFileFromFMS(deleteIds);
|
|
|
}
|
|
|
- }else if(filesVOs != null && filesVOs.size() == 0){//传入为空数组 等于附件需要全部删除
|
|
|
- followUpMapper.deleteAssoId(followUpId,fileIdS);
|
|
|
+ } else if (filesVOs != null && filesVOs.size() == 0) {//传入为空数组 等于附件需要全部删除
|
|
|
+ followUpMapper.deleteAssoId(followUpId, fileIdS);
|
|
|
+ //删除文件(调用文件系统删除文件接口)
|
|
|
+ fileManagerService.deleteFileFromFMS(fileIdS);
|
|
|
}
|
|
|
//上传附件 进行关联绑定
|
|
|
if (files != null && files.size() != 0) {
|
|
|
//将文档上传并返回文件入库的Id
|
|
|
- List<Integer> fileIds = reportFileService.uploadFiles(files);
|
|
|
+ //List<Integer> fileIds = reportFileService.uploadFiles(files);
|
|
|
+ String res = fileManagerService.uploadFile(files);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ List<Integer> fileIds = JSON.parseArray(jsonObject.get("data").toString(), Integer.class);
|
|
|
this.addAsso(register.getFollowUpId(), fileIds);
|
|
|
}
|
|
|
//批量新增后续事项
|
|
|
- if(register.getFollowUps() != null && register.getFollowUps().size()>0) {
|
|
|
+ if (register.getFollowUps() != null && register.getFollowUps().size() > 0) {
|
|
|
this.add(register.getFollowUps());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @param followUpId 后续事项id
|
|
|
- * @param fileIds 文件id
|
|
|
+ * @param fileIds 文件id
|
|
|
* @return
|
|
|
* @function 上传后续事项与文件关联表 对应实体AssoFollowUpFile 0代表上传文件为附件
|
|
|
*/
|
|
|
public String addAsso(Integer followUpId, List<Integer> fileIds) {
|
|
|
- for(int i = 0; i < fileIds.size(); i++){
|
|
|
+ for (int i = 0; i < fileIds.size(); i++) {
|
|
|
Integer fileId = fileIds.get(i);
|
|
|
AssoFollowUpFile assoFollowUpFile = new AssoFollowUpFile();
|
|
|
assoFollowUpFile.setFollowUpId(followUpId);
|
|
@@ -224,11 +307,12 @@ public class FollowUpServiceImpl implements IFollowUpService {
|
|
|
assoFollowUpFile.setFileType(0);
|
|
|
int rows = followUpMapper.addAssoIds(assoFollowUpFile);
|
|
|
System.out.println(rows);
|
|
|
- if(rows != 1){
|
|
|
+ if (rows != 1) {
|
|
|
String message = "第" + i + "条失败";
|
|
|
log.info("新增后续事项和附件id关联表数据失败,{}", message);
|
|
|
}
|
|
|
- }log.info("新增后续事项和附件id关联表完成");
|
|
|
+ }
|
|
|
+ log.info("新增后续事项和附件id关联表完成");
|
|
|
return Response.success();
|
|
|
}
|
|
|
|
|
@@ -236,13 +320,13 @@ public class FollowUpServiceImpl implements IFollowUpService {
|
|
|
* 第二次登记结果,根据传入的register中的followUpId和filesVOs中的fileId删除关联表中的多出的数据
|
|
|
*
|
|
|
* @param followUpId 后续事项id
|
|
|
- * @param fileIds 附件id
|
|
|
+ * @param fileIds 附件id
|
|
|
*/
|
|
|
@Override
|
|
|
- public void deleteAssoId(Integer followUpId,List<Integer> fileIds){
|
|
|
- log.info("开始处理【删除多余关联附件】的业务,参数为:{}", followUpId,fileIds);
|
|
|
- if (followUpId != null && fileIds !=null) {
|
|
|
- followUpMapper.deleteAssoId(followUpId,fileIds);
|
|
|
+ public void deleteAssoId(Integer followUpId, List<Integer> fileIds) {
|
|
|
+ log.info("开始处理【删除多余关联附件】的业务,参数为:{}", followUpId, fileIds);
|
|
|
+ if (followUpId != null && fileIds != null) {
|
|
|
+ followUpMapper.deleteAssoId(followUpId, fileIds);
|
|
|
log.info("多余关联附件删除完成");
|
|
|
} else {
|
|
|
log.info("删除多余关联附件失败,多余关联附件不存在");
|