BusinessServiceImpl.java
2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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;
/**
* table0 => (key0, value0)
*/
private static final Map<String, String[]> DICT_MAP = new HashMap<String, String[]>() {{
put("equipment_info", new String[]{"id", "equipment_name"});
put("sys_user", new String[]{"id", "realname"});
put("sys_struct_dict", new String[]{"id", "struct_name"});
put("equipment_category", new String[]{"id", "des"});
put("evaluate_score_desc", new String[]{"id", "score_desc"});
put("carbon_qualitative_desc", new String[]{"id", "qualitative_desc"});
put("sys_depart", new String[]{"id", "depart_name"});
put("equipment_sparepart_type", new String[]{"id", "item_text"});
put("supplies_warehouse", new String[]{"id", "warehouse_name"});
put("inspection_working_group", new String[]{"id", "group_name"});
}};
@Override
public Map<String, String> dictMap(String dictCode, Collection<?> inCol) {
String key0, value0, table0;
QueryWrapper<?> queryWrapper0 = new QueryWrapper<>();
if (DICT_MAP.containsKey(dictCode)) {
String[] dictArray = DICT_MAP.get(dictCode);
key0 = dictArray[0];
value0 = dictArray[1];
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;
}
}