|
|
@ -139,47 +139,51 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
try {
|
|
|
|
|
|
String selectSql = "SELECT\n" +
|
|
|
"dh.org_code orgCode,dh.org_name orgName, " +
|
|
|
"COUNT(*) 'consultNum', " +
|
|
|
"COUNT(IF(`op`.`status` >= 1,1,null)) 'haveReceiveNum', " +
|
|
|
"COUNT(IF(`op`.`status` <= 0,1,null)) 'noReceiveNum', " +
|
|
|
"COUNT(IF(`op`.`status` = -1,1,null)) 'cancelNum' ";
|
|
|
"o.code AS orgCode," +
|
|
|
"o.name AS orgName, " +
|
|
|
"COUNT(*) AS 'consultNum', " +
|
|
|
"COUNT(CASE WHEN op.status >= 1 THEN 1 ELSE NULL END) AS 'haveReceiveNum', " +
|
|
|
"COUNT(CASE WHEN op.status <= 0 THEN 1 ELSE NULL END) AS 'noReceiveNum', " +
|
|
|
"COUNT(CASE WHEN op.status = -1 THEN 1 ELSE NULL END) AS 'cancelNum' ";
|
|
|
|
|
|
String fromPart = " FROM base_org o " +
|
|
|
" LEFT JOIN dict_hospital_dept dept ON o.code=dept.org_code " +
|
|
|
" LEFT JOIN base_doctor_hospital dh ON dh.dept_code=dept.code " +
|
|
|
" LEFT JOIN wlyy_outpatient op ON dh.doctor_code = op.doctor" ;
|
|
|
|
|
|
String filterSql = " WHERE " +
|
|
|
" op.scbgjt IS NOT NULL AND op.create_time BETWEEN '"+startTime+"' AND '"+endTime+"' ";
|
|
|
" op.scbgjt IS NOT NULL AND op.create_time BETWEEN TO_DATE('"+startTime+"', 'YYYY-MM-DD')" +
|
|
|
" AND TO_DATE('"+endTime+"', 'YYYY-MM-DD') ";
|
|
|
|
|
|
String groupSql = "GROUP BY " +
|
|
|
" dh.org_code,dh.org_name";
|
|
|
" o.code, o.name ";
|
|
|
|
|
|
if("org".equals(aggField)) {
|
|
|
selectSql += " FROM " +
|
|
|
" base_doctor_hospital dh LEFT JOIN wlyy_outpatient op ON dh.doctor_code=op.doctor ";
|
|
|
selectSql += fromPart;
|
|
|
} else if("dept".equals(aggField)) {
|
|
|
selectSql += ",dh.dept_code deptCode,dh.dept_name deptName ";
|
|
|
selectSql += " FROM " +
|
|
|
" base_doctor_hospital dh LEFT JOIN wlyy_outpatient op ON dh.doctor_code=op.doctor ";
|
|
|
selectSql += ",dept.code AS deptCode,dept.name AS deptName ";
|
|
|
selectSql += fromPart;
|
|
|
if(StringUtils.isBlank(relationId)) {
|
|
|
throw new ServiceException("参数未传");
|
|
|
}
|
|
|
filterSql += " AND dh.org_code = '" + relationId + "' ";
|
|
|
groupSql += " ,dh.dept_code,dh.dept_name ";
|
|
|
filterSql += " AND o.code = '" + relationId + "' ";
|
|
|
groupSql += " ,dept.code, dept.name ";
|
|
|
} else if("doctor".equals(aggField)) {
|
|
|
selectSql += ",dh.dept_code deptCode,dh.dept_name deptName,op.doctor,op.`doctor_name` doctorName ";
|
|
|
selectSql += " FROM " +
|
|
|
" base_doctor_hospital dh LEFT JOIN wlyy_outpatient op ON dh.doctor_code=op.doctor ";
|
|
|
selectSql += ",dept.code AS deptCode,dept.name AS deptName,op.doctor,op.doctor_name doctorName ";
|
|
|
selectSql += fromPart;
|
|
|
if(StringUtils.isBlank(relationId)) {
|
|
|
throw new ServiceException("参数未传");
|
|
|
}
|
|
|
filterSql += " AND dh.dept_code='" + relationId + "' ";
|
|
|
groupSql += ",dh.dept_code,dh.dept_name,op.doctor,op.`doctor_name` ";
|
|
|
filterSql += " AND dept.code='" + relationId + "' ";
|
|
|
groupSql += ",dept.code, dept.name,op.doctor,op.`doctor_name` ";
|
|
|
}
|
|
|
|
|
|
if("1".equals(mediaType)) {
|
|
|
filterSql += " (((`op`.`outpatient_type` = 3) AND (`op`.`type` = 1)) OR ((`op`.`outpatient_type` = 1) AND (`op`.`type` = 1))) ";
|
|
|
filterSql += " AND (op.type = 1 AND op.outpatient_type IN (1, 3)) ";
|
|
|
}
|
|
|
|
|
|
if("2".equals(mediaType)) {
|
|
|
filterSql += " (((`op`.`outpatient_type` = 1) AND (`op`.`type` = 2)) OR ((`op`.`outpatient_type` = 3) AND (`op`.`type` = 2))) ";
|
|
|
filterSql += " AND (op.type = 2 AND op.outpatient_type IN (1, 3)) ";
|
|
|
}
|
|
|
|
|
|
selectSql += filterSql;
|
|
|
@ -189,12 +193,15 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
|
|
|
selectSql = selectSql + " limit " + (pageNum-1)*pageSize +","+ pageSize;
|
|
|
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(selectSql);
|
|
|
Integer total = jdbcTemplate.queryForObject(countSql, Integer.class);
|
|
|
// List<Map<String, Object>> list = jdbcTemplate.queryForList(selectSql);
|
|
|
// Integer total = jdbcTemplate.queryForObject(countSql, Integer.class);
|
|
|
|
|
|
System.out.println(selectSql);
|
|
|
System.out.println(countSql);
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("total",total);
|
|
|
result.put("list",list);
|
|
|
// result.put("total",total);
|
|
|
// result.put("list",list);
|
|
|
return success("请求成功",result);
|
|
|
}catch (Exception e){
|
|
|
return failedListEnvelopException(e);
|