| 
					
				 | 
			
			
				@ -6,13 +6,16 @@ import com.yihu.jw.care.dao.security.BaseEmergencyWarnLogDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.PageEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.IdCardUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.Iterator; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * Created by yeshijie on 2022/1/18. 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -25,6 +28,8 @@ public class WlyygcStatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseEmergencyWarnLogDao logDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /***************************************************华联社区******************************************************/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 社区签约老人数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -349,7 +354,6 @@ public class WlyygcStatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return PageEnvelop.getSuccessListWithPage("查询成功",res,page,size,total); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop deviceList(String code,Integer page,Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (page == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            page = 1; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -404,4 +408,330 @@ public class WlyygcStatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,total); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /***************************************************所有社区******************************************************/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     *老人基本信息 居民标签 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop oldInfo(Integer page, Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (page == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            page = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (size == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            size = 10; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patientInfoSql="SELECT DISTINCT" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " a.`name` AS `name`," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " TIMESTAMPDIFF(YEAR, a.birthday, CURDATE()) AS age," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " a.address AS address," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " a.residential_area AS residential_area," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " '老人' AS type," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " a.sign_status * 1 AS signStatus," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " a.archive_status * 1 AS archiveStatus," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " l.label_name AS labelName," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " a.id as id" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_patient a LEFT JOIN " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_patient_label l ON a.id = l.patient" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " a.archive_type = 1" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND a.del = '1' and  l.label_type = 1 limit " + (page - 1)*size + "," + size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> maps = jdbcTemplate.queryForList(patientInfoSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //删除测试老人数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Iterator<Map<String, Object>> iterator = maps.iterator(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, String> signOlderMap = removeTestOld(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        while (iterator.hasNext()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String, Object> next = iterator.next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (!signOlderMap.containsValue(next.get("id").toString())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                iterator.remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return  PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,Long.parseLong(maps.size()+"")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 老人签约信息 签约团队 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop signOldInfo(String patient,Integer page, Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String signOld = "SELECT" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " DATE_FORMAT(pr.create_time,'%Y-%m-%d') AS createTime," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.`name` AS serName," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.type AS serType," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.org_name AS serOrgName," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " sr.sign_doctor_name AS signDoctorName," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.name AS teamName" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_service_package_sign_record sr " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_service_package_record pr ON sr.id = pr.sign_id" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_service_package p ON pr.service_package_id = p.id" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_team t ON t.id = pr.team_code" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  sr.status=1" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND p.del = '1'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.del = '1'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND sr.patient = '"+patient+"' limit " + (page - 1)*size + "," + size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> maps = jdbcTemplate.queryForList(signOld); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,Long.parseLong(maps.size()+"")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 紧急预警信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop emeAndsecinfo(Integer page,Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String emeSql = "SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " eao.patient AS patient, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " eao.patient_name AS patientName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " eao.org_name AS orgName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " eao.serve_address AS serveAddress, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " eao.doctor_name AS doctorName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " DATE_FORMAT(eao.create_time,'%Y-%m-%d')  AS createTime," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " eao.type AS type," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " '紧急呼叫' serve_desc," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " eao.`status` AS `status`," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " DATE_FORMAT(eao.complete_time,'%Y-%m-%d') as completeTime," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " DATE_FORMAT(wdr.response_time,'%Y-%m-%d')  AS responseTime" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_emergency_assistance_order eao LEFT JOIN base_emergency_warn_doctor_response wdr ON eao.id = wdr.order_id limit " + (page - 1)*size + "," + size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String secSql = "SELECT DISTINCT" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " mo.patient AS patient," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " mo.patient_name AS patientName," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " mo.doctor_name AS doctorName," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " mo.serve_desc AS serveDesc," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " mo.serve_address AS serveAddress," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " DATE_FORMAT(mo.create_time,'%Y-%m-%d')  AS createTime," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " DATE_FORMAT(mo.complete_time,'%Y-%m-%d')  AS completeTime," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " DATE_FORMAT(mo.service_response_time,'%Y-%m-%d')  AS responseTime," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " mo.order_source AS orderSource," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " mo.type AS type," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " mo.`status` AS `status`" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_security_monitoring_order mo limit " + (page - 1)*size + "," + size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> emeList = jdbcTemplate.queryForList(emeSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> secList = jdbcTemplate.queryForList(secSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        emeList.addAll(secList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, String> jkzlUserMap = removeTestUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Iterator<Map<String, Object>> iterator = emeList.iterator(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        while (iterator.hasNext()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String, Object> next = iterator.next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (jkzlUserMap.containsValue(next.get("patient"))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                iterator.remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return PageEnvelop.getSuccessListWithPage("查询成功",emeList,page,size,Long.parseLong(emeList.size()+"")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 设备信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop deviceLists(Integer page,Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String deviceSql = "SELECT DISTINCT" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.`name`," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.id," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " pd.device_sn AS deviceSn," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " pd.device_name AS deviceName," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wd.device_type as deviceType," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " pd.category_code as categoryCode  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_patient_device pd," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_devices wd," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_patient p" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.id = pd.`user` AND" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wd.device_code = pd.device_sn limit " + (page - 1)*size + "," + size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> maps = jdbcTemplate.queryForList(deviceSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, String> jkzlUserMap = removeTestUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Iterator<Map<String, Object>> iterator = maps.iterator(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        while (iterator.hasNext()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String, Object> next = iterator.next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (jkzlUserMap.containsValue(next.get("patient"))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                iterator.remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,Long.parseLong(maps.size()+"")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //1血糖仪,2.血压计,3药盒,4智能手表,7 = 居家报警器,12 监控器 13 睡眠带 14气感报警器 15烟感报警器 16拐杖 17随身wifi 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String, Object>> deviceCollectInfo(String deviceSN,String code,String startDate,String endDate){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        switch (code){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case "14": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //烟感气感实时数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql = "SELECT device_sn,device_type,value,unit,DATE_FORMAT(create_time,'%Y-%m-%d') as create_time,temperature_value,power_value FROM base_device_health_index WHERE device_sn = '"+deviceSN+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case "16": //拐杖 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql = "SELECT lat,lon,DATE_FORMAT(create_time,'%Y-%m-%d') as create_time FROM base_yxdevice_index WHERE sn = '"+deviceSN+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case "13": //睡眠带 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql = "SELECT * FROM base_sleep_device WHERE device_sn = '"+deviceSN+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case "4": //智能手表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql = "SELECT sleep_time,deep_sleep,light_sleep,awake_time,interval_time,total,del,DATE_FORMAT(create_time,'%Y-%m-%d') as create_time FROM base_sleep_x1device WHERE device_sn = '"+deviceSN+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(startDate)&&StringUtils.isNotBlank(endDate)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND create_time >= '"+startDate+"' AND create_time <='"+endDate+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += " ORDER BY create_time"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 生活照料 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop lifeCareList(Integer page,Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (null==page||0==page){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            page = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (null==size||0==size) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            size = 10; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql ="SELECT DISTINCT" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " co.proxy_patient_name," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " co.patient_name AS patientName," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " co.serve_address AS serveAddress," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " DATE_FORMAT(co.create_time,'%Y-%m-%d') AS createTime," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " DATE_FORMAT(co.complete_time,'%Y-%m-%d') AS completeTime," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " co.doctor_name AS doctorName," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " fd.`name` AS lifeCareName," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " co.`status` AS `status`," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " co.conclusion_remark AS remark" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_life_care_order co" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_life_care_fee_detail fd ON co.id = fd.order_id ORDER BY co.create_time DESC LIMIT "+(page-1)*size+","+size+""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, String> jkzlUserMap = removeTestUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Iterator<Map<String, Object>> iterator = maps.iterator(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        while (iterator.hasNext()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String, Object> next = iterator.next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (jkzlUserMap.containsValue(next.get("patientName"))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                iterator.remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,Long.parseLong(maps.size()+"")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 幼儿信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop infantInfo(Integer page,Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String infantSql = "SELECT DISTINCT" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.id AS id," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.address AS address," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p. NAME AS `name`," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t. STATUS AS `status`," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o. NAME AS `orgName`" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_patient p" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_doctor_patient_tmp t ON t.patient = p.id" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_org o ON t.org_code = o. CODE" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.archive_type = 2" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.del = 1" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND p.del = 1" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " and o.type = 4 ORDER BY p.create_time DESC LIMIT "+(page-1)*size+","+page+""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> infantList = jdbcTemplate.queryForList(infantSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, String> jkzlUserRem = removeTestUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Iterator<Map<String, Object>> iterator = infantList.iterator(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        while (iterator.hasNext()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String, Object> next = iterator.next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (jkzlUserRem.containsValue(next.get("id"))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                iterator.remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                next.put("age",IdCardUtil.getAgeForIdcard(next.get("idcard").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return PageEnvelop.getSuccessListWithPage("查询成功",infantList,page,size,Long.parseLong(infantList.size()+"")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 上门辅导 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop doorServiceOrder(Integer page,Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String serviceSql ="SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " so.serve_address AS serveAddress, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " so.proxy_patient_name AS ppName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " so.patient_name AS pName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " so.patient AS patient," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " DATE_FORMAT(so.create_time,'%Y-%m-%d')  AS createTime, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " DATE_FORMAT(so.service_response_time,'%Y-%m-%d')  AS serviceTime, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " so.doctor_name AS  doctorName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " dc.`name` AS serveName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " DATE_FORMAT(so.complete_time,'%Y-%m-%d')  AS completeTime, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " so.`status` AS `status`, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " fd.conclusion AS conclusion " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_door_coach_order so " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_door_coach_fee_detail dc ON so.id = dc.order_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_door_coach_conclusion fd ON so.id = fd.order_id "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> lists = jdbcTemplate.queryForList(serviceSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, String> jkzlUserRm = removeTestUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Iterator<Map<String, Object>> iterator = lists.iterator(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        while (iterator.hasNext()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String, Object> next = iterator.next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (jkzlUserRm.containsValue(next.get("patient"))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                iterator.remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return PageEnvelop.getSuccessListWithPage("查询成功",lists,page,size,Long.parseLong(lists.size()+"")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 排除测试数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,String>  removeTestOrg(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String filterOrg = "";//排除的测试机构 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlOgr = "SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' and dict_code is not null "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<String> Orglist =  jdbcTemplate.queryForList(sqlOgr,String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,String> jkzlOrgMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(Orglist.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jkzlOrgMap = Orglist.stream().collect(Collectors.toMap(String::toString,String::toString)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filterOrg = " '" +String.join("','",Orglist)+ "' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return jkzlOrgMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //排除的测试用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String, String> removeTestUser() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String filterUser = " "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqltmp = "SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_child' or dict_name = 'jkzl_older' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  or dict_name = 'jkzl_user' or dict_name = 'jkzl_helper'  or dict_name = 'jkzl_teacher' ) and dict_code is not null"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<String> listtmp = jdbcTemplate.queryForList(sqltmp, String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, String> jkzlUserMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (listtmp.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jkzlUserMap = listtmp.stream().collect(Collectors.toMap(String::toString, String::toString)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filterUser = " '" + String.join("','", listtmp) + "' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return jkzlUserMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //测试 签约老人id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,String> removeTestOld(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String signOlderSql="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " 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 DISTINCT dict_code from wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_child' or dict_name = 'jkzl_older' or dict_name = 'jkzl_user' or dict_name = 'jkzl_helper'  or dict_name = 'jkzl_teacher' ) and dict_code is not null ) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE p.del = 1 and p.archive_type =1  " ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<String> signOlderList = jdbcTemplate.queryForList(signOlderSql,String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,String> signOlderMap = signOlderList.stream().collect(Collectors.toMap(String::toString,String::toString)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return signOlderMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |