Commit 480a40ff307f8b84adacd2f0c1af673b018e77e6

Authored by litao@lymsh.com
1 parent 0efbcc602a

写bug

Showing 3 changed files with 114 additions and 10 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java View file @ 480a40f
... ... @@ -33,7 +33,8 @@
33 33  
34 34 /**
35 35 * 建档统计
36   - * @param statistType 统计环比 1=周 2=月 3=季度 4=半年 5=年
  36 + * @param statistType 1=占比 2=环比
  37 + * @param statistVal 1=占比 2=环比
37 38 * @param ageType 1=全部年龄 2=20岁以下 3=20-30岁 4=30-40岁 5=40岁以上
38 39 * @param patientType 建档孕周 1=孕早期 2=孕中期 3=孕晚期
39 40 * @return
... ... @@ -41,9 +42,9 @@
41 42 @ResponseBody
42 43 @TokenRequired
43 44 @RequestMapping(value = "/patients", method = RequestMethod.GET)
44   - public BaseObjectResponse patients(String provinceId, String cityId, String areaId, String streetId,
45   - @RequestParam Integer statistType, Integer ageType, Integer patientType, Date startDate, Date endDate, HttpServletRequest request) {
46   - return reportService.patients(provinceId, cityId, areaId, streetId, statistType, ageType, patientType, startDate, endDate, getUserId(request));
  45 + public BaseObjectResponse patients(String provinceId, String cityId, String areaId, String streetId, Integer statistType, Integer statistVal,
  46 + Integer ageType, Integer patientType, Date startDate, Date endDate, HttpServletRequest request) {
  47 + return reportService.patients(provinceId, cityId, areaId, streetId, statistType, statistVal, ageType, patientType, startDate, endDate, getUserId(request));
47 48 }
48 49  
49 50 /**
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java View file @ 480a40f
... ... @@ -98,7 +98,7 @@
98 98  
99 99 BaseObjectResponse unUsedPeopleInfo(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId);
100 100  
101   - BaseObjectResponse patients(String provinceId, String cityId, String aredId, String streetId, Integer statistType, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId);
  101 + BaseObjectResponse patients(String provinceId, String cityId, String aredId, String streetId, Integer statistType, Integer statistVal, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId);
102 102  
103 103 void patientsExport(String provinceId, String cityId, String aredId, String streetId, Integer statistType, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId, HttpServletResponse response);
104 104 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java View file @ 480a40f
... ... @@ -190,11 +190,12 @@
190 190 * @return
191 191 */
192 192 @Override
193   - public BaseObjectResponse patients(String provinceId, String cityId, String aredId, String streetId,
194   - Integer statistType, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId) {
  193 + public BaseObjectResponse patients(String provinceId, String cityId, String aredId, String streetId, Integer statistType, Integer statistVal, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId) {
195 194 List<Patients> patients = getPatients(provinceId, cityId, aredId, streetId, ageType, patientType, startDate, endDate, userId);
  195 + List<Map<String, Object>> hospitals = couponMapper.findAllHospitals();
196 196 Map<String, Object> restMap = new HashMap<>();
197   - List<Map<String, Object>> tabList = new ArrayList<>();
  197 + List<List<String>> tabList = new ArrayList<>();
  198 + List<String> titleList = new ArrayList<>();
198 199 List<String> xDatas = new ArrayList<>();
199 200 List<Map<String, Object>> series = new ArrayList<>();
200 201 List<String> legend = Arrays.asList("建档总数");
... ... @@ -218,7 +219,6 @@
218 219 }
219 220 } else {
220 221 Map<Integer, Integer> areaCountMap = new HashMap<>();
221   - List<Map<String, Object>> hospitals = couponMapper.findAllHospitals();
222 222 String groupKey = StringUtils.isNotEmpty(cityId) ? "areaId" : "cityId"; // 按照区县或者市统计
223 223 for (Patients patient : patients) {
224 224 String hospitalId = patient.getHospitalId();
225 225  
... ... @@ -240,8 +240,84 @@
240 240 xDatas.add(mongoUtil.findName(entry.getKey() + ""));
241 241 bar.add(entry.getValue());
242 242 }
243   - }
244 243  
  244 + // 拼装tab数据
  245 + List<Map<String, Date>> range = DateUtil.getRange(startDate, endDate);
  246 + if(StringUtils.isNotEmpty(cityId)) { // 按照区县来
  247 + titleList.add("");
  248 + titleList.add("");
  249 + titleList.add("");
  250 + for (Map<String, Date> map : range) {
  251 + titleList.add(DateUtil.getyyyy_mm(map.get("cname")));
  252 + }
  253 + } else { // 按照城市来
  254 + titleList.add("城市名称");
  255 + titleList.add("机构数");
  256 + titleList.add("统计指标(人)");
  257 + for (Map<String, Date> map : range) {
  258 + titleList.add(DateUtil.getyyyy_mm(map.get("cname")));
  259 + }
  260 + tabList.add(titleList);
  261 + List<Map<String, Object>> infos = new ArrayList<>();
  262 + for (Patients patient : patients) {
  263 + for (Map<String, Object> map : hospitals) {
  264 + if(patient.getHospitalId().equals(map.get("id").toString())) {
  265 + boolean flag = true;
  266 + for (Map<String, Object> info : infos) {
  267 + if(map.get("cityId").equals(info.get("id"))) {
  268 + Set<String> hids = (Set<String>) info.get("hids");
  269 + hids.add(patient.getHospitalId());
  270 + for (Map<String, Date> dateMap : range) {
  271 + if(patient.getBookbuildingDate().getTime() >= dateMap.get("start").getTime()
  272 + && patient.getBookbuildingDate().getTime() < dateMap.get("end").getTime()) {
  273 + String monthKey = DateUtil.getyyyy_mm(dateMap.get("cname"));
  274 + if(info.containsKey(monthKey)) {
  275 + info.put(monthKey, (Integer) info.get(monthKey) + 1);
  276 + flag = false;
  277 + } else {
  278 + info.put(monthKey, 1);
  279 + flag = false;
  280 + }
  281 + }
  282 + }
  283 + }
  284 + }
  285 + if(flag) {
  286 + for (Map<String, Date> dateMap : range) {
  287 + if(patient.getBookbuildingDate().getTime() >= dateMap.get("start").getTime()
  288 + && patient.getBookbuildingDate().getTime() < dateMap.get("end").getTime()) {
  289 + String monthKey = DateUtil.getyyyy_mm(dateMap.get("cname"));
  290 + Map<String, Object> info = new HashMap<>();
  291 + Set<String> hids = new HashSet<>();
  292 + hids.add(patient.getHospitalId());
  293 + info.put(monthKey, 1);
  294 + info.put("id", map.get("cityId"));
  295 + info.put("hids", hids);
  296 + infos.add(info);
  297 + }
  298 + }
  299 + }
  300 + }
  301 + }
  302 + }
  303 +
  304 + for (Map<String, Object> info : infos) {
  305 + List<String> tempList = new ArrayList<>();
  306 + tempList.add(findName(info.get("id")));
  307 + tempList.add(((Set<String>) info.get("hids")).size() + "");
  308 + tempList.add("建档总数");
  309 + for (Map<String, Date> map : range) {
  310 + tempList.add(info.containsKey(DateUtil.getyyyy_mm(map.get("cname"))) ?
  311 + info.get(DateUtil.getyyyy_mm(map.get("cname"))) + "" : "0");
  312 + }
  313 + tabList.add(tempList);
  314 + }
  315 + System.out.println(tabList);
  316 + }
  317 + }
  318 +
  319 + setTabListInfo(tabList);
  320 +
245 321 barMap.put("data", bar);
246 322 barMap.put("type", "bar");
247 323 barMap.put("name", "建档总数");
... ... @@ -268,6 +344,32 @@
268 344 return RespBuilder.buildSuccess(restMap);
269 345 }
270 346  
  347 + private void setTabListInfo(List<List<String>> tabList) {
  348 + if(CollectionUtils.isNotEmpty(tabList)) {
  349 + for (int i = 0; i < tabList.size(); i++) {
  350 + List<String> list = tabList.get(i);
  351 + int seq = 0;
  352 + if(i == 0) {
  353 + list.add(0, "序号" );
  354 + list.add("合计");
  355 + } else {
  356 + int count = 0;
  357 + for (int j = 3; j < list.size(); j++) {
  358 + count += Integer.parseInt(list.get(j));
  359 + }
  360 + list.add(0, ++seq + "");
  361 + list.add(count + "");
  362 + }
  363 + }
  364 + }
  365 + }
  366 +
  367 + private Integer getPatientsCount(List<Patients> patients, Date start, Date end) {
  368 + Integer count = 0;
  369 + if(CollectionUtils.isNotEmpty(patients) && start != null && end != null) {}
  370 + return count;
  371 + }
  372 +
271 373 @Override
272 374 public void patientsExport(String provinceId, String cityId, String aredId, String streetId, Integer statistType, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId, HttpServletResponse response) {
273 375 List<Patients> patients = getPatients(provinceId, cityId, aredId, streetId, ageType, patientType, startDate, endDate, userId);
... ... @@ -362,6 +464,7 @@
362 464 return patients;
363 465 }
364 466  
  467 + // 建档孕周 1=孕早期 2=孕中期 3=孕晚期
365 468 private void doFilter(List<Patients> patients, Integer ageType, Integer patientType) {
366 469 if(patientType != null) {
367 470 Iterator<Patients> iterator = patients.iterator();