|
@@ -23,6 +23,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
@@ -150,6 +151,7 @@ public class FollowUpServiceImpl implements IFollowUpService {
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
Date finishTime = simpleDateFormat.parse(date);//转换为Date类型
|
|
|
System.out.println("等级结果当前完成时间"+ finishTime);
|
|
|
+
|
|
|
FollowUp followUp = new FollowUp();
|
|
|
//从registerDTO中取出后续事项id进行对应的操作
|
|
|
followUp.setId(register.getFollowUpId());
|
|
@@ -169,6 +171,32 @@ public class FollowUpServiceImpl implements IFollowUpService {
|
|
|
List<Integer> fileIds = reportFileService.uploadFiles(files);
|
|
|
this.addAsso(register.getFollowUpId(), fileIds);
|
|
|
}
|
|
|
+ //简化定义后续事项id
|
|
|
+ int followUpId = register.getFollowUpId();
|
|
|
+ //根据后续事项id查询关联表找出所有fileId
|
|
|
+ List<Integer> fileIdS = followUpMapper.queryFileIdByFollowUpId(followUpId);
|
|
|
+ //判断第二次登记结果时候文件数量
|
|
|
+ if(register.getFilesVOs() != null){//传入不为空
|
|
|
+ List<FilesVO> filesVOs= register.getFilesVOs();
|
|
|
+ //遍历前端传入数据,取得fileId的集合ids
|
|
|
+ List<Integer> ids = new ArrayList<>();
|
|
|
+ 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,就是没有,需要删除
|
|
|
+ deleteIds.add(fileId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ followUpMapper.deleteAssoId(followUpId,deleteIds);
|
|
|
+ log.info("多余关联附件删除完成");
|
|
|
+ }else{//传入为空数组 等于附件需要全部删除
|
|
|
+ followUpMapper.deleteAssoId(followUpId,fileIdS);
|
|
|
+ }
|
|
|
//批量新增后续事项
|
|
|
this.add(register.getFollowUps());
|
|
|
}
|
|
@@ -194,4 +222,21 @@ public class FollowUpServiceImpl implements IFollowUpService {
|
|
|
}log.info("新增后续事项和附件id关联表完成");
|
|
|
return Response.success();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 第二次登记结果,根据传入的register中的followUpId和filesVOs中的fileId删除关联表中的多出的数据
|
|
|
+ *
|
|
|
+ * @param followUpId 后续事项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);
|
|
|
+ log.info("多余关联附件删除完成");
|
|
|
+ } else {
|
|
|
+ log.info("删除多余关联附件失败,多余关联附件不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|