|  | @ -13,6 +13,7 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.im.util.ImUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.dao.BasePatientDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.service.BasePatientMedicardCardService;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.ResponseContant;
 | 
	
	
		
			
				|  | @ -59,6 +60,8 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
 | 
	
		
			
				|  |  |     private CapacityAssessmentRecordService capacityAssessmentRecordService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientFamilyMemberService familyMemberService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private ImUtil imUtil;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 签约记录
 | 
	
	
		
			
				|  | @ -389,4 +392,134 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param type 类型:1幼儿,2老人,3助老员,4医生。不传返回四个类型的数据
 | 
	
		
			
				|  |  |      * @param name 姓名
 | 
	
		
			
				|  |  |      * @param residentialArea 居住小区
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject findUserByType(String type,String name,String residentialArea,Integer page,Integer size){
 | 
	
		
			
				|  |  |         JSONObject re = new JSONObject();
 | 
	
		
			
				|  |  |         if(page == null){
 | 
	
		
			
				|  |  |             page = 1;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(size == null){
 | 
	
		
			
				|  |  |             size = 3;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String online= imUtil.getOnlineListByType(null);
 | 
	
		
			
				|  |  |         JSONObject json = JSON.parseObject(online).getJSONObject("data");
 | 
	
		
			
				|  |  |         String limit = " limit "+(page-1)*size+","+size;
 | 
	
		
			
				|  |  |         if("1".equals(type)||StringUtil.isBlank(type)){
 | 
	
		
			
				|  |  |             List<Map<String,Object>> list = findChild(name,residentialArea,limit,json.getJSONObject("child"));
 | 
	
		
			
				|  |  |             re.put("child",list);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if("2".equals(type)||StringUtil.isBlank(type)){
 | 
	
		
			
				|  |  |             List<Map<String,Object>> list = findOld(name,residentialArea,limit,json);
 | 
	
		
			
				|  |  |             re.put("old",list);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if("3".equals(type)||StringUtil.isBlank(type)){
 | 
	
		
			
				|  |  |             List<Map<String,Object>> list = findHelper(name,limit,json.getJSONObject("helper"));
 | 
	
		
			
				|  |  |             re.put("helper",list);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return re;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查找幼儿
 | 
	
		
			
				|  |  |      * @param name
 | 
	
		
			
				|  |  |      * @param residentialArea
 | 
	
		
			
				|  |  |      * @param limit
 | 
	
		
			
				|  |  |      * @param json
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> findChild(String name,String residentialArea,String limit,JSONObject json){
 | 
	
		
			
				|  |  |         String sql = "SELECT id,name,photo from base_patient WHERE archive_type = 2 and del = '1' ";
 | 
	
		
			
				|  |  |         if(!StringUtil.isBlank(name)){
 | 
	
		
			
				|  |  |             sql+= " and name like '%"+name+"%' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(!StringUtil.isBlank(residentialArea)){
 | 
	
		
			
				|  |  |             sql+= " and residential_area = '"+residentialArea+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql+=limit;
 | 
	
		
			
				|  |  |         List<Map<String,Object>>  list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         String sqlCount = "SELECT COUNT(*) from base_door_coach_order where `status` = 6";
 | 
	
		
			
				|  |  |         for (Map<String,Object> map:list){
 | 
	
		
			
				|  |  |             String paientId = map.get("id").toString();
 | 
	
		
			
				|  |  |             String filter = " and patient = '"+paientId+"'";
 | 
	
		
			
				|  |  |             Integer count = jdbcTemplate.queryForObject(sqlCount+filter,Integer.class);
 | 
	
		
			
				|  |  |             map.put("online",json.containsKey(paientId));
 | 
	
		
			
				|  |  |             map.put("doorCoach",count);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查找老人
 | 
	
		
			
				|  |  |      * @param name
 | 
	
		
			
				|  |  |      * @param residentialArea
 | 
	
		
			
				|  |  |      * @param limit
 | 
	
		
			
				|  |  |      * @param json
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> findOld(String name,String residentialArea,String limit,JSONObject json){
 | 
	
		
			
				|  |  |         String sql = "SELECT id,name,photo from base_patient WHERE archive_type = 1 and del = '1' ";
 | 
	
		
			
				|  |  |         if(!StringUtil.isBlank(name)){
 | 
	
		
			
				|  |  |             sql+= " and name like '%"+name+"%' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(!StringUtil.isBlank(residentialArea)){
 | 
	
		
			
				|  |  |             sql+= " and residential_area = '"+residentialArea+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         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 ";
 | 
	
		
			
				|  |  |         for (Map<String,Object> map:list){
 | 
	
		
			
				|  |  |             String paientId = map.get("id").toString();
 | 
	
		
			
				|  |  |             String filter = " and patient = '"+paientId+"'";
 | 
	
		
			
				|  |  |             Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class);
 | 
	
		
			
				|  |  |             Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class);
 | 
	
		
			
				|  |  |             Integer security = jdbcTemplate.queryForObject(sqlSecurity+filter,Integer.class);
 | 
	
		
			
				|  |  |             map.put("onlinePad",json.getJSONObject("olderPad").containsKey(paientId));
 | 
	
		
			
				|  |  |             map.put("onlineWx",json.getJSONObject("olderWx").containsKey(paientId));
 | 
	
		
			
				|  |  |             map.put("lifeCare",lifeCare);
 | 
	
		
			
				|  |  |             map.put("emergency",emergency);
 | 
	
		
			
				|  |  |             map.put("security",security);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查找助老员
 | 
	
		
			
				|  |  |      * @param name
 | 
	
		
			
				|  |  |      * @param limit
 | 
	
		
			
				|  |  |      * @param json
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> findHelper(String name,String limit,JSONObject json){
 | 
	
		
			
				|  |  |         String sql = "SELECT id,name,photo from base_doctor WHERE doctor_level = 2 and del = '1' ";
 | 
	
		
			
				|  |  |         if(!StringUtil.isBlank(name)){
 | 
	
		
			
				|  |  |             sql+= " and name like '%"+name+"%' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         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 ";
 | 
	
		
			
				|  |  |         for (Map<String,Object> map:list){
 | 
	
		
			
				|  |  |             String doctorId = map.get("id").toString();
 | 
	
		
			
				|  |  |             String filter = " and doctor = '"+doctorId+"'";
 | 
	
		
			
				|  |  |             Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class);
 | 
	
		
			
				|  |  |             Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class);
 | 
	
		
			
				|  |  |             Integer security = jdbcTemplate.queryForObject(sqlSecurity+filter,Integer.class);
 | 
	
		
			
				|  |  |             map.put("online",json.containsKey(doctorId));
 | 
	
		
			
				|  |  |             map.put("lifeCare",lifeCare);
 | 
	
		
			
				|  |  |             map.put("emergency",emergency);
 | 
	
		
			
				|  |  |             map.put("security",security);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |