浏览代码

试验-接入成渝第三方接口开发
1、获取检测项目树(成功)
2、本系统前端访问的接口开发

LHB 1 周之前
父节点
当前提交
331f0570c3

+ 2 - 2
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialCyTestType.java

@@ -15,7 +15,7 @@ import lombok.Data;
 @Data
 public class TrialCyTestType {
     @TableId(type = IdType.INPUT)
-    private Long id;
+    private Long pKeyId;
     /**
      * 项目id
      */
@@ -23,7 +23,7 @@ public class TrialCyTestType {
     /**
      * ID唯一标识
      */
-    @TableField("c_id")
+    @TableField("id")
     private String ID;
     /**
      * 名称

+ 90 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialCyController.java

@@ -0,0 +1,90 @@
+package org.springblade.business.controller;
+
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springblade.business.entity.TrialContainerClassification;
+import org.springblade.business.entity.TrialCyFinishTestReport;
+import org.springblade.business.entity.TrialCyTestType;
+import org.springblade.business.entity.TrialCyThirdReport;
+import org.springblade.business.service.TrialCyService;
+import org.springblade.business.service.TrialCyTestTypeService;
+import org.springblade.core.tool.api.R;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 成渝试验数据接口
+ * @author LHB
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/cyTrial")
+@Api(value = "成渝试验数据接口", tags = "成渝试验数据接口")
+public class TrialCyController {
+
+    private TrialCyService trialCyService;
+
+
+    /**
+     * 根据合同段id验证当前合同段是否未成渝项目下未开启试验功能的合同段
+     * @return
+     */
+    @GetMapping("/isCyAndTestModule")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "验证是否使用成渝那边的树", notes = "传入合同段id")
+    public R<Boolean> isCyAndTestModule(Long projectId,Long contractId){
+        return R.data(trialCyService.isCyAndTestModule(projectId, contractId));
+    }
+
+    /**
+     * 获取成渝那边的树
+     * @return
+     */
+    @GetMapping("/getTree")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "获取成渝那边的树", notes = "传入项目id")
+    public R<List<TrialCyTestType>> getTree(Long projectId, String parentId){
+        return R.data(trialCyService.getTree(projectId,parentId));
+    }
+
+    /**
+     * 获取试验检测报告
+     * @return
+     */
+    @GetMapping("/getTrialDetectionReport")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "获取试验检测报告", notes = "")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "contractId", value = "合同段id", required = true),
+            @ApiImplicitParam(name = "pKeyId", value = "树节点pKeyId", required = true)
+    })
+    public R<List<TrialCyFinishTestReport>> getTrialDetectionReport(Long contractId, Long pKeyId){
+        return R.data(trialCyService.getTrialDetectionReport(contractId,pKeyId));
+    }
+
+
+    /**
+     * 获取第三方/外委 检测报告
+     * @return
+     */
+    @GetMapping("/getThirdReport")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "获取第三方/外委 检测报告", notes = "")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "contractId", value = "合同段id", required = true),
+            @ApiImplicitParam(name = "pKeyId", value = "树节点pKeyId", required = true),
+            @ApiImplicitParam(name = "type", value = "类型:0-外委检测,1-第三方", required = true)
+    })
+    public R<List<TrialCyThirdReport>> getThirdReport(Long contractId, Long pKeyId, Integer type){
+        return R.data(trialCyService.getThirdReport(contractId,pKeyId,type));
+    }
+
+
+}

+ 5 - 0
blade-service/blade-business/src/main/java/org/springblade/business/scheduled/ChenYuTestScheduled.java

@@ -515,8 +515,13 @@ public class ChenYuTestScheduled {
 
             List<TrialCyTestType> testTypes = data.toJavaList(TrialCyTestType.class);
             for (TrialCyTestType type : testTypes) {
+                type.setPKeyId(SnowFlakeUtil.getId());
                 type.setProjectId(PROJECT_ID);
+                type.setFatherID(type.getFatherID() == null || type.getFatherID().isEmpty() ? "0" : type.getFatherID());
             }
+            //先删除旧数据
+            trialCyTestTypeService.remove(Wrappers.<TrialCyTestType>lambdaQuery()
+                    .eq(TrialCyTestType::getProjectId, PROJECT_ID));
             trialCyTestTypeService.saveOrUpdateBatch(testTypes);
             log.info("Saved {} test types", testTypes.size());
         } catch (Exception e) {

+ 20 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/TrialCyService.java

@@ -0,0 +1,20 @@
+package org.springblade.business.service;
+
+import org.springblade.business.entity.TrialCyFinishTestReport;
+import org.springblade.business.entity.TrialCyTestType;
+import org.springblade.business.entity.TrialCyThirdReport;
+
+import java.util.List;
+
+/**
+ * @author LHB
+ */
+public interface TrialCyService {
+    Boolean isCyAndTestModule(Long projectId, Long contractId);
+
+    List<TrialCyTestType> getTree(Long projectId, String parentId);
+
+    List<TrialCyFinishTestReport> getTrialDetectionReport(Long contractId, Long pKeyId);
+
+    List<TrialCyThirdReport> getThirdReport(Long contractId, Long pKeyId, Integer type);
+}

+ 74 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialCyServiceImpl.java

@@ -0,0 +1,74 @@
+package org.springblade.business.service.impl;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import org.springblade.business.entity.TrialCyFinishTestReport;
+import org.springblade.business.entity.TrialCyTestType;
+import org.springblade.business.entity.TrialCyThirdReport;
+import org.springblade.business.service.*;
+import org.springblade.manager.entity.ContractInfo;
+import org.springblade.manager.entity.ProjectInfo;
+import org.springblade.manager.feign.ContractClient;
+import org.springblade.manager.feign.ProjectClient;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * 成渝数据获取
+ * @author LHB
+ */
+@Service
+public class TrialCyServiceImpl implements TrialCyService {
+    @Resource
+    private TrialCyAccessoriesService trialCyAccessoriesService;
+    @Resource
+    private TrialCyFinishTestReportService trialCyFinishTestReportService;
+    @Resource
+    private TrialCyTestTypeService trialCyTestTypeService;
+    @Resource
+    private TrialCyThirdReportService trialCyThirdReportService;
+
+    @Resource
+    private ProjectClient projectClient;
+    @Resource
+    private ContractClient contractClient;
+
+    @Override
+    public Boolean isCyAndTestModule(Long projectId, Long contractId) {
+        ProjectInfo byId = projectClient.getById(String.valueOf(projectId));
+        if(!"cqcyfx".equals(byId.getProjectNumber())){
+            return false;
+        }
+        ContractInfo contractById = contractClient.getContractById(contractId);
+        return contractById.getIsTestModule() == 0;
+    }
+
+    @Override
+    public List<TrialCyTestType> getTree(Long projectId, String parentId) {
+        List<TrialCyTestType> list = trialCyTestTypeService.list(Wrappers.<TrialCyTestType>lambdaQuery()
+                .eq(TrialCyTestType::getProjectId, projectId)
+                .eq(TrialCyTestType::getFatherID, parentId)
+        );
+        return list;
+    }
+
+    @Override
+    public List<TrialCyFinishTestReport> getTrialDetectionReport(Long contractId, Long pKeyId) {
+        TrialCyTestType byId = trialCyTestTypeService.getById(pKeyId);
+
+        return trialCyFinishTestReportService.list(Wrappers.<TrialCyFinishTestReport>lambdaQuery()
+                .eq(TrialCyFinishTestReport::getContractId, contractId)
+                .eq(TrialCyFinishTestReport::getProcessName, byId.getName()));
+    }
+
+    @Override
+    public List<TrialCyThirdReport> getThirdReport(Long contractId, Long pKeyId, Integer type) {
+        TrialCyTestType byId = trialCyTestTypeService.getById(pKeyId);
+        return trialCyThirdReportService.list(Wrappers.<TrialCyThirdReport>lambdaQuery()
+                .eq(TrialCyThirdReport::getContractId, contractId)
+                .eq(TrialCyThirdReport::getThirdType, type)
+                .eq(TrialCyThirdReport::getSampleName, byId.getName()));
+    }
+}