|
@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@ -17,14 +18,23 @@ public class WlyygcStatisticsService {
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 社区签约老人数量
|
|
|
* @return
|
|
|
*/
|
|
|
public Integer signOlderNum(){
|
|
|
public Integer signOlderNum(String code){
|
|
|
String sql = "select count(DISTINCT p.id) FROM " +
|
|
|
"base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 and p.id not in (SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older') " +
|
|
|
"WHERE p.del = 1 and p.archive_type =1";
|
|
|
"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 "+
|
|
|
"WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id";
|
|
|
|
|
|
if("1".equals(code)){
|
|
|
//1华联社区
|
|
|
sql += " and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
|
|
|
}else {
|
|
|
return 0;
|
|
|
}
|
|
|
Integer res = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
return res;
|
|
|
}
|
|
@ -33,11 +43,22 @@ public class WlyygcStatisticsService {
|
|
|
* 绑定设备在线数量,绑定设备总数
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject deviceInfo(){
|
|
|
public JSONObject deviceInfo(String code){
|
|
|
JSONObject json = new JSONObject();
|
|
|
Integer total = 0;
|
|
|
Integer online = 0;
|
|
|
String sql = "SELECT IFNULL(contact_status,2) contact_status,COUNT(*) c from wlyy_devices WHERE is_binding = 1 GROUP BY contact_status ";
|
|
|
String sql = "select count(DISTINCT d.id),d.contact_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, wlyy_patient_device pd ,wlyy_devices d " +
|
|
|
"WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
|
|
|
"and p.id = pd.`user` and d.device_code = pd.device_sn ";
|
|
|
if("1".equals(code)){
|
|
|
//1华联社区
|
|
|
sql += " and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
|
|
|
}else {
|
|
|
return json;
|
|
|
}
|
|
|
sql += " GROUP BY d.contact_status ";
|
|
|
List<Map<String,Object>> res = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map : res){
|
|
|
Integer num = Integer.valueOf(map.get("c").toString());
|