eight
2024-12-12 2bc90e242eceb83d9aa80d48ea9f991c0f9b99c6
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;
    }
}