|
@@ -1,5 +1,7 @@
|
|
package com.jeeplus.test.cw.projectRecords.service;
|
|
package com.jeeplus.test.cw.projectRecords.service;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import cn.hutool.core.util.ArrayUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -7,6 +9,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
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.service.dto.UserDTO;
|
|
import com.jeeplus.sys.utils.StringUtils;
|
|
import com.jeeplus.sys.utils.StringUtils;
|
|
import com.jeeplus.sys.utils.UserUtils;
|
|
import com.jeeplus.sys.utils.UserUtils;
|
|
@@ -15,6 +19,7 @@ import com.jeeplus.test.cw.projectRecords.mapper.CwProjectRecordsMapper;
|
|
import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectClientInfoDTO;
|
|
import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectClientInfoDTO;
|
|
import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectRecordsDTO;
|
|
import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectRecordsDTO;
|
|
import com.jeeplus.test.cw.projectRecords.service.mapstruct.CwProjectRecordsWrapper;
|
|
import com.jeeplus.test.cw.projectRecords.service.mapstruct.CwProjectRecordsWrapper;
|
|
|
|
+import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
|
|
import com.jeeplus.test.mould.service.SerialnumTplService;
|
|
import com.jeeplus.test.mould.service.SerialnumTplService;
|
|
import com.jeeplus.test.oss.service.OssService;
|
|
import com.jeeplus.test.oss.service.OssService;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
@@ -22,7 +27,9 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 财务项目登记service
|
|
* 财务项目登记service
|
|
@@ -40,6 +47,8 @@ public class CwProjectRecordsService extends ServiceImpl<CwProjectRecordsMapper,
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private SerialnumTplService serialnumTplService;
|
|
private SerialnumTplService serialnumTplService;
|
|
|
|
+ @Resource
|
|
|
|
+ private UserMapper userMapper;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 差选项目列表信息
|
|
* 差选项目列表信息
|
|
@@ -52,6 +61,20 @@ public class CwProjectRecordsService extends ServiceImpl<CwProjectRecordsMapper,
|
|
QueryWrapper<CwProjectRecords> queryWrapper = QueryWrapperGenerator.buildQueryCondition ( CwProjectRecordsWrapper.INSTANCE.toEntity(cwProjectRecordsDTO), CwProjectRecords.class );
|
|
QueryWrapper<CwProjectRecords> queryWrapper = QueryWrapperGenerator.buildQueryCondition ( CwProjectRecordsWrapper.INSTANCE.toEntity(cwProjectRecordsDTO), CwProjectRecords.class );
|
|
queryWrapper.eq("a.del_flag","0");
|
|
queryWrapper.eq("a.del_flag","0");
|
|
queryWrapper.orderByDesc("a.create_date");
|
|
queryWrapper.orderByDesc("a.create_date");
|
|
|
|
+ if (ObjectUtil.isNotEmpty(cwProjectRecordsDTO)) {
|
|
|
|
+ if (ArrayUtil.isNotEmpty(cwProjectRecordsDTO.getCreateDates())) {
|
|
|
|
+ queryWrapper.between("a.create_date", cwProjectRecordsDTO.getCreateDates()[0], cwProjectRecordsDTO.getCreateDates()[1]);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(cwProjectRecordsDTO.getProjectMasterName())) {
|
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().lambda().like(User::getName, cwProjectRecordsDTO.getProjectMasterName()));
|
|
|
|
+ List<String> ids = userList.stream().distinct().map(User::getId).collect(Collectors.toList());
|
|
|
|
+ if (CollectionUtil.isNotEmpty(ids)) {
|
|
|
|
+ queryWrapper.in("a.create_by", ids);
|
|
|
|
+ } else {
|
|
|
|
+ return new Page<>();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
IPage<CwProjectRecordsDTO> list = cwProjectRecordsMapper.findList(page, queryWrapper);
|
|
IPage<CwProjectRecordsDTO> list = cwProjectRecordsMapper.findList(page, queryWrapper);
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
@@ -81,19 +104,28 @@ public class CwProjectRecordsService extends ServiceImpl<CwProjectRecordsMapper,
|
|
cwProjectRecordsDTO.setProjectNumber(serialNum);
|
|
cwProjectRecordsDTO.setProjectNumber(serialNum);
|
|
}
|
|
}
|
|
CwProjectRecords cwProjectRecords = CwProjectRecordsWrapper.INSTANCE.toEntity(cwProjectRecordsDTO);
|
|
CwProjectRecords cwProjectRecords = CwProjectRecordsWrapper.INSTANCE.toEntity(cwProjectRecordsDTO);
|
|
|
|
+ if (ObjectUtil.isNotEmpty(cwProjectRecords)) {
|
|
|
|
+ if (StringUtils.isBlank(cwProjectRecords.getCreateBy())) {
|
|
|
|
+ cwProjectRecords.setCreateBy(UserUtils.getCurrentUserDTO().getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
this.saveOrUpdate(cwProjectRecords);
|
|
this.saveOrUpdate(cwProjectRecords);
|
|
if (ObjectUtil.isNotEmpty(cwProjectRecordsDTO)) {
|
|
if (ObjectUtil.isNotEmpty(cwProjectRecordsDTO)) {
|
|
// 附件
|
|
// 附件
|
|
ossService.saveOrUpdateFileList(cwProjectRecordsDTO.getWorkAttachmentDtoList(),cwProjectRecords.getId(),"cw_project_records");
|
|
ossService.saveOrUpdateFileList(cwProjectRecordsDTO.getWorkAttachmentDtoList(),cwProjectRecords.getId(),"cw_project_records");
|
|
// 被服务单位
|
|
// 被服务单位
|
|
//根据项目id删除原有的被服务单位数据信息
|
|
//根据项目id删除原有的被服务单位数据信息
|
|
- cwProjectRecordsMapper.deleteProjectClientInfoByProjectId(cwProjectRecordsDTO.getId());
|
|
|
|
|
|
+ cwProjectRecordsMapper.deleteProjectClientInfoByProjectId(cwProjectRecords.getId());
|
|
|
|
|
|
if(null != cwProjectRecordsDTO.getCwProjectClientInfoDTOList() && cwProjectRecordsDTO.getCwProjectClientInfoDTOList().size()>0){
|
|
if(null != cwProjectRecordsDTO.getCwProjectClientInfoDTOList() && cwProjectRecordsDTO.getCwProjectClientInfoDTOList().size()>0){
|
|
//根据项目id添加新的被服务单位信息
|
|
//根据项目id添加新的被服务单位信息
|
|
- List<CwProjectClientInfoDTO> cwProjectClientInfoDTOList = cwProjectRecordsDTO.getCwProjectClientInfoDTOList();
|
|
|
|
- for (CwProjectClientInfoDTO projectClientInfo : cwProjectClientInfoDTOList) {
|
|
|
|
- projectClientInfo.setProjectId(cwProjectRecordsDTO.getId());
|
|
|
|
|
|
+ List<CwWorkClientBaseDTO> cwWorkClientBaseDTOList = cwProjectRecordsDTO.getCwProjectClientInfoDTOList();
|
|
|
|
+ List<CwProjectClientInfoDTO> cwProjectClientInfoDTOList = new ArrayList<>();
|
|
|
|
+ for (CwWorkClientBaseDTO c : cwWorkClientBaseDTOList) {
|
|
|
|
+ CwProjectClientInfoDTO cwProjectClientInfoDTO = new CwProjectClientInfoDTO();
|
|
|
|
+ cwProjectClientInfoDTO.setProjectId(cwProjectRecords.getId());
|
|
|
|
+ cwProjectClientInfoDTO.setClientId(c.getId());
|
|
|
|
+ cwProjectClientInfoDTOList.add(cwProjectClientInfoDTO);
|
|
}
|
|
}
|
|
//对数据进行批量插入
|
|
//对数据进行批量插入
|
|
cwProjectRecordsMapper.insertProjectClientInfoList(cwProjectClientInfoDTOList);
|
|
cwProjectRecordsMapper.insertProjectClientInfoList(cwProjectClientInfoDTOList);
|