|
@@ -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);
|
|
|
+ }
|
|
|
+}
|