|
@@ -0,0 +1,118 @@
|
|
|
+package org.springblade.business.feignClient;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.business.entity.TrialCyFinishTestReport;
|
|
|
+import org.springblade.business.entity.TrialCyThirdReport;
|
|
|
+import org.springblade.business.feign.TrialCyAccessoriesClient;
|
|
|
+import org.springblade.business.mapper.TrialSelfInspectionRecordMapper;
|
|
|
+import org.springblade.business.service.TrialCyFinishTestReportService;
|
|
|
+import org.springblade.business.service.TrialCyThirdReportService;
|
|
|
+import org.springblade.core.tool.utils.CollectionUtil;
|
|
|
+import org.springblade.manager.entity.TableFile;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author LHB
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+public class TrialCyAccessoriesClientImpl implements TrialCyAccessoriesClient {
|
|
|
+
|
|
|
+ private final TrialSelfInspectionRecordMapper trialSelfInspectionRecordMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 第三方、外委
|
|
|
+ */
|
|
|
+ private final TrialCyThirdReportService trialCyThirdReportService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 试验报告
|
|
|
+ */
|
|
|
+ private final TrialCyFinishTestReportService trialCyFinishTestReportService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<JSONObject> getTrialFilePdfRecord(String primaryKeyId, List<Integer> list) {
|
|
|
+ //获取id
|
|
|
+ List<Map<String, Object>> trialFilePdfRecord = trialSelfInspectionRecordMapper.getTrialFilePdfRecord(primaryKeyId, list);
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(trialFilePdfRecord)) {
|
|
|
+
|
|
|
+ //试验报告ids
|
|
|
+ List<Long> listOne = new ArrayList<>();
|
|
|
+ //第三方外委ids
|
|
|
+ List<Long> listTwo = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Map<String, Object> stringObjectMap : trialFilePdfRecord) {
|
|
|
+
|
|
|
+ Integer type = (Integer) stringObjectMap.get("type");
|
|
|
+ Long recordId = (Long) stringObjectMap.get("record_id");
|
|
|
+ //试验报告
|
|
|
+ if (type == 11) {
|
|
|
+ listOne.add(recordId);
|
|
|
+ } else {
|
|
|
+ //第三方、外委
|
|
|
+ listTwo.add(recordId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<JSONObject> result = new ArrayList<>();
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(listOne)) {
|
|
|
+ List<TrialCyFinishTestReport> list1 = trialCyFinishTestReportService.list(Wrappers.<TrialCyFinishTestReport>lambdaQuery()
|
|
|
+ .isNotNull(TrialCyFinishTestReport::getAssembleFile)
|
|
|
+ .in(TrialCyFinishTestReport::getTaskId, listOne)
|
|
|
+ );
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(list1)) {
|
|
|
+ list1.forEach(f -> {
|
|
|
+ String[] split = f.getAssembleFile().split("/");
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("id", f.getTaskId());
|
|
|
+ jsonObject.put("name", split[split.length - 1]);
|
|
|
+ jsonObject.put("contractId", f.getContractId());
|
|
|
+ jsonObject.put("domainUrl", f.getAssembleFile());
|
|
|
+ jsonObject.put("domainPdfUrl", f.getAssembleFile());
|
|
|
+ jsonObject.put("tabId", primaryKeyId);
|
|
|
+ jsonObject.put("extension", "pdf");
|
|
|
+ //是否为试验关联的附件
|
|
|
+ jsonObject.put("isTrial", true);
|
|
|
+ result.add(jsonObject);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(listTwo)) {
|
|
|
+ List<TrialCyThirdReport> list1 = trialCyThirdReportService.list(Wrappers.<TrialCyThirdReport>lambdaQuery()
|
|
|
+ .isNotNull(TrialCyThirdReport::getAssembleFile)
|
|
|
+ .in(TrialCyThirdReport::getId, listTwo)
|
|
|
+ );
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(list1)) {
|
|
|
+ list1.forEach(f -> {
|
|
|
+ String[] split = f.getAssembleFile().split("/");
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("id", f.getId());
|
|
|
+ jsonObject.put("name", split[split.length - 1]);
|
|
|
+ jsonObject.put("contractId", f.getContractId());
|
|
|
+ jsonObject.put("domainUrl", f.getAssembleFile());
|
|
|
+ jsonObject.put("domainPdfUrl", f.getAssembleFile());
|
|
|
+ jsonObject.put("tabId", primaryKeyId);
|
|
|
+ jsonObject.put("extension", "pdf");
|
|
|
+ //是否为试验关联的附件
|
|
|
+ jsonObject.put("isTrial", true);
|
|
|
+ result.add(jsonObject);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|