|
|
@ -37,6 +37,7 @@ import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.entity.ServiceException;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import com.yihu.jw.wechat.service.WxTemplateService;
|
|
|
import com.yihu.jw.wlyy.service.WlyyBusinessService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
@ -115,6 +116,9 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
private HcyyPrescriptionService hcyyPrescriptionService;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Autowired
|
|
|
private HibenateUtils hibenateUtils;
|
|
|
|
|
|
@Value("${wechat.id}")
|
|
|
private String wxId;
|
|
|
@ -125,7 +129,7 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
@GetMapping (value = "/statisticsData")
|
|
|
public ObjEnvelop statisticsData(
|
|
|
@ApiParam(name = "mediaType", value = "图文1,视频2")
|
|
|
@RequestParam(value = "mediaType",required = true) Integer mediaType,
|
|
|
@RequestParam(value = "mediaType",required = true) String mediaType,
|
|
|
@ApiParam(name = "aggField", value = "聚合方式 org dept doctor")
|
|
|
@RequestParam(value = "aggField",required = true) String aggField,
|
|
|
@ApiParam(name = "startTime", value = "开始时间")
|
|
|
@ -143,12 +147,12 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
try {
|
|
|
|
|
|
String selectSql = "SELECT " +
|
|
|
"op.scbgjt_org_code scbgjtOrgCode," +
|
|
|
"op.scbgjt_org_name scbgjtOrgName, " +
|
|
|
"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 ";
|
|
|
"op.scbgjt_org_code AS \"scbgjtOrgCode\"," +
|
|
|
"op.scbgjt_org_name AS \"scbgjtOrgName\", " +
|
|
|
"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_doctor_hospital dh " +
|
|
|
@ -164,7 +168,7 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
if("org".equals(aggField)) {
|
|
|
selectSql += fromPart;
|
|
|
} else if("dept".equals(aggField)) {
|
|
|
selectSql += ",dh.dept_code AS deptCode,dh.dept_name AS deptName ";
|
|
|
selectSql += ",dh.dept_code AS \"deptCode\",dh.dept_name AS \"deptName\" ";
|
|
|
selectSql += fromPart;
|
|
|
if(StringUtils.isBlank(orgId)) {
|
|
|
throw new ServiceException("参数未传");
|
|
|
@ -172,11 +176,11 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
filterSql += " AND op.scbgjt_org_code = '" + orgId + "' ";
|
|
|
groupSql += " ,dh.dept_code, dh.dept_name ";
|
|
|
} else if("doctor".equals(aggField)) {
|
|
|
selectSql += ",dh.dept_code AS deptCode," +
|
|
|
"dh.dept_name AS deptName," +
|
|
|
"op.doctor," +
|
|
|
"op.doctor_name AS doctorName," +
|
|
|
"dh.doctor_duty_name AS doctorDutyName ";
|
|
|
selectSql += ",dh.dept_code AS \"deptCode\"," +
|
|
|
"dh.dept_name AS \"deptName\"," +
|
|
|
"op.doctor AS \"doctor\"," +
|
|
|
"op.doctor_name AS \"doctorName\"," +
|
|
|
"dh.doctor_duty_name AS \"doctorDutyName\" ";
|
|
|
selectSql += fromPart;
|
|
|
if(StringUtils.isBlank(orgId) || StringUtils.isBlank(deptId)) {
|
|
|
throw new ServiceException("参数未传");
|
|
|
@ -185,11 +189,11 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
groupSql += ",dh.dept_code,dh.dept_name,op.doctor,op.doctor_name,dh.doctor_duty_name ";
|
|
|
}
|
|
|
|
|
|
if(mediaType != null) {
|
|
|
if(mediaType == 1) {
|
|
|
if(StringUtils.isNotBlank(mediaType)) {
|
|
|
if("1".equals(mediaType)) {
|
|
|
filterSql += " AND (op.type = 1 AND op.outpatient_type IN (1, 3)) ";
|
|
|
}
|
|
|
if(mediaType == 2) {
|
|
|
if("2".equals(mediaType)) {
|
|
|
filterSql += " AND (op.type = 2 AND op.outpatient_type IN (1, 3)) ";
|
|
|
}
|
|
|
}
|
|
|
@ -208,8 +212,8 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
") WHERE rn > " + startRow;
|
|
|
|
|
|
// selectSql = selectSql + " limit " + (pageNum-1)*pageSize +","+ pageSize;
|
|
|
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(selectSql);
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(selectSql, pageNum, pageSize);
|
|
|
// List<Map<String, Object>> list = jdbcTemplate.queryForList(selectSql);
|
|
|
Integer total = jdbcTemplate.queryForObject(countSql, Integer.class);
|
|
|
|
|
|
// System.out.println(pageSql);
|
|
|
@ -229,7 +233,7 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
@GetMapping (value = "/statisticsGraph")
|
|
|
public ObjEnvelop statisticsGraph(
|
|
|
@ApiParam(name = "mediaType", value = "图文1,视频2")
|
|
|
@RequestParam(value = "mediaType",required = true) Integer mediaType,
|
|
|
@RequestParam(value = "mediaType",required = true) String mediaType,
|
|
|
@ApiParam(name = "aggField", value = "聚合方式 org dept doctor")
|
|
|
@RequestParam(value = "aggField",required = true) String aggField,
|
|
|
@ApiParam(name = "startTime", value = "开始时间")
|
|
|
@ -245,13 +249,13 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
try {
|
|
|
|
|
|
String selectSql = "SELECT " +
|
|
|
"TRUNC(op.create_time) AS statDate," +
|
|
|
"op.scbgjt_org_code scbgjtOrgCode," +
|
|
|
"op.scbgjt_org_name scbgjtOrgName, " +
|
|
|
"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 ";
|
|
|
"TO_CHAR(op.create_time, 'YYYY-MM-DD') AS \"statDate\"," +
|
|
|
"op.scbgjt_org_code AS \"scbgjtOrgCode\"," +
|
|
|
"op.scbgjt_org_name AS \"scbgjtOrgName\", " +
|
|
|
"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_doctor_hospital dh " +
|
|
|
@ -262,7 +266,7 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
" AND TO_DATE('"+endTime+"', 'YYYY-MM-DD') AND op.scbgjt_org_code IS NOT NULL ";
|
|
|
|
|
|
String groupSql = "GROUP BY " +
|
|
|
" TRUNC(op.create_time),op.scbgjt_org_code, op.scbgjt_org_name ";
|
|
|
" TO_CHAR(op.create_time, 'YYYY-MM-DD'),op.scbgjt_org_code, op.scbgjt_org_name ";
|
|
|
|
|
|
if("org".equals(aggField)) {
|
|
|
selectSql += fromPart;
|
|
|
@ -271,7 +275,7 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
}
|
|
|
filterSql += " AND op.scbgjt_org_code='"+orgId+"' ";
|
|
|
} else if("dept".equals(aggField)) {
|
|
|
selectSql += ",dh.dept_code AS deptCode,dh.dept_name AS deptName ";
|
|
|
selectSql += ",dh.dept_code AS \"deptCode\",dh.dept_name AS \"deptName\" ";
|
|
|
selectSql += fromPart;
|
|
|
if(StringUtils.isBlank(orgId) || StringUtils.isBlank(deptId)) {
|
|
|
throw new ServiceException("参数未传");
|
|
|
@ -279,11 +283,11 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
filterSql += " AND op.scbgjt_org_code ='"+orgId+"' AND dh.dept_code='" + deptId + "' ";
|
|
|
groupSql += " ,dh.dept_code, dh.dept_name ";
|
|
|
} else if("doctor".equals(aggField)) {
|
|
|
selectSql += ",dh.dept_code AS deptCode," +
|
|
|
"dh.dept_name AS deptName," +
|
|
|
"op.doctor," +
|
|
|
"op.doctor_name AS doctorName," +
|
|
|
"dh.doctor_duty_name AS doctorDutyName ";
|
|
|
selectSql += ",dh.dept_code AS \"deptCode\"," +
|
|
|
"dh.dept_name AS \"deptName\"," +
|
|
|
"op.doctor AS \"doctor\"," +
|
|
|
"op.doctor_name AS \"doctorName\"," +
|
|
|
"dh.doctor_duty_name AS \"doctorDutyName\" ";
|
|
|
selectSql += fromPart;
|
|
|
if(StringUtils.isBlank(orgId) || StringUtils.isBlank(deptId) || StringUtils.isBlank(doctorId)) {
|
|
|
throw new ServiceException("参数未传");
|
|
|
@ -292,11 +296,11 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
groupSql += ",dh.dept_code,dh.dept_name,op.doctor,op.doctor_name,dh.doctor_duty_name ";
|
|
|
}
|
|
|
|
|
|
if(mediaType != null) {
|
|
|
if(mediaType == 1) {
|
|
|
if(StringUtils.isNotBlank(mediaType)) {
|
|
|
if("1".equals(mediaType)) {
|
|
|
filterSql += " AND (op.type = 1 AND op.outpatient_type IN (1, 3)) ";
|
|
|
}
|
|
|
if(mediaType == 2) {
|
|
|
if("2".equals(mediaType)) {
|
|
|
filterSql += " AND (op.type = 2 AND op.outpatient_type IN (1, 3)) ";
|
|
|
}
|
|
|
}
|
|
|
@ -315,10 +319,10 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
}
|
|
|
|
|
|
|
|
|
@GetMapping (value = "/statisticsExportData")
|
|
|
@GetMapping (value = "/prescription/searchRecordWrite")
|
|
|
public Envelop statisticsExportData(
|
|
|
@ApiParam(name = "mediaType", value = "图文1,视频2")
|
|
|
@RequestParam(value = "mediaType",required = true) Integer mediaType,
|
|
|
@RequestParam(value = "mediaType",required = true) String mediaType,
|
|
|
@ApiParam(name = "aggField", value = "聚合方式 org dept doctor")
|
|
|
@RequestParam(value = "aggField",required = true) String aggField,
|
|
|
@ApiParam(name = "startTime", value = "开始时间")
|
|
|
@ -337,7 +341,7 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
response.setContentType("octets/stream");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + new String("searchRecordWrite.xls"));
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
prescriptionService.searchRecordWrite(os, (List) list);
|
|
|
this.searchRecordWrite(os, (List) list);
|
|
|
return success("操作成功");
|
|
|
}catch (Exception e){
|
|
|
return failedListEnvelopException(e);
|
|
|
@ -345,6 +349,7 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
|
|
|
}
|
|
|
|
|
|
public void searchRecordWrite(OutputStream os, List<Map<String, Object>> list) throws Exception{
|
|
|
System.out.println(list);
|
|
|
WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
|
|
|
try {
|
|
|
WritableSheet ws;
|