Commit 04249f1eb4b739f0193cf79def1a5396be94b3d5

Authored by liquanyu
1 parent 3f6926e02d

update code

Showing 8 changed files with 485 additions and 6 deletions

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/BasicConfigService.java View file @ 04249f1
... ... @@ -2,15 +2,19 @@
2 2  
3 3 import com.google.common.cache.*;
4 4 import com.lyms.platform.biz.dal.IBasicConfigDao;
  5 +import com.lyms.platform.common.constants.ErrorCodeConstants;
5 6 import com.lyms.platform.common.dao.operator.MongoCondition;
6 7 import com.lyms.platform.common.dao.operator.MongoOper;
7 8 import com.lyms.platform.common.dao.operator.MongoQuery;
8 9 import com.lyms.platform.common.dao.operator.Page;
9 10 import com.lyms.platform.common.enums.YnEnums;
  11 +import com.lyms.platform.common.result.BaseObjectResponse;
  12 +import com.lyms.platform.common.utils.AddressUtil;
10 13 import com.lyms.platform.common.utils.CacheHelper;
11 14 import com.lyms.platform.common.utils.ExceptionUtils;
12 15 import com.lyms.platform.pojo.BasicConfig;
13 16 import com.lyms.platform.query.BasicConfigQuery;
  17 +import org.apache.commons.collections.CollectionUtils;
14 18 import org.apache.commons.lang.StringUtils;
15 19 import org.springframework.beans.factory.InitializingBean;
16 20 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -18,8 +22,7 @@
18 22 import org.springframework.data.domain.Sort.Direction;
19 23 import org.springframework.stereotype.Service;
20 24  
21   -import java.util.Collection;
22   -import java.util.List;
  25 +import java.util.*;
23 26 import java.util.concurrent.TimeUnit;
24 27  
25 28 @Service("basicConfigService")
... ... @@ -87,6 +90,285 @@
87 90 return basicConfigDao.getOneBasicConfigById(key);
88 91 }
89 92 },400,3);
  93 + }
  94 +
  95 + public BaseObjectResponse getAddressItems(String address) {
  96 +
  97 + Map<String, String> map = new HashMap<>();
  98 + System.out.println(address);
  99 + List<String> items = AddressUtil.getAddress(address);
  100 + System.out.println("result = " + items);
  101 +
  102 + BasicConfigQuery regionsQuery = new BasicConfigQuery();
  103 + regionsQuery.setYn(YnEnums.YES.getId());
  104 + if (items != null && items.size() == 4)
  105 + {
  106 + regionsQuery.setOrName(items.get(0));
  107 +
  108 + List<BasicConfig> provinceList = queryBasicConfig(regionsQuery);
  109 + if (CollectionUtils.isNotEmpty(provinceList))
  110 + {
  111 + regionsQuery = new BasicConfigQuery();
  112 + regionsQuery.setParentId(provinceList.get(0).getId());
  113 + map.put("provinceId",provinceList.get(0).getId());
  114 +
  115 + List<BasicConfig> cityList = queryBasicConfig(regionsQuery);
  116 + if (CollectionUtils.isNotEmpty(cityList))
  117 + {
  118 + List<String> cityIds = new ArrayList<>();
  119 + for (BasicConfig basicConfig : cityList)
  120 + {
  121 + cityIds.add(basicConfig.getId());
  122 + }
  123 +
  124 + regionsQuery = new BasicConfigQuery();
  125 + regionsQuery.setOrName(items.get(1));
  126 + regionsQuery.setParentIds(cityIds);
  127 + List<BasicConfig> area = queryBasicConfig(regionsQuery);
  128 + if (CollectionUtils.isNotEmpty(area))
  129 + {
  130 + map.put("cityId",area.get(0).getParentId());
  131 + map.put("areaId",area.get(0).getId());
  132 +
  133 +
  134 + regionsQuery = new BasicConfigQuery();
  135 + regionsQuery.setOrName(items.get(2));
  136 + regionsQuery.setParentId(area.get(0).getId());
  137 +
  138 + List<BasicConfig> street = queryBasicConfig(regionsQuery);
  139 + if (CollectionUtils.isNotEmpty(area))
  140 + {
  141 + map.put("streetId",street.get(0).getId());
  142 + }
  143 +
  144 + }
  145 + }
  146 +
  147 + }
  148 + map.put("address",items.get(items.size()-1));
  149 + }
  150 + else if (items != null && items.size() == 5)
  151 + {
  152 + regionsQuery.setOrName(items.get(0));
  153 +
  154 + List<BasicConfig> provinceList = queryBasicConfig(regionsQuery);
  155 + if (CollectionUtils.isNotEmpty(provinceList))
  156 + {
  157 + map.put("provinceId",provinceList.get(0).getId());
  158 +
  159 + regionsQuery = new BasicConfigQuery();
  160 + regionsQuery.setParentId(provinceList.get(0).getId());
  161 + regionsQuery.setOrName(items.get(1));
  162 +
  163 + List<BasicConfig> cityList = queryBasicConfig(regionsQuery);
  164 + if (CollectionUtils.isNotEmpty(cityList))
  165 + {
  166 + map.put("cityId",cityList.get(0).getId());
  167 +
  168 + regionsQuery = new BasicConfigQuery();
  169 + regionsQuery.setOrName(items.get(2));
  170 + regionsQuery.setParentId(cityList.get(0).getId());
  171 + List<BasicConfig> area = queryBasicConfig(regionsQuery);
  172 + if (CollectionUtils.isNotEmpty(area))
  173 + {
  174 + map.put("areaId",area.get(0).getId());
  175 + regionsQuery = new BasicConfigQuery();
  176 + regionsQuery.setOrName(items.get(3));
  177 + regionsQuery.setParentId(area.get(0).getId());
  178 +
  179 + List<BasicConfig> street = queryBasicConfig(regionsQuery);
  180 + if (CollectionUtils.isNotEmpty(area))
  181 + {
  182 + map.put("streetId",street.get(0).getId());
  183 + }
  184 +
  185 + }
  186 + }
  187 +
  188 + }
  189 + map.put("address",items.get(items.size()-1));
  190 +
  191 + }
  192 +
  193 +
  194 +
  195 +// if (items != null && items.size() >3)
  196 +// {
  197 +// BasicConfigQuery regionsQuery = new BasicConfigQuery();
  198 +// regionsQuery.setName(items.get(items.size()-2));
  199 +// regionsQuery.setYn(YnEnums.YES.getId());
  200 +//
  201 +// List<BasicConfig> list = queryBasicConfig(regionsQuery);
  202 +// boolean isArea = false;
  203 +// if (CollectionUtils.isNotEmpty(list))
  204 +// {
  205 +// for(BasicConfig bc : list)
  206 +// {
  207 +// regionsQuery = new BasicConfigQuery();
  208 +// regionsQuery.setId(bc.getParentId());
  209 +// regionsQuery.setYn(YnEnums.YES.getId());
  210 +// List<BasicConfig> list1 = queryBasicConfig(regionsQuery);
  211 +// if (CollectionUtils.isNotEmpty(list1)) {
  212 +// for (BasicConfig bc1 : list1) {
  213 +// if (bc1.getName().trim().equals(items.get(items.size()-3)) || bc1.getName().trim().equals("抚宁区"))
  214 +// {
  215 +// map.put("streetId",bc.getId());
  216 +// map.put("areaId",bc1.getId());
  217 +// map.put("cityId",bc1.getParentId());
  218 +//
  219 +// regionsQuery = new BasicConfigQuery();
  220 +// regionsQuery.setId(bc1.getParentId());
  221 +// regionsQuery.setYn(YnEnums.YES.getId());
  222 +// List<BasicConfig> list2 = queryBasicConfig(regionsQuery);
  223 +//
  224 +// if (CollectionUtils.isNotEmpty(list2)) {
  225 +// for (BasicConfig bc2 : list2) {
  226 +// if (bc2.getName().trim().equals(items.get(0)))
  227 +// {
  228 +// map.put("provinceId",bc2.getId());
  229 +// break;
  230 +// }
  231 +// }
  232 +// }
  233 +// isArea = true;
  234 +// break;
  235 +// }
  236 +// }
  237 +// }
  238 +// }
  239 +// if (!isArea)
  240 +// {
  241 +// if (items.size() == 5)
  242 +// {
  243 +// regionsQuery = new BasicConfigQuery();
  244 +// regionsQuery.setName(items.get(2));
  245 +// regionsQuery.setYn(YnEnums.YES.getId());
  246 +//
  247 +// list = queryBasicConfig(regionsQuery);
  248 +// //area找到
  249 +// if (CollectionUtils.isNotEmpty(list))
  250 +// {
  251 +// for (BasicConfig bc1 : list) {
  252 +//
  253 +// regionsQuery = new BasicConfigQuery();
  254 +// regionsQuery.setId(bc1.getParentId());
  255 +// regionsQuery.setYn(YnEnums.YES.getId());
  256 +// List<BasicConfig> cityList = queryBasicConfig(regionsQuery);
  257 +//
  258 +// if (CollectionUtils.isNotEmpty(cityList))
  259 +// {
  260 +// for (BasicConfig cl : cityList) {
  261 +// if (cl.getName().trim().equals(items.get(1)))
  262 +// {
  263 +// map.put("cityId",cl.getId());
  264 +// map.put("provinceId",cl.getParentId());
  265 +// break;
  266 +// }
  267 +// }
  268 +// }
  269 +// }
  270 +// }
  271 +// else
  272 +// {
  273 +// regionsQuery = new BasicConfigQuery();
  274 +// regionsQuery.setName(items.get(1));
  275 +// regionsQuery.setYn(YnEnums.YES.getId());
  276 +//
  277 +// list = queryBasicConfig(regionsQuery);
  278 +// //city找到
  279 +// if (CollectionUtils.isNotEmpty(list)) {
  280 +// boolean isFind = false;
  281 +// for (BasicConfig bc1 : list) {
  282 +// if (bc1.getName().trim().equals(items.get(1)))
  283 +// {
  284 +// regionsQuery = new BasicConfigQuery();
  285 +// regionsQuery.setId(bc1.getParentId());
  286 +// regionsQuery.setYn(YnEnums.YES.getId());
  287 +// List<BasicConfig> list2 = queryBasicConfig(regionsQuery);
  288 +//
  289 +// if (CollectionUtils.isNotEmpty(list2)) {
  290 +// for (BasicConfig bc2 : list2) {
  291 +// if (bc2.getName().trim().equals(items.get(0)))
  292 +// {
  293 +// map.put("cityId",bc1.getId());
  294 +// map.put("provinceId",bc2.getId());
  295 +// isFind = true;
  296 +// }
  297 +// }
  298 +// }
  299 +// if (isFind)
  300 +// {
  301 +// break;
  302 +// }
  303 +// }
  304 +// }
  305 +//
  306 +// }
  307 +// }
  308 +// }
  309 +// else if (items.size() == 4)
  310 +// {
  311 +// regionsQuery = new BasicConfigQuery();
  312 +// regionsQuery.setName(items.get(1));
  313 +// regionsQuery.setYn(YnEnums.YES.getId());
  314 +//
  315 +// list = queryBasicConfig(regionsQuery);
  316 +// //area找到
  317 +// if (CollectionUtils.isNotEmpty(list))
  318 +// {
  319 +// boolean isFind = false;
  320 +// for (BasicConfig bc1 : list) {
  321 +// if (bc1.getName().trim().equals(items.get(1)))
  322 +// {
  323 +// regionsQuery = new BasicConfigQuery();
  324 +// regionsQuery.setId(bc1.getParentId());
  325 +// regionsQuery.setYn(YnEnums.YES.getId());
  326 +// List<BasicConfig> list2 = queryBasicConfig(regionsQuery);
  327 +// if (CollectionUtils.isNotEmpty(list2)) {
  328 +// for (BasicConfig bc2 : list2) {
  329 +// if (bc2.getName().trim().equals(items.get(0)))
  330 +// {
  331 +// map.put("areaId",bc1.getId());
  332 +// map.put("cityId",bc1.getParentId());
  333 +// map.put("provinceId",bc2.getId());
  334 +// isFind = true;
  335 +// }
  336 +// }
  337 +// }
  338 +// if (isFind)
  339 +// {
  340 +// break;
  341 +// }
  342 +// }
  343 +// }
  344 +// }
  345 +// else
  346 +// {
  347 +// regionsQuery = new BasicConfigQuery();
  348 +// regionsQuery.setName(items.get(0));
  349 +// regionsQuery.setYn(YnEnums.YES.getId());
  350 +//
  351 +// list = queryBasicConfig(regionsQuery);
  352 +// //province找到
  353 +// if (CollectionUtils.isNotEmpty(list)) {
  354 +// for (BasicConfig bc1 : list) {
  355 +// map.put("provinceId",bc1.getId());
  356 +// break;
  357 +// }
  358 +//
  359 +// }
  360 +// }
  361 +// }
  362 +// }
  363 +// map.put("address",items.get(items.size()-1));
  364 +// }
  365 +// }
  366 +
  367 + BaseObjectResponse objectResponse = new BaseObjectResponse();
  368 + objectResponse.setData(map);
  369 + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  370 + objectResponse.setErrormsg("成功");
  371 + return objectResponse;
90 372 }
91 373 }
platform-common/pom.xml View file @ 04249f1
... ... @@ -11,6 +11,17 @@
11 11 <artifactId>platform-common</artifactId>
12 12 <dependencies>
13 13 <dependency>
  14 + <groupId>org.wltea.analyzer</groupId>
  15 + <artifactId>IKAnalyzer</artifactId>
  16 + <version>2012_u6</version>
  17 + </dependency>
  18 +
  19 + <dependency>
  20 + <groupId>org.apache.lucene</groupId>
  21 + <artifactId>lucene-core</artifactId>
  22 + <version>3.6.0</version>
  23 + </dependency>
  24 + <dependency>
14 25 <groupId>commons-httpclient</groupId>
15 26 <artifactId>commons-httpclient</artifactId>
16 27 </dependency>
platform-common/src/main/java/com/lyms/platform/common/utils/AddressUtil.java View file @ 04249f1
  1 +package com.lyms.platform.common.utils;
  2 +
  3 +import org.apache.commons.lang.StringUtils;
  4 +import org.wltea.analyzer.core.IKSegmenter;
  5 +import org.wltea.analyzer.core.Lexeme;
  6 +
  7 +import java.io.StringReader;
  8 +import java.util.ArrayList;
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * Created by Administrator on 2017-02-09.
  13 + */
  14 +public class AddressUtil {
  15 +
  16 + public static boolean isNumeric(String str) {
  17 + return StringUtils.isNumeric(str);
  18 + }
  19 +
  20 + public static List<String> getAddress(String address) {
  21 + List<String> list = new ArrayList<String>();
  22 + StringReader input = new StringReader(address.trim());
  23 + IKSegmenter ikSeg = new IKSegmenter(input, true); // true 用智能分词
  24 + StringBuffer sb = new StringBuffer(); // ,false细粒度
  25 + try {
  26 + int i = 0;
  27 + for (Lexeme lexeme = ikSeg.next(); lexeme != null; lexeme = ikSeg
  28 + .next()) {
  29 + i++;
  30 + String item = lexeme.getLexemeText();
  31 + if (item != null && !isNumeric(item) && item.length() > 1)
  32 + {
  33 + if (i < 5)
  34 + {
  35 + list.add(item);
  36 + }
  37 + else
  38 + {
  39 + sb.append(item);
  40 + }
  41 +
  42 + }
  43 + else
  44 + {
  45 + sb.append(item);
  46 + }
  47 + }
  48 + } catch (Exception e) {
  49 + ExceptionUtils.catchException(e,"地址解析出错");
  50 + return null;
  51 + }
  52 + list.add(sb.toString());
  53 + return list;
  54 + }
  55 +}
platform-common/src/main/java/com/lyms/platform/common/utils/FileUtil.java View file @ 04249f1
  1 +package com.lyms.platform.common.utils;
  2 +
  3 +import org.apache.commons.io.FileUtils;
  4 +
  5 +import java.io.File;
  6 +import java.io.IOException;
  7 +import java.util.ArrayList;
  8 +import java.util.List;
  9 +import java.util.Map;
  10 +
  11 +/**
  12 + * Created by Administrator on 2017-02-10.
  13 + */
  14 +public class FileUtil {
  15 +
  16 + public static void getFileItem() throws IOException {
  17 + File rootFile = new File("F:\\data_location-gh-pages\\town");
  18 + File[] files = rootFile.listFiles();
  19 + List<String> towns = new ArrayList<>();
  20 + for (File file : files)
  21 + {
  22 + String json = FileUtils.readFileToString(file);
  23 + Map<String,String> maps = JsonUtil.getMap(json);
  24 + for (String key : maps.keySet())
  25 + {
  26 + //towns.add(maps.get(key));
  27 + System.out.println(maps.get(key).trim().equals("街道"));
  28 + }
  29 +
  30 + }
  31 + }
  32 +
  33 + public static void main(String[] args) throws IOException {
  34 + getFileItem();
  35 + }
  36 +}
platform-dal/src/main/java/com/lyms/platform/query/BasicConfigQuery.java View file @ 04249f1
... ... @@ -17,10 +17,12 @@
17 17 private List ids;
18 18  
19 19 private String parentId;
  20 + private List<String> parentIds;
20 21  
21 22 private String code;
22 23  
23 24 private String name;
  25 + private String orName;
24 26  
25 27 private String keyword;
26 28  
27 29  
... ... @@ -54,9 +56,19 @@
54 56 if (null != name) {
55 57 condition = condition.and("name", name, MongoOper.IS);
56 58 }
  59 + if (null != orName) {
  60 + MongoCondition con1= MongoCondition.newInstance("alias", orName, MongoOper.LIKE);
  61 + MongoCondition con = MongoCondition.newInstance("name", orName, MongoOper.IS);
  62 + condition = condition.orCondition(new MongoCondition[]{con1, con});
  63 + }
57 64 if (null != parentId) {
58 65 condition = condition.and("parentId", parentId, MongoOper.IS);
59 66 }
  67 +
  68 + if (null != parentIds) {
  69 + condition = condition.and("parentId", parentIds, MongoOper.IN);
  70 + }
  71 +
60 72 if (null != typeId) {
61 73 condition = condition.and("typeId", typeId, MongoOper.IS);
62 74 }
... ... @@ -72,6 +84,22 @@
72 84 }
73 85  
74 86 return condition.toMongoQuery();
  87 + }
  88 +
  89 + public List<String> getParentIds() {
  90 + return parentIds;
  91 + }
  92 +
  93 + public void setParentIds(List<String> parentIds) {
  94 + this.parentIds = parentIds;
  95 + }
  96 +
  97 + public String getOrName() {
  98 + return orName;
  99 + }
  100 +
  101 + public void setOrName(String orName) {
  102 + this.orName = orName;
75 103 }
76 104  
77 105 public List getIds() {
platform-data-api/src/main/java/com/lyms/platform/data/util/AmsMessageService.java View file @ 04249f1
... ... @@ -183,7 +183,7 @@
183 183  
184 184  
185 185 public static void main(String[] args) {
186   - Map<String,List<MessageContent>> list = getMessageTemplateMap("241",
  186 + Map<String,List<MessageContent>> list = getMessageTemplateMap("248",
187 187 AmsServiceTypeEnum.CHILD_GUIDE);
188 188  
189 189 List<MessageContent> msgs = list.get("高血压");
platform-operate-api/src/main/java/com/lyms/platform/operate/web/Test.java View file @ 04249f1
... ... @@ -28,8 +28,12 @@
28 28 public class Test {
29 29  
30 30 public static void main(String[] args) {
31   - String id="1";
32   - System.out.print(String.format("%07d", id));
  31 +// String id="1";
  32 +// System.out.print(String.format("%07d", id));
  33 +
  34 + String addr="四川省华蓥市双河街道办事处民太村";
  35 +
  36 +
33 37 }
34 38 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RegionController.java View file @ 04249f1
... ... @@ -8,6 +8,7 @@
8 8 import com.lyms.platform.common.constants.ErrorCodeConstants;
9 9 import com.lyms.platform.common.enums.UserTypeEnum;
10 10 import com.lyms.platform.common.enums.YnEnums;
  11 +import com.lyms.platform.common.result.BaseObjectResponse;
11 12 import com.lyms.platform.common.utils.ResultUtils;
12 13 import com.lyms.platform.common.utils.SystemConfig;
13 14 import com.lyms.platform.permission.model.Organization;
14 15  
15 16  
... ... @@ -17,15 +18,20 @@
17 18 import com.lyms.platform.pojo.BasicConfig;
18 19 import com.lyms.platform.query.BasicConfigQuery;
19 20 import org.apache.commons.collections.CollectionUtils;
  21 +import org.apache.commons.io.FileUtils;
20 22 import org.apache.commons.lang.StringUtils;
21 23 import org.springframework.beans.factory.annotation.Autowired;
22 24 import org.springframework.stereotype.Controller;
23 25 import org.springframework.web.bind.annotation.RequestMapping;
24 26 import org.springframework.web.bind.annotation.RequestMethod;
25 27 import org.springframework.web.bind.annotation.RequestParam;
  28 +import org.springframework.web.bind.annotation.ResponseBody;
26 29  
27 30 import javax.servlet.http.HttpServletRequest;
28 31 import javax.servlet.http.HttpServletResponse;
  32 +import java.io.File;
  33 +import java.io.IOException;
  34 +import java.io.UnsupportedEncodingException;
29 35 import java.util.ArrayList;
30 36 import java.util.HashMap;
31 37 import java.util.List;
... ... @@ -43,7 +49,10 @@
43 49 private UsersService usersService;
44 50 @Autowired
45 51 private OrganizationService organizationService;
46   -
  52 + /**
  53 + * mongo 里面省市区的id
  54 + */
  55 + public static final String CHINA_BASIC_ID = "f6c505dd-835a-43d7-b0bb-fdb9eb0b7b31";
47 56 @TokenRequired
48 57 @RequestMapping(value = "/regions",method = RequestMethod.GET)
49 58 public void getRegions(@RequestParam(value = "parentId", required = false) String parentId,
... ... @@ -138,6 +147,60 @@
138 147 }
139 148 }
140 149 ResultUtils.buildSuccessResultAndWrite(httpServletResponse, list);
  150 + }
  151 + @RequestMapping(value = "/getAddress",method = RequestMethod.GET)
  152 + public void getAddress() {
  153 + BasicConfigQuery regionsQuery = new BasicConfigQuery();
  154 + regionsQuery.setParentId(CHINA_BASIC_ID);
  155 + regionsQuery.setYn(YnEnums.YES.getId());
  156 + List<BasicConfig> basicConfigList = basicConfigService.queryBasicConfig(regionsQuery);
  157 + List<String> list = new ArrayList<>();
  158 + for(BasicConfig bc : basicConfigList)
  159 + {
  160 + list.add(bc.getName());
  161 + regionsQuery.setParentId(bc.getId());
  162 + List<BasicConfig> list1 = basicConfigService.queryBasicConfig(regionsQuery);
  163 + for(BasicConfig bc1 : list1)
  164 + {
  165 + list.add(bc1.getName());
  166 +
  167 + regionsQuery.setParentId(bc1.getId());
  168 + List<BasicConfig> list2 = basicConfigService.queryBasicConfig(regionsQuery);
  169 + for(BasicConfig bc2 : list2)
  170 + {
  171 + list.add(bc2.getName());
  172 +
  173 + regionsQuery.setParentId(bc2.getId());
  174 + List<BasicConfig> list3 = basicConfigService.queryBasicConfig(regionsQuery);
  175 + for(BasicConfig bc3 : list3)
  176 + {
  177 + list.add(bc3.getName());
  178 + }
  179 +
  180 + }
  181 +
  182 + }
  183 +
  184 + }
  185 + try {
  186 + FileUtils.writeLines(new File("F:\\ext.dic"), list);
  187 + } catch (IOException e) {
  188 + e.printStackTrace();
  189 + }
  190 +
  191 + }
  192 +
  193 +
  194 + /**
  195 + * 解析身份证地址
  196 + * @param address
  197 + * @return
  198 + */
  199 + @RequestMapping(value = "/getAddressItems", method = RequestMethod.GET)
  200 + @ResponseBody
  201 + public BaseObjectResponse getAddressItems(@RequestParam(required = true)String address) throws UnsupportedEncodingException {
  202 + address = new String(address.getBytes("ISO-8859-1"),"UTF-8");
  203 + return basicConfigService.getAddressItems(address);
141 204 }
142 205 }