|
@ -1,5 +1,6 @@
|
|
|
package com.yihu.jw.care.service.statistics;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.care.util.ConstantUtil;
|
|
@ -9,6 +10,7 @@ import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
|
|
|
import com.yihu.jw.es.util.ElasticsearchUtil;
|
|
|
import com.yihu.jw.es.util.SaveModel;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import com.yihu.jw.org.dao.BaseOrgDao;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
@ -45,6 +47,8 @@ public class StatisticsService {
|
|
|
private BaseOrgDao orgDao;
|
|
|
@Autowired
|
|
|
private StatisticsUtilService statisticsUtilService;
|
|
|
@Autowired
|
|
|
private ImUtil imUtil;
|
|
|
|
|
|
private static final String defalutArea = "330100";
|
|
|
|
|
@ -156,6 +160,100 @@ public class StatisticsService {
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 平台人员实时统计
|
|
|
*/
|
|
|
public JSONObject platformPeople(){
|
|
|
JSONObject result = new JSONObject();
|
|
|
Integer olderTotal = 0;
|
|
|
Integer childTotal = 0;
|
|
|
Integer helperTotal = 0;
|
|
|
Integer teacherTotal = 0;
|
|
|
//老人 儿童注册人数
|
|
|
String sql1 = "SELECT COUNT(*) c,archive_type from base_patient WHERE archive_type is not null and del='1' GROUP BY archive_type";
|
|
|
List<Map<String,Object>> list1 = jdbcTemplate.queryForList(sql1);
|
|
|
for(Map<String,Object> map:list1){
|
|
|
String archive_type = map.get("archive_type").toString();
|
|
|
Integer num = Integer.valueOf(map.get("c").toString());
|
|
|
if("1".equals(archive_type)){
|
|
|
olderTotal = num;
|
|
|
continue;
|
|
|
}
|
|
|
if("2".equals(archive_type)){
|
|
|
childTotal = num;
|
|
|
}
|
|
|
}
|
|
|
//助老员和教师注册人数
|
|
|
String sql2 = "SELECT COUNT(a.id) c,a.doctor_level from base_doctor a,base_doctor_hospital h where a.id=h.doctor_code and a.del = '1' and h.del = '1' " +
|
|
|
"and a.doctor_level is not null and h.org_code not in ( " +
|
|
|
"SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' " +
|
|
|
") GROUP BY a.doctor_level";
|
|
|
List<Map<String,Object>> list2 = jdbcTemplate.queryForList(sql2);
|
|
|
for(Map<String,Object> map:list2){
|
|
|
String archive_type = map.get("doctor_level").toString();
|
|
|
Integer num = Integer.valueOf(map.get("c").toString());
|
|
|
if("2".equals(archive_type)){
|
|
|
helperTotal = num;
|
|
|
continue;
|
|
|
}
|
|
|
if("3".equals(archive_type)){
|
|
|
teacherTotal = num;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//helper 助老员,teacher 教师,child 幼儿,olderWx 老人公众号,olderPad 老人平板
|
|
|
String onlineCount = imUtil.getOnlineCountByType("");
|
|
|
JSONObject jsonObject = JSON.parseObject(onlineCount).getJSONObject("data");
|
|
|
//olderPad":0,"olderWx":0,"child":0,"teacher":0,"helper":0
|
|
|
Integer helperOn = jsonObject.getInteger("helper");
|
|
|
Integer teacherOn = jsonObject.getInteger("teacher");
|
|
|
Integer childOn = jsonObject.getInteger("child");
|
|
|
Integer olderWxOn = jsonObject.getInteger("olderWx");
|
|
|
Integer olderPadOn = jsonObject.getInteger("olderPad");
|
|
|
|
|
|
|
|
|
int repeatNum = 0;
|
|
|
if(olderWxOn>0&&olderPadOn>0){
|
|
|
//2个都大于0 要计算重复的人数
|
|
|
String onlineOlderWx = imUtil.getOnlineListByType("olderWx");
|
|
|
|
|
|
JSONObject olderWx = JSON.parseObject(onlineOlderWx);
|
|
|
List<String> list = new ArrayList(olderWx.size());
|
|
|
olderWx.entrySet().stream().forEach(one->{
|
|
|
list.add(one.getKey());
|
|
|
});
|
|
|
String onlineOlderPad = imUtil.getOnlineListByType("olderPad");
|
|
|
JSONObject olderPad = JSON.parseObject(onlineOlderPad);
|
|
|
for (Map.Entry<String,Object> s:olderPad.entrySet()){
|
|
|
if(list.contains(s.getKey())){
|
|
|
repeatNum++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
Integer olderOff = olderTotal - olderWxOn - olderPadOn + repeatNum;
|
|
|
olderOff = olderOff>0?olderOff:0;
|
|
|
|
|
|
Integer childOff = childTotal - childOn;
|
|
|
Integer helperOff = helperTotal - helperOn;
|
|
|
Integer teacherOff = teacherTotal - teacherOn;
|
|
|
|
|
|
result.put("olderTotal",olderTotal);
|
|
|
result.put("childTotal",childTotal);
|
|
|
result.put("helperTotal",helperTotal);
|
|
|
result.put("teacherTotal",teacherTotal);
|
|
|
result.put("helperOn",helperOn);
|
|
|
result.put("teacherOn",teacherOn);
|
|
|
result.put("childOn",childOn);
|
|
|
result.put("olderWxOn",olderWxOn);
|
|
|
result.put("olderPadOn",olderPadOn);
|
|
|
|
|
|
result.put("childOff",childOff);
|
|
|
result.put("helperOff",helperOff);
|
|
|
result.put("teacherOff",teacherOff);
|
|
|
result.put("olderOff",olderOff);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 统计总数
|
|
|
* @param endDate
|