|
@@ -139,100 +139,173 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
List<CwProjectInfoData> infoList = new ArrayList<>();
|
|
|
if (null != report.getCwProjectInfoList()){
|
|
|
infoList = report.getCwProjectInfoList();
|
|
|
- infoList.forEach(info->{
|
|
|
- //删除
|
|
|
- List<String> attachmentId = attachmentMapper.getIdByAttachmentId(info.getId());
|
|
|
- //根据这个id删除cw_project_report_file信息
|
|
|
- if (null != attachmentId) {
|
|
|
+ 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(info.getId());
|
|
|
- });
|
|
|
-
|
|
|
- List<CwProjectInfoData> finalInfoList = infoList;
|
|
|
- infoList.forEach(in->{
|
|
|
- in.setUpdateBy(UserUtils.getCurrentUserDTO().getId());
|
|
|
- in.setUpdateDate(new Date());
|
|
|
- in.setReportId(report.getId());
|
|
|
- //根据reportid查出所以的newline数据
|
|
|
- List<CwProjectInfoData> newList = infoMapper.selectInfoByReportId(report.getId());
|
|
|
- newList.forEach(n->{
|
|
|
- //当传入的id与数据库中的不匹配的时候,删除不匹配的信息
|
|
|
- if (!n.getId().equals(in.getId())){
|
|
|
- infoMapper.deleteById(n.getId());
|
|
|
- //将报告文号放入到报告文号报废表中
|
|
|
+ //删除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(n.getReportNo());
|
|
|
+ cancel.setReportNo(data.getReportNo());
|
|
|
cancelMapper.insert(cancel);
|
|
|
}
|
|
|
+ infoMapper.deleteById(data.getId());
|
|
|
});
|
|
|
- //先去数据库中查是否有数据,有则更新,无则添加
|
|
|
- CwProjectInfoData cwProjectInfoData = infoMapper.selectById(in.getId());
|
|
|
- //报告流水号生成 根据项目编号去new_line表查询
|
|
|
- String reportNumber = infoMapper.selectReportNumberByProjectNo(report.getProjectNumber());
|
|
|
|
|
|
- if (cwProjectInfoData == null){
|
|
|
- try {
|
|
|
- //在插入报告文号前先去报告文号报废表中根据时间排序查看是否有报告文号,有则使用,delflag改为1
|
|
|
- List<String> reportNo = infoMapper.getReportNo();
|
|
|
- if (null != reportNo){
|
|
|
- for (int i = 0; i< finalInfoList.size(); i++){
|
|
|
- in.setReportNo(reportNo.get(i));
|
|
|
- //修改报废表的对应数据delflag为1
|
|
|
- cancelMapper.updateFlag("1",reportNo.get(i));
|
|
|
+ System.out.println("ids01" + ids);
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ }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 (reportNumber.contains(report.getProjectNumber() + "-0")){
|
|
|
+ stress = reportNumber.indexOf("-0");//分隔符位置
|
|
|
}else {
|
|
|
- String documentNo = serialnumTplService.genSerialNum(userDTO.getCompanyDTO().getId(), CwProjectInfoData.BIZ_CODE);
|
|
|
- in.setReportNo(documentNo);
|
|
|
+ stress = reportNumber.indexOf("-");//分隔符位置
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+
|
|
|
+ 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);
|
|
|
+ infoMapper.insert(in);
|
|
|
+ }else {
|
|
|
+ infoMapper.updateById(in);
|
|
|
}
|
|
|
- infoMapper.insert(in);
|
|
|
- }else {
|
|
|
- infoMapper.updateById(in);
|
|
|
- }
|
|
|
|
|
|
- //对上传的文件数据进行持久化操作
|
|
|
- List<ProjectReportWorkAttachmentDTO> fileInfoList = new ArrayList<>();
|
|
|
- if ( null !=in.getCwFileInfoList()){
|
|
|
- fileInfoList = in.getCwFileInfoList();
|
|
|
- }
|
|
|
+ //对上传的文件数据进行持久化操作
|
|
|
+ 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));
|
|
|
+ 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);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }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);
|
|
|
}
|
|
|
- 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);
|
|
|
+ infoMapper.deleteById(info.getId());
|
|
|
});
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -272,7 +345,7 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
|
|
|
if(null != infoList){
|
|
|
List<CwProjectInfoData> finalInfoList = infoList;
|
|
|
- infoList.forEach(in->{
|
|
|
+ finalInfoList.forEach(in->{
|
|
|
in.setCreateBy(UserUtils.getCurrentUserDTO().getId());
|
|
|
in.setCreateDate(new Date());
|
|
|
in.setUpdateBy(UserUtils.getCurrentUserDTO().getId());
|
|
@@ -287,7 +360,7 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
}
|
|
|
//在插入报告文号前先去报告文号报废表中根据时间排序查看是否有报告文号,有则使用,delflag改为1
|
|
|
List<String> reportNo = infoMapper.getReportNo();
|
|
|
- if (null!= reportNo){
|
|
|
+ if (null!= reportNo & reportNo.size()>0){
|
|
|
for (int i = 0; i< finalInfoList.size(); i++){
|
|
|
in.setReportNo(reportNo.get(i));
|
|
|
}
|
|
@@ -295,6 +368,25 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
in.setReportNo(documentNo);
|
|
|
}
|
|
|
|
|
|
+ //报告流水号生成 根据项目编号去new_line表查询
|
|
|
+ String reportNumber = infoMapper.selectReportNumberByProjectNo(report.getProjectNumber());
|
|
|
+ int stress = 0;
|
|
|
+ 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);
|
|
|
infoMapper.insert(in);
|
|
|
//对上传的文件数据进行持久化操作
|
|
|
List<ProjectReportWorkAttachmentDTO> fileInfoList = new ArrayList<>();
|
|
@@ -427,7 +519,7 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
//删除 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 (idList != null & !idList.isEmpty()){
|
|
|
+ if (null != idList & idList.size()>0){
|
|
|
idList.forEach(info->{
|
|
|
List<String> attachmentId = attachmentMapper.getIdByAttachmentId(info.getId());
|
|
|
//根据这个id删除cw_project_report_file信息
|