Commit ee0c33c42f5843e7d178feffa490846b1fd620ed
1 parent
163db800be
Exists in
master
and in
6 other branches
美生县医院系统数据分析报告-2.3.2.二级漏检提醒,3
Showing 1 changed file with 57 additions and 1 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
ee0c33c
... | ... | @@ -5120,7 +5120,63 @@ |
5120 | 5120 | public BaseResponse getAreaFinallyOverdue(String hospitalId, String areaId,Date startDate, Date endDate) { |
5121 | 5121 | BaseResponse br = new BaseResponse(); |
5122 | 5122 | List <Map <String, Object>> mapList=new ArrayList<>(); |
5123 | - | |
5123 | + String name1 = CommonsHelper.getName1(areaId, basicConfigService); | |
5124 | + Criteria criteria = Criteria.where("bookbuildingDate") | |
5125 | + .gte(startDate).lte(endDate) | |
5126 | + .and("areaRegisterId").is(areaId) | |
5127 | + .and("type").is(1) | |
5128 | + .and("hospitalId").is(hospitalId) | |
5129 | + .and("yn").is(1); | |
5130 | + AggregationOperation match = Aggregation.match(criteria); | |
5131 | + AggregationOperation group = Aggregation.group("streetRegisterId").count().as("count"); | |
5132 | + Aggregation aggregation= Aggregation.newAggregation(match, group); | |
5133 | + AggregationResults<HashMap> result = mongoTemplate.aggregate(aggregation,"lyms_patient", HashMap.class); | |
5134 | + long overduetotal=0;//逾期合计 | |
5135 | + long finallytotal=0;//建档合计 | |
5136 | + for (HashMap mappedResult : result.getMappedResults()) { | |
5137 | + Map <String, Object> map=new HashMap<>(); | |
5138 | + if (null!=mappedResult.get("_id")) { | |
5139 | + //地区名称 | |
5140 | + String streetName = CommonsHelper.getName1(mappedResult.get("_id").toString(), basicConfigService); | |
5141 | + map.put("name", streetName); | |
5142 | + Criteria criteria2 = Criteria.where("bookbuildingDate") | |
5143 | + .gte(startDate).lte(endDate) | |
5144 | + .and("areaRegisterId").is(areaId) | |
5145 | + .and("streetRegisterId").is(mappedResult.get("_id")) | |
5146 | + .and("type").is(1) | |
5147 | + .and("hospitalId").is(hospitalId) | |
5148 | + .and("yn").is(1) | |
5149 | + .and("nextCheckTime").lt(new Date()); | |
5150 | + //逾期人数 | |
5151 | + long count = mongoTemplate.count(Query.query(criteria2), Patients.class); | |
5152 | + map.put("overdueCount", count); | |
5153 | + map.put("finallyCount", mappedResult.get("count")); | |
5154 | + //比值(产检逾期人数/建档人数) | |
5155 | + String ratio="0%"; | |
5156 | + if(0!=(int)mappedResult.get("count")) { | |
5157 | + double percent = (double) count / (int)mappedResult.get("count"); | |
5158 | + DecimalFormat format = new DecimalFormat("0.00%"); | |
5159 | + ratio = format.format(percent); | |
5160 | + } | |
5161 | + map.put("ratio", ratio); | |
5162 | + overduetotal+=count; | |
5163 | + finallytotal+=(int)mappedResult.get("count"); | |
5164 | + mapList.add(map); | |
5165 | + } | |
5166 | + } | |
5167 | + Map<String, Object> totalMap=new HashedMap(); | |
5168 | + totalMap.put("name","合计(逾期未检)"); | |
5169 | + totalMap.put("overdueCount",overduetotal); | |
5170 | + totalMap.put("finallyCount",finallytotal); | |
5171 | + //比值(产检逾期人数/建档人数) | |
5172 | + String ratio="0%"; | |
5173 | + if(0!=finallytotal) { | |
5174 | + double percent = (double) overduetotal / finallytotal; | |
5175 | + DecimalFormat format = new DecimalFormat("0.00%"); | |
5176 | + ratio = format.format(percent); | |
5177 | + } | |
5178 | + totalMap.put("ratio", ratio); | |
5179 | + mapList.add(totalMap); | |
5124 | 5180 | |
5125 | 5181 | br.setErrorcode(ErrorCodeConstants.SUCCESS); |
5126 | 5182 | br.setErrormsg("成功"); |