|
@ -21,6 +21,7 @@ import com.yihu.jw.care.service.device.PatientDeviceService;
|
|
|
import com.yihu.jw.care.service.doctor.DoctorServicePermissionsService;
|
|
|
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
|
|
|
import com.yihu.jw.care.service.message.BaseServiceNewsService;
|
|
|
import com.yihu.jw.care.service.role.RoleService;
|
|
|
import com.yihu.jw.care.service.sign.ServicePackageService;
|
|
|
import com.yihu.jw.care.util.ConstantUtil;
|
|
|
import com.yihu.jw.care.util.CountDistance;
|
|
@ -139,6 +140,8 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
private ServicePackageService servicePackageService;
|
|
|
@Autowired
|
|
|
private BaseServiceNewsService baseServiceNewsService;
|
|
|
@Autowired
|
|
|
private RoleService roleService;
|
|
|
|
|
|
/**
|
|
|
* 获取百度天气
|
|
@ -1653,4 +1656,133 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
|
}
|
|
|
|
|
|
|
|
|
/*******************************************管理员端使用********************************************/
|
|
|
public List<Map<String,Object>> getAdminEmeAndSecuOrderList(String orderType,String patient,String patientName,String doctor,String status,Integer page,Integer pageSize,String svrDesc,String area,String level){
|
|
|
String olderFilter = roleService.getOlderRoleSQL(area,level+"");
|
|
|
page = page>0?page-1:0;
|
|
|
List<Map<String,Object>> result = new ArrayList<>();
|
|
|
String filter = " ";
|
|
|
if (StringUtils.isNotBlank(patient)){
|
|
|
filter += " and ord.patient ='"+patient+"' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(patientName)){
|
|
|
filter += " and ord.patient_name like'%"+patientName+"%' ";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(status)){
|
|
|
filter += " and ord.status ='"+status+"' ";
|
|
|
}
|
|
|
String sql = " ";
|
|
|
if (StringUtils.isNotBlank(orderType)){
|
|
|
List<String> orderTypes = Arrays.asList(orderType.split(",").clone());
|
|
|
if (orderTypes.contains("20")){
|
|
|
sql += "select '20' as OrderType,ord.id,ord.patient,ord.patient_name patientName,ord.doctor,ord.status,ord.doctor_name," +
|
|
|
"'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time ,case p.sex when 1 then '男' when 2 then '女' else p.sex end as sex," +
|
|
|
" TIMESTAMPDIFF(YEAR,p.birthday,now()) as age,ord.order_source orderSource,p.mobile,p.photo,ord.session_id sessionId " +
|
|
|
"from base_emergency_assistance_order ord INNER JOIN base_patient p on ord.patient = p.id INNER JOIN base_patient_helper ph on p.id = ph.patient and ph.del=1 " +
|
|
|
" where ph.doctor='"+doctor+"' "+filter +" "+olderFilter.replace("{patient}","p.id");
|
|
|
}
|
|
|
if (orderTypes.contains("20")&&orderTypes.contains("22")){
|
|
|
sql += " UNION ";
|
|
|
}
|
|
|
if (orderTypes.contains("22")){
|
|
|
sql += " select '22' as 'OrderType',ord.id,ord.patient,ord.patient_name patientName,ord.doctor,ord.status,ord.doctor_name," +
|
|
|
"ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time ,case p.sex when 1 then '男' when 2 then '女' else p.sex end as sex, " +
|
|
|
"TIMESTAMPDIFF(YEAR,p.birthday,now()) as age,ord.order_source orderSource,p.mobile,p.photo,CONCAT(ord.patient,'_22') sessionId " +
|
|
|
" from base_security_monitoring_order ord " +
|
|
|
" INNER JOIN base_patient p on ord.patient = p.id INNER JOIN base_patient_helper ph on p.id = ph.patient and ph.del=1 " +
|
|
|
" where ph.doctor='"+doctor+"' "+filter +" "+olderFilter.replace("{patient}","p.id");
|
|
|
if(StringUtils.isNotBlank(svrDesc)){
|
|
|
sql += " and ord.serve_desc = '"+svrDesc+"' ";
|
|
|
}
|
|
|
}
|
|
|
sql += " order by create_time desc limit "+page*pageSize+","+pageSize;
|
|
|
result = jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject getAdminEmeAndSecuOrderTab(String doctor,String status,String area,String level){
|
|
|
String olderFilter = roleService.getOlderRoleSQL(area,level+"");
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONObject eme = new JSONObject();
|
|
|
JSONObject secu = new JSONObject();
|
|
|
JSONObject emeAndSecu = new JSONObject();
|
|
|
|
|
|
/************************紧急********/
|
|
|
eme.put("status_-2",0);//误报警
|
|
|
eme.put("status_-1",0);//已取消
|
|
|
eme.put("status_0",0);//已完成
|
|
|
eme.put("status_1",0);//预警中
|
|
|
String sql = " select ord.status,count(distinct ord.id) count from base_emergency_assistance_order ord INNER JOIN base_patient_helper ph on ord.patient = ph.patient and ph.del=1 ";
|
|
|
if (StringUtils.isNotBlank(status)){
|
|
|
sql += " and ord.status='"+status+"' ";
|
|
|
}
|
|
|
sql += " where ph.doctor='"+doctor+"' "+olderFilter.replace("{patient}","ph.patient")+" group by ord.status ";
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:sqlResult){
|
|
|
eme.put("status_"+map.get("status"),map.get("count"));
|
|
|
}
|
|
|
Integer All = 0;
|
|
|
Set<String> keySet = eme.keySet();
|
|
|
for (String key : keySet){
|
|
|
All+=eme.getInteger(key);
|
|
|
}
|
|
|
eme.put("all",All);
|
|
|
result.put("eme",eme);
|
|
|
|
|
|
/************************ 安防********/
|
|
|
secu.put("status_-2", 0);//误报警
|
|
|
secu.put("status_-1", 0);//已取消
|
|
|
secu.put("status_0", 0);//已完成
|
|
|
secu.put("status_1", 0);//预警中
|
|
|
secu.put("status_all", 0);//
|
|
|
secu.put("svr_all", 0);//
|
|
|
Map<String, String> serverTmp = new HashMap<>();
|
|
|
sql = " select py_code,dict_value from wlyy_hospital_sys_dict where dict_name='security_server_dict' ";
|
|
|
List<Map<String, Object>> servers = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String, Object> server : servers) {
|
|
|
secu.put("svr_" + server.get("py_code").toString(), 0);
|
|
|
serverTmp.put(server.get("dict_value").toString(), server.get("py_code").toString());
|
|
|
}
|
|
|
sql = "select ord.status,ord.serve_desc,count(distinct ord.id) count from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
|
|
|
" INNER JOIN base_patient_helper ph on ord.patient = ph.patient and ph.del=1 where ph.doctor='"+doctor+"' ";
|
|
|
String fliter = " group by ord.status";
|
|
|
sqlResult = jdbcTemplate.queryForList(sql +olderFilter.replace("{patient}","ph.patient")+ fliter);
|
|
|
|
|
|
for (Map<String, Object> map : sqlResult) {
|
|
|
secu.put("status_" + map.get("status"), secu.getInteger("status_" + map.get("status")) + Integer.parseInt(map.get("count").toString()));
|
|
|
secu.put("status_all", secu.getInteger("status_all") + Integer.parseInt(map.get("count").toString()));
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(status)){
|
|
|
sql += " and ord.status='"+status+"' ";
|
|
|
}
|
|
|
fliter = " group by ord.status,ord.serve_desc ";
|
|
|
sqlResult = jdbcTemplate.queryForList(sql + fliter);
|
|
|
|
|
|
String pyCode = "";
|
|
|
for (Map<String, Object> map : sqlResult) {
|
|
|
pyCode = serverTmp.get(map.get("serve_desc")) == null ? null : serverTmp.get(map.get("serve_desc")).toString();
|
|
|
if (StringUtils.isNotBlank(pyCode)) {
|
|
|
secu.put("svr_" + pyCode, secu.getInteger("svr_" + pyCode) + Integer.parseInt(map.get("count").toString()));
|
|
|
secu.put("svr_all", secu.getInteger("svr_all") + Integer.parseInt(map.get("count").toString()));
|
|
|
}
|
|
|
}
|
|
|
result.put("secu",secu);
|
|
|
|
|
|
/************************ 安防、紧急总数********/
|
|
|
sql = " select count(distinct ord.id) from base_emergency_assistance_order ord INNER JOIN base_patient p on ord.patient = p.id and p.del=1 INNER JOIN base_patient_helper ph on ord.patient = ph.patient and ph.del=1 " +
|
|
|
" where ph.doctor='"+doctor+"' " ;
|
|
|
Long emeCount = jdbcTemplate.queryForObject(sql+olderFilter.replace("{patient}","p.id"),Long.class);
|
|
|
emeAndSecu.put("emeAll",emeCount);
|
|
|
sql = "select count(distinct ord.id) count from base_security_monitoring_order ord INNER JOIN base_patient p on ord.patient = p.id and p.del=1 " +
|
|
|
" INNER JOIN base_patient_helper ph on p.id = ph.patient and ph.del=1 where ph.doctor='"+doctor+"' ";
|
|
|
fliter = " ";
|
|
|
Long secuCount = jdbcTemplate.queryForObject(sql+olderFilter.replace("{patient}","p.id"),Long.class);
|
|
|
emeAndSecu.put("secuAll",secuCount);
|
|
|
result.put("emeAndSecu",emeAndSecu);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
}
|