|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
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.service.patient.CarePatientService;
|
|
|
import com.yihu.jw.care.service.role.RoleService;
|
|
|
import com.yihu.jw.care.util.CommonUtil;
|
|
@ -16,6 +17,7 @@ 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.entity.care.device.DevicePatientDevice;
|
|
|
import com.yihu.jw.entity.care.message.BaseServiceNews;
|
|
|
import com.yihu.jw.es.es.ElasticSearchHelperUtil;
|
|
|
import com.yihu.jw.es.util.ElasticsearchUtil;
|
|
|
import com.yihu.jw.es.util.SaveModel;
|
|
@ -25,7 +27,6 @@ import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@ -86,6 +87,8 @@ public class StatisticsService {
|
|
|
private CarePatientService carePatientService;
|
|
|
@Autowired
|
|
|
private RoleService roleService;
|
|
|
@Autowired
|
|
|
private BaseServiceNewsDao baseServiceNewsDao;
|
|
|
|
|
|
private static final String defalutArea = "330100";
|
|
|
|
|
@ -1490,7 +1493,7 @@ public class StatisticsService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public PageEnvelop getAllDeviceLostMessage(String area, Integer deviceCode,String deviceName,Integer page, Integer size) {
|
|
|
public PageEnvelop getAllDeviceLostMessage(String area, Integer deviceCode,String deviceName,Integer page, Integer size,String doctor) {
|
|
|
page = page > 0 ? page - 1 : 0;
|
|
|
String sql = "";
|
|
|
boolean dc = null==deviceCode;
|
|
@ -1499,12 +1502,12 @@ public class StatisticsService {
|
|
|
sql = "select GROUP_CONCAT(id) id,type,title,sender,sender_name senderName,\n" +
|
|
|
"receiver,receiver_name receiverName,relation_code relationCode,\n" +
|
|
|
"data,is_read isRead,create_time createTime,sender_photo\n" +
|
|
|
"from base_system_message where type=43 and del=1 GROUP BY relation_code order by createTime desc ";
|
|
|
"from base_system_message where type=43 and del=1 receiver = '"+doctor+"' GROUP BY relation_code order by createTime desc ";
|
|
|
}else {
|
|
|
sql = "select DISTINCT GROUP_CONCAT(sm.id) id,sm.type AS type,sm.title AS title,sm.sender AS sender,sm.sender_name AS senderName,\n" +
|
|
|
" sm.receiver AS receiver,sm.receiver_name AS receiver_name,sm.relation_code AS relationCode,\n" +
|
|
|
" sm.data AS data,sm.is_read AS isRead,sm.create_time AS createTime,sm.sender_photo AS sender_photo\n" +
|
|
|
" from base_system_message sm LEFT JOIN wlyy_patient_device pd ON sm.relation_code = pd.device_sn where sm.type=43 and sm.del=1 ";
|
|
|
" from base_system_message sm LEFT JOIN wlyy_patient_device pd ON sm.relation_code = pd.device_sn where sm.type=43 and sm.del=1 sm.receiver = '"+doctor+"' ";
|
|
|
|
|
|
if (dc) {
|
|
|
sql +=" AND pd.category_code = '"+deviceCode+"'";
|
|
@ -2561,4 +2564,69 @@ public class StatisticsService {
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public List<BaseServiceNews> serviceDynamics(Integer page,Integer size,String area,String level){
|
|
|
if (null==page){
|
|
|
page=0;
|
|
|
}
|
|
|
page = page>0?page-1:0;
|
|
|
if(size==null||size<1){
|
|
|
size = 9;
|
|
|
}
|
|
|
|
|
|
List<String> jkzlPatients = jdbcTemplate.queryForList("SELECT dict_code FROM wlyy_hospital_sys_dict WHERE dict_name LIKE '%jkzl%' ",String.class);
|
|
|
|
|
|
List<BaseServiceNews> result = new ArrayList<>();
|
|
|
String olderFilter = roleService.getOlderRoleSQL(area,level);
|
|
|
String baseServiceSql = "select sn.* from base_service_news sn where sn.type = 1 " + olderFilter.replace("{patient}","sn.code");
|
|
|
|
|
|
if ("330100".equals(area)){
|
|
|
baseServiceSql +=" UNION SELECT sn.* FROM base_service_news sn WHERE sn.type =2 ";
|
|
|
}else {
|
|
|
// 1省 2市 3区县 4机构 5团队 6医生
|
|
|
baseServiceSql +=" UNION SELECT sn.* FROM base_service_news sn LEFT JOIN base_team_member tm ON sn.`code` = tm.doctor_code WHERE sn.type =2 AND tm.del =1 ";
|
|
|
if ("4".equals(level)){
|
|
|
baseServiceSql +=" AND tm.org_code ='"+area+"'";
|
|
|
}
|
|
|
if ("5".equals(level)){
|
|
|
baseServiceSql += " AND tm.team_code ='"+area+"'";
|
|
|
}
|
|
|
}
|
|
|
baseServiceSql += " sn.create_time DESC LIMIT "+(page-1)*size+","+page+"";
|
|
|
|
|
|
List<BaseServiceNews> list = jdbcTemplate.query(baseServiceSql,new BeanPropertyRowMapper<>(BaseServiceNews.class));
|
|
|
|
|
|
for (BaseServiceNews tmp:list){
|
|
|
if (jkzlPatients.contains(tmp.getCode())){
|
|
|
continue;
|
|
|
}
|
|
|
BasePatientDO patientDO = patientDao.findById(tmp.getCode());
|
|
|
if (null!=patientDO){
|
|
|
tmp.setArchiveType(patientDO.getArchiveType());
|
|
|
tmp.setResidentialArea(patientDO.getResidentialArea());
|
|
|
}
|
|
|
String relationCode = tmp.getRelationCode();
|
|
|
if (StringUtils.isNotBlank(relationCode)){
|
|
|
if ("1".equals(tmp.getType())){//上门
|
|
|
String sql = " select group_concat(Distinct name SEPARATOR '、') from base_door_coach_fee_detail where order_id ='"+relationCode+"' and status =1 ";
|
|
|
List<String> serviceItems = jdbcTemplate.queryForList(sql,String.class);
|
|
|
if (serviceItems.size()>0){
|
|
|
tmp.setServeItems(serviceItems.get(0));
|
|
|
}
|
|
|
}
|
|
|
if ("3".equals(tmp.getType())||"4".equals(tmp.getType())){//生活照料
|
|
|
String sql = " select group_concat(Distinct name SEPARATOR '、') from base_life_care_fee_detail where order_id ='"+relationCode+"' ";
|
|
|
List<String> serviceItems = jdbcTemplate.queryForList(sql,String.class);
|
|
|
if (serviceItems.size()>0){
|
|
|
tmp.setServeItems(serviceItems.get(0));
|
|
|
}
|
|
|
}
|
|
|
if ("5".equals(tmp.getType())){
|
|
|
String sql = "";
|
|
|
}
|
|
|
}
|
|
|
result.add(tmp);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
}
|