|
@ -8,6 +8,7 @@ import com.yihu.jw.care.vo.NumVo;
|
|
|
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.es.util.ElasticsearchUtil;
|
|
@ -54,8 +55,6 @@ public class StatisticsService {
|
|
|
@Autowired
|
|
|
private StatisticsUtilService statisticsUtilService;
|
|
|
@Autowired
|
|
|
private ImUtil imUtil;
|
|
|
@Autowired
|
|
|
private BasePatientDao patientDao;
|
|
|
|
|
|
private static final String defalutArea = "330100";
|
|
@ -227,42 +226,45 @@ public class StatisticsService {
|
|
|
for (BaseLoginLogDO log:loginLogDOs) {
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("patient",log.getUserId());
|
|
|
BasePatientDO patient = patientDao.findById(log.getUserId());
|
|
|
if (patient != null){
|
|
|
String archive_type = null;
|
|
|
if("1".equals(log.getLoginType())){
|
|
|
//user
|
|
|
object.put("onLineFlag", 0);
|
|
|
object.put("archiveType","0");
|
|
|
}else if("2".equals(log.getLoginType())){
|
|
|
//docotr
|
|
|
Integer onLineFlag =0;
|
|
|
if (patient.getArchiveType() == null){
|
|
|
continue;
|
|
|
}
|
|
|
switch (patient.getArchiveType().toString()){
|
|
|
case "1":
|
|
|
archive_type = "older";//老人
|
|
|
break;
|
|
|
case "2":
|
|
|
archive_type = "child";//新生儿
|
|
|
break;
|
|
|
}
|
|
|
object.put("archiveType",patient.getArchiveType());
|
|
|
object.put("residentialArea",patient.getResidentialArea());
|
|
|
String onLineStr = imUtil.findByUserIdAndType(log.getUserId().toString(),archive_type);
|
|
|
JSONObject oneLineObj = JSONObject.parseObject(onLineStr);
|
|
|
if (200 == oneLineObj.getInteger("status")){
|
|
|
if (oneLineObj.getInteger("data")>0){
|
|
|
onLineFlag=1;
|
|
|
}
|
|
|
BaseDoctorDO doctorDO = doctorDao.findOne(log.getUserId());
|
|
|
if(doctorDO!=null&&"1".equals(doctorDO.getOnline())){
|
|
|
onLineFlag=1;
|
|
|
}
|
|
|
object.put("onLineFlag", onLineFlag);
|
|
|
} else {
|
|
|
Integer onLineFlag =0;
|
|
|
String onLineStr = imUtil.findByUserIdAndType(log.getUserId().toString(),"helper");
|
|
|
JSONObject oneLineObj = JSONObject.parseObject(onLineStr);
|
|
|
if (200 == oneLineObj.getInteger("status")){
|
|
|
if (oneLineObj.getInteger("data")>0){
|
|
|
onLineFlag=1;
|
|
|
object.put("archiveType","0");
|
|
|
}else{
|
|
|
//居民
|
|
|
BasePatientDO patient = patientDao.findById(log.getUserId());
|
|
|
if (patient != null){
|
|
|
Integer onLineFlag =0;
|
|
|
if (patient.getArchiveType() == null){
|
|
|
continue;
|
|
|
}
|
|
|
switch (patient.getArchiveType().toString()){
|
|
|
case "1":
|
|
|
//老人
|
|
|
if(StringUtils.isNotBlank(patient.getOpenid())||"1".equals(patient.getOnline())){
|
|
|
onLineFlag=1;
|
|
|
}
|
|
|
break;
|
|
|
case "2":
|
|
|
//新生儿
|
|
|
if(StringUtils.isNotBlank(patient.getOpenid())){
|
|
|
onLineFlag=1;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
object.put("archiveType",patient.getArchiveType());
|
|
|
object.put("residentialArea",patient.getResidentialArea());
|
|
|
object.put("onLineFlag", onLineFlag);
|
|
|
}
|
|
|
object.put("onLineFlag", onLineFlag);
|
|
|
object.put("archiveType","0");
|
|
|
}
|
|
|
object.put("name",log.getName());
|
|
|
object.put("createTime", DateUtil.dateToStrLong(log.getCreateTime()) );
|
|
@ -419,37 +421,49 @@ public class StatisticsService {
|
|
|
Integer olderOn = 0;
|
|
|
Integer olderWxOn = 0;
|
|
|
Integer olderPadOn = 0;
|
|
|
//老人 儿童注册人数
|
|
|
String pateintFilter = "";
|
|
|
String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
|
|
|
List<Map<String,Object>> listtmp = jdbcTemplate.queryForList(sqltmp);
|
|
|
//儿童注册人数
|
|
|
String childFilter = "";
|
|
|
String sqlChildtmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
|
|
|
List<Map<String,Object>> listtmp = jdbcTemplate.queryForList(sqlChildtmp);
|
|
|
if(listtmp.size()>0){
|
|
|
String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
|
|
|
orgCodes = orgCodes.replaceAll(",","','");
|
|
|
pateintFilter = " and id not in ('"+orgCodes+"')";
|
|
|
childFilter = " and id not in ('"+orgCodes+"')";
|
|
|
}
|
|
|
String sqlchild = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 2" +
|
|
|
" and del='1' "+childFilter+" GROUP BY online";
|
|
|
List<Map<String,Object>> listChild = jdbcTemplate.queryForList(sqlchild);
|
|
|
for(Map<String,Object> map:listChild){
|
|
|
Integer num = Integer.valueOf(map.get("c").toString());
|
|
|
Integer online = Integer.valueOf(map.get("online").toString());
|
|
|
if(online == 1){
|
|
|
childOn += num;
|
|
|
}else{
|
|
|
childOff += num;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//老人
|
|
|
String oldFilter = "";
|
|
|
String sqlOldtmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_older' ";
|
|
|
List<Map<String,Object>> listOldtmp = jdbcTemplate.queryForList(sqlOldtmp);
|
|
|
if(listOldtmp.size()>0){
|
|
|
String orgCodes = String.valueOf(listOldtmp.get(0).get("orgCodes"));
|
|
|
orgCodes = orgCodes.replaceAll(",","','");
|
|
|
oldFilter = " and a.id not in ('"+orgCodes+"')";
|
|
|
}
|
|
|
|
|
|
String sql1 = "SELECT COUNT(*) c,archive_type*1 as archive_type,IFNULL(on_line,0) online from base_patient WHERE archive_type is not null" +
|
|
|
" and del='1' "+pateintFilter+" GROUP BY archive_type,on_line";
|
|
|
|
|
|
String sql1 = "SELECT COUNT(*) c,IFNULL(on_line,0) online from base_patient a WHERE archive_type = 1" +
|
|
|
" and del='1' "+oldFilter+" GROUP BY on_line";
|
|
|
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());
|
|
|
Integer online = Integer.valueOf(map.get("online").toString());
|
|
|
if("1".equals(archive_type)){
|
|
|
if(online == 1){
|
|
|
olderOn += num;
|
|
|
}else{
|
|
|
olderOff += num;
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
if("2".equals(archive_type)){
|
|
|
if(online == 1){
|
|
|
childOn += num;
|
|
|
}else{
|
|
|
childOff += num;
|
|
|
}
|
|
|
if(online == 1){
|
|
|
olderOn += num;
|
|
|
}else{
|
|
|
olderOff += num;
|
|
|
}
|
|
|
}
|
|
|
olderTotal = olderOff+olderOn;
|
|
@ -485,12 +499,6 @@ public class StatisticsService {
|
|
|
teacherTotal = teacherOff+teacherOn;
|
|
|
|
|
|
//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
|
|
|
olderWxOn = jsonObject.getInteger("olderWx");
|
|
|
olderPadOn = jsonObject.getInteger("olderPad");
|
|
|
|
|
|
result.put("olderTotal",olderTotal);
|
|
|
result.put("childTotal",childTotal);
|
|
|
result.put("helperTotal",helperTotal);
|
|
@ -498,8 +506,6 @@ public class StatisticsService {
|
|
|
result.put("helperOn",helperOn);
|
|
|
result.put("teacherOn",teacherOn);
|
|
|
result.put("childOn",childOn);
|
|
|
result.put("olderWxOn",olderWxOn);
|
|
|
result.put("olderPadOn",olderPadOn);
|
|
|
result.put("olderOn",olderOn);
|
|
|
|
|
|
result.put("childOff",childOff);
|