|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
|
import com.yihu.jw.care.dao.message.BaseServiceNewsDao;
|
|
|
import com.yihu.jw.care.dao.security.EmergencyWarnDoctorResponseDao;
|
|
|
import com.yihu.jw.care.service.patient.CarePatientService;
|
|
|
import com.yihu.jw.care.service.role.RoleService;
|
|
|
import com.yihu.jw.care.util.CommonUtil;
|
|
@ -19,6 +20,7 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
|
|
|
import com.yihu.jw.entity.care.device.DevicePatientDevice;
|
|
|
import com.yihu.jw.entity.care.message.BaseServiceNews;
|
|
|
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
|
|
|
import com.yihu.jw.es.es.ElasticSearchHelperUtil;
|
|
|
import com.yihu.jw.es.util.ElasticsearchUtil;
|
|
|
import com.yihu.jw.es.util.SaveModel;
|
|
@ -90,6 +92,8 @@ public class StatisticsService {
|
|
|
private RoleService roleService;
|
|
|
@Autowired
|
|
|
private BaseServiceNewsDao baseServiceNewsDao;
|
|
|
@Autowired
|
|
|
private EmergencyWarnDoctorResponseDao emergencyWarnDoctorResponseDao;
|
|
|
|
|
|
private static final String defalutArea = "330100";
|
|
|
|
|
@ -2238,7 +2242,6 @@ public class StatisticsService {
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
if (list.size()>0){
|
|
|
//街道老人暂时写死
|
|
|
list.stream().forEach(m->m.put("jd_num",32661));
|
|
|
list.stream().forEach(m->m.put("zf_num",signOldNum!=null?signOldNum:0));
|
|
|
list.stream().forEach(m->m.put("xzf_num",unSignOldNum!=null?unSignOldNum:0));
|
|
|
return list.get(0);
|
|
@ -3740,7 +3743,7 @@ public class StatisticsService {
|
|
|
|
|
|
|
|
|
//获取设备
|
|
|
public JSONObject deviceinfoStatisticsNum(String type){
|
|
|
public JSONObject deviceinfoStatisticsNum(String type,String deviceCategory){
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
@ -3763,10 +3766,15 @@ public class StatisticsService {
|
|
|
" INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " +
|
|
|
" where dev.contact_status=1 and pd.device_type = 0 AND pd.user NOT IN ("+testUsqlSql+") group by pd.device_type";
|
|
|
|
|
|
String deviceCategorySql = "";
|
|
|
if (StringUtils.isNotBlank(deviceCategory)){
|
|
|
deviceCategorySql = " AND device_category= '"+deviceCategory+"' ";
|
|
|
}
|
|
|
|
|
|
//七天使用 AND device_category= 4 手表
|
|
|
String sevenDayUseSql ="select count(distinct pd.device_sn) total from wlyy_patient_device pd INNER JOIN wlyy_devices dev on pd.device_sn = dev.device_code " +
|
|
|
" INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " +
|
|
|
" where pd.device_type = "+type+" AND EXISTS(SELECT 1 FROM device_data_push_log pl WHERE pl.device_sn = pd.device_sn AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= pl.create_time ) AND pd.user NOT IN ("+testUsqlSql+") group by pd.device_type";
|
|
|
" where pd.device_type = "+type+" AND EXISTS(SELECT 1 FROM device_data_push_log pl WHERE pl.device_sn = pd.device_sn "+deviceCategorySql+" AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= pl.create_time ) AND pd.user NOT IN ("+testUsqlSql+") group by pd.device_type";
|
|
|
|
|
|
|
|
|
List<Integer> total = jdbcTemplate.queryForList(typeTotalSql, Integer.class);
|
|
@ -3799,6 +3807,64 @@ public class StatisticsService {
|
|
|
return jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
|
|
|
public JSONObject findPatientFamilyAndDoctor(String patient,String orderId){
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
|
|
|
//自己
|
|
|
String patientSql = " SELECT name,mobile,photo,sex, idcard FROM base_patient WHERE id = '"+patient+"' ";
|
|
|
|
|
|
//家属
|
|
|
String familySql = "SELECT DISTINCT p.`name`,p.id,p.photo FROM base_patient p WHERE p.id IN (SELECT fm.family_member FROM base_patient_family_member fm WHERE fm.patient = '"+patient+"')";
|
|
|
//社工
|
|
|
String doctorSql ="SELECT DISTINCT d.`name`,d.id,d.photo FROM base_service_package_sign_record sr,base_service_package_record r,base_service_package i,base_team_member m," +
|
|
|
" base_doctor d WHERE sr.id = r.sign_id AND sr.STATUS = 1 AND sr.patient = '"+patient+"' AND r.service_package_id = i.id AND i.del = 1 AND m.team_code = r.team_code " +
|
|
|
" AND sr.id = r.sign_id AND m.doctor_code = d.id AND m.del = '1'";
|
|
|
//助老元
|
|
|
String dHelpSql = "SELECT DISTINCT ph.doctor,ph.doctor_name,d.photo FROM base_patient_helper ph INNER JOIN base_doctor d WHERE ph.patient= '"+patient+"' AND ph.del = 1 GROUP BY ph.id";
|
|
|
List<Map<String, Object>> doctorList = jdbcTemplate.queryForList(doctorSql);
|
|
|
List<Map<String, Object>> familyList = jdbcTemplate.queryForList(familySql);
|
|
|
List<Map<String, Object>> helperList = jdbcTemplate.queryForList(dHelpSql);
|
|
|
List<Map<String, Object>> patientList = jdbcTemplate.queryForList(patientSql);
|
|
|
|
|
|
patientList.stream().forEach(patientMap-> patientMap.put("age",IdCardUtil.getAgeForIdcard(patientMap.get("idcard").toString())));
|
|
|
|
|
|
doctorList.stream().forEach(doctorMap->{
|
|
|
doctorMap.put("statusName", "未响应");
|
|
|
doctorMap.put("status", 0);
|
|
|
if (emergencyWarnDoctorResponseDao.findByDoctorAndOrderId(doctorMap.get("id").toString(), orderId) != null) {
|
|
|
doctorMap.put("statusName","已响应");
|
|
|
doctorMap.put("status", 1);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
familyList.stream().forEach(familyMap->{
|
|
|
SystemMessageDO byRelationCodeAndReceiver = systemMessageDao.findByRelationCodeAndReceiver(orderId, patient);
|
|
|
familyMap.put("statusName", "未读");
|
|
|
familyMap.put("status", 0);
|
|
|
if (null!=byRelationCodeAndReceiver){
|
|
|
if (StringUtils.isNotBlank(byRelationCodeAndReceiver.getIsRead())) {
|
|
|
//familyMap.put("status", Integer.parseInt(byRelationCodeAndReceiver.getIsRead()));
|
|
|
if (Integer.parseInt(byRelationCodeAndReceiver.getIsRead()) == 1) {
|
|
|
familyMap.put("statusName", "已读");
|
|
|
familyMap.put("status", 1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
jsonObject.put("doctors",doctorList);
|
|
|
jsonObject.put("familys",familyList);
|
|
|
jsonObject.put("helpers",helperList);
|
|
|
jsonObject.put("patient",patientList);
|
|
|
|
|
|
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|