22e8d044 张雷

设备台账导入功能

1 个父辈 b242b3bf
...@@ -312,7 +312,7 @@ public class EmergencyEventsController { ...@@ -312,7 +312,7 @@ public class EmergencyEventsController {
312 lastYearData.add(String.valueOf(lastYearMap.getOrDefault(type, "0"))); 312 lastYearData.add(String.valueOf(lastYearMap.getOrDefault(type, "0")));
313 } 313 }
314 } 314 }
315 Map<String, String> eventType = sysDictService.getDictMap("emergency_event_type").get("emergency_event_type"); 315 Map<String, String> eventType = sysDictService.getDictMap("emergency_event_type","export").get("emergency_event_type");
316 for (int i = 0; i < types.size(); i++) { 316 for (int i = 0; i < types.size(); i++) {
317 types.set(i, eventType.getOrDefault(types.get(i), "")); 317 types.set(i, eventType.getOrDefault(types.get(i), ""));
318 } 318 }
......
...@@ -671,6 +671,23 @@ public class EquipmentController { ...@@ -671,6 +671,23 @@ public class EquipmentController {
671 @AutoLog(value = "设备台账-excel导入") 671 @AutoLog(value = "设备台账-excel导入")
672 @ApiOperation(value = "设备台账-excel导入", notes = "设备台账-excel导入") 672 @ApiOperation(value = "设备台账-excel导入", notes = "设备台账-excel导入")
673 @RequestMapping(value = "/importExcel", method = RequestMethod.POST) 673 @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
674 public Result<?> importExcel(String departId,HttpServletRequest request) {
675 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
676 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
677 try {
678 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
679 MultipartFile file = entity.getValue();// 获取上传文件对象
680 equipmentInfoService.importExcel(file,departId);
681 }
682 return Result.ok("设备台账导入完成");
683 } catch (Exception e) {
684 return Result.error("设备台账导入失败");
685 }
686 }
687
688 @AutoLog(value = "设备台账-excel导入")
689 @ApiOperation(value = "设备台账-excel导入", notes = "设备台账-excel导入")
690 @RequestMapping(value = "/importData", method = RequestMethod.POST)
674 public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws Exception { 691 public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws Exception {
675 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; 692 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
676 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); 693 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
......
1 package com.skua.modules.equipment.service; 1 package com.skua.modules.equipment.service;
2 2
3 import java.io.IOException;
3 import java.util.List; 4 import java.util.List;
4 import java.util.Map; 5 import java.util.Map;
5 6
...@@ -10,6 +11,7 @@ import com.skua.modules.equipment.dto.EquipmentDTO; ...@@ -10,6 +11,7 @@ import com.skua.modules.equipment.dto.EquipmentDTO;
10 import com.skua.modules.equipment.entity.EquipmentInfo; 11 import com.skua.modules.equipment.entity.EquipmentInfo;
11 import com.skua.modules.equipment.vo.EquipmentInfoForMonitorVO; 12 import com.skua.modules.equipment.vo.EquipmentInfoForMonitorVO;
12 import com.skua.modules.equipment.vo.EquipmentVO; 13 import com.skua.modules.equipment.vo.EquipmentVO;
14 import org.springframework.web.multipart.MultipartFile;
13 15
14 /** 16 /**
15 * 设备信息 17 * 设备信息
...@@ -64,7 +66,7 @@ public interface IEquipmentInfoService extends IService<EquipmentInfo> { ...@@ -64,7 +66,7 @@ public interface IEquipmentInfoService extends IService<EquipmentInfo> {
64 * 自定义查询 66 * 自定义查询
65 * </pre> 67 * </pre>
66 * @param pageList 68 * @param pageList
67 * @param equipmentInfoVO 69 * @param equipmentInfoForMonitorVO
68 * @return 70 * @return
69 * @author Li Yuanyuan, 2022年6月28日 下午3:30:33 71 * @author Li Yuanyuan, 2022年6月28日 下午3:30:33
70 * @Description: TODO(这里描述这个方法的需求变更情况) 72 * @Description: TODO(这里描述这个方法的需求变更情况)
...@@ -78,4 +80,6 @@ public interface IEquipmentInfoService extends IService<EquipmentInfo> { ...@@ -78,4 +80,6 @@ public interface IEquipmentInfoService extends IService<EquipmentInfo> {
78 * @return 80 * @return
79 */ 81 */
80 List<Map<String, Object>> getEquipmentLifeTree(String id, String eventType); 82 List<Map<String, Object>> getEquipmentLifeTree(String id, String eventType);
83
84 void importExcel(MultipartFile file, String departId) throws Exception;
81 } 85 }
......
1 package com.skua.modules.equipment.service.impl; 1 package com.skua.modules.equipment.service.impl;
2 2
3 import java.io.File; 3 import java.io.File;
4 import java.io.IOException;
5 import java.io.InputStream;
4 import java.util.ArrayList; 6 import java.util.ArrayList;
5 import java.util.HashMap; 7 import java.util.HashMap;
6 import java.util.List; 8 import java.util.List;
7 import java.util.Map; 9 import java.util.Map;
8 import java.util.Set; 10 import java.util.Set;
9 11
12 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
13 import com.skua.core.context.BaseContextHandler;
14 import com.skua.core.excel.CustomExcelUtil;
15 import com.skua.core.excel.CustomExcelUtil07;
16 import com.skua.core.excel.entity.HeadEntity;
17 import com.skua.modules.equipment.entity.EquipmentAsset;
18 import com.skua.modules.equipment.service.IEquipmentAssetService;
19 import com.skua.modules.system.service.ISysDictService;
10 import org.apache.commons.lang.StringUtils; 20 import org.apache.commons.lang.StringUtils;
21 import org.apache.poi.ss.usermodel.Workbook;
22 import org.apache.poi.ss.usermodel.WorkbookFactory;
11 import org.springframework.beans.factory.annotation.Autowired; 23 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.beans.factory.annotation.Value; 24 import org.springframework.beans.factory.annotation.Value;
13 import org.springframework.jdbc.core.JdbcTemplate; 25 import org.springframework.jdbc.core.JdbcTemplate;
...@@ -35,6 +47,9 @@ import com.skua.modules.equipment.vo.EquipmentInfoForMonitorVO; ...@@ -35,6 +47,9 @@ import com.skua.modules.equipment.vo.EquipmentInfoForMonitorVO;
35 import com.skua.modules.equipment.vo.EquipmentVO; 47 import com.skua.modules.equipment.vo.EquipmentVO;
36 import com.skua.tool.util.BeanExtUtils; 48 import com.skua.tool.util.BeanExtUtils;
37 import com.skua.tool.util.JoinSqlUtils; 49 import com.skua.tool.util.JoinSqlUtils;
50 import org.springframework.web.multipart.MultipartFile;
51
52 import javax.annotation.Resource;
38 53
39 /** 54 /**
40 * 设备信息 55 * 设备信息
...@@ -50,10 +65,14 @@ public class EquipmentInfoServiceImpl extends ServiceImpl<EquipmentInfoMapper, E ...@@ -50,10 +65,14 @@ public class EquipmentInfoServiceImpl extends ServiceImpl<EquipmentInfoMapper, E
50 private ICrudSqlService iCrudSqlService; 65 private ICrudSqlService iCrudSqlService;
51 @Autowired 66 @Autowired
52 private IEquipmentInfoExtParamService equipmentInfoExtParamService; 67 private IEquipmentInfoExtParamService equipmentInfoExtParamService;
53 @Autowired 68 @Resource
54 private EquipmentInfoExtParamMapper equipmentInfoExtParamMapper; 69 private EquipmentInfoExtParamMapper equipmentInfoExtParamMapper;
55 @Autowired 70 @Resource
56 private EquipmentInfoMapper equipmentInfoMapper; 71 private EquipmentInfoMapper equipmentInfoMapper;
72 @Autowired
73 private ISysDictService sysDictService;
74 @Autowired
75 private IEquipmentAssetService equipmentAssetService;
57 76
58 77
59 @Override 78 @Override
...@@ -127,14 +146,13 @@ public class EquipmentInfoServiceImpl extends ServiceImpl<EquipmentInfoMapper, E ...@@ -127,14 +146,13 @@ public class EquipmentInfoServiceImpl extends ServiceImpl<EquipmentInfoMapper, E
127 146
128 @Override 147 @Override
129 public void editData(Result<EquipmentVO> result, EquipmentDTO equipmentDTO) throws Exception { 148 public void editData(Result<EquipmentVO> result, EquipmentDTO equipmentDTO) throws Exception {
130
131 Equipment equipment = EquipmentUtils.equipDTO2Entity(equipmentDTO); 149 Equipment equipment = EquipmentUtils.equipDTO2Entity(equipmentDTO);
132 // 前端未传,特殊处理 150 // 前端未传,特殊处理
133 equipment.getEquipmentInfo().setAssetId(equipment.getEquipmentAsset().getId()); 151 equipment.getEquipmentInfo().setAssetId(equipment.getEquipmentAsset().getId());
134 // 校验ID是否一致 152 // 校验ID是否一致
135 JoinSqlUtils.checkSqlIdFunc(equipment); 153 JoinSqlUtils.checkSqlIdFunc(equipment);
136 EquipmentInfo equipmentInfo = equipment.getEquipmentInfo(); 154 EquipmentInfo equipmentInfo = equipment.getEquipmentInfo();
137 155 equipmentInfo.setQrCode(createQrCode(equipmentInfo.getId()));
138 if (StringUtils.isNotEmpty(equipmentInfo.getStartUseDate()) && equipmentInfo.getLimitUseYear() != null) { 156 if (StringUtils.isNotEmpty(equipmentInfo.getStartUseDate()) && equipmentInfo.getLimitUseYear() != null) {
139 String[] items = equipmentInfo.getStartUseDate().split("-"); 157 String[] items = equipmentInfo.getStartUseDate().split("-");
140 equipmentInfo.setAdviceReplaceDate(Integer.parseInt(items[0]) + equipmentInfo.getLimitUseYear() + "-" + items[1] + "-" + items[2]); 158 equipmentInfo.setAdviceReplaceDate(Integer.parseInt(items[0]) + equipmentInfo.getLimitUseYear() + "-" + items[1] + "-" + items[2]);
...@@ -202,4 +220,108 @@ public class EquipmentInfoServiceImpl extends ServiceImpl<EquipmentInfoMapper, E ...@@ -202,4 +220,108 @@ public class EquipmentInfoServiceImpl extends ServiceImpl<EquipmentInfoMapper, E
202 } 220 }
203 } 221 }
204 222
223 @Override
224 public void importExcel(MultipartFile multipartFile, String departId) throws Exception {
225 if(StringUtils.isEmpty(departId)) {
226 departId = BaseContextHandler.getRealDepartId();
227 }
228 InputStream inputStream = multipartFile.getInputStream();
229 Workbook wb= WorkbookFactory.create(inputStream);
230 //构造字典数据对象
231 Map<String, Map<String, String>> dictMap = new HashMap<String,Map<String,String>>();
232 //基础字典
233 dictMap.putAll(sysDictService.getDictMap("spareTag","import"));//有无备用
234 dictMap.putAll(sysDictService.getDictMap("equipment-equipment_level","import"));//设备级别
235 dictMap.putAll(sysDictService.getDictMap("equipment-equipment_status","import"));//使用状况
236 //业务字典
237 dictMap.putAll(sysDictService.getBusinessMap("id", "sys_struct_dict", "struct_name","import"));//构筑物
238 dictMap.putAll(sysDictService.getBusinessMap("id", "ajh_supplier_manage", "supp_name","import"));//供应商
239 dictMap.putAll(sysDictService.getBusinessMap("id", "equipment_brand", "brand_name","import"));//品牌
240 dictMap.putAll(sysDictService.getBusinessMap("tree_path", "equipment_category", "tree_path_name","import"));//设备类别
241
242 //解析excel模板
243 List<HeadEntity> headEntityList = new ArrayList<HeadEntity>();
244 HeadEntity headEntity0 = CustomExcelUtil.createHeadEntity("设备名称", "equipmentName", 0, CustomExcelUtil.FieldType.INPUT, "");
245 HeadEntity headEntity1 = CustomExcelUtil.createHeadEntity("设备类别", "equipmentTypeTreePath", 1, CustomExcelUtil.FieldType.BUSINESS_DICT, "equipment_category");
246 headEntity1.setDictArray(dictMap.get("equipment_category").values().toArray(new String[0]));
247 HeadEntity headEntity2 = CustomExcelUtil.createHeadEntity("有无备用", "spareTag", 2, CustomExcelUtil.FieldType.COMMON_DICT, "spareTag");
248 headEntity2.setDictArray(dictMap.get("spareTag").values().toArray(new String[0]));
249 HeadEntity headEntity3 = CustomExcelUtil.createHeadEntity("设备编码", "equipmentCode", 3, CustomExcelUtil.FieldType.INPUT, "");
250 HeadEntity headEntity4 = CustomExcelUtil.createHeadEntity("设备级别", "equipmentLevel", 4, CustomExcelUtil.FieldType.COMMON_DICT, "equipment-equipment_level");
251 headEntity4.setDictArray(dictMap.get("equipment-equipment_level").values().toArray(new String[0]));
252 HeadEntity headEntity5 = CustomExcelUtil.createHeadEntity("规格型号", "productModel", 5, CustomExcelUtil.FieldType.INPUT, "");
253 HeadEntity headEntity6 = CustomExcelUtil.createHeadEntity("所属构筑物", "structures", 6, CustomExcelUtil.FieldType.BUSINESS_DICT, "sys_struct_dict");
254 headEntity6.setDictArray(dictMap.get("sys_struct_dict").values().toArray(new String[0]));
255 HeadEntity headEntity7 = CustomExcelUtil.createHeadEntity("使用年限(年)", "workingLife", 7, CustomExcelUtil.FieldType.INPUT, "");
256 HeadEntity headEntity8 = CustomExcelUtil.createHeadEntity("使用状况", "equipmentStatus", 8, CustomExcelUtil.FieldType.COMMON_DICT, "equipment-equipment_status");
257 headEntity8.setDictArray(dictMap.get("equipment-equipment_status").values().toArray(new String[0]));
258 HeadEntity headEntity9 = CustomExcelUtil.createHeadEntity("供应商", "manufacturer", 9, CustomExcelUtil.FieldType.BUSINESS_DICT, "ajh_supplier_manage");
259 headEntity9.setDictArray(dictMap.get("ajh_supplier_manage").values().toArray(new String[0]));
260 HeadEntity headEntity10 = CustomExcelUtil.createHeadEntity("设备品牌", "equipmentBrand", 10, CustomExcelUtil.FieldType.BUSINESS_DICT, "equipment_brand");
261 headEntity10.setDictArray(dictMap.get("equipment_brand").values().toArray(new String[0]));
262 HeadEntity headEntity11 = CustomExcelUtil.createHeadEntity("生产日期", "manufactureDate", 11, CustomExcelUtil.FieldType.INPUT, "");
263 HeadEntity headEntity12 = CustomExcelUtil.createHeadEntity("购置日期", "intakeDate", 12, CustomExcelUtil.FieldType.INPUT, "");
264 HeadEntity headEntity13 = CustomExcelUtil.createHeadEntity("原购置价", "originalValue", 13, CustomExcelUtil.FieldType.INPUT, "");
265 HeadEntity headEntity14 = CustomExcelUtil.createHeadEntity("安装日期", "installDate", 14, CustomExcelUtil.FieldType.INPUT, "");
266 HeadEntity headEntity15 = CustomExcelUtil.createHeadEntity("移交日期", "handoverDate", 15, CustomExcelUtil.FieldType.INPUT, "");
267 HeadEntity headEntity16 = CustomExcelUtil.createHeadEntity("报废日期", "scrapDate", 16, CustomExcelUtil.FieldType.INPUT, "");
268
269 headEntityList.add(headEntity0);headEntityList.add(headEntity1);headEntityList.add(headEntity2);headEntityList.add(headEntity3);headEntityList.add(headEntity4);
270 headEntityList.add(headEntity5);headEntityList.add(headEntity6);headEntityList.add(headEntity7); headEntityList.add(headEntity8);headEntityList.add(headEntity9);
271 headEntityList.add(headEntity10);headEntityList.add(headEntity11);headEntityList.add(headEntity12);headEntityList.add(headEntity13);headEntityList.add(headEntity14);
272 headEntityList.add(headEntity15);headEntityList.add(headEntity16);
273
274 List<EquipmentInfo> excelDataList = CustomExcelUtil07.readExcel(wb, "设备台账", 0, 1, headEntityList, EquipmentInfo.class, dictMap);
275 //新增设备
276 List<EquipmentInfo> addList = new ArrayList<EquipmentInfo>();
277 List<EquipmentAsset> assetAddList = new ArrayList<EquipmentAsset>();
278 //更新设备
279 List<EquipmentInfo> updateList = new ArrayList<EquipmentInfo>();
280 if(excelDataList!=null&&excelDataList.size()>0) {
281 QueryWrapper<EquipmentInfo> qw = null;
282 for(EquipmentInfo equipmentInfo : excelDataList) {
283 qw = new QueryWrapper<EquipmentInfo>();
284 String equipmentCode = equipmentInfo.getEquipmentCode();
285 qw.eq("equipment_code", equipmentCode);
286 List<EquipmentInfo> checkList = this.list(qw);
287 if(checkList!=null&&checkList.size()>0) {
288 //存在
289 equipmentInfo.setId(checkList.get(0).getId());
290 String equipmentTypeTreePath = equipmentInfo.getEquipmentTypeTreePath();
291 if(StringUtils.isNotEmpty(equipmentTypeTreePath)) {
292 String[] equipmentTypeArray = equipmentTypeTreePath.split(",");
293 equipmentInfo.setEquipmentTopType(equipmentTypeArray[0]);
294 equipmentInfo.setEquipmentType(equipmentTypeArray[equipmentTypeArray.length-1]);
295 }
296 updateList.add(equipmentInfo);
297 }else {
298 //不存在
299 String equipmentTypeTreePath = equipmentInfo.getEquipmentTypeTreePath();
300 if(StringUtils.isNotEmpty(equipmentTypeTreePath)) {
301 String[] equipmentTypeArray = equipmentTypeTreePath.split(",");
302 equipmentInfo.setEquipmentTopType(equipmentTypeArray[0]);
303 equipmentInfo.setEquipmentType(equipmentTypeArray[equipmentTypeArray.length-1]);
304 }
305 equipmentInfo.setDepartId(departId);
306 //equipment_asset表添加相关数据
307 EquipmentAsset equipmentAsset = new EquipmentAsset();
308 String assetId = String.valueOf(sequenceService.nextId());
309 equipmentAsset.setId(assetId);
310 equipmentInfo.setAssetId(assetId);
311 addList.add(equipmentInfo);
312 assetAddList.add(equipmentAsset);
313 }
314 }
315 }
316 if(addList.size()>0) {
317 //执行批量新增
318 this.saveOrUpdateBatch(addList);
319 equipmentAssetService.saveOrUpdateBatch(assetAddList);
320 }
321 if(updateList.size()>0) {
322 //执行批量修改
323 this.saveOrUpdateBatch(updateList);
324 }
325 }
326
205 } 327 }
......
...@@ -105,7 +105,7 @@ public class DictAspect { ...@@ -105,7 +105,7 @@ public class DictAspect {
105 if(!org.apache.commons.lang3.StringUtils.isBlank(table)){ 105 if(!org.apache.commons.lang3.StringUtils.isBlank(table)){
106 if (!businessMap.containsKey(table)){ 106 if (!businessMap.containsKey(table)){
107 //获取table的集合 107 //获取table的集合
108 Map<String, Map<String,String>> map = dictService.getBusinessMap(code,table,text); 108 Map<String, Map<String,String>> map = dictService.getBusinessMap(code,table,text,"export");
109 businessMap.putAll(map); 109 businessMap.putAll(map);
110 } 110 }
111 111
...@@ -120,7 +120,7 @@ public class DictAspect { ...@@ -120,7 +120,7 @@ public class DictAspect {
120 textValue = textValueStringBuilder.toString().replaceFirst(",",""); 120 textValue = textValueStringBuilder.toString().replaceFirst(",","");
121 }else{ 121 }else{
122 if (!dictMap.containsKey(code)){ 122 if (!dictMap.containsKey(code)){
123 Map<String, Map<String,String>> map = dictService.getDictMap(code); 123 Map<String, Map<String,String>> map = dictService.getDictMap(code,"export");
124 dictMap.putAll(map); 124 dictMap.putAll(map);
125 } 125 }
126 String[] keys = key.split(","); 126 String[] keys = key.split(",");
......
...@@ -343,17 +343,13 @@ public class PipenetworkTubewellController { ...@@ -343,17 +343,13 @@ public class PipenetworkTubewellController {
343 /** 343 /**
344 * 分页列表查询 344 * 分页列表查询
345 * 345 *
346 * @param pipenetworkTubewell
347 * @param pageNo
348 * @param pageSize
349 * @param req 346 * @param req
350 * @return 347 * @return
351 */ 348 */
352 @AutoLog(value = "排水管网-管井-获取所有管井数据") 349 @AutoLog(value = "排水管网-管井-获取所有管井数据")
353 @ApiOperation(value = "排水管网-管井-获取所有管井数据", notes = "排水管网-管井--获取所有管井数据") 350 @ApiOperation(value = "排水管网-管井-获取所有管井数据", notes = "排水管网-管井--获取所有管井数据")
354 @GetMapping(value = "/queryAllList") 351 @GetMapping(value = "/queryAllList")
355 public Result<List<PipenetworkTubewell>> queryAllList( 352 public Result<List<PipenetworkTubewell>> queryAllList(HttpServletRequest req) {
356 HttpServletRequest req) {
357 Result<List<PipenetworkTubewell>> result = new Result<List<PipenetworkTubewell>>(); 353 Result<List<PipenetworkTubewell>> result = new Result<List<PipenetworkTubewell>>();
358 QueryWrapper<PipenetworkTubewell> pipenetworkTubewell = new QueryWrapper<>(); 354 QueryWrapper<PipenetworkTubewell> pipenetworkTubewell = new QueryWrapper<>();
359 pipenetworkTubewell.eq("del_flag", 0); 355 pipenetworkTubewell.eq("del_flag", 0);
...@@ -375,22 +371,19 @@ public class PipenetworkTubewellController { ...@@ -375,22 +371,19 @@ public class PipenetworkTubewellController {
375 } 371 }
376 372
377 private Map<String, String> setDictText(String table) { 373 private Map<String, String> setDictText(String table) {
378 Map<String, String> type = sysDictService.getDictMap(table).get(table); 374 Map<String, String> type = sysDictService.getDictMap(table,"export").get(table);
379 return type; 375 return type;
380 } 376 }
381 377
382 /** 378 /**
383 * 根据管径查询管线 379 * 根据管径查询管线
384 * 380 * @param gjID
385 * @param gjID[]
386 * @param req
387 * @return 381 * @return
388 */ 382 */
389 @AutoLog(value = "排水管网-管线-分页列表查询") 383 @AutoLog(value = "排水管网-管线-分页列表查询")
390 @ApiOperation(value = "排水管网-管线-分页列表查询", notes = "排水管网-管线-分页列表查询") 384 @ApiOperation(value = "排水管网-管线-分页列表查询", notes = "排水管网-管线-分页列表查询")
391 @GetMapping(value = "/queryPipelineBytubWells") 385 @GetMapping(value = "/queryPipelineBytubWells")
392 public Result<List<PipenetworkPipeline>> queryPipelineBytubWells(String[] gjID, 386 public Result<List<PipenetworkPipeline>> queryPipelineBytubWells(String[] gjID) {
393 HttpServletRequest req) {
394 Result<List<PipenetworkPipeline>> result = new Result<List<PipenetworkPipeline>>(); 387 Result<List<PipenetworkPipeline>> result = new Result<List<PipenetworkPipeline>>();
395 String ids = ""; 388 String ids = "";
396 for (String id : gjID) { 389 for (String id : gjID) {
......
...@@ -99,9 +99,9 @@ public interface ISysDictService extends IService<SysDict> { ...@@ -99,9 +99,9 @@ public interface ISysDictService extends IService<SysDict> {
99 <T> List<JSONObject> translateListDictValue(List<T> list); 99 <T> List<JSONObject> translateListDictValue(List<T> list);
100 100
101 101
102 Map<String, Map<String, String>> getDictMap(String code); 102 Map<String, Map<String, String>> getDictMap(String code, String type);
103 103
104 Map<String, Map<String, String>> getBusinessMap(String code, String table, String text); 104 Map<String, Map<String, String>> getBusinessMap(String code, String table, String text, String type);
105 105
106 String queryDictIdByCode(String code); 106 String queryDictIdByCode(String code);
107 107
......
...@@ -23,6 +23,7 @@ import org.springframework.stereotype.Service; ...@@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
23 import org.springframework.transaction.annotation.Transactional; 23 import org.springframework.transaction.annotation.Transactional;
24 import org.springframework.util.StringUtils; 24 import org.springframework.util.StringUtils;
25 25
26 import javax.annotation.Resource;
26 import java.lang.reflect.Field; 27 import java.lang.reflect.Field;
27 import java.text.SimpleDateFormat; 28 import java.text.SimpleDateFormat;
28 import java.util.*; 29 import java.util.*;
...@@ -35,9 +36,9 @@ import java.util.stream.Collectors; ...@@ -35,9 +36,9 @@ import java.util.stream.Collectors;
35 @Slf4j 36 @Slf4j
36 public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> implements ISysDictService { 37 public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> implements ISysDictService {
37 38
38 @Autowired 39 @Resource
39 private SysDictMapper sysDictMapper; 40 private SysDictMapper sysDictMapper;
40 @Autowired 41 @Resource
41 private SysDictItemMapper sysDictItemMapper; 42 private SysDictItemMapper sysDictItemMapper;
42 43
43 @Override 44 @Override
...@@ -221,7 +222,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl ...@@ -221,7 +222,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
221 222
222 @Override 223 @Override
223 public Map<String, String> getDictMapByCode(String code) { 224 public Map<String, String> getDictMapByCode(String code) {
224 return this.getDictMap(code).get(code); 225 return this.getDictMap(code,"export").get(code);
225 } 226 }
226 @Override 227 @Override
227 public <T> List<JSONObject> translateListDictValue(List<T> list) { 228 public <T> List<JSONObject> translateListDictValue(List<T> list) {
...@@ -250,13 +251,13 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl ...@@ -250,13 +251,13 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
250 if (!org.apache.commons.lang3.StringUtils.isBlank(table)) { 251 if (!org.apache.commons.lang3.StringUtils.isBlank(table)) {
251 if (!businessMap.containsKey(table)) { 252 if (!businessMap.containsKey(table)) {
252 //获取table的集合 253 //获取table的集合
253 Map<String, Map<String, String>> map = getBusinessMap(code, table, text); 254 Map<String, Map<String, String>> map = getBusinessMap(code, table, text,"export");
254 businessMap.putAll(map); 255 businessMap.putAll(map);
255 } 256 }
256 textValue = businessMap.get(table).get(key); 257 textValue = businessMap.get(table).get(key);
257 } else { 258 } else {
258 if (!dictMap.containsKey(code)) { 259 if (!dictMap.containsKey(code)) {
259 Map<String, Map<String, String>> map = getDictMap(code); 260 Map<String, Map<String, String>> map = getDictMap(code,"export");
260 dictMap.putAll(map); 261 dictMap.putAll(map);
261 } 262 }
262 if (!StringUtils.isEmpty(key)&&key.split(",").length > 1) { 263 if (!StringUtils.isEmpty(key)&&key.split(",").length > 1) {
...@@ -291,24 +292,32 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl ...@@ -291,24 +292,32 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
291 } 292 }
292 293
293 @Override 294 @Override
294 public Map<String, Map<String, String>> getDictMap(String code) { 295 public Map<String, Map<String, String>> getDictMap(String code,String type) {
295 Map<String, Map<String, String>> dictMap = new HashMap<>(); 296 Map<String, Map<String, String>> dictMap = new HashMap<>();
296 List<Map<String, String>> listMap = sysDictMapper.getDictMapByCode(code); 297 List<Map<String, String>> listMap = sysDictMapper.getDictMapByCode(code);
297 Map<String, String> map = new HashMap<>(); 298 Map<String, String> map = new HashMap<>();
298 listMap.forEach(map1 -> { 299 listMap.forEach(map1 -> {
300 if("export".equals(type)) {
299 map.put(map1.get("item_value"), map1.get("item_text")); 301 map.put(map1.get("item_value"), map1.get("item_text"));
302 }else {
303 map.put(map1.get("item_text"), map1.get("item_value"));
304 }
300 }); 305 });
301 dictMap.put(code, map); 306 dictMap.put(code, map);
302 return dictMap; 307 return dictMap;
303 } 308 }
304 309
305 @Override 310 @Override
306 public Map<String, Map<String, String>> getBusinessMap(String code, String table, String text) { 311 public Map<String, Map<String, String>> getBusinessMap(String code, String table, String text,String type) {
307 Map<String, Map<String, String>> businessMap = new HashMap<>(); 312 Map<String, Map<String, String>> businessMap = new HashMap<>();
308 List<Map<String, String>> listMap = sysDictMapper.getBusinessMapByTable(code, table, text); 313 List<Map<String, String>> listMap = sysDictMapper.getBusinessMapByTable(code, table, text);
309 Map<String, String> map = new HashMap<>(); 314 Map<String, String> map = new HashMap<>();
310 listMap.forEach(map1 -> { 315 listMap.forEach(map1 -> {
316 if("export".equals(type)) {
311 map.put(String.valueOf(map1.get(code)), map1.get(text)); 317 map.put(String.valueOf(map1.get(code)), map1.get(text));
318 }else {
319 map.put(map1.get(text),String.valueOf(map1.get(code)));
320 }
312 }); 321 });
313 businessMap.put(table, map); 322 businessMap.put(table, map);
314 return businessMap; 323 return businessMap;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!