|
@@ -1,22 +1,128 @@
|
|
|
package org.springblade.business.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springblade.business.entity.InformationQuery;
|
|
|
import org.springblade.business.entity.TrialCyAccessories;
|
|
|
+import org.springblade.business.entity.TrialCyFinishTestReport;
|
|
|
+import org.springblade.business.entity.TrialCyThirdReport;
|
|
|
import org.springblade.business.service.TrialCyAccessoriesService;
|
|
|
import org.springblade.business.mapper.TrialCyAccessoriesMapper;
|
|
|
+import org.springblade.business.service.TrialCyFinishTestReportService;
|
|
|
+import org.springblade.business.service.TrialCyThirdReportService;
|
|
|
+import org.springblade.business.utils.FileUtils;
|
|
|
+import org.springblade.common.constant.CommonConstant;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.core.oss.model.BladeFile;
|
|
|
+import org.springblade.core.tool.utils.CollectionUtil;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springblade.core.tool.utils.ResourceUtil;
|
|
|
+import org.springblade.resource.feign.NewIOSSClient;
|
|
|
+import org.springblade.system.cache.ParamCache;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
-* @author LHB
|
|
|
-* @description 针对表【u_trial_cy_accessories(成渝-附件信息)】的数据库操作Service实现
|
|
|
-* @createDate 2025-08-04 14:39:16
|
|
|
-*/
|
|
|
+ * @author LHB
|
|
|
+ * @description 针对表【u_trial_cy_accessories(成渝-附件信息)】的数据库操作Service实现
|
|
|
+ * @createDate 2025-08-04 14:39:16
|
|
|
+ */
|
|
|
@Service
|
|
|
public class TrialCyAccessoriesServiceImpl extends ServiceImpl<TrialCyAccessoriesMapper, TrialCyAccessories>
|
|
|
- implements TrialCyAccessoriesService {
|
|
|
+ implements TrialCyAccessoriesService {
|
|
|
+ @Resource
|
|
|
+ private TrialCyFinishTestReportService trialCyFinishTestReportService;
|
|
|
+ @Resource
|
|
|
+ private TrialCyThirdReportService trialCyThirdReportService;
|
|
|
+ @Resource
|
|
|
+ private InformationQueryServiceImpl informationQueryService;
|
|
|
+ @Resource
|
|
|
+ private NewIOSSClient newIOSSClient;
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean clearTrialAssociation(Long nodeId, Long recordId) {
|
|
|
- return baseMapper.clearTrialAssociation(nodeId,recordId);
|
|
|
+
|
|
|
+ baseMapper.clearTrialAssociation(nodeId, recordId);
|
|
|
+ //重新生成pdf
|
|
|
+ List<String> listOne = baseMapper.selectFilePdfList(nodeId, 11);
|
|
|
+ List<String> listTwo = baseMapper.selectFilePdfList(nodeId, 11, 12);
|
|
|
+
|
|
|
+ InformationQuery informationQuery = informationQueryService.getBaseMapper().selectList(Wrappers.<InformationQuery>lambdaQuery()
|
|
|
+ .eq(InformationQuery::getWbsId, nodeId)
|
|
|
+ .ne(InformationQuery::getStatus, 3)
|
|
|
+ .eq(InformationQuery::getType, 1)).stream().findAny().orElse(null);
|
|
|
+
|
|
|
+
|
|
|
+ List<String> pdfList = new ArrayList<>();
|
|
|
+ //成渝自检
|
|
|
+ if (CollectionUtil.isNotEmpty(listOne)) {
|
|
|
+ List<TrialCyFinishTestReport> trialCyFinishTestReports = trialCyFinishTestReportService.getBaseMapper().selectList(Wrappers.<TrialCyFinishTestReport>lambdaQuery()
|
|
|
+ .in(TrialCyFinishTestReport::getTaskId, listOne));
|
|
|
+ trialCyFinishTestReports.forEach(f -> {
|
|
|
+ if (StringUtils.isNotBlank(f.getAssembleFile())) {
|
|
|
+ pdfList.add(f.getAssembleFile());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //外委-第三方
|
|
|
+ if (CollectionUtil.isNotEmpty(listOne)) {
|
|
|
+ List<TrialCyThirdReport> trialCyThirdReports = trialCyThirdReportService.getBaseMapper().selectList(Wrappers.<TrialCyThirdReport>lambdaQuery()
|
|
|
+ .in(TrialCyThirdReport::getId, listTwo));
|
|
|
+ trialCyThirdReports.forEach(f -> {
|
|
|
+ if (StringUtils.isNotBlank(f.getAssembleFile())) {
|
|
|
+ pdfList.add(f.getAssembleFile());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ String pdfTrialUrl = informationQuery.getPdfTrialUrl();
|
|
|
+ //删除之前的文件
|
|
|
+ if (StringUtils.isNotBlank(pdfTrialUrl)) {
|
|
|
+ String pdfName = pdfTrialUrl.split("upload")[1];
|
|
|
+ this.newIOSSClient.removeFile("upload" + pdfName);
|
|
|
+ }
|
|
|
+ if (pdfList.size() > 0) {
|
|
|
+ //合并试验自检、第三方、外委的pdf
|
|
|
+ List<String> collect = pdfList.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ if (ObjectUtil.isNotEmpty(collect) && collect.size() > 0) {
|
|
|
+ String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ String listPdf = filePath + "/pdf/" + informationQuery.getId() + ".pdf";
|
|
|
+ try {
|
|
|
+ File tabPDF = ResourceUtil.getFile(listPdf);
|
|
|
+ if (tabPDF.exists()) {
|
|
|
+ tabPDF.delete();
|
|
|
+ }
|
|
|
+ FileUtils.mergePdfPublicMethods(collect, listPdf);
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(informationQuery.getId() + ".pdf", listPdf);
|
|
|
+ if (bladeFile != null) {
|
|
|
+
|
|
|
+ //修改当前节点的pdfTrialURL地址
|
|
|
+ informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate()
|
|
|
+ .set(InformationQuery::getPdfTrialUrl, bladeFile.getLink())
|
|
|
+ .eq(InformationQuery::getId, informationQuery.getId()));
|
|
|
+ }
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //修改当前节点的pdfTrialURL地址
|
|
|
+ informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate()
|
|
|
+ .set(InformationQuery::getPdfTrialUrl, null)
|
|
|
+ .eq(InformationQuery::getId, informationQuery.getId()));
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|
|
|
|