Commit 3b3285e88495f3dc3b9f97cc549bcba5f8294cf5
1 parent
f3c6d79dce
Exists in
master
and in
6 other branches
产检次数详情统计
Showing 2 changed files with 73 additions and 10 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
3b3285e
| 1 | 1 | package com.lyms.platform.operate.web.service.impl; |
| 2 | 2 | |
| 3 | 3 | import com.lyms.hospitalapi.pojo.ReportModel; |
| 4 | +import com.lyms.platform.biz.service.CommonService; | |
| 4 | 5 | import com.lyms.platform.common.enums.CouponEnums; |
| 5 | 6 | import com.lyms.platform.common.result.BaseObjectResponse; |
| 6 | 7 | import com.lyms.platform.common.result.PageResult; |
| 7 | 8 | |
| ... | ... | @@ -14,7 +15,9 @@ |
| 14 | 15 | import com.lyms.platform.operate.web.utils.*; |
| 15 | 16 | import com.lyms.platform.permission.dao.master.CouponMapper; |
| 16 | 17 | import com.lyms.platform.permission.model.Organization; |
| 18 | +import com.lyms.platform.permission.model.Users; | |
| 17 | 19 | import com.lyms.platform.permission.service.OrganizationService; |
| 20 | +import com.lyms.platform.permission.service.UsersService; | |
| 18 | 21 | import com.lyms.platform.pojo.*; |
| 19 | 22 | import com.lymsh.platform.reportdata.model.echarts.Series; |
| 20 | 23 | import org.apache.commons.collections.MapUtils; |
| ... | ... | @@ -62,6 +65,12 @@ |
| 62 | 65 | @Autowired |
| 63 | 66 | private OrganizationService organizationService; |
| 64 | 67 | |
| 68 | + @Autowired | |
| 69 | + private UsersService usersService; | |
| 70 | + | |
| 71 | + @Autowired | |
| 72 | + private CommonService commonService; | |
| 73 | + | |
| 65 | 74 | private static final Map<String, String> colorMap = new HashMap<>(); |
| 66 | 75 | |
| 67 | 76 | /** |
| 68 | 77 | |
| 69 | 78 | |
| 70 | 79 | |
| 71 | 80 | |
| 72 | 81 | |
| ... | ... | @@ -1207,31 +1216,82 @@ |
| 1207 | 1216 | |
| 1208 | 1217 | @Override |
| 1209 | 1218 | public BaseObjectResponse getCheckNumberInfo(Integer childBirth, Date startDate, Date endDate, Integer startWeek, Integer endWeek, Integer number, Integer id, Integer currentPage, Integer pageSize) { |
| 1219 | + String hospitalId = autoMatchFacade.getHospitalId(id); | |
| 1210 | 1220 | Map<String, Object> restMap = (Map<String, Object>) getCheckNumber(startDate, endDate, startWeek, endWeek, childBirth, id).getData(); |
| 1211 | 1221 | Map<Integer, List<String>> pidMap = (Map<Integer, List<String>>) restMap.get("pidMap"); |
| 1212 | 1222 | if(number == null) { /** 为null就查询总数 */ |
| 1213 | 1223 | number = 0; |
| 1214 | 1224 | } |
| 1225 | + Integer count = pidMap.get(number).size(); | |
| 1215 | 1226 | List<String> ids = CollectionUtils.getPageIds(pidMap.get(number), currentPage, pageSize); |
| 1216 | - System.out.println(ids); | |
| 1227 | + List<Map<String, Object>> rest = new ArrayList<>(); | |
| 1228 | + PageResult pageResult = new PageResult(count, currentPage, pageSize, rest); | |
| 1229 | + for (String pid : ids) { | |
| 1230 | + Map<String, Object> tempMap = new HashMap<>(); | |
| 1231 | + PersonModel personModel = mongoTemplate.findById(pid, PersonModel.class); | |
| 1232 | + if(personModel != null) { | |
| 1233 | + List<AntenatalExaminationModel> antenatalExaminationModels = mongoTemplate.find(Query.query(Criteria.where("pid").is(pid)).with(new Sort(Sort.Direction.DESC, "checkDate")), AntenatalExaminationModel.class); | |
| 1234 | + List<AntExChuModel> antExChuModels = mongoTemplate.find(Query.query(Criteria.where("pid").is(pid)).with(new Sort(Sort.Direction.DESC, "checkTime")), AntExChuModel.class); | |
| 1235 | + tempMap.put("NAME", personModel.getName()); | |
| 1236 | + tempMap.put("TOTAL_NUM", antenatalExaminationModels.size() + antExChuModels.size()); | |
| 1237 | + Integer benyuan = 0; | |
| 1238 | + for (AntenatalExaminationModel antenatalExaminationModel : antenatalExaminationModels) { | |
| 1239 | + if(antenatalExaminationModel.getHospitalId().equals(hospitalId)) { | |
| 1240 | + benyuan++; | |
| 1241 | + } | |
| 1242 | + } | |
| 1243 | + for (AntExChuModel antExChuModel : antExChuModels) { | |
| 1244 | + if(antExChuModel.getHospitalId().equals(hospitalId)) { | |
| 1245 | + benyuan++; | |
| 1246 | + } | |
| 1247 | + } | |
| 1248 | + tempMap.put("BENYUAN_NUM", benyuan); | |
| 1249 | + if(CollectionUtils.isNotEmpty(antenatalExaminationModels)) { | |
| 1250 | + AntenatalExaminationModel examinationModel = antenatalExaminationModels.get(0); | |
| 1251 | + tempMap.put("YUNZHOU", DateUtil.getWeek(examinationModel.getLastMenses(), examinationModel.getCheckDate())); | |
| 1252 | + tempMap.put("HIGH_RISK_GRADE", mongoUtil.findName(examinationModel.getRiskScore())); | |
| 1253 | + tempMap.put("HIGH_RISK_FACTOR", mongoUtil.findName(examinationModel.getRiskFactor())); | |
| 1254 | +// tempMap.put("EDD_DATE", examinationModel.); | |
| 1255 | + tempMap.put("LAST_EXAMINE_DATE", examinationModel.getLastMenses()); | |
| 1256 | + String prodDoctor = examinationModel.getCheckDoctor(); | |
| 1257 | + if(StringUtils.isNotBlank(prodDoctor)) { | |
| 1258 | + Users users = usersService.getUsers(Integer.parseInt(prodDoctor)); | |
| 1259 | + tempMap.put("LAST_EXAMINE_DATE", users == null ? null : users.getName()); | |
| 1260 | + } | |
| 1261 | + } else if(CollectionUtils.isNotEmpty(antExChuModels)) { | |
| 1262 | + AntExChuModel antExChuModel = antExChuModels.get(0); | |
| 1263 | + tempMap.put("YUNZHOU", DateUtil.getWeek(antExChuModel.getLastMenses(), antExChuModel.getCheckTime())); | |
| 1264 | + List riskLeve = commonService.findRiskLevel(commonService.findRiskLevel(antExChuModel.getHighrisk())); | |
| 1265 | + tempMap.put("HIGH_RISK_GRADE", mongoUtil.findName(antExChuModel.getHighriskSocre())); /** 高危等级 */ | |
| 1266 | + tempMap.put("HIGH_RISK_FACTOR", mongoUtil.findName(antExChuModel.getHighrisk())); /** 风险因素 */ | |
| 1267 | + tempMap.put("EDD_DATE", antExChuModel.getDueDate()); | |
| 1268 | + tempMap.put("LAST_EXAMINE_DATE", antExChuModel.getCheckTime()); | |
| 1269 | + String prodDoctor = antExChuModel.getProdDoctor(); | |
| 1270 | + if(StringUtils.isNotBlank(prodDoctor)) { | |
| 1271 | + Users users = usersService.getUsers(Integer.parseInt(prodDoctor)); | |
| 1272 | + tempMap.put("LAST_EXAMINE_DATE", users == null ? null : users.getName()); | |
| 1273 | + } | |
| 1274 | + } | |
| 1217 | 1275 | |
| 1218 | - | |
| 1219 | - | |
| 1220 | - return null; | |
| 1276 | + rest.add(tempMap); | |
| 1277 | + } | |
| 1278 | + setColor(rest); | |
| 1279 | + pageResult.setGrid(rest); | |
| 1280 | + } | |
| 1281 | + return RespBuilder.buildSuccess(pageResult); | |
| 1221 | 1282 | } |
| 1222 | 1283 | |
| 1223 | 1284 | private List<Map<String,Object>> getCheckNumerGrid(List<Map<String, Object>> datas, List<Object> yData, Map<Integer, List<String>> pidMap) { |
| 1224 | 1285 | /** key = pid, value = 初诊复诊记录 */ |
| 1225 | 1286 | Map<String, List<Map<String, Object>>> userCheckInfo = new HashMap<>(); |
| 1226 | 1287 | for (Map<String, Object> data : datas) { |
| 1227 | - String patientId = (String) data.get("patientId"); | |
| 1228 | - if(userCheckInfo.containsKey(patientId)) { | |
| 1229 | - List<Map<String, Object>> maps = userCheckInfo.get(patientId); | |
| 1230 | - maps.add(data); | |
| 1288 | + String pid = (String) data.get("pid"); | |
| 1289 | + if(userCheckInfo.containsKey(pid)) { | |
| 1290 | + userCheckInfo.get(pid).add(data); | |
| 1231 | 1291 | } else { |
| 1232 | 1292 | List<Map<String, Object>> maps = new ArrayList<>(); |
| 1233 | 1293 | maps.add(data); |
| 1234 | - userCheckInfo.put(patientId, maps); | |
| 1294 | + userCheckInfo.put(pid, maps); | |
| 1235 | 1295 | } |
| 1236 | 1296 | } |
| 1237 | 1297 | Map<Integer, Integer> countMap = new HashMap<>(); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/CollectionUtils.java
View file @
3b3285e
| ... | ... | @@ -162,7 +162,10 @@ |
| 162 | 162 | public static <T> List<T> getPageIds(List<T> data, Integer page, Integer limit) { |
| 163 | 163 | Integer startIndex = (page - 1) * limit; |
| 164 | 164 | Integer endIndex = startIndex + limit; |
| 165 | - return data.subList(startIndex, endIndex); | |
| 165 | + if(data.size() > endIndex) { | |
| 166 | + return data.subList(startIndex, endIndex); | |
| 167 | + } | |
| 168 | + return data.subList(startIndex, data.size()); | |
| 166 | 169 | } |
| 167 | 170 | |
| 168 | 171 | } |