Commit 4b4154cfc9ce19669796d3cf2221da4fe4192b0b

Authored by yangfei

Merge remote-tracking branch 'origin/master'

Showing 2 changed files

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java View file @ 4b4154c
... ... @@ -40,7 +40,7 @@
40 40 * @param childBirth 统计范围 1=孕妇 3=产妇 不传=全部
41 41 * @return
42 42 */
43   - @RequestMapping(method = RequestMethod.GET, value = "/getCheckStatistics")
  43 +// @RequestMapping(method = RequestMethod.GET, value = "/getCheckStatistics")
44 44 @ResponseBody
45 45 @TokenRequired
46 46 @Deprecated
... ... @@ -61,7 +61,8 @@
61 61 * @param childBirth 统计范围 1=孕妇 3=产妇 不传=全部
62 62 * @return
63 63 */
64   - @RequestMapping(method = RequestMethod.GET, value = "/getCheckNumber")
  64 +// @RequestMapping(method = RequestMethod.GET, value = "/getCheckNumber")
  65 + @RequestMapping(method = RequestMethod.GET, value = "/getCheckStatistics")
65 66 @ResponseBody
66 67 @TokenRequired
67 68 public BaseObjectResponse getCheckNumber(Date startDate, Date endDate,
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java View file @ 4b4154c
... ... @@ -1165,11 +1165,14 @@
1165 1165 criteria.and("bookbuildingDate").gte(startDate).lt(DateUtil.addDay(endDate, 1));
1166 1166 }
1167 1167 if(startWeek != null && endWeek != null) { /** 末次月经 到 现在相隔的周数 */
1168   - criteria.and("lastMenses").lte(DateUtil.getWeekDay(startWeek))
1169   - .gte(DateUtil.getWeekDay(-startWeek));
  1168 + criteria.and("lastMenses").lte(DateUtil.getWeekDay(startWeek)).gte(DateUtil.getWeekDay(-endWeek));
1170 1169 }
  1170 + if(childBirth != null) {
  1171 + criteria.and("type").is(childBirth);
  1172 + }
1171 1173 List<Patients> patients = mongoUtil.findField(Patients.class, criteria,"id", "bookbuildingDate", "fmDate", "pid");
1172 1174 List<String> patientIds = CollectionUtils.getId(patients, "id", String.class);
  1175 + Map<String, Object> restMap = new HashMap<>();
1173 1176 if(CollectionUtils.isNotEmpty(patientIds)) {
1174 1177 /** 初诊数据 */
1175 1178 Criteria c = Criteria.where("hospitalId").is(hid).and("parentId").in(patientIds);
1176 1179  
1177 1180  
... ... @@ -1182,27 +1185,17 @@
1182 1185 doMerge(datas, antExChuModels, antExModels, patients);
1183 1186  
1184 1187 /** 拼装好产检次数 */
1185   - List<Map<String, Object>> grid = getCheckNumerGrid(datas);
  1188 + List<Object> yData = new ArrayList<>();
  1189 + List<Map<String, Object>> grid = getCheckNumerGrid(datas, yData);
  1190 + restMap.put("grid", grid);
  1191 + restMap.put("xAxis", Arrays.asList("1次", "2次", "3次", "4次", "5次", "6次", "7次", "8次", "9次", "10次", "11次", "12次", "≥13次"));
  1192 + restMap.put("yAxis", yData);
  1193 + rest.setData(restMap);
1186 1194 }
1187   -
1188   -// List<AntExChuModel> antExChuModels = mongoTemplate.find(antexcQuery, AntExChuModel.class);
1189   -
1190   -// mongoUtil.findField(AntExChuModel.class, antexcQuery, "");
1191   -
1192   - /*Map<String, Object> restMap = new HashMap<>();
1193   - List<Object> params = new ArrayList<>();
1194   - String hospitalId = autoMatchFacade.getHospitalId(userId);
1195   - List<Map<String, Object>> mapList = reportDao.findList(getAreaCountFacadeSql(startDate, endDate, startWeek, endWeek, childBirth, hospitalId, params), params);
1196   - List<Object> peopleList = createPeoples(mapList);
1197   - restMap.put("grid", createGrid( createPeoples(mapList), createProportion(peopleList)));
1198   - restMap.put("xAxis", Arrays.asList("1次", "2次", "3次", "4次", "5次", "6次", "7次", "8次", "9次", "10次", "11次", "12次", "≥13次")); *//** x轴数据 *//*
1199   - restMap.put("yAxis", createYData(peopleList));
1200   -
1201   - rest.setData(restMap);*/
1202 1195 return rest;
1203 1196 }
1204 1197  
1205   - private List<Map<String,Object>> getCheckNumerGrid(List<Map<String, Object>> datas) {
  1198 + private List<Map<String,Object>> getCheckNumerGrid(List<Map<String, Object>> datas, List<Object> yData) {
1206 1199 /** key = pid, value = 初诊复诊记录 */
1207 1200 Map<String, List<Map<String, Object>>> userCheckInfo = new HashMap<>();
1208 1201 for (Map<String, Object> data : datas) {
... ... @@ -1216,7 +1209,6 @@
1216 1209 userCheckInfo.put(patientId, maps);
1217 1210 }
1218 1211 }
1219   - System.out.println("===========");
1220 1212 Map<Integer, Integer> countMap = new HashMap<>();
1221 1213 for (int i = 1; i < 14; i++) {
1222 1214 countMap.put(i, 0);
... ... @@ -1231,7 +1223,6 @@
1231 1223 /** key=pid value=count */
1232 1224 Map<Date, Integer> tempMap = new HashMap<>();
1233 1225 Integer other = 0;
1234   - Date otherDate = new Date();
1235 1226 for (Map<String, Object> map : value) {
1236 1227 Date fmDate = (Date) map.get("fmDate");
1237 1228 if(fmDate == null) {
1238 1229  
1239 1230  
1240 1231  
1241 1232  
... ... @@ -1244,16 +1235,73 @@
1244 1235 tempMap.put(fmDate, 1);
1245 1236 }
1246 1237 }
1247   - tempMap.put(otherDate, other);
1248   - System.out.println(">>> " + tempMap + " >>" + other);
  1238 + if(other != 0) { /** 处理大于或等于13次 没有分娩时间的数据 */
  1239 + if(other >= 13) {
  1240 + countMap.put(13, countMap.get(13) + 1);
  1241 + } else {
  1242 + countMap.put(other, countMap.get(other) + 1);
  1243 + }
  1244 + }
  1245 +
  1246 + Set<Map.Entry<Date, Integer>> entries1 = tempMap.entrySet();
  1247 + for (Map.Entry<Date, Integer> en : entries1) {
  1248 + Integer v = en.getValue();
  1249 + if(v >= 13) {
  1250 + countMap.put(13, countMap.get(13) + 1);
  1251 + } else {
  1252 + countMap.put(v, countMap.get(v) + 1);
  1253 + }
  1254 +
  1255 + }
1249 1256 }
1250 1257 }
  1258 + /** 处理总数 */
  1259 + Integer count = 0;
  1260 + for (int i = 1; i < 14; i++) {
  1261 + count += countMap.get(i);
  1262 + }
  1263 + countMap.put(0, count);
1251 1264  
1252 1265 List<Map<String,Object>> restList = new ArrayList<>();
1253 1266 Map<String, Object> peoples = new LinkedHashMap<>();
1254   - peoples.put("desc", "产检人数");
  1267 + peoples.put("desc", "产检人数"); /** 产检人数 */
  1268 + peoples.put("count", countMap.get(0));/** 总计 */
  1269 + peoples.put("once", countMap.get(1));
  1270 + peoples.put("twice", countMap.get(2));
  1271 + peoples.put("threeTimes", countMap.get(3));
  1272 + peoples.put("fourTimes", countMap.get(4));
  1273 + peoples.put("fiveTimes", countMap.get(5));
  1274 + peoples.put("sixTimes", countMap.get(6));
  1275 + peoples.put("sevenTimes", countMap.get(7));
  1276 + peoples.put("eightTimes", countMap.get(8));
  1277 + peoples.put("nineTimes", countMap.get(9));
  1278 + peoples.put("tenTimes", countMap.get(10));
  1279 + peoples.put("elevenTimes", countMap.get(11));
  1280 + peoples.put("twelveTimes", countMap.get(12));
  1281 + peoples.put("otherTimes", countMap.get(13));
  1282 + restList.add(peoples);
1255 1283  
  1284 + Map<String, Object> proportion = new LinkedHashMap<>();
  1285 + proportion.put("desc", "占比"); /** 占比 */
  1286 + proportion.put("count", "100%");/** 总计 */
  1287 + proportion.put("once", MathUtil.getProportion(countMap.get(1), count));
  1288 + proportion.put("twice", MathUtil.getProportion(countMap.get(2), count));
  1289 + proportion.put("threeTimes", MathUtil.getProportion(countMap.get(3), count));
  1290 + proportion.put("fourTimes", MathUtil.getProportion(countMap.get(4), count));
  1291 + proportion.put("fiveTimes", MathUtil.getProportion(countMap.get(5), count));
  1292 + proportion.put("sixTimes", MathUtil.getProportion(countMap.get(6), count));
  1293 + proportion.put("sevenTimes", MathUtil.getProportion(countMap.get(7), count));
  1294 + proportion.put("eightTimes", MathUtil.getProportion(countMap.get(8), count));
  1295 + proportion.put("nineTimes", MathUtil.getProportion(countMap.get(9), count));
  1296 + proportion.put("tenTimes", MathUtil.getProportion(countMap.get(10), count));
  1297 + proportion.put("elevenTimes", MathUtil.getProportion(countMap.get(11), count));
  1298 + proportion.put("twelveTimes", MathUtil.getProportion(countMap.get(12), count));
  1299 + proportion.put("otherTimes", MathUtil.getProportion(countMap.get(13), count));
  1300 + restList.add(proportion);
1256 1301  
  1302 + for (int i = 0; i < 12; i++) {
  1303 + yData.add(countMap.get(i + 1));
  1304 + }
1257 1305 return restList;
1258 1306 }
1259 1307  
1260 1308  
... ... @@ -1287,16 +1335,13 @@
1287 1335 }
1288 1336 }
1289 1337 }
1290   - System.out.println(antExChuModels.size());
1291   - System.out.println(antExModels.size());
1292   - System.out.println(datas.size());
1293   - for (Map<String, Object> data : datas) {
  1338 + /* for (Map<String, Object> data : datas) {
1294 1339 Set<Map.Entry<String, Object>> entries = data.entrySet();
1295 1340 for (Map.Entry<String, Object> entry : entries) {
1296 1341 System.out.print(entry.getKey() + " = " + (entry.getValue() instanceof Date ? ((Date) entry.getValue()).toLocaleString(): entry.getValue()) + "\t");
1297 1342 }
1298 1343 System.out.println();
1299   - }
  1344 + }*/
1300 1345 }
1301 1346  
1302 1347 private List<Series> createPatientSeries(List<Map<String, Object>> datas) {