Commit 740e46fe6e2be7f152cfeba697b311d568669201
1 parent
361f64034f
Exists in
master
and in
6 other branches
数据接口
Showing 4 changed files with 51 additions and 22 deletions
- platform-common/src/main/java/com/lyms/platform/common/utils/SystemConfig.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AreaCountFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MongoUtil.java
platform-common/src/main/java/com/lyms/platform/common/utils/SystemConfig.java
View file @
740e46f
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
View file @
740e46f
| ... | ... | @@ -8,10 +8,7 @@ |
| 8 | 8 | import com.lyms.platform.biz.service.*; |
| 9 | 9 | import com.lyms.platform.common.enums.SieveStatusEnums; |
| 10 | 10 | import com.lyms.platform.common.enums.YnEnums; |
| 11 | -import com.lyms.platform.common.utils.CompressEncodeingUtil; | |
| 12 | -import com.lyms.platform.common.utils.DateUtil; | |
| 13 | -import com.lyms.platform.common.utils.ExceptionUtils; | |
| 14 | -import com.lyms.platform.common.utils.JsonUtil; | |
| 11 | +import com.lyms.platform.common.utils.*; | |
| 15 | 12 | import com.lyms.platform.operate.web.facade.AntenatalExaminationFacade; |
| 16 | 13 | import com.lyms.platform.operate.web.facade.BabyCheckFacade; |
| 17 | 14 | import com.lyms.platform.operate.web.facade.SieveFacade; |
| ... | ... | @@ -33,6 +30,8 @@ |
| 33 | 30 | import org.springframework.data.authentication.UserCredentials; |
| 34 | 31 | import org.springframework.data.domain.Sort; |
| 35 | 32 | import org.springframework.data.mongodb.core.MongoTemplate; |
| 33 | +import org.springframework.data.mongodb.core.query.Criteria; | |
| 34 | +import org.springframework.data.mongodb.core.query.Query; | |
| 36 | 35 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| 37 | 36 | import org.springframework.stereotype.Controller; |
| 38 | 37 | import org.springframework.web.bind.annotation.RequestMapping; |
| ... | ... | @@ -112,6 +111,22 @@ |
| 112 | 111 | private ThreadPoolTaskExecutor commonThreadPool; |
| 113 | 112 | @Autowired |
| 114 | 113 | private PatientServiceService patientServiceService; |
| 114 | + | |
| 115 | + | |
| 116 | + @RequestMapping("/area") | |
| 117 | + @ResponseBody | |
| 118 | + public Object getArea() { | |
| 119 | + List<BasicConfig> basicConfigs = mongoTemplate.find(Query.query(Criteria.where("typeId").is("b7ea005c-dfac-4c2a-bdae-25239b3f44fd")), BasicConfig.class); | |
| 120 | + List<Map<String, Object>> datas = new ArrayList<>(); | |
| 121 | + for (BasicConfig basicConfig : basicConfigs) { | |
| 122 | + Map<String, Object> temp = new HashMap<>(); | |
| 123 | + temp.put("id", basicConfig.getId()); | |
| 124 | + temp.put("name", basicConfig.getName()); | |
| 125 | + temp.put("pid", basicConfig.getParentId()); | |
| 126 | + datas.add(temp); | |
| 127 | + } | |
| 128 | + return datas; | |
| 129 | + } | |
| 115 | 130 | |
| 116 | 131 | |
| 117 | 132 | /** |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AreaCountFacade.java
View file @
740e46f
| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | import com.lyms.platform.common.utils.StringUtils; |
| 13 | 13 | import com.lyms.platform.operate.web.utils.CommonsHelper; |
| 14 | 14 | import com.lyms.platform.operate.web.utils.FunvCommonUtil; |
| 15 | +import com.lyms.platform.operate.web.utils.MongoUtil; | |
| 15 | 16 | import com.lyms.platform.operate.web.utils.ResponseUtil; |
| 16 | 17 | import com.lyms.platform.operate.web.worker.CheckPointCountWorker; |
| 17 | 18 | import com.lyms.platform.permission.model.Organization; |
| 18 | 19 | |
| ... | ... | @@ -81,7 +82,10 @@ |
| 81 | 82 | @Qualifier("commonThreadPool") |
| 82 | 83 | private ThreadPoolTaskExecutor commonThreadPool; |
| 83 | 84 | |
| 85 | + @Autowired | |
| 86 | + private MongoUtil mongoUtil; | |
| 84 | 87 | |
| 88 | + | |
| 85 | 89 | /** |
| 86 | 90 | * 获取当前用户拥有的医院权限列表并和查询条件取交集 |
| 87 | 91 | * |
| 88 | 92 | |
| 89 | 93 | |
| ... | ... | @@ -871,28 +875,26 @@ |
| 871 | 875 | } |
| 872 | 876 | |
| 873 | 877 | public BaseResponse getAreaId(String provinceName, String cityName, String areaName) { |
| 874 | - BasicConfig province = mongoTemplate.findOne(Query.query(Criteria.where("name").is(provinceName).and("typeId").is("b7ea005c-dfac-4c2a-bdae-25239b3f44fd")), BasicConfig.class); | |
| 875 | - if (province != null) { | |
| 876 | - if(StringUtils.isEmpty(cityName)) { | |
| 877 | - return RespBuilder.buildSuccess(province.getId()); | |
| 878 | - } | |
| 879 | - List<BasicConfig> citys = mongoTemplate.find(Query.query(Criteria.where("parentId").is(province.getId()).and("typeId").is("b7ea005c-dfac-4c2a-bdae-25239b3f44fd")), BasicConfig.class); | |
| 880 | - for (BasicConfig city : citys) { | |
| 881 | - if (cityName.equals(city.getName())) { | |
| 882 | - if (StringUtils.isEmpty(areaName)) { | |
| 883 | - return RespBuilder.buildSuccess(city.getId()); | |
| 884 | - } else { | |
| 885 | - List<BasicConfig> areas = mongoTemplate.find(Query.query(Criteria.where("parentId").is(city.getId()).and("typeId").is("b7ea005c-dfac-4c2a-bdae-25239b3f44fd")), BasicConfig.class); | |
| 886 | - for (BasicConfig area : areas) { | |
| 887 | - if (areaName.equals(area.getName())) { | |
| 888 | - return RespBuilder.buildSuccess(area.getId()); | |
| 889 | - } | |
| 890 | - } | |
| 878 | + List<BasicConfig> basicConfigs = mongoTemplate.find(Query.query(Criteria.where("name").regex(provinceName).and("typeId").is(SystemConfig.CHINA_TYPE_ID).and("parentId").is(SystemConfig.CHINA_BASIC_ID).and("yn").ne(0)), BasicConfig.class); | |
| 879 | + List<Map<String, Object>> restList = new ArrayList<>(); | |
| 880 | + List<String> parentIds = new ArrayList<>(); | |
| 881 | + if (CollectionUtils.isNotEmpty(basicConfigs)) { | |
| 882 | + if(StringUtils.isNotEmpty(cityName)) { | |
| 883 | + for (BasicConfig config : basicConfigs) { | |
| 884 | + parentIds.add(config.getId()); | |
| 885 | + } | |
| 886 | + basicConfigs = mongoTemplate.find(Query.query(Criteria.where("name").regex(cityName).and("typeId").is(SystemConfig.CHINA_TYPE_ID).and("parentId").in(parentIds).and("yn").ne(0)), BasicConfig.class); | |
| 887 | + if(StringUtils.isNotEmpty(areaName)) { | |
| 888 | + parentIds.clear(); | |
| 889 | + for (BasicConfig config : basicConfigs) { | |
| 890 | + parentIds.add(config.getId()); | |
| 891 | 891 | } |
| 892 | + basicConfigs = mongoTemplate.find(Query.query(Criteria.where("name").regex(areaName).and("typeId").is(SystemConfig.CHINA_TYPE_ID).and("parentId").in(parentIds).and("yn").ne(0)), BasicConfig.class); | |
| 892 | 893 | } |
| 893 | 894 | } |
| 894 | 895 | } |
| 895 | - return RespBuilder.buildSuccess("not found"); | |
| 896 | + mongoUtil.setIdNames(basicConfigs, restList); | |
| 897 | + return RespBuilder.buildSuccess(restList); | |
| 896 | 898 | } |
| 897 | 899 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MongoUtil.java
View file @
740e46f
| ... | ... | @@ -51,6 +51,15 @@ |
| 51 | 51 | @Autowired |
| 52 | 52 | private CouponMapper couponMapper; |
| 53 | 53 | |
| 54 | + public void setIdNames(List<BasicConfig> basicConfigs, List<Map<String, Object>> restList) { | |
| 55 | + for (BasicConfig config : basicConfigs) { | |
| 56 | + Map<String, Object> temp = new HashMap<>(); | |
| 57 | + temp.put("id", config.getId()); | |
| 58 | + temp.put("name", config.getName()); | |
| 59 | + restList.add(temp); | |
| 60 | + } | |
| 61 | + } | |
| 62 | + | |
| 54 | 63 | public List<Map<String, Object>> getChilds(String parentId,String childId) { |
| 55 | 64 | List<Map<String, Object>> childList = new ArrayList<>(); |
| 56 | 65 |