|
@@ -11,11 +11,10 @@ import com.spire.xls.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
|
import org.springblade.business.dto.RawMaterialSubmitRelationDTO;
|
|
|
+import org.springblade.business.dto.TrialFileSubmitDTO;
|
|
|
import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
|
|
|
import org.springblade.business.dto.TrialSelfInspectionRecordPageDTO;
|
|
|
-import org.springblade.business.entity.TrialMaterialMobilization;
|
|
|
-import org.springblade.business.entity.TrialSampleInfo;
|
|
|
-import org.springblade.business.entity.TrialSelfInspectionRecord;
|
|
|
+import org.springblade.business.entity.*;
|
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
|
import org.springblade.business.mapper.TrialMaterialMobilizationMapper;
|
|
|
import org.springblade.business.mapper.TrialSampleInfoMapper;
|
|
@@ -77,6 +76,9 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
private final IOSSClient iossClient;
|
|
|
private final CommonFileClient commonFileClient;
|
|
|
private final TableFileClient tableFileClient;
|
|
|
+ private final TrialDeviceUseServiceImpl trialDeviceUseService;
|
|
|
+ private final InformationQueryServiceImpl informationQueryService;
|
|
|
+ private final TrialDetectionDataServiceImpl trialDetectionDataService;
|
|
|
|
|
|
@Override
|
|
|
public IPage<TrialSelfInspectionRecordVO> selfPage(IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto) {
|
|
@@ -579,6 +581,12 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
updateWrapper.eq(TrialSelfInspectionRecord::getId, dto.getId());
|
|
|
this.update(null, updateWrapper);
|
|
|
}
|
|
|
+
|
|
|
+ //新增设备使用记录信息
|
|
|
+ if (StringUtils.isNotEmpty(dto.getDeviceUseIds())) {
|
|
|
+ trialDeviceUseService.addDeviceUseInfo(dto);
|
|
|
+ }
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -593,7 +601,7 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
} else {
|
|
|
List<String> numberRecordNos = new ArrayList<>();
|
|
|
for (String recordNo : recordNos) {
|
|
|
- String number = recordNo.split("-")[4];
|
|
|
+ String number = recordNo.split("-")[recordNo.split("-").length - 1];
|
|
|
numberRecordNos.add(number);
|
|
|
}
|
|
|
int maxRecordNo1 = Integer.parseInt(Collections.max(numberRecordNos)) + 1;
|
|
@@ -612,7 +620,7 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
} else {
|
|
|
List<String> numberReportNo = new ArrayList<>();
|
|
|
for (String reportNo : reportNos) {
|
|
|
- String number = reportNo.split("-")[4];
|
|
|
+ String number = reportNo.split("-")[reportNo.split("-").length - 1];
|
|
|
numberReportNo.add(number);
|
|
|
}
|
|
|
int maxReportNo1 = Integer.parseInt(Collections.max(numberReportNo)) + 1;
|
|
@@ -648,4 +656,154 @@ public class TrialSelfInspectionRecordServiceImpl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public IPage<TrialSelfInspectionRecordVO> trialDataPage(IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto) {
|
|
|
+ QueryWrapper<TrialSelfInspectionRecord> queryWrapper = Condition.getQueryWrapper(dto);
|
|
|
+
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getStartTime()) && org.apache.commons.lang.StringUtils.isNotEmpty(dto.getEndTime())) {
|
|
|
+ String endTime = dto.getEndTime();
|
|
|
+ endTime = DateUtil.format(DateUtils.addDays(DateUtil.parse(endTime, "yyyy-MM-dd"), 1), "yyyy-MM-dd");
|
|
|
+ queryWrapper.lambda().between(TrialSelfInspectionRecord::getReportDate, dto.getStartTime(), endTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ queryWrapper.lambda().eq(TrialSelfInspectionRecord::getTaskStatus, "已审批");
|
|
|
+ queryWrapper.lambda().eq(TrialSelfInspectionRecord::getDetectionResult, 1); //合格
|
|
|
+ queryWrapper.lambda().eq(TrialSelfInspectionRecord::getDetectionCategory, 1); //自检
|
|
|
+
|
|
|
+ IPage<TrialSelfInspectionRecord> pages = this.page(page, queryWrapper.lambda().orderBy(true, true, TrialSelfInspectionRecord::getCreateTime));
|
|
|
+ IPage<TrialSelfInspectionRecordVO> trialSelfInspectionRecordVOIPage = TrialSelfInspectionRecordWarpper.build().pageVO(pages);
|
|
|
+ List<TrialSelfInspectionRecordVO> records = trialSelfInspectionRecordVOIPage.getRecords();
|
|
|
+
|
|
|
+ List<WbsTreeContract> contractTreeList = wbsTreeContractClient.getContractWbsTreeByContractId(dto.getContractId());
|
|
|
+
|
|
|
+ //查询是否关联过
|
|
|
+ List<String> selectedIds = baseMapper.selectSelectedStatusList(dto.getNodeId(), "1");
|
|
|
+
|
|
|
+ for (TrialSelfInspectionRecordVO record : records) {
|
|
|
+ record.setDetectionResultName(record.getDetectionResult().equals(1) ? "合格" : "不合格");
|
|
|
+
|
|
|
+ //是否关联过
|
|
|
+ for (String id : selectedIds) {
|
|
|
+ record.setIsSelectedStatus(record.getId().toString().equals(id) ? 1 : 0);
|
|
|
+ }
|
|
|
+ if (selectedIds.size() == 0) {
|
|
|
+ record.setIsSelectedStatus(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ //工程部位及用途名称
|
|
|
+ if (contractTreeList.size() > 0 && ObjectUtil.isNotEmpty(record.getProjectPosition())) {
|
|
|
+ List<String> projectPositionNames = new ArrayList<>();
|
|
|
+ for (WbsTreeContract wbsTreeContract : contractTreeList) {
|
|
|
+ if ((record.getProjectPosition()).contains(String.valueOf(wbsTreeContract.getPKeyId()))) {
|
|
|
+ projectPositionNames.add(wbsTreeContract.getNodeName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String name = projectPositionNames.stream().findAny().orElse(null);
|
|
|
+ if (projectPositionNames.size() > 1) {
|
|
|
+ record.setProjectPositionName(name + "等" + projectPositionNames.size() + "个工程部位信息");
|
|
|
+ } else {
|
|
|
+ record.setProjectPositionName(name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return trialSelfInspectionRecordVOIPage.setRecords(records);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean fileSubmit(TrialFileSubmitDTO dto) throws FileNotFoundException {
|
|
|
+ if (ObjectUtil.isEmpty(dto.getType())) {
|
|
|
+ throw new ServiceException("请选择一个类型");
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isEmpty(dto.getNodeId())) {
|
|
|
+ throw new ServiceException("未获取到当前节点的pKeyId");
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取当前节点的合并的pdfURL
|
|
|
+ InformationQuery informationQuery = informationQueryService.getBaseMapper().selectOne(Wrappers.<InformationQuery>lambdaQuery()
|
|
|
+ .eq(InformationQuery::getWbsId, dto.getNodeId())
|
|
|
+ .eq(InformationQuery::getProjectId, dto.getProjectId())
|
|
|
+ .eq(InformationQuery::getContractId, dto.getContractId())
|
|
|
+ .eq(InformationQuery::getType, 1) //质检
|
|
|
+ );
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(dto.getIds())) {
|
|
|
+ if (ObjectUtil.isNotEmpty(informationQuery) && StringUtils.isNotEmpty(informationQuery.getPdfUrl())) {
|
|
|
+
|
|
|
+ List<String> pdfList = new ArrayList<>();
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(informationQuery.getPdfTrialUrl())) {
|
|
|
+ //如果PdfTrialUrl == null 说明是第一次关联
|
|
|
+ pdfList.add(informationQuery.getPdfUrl());
|
|
|
+ } else {
|
|
|
+ //如果PdfTrialUrl != null 说明是第二次以上操作关联,那么就在之前的上面做增量,主要解决不同类型提交时的问题
|
|
|
+ pdfList.add(informationQuery.getPdfTrialUrl());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dto.getType().equals(1)) { //自检
|
|
|
+ //获取自检的对应的数据pdf
|
|
|
+ List<TrialSelfInspectionRecord> trialSelfInspectionRecords = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, dto.getIds()));
|
|
|
+ List<String> pdfURLs = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
|
|
|
+ pdfList.addAll(pdfURLs);
|
|
|
+
|
|
|
+ } else if (dto.getType().equals(2) || dto.getType().equals(3)) { //第三方、外委
|
|
|
+ //获取第三方、外委的对应的数据pdf
|
|
|
+ List<TrialDetectionData> trialDetectionData = trialDetectionDataService.getBaseMapper().selectList(Wrappers.<TrialDetectionData>lambdaQuery().in(TrialDetectionData::getId, dto.getIds()));
|
|
|
+ List<String> pdfURLs = new ArrayList<>();
|
|
|
+ for (TrialDetectionData trialDetectionDatum : trialDetectionData) {
|
|
|
+ if (StringUtils.isNotEmpty(trialDetectionDatum.getRecordTableUrl())) {
|
|
|
+ pdfURLs.add(trialDetectionDatum.getRecordTableUrl());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(trialDetectionDatum.getReportAttachmentUrl())) {
|
|
|
+ pdfURLs.add(trialDetectionDatum.getReportAttachmentUrl());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pdfList.addAll(pdfURLs);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pdfList.size() > 0) {
|
|
|
+ //合并pdf把试验自检记录、第三方、外委的pdf追加到当前质检合同段树节点下的pdf后显示
|
|
|
+ List<String> collect = pdfList.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ String listPdf = filePath + "/pdf/" + informationQuery.getId() + ".pdf";
|
|
|
+ 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地址
|
|
|
+ if (informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate().set(InformationQuery::getPdfTrialUrl, bladeFile.getLink()).eq(InformationQuery::getId, informationQuery.getId()))) {
|
|
|
+ //修改选中状态记录信息(选中为勾选绿色)
|
|
|
+ baseMapper.deleteSeletedStatusByNodeId(dto.getNodeId(), dto.getType()); //先删除该类型的所有记录信息
|
|
|
+
|
|
|
+ for (String recordId : Func.toStrList(dto.getIds())) {
|
|
|
+ baseMapper.insertSeletedStatus(SnowFlakeUtil.getId(), dto.getNodeId(), dto.getType(), recordId); //新增该类型选中的记录信息
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("当前节点还未上报,获取pdf信息失败,请先上报后再进行关联");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else { //删除
|
|
|
+ //如果没有关联信息ids=null,那么删除当前类型对应的记录
|
|
|
+ //删除前判断当前节点下关联的信息是否还有其他类型的,如果有就不修改pdfTrialUrl=null,如果当前记录为null,那就修改pdfTrialUrl=null
|
|
|
+ int row = baseMapper.selectCountSeletedStatus(dto.getNodeId(), dto.getType());
|
|
|
+ if (row == 0) {
|
|
|
+ //修改pdfTrialUrl=null
|
|
|
+ informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate().set(InformationQuery::getPdfTrialUrl, null).eq(InformationQuery::getId, informationQuery.getId()));
|
|
|
+ }
|
|
|
+ //删除该类型的所有记录信息
|
|
|
+ baseMapper.deleteSeletedStatusByNodeId(dto.getNodeId(), dto.getType());
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|