|
@ -1,6 +1,10 @@
|
|
|
package com.yihu.jw.care.service.statistics;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.care.dao.security.BaseEmergencyWarnLogDao;
|
|
|
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
@ -17,7 +21,8 @@ public class WlyygcStatisticsService {
|
|
|
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Autowired
|
|
|
private BaseEmergencyWarnLogDao logDao;
|
|
|
|
|
|
/**
|
|
|
* 社区签约老人数量
|
|
@ -72,4 +77,163 @@ public class WlyygcStatisticsService {
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 紧急救助和安防监控数量
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject emeAndSec(String code){
|
|
|
JSONObject json = new JSONObject();
|
|
|
String sqlEme = "select count(DISTINCT o.id) c,o.status FROM " +
|
|
|
"base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
|
|
|
", base_service_package_record r, base_emergency_assistance_order o " +
|
|
|
"WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
|
|
|
"and p.id = o.patient ";
|
|
|
String sqlSec = "select count(DISTINCT o.id) c,o.status FROM " +
|
|
|
"base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
|
|
|
", base_service_package_record r, base_security_monitoring_order o " +
|
|
|
"WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
|
|
|
"and p.id = o.patient ";
|
|
|
|
|
|
String filter = "";
|
|
|
if("1".equals(code)){
|
|
|
filter += " and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
|
|
|
}else {
|
|
|
return json;
|
|
|
}
|
|
|
filter += " GROUP BY o.status";
|
|
|
|
|
|
Integer emeTotla = 0;
|
|
|
Integer emeErrorWarning = 0;
|
|
|
Integer emeCancel = 0;
|
|
|
Integer emeComplete = 0;
|
|
|
Integer emeApply = 0;
|
|
|
|
|
|
Integer secTotla = 0;
|
|
|
Integer secErrorWarning = 0;
|
|
|
Integer secCancel = 0;
|
|
|
Integer secComplete = 0;
|
|
|
Integer secApply = 0;
|
|
|
|
|
|
List<Map<String,Object>> res1 = jdbcTemplate.queryForList(sqlEme + filter);
|
|
|
for (Map<String,Object> map : res1){
|
|
|
Integer num = Integer.valueOf(map.get("c").toString());
|
|
|
String status = map.get("status")+"";
|
|
|
emeTotla += num;
|
|
|
if("1".equals(status)){
|
|
|
emeApply = num;
|
|
|
continue;
|
|
|
}
|
|
|
if("0".equals(status)){
|
|
|
emeComplete = num;
|
|
|
continue;
|
|
|
}
|
|
|
if("-1".equals(status)){
|
|
|
emeCancel = num;
|
|
|
continue;
|
|
|
}
|
|
|
if("-2".equals(status)){
|
|
|
emeErrorWarning = num;
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
List<Map<String,Object>> res2 = jdbcTemplate.queryForList(sqlSec + filter);
|
|
|
for (Map<String,Object> map : res2){
|
|
|
Integer num = Integer.valueOf(map.get("c").toString());
|
|
|
String status = map.get("status")+"";
|
|
|
secTotla += num;
|
|
|
if("1".equals(status)){
|
|
|
secApply = num;
|
|
|
continue;
|
|
|
}
|
|
|
if("0".equals(status)){
|
|
|
secComplete = num;
|
|
|
continue;
|
|
|
}
|
|
|
if("-1".equals(status)){
|
|
|
secCancel = num;
|
|
|
continue;
|
|
|
}
|
|
|
if("-2".equals(status)){
|
|
|
secErrorWarning = num;
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
json.put("secTotla",secTotla);
|
|
|
json.put("secApply",secApply);
|
|
|
json.put("secComplete",secComplete);
|
|
|
json.put("secCancel",secCancel);
|
|
|
json.put("secErrorWarning",secErrorWarning);
|
|
|
|
|
|
json.put("emeTotla",emeTotla);
|
|
|
json.put("emeApply",emeApply);
|
|
|
json.put("emeComplete",emeComplete);
|
|
|
json.put("emeCancel",emeCancel);
|
|
|
json.put("emeErrorWarning",emeErrorWarning);
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 安防/紧急呼叫概要
|
|
|
* @param page
|
|
|
* @param size
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray emeAndSecInfo(Integer page, Integer size,String code){
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
String filter = "";
|
|
|
if("1".equals(code)){
|
|
|
filter = " and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
|
|
|
}else {
|
|
|
return jsonArray;
|
|
|
}
|
|
|
if(page==null){
|
|
|
page =1;
|
|
|
}
|
|
|
if(size==null){
|
|
|
size = 10;
|
|
|
}
|
|
|
Map<String,String> statusMap = new HashMap<>();
|
|
|
statusMap.put("-1","已取消");
|
|
|
statusMap.put("-2","误报警");
|
|
|
statusMap.put("0","已完成");
|
|
|
statusMap.put("1","申请中");
|
|
|
String sql = "SELECT * from ( " +
|
|
|
"select o.id,p.name,p.idcard,p.residential_area,'1' type,o.serve_address,'紧急呼叫' serve_desc,o.status,o.create_time FROM " +
|
|
|
"base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
|
|
|
", base_service_package_record r, base_emergency_assistance_order o " +
|
|
|
"WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
|
|
|
"and p.id = o.patient " + filter +
|
|
|
"UNION ALL " +
|
|
|
"select o.id,p.name,p.idcard,p.residential_area,'2' type,o.serve_address,o.serve_desc,o.status,o.create_time FROM " +
|
|
|
"base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
|
|
|
", base_service_package_record r, base_security_monitoring_order o " +
|
|
|
"WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
|
|
|
"and p.id = o.patient " + filter +
|
|
|
" ) a ORDER BY a.create_time desc limit "+(page*size)+","+size;
|
|
|
List<Map<String,Object>> res = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map : res){
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("name",map.get("name"));
|
|
|
json.put("age", IdCardUtil.getAgeForIdcard(map.get("idcard")+""));
|
|
|
json.put("residentialArea",map.get("residential_area"));
|
|
|
json.put("type",map.get("type"));
|
|
|
json.put("serveAddress",map.get("serve_address"));
|
|
|
json.put("serveDesc",map.get("serve_desc"));
|
|
|
json.put("status",statusMap.get(map.get("status")+""));
|
|
|
json.put("createTime",map.get("create_time").toString().substring(0,19));
|
|
|
String orderLogInfo = "";
|
|
|
List<BaseEmergencyWarnLogDO> logDOS = logDao.findByOrderIdOrderByCreateTimeDesc(map.get("id")+"");
|
|
|
if(logDOS.size()>0){
|
|
|
BaseEmergencyWarnLogDO warnLogDO = logDOS.get(0);
|
|
|
orderLogInfo = warnLogDO.getUserName()+":"+warnLogDO.getContent();
|
|
|
}
|
|
|
json.put("orderLogInfo",orderLogInfo);
|
|
|
jsonArray.add(json);
|
|
|
}
|
|
|
return jsonArray;
|
|
|
}
|
|
|
|
|
|
}
|