Commit 6cff3a7db29266aff70be55a68e8d7ca7e6fa187

Authored by hujiaqi
1 parent 472f0c1352

BUG

Showing 5 changed files with 330 additions and 7 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyStatisticsManagerController.java View file @ 6cff3a7
... ... @@ -5,6 +5,7 @@
5 5 import com.lyms.platform.common.base.LoginContext;
6 6 import com.lyms.platform.common.constants.ErrorCodeConstants;
7 7 import com.lyms.platform.common.result.BaseListResponse;
  8 +import com.lyms.platform.common.result.BaseObjectResponse;
8 9 import com.lyms.platform.common.utils.BeanUtils;
9 10 import com.lyms.platform.common.utils.ExcelUtil;
10 11 import com.lyms.platform.common.utils.ExceptionUtils;
... ... @@ -347,6 +348,31 @@
347 348 } catch (Exception e) {
348 349 ExceptionUtils.catchException(e, "babyStatisticsManagerBuildSourceListExcel异常");
349 350 }
  351 + }
  352 +
  353 + /**
  354 + * @auther HuJiaqi
  355 + * @createTime 2017年01月16日 13时54分
  356 + * @discription 本院转化统计
  357 + */
  358 + @TokenRequired
  359 + @ResponseBody
  360 + @RequestMapping(value = "babyStatisticsManagerSelfConversionList", method = RequestMethod.POST, consumes = "application/json")
  361 + public BaseObjectResponse babyStatisticsManagerSelfConversionList(HttpServletRequest httpServletRequest, @RequestBody BabyStatisticsManagerSelfConversionListRequest babyStatisticsManagerSelfConversionListRequest) {
  362 + BaseObjectResponse baseObjectResponse;
  363 + try {
  364 + babyStatisticsManagerSelfConversionListRequest.setOperatorId(((LoginContext) httpServletRequest.getAttribute("loginContext")).getId());
  365 + BabyStatisticsManagerSelfConversionListResult babyStatisticsManagerSelfConversionListResult = babyStatisticsManagerFacade.babyStatisticsManagerSelfConversionList(babyStatisticsManagerSelfConversionListRequest);
  366 + if (babyStatisticsManagerSelfConversionListResult.getErrorcode() != ErrorCodeConstants.SUCCESS) {
  367 + baseObjectResponse = new BaseObjectResponse().setErrorcode(babyStatisticsManagerSelfConversionListResult.getErrorcode()).setErrormsg(babyStatisticsManagerSelfConversionListResult.getErrormsg());
  368 + return baseObjectResponse;
  369 + }
  370 + baseObjectResponse = new BaseObjectResponse().setErrorcode(babyStatisticsManagerSelfConversionListResult.getErrorcode()).setErrormsg(babyStatisticsManagerSelfConversionListResult.getErrormsg()).setData(babyStatisticsManagerSelfConversionListResult);
  371 + } catch (Exception e) {
  372 + baseObjectResponse = new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SYSTEM_ERROR).setErrormsg(ErrorCodeConstants.SYSTEM_ERROR_DESCRIPTION);
  373 + ExceptionUtils.catchException(e, "babyStatisticsManagerSelfConversionList异常");
  374 + }
  375 + return baseObjectResponse;
350 376 }
351 377  
352 378 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyStatisticsManagerFacade.java View file @ 6cff3a7
... ... @@ -380,21 +380,19 @@
380 380 }
381 381 }
382 382 });
383   - for (BabyStatisticsManagerWeekAgeGroupQueryModel babyStatisticsManagerWeekAgeGroupQueryModel : babyStatisticsManagerWeekAgeGroupQueryModelList) {
384   - System.out.println(babyStatisticsManagerWeekAgeGroupQueryModel.getWeekAge());
385   - }
  383 +
386 384 List<BabyStatisticsManagerWeekAgeGroupQueryModel> babyStatisticsManagerWeekAgeGroupQueryModelListResult = new ArrayList<>();
387 385 // 从0开始,没有也填充
388 386 int index = 0;
389 387 for (Integer i = 0; i < 37; i++) {
390 388 try {
391   - while (!i.toString().equals(babyStatisticsManagerWeekAgeGroupQueryModelList.get(index).getWeekAge()) && i < Integer.valueOf(babyStatisticsManagerWeekAgeGroupQueryModelList.get(index).getWeekAge())) {
  389 + while (!i.toString().equals(babyStatisticsManagerWeekAgeGroupQueryModelList.get(index).getWeekAge()) && i > Integer.valueOf(babyStatisticsManagerWeekAgeGroupQueryModelList.get(index).getWeekAge())) {
392 390 index++;
393 391 }
394 392 } catch (Exception e) {
395 393 index++;
396 394 }
397   - if (CollectionUtils.isEmpty(babyStatisticsManagerWeekAgeGroupQueryModelList) || babyStatisticsManagerWeekAgeGroupQueryModelList.size() < index || babyStatisticsManagerWeekAgeGroupQueryModelList.get(index) == null) {
  395 + if (CollectionUtils.isEmpty(babyStatisticsManagerWeekAgeGroupQueryModelList) || babyStatisticsManagerWeekAgeGroupQueryModelList.size() < index || babyStatisticsManagerWeekAgeGroupQueryModelList.get(index) == null || !i.toString().equals(babyStatisticsManagerWeekAgeGroupQueryModelList.get(index).getWeekAge())) {
398 396 BabyStatisticsManagerWeekAgeGroupQueryModel babyStatisticsManagerWeekAgeGroupQueryModel = new BabyStatisticsManagerWeekAgeGroupQueryModel();
399 397 babyStatisticsManagerWeekAgeGroupQueryModel.setCount("0");
400 398 babyStatisticsManagerWeekAgeGroupQueryModel.setWeekAge(i.toString());
... ... @@ -540,7 +538,7 @@
540 538 // "AND B.CITY_ID=" +
541 539 // "AND B.AREA_COUNTY_ID="
542 540 if (StringUtils.isNotEmpty(babyStatisticsManagerBuildSourceListRequest.getBuildDate())) {
543   - sql += "AND A.INSERT_DATE BETWEEN" + buildDateStart + " AND" + buildDateEnd;
  541 + sql += "AND A.INSERT_DATE BETWEEN" + buildDateStart + "AND" + buildDateEnd;
544 542 }
545 543 sql += "GROUP BY" +
546 544 "B.PROVINCE_ID," +
... ... @@ -632,6 +630,209 @@
632 630 babyStatisticsManagerBuildSourceListResult.setErrorcode(ErrorCodeConstants.SUCCESS);
633 631 babyStatisticsManagerBuildSourceListResult.setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION);
634 632 return babyStatisticsManagerBuildSourceListResult;
  633 + }
  634 +
  635 + public BabyStatisticsManagerSelfConversionListResult babyStatisticsManagerSelfConversionList(BabyStatisticsManagerSelfConversionListRequest babyStatisticsManagerSelfConversionListRequest) {
  636 + BabyStatisticsManagerSelfConversionListResult babyStatisticsManagerSelfConversionListResult = new BabyStatisticsManagerSelfConversionListResult();
  637 +
  638 + String hospitalId;
  639 + try {
  640 + hospitalId = autoMatchFacade.getHospitalId(babyStatisticsManagerSelfConversionListRequest.getOperatorId());
  641 + } catch (Exception e) {
  642 + babyStatisticsManagerSelfConversionListResult.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR);
  643 + babyStatisticsManagerSelfConversionListResult.setErrormsg("获取当前医院异常");
  644 + return babyStatisticsManagerSelfConversionListResult;
  645 + }
  646 +
  647 + String birthDateStart = null;
  648 + String birthDateEnd = null;
  649 + if (StringUtils.isNotEmpty(babyStatisticsManagerSelfConversionListRequest.getBirthDate())) {
  650 + birthDateStart = DateUtil.getyyyy_MM_dd(DateUtil.getSNDate(babyStatisticsManagerSelfConversionListRequest.getBirthDate())[0]);
  651 + birthDateEnd = DateUtil.getyyyy_MM_dd(DateUtil.getSNDate(babyStatisticsManagerSelfConversionListRequest.getBirthDate())[1]);
  652 + }
  653 +
  654 + String sql =
  655 + "SELECT B.PROVINCE_ID," +
  656 + "B.PROVINCE," +
  657 + "B.CITY_ID," +
  658 + "B.CITY," +
  659 + "B.AREA_COUNTY_ID," +
  660 + "B.AREA_COUNTY," +
  661 + "B.HOSPITAL_NO," +
  662 + "B.HOSPITAL_NAME," +
  663 + "TRUNC(MONTHS_BETWEEN(C.EXAMINE_DATE,A.BIRTHDAY)) AS EXAMINE_MONTH," +
  664 + "COUNT(*) AS CNT" +
  665 + "FROM ODS_F_INFANT_RECORD A" +
  666 + "INNER JOIN ODS_D_HOSPITAL B ON A.HOSPITAL_NO=B.HOSPITAL_NO" +
  667 + "LEFT JOIN ODS_F_CHILD_PHYSICAL C ON A.RECORD_ID=C.RECORD_ID AND C.EXAMINE_HISTORY_NUM=1" +
  668 + "WHERE A.HOSPITAL_NO=A.BIRTH_HOSPITAL_NO" +
  669 + "AND B.YCY_STSTEM_ID=" + hospitalId;
  670 + // 这三个查询条件暂时没用,直接注释掉
  671 + // "AND B.PROVINCE_ID="+
  672 + // "AND B.CITY_ID="+
  673 + // "AND B.AREA_COUNTY_ID="+
  674 + if (StringUtils.isNotEmpty(babyStatisticsManagerSelfConversionListRequest.getBirthDate())) {
  675 + sql += "AND A.INSERT_DATE BETWEEN" + birthDateStart + "AND" + birthDateEnd;
  676 + }
  677 + sql += "GROUP BY" +
  678 + "B.PROVINCE_ID," +
  679 + "B.PROVINCE," +
  680 + "B.CITY_ID," +
  681 + "B.CITY," +
  682 + "B.AREA_COUNTY_ID," +
  683 + "B.AREA_COUNTY," +
  684 + "B.HOSPITAL_NO," +
  685 + "B.HOSPITAL_NAME," +
  686 + "TRUNC(MONTHS_BETWEEN(C.EXAMINE_DATE,A.BIRTHDAY))";
  687 +
  688 + // jdbc查oracle
  689 + List<Map<String, Object>> list = JdbcUtil.getOracleListDataBySql("com.mysql.jdbc.Driver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql);
  690 +
  691 + // List<Map<String, Object>> list = new ArrayList<>();
  692 + // Map<String, Object> test1 = new HashMap<>();
  693 + // test1.put("examineMonth", 2);
  694 + // test1.put("cnt", "2");
  695 + // Map<String, Object> test2 = new HashMap<>();
  696 + // test2.put("examineMonth", 3);
  697 + // test2.put("cnt", "3");
  698 + // Map<String, Object> test3 = new HashMap<>();
  699 + // test3.put("examineMonth", 1);
  700 + // test3.put("cnt", "1");
  701 + // Map<String, Object> test4 = new HashMap<>();
  702 + // test4.put("examineMonth", 0);
  703 + // test4.put("cnt", "5");
  704 + // list.add(test1);
  705 + // list.add(test2);
  706 + // list.add(test3);
  707 + // list.add(test4);
  708 +
  709 + Collections.sort(list, new Comparator<Map<String, Object>>() {
  710 + @Override
  711 + public int compare(Map<String, Object> o1, Map<String, Object> o2) {
  712 + int i1;
  713 + int i2;
  714 + try {
  715 + i1 = Integer.valueOf(o1.get("examineMonth").toString());
  716 + } catch (Exception e) {
  717 + i1 = 0;
  718 + }
  719 + try {
  720 + i2 = Integer.valueOf(o2.get("examineMonth").toString());
  721 + } catch (Exception e) {
  722 + i2 = 0;
  723 + }
  724 + if (i1 > i2) {
  725 + return 1;
  726 + } else if (i1 < i2) {
  727 + return -1;
  728 + } else {
  729 + return 0;
  730 + }
  731 + }
  732 + });
  733 +
  734 + // 检查人数
  735 + List<Integer> result = new ArrayList<>();
  736 + Integer total = 0;
  737 + // 从0开始,没有也填充
  738 + int index = 0;
  739 + for (Integer i = 0; i < 13; i++) {
  740 + try {
  741 + while (!i.toString().equals(list.get(index).get("examineMonth").toString()) && index > Integer.valueOf(list.get(index).get("examineMonth").toString())) {
  742 + index++;
  743 + }
  744 + } catch (Exception e) {
  745 + index++;
  746 + }
  747 + if (CollectionUtils.isEmpty(list) || list.size() < index || list.get(index) == null || !i.toString().equals(list.get(index).get("examineMonth").toString())) {
  748 + result.add(0);
  749 + } else {
  750 + try {
  751 + result.add(Integer.valueOf(list.get(index).get("cnt").toString()));
  752 + total += Integer.valueOf(list.get(index).get("cnt").toString());
  753 + index++;
  754 + } catch (Exception e) {
  755 + result.add(0);
  756 + index++;
  757 + }
  758 + }
  759 + }
  760 +
  761 + Integer check18 = 0;
  762 + Integer check24 = 0;
  763 + Integer check30 = 0;
  764 + Integer check36 = 0;
  765 + for (Map<String, Object> other : list) {
  766 + if ("18".equals(other.get("examineMonth").toString())) {
  767 + check18 = Integer.valueOf(other.get("cnt").toString());
  768 + }
  769 + if ("24".equals(other.get("examineMonth").toString())) {
  770 + check24 = Integer.valueOf(other.get("cnt").toString());
  771 + }
  772 + if ("30".equals(other.get("examineMonth").toString())) {
  773 + check30 = Integer.valueOf(other.get("cnt").toString());
  774 + }
  775 + if ("36".equals(other.get("examineMonth").toString())) {
  776 + check36 = Integer.valueOf(other.get("cnt").toString());
  777 + }
  778 + }
  779 + result.add(check18);
  780 + result.add(check24);
  781 + result.add(check30);
  782 + result.add(check36);
  783 +
  784 + for (int i = 1; i < result.size(); i++) {
  785 + result.set(i, result.get(i) + result.get(i - 1));
  786 + }
  787 + result.remove(0);
  788 +
  789 + // 未检查人数
  790 + List<Integer> resultOther = new ArrayList<>();
  791 + for (Integer i : result) {
  792 + resultOther.add(total - i);
  793 + }
  794 +
  795 + // 下面的表格
  796 + Integer check1 = result.get(0);
  797 + Integer check3 = 0;
  798 + Integer check6 = 0;
  799 + Integer check12 = 0;
  800 + for (int i = 0; i < 12; i++) {
  801 + if (i < 3) {
  802 + check3 += result.get(i);
  803 + }
  804 + if (i < 6) {
  805 + check6 += result.get(i);
  806 + }
  807 + if (i < 12) {
  808 + check12 += result.get(i);
  809 + }
  810 + }
  811 + Integer checkOther = total - check12;
  812 +
  813 + List<Integer> babyCount = new ArrayList<>();
  814 + List<String> percent = new ArrayList<>();
  815 + babyCount.add(total);
  816 + percent.add("100%");
  817 + babyCount.add(check1);
  818 + percent.add(Math.round((double) check1 * 100 / (double) total) / 1.00 + "%");
  819 + babyCount.add(check3);
  820 + percent.add(Math.round((double) check3 * 100 / (double) total) / 1.00 + "%");
  821 + babyCount.add(check6);
  822 + percent.add(Math.round((double) check6 * 100 / (double) total) / 1.00 + "%");
  823 + babyCount.add(check12);
  824 + percent.add(Math.round((double) check12 * 100 / (double) total) / 1.00 + "%");
  825 + babyCount.add(checkOther);
  826 + percent.add(Math.round((double) checkOther * 100 / (double) total) / 1.00 + "%");
  827 +
  828 + babyStatisticsManagerSelfConversionListResult.setResult(result);
  829 + babyStatisticsManagerSelfConversionListResult.setResultOther(resultOther);
  830 + babyStatisticsManagerSelfConversionListResult.setBabyCount(babyCount);
  831 + babyStatisticsManagerSelfConversionListResult.setPercent(percent);
  832 +
  833 + babyStatisticsManagerSelfConversionListResult.setErrorcode(ErrorCodeConstants.SUCCESS);
  834 + babyStatisticsManagerSelfConversionListResult.setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION);
  835 + return babyStatisticsManagerSelfConversionListResult;
635 836 }
636 837 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyStatisticsManagerBuildSourceListRequest.java View file @ 6cff3a7
... ... @@ -5,7 +5,7 @@
5 5 * @createTime 2017年01月16日 11时26分
6 6 * @discription
7 7 */
8   -public class BabyStatisticsManagerBuildSourceListRequest extends BasePageQueryRequest {
  8 +public class BabyStatisticsManagerBuildSourceListRequest {
9 9  
10 10 private String buildDate;
11 11  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyStatisticsManagerSelfConversionListRequest.java View file @ 6cff3a7
  1 +package com.lyms.platform.operate.web.request;
  2 +
  3 +/**
  4 + * @auther HuJiaqi
  5 + * @createTime 2017年01月17日 14时08分
  6 + * @discription
  7 + */
  8 +public class BabyStatisticsManagerSelfConversionListRequest {
  9 +
  10 + private String birthDate;
  11 +
  12 + private Integer operatorId;
  13 +
  14 + private String isExcel;
  15 +
  16 + public String getBirthDate() {
  17 + return birthDate;
  18 + }
  19 +
  20 + public void setBirthDate(String birthDate) {
  21 + this.birthDate = birthDate;
  22 + }
  23 +
  24 + public Integer getOperatorId() {
  25 + return operatorId;
  26 + }
  27 +
  28 + public void setOperatorId(Integer operatorId) {
  29 + this.operatorId = operatorId;
  30 + }
  31 +
  32 + public String getIsExcel() {
  33 + return isExcel;
  34 + }
  35 +
  36 + public void setIsExcel(String isExcel) {
  37 + this.isExcel = isExcel;
  38 + }
  39 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/BabyStatisticsManagerSelfConversionListResult.java View file @ 6cff3a7
  1 +package com.lyms.platform.operate.web.result;
  2 +
  3 +import com.lyms.platform.common.result.BaseResponse;
  4 +
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * @auther HuJiaqi
  9 + * @createTime 2017年01月17日 14时16分
  10 + * @discription
  11 + */
  12 +public class BabyStatisticsManagerSelfConversionListResult extends BaseResponse {
  13 +
  14 + // 检查人数
  15 + private List<Integer> result;
  16 +
  17 + // 未检查人数
  18 + private List<Integer> resultOther;
  19 +
  20 + // 儿童数量
  21 + private List<Integer> babyCount;
  22 +
  23 + // 占比
  24 + private List<String> percent;
  25 +
  26 + public List<Integer> getResult() {
  27 + return result;
  28 + }
  29 +
  30 + public void setResult(List<Integer> result) {
  31 + this.result = result;
  32 + }
  33 +
  34 + public List<Integer> getResultOther() {
  35 + return resultOther;
  36 + }
  37 +
  38 + public void setResultOther(List<Integer> resultOther) {
  39 + this.resultOther = resultOther;
  40 + }
  41 +
  42 + public List<Integer> getBabyCount() {
  43 + return babyCount;
  44 + }
  45 +
  46 + public void setBabyCount(List<Integer> babyCount) {
  47 + this.babyCount = babyCount;
  48 + }
  49 +
  50 + public List<String> getPercent() {
  51 + return percent;
  52 + }
  53 +
  54 + public void setPercent(List<String> percent) {
  55 + this.percent = percent;
  56 + }
  57 +}