Commit d3417c8de69f3cb7e88d63607631aa69a1800e57

Authored by litao@lymsh.com
1 parent a8b01ad127

写bug

Showing 5 changed files with 82 additions and 4 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AreaCountController.java View file @ d3417c8
... ... @@ -30,6 +30,12 @@
30 30 return areaCountFacade.getAreaChilds(provinceName, cityName, areaName);
31 31 }
32 32  
  33 + @RequestMapping(value = "/get/area/id", method = RequestMethod.GET)
  34 + @ResponseBody
  35 + public BaseResponse getAreaId(@RequestParam String provinceName, @RequestParam String cityName, String areaName) {
  36 + return areaCountFacade.getAreaId(provinceName, cityName, areaName);
  37 + }
  38 +
33 39 /**
34 40 * 产检节点统计
35 41 * @param request
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java View file @ d3417c8
... ... @@ -54,12 +54,12 @@
54 54 * @return
55 55 */
56 56 @ResponseBody
57   -// @TokenRequired
  57 + @TokenRequired
58 58 @RequestMapping(value = "/patients/export", method = RequestMethod.GET)
59 59 public void patientsExport(String provinceId, String cityId, String aredId, String streetId, @RequestParam Integer statistType,
60 60 Integer ageType, Integer patientType, Date startDate, Date endDate, HttpServletRequest request, HttpServletResponse response) {
61   -// reportService.patientsExport(provinceId, cityId, aredId, streetId, statistType, ageType, patientType, startDate, endDate, getUserId(request), response);
62   - reportService.patientsExport(provinceId, cityId, aredId, streetId, statistType, ageType, patientType, startDate, endDate, 1000000185, response);
  61 + reportService.patientsExport(provinceId, cityId, aredId, streetId, statistType, ageType, patientType, startDate, endDate, getUserId(request), response);
  62 +// reportService.patientsExport(provinceId, cityId, aredId, streetId, statistType, ageType, patientType, startDate, endDate, 1000000185, response);
63 63 }
64 64  
65 65  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AreaCountFacade.java View file @ d3417c8
... ... @@ -870,5 +870,26 @@
870 870 return RespBuilder.buildSuccess(childs);
871 871 }
872 872  
  873 + 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 + List<BasicConfig> citys = mongoTemplate.find(Query.query(Criteria.where("parentId").is(province.getId()).and("typeId").is("b7ea005c-dfac-4c2a-bdae-25239b3f44fd")), BasicConfig.class);
  877 + for (BasicConfig city : citys) {
  878 + if (cityName.equals(city.getName())) {
  879 + if (StringUtils.isEmpty(areaName)) {
  880 + return RespBuilder.buildSuccess(city.getId());
  881 + } else {
  882 + List<BasicConfig> areas = mongoTemplate.find(Query.query(Criteria.where("parentId").is(city.getId()).and("typeId").is("b7ea005c-dfac-4c2a-bdae-25239b3f44fd")), BasicConfig.class);
  883 + for (BasicConfig area : areas) {
  884 + if (areaName.equals(area.getName())) {
  885 + return RespBuilder.buildSuccess(area.getId());
  886 + }
  887 + }
  888 + }
  889 + }
  890 + }
  891 + }
  892 + return RespBuilder.buildSuccess("not found");
  893 + }
873 894 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java View file @ d3417c8
... ... @@ -27,6 +27,9 @@
27 27 import org.springframework.beans.factory.annotation.Autowired;
28 28 import org.springframework.data.domain.Sort;
29 29 import org.springframework.data.mongodb.core.MongoTemplate;
  30 +import org.springframework.data.mongodb.core.aggregation.Aggregation;
  31 +import org.springframework.data.mongodb.core.aggregation.AggregationResults;
  32 +import org.springframework.data.mongodb.core.aggregation.GroupOperation;
30 33 import org.springframework.data.mongodb.core.query.Criteria;
31 34 import org.springframework.data.mongodb.core.query.Query;
32 35 import org.springframework.stereotype.Service;
... ... @@ -190,7 +193,40 @@
190 193 public BaseObjectResponse patients(String provinceId, String cityId, String aredId, String streetId,
191 194 Integer statistType, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId) {
192 195 List<Patients> patients = getPatients(provinceId, cityId, aredId, streetId, ageType, patientType, startDate, endDate, userId);
193   - return null;
  196 + Map<String, Object> restMap = new HashMap<>();
  197 + List<String> xDatas = new ArrayList<>();
  198 + List<Map<String, Object>> series = new ArrayList<>();
  199 + List<String> legend = Arrays.asList("建档总数");
  200 +
  201 + List<String> patientIds = new ArrayList<>();
  202 + for (Patients patient : patients) {
  203 + patientIds.add(patient.getId());
  204 + }
  205 +
  206 + GroupOperation groupOperation = Aggregation.group("hospitalId").count().as("count");
  207 + Aggregation agg = Aggregation.newAggregation(Patients.class, Aggregation.match(Criteria.where("id").in(patientIds)), groupOperation);
  208 + AggregationResults<Map> results = mongoTemplate.aggregate(agg, Patients.class, Map.class);
  209 + List<Map> mappedResults = results.getMappedResults();
  210 +
  211 + List<Object> bar = new ArrayList<>();
  212 + List<Object> port = new ArrayList<>();
  213 + Map<String, Object> barMap = new HashMap<>();
  214 + barMap.put("data", new ArrayList<>());
  215 + Map<String, Object> portMap = new HashMap<>();
  216 + portMap.put("data", new ArrayList<>());
  217 + for (Map mappedResult : mappedResults) {
  218 + xDatas.add(couponMapper.findHospitalNameById((String) mappedResult.get("_id")));
  219 + bar.add(mappedResult.get("count"));
  220 + }
  221 + barMap.put("data", bar);
  222 + barMap.put("type", "bar");
  223 + barMap.put("name", "建档总数");
  224 + series.add(barMap);
  225 +
  226 + restMap.put("legend", legend);
  227 + restMap.put("series", series);
  228 + restMap.put("xDatas", xDatas);
  229 + return RespBuilder.buildSuccess(restMap);
194 230 }
195 231  
196 232 @Override
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MongoUtil.java View file @ d3417c8
... ... @@ -51,6 +51,21 @@
51 51 @Autowired
52 52 private CouponMapper couponMapper;
53 53  
  54 + public List<Map<String, Object>> getChilds(String id) {
  55 + List<Map<String, Object>> childList = new ArrayList<>();
  56 + BasicConfig basicConfig = mongoTemplate.findById(id, BasicConfig.class);
  57 + if(basicConfig != null) {
  58 + List<BasicConfig> childs = mongoTemplate.find(Query.query(Criteria.where("parentId").is(basicConfig.getId()).and("typeId").is("b7ea005c-dfac-4c2a-bdae-25239b3f44fd")), BasicConfig.class);
  59 + for (BasicConfig child : childs) {
  60 + Map<String, Object> temp = new HashMap<>();
  61 + temp.put("id", child.getId());
  62 + temp.put("name", child.getName());
  63 + childList.add(temp);
  64 + }
  65 + }
  66 + return childList;
  67 + }
  68 +
54 69 public List<Map<String, Object>> getHospitals(Integer userId, String provinceId, String cityId, String areaId, String streetId) {
55 70 List<String> hospitalIds = accessPermissionFacade.getCurrentUserHospPermissions(userId);
56 71 List<Map<String, Object>> hospitals= couponMapper.findHospitalInfoByIds2(CollectionUtils.createMap("list", hospitalIds, "provinceId", provinceId, "cityId", cityId, "areaId", areaId, "streetId", streetId));