|
@@ -0,0 +1,148 @@
|
|
|
+package cn.cslg.pas.service.business;
|
|
|
+
|
|
|
+import cn.cslg.pas.common.dto.business.ReportAffairDTO;
|
|
|
+import cn.cslg.pas.common.dto.invalidDTO.*;
|
|
|
+import cn.cslg.pas.common.vo.invalidVO.InvalidDecisionFileVO;
|
|
|
+import cn.cslg.pas.common.vo.invalidVO.OralTrailVO;
|
|
|
+import cn.cslg.pas.common.vo.invalidVO.OtherDocumentsVO;
|
|
|
+import cn.cslg.pas.domain.business.*;
|
|
|
+import cn.cslg.pas.exception.XiaoShiException;
|
|
|
+import cn.cslg.pas.mapper.OtherDocumentsMapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 其他文档
|
|
|
+ * @Author xiexiang
|
|
|
+ * @Date 2024/2/23
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class OtherDocumentsService extends ServiceImpl<OtherDocumentsMapper, OtherDocuments> {
|
|
|
+ @Autowired
|
|
|
+ private ReportAffairService reportAffairService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AssoReportAffairFileService assoReportAffairFileService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增
|
|
|
+ * @param addOtherDocumentsDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Integer add(AddOtherDocumentsDTO addOtherDocumentsDTO){
|
|
|
+ if (addOtherDocumentsDTO == null) {
|
|
|
+ throw new XiaoShiException("入参为空");
|
|
|
+ }
|
|
|
+ Integer projectId = addOtherDocumentsDTO.getProjectId();
|
|
|
+ if (projectId == null) {
|
|
|
+ throw new XiaoShiException("报告id为空");
|
|
|
+ }
|
|
|
+ //1. 首先上传报告事务,拿到报告事务id
|
|
|
+ ReportAffairDTO reportAffairDTO = new ReportAffairDTO();
|
|
|
+ reportAffairDTO.setProjectId(projectId);
|
|
|
+ //其他文档 8
|
|
|
+ reportAffairDTO.setAffairType(8);
|
|
|
+ //发生时间是文档时间
|
|
|
+ reportAffairDTO.setOccurredTime(addOtherDocumentsDTO.getDocumentTime());
|
|
|
+ //备注
|
|
|
+ reportAffairDTO.setDescription(addOtherDocumentsDTO.getDescription());
|
|
|
+ Integer reportAffairId = reportAffairService.addReportAffair(reportAffairDTO);
|
|
|
+
|
|
|
+ if (reportAffairId == null) {
|
|
|
+ throw new XiaoShiException("上传报告事务失败");
|
|
|
+ }
|
|
|
+ //2. 上传其他文档
|
|
|
+ OtherDocuments otherDocuments = new OtherDocuments();
|
|
|
+ otherDocuments.setDocumentName(addOtherDocumentsDTO.getDocumentName());
|
|
|
+ otherDocuments.setReportAffairId(reportAffairId);
|
|
|
+ otherDocuments.insert();
|
|
|
+ //3. 添加报告事务与文件关联
|
|
|
+ List<String> fileGuids = addOtherDocumentsDTO.getFileGuids();
|
|
|
+ if (fileGuids != null && !fileGuids.isEmpty()) {
|
|
|
+ List<AssoReportAffairFile> assoReportAffairFiles = new ArrayList<>();
|
|
|
+ fileGuids.forEach(item -> {
|
|
|
+ AssoReportAffairFile assoReportAffairFile = new AssoReportAffairFile();
|
|
|
+ assoReportAffairFile.setReportAffairId(reportAffairId);
|
|
|
+ assoReportAffairFile.setFileGuid(item);
|
|
|
+ assoReportAffairFiles.add(assoReportAffairFile);
|
|
|
+ });
|
|
|
+ assoReportAffairFileService.saveBatch(assoReportAffairFiles);
|
|
|
+ }
|
|
|
+ return reportAffairId;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改其他文档
|
|
|
+ * @param updateOtherDocumentsDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Integer update(UpdateOtherDocumentsDTO updateOtherDocumentsDTO){
|
|
|
+ if (updateOtherDocumentsDTO == null) {
|
|
|
+ throw new XiaoShiException("入参为空");
|
|
|
+ }
|
|
|
+ Integer projectId = updateOtherDocumentsDTO.getProjectId();
|
|
|
+ Integer id = updateOtherDocumentsDTO.getDocumentId();
|
|
|
+ if (id == null) {
|
|
|
+ throw new XiaoShiException("id为空");
|
|
|
+ }
|
|
|
+ if (projectId == null) {
|
|
|
+ throw new XiaoShiException("报告id为空");
|
|
|
+ }
|
|
|
+ //1. 根据id查出其他文档
|
|
|
+ OtherDocuments otherDocuments = this.getById(id);
|
|
|
+ if (otherDocuments == null) {
|
|
|
+ throw new XiaoShiException("其他文档查询错误");
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(updateOtherDocumentsDTO, otherDocuments);
|
|
|
+ otherDocuments.updateById();
|
|
|
+ Integer reportAffairId = otherDocuments.getReportAffairId();
|
|
|
+ //2. 拿到报告事务id,获取报告事务
|
|
|
+ ReportAffair reportAffair = reportAffairService.getById(reportAffairId);
|
|
|
+ reportAffair.setProjectId(projectId);
|
|
|
+ //发生时间是文档时间
|
|
|
+ reportAffair.setOccurredTime(updateOtherDocumentsDTO.getDocumentTime());
|
|
|
+ //备注
|
|
|
+ reportAffair.setDescription(updateOtherDocumentsDTO.getDescription());
|
|
|
+ reportAffair.updateById();
|
|
|
+ //3. 更新报告事务与文件关联
|
|
|
+ LambdaQueryWrapper<AssoReportAffairFile> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(AssoReportAffairFile::getReportAffairId, reportAffairId);
|
|
|
+ assoReportAffairFileService.remove(queryWrapper);
|
|
|
+ List<String> fileGuids = updateOtherDocumentsDTO.getFileGuids();
|
|
|
+ if (fileGuids != null && !fileGuids.isEmpty()) {
|
|
|
+ List<AssoReportAffairFile> assoReportAffairFiles = new ArrayList<>();
|
|
|
+ fileGuids.forEach(item -> {
|
|
|
+ AssoReportAffairFile assoReportAffairFile = new AssoReportAffairFile();
|
|
|
+ assoReportAffairFile.setReportAffairId(reportAffairId);
|
|
|
+ assoReportAffairFile.setFileGuid(item);
|
|
|
+ assoReportAffairFiles.add(assoReportAffairFile);
|
|
|
+ });
|
|
|
+ assoReportAffairFileService.saveBatch(assoReportAffairFiles);
|
|
|
+ }
|
|
|
+ return reportAffairId;
|
|
|
+ }
|
|
|
+
|
|
|
+ public OtherDocumentsVO getOtherDocuments(Integer reportAffairId) {
|
|
|
+ LambdaQueryWrapper<OtherDocuments> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(OtherDocuments::getReportAffairId, reportAffairId);
|
|
|
+ OtherDocuments otherDocuments = this.getOne(queryWrapper, false);
|
|
|
+ OtherDocumentsVO otherDocumentsVO = new OtherDocumentsVO();
|
|
|
+ if (otherDocuments != null) {
|
|
|
+ BeanUtils.copyProperties(otherDocuments, otherDocumentsVO);
|
|
|
+ otherDocumentsVO.setDocumentId(otherDocuments.getId());
|
|
|
+ }
|
|
|
+ ReportAffair reportAffair = reportAffairService.getById(reportAffairId);
|
|
|
+ otherDocumentsVO.setDocumentTime(reportAffair.getOccurredTime());
|
|
|
+ otherDocumentsVO.setDescription(reportAffair.getDescription());
|
|
|
+ otherDocumentsVO.setProjectId(reportAffair.getProjectId());
|
|
|
+ return otherDocumentsVO;
|
|
|
+ }
|
|
|
+}
|