Commit 9531d6297e2c0bac3815cbd06ba8742919e10eb8

Authored by litao
1 parent 44f975f0f1
Exists in master and in 1 other branch dev

删除配置初始化类

Showing 2 changed files with 9 additions and 111 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/BasicConfigContainer.java View file @ 9531d62
1   -package com.lyms.platform.permission;
2   -
3   -import com.lyms.platform.pojo.BasicConfig;
4   -import org.apache.commons.lang3.StringUtils;
5   -import org.slf4j.Logger;
6   -import org.slf4j.LoggerFactory;
7   -import org.springframework.beans.factory.annotation.Autowired;
8   -import org.springframework.data.mongodb.core.MongoTemplate;
9   -import org.springframework.data.mongodb.core.query.Criteria;
10   -import org.springframework.data.mongodb.core.query.Query;
11   -import org.springframework.stereotype.Component;
12   -
13   -import javax.annotation.PostConstruct;
14   -import java.util.ArrayList;
15   -import java.util.HashMap;
16   -import java.util.List;
17   -import java.util.Map;
18   -
19   -/**
20   - * @Author: litao
21   - * @Date: 2017/5/12 0012 14:55
22   - * @Version: V1.0
23   - */
24   -@Component
25   -public class BasicConfigContainer {
26   -
27   - private Logger logger = LoggerFactory.getLogger(BasicConfigContainer.class);
28   -
29   - @Autowired
30   - private MongoTemplate mongoTemplate;
31   -
32   - /** 用于存储 k-v 的数据*/
33   - private List<Map<String, BasicConfig>> map = new ArrayList<>();
34   -
35   - /** 用于存储 parent key 相同的数据 */
36   - private List<Map<String, List<BasicConfig>>> parentMap = new ArrayList<>();
37   -
38   - /**
39   - * 初始平台缓存信息
40   - */
41   - @PostConstruct
42   - public void initCache() {
43   - List<BasicConfig> configs = mongoTemplate.findAll(BasicConfig.class);
44   - for (BasicConfig config : configs) {
45   - if(StringUtils.isBlank(config.getParentId()) || !"0".equals(config.getParentId())) {
46   - Map<String, List<BasicConfig>> tempMap = new HashMap<>();
47   - List<BasicConfig> childs = mongoTemplate.find(Query.query(Criteria.where("parentId").is(config.getId())), BasicConfig.class);
48   - tempMap.put(config.getId(), childs);
49   - parentMap.add(tempMap);
50   - } else {
51   - Map<String, BasicConfig> tempMap = new HashMap<>();
52   - tempMap.put(config.getId(), config);
53   - map.add(tempMap);
54   - }
55   - }
56   - logger.info("baseconfig 加载完成");
57   - }
58   -
59   - /**
60   - * 删除平台缓存信息
61   - */
62   - public void deleteCache() {
63   - this.map.clear();
64   - this.parentMap.clear();
65   - logger.info("baseconfig 清理完成");
66   - }
67   -
68   - /**
69   - * 刷新缓存
70   - */
71   - public void flush() {
72   - deleteCache();
73   - initCache();
74   - }
75   -
76   - /**
77   - * 获取所有子级
78   - * @param parentId
79   - * @return
80   - */
81   - public List<BasicConfig> getChilds(String parentId) {
82   - for (Map<String, List<BasicConfig>> listMap : parentMap) {
83   - if(listMap.containsKey(parentId)) {
84   - return listMap.get(parentId);
85   - }
86   - }
87   - return null;
88   - }
89   -
90   - /**
91   - *
92   - * @param parentId
93   - * @return
94   - */
95   - public List<Map<String, Object>> getKvChilds(String parentId) {
96   - return null;
97   - }
98   -
99   - public BasicConfig getVal(String id){
100   - for (Map<String, BasicConfig> configMap : map) {
101   - if(configMap.containsKey(id)) {
102   - return configMap.get(id);
103   - }
104   - }
105   - return null;
106   - }
107   -}
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/BabyPatientExtendEarServiceImpl.java View file @ 9531d62
1 1 package com.lyms.platform.permission.service.impl;
2 2  
  3 +import com.lyms.platform.common.enums.FmTypeEnums;
3 4 import com.lyms.platform.common.result.BaseObjectResponse;
4 5 import com.lyms.platform.common.result.RespBuilder;
5 6 import com.lyms.platform.common.utils.SystemConfig;
... ... @@ -10,6 +11,8 @@
10 11 import com.lyms.platform.permission.model.BabyPatientExtendEarFamily;
11 12 import com.lyms.platform.permission.model.BabyPatientExtendEarMother;
12 13 import com.lyms.platform.permission.service.BabyPatientExtendEarService;
  14 +import net.sf.json.JSONArray;
  15 +import net.sf.json.JSONObject;
13 16 import org.springframework.beans.factory.annotation.Autowired;
14 17 import org.springframework.data.mongodb.core.MongoTemplate;
15 18 import org.springframework.stereotype.Service;
16 19  
17 20  
18 21  
... ... @@ -23,20 +26,22 @@
23 26 @Autowired
24 27 private BabyPatientExtendEarMapper earMapper;
25 28  
26   - @Autowired
27   - private BasicConfigContainer configContainer;
28   -
29 29 @Override
30 30 public BaseObjectResponse insert(BabyPatientExtendEar ear, BabyPatientExtendEarBirth earBirth,
31 31 BabyPatientExtendEarMother earMother, BabyPatientExtendEarFamily earFamily, Integer userId) {
32 32 System.out.println("ear = [" + ear + "], earBirth = [" + earBirth + "], earMother = [" + earMother + "], earFamily = [" + earFamily + "], userId = [" + userId + "]");
33   - System.out.println(configContainer.getChilds(SystemConfig.CENSUS_TYPE_ID));
34 33 return RespBuilder.buildSuccess();
35 34 }
36 35  
37 36 @Override
38 37 public BaseObjectResponse getConfigs() {
  38 + FmTypeEnums[] fmTypes = FmTypeEnums.values();
  39 + for (FmTypeEnums fmType : fmTypes) {
  40 + JSONObject jsonObject = JSONObject.fromObject(fmType);
  41 + System.err.println(">> " + jsonObject);
  42 + }
39 43 return null;
40 44 }
  45 +
41 46 }