|
@@ -8,7 +8,9 @@ import cn.cslg.report.common.utils.CacheUtils;
|
|
|
import cn.cslg.report.common.utils.FileUtils;
|
|
|
import cn.cslg.report.common.utils.Response;
|
|
|
import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
|
|
|
+import cn.cslg.report.common.utils.SystemFileToReportFile;
|
|
|
import cn.cslg.report.entity.ReportFiles;
|
|
|
+import cn.cslg.report.entity.SystemFile;
|
|
|
import cn.cslg.report.entity.Template;
|
|
|
import cn.cslg.report.entity.invalidReReport.InvalidProcess;
|
|
|
import cn.cslg.report.entity.invalidReReport.OralExam;
|
|
@@ -17,6 +19,8 @@ import cn.cslg.report.mapper.InvalidReReport.InvalidProcessMapper;
|
|
|
import cn.cslg.report.mapper.TemplateMapper;
|
|
|
import cn.cslg.report.service.business.OralExamService;
|
|
|
import cn.cslg.report.service.business.ReportFileService;
|
|
|
+import cn.cslg.report.service.file.FileManagerService;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -27,6 +31,7 @@ import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -41,16 +46,19 @@ public class InvalidProcessService extends ServiceImpl<InvalidProcessMapper, Inv
|
|
|
private final FileUtils fileUtils;
|
|
|
private final ReportFileService reportFileService;
|
|
|
private final OralExamService oralExamService;
|
|
|
+ private final FileManagerService fileManagerService;
|
|
|
+
|
|
|
/**
|
|
|
* 无效事务添加
|
|
|
+ *
|
|
|
* @param invalidProcessStr
|
|
|
* @param file
|
|
|
* @return
|
|
|
*/
|
|
|
- public void addInvalidProcess(String invalidProcessStr, MultipartFile file) {
|
|
|
+ public void addInvalidProcess(String invalidProcessStr, MultipartFile file) throws IOException {
|
|
|
InvalidProcessDTO invalidProcessDTO = JSONObject.parseObject(invalidProcessStr, InvalidProcessDTO.class);
|
|
|
//判断无效事务时间是否为空,无论是文件类型或者口审类型都要时间
|
|
|
- if(invalidProcessDTO.getOccuredTime() != null) {
|
|
|
+ if (invalidProcessDTO.getOccuredTime() != null) {
|
|
|
//判断无效事务的类型
|
|
|
//获取当前登陆人信息
|
|
|
PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
@@ -70,9 +78,9 @@ public class InvalidProcessService extends ServiceImpl<InvalidProcessMapper, Inv
|
|
|
typeIds.add(3);
|
|
|
typeIds.add(4);
|
|
|
//如果类型为0,则为口审记录
|
|
|
- if(invalidProcessDTO.getProcessType().equals(0)){
|
|
|
+ if (invalidProcessDTO.getProcessType().equals(0)) {
|
|
|
//口审记录要判断 参与人,地点是否为空
|
|
|
- if(invalidProcessDTO.getAddress() != null && invalidProcessDTO.getAddress() != "" && invalidProcessDTO.getParticipants() != null && invalidProcessDTO.getParticipants() != ""){
|
|
|
+ if (invalidProcessDTO.getAddress() != null && invalidProcessDTO.getAddress() != "" && invalidProcessDTO.getParticipants() != null && invalidProcessDTO.getParticipants() != "") {
|
|
|
//若是口审记录则添加口审记录接着添加无效事务
|
|
|
//添加口审记录
|
|
|
OralExam oralExam = new OralExam();
|
|
@@ -92,12 +100,15 @@ public class InvalidProcessService extends ServiceImpl<InvalidProcessMapper, Inv
|
|
|
} else {
|
|
|
throw new XiaoShiException("参与人,地点不能为空");
|
|
|
}
|
|
|
- } else if(typeIds.contains(invalidProcessDTO.getProcessType())) {
|
|
|
+ } else if (typeIds.contains(invalidProcessDTO.getProcessType())) {
|
|
|
//流程类型不为0
|
|
|
//若是文件则上传文件并添加无效事务
|
|
|
List<MultipartFile> files = new ArrayList<>();
|
|
|
files.add(file);
|
|
|
- List<Integer> ids = reportFileService.uploadFiles(files);
|
|
|
+ //List<Integer> ids = reportFileService.uploadFiles(files);
|
|
|
+ String res = fileManagerService.uploadFile(files);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ List<Integer> ids = JSONArray.parseArray(jsonObject.get("data").toString(), Integer.class);
|
|
|
int fileId = ids.get(0);
|
|
|
invalidProcess.setFileId(fileId);
|
|
|
invalidProcess.setProcessType(invalidProcessDTO.getProcessType());
|
|
@@ -112,17 +123,22 @@ public class InvalidProcessService extends ServiceImpl<InvalidProcessMapper, Inv
|
|
|
|
|
|
/**
|
|
|
* 删除无效事务
|
|
|
+ *
|
|
|
* @param id
|
|
|
*/
|
|
|
- public void removeInvalidProcess(Integer id) {
|
|
|
+ public void removeInvalidProcess(Integer id) throws IOException {
|
|
|
//根据无效事务id删除无效事务
|
|
|
LambdaQueryWrapper<InvalidProcess> lw = new LambdaQueryWrapper<>();
|
|
|
lw.eq(InvalidProcess::getId, id);
|
|
|
InvalidProcess invalidProcess = this.getOne(lw);
|
|
|
- if(invalidProcess != null){
|
|
|
+ if (invalidProcess != null) {
|
|
|
//如果流程类型为0,则为口审记录
|
|
|
- if(invalidProcess.getProcessType().equals(0)) {
|
|
|
+ if (invalidProcess.getProcessType().equals(0)) {
|
|
|
oralExamService.removeById(id);
|
|
|
+ } else {
|
|
|
+ ArrayList<Integer> fileIds = new ArrayList<>();
|
|
|
+ fileIds.add(invalidProcess.getFileId());
|
|
|
+ fileManagerService.deleteFileFromFMS(fileIds);
|
|
|
}
|
|
|
invalidProcess.deleteById();
|
|
|
} else {
|
|
@@ -131,16 +147,16 @@ public class InvalidProcessService extends ServiceImpl<InvalidProcessMapper, Inv
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 修改无效事务
|
|
|
+ *
|
|
|
* @param invalidProcessStr
|
|
|
* @param file
|
|
|
*/
|
|
|
- public void updateInvalidProcess(String invalidProcessStr, MultipartFile file) {
|
|
|
+ public void updateInvalidProcess(String invalidProcessStr, MultipartFile file) throws IOException {
|
|
|
InvalidProcessDTO iPDTO = JSONObject.parseObject(invalidProcessStr, InvalidProcessDTO.class);
|
|
|
//判断无效事务时间是否为空,无论是文件类型或者口审类型都要时间
|
|
|
- if(iPDTO.getOccuredTime() != null) {
|
|
|
+ if (iPDTO.getOccuredTime() != null) {
|
|
|
//判断无效事务的类型
|
|
|
//获取当前登陆人信息
|
|
|
PersonnelVO pVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
@@ -157,9 +173,9 @@ public class InvalidProcessService extends ServiceImpl<InvalidProcessMapper, Inv
|
|
|
typeIds.add(3);
|
|
|
typeIds.add(4);
|
|
|
//如果类型为0,则为口审记录
|
|
|
- if(iPDTO.getProcessType().equals(0)){
|
|
|
+ if (iPDTO.getProcessType().equals(0)) {
|
|
|
//口审记录要判断 参与人,地点是否为空
|
|
|
- if(iPDTO.getAddress() != null && iPDTO.getAddress() != "" && iPDTO.getParticipants() != null && iPDTO.getParticipants() != ""){
|
|
|
+ if (iPDTO.getAddress() != null && iPDTO.getAddress() != "" && iPDTO.getParticipants() != null && iPDTO.getParticipants() != "") {
|
|
|
//若是口审记录则添加口审记录接着添加无效事务
|
|
|
//口审记录也需要先查出来
|
|
|
OralExam oralExam = oralExamService.getById(invalidProcess.getOralExamId());
|
|
@@ -179,12 +195,15 @@ public class InvalidProcessService extends ServiceImpl<InvalidProcessMapper, Inv
|
|
|
} else {
|
|
|
throw new XiaoShiException("参与人,地点不能为空");
|
|
|
}
|
|
|
- } else if(typeIds.contains(iPDTO.getProcessType())) {
|
|
|
+ } else if (typeIds.contains(iPDTO.getProcessType())) {
|
|
|
//流程类型不为0
|
|
|
//若是文件则上传文件并添加无效事务
|
|
|
List<MultipartFile> files = new ArrayList<>();
|
|
|
files.add(file);
|
|
|
- List<Integer> ids = reportFileService.uploadFiles(files);
|
|
|
+ //List<Integer> ids = reportFileService.uploadFiles(files);
|
|
|
+ String res = fileManagerService.uploadFile(files);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ List<Integer> ids = JSONArray.parseArray(jsonObject.get("data").toString(), Integer.class);
|
|
|
int fileId = ids.get(0);
|
|
|
invalidProcess.setFileId(fileId);
|
|
|
invalidProcess.setProcessType(iPDTO.getProcessType());
|
|
@@ -204,83 +223,88 @@ public class InvalidProcessService extends ServiceImpl<InvalidProcessMapper, Inv
|
|
|
* @param orderBy
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<InvalidProcessVO> queryInvalidProcess(Integer reportId, Integer orderBy,Integer type) {
|
|
|
+ public List<InvalidProcessVO> queryInvalidProcess(Integer reportId, Integer orderBy, Integer type) throws IOException {
|
|
|
//根据报告id,根据时间排序返回所有的无效事务。
|
|
|
LambdaQueryWrapper<InvalidProcess> LW = new LambdaQueryWrapper<>();
|
|
|
LW.eq(InvalidProcess::getReportId, reportId);
|
|
|
- if(type!=null){
|
|
|
- LW.eq(InvalidProcess::getProcessType,type);
|
|
|
+ if (type != null) {
|
|
|
+ LW.eq(InvalidProcess::getProcessType, type);
|
|
|
}
|
|
|
//根据时间排序
|
|
|
- if(orderBy!=null&&orderBy==1) {
|
|
|
+ if (orderBy != null && orderBy == 1) {
|
|
|
LW.orderByAsc(InvalidProcess::getOccuredTime);
|
|
|
} else {
|
|
|
LW.orderByDesc(InvalidProcess::getOccuredTime);
|
|
|
}
|
|
|
List<InvalidProcess> invalidProcessList = this.list(LW);
|
|
|
- List<InvalidProcessVO> invalidProcessVOS =this.loadInvalidProcess(invalidProcessList);
|
|
|
+ List<InvalidProcessVO> invalidProcessVOS = this.loadInvalidProcess(invalidProcessList);
|
|
|
return invalidProcessVOS;
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<InvalidProcessVO> loadInvalidProcess(List<InvalidProcess> invalidProcessList){
|
|
|
- List<InvalidProcessVO> invalidProcessVOS =new ArrayList<>();
|
|
|
- if(invalidProcessList.size()==0)
|
|
|
- {
|
|
|
+ public List<InvalidProcessVO> loadInvalidProcess(List<InvalidProcess> invalidProcessList) throws IOException {
|
|
|
+ List<InvalidProcessVO> invalidProcessVOS = new ArrayList<>();
|
|
|
+ if (invalidProcessList.size() == 0) {
|
|
|
return invalidProcessVOS;
|
|
|
}
|
|
|
- List<Integer> oralIds =invalidProcessList.stream().filter(item->item.getProcessType().equals(0)).map(InvalidProcess::getOralExamId).collect(Collectors.toList());
|
|
|
- List<Integer> fileIds =invalidProcessList.stream().filter(item->!item.getProcessType().equals(0)).map(InvalidProcess::getFileId).collect(Collectors.toList());
|
|
|
- //查询口审记录集合
|
|
|
- List<OralExam> oralExams =new ArrayList<>();
|
|
|
+ List<Integer> oralIds = invalidProcessList.stream().filter(item -> item.getProcessType().equals(0)).map(InvalidProcess::getOralExamId).collect(Collectors.toList());
|
|
|
+ List<Integer> fileIds = invalidProcessList.stream().filter(item -> !item.getProcessType().equals(0)).map(InvalidProcess::getFileId).collect(Collectors.toList());
|
|
|
+ //查询口审记录集合
|
|
|
+ List<OralExam> oralExams = new ArrayList<>();
|
|
|
//查询文件集合
|
|
|
- List<ReportFiles> reportFiles =new ArrayList<>();
|
|
|
- if(oralIds.size()>0){
|
|
|
- LambdaQueryWrapper<OralExam> examWrapper =new LambdaQueryWrapper<>();
|
|
|
- examWrapper.in(OralExam::getId,oralIds);
|
|
|
- oralExams= oralExamService.list(examWrapper);
|
|
|
- }
|
|
|
- if(fileIds.size()>0){
|
|
|
- LambdaQueryWrapper<ReportFiles> examWrapper =new LambdaQueryWrapper<>();
|
|
|
- examWrapper.in(ReportFiles::getId,fileIds);
|
|
|
- reportFiles= reportFileService.list(examWrapper);
|
|
|
- }
|
|
|
+ List<ReportFiles> reportFiles = new ArrayList<>();
|
|
|
+ if (oralIds.size() > 0) {
|
|
|
+ LambdaQueryWrapper<OralExam> examWrapper = new LambdaQueryWrapper<>();
|
|
|
+ examWrapper.in(OralExam::getId, oralIds);
|
|
|
+ oralExams = oralExamService.list(examWrapper);
|
|
|
+ }
|
|
|
+ if (fileIds.size() > 0) {
|
|
|
+// LambdaQueryWrapper<ReportFiles> examWrapper = new LambdaQueryWrapper<>();
|
|
|
+// examWrapper.in(ReportFiles::getId, fileIds);
|
|
|
+// reportFiles = reportFileService.list(examWrapper);
|
|
|
+ String res = fileManagerService.getSystemFileFromFMS(fileIds);
|
|
|
+ List<SystemFile> systemFiles = JSONArray.parseArray(res, SystemFile.class);
|
|
|
+ systemFiles.forEach(systemFile -> {
|
|
|
+ ReportFiles reportFile = new ReportFiles();
|
|
|
+ SystemFileToReportFile.systemFileToReportFile(systemFile, reportFile);
|
|
|
+ reportFiles.add(reportFile);
|
|
|
+ });
|
|
|
+ }
|
|
|
//口审记录集合
|
|
|
- List<OralExam> oralExamTrue =oralExams;
|
|
|
+ List<OralExam> oralExamTrue = oralExams;
|
|
|
//文件集合
|
|
|
- List<ReportFiles> reportFileTrue =reportFiles;
|
|
|
- //遍历装载
|
|
|
- invalidProcessList.forEach(item->{
|
|
|
- InvalidProcessVO invalidProcessVO =new InvalidProcessVO();
|
|
|
- BeanUtils.copyProperties(item,invalidProcessVO);
|
|
|
+ List<ReportFiles> reportFileTrue = reportFiles;
|
|
|
+ //遍历装载
|
|
|
+ invalidProcessList.forEach(item -> {
|
|
|
+ InvalidProcessVO invalidProcessVO = new InvalidProcessVO();
|
|
|
+ BeanUtils.copyProperties(item, invalidProcessVO);
|
|
|
//装载文件信息
|
|
|
- if(!item.getProcessType().equals(0)){
|
|
|
- ReportFiles reportFile =reportFileTrue.stream().filter(tem->tem.getId().equals(item.getFileId())).findFirst().orElse(null);
|
|
|
- if(reportFile!=null){
|
|
|
- InvalidProcessVO.reportFileIn reportFileIn=new InvalidProcessVO.reportFileIn();
|
|
|
+ if (!item.getProcessType().equals(0)) {
|
|
|
+ ReportFiles reportFile = reportFileTrue.stream().filter(tem -> tem.getId().equals(item.getFileId())).findFirst().orElse(null);
|
|
|
+ if (reportFile != null) {
|
|
|
+ InvalidProcessVO.reportFileIn reportFileIn = new InvalidProcessVO.reportFileIn();
|
|
|
reportFileIn.setName(reportFile.getName());
|
|
|
reportFileIn.setUrl(reportFile.getUrl());
|
|
|
reportFileIn.setSuffix(reportFile.getSuffix());
|
|
|
invalidProcessVO.setReportFile(reportFileIn);
|
|
|
}
|
|
|
}
|
|
|
- //装载口审记录
|
|
|
- if(item.getProcessType().equals(0)){
|
|
|
- OralExam oralExam =oralExamTrue.stream().filter(tem->tem.getId().equals(item.getOralExamId())).findFirst().orElse(null);
|
|
|
- if(oralExam!=null){
|
|
|
- InvalidProcessVO.OralExamIn oralExamIn =new InvalidProcessVO.OralExamIn();
|
|
|
- oralExamIn.setAddress(oralExam.getAddress());
|
|
|
- oralExamIn.setParticipants(oralExam.getParticipants());
|
|
|
- invalidProcessVO.setOralExam(oralExamIn);
|
|
|
+ //装载口审记录
|
|
|
+ if (item.getProcessType().equals(0)) {
|
|
|
+ OralExam oralExam = oralExamTrue.stream().filter(tem -> tem.getId().equals(item.getOralExamId())).findFirst().orElse(null);
|
|
|
+ if (oralExam != null) {
|
|
|
+ InvalidProcessVO.OralExamIn oralExamIn = new InvalidProcessVO.OralExamIn();
|
|
|
+ oralExamIn.setAddress(oralExam.getAddress());
|
|
|
+ oralExamIn.setParticipants(oralExam.getParticipants());
|
|
|
+ invalidProcessVO.setOralExam(oralExamIn);
|
|
|
}
|
|
|
}
|
|
|
invalidProcessVOS.add(invalidProcessVO);
|
|
|
});
|
|
|
|
|
|
|
|
|
-return invalidProcessVOS;
|
|
|
+ return invalidProcessVOS;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|