Преглед изворни кода

根据项目编号查询动物品种

陈长荣 пре 2 недеља
родитељ
комит
4c8456cbcb

+ 57 - 0
jfcloud-gene-api/pom.xml

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>com.github.jfcloud</groupId>
+    <artifactId>jfcloud-gene</artifactId>
+    <version>1.0</version>
+  </parent>
+
+  <artifactId>jfcloud-gene-api</artifactId>
+
+  <properties>
+    <maven.compiler.source>8</maven.compiler.source>
+    <maven.compiler.target>8</maven.compiler.target>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.cloud</groupId>
+      <artifactId>spring-cloud-openfeign-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.github.jfcloud</groupId>
+      <artifactId>jfcloud-common-core</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>3.2.0</version>
+        <configuration>
+          <!-- 不指定 mainClass 属性 -->
+        </configuration>
+      </plugin>
+      <!-- 配置 maven-source-plugin 以生成 sources.jar -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+        <version>3.0.1</version>
+        <executions>
+          <execution>
+            <id>attach-sources</id>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

+ 22 - 0
jfcloud-gene-api/src/main/java/com/github/jfcloud/gene/feign/GeneInfoApi.java

@@ -0,0 +1,22 @@
+package com.github.jfcloud.gene.feign;
+
+import com.github.jfcloud.common.core.util.R;
+import com.github.jfcloud.gene.vo.AnimalItemVo;
+import com.github.jfcloud.gene.vo.ProjectRequestVO;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.List;
+import java.util.Map;
+
+@FeignClient(value = "jfcloud-gene-biz", contextId = "GeneInfoApi")
+public interface GeneInfoApi {
+
+    /**
+     * 获取项目的动物类型
+     */
+    @PostMapping("/gene/animals")
+    R<Map<String, List<AnimalItemVo>>> getAnimalList(@RequestBody ProjectRequestVO projectRequestVO);
+
+}

+ 20 - 0
jfcloud-gene-api/src/main/java/com/github/jfcloud/gene/vo/AnimalItemVo.java

@@ -0,0 +1,20 @@
+package com.github.jfcloud.gene.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class AnimalItemVo implements Serializable {
+
+    @Schema(description = "品系名称")
+    private String strainName;
+
+    @Schema(description = "数量")
+    private Integer quantity;
+}

+ 16 - 0
jfcloud-gene-api/src/main/java/com/github/jfcloud/gene/vo/ProjectRequestVO.java

@@ -0,0 +1,16 @@
+package com.github.jfcloud.gene.vo;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import java.util.List;
+
+@Data
+public class ProjectRequestVO {
+
+    /**
+     * 项目编号列表
+     */
+    @NotEmpty(message = "项目编号列表不能为空")
+    private List<String> projectNoList;
+}

+ 6 - 0
jfcloud-gene-biz/pom.xml

@@ -45,6 +45,12 @@
       <version>${project.version}</version>
     </dependency>
 
+    <dependency>
+      <groupId>com.github.jfcloud</groupId>
+      <artifactId>jfcloud-gene-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
     <dependency>
       <groupId>com.github.xiaoymin</groupId>
       <artifactId>knife4j-openapi3-spring-boot-starter</artifactId>

+ 88 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/controller/GeneApiController.java

@@ -0,0 +1,88 @@
+package com.github.jfcloud.gene.flow.controller;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.github.jfcloud.common.core.util.R;
+import com.github.jfcloud.common.enums.WhetherEnum;
+import com.github.jfcloud.gene.flow.entity.FlowInfo;
+import com.github.jfcloud.gene.flow.service.FlowInfoService;
+import com.github.jfcloud.gene.form.dto.StrainCustomDto;
+import com.github.jfcloud.gene.form.dto.StrainPurificationInfoDto;
+import com.github.jfcloud.gene.form.service.StrainCustomInfoService;
+import com.github.jfcloud.gene.form.service.StrainPurificationInfoService;
+import com.github.jfcloud.gene.form.vo.AnimalDemandVo;
+import com.github.jfcloud.gene.form.vo.StrainCustomDetailVo;
+import com.github.jfcloud.gene.vo.AnimalItemVo;
+import com.github.jfcloud.gene.vo.ProjectRequestVO;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Tag(name = "api模块定义的接口")
+@RestController
+@RequestMapping("/gene")
+@RequiredArgsConstructor
+public class GeneApiController {
+
+    private final FlowInfoService flowInfoService;
+    private final StrainCustomInfoService customInfoService;
+    private final StrainPurificationInfoService purificationInfoService;
+
+    /**
+     * 获取项目的动物类型
+     */
+    @PostMapping("/animals")
+    public R<Map<String, List<AnimalItemVo>>> getAnimalList(@RequestBody ProjectRequestVO projectRequestVO) {
+        List<FlowInfo> list = flowInfoService.list(new LambdaQueryWrapper<>(FlowInfo.class)
+                .select(FlowInfo::getId, FlowInfo::getApprovalNo)
+                .in(FlowInfo::getApprovalNo, projectRequestVO.getProjectNoList())
+                .eq(FlowInfo::getDeleted, WhetherEnum.NO.getCode()));
+        Map<String, Long> projectIdMap = list.stream().collect(Collectors.toMap(FlowInfo::getApprovalNo, FlowInfo::getId, (a, b) -> b));
+
+        Map<String, List<AnimalItemVo>> resultMap = new HashMap<>();
+        if (list.isEmpty()) {
+            return R.ok(resultMap);
+        }
+
+        for (String projectNo : projectRequestVO.getProjectNoList()) {
+            if (!projectIdMap.containsKey(projectNo)) {
+                continue;
+            }
+
+            List<AnimalItemVo> animals = new ArrayList<>();
+
+            Long flowId = projectIdMap.get(projectNo);
+            //查询基因定制
+            StrainCustomDto customDto = customInfoService.getByFlowId(flowId);
+            if (customDto != null) {
+                String requirements = customDto.getDetailList().stream()
+                        .map(StrainCustomDetailVo::getSpecificRequirement)
+                        .filter(StrUtil::isNotBlank)
+                        .distinct()
+                        .collect(Collectors.joining(";"));
+                animals.add(new AnimalItemVo(requirements, customDto.getDetailList().size()));
+            }
+
+            //查询净化扩繁的动物需求
+            StrainPurificationInfoDto purificationInfoDto = purificationInfoService.getByFlowId(flowId);
+            if (purificationInfoDto != null) {
+                List<AnimalDemandVo> animalDemands = purificationInfoDto.getAnimalDemands();
+                animals.addAll(BeanUtil.copyToList(animalDemands, AnimalItemVo.class));
+            }
+
+            resultMap.put(projectNo, animals);
+        }
+
+        return R.ok(resultMap);
+    }
+}

+ 1 - 0
pom.xml

@@ -11,6 +11,7 @@
   <modules>
     <module>jfcloud-gene-biz</module>
     <module>jfcloud-gene-common</module>
+    <module>jfcloud-gene-api</module>
   </modules>
 
   <properties>