|
@@ -43,6 +43,7 @@ import com.jeeplus.test.oss.service.OSSClientService;
|
|
|
import com.jeeplus.test.oss.service.OssService;
|
|
|
import com.jeeplus.test.signature.domain.*;
|
|
|
import com.jeeplus.test.signature.utils.SignaturePostUtil;
|
|
|
+import com.jeeplus.test.workContract.service.dto.WorkAttachmentDto;
|
|
|
import org.apache.commons.beanutils.BeanMap;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.flowable.engine.TaskService;
|
|
@@ -148,189 +149,34 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
report.setUpdateBy(userDTO.getId());
|
|
|
report.setUpdateDate(new Date());
|
|
|
reportMapper.updateById(report);
|
|
|
- //附件信息修改
|
|
|
- //1、修改work_attachment_id信息
|
|
|
- //删除在添加
|
|
|
- List<CwProjectInfoData> infoList = new ArrayList<>();
|
|
|
- if (null != report.getCwProjectInfoList()){
|
|
|
- infoList = report.getCwProjectInfoList();
|
|
|
- if ( null != infoList &infoList.size()>0){
|
|
|
- infoList.forEach(info->{
|
|
|
- //删除
|
|
|
- List<String> attachmentId = attachmentMapper.getIdByAttachmentId(info.getId());
|
|
|
- //根据这个id删除cw_project_report_file信息
|
|
|
- if (null != attachmentId) {
|
|
|
- attachmentId.forEach(atId->{
|
|
|
- attachmentMapper.deleteByRepotyId(atId);
|
|
|
- });
|
|
|
- }
|
|
|
- //删除work_attachment_id信息
|
|
|
- attachmentMapper.deleteByAttachMnentId(info.getId());
|
|
|
- });
|
|
|
- List<CwProjectInfoData> newList = infoMapper.selectInfoByReportId(report.getId());
|
|
|
- List<String> ids = infoMapper.getId(report.getId());
|
|
|
-
|
|
|
- List<CwProjectInfoData> finalInfoList = infoList;
|
|
|
-
|
|
|
- finalInfoList.forEach(in->{
|
|
|
- if (ids.contains(in.getId())){
|
|
|
- ids.remove(in.getId());
|
|
|
- }
|
|
|
- });
|
|
|
- //删除新建行
|
|
|
- ids.forEach(id->{
|
|
|
- List<String> attachmentId = attachmentMapper.getIdByAttachmentId(id);
|
|
|
- //根据这个id删除cw_project_report_file信息
|
|
|
- attachmentId.forEach(atId->{
|
|
|
- attachmentMapper.deleteByRepotyId(atId);
|
|
|
- });
|
|
|
- //删除work_attachment_id信息
|
|
|
- attachmentMapper.deleteByAttachMnentId(id);
|
|
|
- //删除cw_project_report_new_line表信息
|
|
|
- //删除前先将report_no放入到cw_project_report_cancel报废表中
|
|
|
- CwProjectInfoData data = infoMapper.getById(id);
|
|
|
- if (StringUtils.isNotEmpty(data.getReportNo())){
|
|
|
- CwProjectReportCancel cancel = new CwProjectReportCancel();
|
|
|
- cancel.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
- cancel.setReportNo(data.getReportNo());
|
|
|
- cancelMapper.insert(cancel);
|
|
|
- }
|
|
|
- infoMapper.deleteById(data.getId());
|
|
|
- });
|
|
|
- finalInfoList.forEach(in->{
|
|
|
- in.setUpdateBy(UserUtils.getCurrentUserDTO().getId());
|
|
|
- in.setUpdateDate(new Date());
|
|
|
- in.setReportId(report.getId());
|
|
|
- //根据reportid查出所以的newline数据
|
|
|
-// if (null != newList){
|
|
|
-// newList.forEach(n->{
|
|
|
-// //当传入的id与数据库中的不匹配的时候,删除不匹配的信息
|
|
|
-// if (null != in.getId()){
|
|
|
-// if (!n.getId().equals(in.getId())){
|
|
|
-//// infoMapper.deleteById(n.getId());
|
|
|
-// //将报告文号放入到报告文号报废表中
|
|
|
-// CwProjectReportCancel cancel = new CwProjectReportCancel();
|
|
|
-// cancel.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
-// cancel.setReportNo(n.getReportNo());
|
|
|
-// cancelMapper.insert(cancel);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
- //先去数据库中查是否有数据,有则更新,无则添加
|
|
|
- CwProjectInfoData cwProjectInfoData = infoMapper.getById(in.getId());
|
|
|
- if (cwProjectInfoData == null){
|
|
|
- try {
|
|
|
- //在插入报告文号前先去报告文号报废表中根据时间排序查看是否有报告文号,有则使用,delflag改为1
|
|
|
- List<String> reportNo = infoMapper.getReportNo();
|
|
|
- if (null != reportNo & reportNo.size()>0){
|
|
|
-// for (int i = 0; i< finalInfoList.size(); i++){
|
|
|
-// in.setReportNo(reportNo.get(i));
|
|
|
-// //修改报废表的对应数据delflag为1
|
|
|
-// cancelMapper.updateFlag("1",reportNo.get(i));
|
|
|
-// }
|
|
|
- in.setReportNo(reportNo.get(0));
|
|
|
-// //修改报废表的对应数据delflag为1
|
|
|
- cancelMapper.updateFlag("1",reportNo.get(0));
|
|
|
- }else {
|
|
|
- String documentNo = serialnumTplService.genSerialNum(userDTO.getCompanyDTO().getId(), CwProjectInfoData.BIZ_CODE);
|
|
|
- in.setReportNo(documentNo);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- //报告流水号生成 根据项目编号去new_line表查询
|
|
|
- String reportNumber = infoMapper.selectReportNumberByProjectNo(report.getProjectNumber());
|
|
|
- int stress = 0;
|
|
|
- if (null != reportNumber){
|
|
|
- if (reportNumber.contains(report.getProjectNumber() + "-0")){
|
|
|
- stress = reportNumber.indexOf("-0");//分隔符位置
|
|
|
- }else {
|
|
|
- stress = reportNumber.indexOf("-");//分隔符位置
|
|
|
- }
|
|
|
- String substring = reportNumber.substring(stress + 1, reportNumber.length());
|
|
|
- Integer integer = Integer.valueOf(substring);
|
|
|
- String newReportNumber = "";
|
|
|
- if (integer>=9){
|
|
|
- newReportNumber = report.getProjectNumber() + "-" + (integer + 1);
|
|
|
- }else {
|
|
|
- newReportNumber = report.getProjectNumber() + "-0" + (integer + 1);
|
|
|
- }
|
|
|
- in.setReportNumber(newReportNumber);
|
|
|
- }else {
|
|
|
- in.setReportNumber(report.getProjectNumber() + "-0" + "1");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- infoMapper.insert(in);
|
|
|
- }else {
|
|
|
- infoMapper.updateById(in);
|
|
|
- }
|
|
|
-
|
|
|
- //对上传的文件数据进行持久化操作
|
|
|
- List<ProjectReportWorkAttachmentDTO> fileInfoList = new ArrayList<>();
|
|
|
- if ( null !=in.getCwFileInfoList()){
|
|
|
- fileInfoList = in.getCwFileInfoList();
|
|
|
- }
|
|
|
-
|
|
|
-// UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
- ossServiceMapper.delete(new QueryWrapper<WorkAttachment>().lambda().eq(WorkAttachment::getAttachmentId, in.getId()));
|
|
|
- AtomicInteger j = new AtomicInteger(1);
|
|
|
- if (null != fileInfoList){
|
|
|
- fileInfoList.forEach(item -> {
|
|
|
- WorkAttachment i = new WorkAttachment();
|
|
|
- //包含了url、size、name
|
|
|
- i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
- i.setCreateDate(new Date());
|
|
|
- i.setUpdateDate(new Date());
|
|
|
- i.setDelFlag(0);
|
|
|
- i.setUrl(item.getUrl());
|
|
|
- //文件类型处理
|
|
|
- List<String> strings = Arrays.asList(item.getName().split("\\."));
|
|
|
- if (CollectionUtils.isNotEmpty(strings)) {
|
|
|
- i.setType(strings.get(1));
|
|
|
- }
|
|
|
- i.setAttachmentId(in.getId());
|
|
|
- i.setAttachmentName(item.getName());
|
|
|
- i.setAttachmentFlag("cw_project_report_file");
|
|
|
- i.setFileSize(item.getSize());
|
|
|
- i.setSort(j.get());
|
|
|
- ossServiceMapper.insertWorkAttachment(i, userDTO);
|
|
|
- j.getAndIncrement();
|
|
|
- CwProjectReportFile cwProjectReportFile = CwProjectReportFileWrapper.INSTANCE.toEntity(item);
|
|
|
- cwProjectReportFile.setReportFileId(i.getId());
|
|
|
- attachmentMapper.insert(cwProjectReportFile);
|
|
|
- });
|
|
|
- }
|
|
|
+ //修改新增行数据
|
|
|
+ CwProjectInfoData infoData = infoMapper.selectInfoByReportId(report.getId());
|
|
|
+ infoData.setServedUnitName(report.getServedUnitName());
|
|
|
+ infoData.setReportDate(report.getReportDate());
|
|
|
+ infoData.setReportType(report.getReportType());
|
|
|
+ infoData.setOpinionType(report.getOpinionType());
|
|
|
+ infoData.setSealType(report.getSealType());
|
|
|
+ infoData.setServedUnitId(report.getServedUnitId());
|
|
|
+ infoData.setUpdateBy(UserUtils.getCurrentUserDTO().getId());
|
|
|
+ infoData.setUpdateDate(new Date());
|
|
|
+ infoMapper.updateById(infoData);
|
|
|
+ //对上传的文件数据进行持久化操作
|
|
|
+ List<ProjectReportWorkAttachmentDTO> cwFileInfoList = report.getCwFileInfoList();
|
|
|
+ if (CollectionUtils.isNotEmpty(cwFileInfoList)) {
|
|
|
+ updateFiles(cwFileInfoList, userDTO, report.getId());
|
|
|
+ } else {
|
|
|
+ //删除所有的文件信息
|
|
|
+ List<String> ids = attachmentMapper.getIdByAttachmentId(report.getId());
|
|
|
+ ids.forEach(id->{
|
|
|
+ List<String> fileId = attachmentMapper.getFileId(id);
|
|
|
+ fileId.forEach(fidId->{
|
|
|
+ attachmentMapper.deleteById(fidId);
|
|
|
});
|
|
|
- }else {
|
|
|
- List<CwProjectInfoData> idList = infoMapper.selectIdByReportId(report.getId());
|
|
|
- if (null != idList & idList.size()>0){
|
|
|
- idList.forEach(info->{
|
|
|
- List<String> attachmentId = attachmentMapper.getIdByAttachmentId(info.getId());
|
|
|
- //根据这个id删除cw_project_report_file信息
|
|
|
- attachmentId.forEach(atId->{
|
|
|
- attachmentMapper.deleteByRepotyId(atId);
|
|
|
- });
|
|
|
- //删除work_attachment_id信息
|
|
|
- attachmentMapper.deleteByAttachMnentId(info.getId());
|
|
|
- //删除cw_project_report_new_line表信息
|
|
|
- //删除前先将report_no放入到cw_project_report_cancel报废表中
|
|
|
- if (StringUtils.isNotEmpty(info.getReportNo())){
|
|
|
- CwProjectReportCancel cancel = new CwProjectReportCancel();
|
|
|
- cancel.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
- cancel.setReportNo(info.getReportNo());
|
|
|
- cancelMapper.insert(cancel);
|
|
|
- }
|
|
|
- infoMapper.deleteById(info.getId());
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
+ ossServiceMapper.deleteById(id);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-
|
|
|
return report.getId();
|
|
|
}
|
|
|
|
|
@@ -376,98 +222,95 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
}
|
|
|
}
|
|
|
//对新增行数据进行持久化操作
|
|
|
- List<CwProjectInfoData> infoList = new ArrayList<>();
|
|
|
- if ( null != report.getCwProjectInfoList()) {
|
|
|
- infoList = report.getCwProjectInfoList();
|
|
|
+ CwProjectInfoData infoData = new CwProjectInfoData();
|
|
|
+// List<CwProjectInfoData> infoList = new ArrayList<>();
|
|
|
+ infoData.setCreateBy(UserUtils.getCurrentUserDTO().getId());
|
|
|
+ infoData.setCreateDate(new Date());
|
|
|
+ infoData.setUpdateBy(UserUtils.getCurrentUserDTO().getId());
|
|
|
+ infoData.setUpdateDate(new Date());
|
|
|
+ infoData.setReportId(report.getId());
|
|
|
+ String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ infoData.setId(id);
|
|
|
+ infoData.setServedUnitName(report.getServedUnitName());
|
|
|
+ infoData.setReportDate(report.getReportDate());
|
|
|
+ infoData.setReportType(report.getReportType());
|
|
|
+ infoData.setOpinionType(report.getOpinionType());
|
|
|
+ infoData.setSealType(report.getSealType());
|
|
|
+ infoData.setServedUnitId(report.getServedUnitId());
|
|
|
+ //报告文号生成
|
|
|
+ String documentNo = "";
|
|
|
+ try {
|
|
|
+ documentNo = serialnumTplService.genSerialNum(userDTO.getCompanyDTO().getId(), CwProjectInfoData.BIZ_CODE);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
+ //在插入报告文号前先去报告文号报废表中根据时间排序查看是否有报告文号,有则使用,delflag改为1
|
|
|
+ List<String> reportNo = infoMapper.getReportNo();
|
|
|
+ if (null!= reportNo & reportNo.size()>0){
|
|
|
+ infoData.setReportNo(reportNo.get(0));
|
|
|
+ cancelMapper.updateFlag("1",reportNo.get(0));
|
|
|
+ }else {
|
|
|
+ infoData.setReportNo(documentNo);
|
|
|
+ }
|
|
|
+ //报告流水号生成 根据项目编号去new_line表查询
|
|
|
+ String reportNumber = infoMapper.selectReportNumberByProjectNo(report.getProjectNumber());
|
|
|
+ int stress = 0;
|
|
|
+ if (null != reportNumber){
|
|
|
+ if (reportNumber.contains(report.getProjectNumber() + "-0")){
|
|
|
+ stress = reportNumber.indexOf("-0");//分隔符位置
|
|
|
+ }else {
|
|
|
+ stress = reportNumber.indexOf("-");//分隔符位置
|
|
|
+ }
|
|
|
+ String substring = reportNumber.substring(stress + 1, reportNumber.length());
|
|
|
+ int integer = Integer.parseInt(substring);
|
|
|
|
|
|
- if(null != infoList){
|
|
|
- List<CwProjectInfoData> finalInfoList = infoList;
|
|
|
- finalInfoList.forEach(in->{
|
|
|
- in.setCreateBy(UserUtils.getCurrentUserDTO().getId());
|
|
|
- in.setCreateDate(new Date());
|
|
|
- in.setUpdateBy(UserUtils.getCurrentUserDTO().getId());
|
|
|
- in.setUpdateDate(new Date());
|
|
|
- in.setReportId(report.getId());
|
|
|
- //报告文号生成
|
|
|
- String documentNo = "";
|
|
|
- try {
|
|
|
- documentNo = serialnumTplService.genSerialNum(userDTO.getCompanyDTO().getId(), CwProjectInfoData.BIZ_CODE);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- //在插入报告文号前先去报告文号报废表中根据时间排序查看是否有报告文号,有则使用,delflag改为1
|
|
|
- List<String> reportNo = infoMapper.getReportNo();
|
|
|
- if (null!= reportNo & reportNo.size()>0){
|
|
|
-// for (int i = 0; i< finalInfoList.size(); i++){
|
|
|
-// in.setReportNo(reportNo.get(i));
|
|
|
-// }
|
|
|
- in.setReportNo(reportNo.get(0));
|
|
|
- cancelMapper.updateFlag("1",reportNo.get(0));
|
|
|
- }else {
|
|
|
- in.setReportNo(documentNo);
|
|
|
- }
|
|
|
-
|
|
|
- //报告流水号生成 根据项目编号去new_line表查询
|
|
|
- String reportNumber = infoMapper.selectReportNumberByProjectNo(report.getProjectNumber());
|
|
|
- int stress = 0;
|
|
|
- if (null != reportNumber){
|
|
|
- if (reportNumber.contains(report.getProjectNumber() + "-0")){
|
|
|
- stress = reportNumber.indexOf("-0");//分隔符位置
|
|
|
- }else {
|
|
|
- stress = reportNumber.indexOf("-");//分隔符位置
|
|
|
- }
|
|
|
- String substring = reportNumber.substring(stress + 1, reportNumber.length());
|
|
|
- Integer integer = Integer.valueOf(substring);
|
|
|
-
|
|
|
- String newReportNumber = "";
|
|
|
- if (integer>=9){
|
|
|
- newReportNumber = report.getProjectNumber() + "-" + (integer + 1);
|
|
|
- }else {
|
|
|
- newReportNumber = report.getProjectNumber() + "-0" + (integer + 1);
|
|
|
- }
|
|
|
+ String newReportNumber = "";
|
|
|
+ if (integer>=9){
|
|
|
+ newReportNumber = report.getProjectNumber() + "-" + (integer + 1);
|
|
|
+ }else {
|
|
|
+ newReportNumber = report.getProjectNumber() + "-0" + (integer + 1);
|
|
|
+ }
|
|
|
|
|
|
- in.setReportNumber(newReportNumber);
|
|
|
- }else {
|
|
|
- in.setReportNumber(report.getProjectNumber() + "-0" + "1");
|
|
|
- }
|
|
|
+ infoData.setReportNumber(newReportNumber);
|
|
|
+ }else {
|
|
|
+ infoData.setReportNumber(report.getProjectNumber() + "-0" + "1");
|
|
|
+ }
|
|
|
+ infoMapper.insert(infoData);
|
|
|
|
|
|
- infoMapper.insert(in);
|
|
|
- //对上传的文件数据进行持久化操作
|
|
|
- List<ProjectReportWorkAttachmentDTO> fileInfoList = new ArrayList<>();
|
|
|
- if ( null !=in.getCwFileInfoList()){
|
|
|
- fileInfoList = in.getCwFileInfoList();
|
|
|
- }
|
|
|
- ossServiceMapper.delete(new QueryWrapper<WorkAttachment>().lambda().eq(WorkAttachment::getAttachmentId, in.getId()));
|
|
|
- AtomicInteger j = new AtomicInteger(1);
|
|
|
- if (fileInfoList != null){
|
|
|
- fileInfoList.forEach(item -> {
|
|
|
- WorkAttachment i = new WorkAttachment();
|
|
|
- //包含了url、size、name
|
|
|
- i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
- i.setCreateDate(new Date());
|
|
|
- i.setUpdateDate(new Date());
|
|
|
- i.setDelFlag(0);
|
|
|
- i.setUrl(item.getUrl());
|
|
|
- //文件类型处理
|
|
|
- List<String> strings = Arrays.asList(item.getName().split("\\."));
|
|
|
- if (CollectionUtils.isNotEmpty(strings)) {
|
|
|
- i.setType(strings.get(1));
|
|
|
- }
|
|
|
- i.setAttachmentId(in.getId());
|
|
|
- i.setAttachmentName(item.getName());
|
|
|
- i.setAttachmentFlag("cw_project_report_file");
|
|
|
- i.setFileSize(item.getSize());
|
|
|
- i.setSort(j.get());
|
|
|
- ossServiceMapper.insertWorkAttachment(i, userDTO);
|
|
|
- j.getAndIncrement();
|
|
|
- CwProjectReportFile cwProjectReportFile = CwProjectReportFileWrapper.INSTANCE.toEntity(item);
|
|
|
- cwProjectReportFile.setReportFileId(i.getId());
|
|
|
- attachmentMapper.insert(cwProjectReportFile);
|
|
|
- });
|
|
|
+ //对上传的文件数据进行持久化操作
|
|
|
+ List<ProjectReportWorkAttachmentDTO> fileInfoList = new ArrayList<>();
|
|
|
+ if ( null !=report.getCwFileInfoList()){
|
|
|
+ fileInfoList = report.getCwFileInfoList();
|
|
|
+ }
|
|
|
+ ossServiceMapper.delete(new QueryWrapper<WorkAttachment>().lambda().eq(WorkAttachment::getAttachmentId, report.getId()));
|
|
|
+ AtomicInteger j = new AtomicInteger(1);
|
|
|
+ if (fileInfoList != null){
|
|
|
+ fileInfoList.forEach(item -> {
|
|
|
+ WorkAttachment i = new WorkAttachment();
|
|
|
+ //包含了url、size、name
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
+ i.setCreateDate(new Date());
|
|
|
+ i.setUpdateDate(new Date());
|
|
|
+ i.setDelFlag(0);
|
|
|
+ i.setUrl(item.getUrl());
|
|
|
+ //文件类型处理
|
|
|
+ List<String> strings = Arrays.asList(item.getName().split("\\."));
|
|
|
+ if (CollectionUtils.isNotEmpty(strings)) {
|
|
|
+ i.setType(strings.get(1));
|
|
|
}
|
|
|
+ i.setAttachmentId(report.getId());
|
|
|
+ i.setAttachmentName(item.getName());
|
|
|
+ i.setAttachmentFlag("cw_project_report_file");
|
|
|
+ i.setFileSize(item.getSize());
|
|
|
+ i.setSort(j.get());
|
|
|
+ ossServiceMapper.insertWorkAttachment(i, userDTO);
|
|
|
+ j.getAndIncrement();
|
|
|
+ CwProjectReportFile cwProjectReportFile = CwProjectReportFileWrapper.INSTANCE.toEntity(item);
|
|
|
+ cwProjectReportFile.setReportFileId(i.getId());
|
|
|
+ attachmentMapper.insert(cwProjectReportFile);
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
this.reportMapper.insert(report);
|
|
|
|
|
|
// 添加签章流程初始数据
|
|
@@ -537,87 +380,46 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
public CwProjectReportData queryById(String id) {
|
|
|
|
|
|
CwProjectReportData reportData = reportMapper.queryById(id);
|
|
|
+
|
|
|
//将新增行数据查询出来放入到cwProjectInfoList中
|
|
|
- List<CwProjectInfoData> cwProjectInfoData = infoMapper.selectByReportId(id);
|
|
|
- List<CwProjectInfoData> infoData = new ArrayList<>();
|
|
|
- //根据新增行id查出上传的附件信息
|
|
|
- cwProjectInfoData.forEach(info->{
|
|
|
- //保存到work_attachment表中的信息
|
|
|
- List<ProjectReportWorkAttachmentDTO> dtos = attachmentMapper.selectByInfoId(info.getId());
|
|
|
- List<ProjectReportWorkAttachmentDTO> dtoList = new ArrayList<>();
|
|
|
- dtos.forEach(d->{
|
|
|
- //根据id查出cw_project_report_file文件表的其他信息
|
|
|
- CwProjectReportFile file = attachmentMapper.selectInfoByFileId(d.getId());
|
|
|
- d.setFileType(file.getFileType());
|
|
|
- d.setSealType(file.getSealType());
|
|
|
- d.setSealedFile(file.getSealedFile());
|
|
|
- d.setSealUser(file.getSealUser());
|
|
|
- d.setSealDate(file.getSealDate());
|
|
|
- d.setRemarks(file.getRemarks());
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- //根据创建人id查出创建人名称
|
|
|
- String name = reportMapper.getUserNameById(file.getCreateBy());
|
|
|
- userDTO.setId(file.getCreateBy());
|
|
|
- userDTO.setName(name);
|
|
|
- d.setCreateBy(userDTO);
|
|
|
- d.setCreateDate(file.getCreateDate());
|
|
|
- dtoList.add(d);
|
|
|
- });
|
|
|
- info.setCwFileInfoList(dtoList);
|
|
|
- infoData.add(info);
|
|
|
- });
|
|
|
- //根据项目id查出所有的新增行数据及对应的附件
|
|
|
- List<CwProjectInfoData> dataList = new ArrayList<>();
|
|
|
- if (null !=reportData){
|
|
|
- if (StringUtils.isNotEmpty(reportData.getProjectId())){
|
|
|
- String projectId = reportData.getProjectId();
|
|
|
- //根据项目id找出所有的reportID
|
|
|
- List<CwProjectReportData> byProjectId = reportMapper.getByProjectId(projectId);
|
|
|
- //根据查出的report信息查新建行数据
|
|
|
- byProjectId.forEach(by->{
|
|
|
- List<CwProjectInfoData> byReportId = infoMapper.getByReportId(by.getId());
|
|
|
- byReportId.forEach(byr->{
|
|
|
- //保存到work_attachment表中的信息
|
|
|
- List<ProjectReportWorkAttachmentDTO> dtos = attachmentMapper.selectByInfoId(byr.getId());
|
|
|
- List<ProjectReportWorkAttachmentDTO> dtoList = new ArrayList<>();
|
|
|
- dtos.forEach(d->{
|
|
|
- //根据id查出cw_project_report_file文件表的其他信息
|
|
|
- CwProjectReportFile file = attachmentMapper.selectInfoByFileId(d.getId());
|
|
|
- d.setFileType(file.getFileType());
|
|
|
- d.setSealType(file.getSealType());
|
|
|
- d.setSealedFile(file.getSealedFile());
|
|
|
- d.setSealUser(file.getSealUser());
|
|
|
- d.setSealDate(file.getSealDate());
|
|
|
- d.setRemarks(file.getRemarks());
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- //根据创建人id查出创建人名称
|
|
|
- String name = reportMapper.getUserNameById(file.getCreateBy());
|
|
|
- userDTO.setId(file.getCreateBy());
|
|
|
- userDTO.setName(name);
|
|
|
- d.setCreateBy(userDTO);
|
|
|
- d.setCreateDate(file.getCreateDate());
|
|
|
- dtoList.add(d);
|
|
|
- });
|
|
|
- byr.setCwFileInfoList(dtoList);
|
|
|
- byr.setDocumentStatus("已完成");
|
|
|
- dataList.add(byr);
|
|
|
- });
|
|
|
+ CwProjectInfoData cwProjectInfoData = infoMapper.selectByReportId(id);
|
|
|
+ if (null != cwProjectInfoData){
|
|
|
+ reportData.setServedUnitName(cwProjectInfoData.getServedUnitName());
|
|
|
+ reportData.setServedUnitId(cwProjectInfoData.getServedUnitId());
|
|
|
+ reportData.setReportDate(cwProjectInfoData.getReportDate());
|
|
|
+ reportData.setReportType(cwProjectInfoData.getReportType());
|
|
|
+ reportData.setReportNumber(cwProjectInfoData.getReportNumber());
|
|
|
+ reportData.setReportNo(cwProjectInfoData.getReportNo());
|
|
|
+ reportData.setSealType(cwProjectInfoData.getSealType());
|
|
|
+ }
|
|
|
|
|
|
+// List<CwProjectInfoData> infoData = new ArrayList<>();
|
|
|
+
|
|
|
+ List<ProjectReportWorkAttachmentDTO> dtoList = new ArrayList<>();
|
|
|
+ if ( null != reportData){
|
|
|
+ List<ProjectReportWorkAttachmentDTO> dtos = attachmentMapper.selectByInfoId(reportData.getId());
|
|
|
+ if (null != dtos){
|
|
|
+ dtos.forEach(d->{
|
|
|
+ //根据id查出cw_project_report_file文件表的其他信息
|
|
|
+ CwProjectReportFile file = attachmentMapper.selectInfoByFileId(d.getId());
|
|
|
+ d.setFileType(file.getFileType());
|
|
|
+ d.setSealType(file.getSealType());
|
|
|
+ d.setSealedFile(file.getSealedFile());
|
|
|
+ d.setSealUser(file.getSealUser());
|
|
|
+ d.setSealDate(file.getSealDate());
|
|
|
+ d.setRemarks(file.getRemarks());
|
|
|
+ UserDTO userDTO = new UserDTO();
|
|
|
+ //根据创建人id查出创建人名称
|
|
|
+ String name = reportMapper.getUserNameById(file.getCreateBy());
|
|
|
+ userDTO.setId(file.getCreateBy());
|
|
|
+ userDTO.setName(name);
|
|
|
+ d.setCreateBy(userDTO);
|
|
|
+ d.setCreateDate(file.getCreateDate());
|
|
|
+ dtoList.add(d);
|
|
|
});
|
|
|
+ reportData.setCwFileInfoList(dtoList);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (infoData != null & !infoData.isEmpty()){
|
|
|
- reportData.setCwProjectInfoList(infoData);
|
|
|
- }
|
|
|
- if (dataList != null & !dataList.isEmpty()){
|
|
|
- reportData.setCwWorkClientContactDTOList(dataList);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
return reportData;
|
|
|
}
|
|
|
|
|
@@ -625,9 +427,28 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
String idArray[] =ids.split(",");
|
|
|
//删除 cw_project_report_new_line表信息 cw_project_report_file信息 work_attachment_id表信息
|
|
|
//先根据ids找到cw_project_report_new_line表的id,根据id去work_attachment_id表中查出id信息删除cw_project_report_file信息
|
|
|
- List<CwProjectInfoData> idList = infoMapper.selectIdByReportId(ids);
|
|
|
- if (null != idList & idList.size()>0){
|
|
|
- idList.forEach(info->{
|
|
|
+ CwProjectInfoData infoData = infoMapper.selectIdByReportId(ids);
|
|
|
+ if (null != infoData ){
|
|
|
+ //将report_no放入到cw_project_report_cancel报废表中
|
|
|
+ CwProjectReportCancel cancel = new CwProjectReportCancel();
|
|
|
+ cancel.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
+ cancel.setReportNo(infoData.getReportNo());
|
|
|
+ cancelMapper.insert(cancel);
|
|
|
+ //删除被服务单位信息
|
|
|
+ infoMapper.deleteById(infoData.getId());
|
|
|
+ //查询保存的附件信息
|
|
|
+ List<WorkAttachment> infoList = reportMapper.findFileList(ids);
|
|
|
+ //删除附件信息
|
|
|
+ infoList.forEach(in->{
|
|
|
+ //删除新建行文件表id
|
|
|
+ List<String> fileId = attachmentMapper.getFileId(in.getId());
|
|
|
+ fileId.forEach(fid->{
|
|
|
+ attachmentMapper.deleteById(fid);
|
|
|
+ });
|
|
|
+ ossServiceMapper.deleteById(in.getId());
|
|
|
+ });
|
|
|
+
|
|
|
+ /*idList.forEach(info->{
|
|
|
List<String> attachmentId = attachmentMapper.getIdByAttachmentId(info.getId());
|
|
|
//根据这个id删除cw_project_report_file信息
|
|
|
attachmentId.forEach(atId->{
|
|
@@ -644,7 +465,7 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
cancelMapper.insert(cancel);
|
|
|
}
|
|
|
infoMapper.deleteById(info.getId());
|
|
|
- });
|
|
|
+ });*/
|
|
|
}
|
|
|
this.removeByIds (Lists.newArrayList (idArray));
|
|
|
return ResponseEntity.ok ("删除成功");
|
|
@@ -1126,4 +947,70 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
CwProjectReportData reportData = reportMapper.queryByContractId(contractId);
|
|
|
return reportData;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改附件信息
|
|
|
+ * @param list 待修改的附件列表
|
|
|
+ * @param userDTO 当前登录用户
|
|
|
+ * @param id 关联id
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void updateFiles(List<ProjectReportWorkAttachmentDTO> list, UserDTO userDTO, String id) {
|
|
|
+ int j = 1;
|
|
|
+ String names = new String();
|
|
|
+ //表中存在,但是传过来不存在,说明已删除,表中数据也要删除
|
|
|
+ for (ProjectReportWorkAttachmentDTO dto : list) {
|
|
|
+ names = names + "," +dto.getUrl();
|
|
|
+ }
|
|
|
+ //查询保存的附件信息
|
|
|
+ List<WorkAttachment> infoList = reportMapper.findFileList(id);
|
|
|
+ if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(infoList)) {
|
|
|
+ for (WorkAttachment i : infoList) {
|
|
|
+ if (!names.contains(i.getUrl())) {
|
|
|
+ ossServiceMapper.deleteById(i.getId());
|
|
|
+ List<String> fileId = attachmentMapper.getFileId(i.getId());
|
|
|
+ fileId.forEach(fid->{
|
|
|
+ attachmentMapper.deleteById(fid);
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存信息
|
|
|
+ for (ProjectReportWorkAttachmentDTO dto : list) {
|
|
|
+ //判断是否存在
|
|
|
+ Integer isExit = reportMapper.findIsExit(id, dto.getName());
|
|
|
+ if (isExit == 0) {
|
|
|
+ WorkAttachment i = new WorkAttachment();
|
|
|
+ //包含了url、size、name
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
+// i.getCreateBy().setId(userDTO.getId());
|
|
|
+ i.setCreateDate(new Date());
|
|
|
+// i.getUpdateBy().setId(userDTO.getId());
|
|
|
+ i.setUpdateDate(new Date());
|
|
|
+ i.setDelFlag(0);
|
|
|
+ i.setUrl(dto.getUrl());
|
|
|
+ //文件类型处理
|
|
|
+ List<String> strings = Arrays.asList(dto.getName().split("\\."));
|
|
|
+ if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(strings)) {
|
|
|
+ i.setType(strings.get(1));
|
|
|
+ }
|
|
|
+ i.setAttachmentId(id);
|
|
|
+ i.setAttachmentName(dto.getName());
|
|
|
+ i.setAttachmentFlag("cwWorkContract");
|
|
|
+ i.setFileSize(dto.getSize());
|
|
|
+ i.setSort(j);
|
|
|
+ ossServiceMapper.insertWorkAttachment(i, userDTO);
|
|
|
+ CwProjectReportFile reportFile = new CwProjectReportFile();
|
|
|
+ BeanUtils.copyProperties(dto, reportFile);
|
|
|
+ reportFile.setReportFileId(i.getId());
|
|
|
+ attachmentMapper.insert(reportFile);
|
|
|
+ j++;
|
|
|
+ } else {
|
|
|
+// CwProjectReportFile reportFile = new CwProjectReportFile();
|
|
|
+// BeanUtils.copyProperties(dto, reportFile);
|
|
|
+ attachmentMapper.updateFileInfo(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|