|
@@ -1,5 +1,6 @@
|
|
|
package com.jeeplus.test.cw.projectReport.service;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -8,6 +9,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
|
+import com.jeeplus.sys.domain.User;
|
|
|
+import com.jeeplus.sys.mapper.UserMapper;
|
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
import com.jeeplus.sys.utils.StringUtils;
|
|
|
import com.jeeplus.sys.utils.UserUtils;
|
|
@@ -39,6 +42,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author: 王强
|
|
@@ -69,6 +73,9 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
@Resource
|
|
|
private CwProjectReportCancelMapper cancelMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private UserMapper userMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 保存项目以及其他相关信息
|
|
|
* @param reportData
|
|
@@ -105,13 +112,13 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
//1、修改work_attachment_id信息
|
|
|
//删除在添加
|
|
|
List<CwProjectInfoData> infoList = new ArrayList<>();
|
|
|
- if (!report.getCwProjectInfoList().isEmpty()){
|
|
|
+ if (null != report.getCwProjectInfoList()){
|
|
|
infoList = report.getCwProjectInfoList();
|
|
|
infoList.forEach(info->{
|
|
|
//删除
|
|
|
List<String> attachmentId = attachmentMapper.getIdByAttachmentId(info.getId());
|
|
|
//根据这个id删除cw_project_report_file信息
|
|
|
- if (attachmentId != null & !attachmentId.isEmpty()) {
|
|
|
+ if (null != attachmentId) {
|
|
|
attachmentId.forEach(atId->{
|
|
|
attachmentMapper.deleteByRepotyId(atId);
|
|
|
});
|
|
@@ -119,20 +126,36 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
//删除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());
|
|
|
+ //将报告文号放入到报告文号报废表中
|
|
|
+ CwProjectReportCancel cancel = new CwProjectReportCancel();
|
|
|
+ cancel.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
+ cancel.setReportNo(n.getReportNo());
|
|
|
+ cancelMapper.insert(cancel);
|
|
|
+ }
|
|
|
+ });
|
|
|
//先去数据库中查是否有数据,有则更新,无则添加
|
|
|
CwProjectInfoData cwProjectInfoData = infoMapper.selectById(in.getId());
|
|
|
if (cwProjectInfoData == null){
|
|
|
try {
|
|
|
//在插入报告文号前先去报告文号报废表中根据时间排序查看是否有报告文号,有则使用,delflag改为1
|
|
|
List<String> reportNo = infoMapper.getReportNo();
|
|
|
- if (reportNo != null & !reportNo.isEmpty()){
|
|
|
+ if (null != reportNo){
|
|
|
for (int i = 0; i< finalInfoList.size(); i++){
|
|
|
in.setReportNo(reportNo.get(i));
|
|
|
+ //修改报废表的对应数据delflag为1
|
|
|
+ cancelMapper.updateFlag("1");
|
|
|
}
|
|
|
}else {
|
|
|
String documentNo = serialnumTplService.genSerialNum(userDTO.getCompanyDTO().getId(), CwProjectInfoData.BIZ_CODE);
|
|
@@ -148,14 +171,14 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
|
|
|
//对上传的文件数据进行持久化操作
|
|
|
List<ProjectReportWorkAttachmentDTO> fileInfoList = new ArrayList<>();
|
|
|
- if (!in.getCwFileInfoList().isEmpty()){
|
|
|
+ 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 (fileInfoList != null & !fileInfoList.isEmpty()){
|
|
|
+ if (null != fileInfoList){
|
|
|
fileInfoList.forEach(item -> {
|
|
|
WorkAttachment i = new WorkAttachment();
|
|
|
//包含了url、size、name
|
|
@@ -211,11 +234,11 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
}
|
|
|
//对新增行数据进行持久化操作
|
|
|
List<CwProjectInfoData> infoList = new ArrayList<>();
|
|
|
- if (!report.getCwProjectInfoList().isEmpty()) {
|
|
|
+ if ( null != report.getCwProjectInfoList()) {
|
|
|
infoList = report.getCwProjectInfoList();
|
|
|
}
|
|
|
|
|
|
- if(infoList != null & !infoList.isEmpty()){
|
|
|
+ if(null != infoList){
|
|
|
List<CwProjectInfoData> finalInfoList = infoList;
|
|
|
infoList.forEach(in->{
|
|
|
in.setCreateBy(UserUtils.getCurrentUserDTO().getId());
|
|
@@ -232,7 +255,7 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
}
|
|
|
//在插入报告文号前先去报告文号报废表中根据时间排序查看是否有报告文号,有则使用,delflag改为1
|
|
|
List<String> reportNo = infoMapper.getReportNo();
|
|
|
- if (reportNo != null & !reportNo.isEmpty()){
|
|
|
+ if (null!= reportNo){
|
|
|
for (int i = 0; i< finalInfoList.size(); i++){
|
|
|
in.setReportNo(reportNo.get(i));
|
|
|
}
|
|
@@ -243,7 +266,7 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
infoMapper.insert(in);
|
|
|
//对上传的文件数据进行持久化操作
|
|
|
List<ProjectReportWorkAttachmentDTO> fileInfoList = new ArrayList<>();
|
|
|
- if (!in.getCwFileInfoList().isEmpty()){
|
|
|
+ if ( null !=in.getCwFileInfoList()){
|
|
|
fileInfoList = in.getCwFileInfoList();
|
|
|
}
|
|
|
ossServiceMapper.delete(new QueryWrapper<WorkAttachment>().lambda().eq(WorkAttachment::getAttachmentId, in.getId()));
|
|
@@ -347,6 +370,13 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
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);
|
|
@@ -407,4 +437,5 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
|
|
|
IPage<CwWorkClientBaseDTO> list = reportMapper.findClineList(page, queryWrapper);
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
}
|