|
@ -15,16 +15,12 @@ import com.yihu.jw.entity.base.org.BaseOrgDO;
|
|
|
import com.yihu.jw.es.util.ElasticsearchUtil;
|
|
|
import com.yihu.jw.es.util.SaveModel;
|
|
|
import com.yihu.jw.evaluate.score.service.BaseEvaluateScoreService;
|
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
|
import com.yihu.jw.org.dao.BaseOrgDao;
|
|
|
import com.yihu.jw.restmodel.hospital.statistics.ScreenQvo;
|
|
|
import com.yihu.jw.rm.base.BaseRequestMapping;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import jxl.Workbook;
|
|
|
import jxl.write.Label;
|
|
|
import jxl.write.WritableSheet;
|
|
|
import jxl.write.WritableWorkbook;
|
|
|
import jxl.write.WriteException;
|
|
|
import jxl.format.VerticalAlignment;
|
|
|
import jxl.write.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@ -38,7 +34,6 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.transaction.Transactional;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
@ -50,6 +45,7 @@ import java.time.ZonedDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.TextStyle;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by wangzhinan on 2019/12/3.
|
|
@ -82,6 +78,9 @@ public class StatisticsEsService {
|
|
|
private String wxId;
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
@Autowired
|
|
|
private WlyyHospitalSysDictDao sysDictDao;//字典
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 问诊量
|
|
@ -1015,8 +1014,10 @@ public class StatisticsEsService {
|
|
|
return -1;
|
|
|
} else if (a == b) {
|
|
|
return 0;
|
|
|
} else
|
|
|
} else {
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
});
|
|
|
JSONArray jsonArray = JSONArray.parseArray(bindArrayResult.toString());
|
|
@ -5843,25 +5844,25 @@ public class StatisticsEsService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public List<Map<String,Object>> selectArticleCountExcel(Integer flag, String startDate, String endDate,int level, String area, String lowLevel, String lowCode) throws Exception {
|
|
|
if (level==4){
|
|
|
List<Map<String,Object>> mapList = getArticleExcel(flag,startDate,endDate,level,area, "5", null);
|
|
|
for (Map<String,Object> map:mapList){
|
|
|
List<Map<String,Object>> maps= getArticleExcel(flag,startDate,endDate,5,map.get("code").toString(), "6", null);
|
|
|
map.put("doctors",maps);
|
|
|
public List<Map<String, Object>> selectArticleCountExcel(Integer flag, String startDate, String endDate, int level, String area, String lowLevel, String lowCode) throws Exception {
|
|
|
if (level == 4) {
|
|
|
List<Map<String, Object>> mapList = getArticleExcel(flag, startDate, endDate, level, area, "5", null);
|
|
|
for (Map<String, Object> map : mapList) {
|
|
|
List<Map<String, Object>> maps = getArticleExcel(flag, startDate, endDate, 5, map.get("code").toString(), "6", null);
|
|
|
map.put("doctors", maps);
|
|
|
}
|
|
|
return mapList;
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public void pushArticleTotalExcel(OutputStream os, List<Map<String, Object>> list) throws Exception{
|
|
|
public void pushArticleTotalExcel(OutputStream os, List<Map<String, Object>> list) throws Exception {
|
|
|
WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
|
|
|
try {
|
|
|
WritableSheet ws;
|
|
|
ws = wwb.createSheet("sheet", 1);
|
|
|
|
|
|
String[] header = {"科室","医生","发布类型","发布量","点赞量","收藏数","评论数"};
|
|
|
String[] header = {"科室", "医生", "发布类型", "发布量", "点赞量", "收藏数", "评论数"};
|
|
|
int k = 0;
|
|
|
for (String h : header) {
|
|
|
addCell(ws, 0, k, h);//表名,行,列,header
|
|
@ -5873,23 +5874,23 @@ public class StatisticsEsService {
|
|
|
|
|
|
|
|
|
for (Map<String, Object> m : list) {
|
|
|
addCell(ws, i, 0, m.get("name")!=null?m.get("name").toString():n);
|
|
|
addCell(ws, i, 0, m.get("name") != null ? m.get("name").toString() : n);
|
|
|
addCell(ws, i, 1, "-");
|
|
|
addCell(ws, i, 2, m.get("publishTypeCount")!=null?m.get("publishTypeCount").toString():n);
|
|
|
addCell(ws, i, 3, m.get("total")!=null?m.get("total").toString():n);
|
|
|
addCell(ws, i, 4, m.get("dianzangCount")!=null?m.get("dianzangCount").toString():n);
|
|
|
addCell(ws, i, 5, m.get("collectCount")!=null?m.get("collectCount").toString():n);
|
|
|
addCell(ws, i, 6, m.get("pinglunCount")!=null?m.get("pinglunCount").toString():n);
|
|
|
addCell(ws, i, 2, m.get("publishTypeCount") != null ? m.get("publishTypeCount").toString() : n);
|
|
|
addCell(ws, i, 3, m.get("total") != null ? m.get("total").toString() : n);
|
|
|
addCell(ws, i, 4, m.get("dianzangCount") != null ? m.get("dianzangCount").toString() : n);
|
|
|
addCell(ws, i, 5, m.get("collectCount") != null ? m.get("collectCount").toString() : n);
|
|
|
addCell(ws, i, 6, m.get("pinglunCount") != null ? m.get("pinglunCount").toString() : n);
|
|
|
i++;
|
|
|
List<Map<String,Object>> maps = (List<Map<String, Object>>) m.get("doctors");
|
|
|
for (Map<String,Object> map:maps){
|
|
|
addCell(ws, i, 0, m.get("name")!=null?m.get("name").toString():n);
|
|
|
addCell(ws, i, 1, map.get("name")!=null?map.get("name").toString():n);
|
|
|
addCell(ws, i, 2, map.get("publishTypeCount")!=null?map.get("publishTypeCount").toString():n);
|
|
|
addCell(ws, i, 3, map.get("total")!=null?map.get("total").toString():n);
|
|
|
addCell(ws, i, 4, map.get("dianzangCount")!=null?map.get("dianzangCount").toString():n);
|
|
|
addCell(ws, i, 5, map.get("collectCount")!=null?map.get("collectCount").toString():n);
|
|
|
addCell(ws, i, 6, map.get("pinglunCount")!=null?map.get("pinglunCount").toString():n);
|
|
|
List<Map<String, Object>> maps = (List<Map<String, Object>>) m.get("doctors");
|
|
|
for (Map<String, Object> map : maps) {
|
|
|
addCell(ws, i, 0, m.get("name") != null ? m.get("name").toString() : n);
|
|
|
addCell(ws, i, 1, map.get("name") != null ? map.get("name").toString() : n);
|
|
|
addCell(ws, i, 2, map.get("publishTypeCount") != null ? map.get("publishTypeCount").toString() : n);
|
|
|
addCell(ws, i, 3, map.get("total") != null ? map.get("total").toString() : n);
|
|
|
addCell(ws, i, 4, map.get("dianzangCount") != null ? map.get("dianzangCount").toString() : n);
|
|
|
addCell(ws, i, 5, map.get("collectCount") != null ? map.get("collectCount").toString() : n);
|
|
|
addCell(ws, i, 6, map.get("pinglunCount") != null ? map.get("pinglunCount").toString() : n);
|
|
|
i++;
|
|
|
}
|
|
|
}
|
|
@ -5962,7 +5963,7 @@ public class StatisticsEsService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 按照科室和医生查询列表
|
|
|
* 按照科室和医生查询列表
|
|
|
*
|
|
|
* @param flag
|
|
|
* @param startDate
|
|
@ -5974,41 +5975,41 @@ public class StatisticsEsService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public List<Map<String,Object>> getArticleTotalList(Integer flag,String startDate,String endDate,int level, String area, String lowLevel,String lowCode) throws Exception {
|
|
|
if (flag==1){
|
|
|
startDate = DateUtil.getFirstMonthDay() +" 00:00:00";
|
|
|
endDate = DateUtil.getLastMonthDay()+" 23:59:59";
|
|
|
} else if (flag==2) {
|
|
|
startDate = DateUtil.getMonthDate(new Date(),-6)+" 00:00:00";
|
|
|
endDate = DateUtil.getStringDateShort()+" 23:59:59";
|
|
|
}else if (flag==3){
|
|
|
startDate = DateUtil.getCurrentYearStartTime()+" 00:00:00";
|
|
|
endDate = DateUtil.getCurrentYearEndTime() +" 23:59:59";
|
|
|
public List<Map<String, Object>> getArticleTotalList(Integer flag, String startDate, String endDate, int level, String area, String lowLevel, String lowCode) throws Exception {
|
|
|
if (flag == 1) {
|
|
|
startDate = DateUtil.getFirstMonthDay() + " 00:00:00";
|
|
|
endDate = DateUtil.getLastMonthDay() + " 23:59:59";
|
|
|
} else if (flag == 2) {
|
|
|
startDate = DateUtil.getMonthDate(new Date(), -6) + " 00:00:00";
|
|
|
endDate = DateUtil.getStringDateShort() + " 23:59:59";
|
|
|
} else if (flag == 3) {
|
|
|
startDate = DateUtil.getCurrentYearStartTime() + " 00:00:00";
|
|
|
endDate = DateUtil.getCurrentYearEndTime() + " 23:59:59";
|
|
|
}
|
|
|
//文章发布数
|
|
|
List<SaveModel> total = elasticsearchUtil.findListDateQuotaLevel1Empty(startDate, endDate,area,level, "75", SaveModel.timeLevel_ZL, lowLevel,lowCode);//总数
|
|
|
List<Map<String,Object>> resultMaps = new ArrayList<>();
|
|
|
for (SaveModel saveModel:total){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
List<SaveModel> total = elasticsearchUtil.findListDateQuotaLevel1Empty(startDate, endDate, area, level, "75", SaveModel.timeLevel_ZL, lowLevel, lowCode);//总数
|
|
|
List<Map<String, Object>> resultMaps = new ArrayList<>();
|
|
|
for (SaveModel saveModel : total) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
if (SaveModel.doctorLevel.equalsIgnoreCase(lowLevel)) {
|
|
|
map.put("code",saveModel.getDoctor());
|
|
|
map.put("code", saveModel.getDoctor());
|
|
|
map.put("name", saveModel.getDoctorName());
|
|
|
BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(saveModel.getDoctor());
|
|
|
if (doctorDO!=null){
|
|
|
map.put("doctor",doctorDO);
|
|
|
if (doctorDO != null) {
|
|
|
map.put("doctor", doctorDO);
|
|
|
}
|
|
|
List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(saveModel.getDoctor());
|
|
|
if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
|
|
|
map.put("doctorHospital",doctorHospitalDOS);
|
|
|
if (doctorHospitalDOS != null && doctorHospitalDOS.size() != 0) {
|
|
|
map.put("doctorHospital", doctorHospitalDOS);
|
|
|
}
|
|
|
} else if (SaveModel.deptLevel.equalsIgnoreCase(lowLevel)) {
|
|
|
map.put("code",saveModel.getDept());
|
|
|
map.put("code", saveModel.getDept());
|
|
|
map.put("name", saveModel.getDeptName());
|
|
|
} else if (SaveModel.OrgLevel.equalsIgnoreCase(lowLevel)) {
|
|
|
map.put("code",saveModel.getHospital());
|
|
|
map.put("code", saveModel.getHospital());
|
|
|
map.put("name", saveModel.getHospitalName());
|
|
|
}
|
|
|
map.put("total",saveModel.getResult1().intValue());
|
|
|
map.put("total", saveModel.getResult1().intValue());
|
|
|
resultMaps.add(map);
|
|
|
}
|
|
|
Collections.sort(resultMaps, new Comparator<Map<String, Object>>() {
|
|
@ -6021,7 +6022,6 @@ public class StatisticsEsService {
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 文章类型统计
|
|
|
*
|
|
@ -6126,6 +6126,10 @@ public class StatisticsEsService {
|
|
|
//---------------------【接诊量】------------------------------------
|
|
|
//接诊量-已接诊
|
|
|
List<SaveModel> jz_model01 = elasticsearchUtil.findListDateQuotaLevel2(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), "12,14,16", "1", null, "9,16,12,1,17", "1");
|
|
|
//上个周期
|
|
|
List<SaveModel> jz_model02 = elasticsearchUtil.findListDateQuotaLevel2(period[0], period[1], qvo.getArea(), qvo.getLevel(), "12,14,16", "1", null, "9,16,12,1,17", "1");
|
|
|
//去年同期时间
|
|
|
List<SaveModel> jz_model03 = elasticsearchUtil.findListDateQuotaLevel2(periodYear[0], periodYear[1], qvo.getArea(), qvo.getLevel(), "12,14,16", "1", null, "9,16,12,1,17", "1");
|
|
|
|
|
|
/**
|
|
|
* 计算同比和环比
|
|
@ -6136,34 +6140,40 @@ public class StatisticsEsService {
|
|
|
//上周期总收入
|
|
|
int periodTotal = countListTotal(model03) + countListTotal(model04);
|
|
|
//去年同期时间段总收入
|
|
|
int periodYearTotal =countListTotal(model05) + countListTotal(model06);
|
|
|
int periodYearTotal = countListTotal(model05) + countListTotal(model06);
|
|
|
//赋值
|
|
|
result.put("fee_examination",countListTotal(model01));//诊查费
|
|
|
result.put("fee_examination", countListTotal(model01));//诊查费
|
|
|
result.put("fee_prescription", countListTotal(model02));//处方费
|
|
|
result.put("fee_total", totalRevenue);//总收入
|
|
|
result.put("fee_hb", getRange((totalRevenue - periodTotal), periodTotal, 0));//环比
|
|
|
result.put("fee_tb",getRange((totalRevenue - periodYearTotal), periodYearTotal, 0));//同比
|
|
|
result.put("fee_tb", getRange((totalRevenue - periodYearTotal), periodYearTotal, 0));//同比
|
|
|
|
|
|
int patientVolume = 0;
|
|
|
//接诊量
|
|
|
if (!jz_model01.isEmpty()) {
|
|
|
patientVolume = (int) jz_model01.stream().mapToDouble(SaveModel::getResult1).sum();
|
|
|
}
|
|
|
int patientVolume = countListTotal(jz_model01);
|
|
|
int periodPatientVolume = countListTotal(jz_model02);//上个周期
|
|
|
int periodYearPatientVolume = countListTotal(jz_model03);//去年同期时间
|
|
|
|
|
|
|
|
|
result.put("wzl_jz", patientVolume);//接诊量
|
|
|
result.put("wzl_jz_hb", getRange((patientVolume - periodPatientVolume), periodPatientVolume, 0));//接诊量-环比
|
|
|
result.put("wzl_jz_tb", getRange((patientVolume - periodYearPatientVolume), periodYearPatientVolume, 0));//接诊量-同比
|
|
|
|
|
|
//问诊
|
|
|
int wzl = countListTotal(wz_model01);
|
|
|
//同比和环比
|
|
|
int wzl_period = countListTotal(wz_model02);//上个周期
|
|
|
int wzl_periodYear = countListTotal(wz_model03);//去年同周期
|
|
|
result.put("wzl_total", wzl);//问诊量
|
|
|
result.put("wzl_jz", patientVolume);//接诊量
|
|
|
result.put("wzl_jzl", getRange(patientVolume, wzl, 0));//【接诊率】= 接诊量 ÷ 问诊量 ×100%
|
|
|
result.put("wzl_hb", getRange((wzl - wzl_period), wzl_period, 0));//环比
|
|
|
result.put("wzl_tb", getRange((wzl - wzl_periodYear), wzl_periodYear, 0));//同比
|
|
|
|
|
|
//开方 【处方量】
|
|
|
int kf_total = countListTotal(cf_model01);
|
|
|
int kf_period = countListTotal(cf_model02);;//上个周期
|
|
|
int kf_periodYear = countListTotal(cf_model03);;//去年同周期
|
|
|
int kf_period = countListTotal(cf_model02);
|
|
|
;//上个周期
|
|
|
int kf_periodYear = countListTotal(cf_model03);
|
|
|
;//去年同周期
|
|
|
result.put("kf_total", kf_total);//开方量
|
|
|
result.put("kf_kfl", getRange(kf_total, patientVolume, 0));//【处方率】= 处方量 ÷ 接诊量 ×100%
|
|
|
result.put("kf_hb", getRange((kf_total - kf_period), kf_period, 0));//环比
|
|
@ -6336,7 +6346,7 @@ public class StatisticsEsService {
|
|
|
qvo.setStartDate(DateUtil.getCurrentYearStartTime());
|
|
|
qvo.setEndDate(DateUtil.getCurrentYearEndTime());
|
|
|
}
|
|
|
System.out.println("赋值时间-参数:"+JSON.toJSONString(qvo));
|
|
|
System.out.println("赋值时间-参数:" + JSON.toJSONString(qvo));
|
|
|
HashMap<String, String> map = new HashMap<>();
|
|
|
JSONObject result = new JSONObject();
|
|
|
map.put("drugFree", "3"); //诊查费
|
|
@ -6351,7 +6361,7 @@ public class StatisticsEsService {
|
|
|
result.put(key, array);
|
|
|
} else {
|
|
|
//按日
|
|
|
System.out.println("执行dateTotalStatistics2方法==>时间"+qvo.getStartDate()+" -- "+qvo.getEndDate());
|
|
|
System.out.println("执行dateTotalStatistics2方法==>时间" + qvo.getStartDate() + " -- " + qvo.getEndDate());
|
|
|
JSONArray array = dateTotalStatistics2(qvo.getStartDate(), qvo.getEndDate(), qvo.getArea(), qvo.getLevel(), value, null, SaveModel.timeLevel_ZL, null);
|
|
|
result.put(key, addWeekdayToJSONArray(array));
|
|
|
}
|
|
@ -6470,7 +6480,6 @@ public class StatisticsEsService {
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 【全院明细】
|
|
|
* 科室、医生、问诊量、接诊量、未接诊量、接诊率、处方量、检查费、药品费、总收入
|
|
@ -6954,4 +6963,61 @@ public class StatisticsEsService {
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* todo 查看科室排班数据
|
|
|
*
|
|
|
* @param qvo
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getDeptScheduling(ScreenQvo qvo) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取功能全部的设置
|
|
|
*/
|
|
|
public JSONObject getAllFunctionSetting() {
|
|
|
JSONObject result = new JSONObject();
|
|
|
String sql = " SELECT dict_code \"functionCode\",dict_value \"functionName\" FROM wlyy_hospital_sys_dict WHERE dict_name='FUNCTION_SETTING' ORDER BY sort ";
|
|
|
List<Map<String, Object>> functionList = jdbcTemplate.queryForList(sql);
|
|
|
result.put("list", functionList);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject getDoctorSetting(String doctorCode) {
|
|
|
//设置
|
|
|
String functionSql = " SELECT dict_code \"functionCode\",dict_value \"functionName\" FROM wlyy_hospital_sys_dict WHERE dict_name='FUNCTION_SETTING' ORDER BY sort ";
|
|
|
List<Map<String, Object>> functionList = jdbcTemplate.queryForList(functionSql);
|
|
|
//医生信息
|
|
|
String sql = " SELECT function_setting \"functionCode\" FROM base.base_doctor WHERE id='"+doctorCode+"'";
|
|
|
List<Map<String, Object>> doctorList = jdbcTemplate.queryForList(sql);
|
|
|
if (doctorList.isEmpty()){
|
|
|
return null;
|
|
|
}else {
|
|
|
String functionCodeList =(String) doctorList.get(0).get("functionCode");
|
|
|
// List<String> list = Arrays.asList(functionCodeList.split(","));
|
|
|
// List<Map<String, Object>> collect = functionList.stream()
|
|
|
// .filter(map -> map.keySet().containsAll(list))
|
|
|
// .collect(Collectors.toList());
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
for (String code : functionCodeList.split(",")) {
|
|
|
for (Map<String, Object> map : functionList) {
|
|
|
if (code.equals(map.get("functionCode"))){
|
|
|
list.add(map);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("list",list);
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public int updateDoctorSetting(String doctorCode,String functionCodeList) {
|
|
|
String sql=" UPDATE base.base_doctor SET function_setting='"+functionCodeList+"' WHERE id='"+doctorCode+"'" ;
|
|
|
int update = jdbcTemplate.update(sql);
|
|
|
|
|
|
return update;
|
|
|
}
|
|
|
}
|