From 6cff3a7db29266aff70be55a68e8d7ca7e6fa187 Mon Sep 17 00:00:00 2001 From: hujiaqi Date: Wed, 18 Jan 2017 16:47:36 +0800 Subject: [PATCH] BUG --- .../BabyStatisticsManagerController.java | 26 +++ .../web/facade/BabyStatisticsManagerFacade.java | 213 ++++++++++++++++++++- ...abyStatisticsManagerBuildSourceListRequest.java | 2 +- ...StatisticsManagerSelfConversionListRequest.java | 39 ++++ ...yStatisticsManagerSelfConversionListResult.java | 57 ++++++ 5 files changed, 330 insertions(+), 7 deletions(-) create mode 100644 platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyStatisticsManagerSelfConversionListRequest.java create mode 100644 platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/BabyStatisticsManagerSelfConversionListResult.java diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyStatisticsManagerController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyStatisticsManagerController.java index 02cb242..7f1b272 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyStatisticsManagerController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyStatisticsManagerController.java @@ -5,6 +5,7 @@ import com.lyms.platform.common.base.BaseController; import com.lyms.platform.common.base.LoginContext; import com.lyms.platform.common.constants.ErrorCodeConstants; import com.lyms.platform.common.result.BaseListResponse; +import com.lyms.platform.common.result.BaseObjectResponse; import com.lyms.platform.common.utils.BeanUtils; import com.lyms.platform.common.utils.ExcelUtil; import com.lyms.platform.common.utils.ExceptionUtils; @@ -349,4 +350,29 @@ public class BabyStatisticsManagerController extends BaseController { } } + /** + * @auther HuJiaqi + * @createTime 2017年01月16日 13时54分 + * @discription 本院转化统计 + */ + @TokenRequired + @ResponseBody + @RequestMapping(value = "babyStatisticsManagerSelfConversionList", method = RequestMethod.POST, consumes = "application/json") + public BaseObjectResponse babyStatisticsManagerSelfConversionList(HttpServletRequest httpServletRequest, @RequestBody BabyStatisticsManagerSelfConversionListRequest babyStatisticsManagerSelfConversionListRequest) { + BaseObjectResponse baseObjectResponse; + try { + babyStatisticsManagerSelfConversionListRequest.setOperatorId(((LoginContext) httpServletRequest.getAttribute("loginContext")).getId()); + BabyStatisticsManagerSelfConversionListResult babyStatisticsManagerSelfConversionListResult = babyStatisticsManagerFacade.babyStatisticsManagerSelfConversionList(babyStatisticsManagerSelfConversionListRequest); + if (babyStatisticsManagerSelfConversionListResult.getErrorcode() != ErrorCodeConstants.SUCCESS) { + baseObjectResponse = new BaseObjectResponse().setErrorcode(babyStatisticsManagerSelfConversionListResult.getErrorcode()).setErrormsg(babyStatisticsManagerSelfConversionListResult.getErrormsg()); + return baseObjectResponse; + } + baseObjectResponse = new BaseObjectResponse().setErrorcode(babyStatisticsManagerSelfConversionListResult.getErrorcode()).setErrormsg(babyStatisticsManagerSelfConversionListResult.getErrormsg()).setData(babyStatisticsManagerSelfConversionListResult); + } catch (Exception e) { + baseObjectResponse = new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SYSTEM_ERROR).setErrormsg(ErrorCodeConstants.SYSTEM_ERROR_DESCRIPTION); + ExceptionUtils.catchException(e, "babyStatisticsManagerSelfConversionList异常"); + } + return baseObjectResponse; + } + } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyStatisticsManagerFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyStatisticsManagerFacade.java index f1bf24d..b344174 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyStatisticsManagerFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyStatisticsManagerFacade.java @@ -380,21 +380,19 @@ public class BabyStatisticsManagerFacade { } } }); - for (BabyStatisticsManagerWeekAgeGroupQueryModel babyStatisticsManagerWeekAgeGroupQueryModel : babyStatisticsManagerWeekAgeGroupQueryModelList) { - System.out.println(babyStatisticsManagerWeekAgeGroupQueryModel.getWeekAge()); - } + List babyStatisticsManagerWeekAgeGroupQueryModelListResult = new ArrayList<>(); // 从0开始,没有也填充 int index = 0; for (Integer i = 0; i < 37; i++) { try { - while (!i.toString().equals(babyStatisticsManagerWeekAgeGroupQueryModelList.get(index).getWeekAge()) && i < Integer.valueOf(babyStatisticsManagerWeekAgeGroupQueryModelList.get(index).getWeekAge())) { + while (!i.toString().equals(babyStatisticsManagerWeekAgeGroupQueryModelList.get(index).getWeekAge()) && i > Integer.valueOf(babyStatisticsManagerWeekAgeGroupQueryModelList.get(index).getWeekAge())) { index++; } } catch (Exception e) { index++; } - if (CollectionUtils.isEmpty(babyStatisticsManagerWeekAgeGroupQueryModelList) || babyStatisticsManagerWeekAgeGroupQueryModelList.size() < index || babyStatisticsManagerWeekAgeGroupQueryModelList.get(index) == null) { + if (CollectionUtils.isEmpty(babyStatisticsManagerWeekAgeGroupQueryModelList) || babyStatisticsManagerWeekAgeGroupQueryModelList.size() < index || babyStatisticsManagerWeekAgeGroupQueryModelList.get(index) == null || !i.toString().equals(babyStatisticsManagerWeekAgeGroupQueryModelList.get(index).getWeekAge())) { BabyStatisticsManagerWeekAgeGroupQueryModel babyStatisticsManagerWeekAgeGroupQueryModel = new BabyStatisticsManagerWeekAgeGroupQueryModel(); babyStatisticsManagerWeekAgeGroupQueryModel.setCount("0"); babyStatisticsManagerWeekAgeGroupQueryModel.setWeekAge(i.toString()); @@ -540,7 +538,7 @@ public class BabyStatisticsManagerFacade { // "AND B.CITY_ID=" + // "AND B.AREA_COUNTY_ID=" if (StringUtils.isNotEmpty(babyStatisticsManagerBuildSourceListRequest.getBuildDate())) { - sql += "AND A.INSERT_DATE BETWEEN" + buildDateStart + " AND" + buildDateEnd; + sql += "AND A.INSERT_DATE BETWEEN" + buildDateStart + "AND" + buildDateEnd; } sql += "GROUP BY" + "B.PROVINCE_ID," + @@ -633,4 +631,207 @@ public class BabyStatisticsManagerFacade { babyStatisticsManagerBuildSourceListResult.setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION); return babyStatisticsManagerBuildSourceListResult; } + + public BabyStatisticsManagerSelfConversionListResult babyStatisticsManagerSelfConversionList(BabyStatisticsManagerSelfConversionListRequest babyStatisticsManagerSelfConversionListRequest) { + BabyStatisticsManagerSelfConversionListResult babyStatisticsManagerSelfConversionListResult = new BabyStatisticsManagerSelfConversionListResult(); + + String hospitalId; + try { + hospitalId = autoMatchFacade.getHospitalId(babyStatisticsManagerSelfConversionListRequest.getOperatorId()); + } catch (Exception e) { + babyStatisticsManagerSelfConversionListResult.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR); + babyStatisticsManagerSelfConversionListResult.setErrormsg("获取当前医院异常"); + return babyStatisticsManagerSelfConversionListResult; + } + + String birthDateStart = null; + String birthDateEnd = null; + if (StringUtils.isNotEmpty(babyStatisticsManagerSelfConversionListRequest.getBirthDate())) { + birthDateStart = DateUtil.getyyyy_MM_dd(DateUtil.getSNDate(babyStatisticsManagerSelfConversionListRequest.getBirthDate())[0]); + birthDateEnd = DateUtil.getyyyy_MM_dd(DateUtil.getSNDate(babyStatisticsManagerSelfConversionListRequest.getBirthDate())[1]); + } + + String sql = + "SELECT B.PROVINCE_ID," + + "B.PROVINCE," + + "B.CITY_ID," + + "B.CITY," + + "B.AREA_COUNTY_ID," + + "B.AREA_COUNTY," + + "B.HOSPITAL_NO," + + "B.HOSPITAL_NAME," + + "TRUNC(MONTHS_BETWEEN(C.EXAMINE_DATE,A.BIRTHDAY)) AS EXAMINE_MONTH," + + "COUNT(*) AS CNT" + + "FROM ODS_F_INFANT_RECORD A" + + "INNER JOIN ODS_D_HOSPITAL B ON A.HOSPITAL_NO=B.HOSPITAL_NO" + + "LEFT JOIN ODS_F_CHILD_PHYSICAL C ON A.RECORD_ID=C.RECORD_ID AND C.EXAMINE_HISTORY_NUM=1" + + "WHERE A.HOSPITAL_NO=A.BIRTH_HOSPITAL_NO" + + "AND B.YCY_STSTEM_ID=" + hospitalId; + // 这三个查询条件暂时没用,直接注释掉 + // "AND B.PROVINCE_ID="+ + // "AND B.CITY_ID="+ + // "AND B.AREA_COUNTY_ID="+ + if (StringUtils.isNotEmpty(babyStatisticsManagerSelfConversionListRequest.getBirthDate())) { + sql += "AND A.INSERT_DATE BETWEEN" + birthDateStart + "AND" + birthDateEnd; + } + sql += "GROUP BY" + + "B.PROVINCE_ID," + + "B.PROVINCE," + + "B.CITY_ID," + + "B.CITY," + + "B.AREA_COUNTY_ID," + + "B.AREA_COUNTY," + + "B.HOSPITAL_NO," + + "B.HOSPITAL_NAME," + + "TRUNC(MONTHS_BETWEEN(C.EXAMINE_DATE,A.BIRTHDAY))"; + + // jdbc查oracle + List> list = JdbcUtil.getOracleListDataBySql("com.mysql.jdbc.Driver", "jdbc:oracle:thin:@127.0.0.1:1521:orcl", "LYMS_ODS", "Welcome1", sql); + + // List> list = new ArrayList<>(); + // Map test1 = new HashMap<>(); + // test1.put("examineMonth", 2); + // test1.put("cnt", "2"); + // Map test2 = new HashMap<>(); + // test2.put("examineMonth", 3); + // test2.put("cnt", "3"); + // Map test3 = new HashMap<>(); + // test3.put("examineMonth", 1); + // test3.put("cnt", "1"); + // Map test4 = new HashMap<>(); + // test4.put("examineMonth", 0); + // test4.put("cnt", "5"); + // list.add(test1); + // list.add(test2); + // list.add(test3); + // list.add(test4); + + Collections.sort(list, new Comparator>() { + @Override + public int compare(Map o1, Map o2) { + int i1; + int i2; + try { + i1 = Integer.valueOf(o1.get("examineMonth").toString()); + } catch (Exception e) { + i1 = 0; + } + try { + i2 = Integer.valueOf(o2.get("examineMonth").toString()); + } catch (Exception e) { + i2 = 0; + } + if (i1 > i2) { + return 1; + } else if (i1 < i2) { + return -1; + } else { + return 0; + } + } + }); + + // 检查人数 + List result = new ArrayList<>(); + Integer total = 0; + // 从0开始,没有也填充 + int index = 0; + for (Integer i = 0; i < 13; i++) { + try { + while (!i.toString().equals(list.get(index).get("examineMonth").toString()) && index > Integer.valueOf(list.get(index).get("examineMonth").toString())) { + index++; + } + } catch (Exception e) { + index++; + } + if (CollectionUtils.isEmpty(list) || list.size() < index || list.get(index) == null || !i.toString().equals(list.get(index).get("examineMonth").toString())) { + result.add(0); + } else { + try { + result.add(Integer.valueOf(list.get(index).get("cnt").toString())); + total += Integer.valueOf(list.get(index).get("cnt").toString()); + index++; + } catch (Exception e) { + result.add(0); + index++; + } + } + } + + Integer check18 = 0; + Integer check24 = 0; + Integer check30 = 0; + Integer check36 = 0; + for (Map other : list) { + if ("18".equals(other.get("examineMonth").toString())) { + check18 = Integer.valueOf(other.get("cnt").toString()); + } + if ("24".equals(other.get("examineMonth").toString())) { + check24 = Integer.valueOf(other.get("cnt").toString()); + } + if ("30".equals(other.get("examineMonth").toString())) { + check30 = Integer.valueOf(other.get("cnt").toString()); + } + if ("36".equals(other.get("examineMonth").toString())) { + check36 = Integer.valueOf(other.get("cnt").toString()); + } + } + result.add(check18); + result.add(check24); + result.add(check30); + result.add(check36); + + for (int i = 1; i < result.size(); i++) { + result.set(i, result.get(i) + result.get(i - 1)); + } + result.remove(0); + + // 未检查人数 + List resultOther = new ArrayList<>(); + for (Integer i : result) { + resultOther.add(total - i); + } + + // 下面的表格 + Integer check1 = result.get(0); + Integer check3 = 0; + Integer check6 = 0; + Integer check12 = 0; + for (int i = 0; i < 12; i++) { + if (i < 3) { + check3 += result.get(i); + } + if (i < 6) { + check6 += result.get(i); + } + if (i < 12) { + check12 += result.get(i); + } + } + Integer checkOther = total - check12; + + List babyCount = new ArrayList<>(); + List percent = new ArrayList<>(); + babyCount.add(total); + percent.add("100%"); + babyCount.add(check1); + percent.add(Math.round((double) check1 * 100 / (double) total) / 1.00 + "%"); + babyCount.add(check3); + percent.add(Math.round((double) check3 * 100 / (double) total) / 1.00 + "%"); + babyCount.add(check6); + percent.add(Math.round((double) check6 * 100 / (double) total) / 1.00 + "%"); + babyCount.add(check12); + percent.add(Math.round((double) check12 * 100 / (double) total) / 1.00 + "%"); + babyCount.add(checkOther); + percent.add(Math.round((double) checkOther * 100 / (double) total) / 1.00 + "%"); + + babyStatisticsManagerSelfConversionListResult.setResult(result); + babyStatisticsManagerSelfConversionListResult.setResultOther(resultOther); + babyStatisticsManagerSelfConversionListResult.setBabyCount(babyCount); + babyStatisticsManagerSelfConversionListResult.setPercent(percent); + + babyStatisticsManagerSelfConversionListResult.setErrorcode(ErrorCodeConstants.SUCCESS); + babyStatisticsManagerSelfConversionListResult.setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION); + return babyStatisticsManagerSelfConversionListResult; + } } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyStatisticsManagerBuildSourceListRequest.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyStatisticsManagerBuildSourceListRequest.java index aece1e4..427ccf5 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyStatisticsManagerBuildSourceListRequest.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyStatisticsManagerBuildSourceListRequest.java @@ -5,7 +5,7 @@ package com.lyms.platform.operate.web.request; * @createTime 2017年01月16日 11时26分 * @discription */ -public class BabyStatisticsManagerBuildSourceListRequest extends BasePageQueryRequest { +public class BabyStatisticsManagerBuildSourceListRequest { private String buildDate; diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyStatisticsManagerSelfConversionListRequest.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyStatisticsManagerSelfConversionListRequest.java new file mode 100644 index 0000000..73d6d64 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyStatisticsManagerSelfConversionListRequest.java @@ -0,0 +1,39 @@ +package com.lyms.platform.operate.web.request; + +/** + * @auther HuJiaqi + * @createTime 2017年01月17日 14时08分 + * @discription + */ +public class BabyStatisticsManagerSelfConversionListRequest { + + private String birthDate; + + private Integer operatorId; + + private String isExcel; + + public String getBirthDate() { + return birthDate; + } + + public void setBirthDate(String birthDate) { + this.birthDate = birthDate; + } + + public Integer getOperatorId() { + return operatorId; + } + + public void setOperatorId(Integer operatorId) { + this.operatorId = operatorId; + } + + public String getIsExcel() { + return isExcel; + } + + public void setIsExcel(String isExcel) { + this.isExcel = isExcel; + } +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/BabyStatisticsManagerSelfConversionListResult.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/BabyStatisticsManagerSelfConversionListResult.java new file mode 100644 index 0000000..806d476 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/BabyStatisticsManagerSelfConversionListResult.java @@ -0,0 +1,57 @@ +package com.lyms.platform.operate.web.result; + +import com.lyms.platform.common.result.BaseResponse; + +import java.util.List; + +/** + * @auther HuJiaqi + * @createTime 2017年01月17日 14时16分 + * @discription + */ +public class BabyStatisticsManagerSelfConversionListResult extends BaseResponse { + + // 检查人数 + private List result; + + // 未检查人数 + private List resultOther; + + // 儿童数量 + private List babyCount; + + // 占比 + private List percent; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + public List getResultOther() { + return resultOther; + } + + public void setResultOther(List resultOther) { + this.resultOther = resultOther; + } + + public List getBabyCount() { + return babyCount; + } + + public void setBabyCount(List babyCount) { + this.babyCount = babyCount; + } + + public List getPercent() { + return percent; + } + + public void setPercent(List percent) { + this.percent = percent; + } +} -- 1.8.3.1