BusinessServiceImpl.java 2.6 KB
package com.skua.modules.biz.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.skua.modules.base.service.IBaseService;
import com.skua.modules.biz.IBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author:sonin
 * @Date:2025/2/18 15:35
 */
@Service
public class BusinessServiceImpl implements IBusinessService {

    @Autowired
    private IBaseService baseService;

    @Override
    public Map<String, String> dictMap(String dictCode, Collection<?> inCol) {
        String key0, value0, table0;
        QueryWrapper<?> queryWrapper0 = new QueryWrapper<>();
        if ("equipment_info".equals(dictCode)) {
            key0 = "id";
            value0 = "equipment_name";
            table0 = dictCode;
        } else if ("sys_user".equals(dictCode)) {
            key0 = "id";
            value0 = "realname";
            table0 = dictCode;
        } else if ("sys_struct_dict".equals(dictCode)) {
            key0 = "id";
            value0 = "struct_name";
            table0 = dictCode;
        } else if ("equipment_category".equals(dictCode)) {
            key0 = "id";
            value0 = "des";
            table0 = dictCode;
        } else if ("evaluate_score_desc".equals(dictCode)) {
            key0 = "id";
            value0 = "score_desc";
            table0 = dictCode;
        } else if ("carbon_qualitative_desc".equals(dictCode)) {
            key0 = "id";
            value0 = "qualitative_desc";
            table0 = dictCode;
        } else if ("sys_depart".equals(dictCode)) {
            key0 = "id";
            value0 = "depart_name";
            table0 = dictCode;
        } else {
            // 数据字典查询
            queryWrapper0.eq("sys_dict.dict_code", dictCode);
            key0 = "sys_dict_item.item_value";
            value0 = "sys_dict_item.item_text";
            table0 = "sys_dict inner join sys_dict_item on sys_dict.id = sys_dict_item.dict_id";
        }
        String sqlSelect = "select " + key0 + " as key0, " + value0 + " as value0 from " + table0;
        if (inCol != null && !inCol.isEmpty()) {
            queryWrapper0.in(key0, inCol);
        }
        List<Map<String, Object>> queryMapList0 = baseService.queryForList(sqlSelect, queryWrapper0);
        Map<String, String> dictMap = new HashMap<>(10);
        for (Map<String, Object> item : queryMapList0) {
            dictMap.put(String.valueOf(item.get("key0")), String.valueOf(item.get("value0")));
        }
        return dictMap;
    }


}