Commit 9321e796ab672c4f92769e3941070712e38af0e3
1 parent
4ef9279e39
Exists in
master
and in
7 other branches
分娩作废产检劵
Showing 4 changed files with 78 additions and 23 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/AntExRecordDaoImpl.java
- platform-dal/src/main/java/com/lyms/platform/query/AntExRecordQuery.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntExRecordFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/CjStatisticsResult.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/AntExRecordDaoImpl.java
View file @
9321e79
... | ... | @@ -5,21 +5,17 @@ |
5 | 5 | import com.lyms.platform.common.dao.operator.MongoCondition; |
6 | 6 | import com.lyms.platform.common.dao.operator.MongoOper; |
7 | 7 | import com.lyms.platform.common.dao.operator.MongoQuery; |
8 | -import com.lyms.platform.common.utils.StringUtils; | |
9 | 8 | import com.lyms.platform.pojo.AntExRecordModel; |
10 | -import com.lyms.platform.pojo.BabyCheckModel; | |
11 | -import com.lyms.platform.query.AntExRecordQuery; | |
12 | 9 | import com.mongodb.DBCollection; |
13 | 10 | import com.mongodb.DBObject; |
14 | 11 | import com.mongodb.MapReduceCommand; |
15 | 12 | import com.mongodb.MapReduceOutput; |
16 | -import org.springframework.data.mongodb.core.aggregation.Aggregation; | |
17 | -import org.springframework.data.mongodb.core.aggregation.AggregationOperation; | |
18 | -import org.springframework.data.mongodb.core.aggregation.AggregationResults; | |
19 | -import org.springframework.data.mongodb.core.query.Criteria; | |
20 | 13 | import org.springframework.stereotype.Repository; |
21 | 14 | |
22 | -import java.util.*; | |
15 | +import java.util.ArrayList; | |
16 | +import java.util.Date; | |
17 | +import java.util.HashMap; | |
18 | +import java.util.List; | |
23 | 19 | |
24 | 20 | /** |
25 | 21 | * 产检管理接口 |
... | ... | @@ -41,7 +37,7 @@ |
41 | 37 | * @return |
42 | 38 | */ |
43 | 39 | public List<HashMap> aggregateOne(MongoQuery mongoQuery){ |
44 | - AggregationOperation match = Aggregation.match(/*Criteria.where("hospitalId").is(hospitalId)*/mongoQuery.getCriteria()); | |
40 | + /*AggregationOperation match = Aggregation.match(*//*Criteria.where("hospitalId").is(hospitalId)*//*mongoQuery.getCriteria()); | |
45 | 41 | |
46 | 42 | String[] str= new String[]{"checkDoctor","pid"}; |
47 | 43 | AggregationOperation group = Aggregation.group(str).count().as("count"); |
... | ... | @@ -49,7 +45,48 @@ |
49 | 45 | Aggregation aggregation= Aggregation.newAggregation(match, group); |
50 | 46 | |
51 | 47 | AggregationResults<HashMap> result = mongoTemplate.aggregate(aggregation,"lyms_antexrecord", HashMap.class); |
52 | - return result.getMappedResults(); | |
48 | + return result.getMappedResults();*/ | |
49 | + | |
50 | + | |
51 | + String map = "function() {\n" + | |
52 | + "\t\temit({checkDoctor:this.checkDoctor}, \n" + | |
53 | + "\t\t{\"data\":[{\"pid\":this.pid}]});\n" + | |
54 | + "\t}"; | |
55 | + String reduce = "function(key, value) {\n" + | |
56 | + "\t\tvar ret = {data:[]};\n" + | |
57 | + "\t\tvar srctermid = {};\n" + | |
58 | + "\t\tfor(var i in value) {\n" + | |
59 | + "\t\t\tvar ia = value[i];\n" + | |
60 | + "\t\t\tfor(var j in ia.data) {\n" + | |
61 | + "\t\t\t\tif(!srctermid[ia.data[j].pid]) {\n" + | |
62 | + "\t\t\t\t\tsrctermid[ia.data[j].pid] = true;\n" + | |
63 | + "\t\t\t\t\tret.data.push(ia.data[j]);\n" + | |
64 | + "\t\t\t\t}\n" + | |
65 | + "\t\t\t}\n" + | |
66 | + "\t\t}\n" + | |
67 | + " return ret;\n" + | |
68 | + "\t}"; | |
69 | + DBCollection collections =this.mongoTemplate.getCollection("lyms_antexrecord"); | |
70 | + MapReduceCommand cmd = new MapReduceCommand(collections, map, reduce, | |
71 | + null, MapReduceCommand.OutputType.INLINE, mongoQuery.convertToMongoQuery().getQueryObject()); | |
72 | + cmd.setFinalize("function(key, values){\n" + | |
73 | + "\t\treturn {count:values.data.length};\n" + | |
74 | + "\t}"); | |
75 | + MapReduceOutput out = collections.mapReduce(cmd); | |
76 | + | |
77 | + List<HashMap> ids = new ArrayList<>(); | |
78 | + | |
79 | + for (DBObject o : out.results()) { | |
80 | + if (o != null && o.get("_id") != null) | |
81 | + { | |
82 | + HashMap map1 =new HashMap<>(); | |
83 | + map1.put("checkDoctor", ((DBObject)o.get("_id")).get("checkDoctor")); | |
84 | + | |
85 | + map1.put("count", (int)Double.parseDouble(((DBObject)o.get("value")).get("count").toString())); | |
86 | + ids.add(map1); | |
87 | + } | |
88 | + } | |
89 | + return ids; | |
53 | 90 | } |
54 | 91 | |
55 | 92 | public void batchAddRecord(List<AntExRecordModel> list){ |
platform-dal/src/main/java/com/lyms/platform/query/AntExRecordQuery.java
View file @
9321e79
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | import com.lyms.platform.common.dao.operator.MongoOper; |
7 | 7 | import com.lyms.platform.common.dao.operator.MongoQuery; |
8 | 8 | import com.lyms.platform.common.utils.StringUtils; |
9 | +import com.sun.org.apache.xpath.internal.operations.Bool; | |
9 | 10 | import org.springframework.data.mongodb.core.query.Criteria; |
10 | 11 | |
11 | 12 | import java.util.Date; |
... | ... | @@ -23,6 +24,8 @@ |
23 | 24 | private String phone; |
24 | 25 | private String barCode; |
25 | 26 | |
27 | + private Boolean NeNullCheckDoctor; | |
28 | + | |
26 | 29 | /** |
27 | 30 | * 末次月经 |
28 | 31 | */ |
... | ... | @@ -67,6 +70,14 @@ |
67 | 70 | private String cityId; |
68 | 71 | private String areaId; |
69 | 72 | |
73 | + public boolean isNeNullCheckDoctor() { | |
74 | + return NeNullCheckDoctor; | |
75 | + } | |
76 | + | |
77 | + public void setNeNullCheckDoctor(boolean neNullCheckDoctor) { | |
78 | + NeNullCheckDoctor = neNullCheckDoctor; | |
79 | + } | |
80 | + | |
70 | 81 | public String getProvinceRegisterId() { |
71 | 82 | return provinceRegisterId; |
72 | 83 | } |
... | ... | @@ -357,6 +368,10 @@ |
357 | 368 | if (null != name) { |
358 | 369 | condition = condition.and("name", name, MongoOper.IS); |
359 | 370 | } |
371 | + if (null != NeNullCheckDoctor) { | |
372 | + condition = condition.and("checkDoctor", null, MongoOper.NE); | |
373 | + } | |
374 | + | |
360 | 375 | if (StringUtils.isNotEmpty(levelId)) { |
361 | 376 | condition = condition.and("hLevel", levelId, MongoOper.IN); |
362 | 377 | } |
363 | 378 | |
364 | 379 | |
365 | 380 | |
366 | 381 | |
... | ... | @@ -377,20 +392,20 @@ |
377 | 392 | if (StringUtils.isNotEmpty(areaId)) { |
378 | 393 | condition = condition.and("areaId", areaId, MongoOper.IS); |
379 | 394 | } |
380 | - if(StringUtils.isNotEmpty(cityId)){ | |
395 | + if (StringUtils.isNotEmpty(cityId)) { | |
381 | 396 | condition = condition.and("cityId", cityId, MongoOper.IS); |
382 | 397 | } |
383 | - if(StringUtils.isNotEmpty(provinceId)){ | |
398 | + if (StringUtils.isNotEmpty(provinceId)) { | |
384 | 399 | condition = condition.and("provinceId", provinceId, MongoOper.IS); |
385 | 400 | } |
386 | 401 | //户籍地 |
387 | - if(StringUtils.isNotEmpty(provinceRegisterId)){ | |
402 | + if (StringUtils.isNotEmpty(provinceRegisterId)) { | |
388 | 403 | condition = condition.and("provinceRegisterId", provinceRegisterId, MongoOper.IS); |
389 | 404 | } |
390 | - if(StringUtils.isNotEmpty(cityRegisterId)){ | |
405 | + if (StringUtils.isNotEmpty(cityRegisterId)) { | |
391 | 406 | condition = condition.and("cityRegisterId", cityRegisterId, MongoOper.IS); |
392 | 407 | } |
393 | - if(StringUtils.isNotEmpty(areaRegisterId)){ | |
408 | + if (StringUtils.isNotEmpty(areaRegisterId)) { | |
394 | 409 | condition = condition.and("areaRegisterId", areaRegisterId, MongoOper.IS); |
395 | 410 | } |
396 | 411 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntExRecordFacade.java
View file @
9321e79
... | ... | @@ -418,7 +418,7 @@ |
418 | 418 | } |
419 | 419 | } else { |
420 | 420 | // List<HashMap> list = patientsService.aggregateOne(patientsQuery1); |
421 | - | |
421 | + antExRecordQuery.setNeNullCheckDoctor(true); | |
422 | 422 | List<HashMap> list = recordService.aggregateOne(antExRecordQuery); |
423 | 423 | for (HashMap map : list) { |
424 | 424 | CjStatisticsResult cjStatisticsResult = new CjStatisticsResult(); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/CjStatisticsResult.java
View file @
9321e79
... | ... | @@ -5,7 +5,6 @@ |
5 | 5 | import java.util.Comparator; |
6 | 6 | |
7 | 7 | /** |
8 | - * | |
9 | 8 | * 产检统计 |
10 | 9 | * Created by Administrator on 2016/11/28 0028. |
11 | 10 | */ |
... | ... | @@ -32,7 +31,7 @@ |
32 | 31 | |
33 | 32 | public String getCount() { |
34 | 33 | |
35 | - if(null==count){ | |
34 | + if (null == count) { | |
36 | 35 | return "0"; |
37 | 36 | } |
38 | 37 | return count; |
... | ... | @@ -44,11 +43,15 @@ |
44 | 43 | |
45 | 44 | @Override |
46 | 45 | public int compare(CjStatisticsResult o1, CjStatisticsResult o2) { |
47 | - if (o1 != null && o2 != null) | |
48 | - { | |
49 | - if (StringUtils.isNotEmpty(o2.getCount()) && StringUtils.isNotEmpty(o1.getCount())) | |
50 | - { | |
51 | - return Integer.parseInt(o2.getCount()) - Integer.parseInt(o1.getCount()); | |
46 | + if (o1 != null && o2 != null) { | |
47 | + if (StringUtils.isNotEmpty(o2.getCount()) && StringUtils.isNotEmpty(o1.getCount())) { | |
48 | + double o1d = Double.parseDouble(o2.getCount()); | |
49 | + double o2d = Double.parseDouble(o1.getCount()); | |
50 | + if (o1d > o2d) { | |
51 | + return 1; | |
52 | + } else if (o1d < o2d) { | |
53 | + return -1; | |
54 | + } | |
52 | 55 | } |
53 | 56 | } |
54 | 57 | return 0; |