浏览代码

【患者端】服务团队页面本年度服务统计有误。

liuwenbin 7 年之前
父节点
当前提交
77278236a5

+ 17 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -872,6 +872,8 @@ public class SignWebService extends BaseService {
        Long adminTeamId = null;
        String doctorHealth = null;
        String doctor = null;
        Date beginTime = null;
        Date endTime = null;
        JSONObject resultObject = new JSONObject();
        //先查找续签表有没有记录
        List<SignFamilyRenew> renews = signFamilyRenewDao.findByTeamCodeIsValid(teamCode, code);
@ -899,6 +901,8 @@ public class SignWebService extends BaseService {
            adminTeamId = signFamily.getAdminTeamId();
            doctorHealth = signFamily.getDoctorHealth();
            doctor = signFamily.getDoctor();
            beginTime = signFamily.getBegin();
            endTime = signFamily.getEnd();
            resultObject.put("expensesStatus", signFamily.getExpensesStatus());
        } else {
            SignFamilyRenew renew = renews.get(0);
@ -907,6 +911,8 @@ public class SignWebService extends BaseService {
            adminTeamId = renew.getAdminTeamId();
            doctorHealth = renew.getDoctorHealth();
            doctor = renew.getDoctor();
            beginTime = renew.getBegin();
            endTime = renew.getEnd();
            resultObject.put("expensesStatus",renew.getExpensesStatus() );
        }
@ -945,18 +951,24 @@ public class SignWebService extends BaseService {
        //统计待预约数量
        String reservation_sql = "select count(1) as count from wlyy_patient_reservation  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        //统计健康教育数量
        String article_sql = "select count(1) as count from wlyy_health_edu_article_patient  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        String yearBegin = DateUtil.dateToStrShort(beginTime) + " 00:00:00";
        String yearEnd = DateUtil.dateToStrShort(endTime) + " 23:59:59";
        String start = elasticsearchUtil.changeTime(yearBegin);
        String end = elasticsearchUtil.changeTime(yearEnd);
//        String article_sql = "select count(1) as count from wlyy_health_edu_article_patient  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        String article_sql = "SELECT COUNT(*) FROM "+esIndex+" where userType='1' and patientCode='"+patient+"' and (doctorCode='"+doctorHealth+"' or doctorCode='"+doctor+"') and createTime>='"+start+"' and createTime<'"+end+"'";
        //统计健康指导数量
        String guidance_sql = "select count(1) as count from wlyy_patient_health_guidance  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        StringBuffer countSql = new StringBuffer();
        countSql.append(consult_sql).append(" union all ").append(followup_sql).append(" union all ").append(reservation_sql).append(" union all ").append(article_sql).append(" union all ").append(guidance_sql);
        List<Map<String, Object>> resultCount = jdbcTemplate.queryForList(countSql.toString(), new Object[]{doctorHealth, patient, year, doctorHealth, doctor, patient, year, doctorHealth, doctor, patient, year, doctorHealth, doctor, patient, year, doctorHealth, doctor, patient, year});
        countSql.append(consult_sql).append(" union all ").append(followup_sql).append(" union all ").append(reservation_sql).append(" union all ").append(guidance_sql);
        List<Map<String, Object>> resultCount = jdbcTemplate.queryForList(countSql.toString(), new Object[]{doctorHealth, patient, year, doctorHealth, doctor, patient, year, doctorHealth, doctor, patient, year,  doctorHealth, doctor, patient, year});
        Long count = elasticsearchUtil.excuteForLong(article_sql,esType,esIndex);
        resultObject.put("consultNum", resultCount.get(0).get("count"));
        resultObject.put("followupNum", resultCount.get(1).get("count"));
        resultObject.put("reservationNum", resultCount.get(2).get("count"));
        resultObject.put("articleNum", resultCount.get(3).get("count"));
        resultObject.put("guidanceNum", resultCount.get(4).get("count"));
        resultObject.put("articleNum", count!=null?count.longValue():0);
        resultObject.put("guidanceNum", resultCount.get(3).get("count"));
        return resultObject;
    }