|
@ -27,6 +27,7 @@ import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import com.yihu.utils.security.MD5;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@ -576,8 +577,8 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
|
|
|
*/
|
|
|
public List<Map<String,Object>> findOld(String name,String residentialArea,String limit,String filter1){
|
|
|
String sql = "SELECT a.id,a.name,a.photo,a.idcard,CAST(IFNULL(a.birthday,'') AS char ) birthday,a.residential_area residentialArea,a.sex " +
|
|
|
", GROUP_CONCAT(DISTINCT d.category_code) deviceFlag,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online,IFNULL(sign_status,0) signStatus from base_patient a " +
|
|
|
" LEFT JOIN wlyy_patient_device d on d.`user`=a.id WHERE a.archive_type = 1 and a.del = '1' ";
|
|
|
", case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online,IFNULL(sign_status,0) signStatus from base_patient a " +
|
|
|
" WHERE a.archive_type = 1 and a.del = '1' ";
|
|
|
|
|
|
//case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online
|
|
|
//if(openid is null,0,1) onlineWx,IFNULL(a.on_line,0) onlinePad
|
|
@ -588,15 +589,17 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
|
|
|
sql+= " and residential_area = '"+residentialArea+"' ";
|
|
|
}
|
|
|
sql += filter1;
|
|
|
sql += " GROUP BY a.id,a.name,a.photo,a.idcard,a.birthday,a.residential_area,a.sex,on_line,signStatus ";
|
|
|
sql += " ORDER BY a.on_line desc,signStatus desc";
|
|
|
sql += " GROUP BY a.id,a.name,a.photo,a.idcard,a.birthday,a.residential_area,a.sex,online,signStatus ";
|
|
|
sql += " ORDER BY online desc,signStatus desc";
|
|
|
sql += limit;
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
String sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
|
|
|
String sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order where `status` = 0";
|
|
|
String sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order where `status` = 7 ";
|
|
|
String sqlDevice = "SELECT category_code deviceFlag, IFNULL(online_status,0) status from wlyy_patient_device ";
|
|
|
for (Map<String,Object> map:list){
|
|
|
String paientId = map.get("id").toString();
|
|
|
String filterDevice = " WHERE user = '"+paientId+"' ORDER BY deviceFlag,status desc";
|
|
|
String idcardNo = map.get("idcard") + "";
|
|
|
Date birthday = DateUtil.strToDate(map.get("birthday").toString());
|
|
|
Integer age = IdCardUtil.getAgeByIdcardOrBirthday(idcardNo,birthday);
|
|
@ -605,9 +608,21 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
|
|
|
Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class);
|
|
|
Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class);
|
|
|
Integer security = jdbcTemplate.queryForObject(sqlSecurity+filter,Integer.class);
|
|
|
List<Map<String,Object>> deviceList = jdbcTemplate.queryForList(sqlDevice+filterDevice);
|
|
|
Iterator it = deviceList.listIterator();
|
|
|
Map<Object,Object> deviceMap = new HashedMap();
|
|
|
while (it.hasNext()){
|
|
|
Map<String,Object> tmp = (Map<String,Object>)it.next();
|
|
|
if(deviceMap.containsKey(tmp.get("deviceFlag"))){
|
|
|
it.remove();
|
|
|
}else{
|
|
|
deviceMap.put(tmp.get("deviceFlag"),tmp.get("deviceFlag"));
|
|
|
}
|
|
|
}
|
|
|
map.put("lifeCare",lifeCare);
|
|
|
map.put("emergency",emergency);
|
|
|
map.put("security",security);
|
|
|
map.put("devices",deviceList);
|
|
|
}
|
|
|
return list;
|
|
|
}
|