|
@@ -0,0 +1,320 @@
|
|
|
+package com.jeeplus.test.cw.reportCancellApplyArchived.service;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
|
+import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
+import com.jeeplus.sys.utils.StringUtils;
|
|
|
+import com.jeeplus.sys.utils.UserUtils;
|
|
|
+import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectRecordsDTO;
|
|
|
+import com.jeeplus.test.cw.projectReportArchive.service.dto.WorkAttachmentArchiveDto;
|
|
|
+import com.jeeplus.test.cw.reportCancellApply.domain.ReportCancellApply;
|
|
|
+import com.jeeplus.test.cw.reportCancellApplyArchived.domain.CwProjectReportApplyArchive;
|
|
|
+import com.jeeplus.test.cw.reportCancellApplyArchived.mapper.ReportCancellApplyArchivedMapper;
|
|
|
+import com.jeeplus.test.cw.reportCancellApplyArchived.service.dto.ApplyArchiveReportDTO;
|
|
|
+import com.jeeplus.test.cw.reportCancellApplyArchived.service.dto.ArchivedReportInfoDto;
|
|
|
+import com.jeeplus.test.cw.reportCancellApplyArchived.service.dto.CwWorkAttachmentArchiveDto;
|
|
|
+import com.jeeplus.test.mould.service.SerialnumTplService;
|
|
|
+import com.jeeplus.test.oss.domain.WorkAttachment;
|
|
|
+import com.jeeplus.test.oss.mapper.OssServiceMapper;
|
|
|
+import com.jeeplus.test.oss.service.OssService;
|
|
|
+import com.jeeplus.test.workContract.service.dto.WorkAttachmentDto;
|
|
|
+import org.flowable.editor.language.json.converter.util.CollectionUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author: 王强
|
|
|
+ * @create: 2022-11-18 17:36
|
|
|
+ **/
|
|
|
+@Service
|
|
|
+@Transactional
|
|
|
+public class ReportCancellApplyArchivedService extends ServiceImpl<ReportCancellApplyArchivedMapper, CwProjectReportApplyArchive> {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ReportCancellApplyArchivedMapper applyMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SerialnumTplService serialnumTplService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private OssServiceMapper ossServiceMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private OssService ossService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 差选项目列表信息
|
|
|
+ * @param page
|
|
|
+ * @param projectReportData
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public IPage<ArchivedReportInfoDto> getList(Page<ArchivedReportInfoDto> page, ArchivedReportInfoDto projectReportData) throws Exception{
|
|
|
+ QueryWrapper<ArchivedReportInfoDto> queryWrapper = QueryWrapperGenerator.buildQueryCondition (projectReportData,ArchivedReportInfoDto.class);
|
|
|
+ queryWrapper.eq("a.del_flag","0");
|
|
|
+ queryWrapper.eq("a.status","5");
|
|
|
+ queryWrapper.orderByDesc("a.create_date");
|
|
|
+ //条件
|
|
|
+ if (StringUtils.isNotEmpty(projectReportData.getProjectNumber())) {
|
|
|
+ queryWrapper.like("d.project_number", projectReportData.getProjectNumber());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(projectReportData.getProjectName())) {
|
|
|
+ queryWrapper.like("d.project_name", projectReportData.getProjectName());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(projectReportData.getProjectMasterId())) {
|
|
|
+ queryWrapper.eq("d.project_master_id", projectReportData.getProjectMasterId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(projectReportData.getCreateBy().getId())) {
|
|
|
+ queryWrapper.like("a.create_by", projectReportData.getCreateBy().getId());
|
|
|
+ }
|
|
|
+ //创建时间
|
|
|
+ String[] contractDates = projectReportData.getContractDates();
|
|
|
+ if (contractDates != null) {
|
|
|
+
|
|
|
+ queryWrapper.between("a.create_date", contractDates[0], contractDates[1]);
|
|
|
+ }
|
|
|
+ IPage<ArchivedReportInfoDto> list = applyMapper.getList(page, queryWrapper);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id查询项目详情
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ApplyArchiveReportDTO queryById(String id) {
|
|
|
+ //查附件信息
|
|
|
+ ApplyArchiveReportDTO reportDTO = applyMapper.queryById(id);
|
|
|
+ //查询报告作废归档表的id
|
|
|
+ if (null != reportDTO) {
|
|
|
+ CwProjectReportApplyArchive applyArchive = applyMapper.selectByArchiveId(id);
|
|
|
+ if (null != applyArchive) {
|
|
|
+ List<CwWorkAttachmentArchiveDto> files = applyMapper.selectFileInfoByAttid(applyArchive.getId());
|
|
|
+ if (null != files) {
|
|
|
+ files.forEach(fi->{
|
|
|
+ UserDTO userDTO = applyMapper.getUserInfo(fi.getUserId());
|
|
|
+ fi.setCreateBy(userDTO);
|
|
|
+ });
|
|
|
+ reportDTO.setWorkAttachmentDtoList(files);
|
|
|
+ }
|
|
|
+ CwProjectRecordsDTO recordsDTO = applyMapper.selectProjectInfo(applyArchive.getProjectId());
|
|
|
+ if (null != recordsDTO) {
|
|
|
+ reportDTO.setCwProjectRecordsDTO(recordsDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //传过来的是归档的id
|
|
|
+ reportDTO = applyMapper.queryByArchivedId(id);
|
|
|
+ CwProjectReportApplyArchive applyArchive = applyMapper.selectByArchiveId(reportDTO.getId());
|
|
|
+ if (null != applyArchive) {
|
|
|
+ List<CwWorkAttachmentArchiveDto> files = applyMapper.selectFileInfoByAttid(applyArchive.getId());
|
|
|
+ if (null != files) {
|
|
|
+ files.forEach(fi->{
|
|
|
+ UserDTO userDTO = applyMapper.getUserInfo(fi.getUserId());
|
|
|
+ fi.setCreateBy(userDTO);
|
|
|
+ });
|
|
|
+ reportDTO.setWorkAttachmentDtoList(files);
|
|
|
+ }
|
|
|
+ CwProjectRecordsDTO recordsDTO = applyMapper.selectProjectInfo(applyArchive.getProjectId());
|
|
|
+ if (null != recordsDTO) {
|
|
|
+ reportDTO.setCwProjectRecordsDTO(recordsDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return reportDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存项目归档信息以及其他相关信息
|
|
|
+ * @param cwProjectReportArchiveDTO
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public String saveForm(ApplyArchiveReportDTO cwProjectReportArchiveDTO) throws Exception{
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(cwProjectReportArchiveDTO.getId())){
|
|
|
+ CwProjectReportApplyArchive report = applyMapper.selectByApplyId(cwProjectReportArchiveDTO.getId());
|
|
|
+ if (null != report) {
|
|
|
+ //修改报告作废表的归档状态
|
|
|
+ applyMapper.updateArchiveStyle(cwProjectReportArchiveDTO.getId(),cwProjectReportArchiveDTO.getStatus());
|
|
|
+ report.setCreateBy(cwProjectReportArchiveDTO.getCreateBy().getId());
|
|
|
+ return update(cwProjectReportArchiveDTO, report.getId());
|
|
|
+ } else {
|
|
|
+ //传过来的是归档id
|
|
|
+ report = applyMapper.selectById(cwProjectReportArchiveDTO.getId());
|
|
|
+ if (null != report) {
|
|
|
+ //修改报告作废表的归档状态
|
|
|
+ applyMapper.updateArchiveStyle(report.getArchiveId(),cwProjectReportArchiveDTO.getStatus());
|
|
|
+ report.setCreateBy(cwProjectReportArchiveDTO.getCreateBy().getId());
|
|
|
+ return update(cwProjectReportArchiveDTO, report.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return add(cwProjectReportArchiveDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 合同登记新增
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public String add(ApplyArchiveReportDTO reportDTO) throws Exception{
|
|
|
+ //获取当前登录人信息
|
|
|
+ UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
+ String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ CwProjectReportApplyArchive applyArchive = new CwProjectReportApplyArchive();
|
|
|
+ BeanUtils.copyProperties(reportDTO, applyArchive);
|
|
|
+ applyArchive.setId(id);
|
|
|
+ applyArchive.setCreateBy(userDTO.getId());
|
|
|
+ applyArchive.setCreateDate(new Date());
|
|
|
+ applyArchive.setUpdateBy(userDTO.getId());
|
|
|
+ applyArchive.setUpdateDate(new Date());
|
|
|
+ applyArchive.setArchiveId(reportDTO.getId());
|
|
|
+ applyMapper.insert(applyArchive);
|
|
|
+ List<CwWorkAttachmentArchiveDto> list = reportDTO.getWorkAttachmentDtoList();
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ saveFiles(list, userDTO, id);
|
|
|
+ }
|
|
|
+ return id;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public String update(ApplyArchiveReportDTO reportData,String id) throws Exception{
|
|
|
+ //获取当前登录人信息
|
|
|
+ UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
+
|
|
|
+ CwProjectReportApplyArchive cwProjectReportArchive = new CwProjectReportApplyArchive();
|
|
|
+ BeanUtils.copyProperties(reportData, cwProjectReportArchive);
|
|
|
+ cwProjectReportArchive.setUpdateBy(userDTO.getId());
|
|
|
+ cwProjectReportArchive.setUpdateDate(new Date());
|
|
|
+ cwProjectReportArchive.setId(id);
|
|
|
+ cwProjectReportArchive.setArchiveId(reportData.getId());
|
|
|
+ applyMapper.updateById(cwProjectReportArchive);
|
|
|
+ //对上传的文件数据进行持久化操作
|
|
|
+ List<CwWorkAttachmentArchiveDto> list = reportData.getWorkAttachmentDtoList();
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ updateFiles(list, userDTO, cwProjectReportArchive.getId());
|
|
|
+ } else {
|
|
|
+ applyMapper.deleteFileInfo(cwProjectReportArchive.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ return cwProjectReportArchive.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改附件信息
|
|
|
+ * @param list 待修改的附件列表
|
|
|
+ * @param userDTO 当前登录用户
|
|
|
+ * @param id 关联id
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void updateFiles(List<CwWorkAttachmentArchiveDto> list, UserDTO userDTO, String id) {
|
|
|
+ int j = 1;
|
|
|
+ String names = new String();
|
|
|
+ //表中存在,但是传过来不存在,说明已删除,表中数据也要删除
|
|
|
+ for (CwWorkAttachmentArchiveDto dto : list) {
|
|
|
+ names = names + "," +dto.getUrl();
|
|
|
+ }
|
|
|
+ //查询保存的附件信息
|
|
|
+ List<WorkAttachment> infoList = applyMapper.findList(id);
|
|
|
+ if (CollectionUtils.isNotEmpty(infoList)) {
|
|
|
+ for (WorkAttachment i : infoList) {
|
|
|
+ if (!names.contains(i.getUrl())) {
|
|
|
+ ossServiceMapper.deleteById(i.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存信息
|
|
|
+ for (CwWorkAttachmentArchiveDto dto : list) {
|
|
|
+ //判断是否存在
|
|
|
+ Integer isExit = applyMapper.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 (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);
|
|
|
+ j++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存附件信息
|
|
|
+ * @param list 待保存的附件列表
|
|
|
+ * @param userDTO 当前登录用户
|
|
|
+ * @param id 关联id
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void saveFiles(List<CwWorkAttachmentArchiveDto> list, UserDTO userDTO, String id) {
|
|
|
+ int j = 1;
|
|
|
+ for (CwWorkAttachmentArchiveDto dto : list) {
|
|
|
+ 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 (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);
|
|
|
+ j++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改状态
|
|
|
+ * @param cwProjectReportArchiveDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String updateStatusById(ApplyArchiveReportDTO cwProjectReportArchiveDTO) {
|
|
|
+ CwProjectReportApplyArchive cwProjectReportArchive = new CwProjectReportApplyArchive();
|
|
|
+ //修改报告作废表归档状态
|
|
|
+ applyMapper.updateCancellArchiveType(cwProjectReportArchiveDTO.getStatus(),cwProjectReportArchiveDTO.getId());
|
|
|
+ applyMapper.updateStatusByArchiveId(cwProjectReportArchive.getStatus(),cwProjectReportArchive.getArchiveId());
|
|
|
+ return "操作成功";
|
|
|
+ }
|
|
|
+
|
|
|
+ public ApplyArchiveReportDTO findByContractInfoId(String id) {
|
|
|
+ return applyMapper.selectFilePaperByContractInfoId(id);
|
|
|
+ }
|
|
|
+}
|