From a5115a30066847baaf0d85ae8ba802b8f2fd5e58 Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期一, 09 九月 2024 18:03:00 +0800
Subject: [PATCH] 设备功能

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devmanage/DevModelService.java             |   12 +++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devmanage/DevModelServiceImpl.java         |   40 ++++++++++++++++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/devmanage/DevModelMapper.java            |    8 ++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devmanage/DevModelController.java |   16 ++++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devmanage/vo/OptionVO.java        |   19 +++++++++
 5 files changed, 94 insertions(+), 1 deletions(-)

diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devmanage/DevModelController.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devmanage/DevModelController.java
index bee8e5c..6e6ed41 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devmanage/DevModelController.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devmanage/DevModelController.java
@@ -92,4 +92,20 @@
                         BeanUtils.toBean(list, DevModelRespVO.class));
     }
 
+    @GetMapping("/brand-option")
+    @Operation(summary = "鑾峰緱鍝佺墝閫夐」")
+    @PreAuthorize("@ss.hasPermission('ecg:dev-model:query')")
+    public CommonResult<List<OptionVO>> getBrandOption(String category) {
+        List<OptionVO> optionVOList = devModelService.getBrandOptions( category );
+        return success( optionVOList );
+    }
+
+    @GetMapping("/model-option")
+    @Operation(summary = "鑾峰緱妯″瀷閫夐」")
+    @PreAuthorize("@ss.hasPermission('ecg:dev-model:query')")
+    public CommonResult<List<OptionVO>> getModelOption(String category, String brand) {
+        List<OptionVO> optionVOList = devModelService.getBrandModelOptions( category, brand );
+        return success( optionVOList );
+    }
+
 }
\ No newline at end of file
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devmanage/vo/OptionVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devmanage/vo/OptionVO.java
new file mode 100644
index 0000000..74c510c
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devmanage/vo/OptionVO.java
@@ -0,0 +1,19 @@
+package cn.lihu.jh.module.ecg.controller.admin.devmanage.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+
+@Schema(description = "绠$悊鍚庡彴 - 璁惧鍨嬪彿鏂板/淇敼 Option VO")
+@Data
+public class OptionVO {
+
+    @Schema(description = "鏄剧ず鍚�", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "鏄剧ず鍚嶄笉鑳戒负绌�")
+    private String label;
+
+    @Schema(description = "閫夊瀷鍊�", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "閫夊瀷鍊间笉鑳戒负绌�")
+    private String value;
+}
\ No newline at end of file
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/devmanage/DevModelMapper.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/devmanage/DevModelMapper.java
index c37aba5..df3a775 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/devmanage/DevModelMapper.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/devmanage/DevModelMapper.java
@@ -8,6 +8,8 @@
 import cn.lihu.jh.module.ecg.dal.dataobject.devmanage.DevModelDO;
 import org.apache.ibatis.annotations.Mapper;
 import cn.lihu.jh.module.ecg.controller.admin.devmanage.vo.*;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * 璁惧鍨嬪彿 Mapper
@@ -26,4 +28,10 @@
                 .orderByDesc(DevModelDO::getId));
     }
 
+    @Select("select distinct brand from lihu.device_model where category=#{category}")
+    List<String> getBrandByCategory(@Param("category") String category);
+
+    @Select("select model from lihu.device_model where category=#{category} and brand=#{brand}")
+    List<String> getModelByCategoryBrand(@Param("category") String category, @Param("brand") String brand);
+
 }
\ No newline at end of file
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devmanage/DevModelService.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devmanage/DevModelService.java
index ab17c84..526a30d 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devmanage/DevModelService.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devmanage/DevModelService.java
@@ -5,6 +5,7 @@
 import cn.lihu.jh.framework.common.pojo.PageResult;
 
 import javax.validation.Valid;
+import java.util.List;
 
 /**
  * 璁惧鍨嬪彿 Service 鎺ュ彛
@@ -51,4 +52,13 @@
      */
     PageResult<DevModelDO> getDevModelPage(DevModelPageReqVO pageReqVO);
 
-}
\ No newline at end of file
+    /**
+     * 鏍规嵁鍒嗙被鑾峰彇鍝佺墝
+     */
+    List<OptionVO> getBrandOptions(String devCategory);
+
+    /**
+     * 鏍规嵁鍒嗙被鍜屽搧鐗岋紝鑾峰彇鍨嬪彿
+     */
+    List<OptionVO> getBrandModelOptions(String devCategory, String devBrand);
+}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devmanage/DevModelServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devmanage/DevModelServiceImpl.java
index 29ec88b..7939b42 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devmanage/DevModelServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devmanage/DevModelServiceImpl.java
@@ -1,5 +1,7 @@
 package cn.lihu.jh.module.ecg.service.devmanage;
 
+import cn.lihu.jh.module.system.api.dict.DictDataApi;
+import cn.lihu.jh.module.system.api.dict.dto.DictDataRespDTO;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 
@@ -11,6 +13,11 @@
 import cn.lihu.jh.module.ecg.dal.mysql.devmanage.DevModelMapper;
 
 import javax.annotation.Resource;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*;
@@ -26,6 +33,9 @@
 
     @Resource
     private DevModelMapper devModelMapper;
+
+    @Resource
+    private DictDataApi dictDataApi;
 
     @Override
     public Integer createDevModel(DevModelSaveReqVO createReqVO) {
@@ -69,4 +79,34 @@
         return devModelMapper.selectPage(pageReqVO);
     }
 
+    @Override
+    public List<OptionVO> getBrandOptions(String devCategory) {
+        List<String> list = devModelMapper.getBrandByCategory(devCategory);
+
+        List<DictDataRespDTO> dictDataRespDTOList = dictDataApi.getDictDataList("ecg_dev_brand");
+        Map<String, String> map = dictDataRespDTOList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel));
+
+        List<OptionVO> optionVOList = new ArrayList<>();
+        list.forEach(item -> {
+            OptionVO optionVO = new OptionVO();
+            optionVO.setLabel( map.get(item) );
+            optionVO.setValue( item );
+            optionVOList.add( optionVO );
+        });
+        return optionVOList;
+    }
+
+    @Override
+    public List<OptionVO> getBrandModelOptions(String devCategory, String devBrand) {
+        List<String> list = devModelMapper.getModelByCategoryBrand(devCategory, devBrand);
+        List<OptionVO> optionVOList = new ArrayList<>();
+        list.forEach(item -> {
+            OptionVO optionVO = new OptionVO();
+            optionVO.setLabel( item );
+            optionVO.setValue( item );
+            optionVOList.add( optionVO );
+        });
+        return optionVOList;
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.3