|  | @ -89,48 +89,43 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public MixEnvelop<Map<String,Object>, Map<String,Object>> findRehabilitationPlan(Integer doctorType,String doctorCode, String diseaseCode, Integer planType,Integer todaybacklog, String patientCondition,Integer page, Integer pageSize) throws Exception{
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String leftSql = "";
 | 
	
		
			
				|  |  |         String sql = " select p.*  from wlyy_specialist.wlyy_patient_rehabilitation_plan p  " ;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String sql = " select DISTINCT p.* " +
 | 
	
		
			
				|  |  |                 " from wlyy_specialist.wlyy_rehabilitation_plan_detail a INNER JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p " +
 | 
	
		
			
				|  |  |                 " on a.plan_id = p.id  " ;
 | 
	
		
			
				|  |  |         if(doctorType==2){//家医是根据签约关系过滤
 | 
	
		
			
				|  |  |             leftSql =" join "+basedb+".wlyy_sign_family f on f.patient=p.patient and f.expenses_status='1' and f.status=1 ";
 | 
	
		
			
				|  |  |             leftSql+=" and (f.doctor='"+doctorCode+"' or f.doctor_health='"+doctorCode+"') ";
 | 
	
		
			
				|  |  |             sql.replace("from", ",f.idcard,f.hospital_name from");
 | 
	
		
			
				|  |  |             sql += leftSql;
 | 
	
		
			
				|  |  |             sql+=" INNER JOIN wlyy.wlyy_sign_family f ON f.patient = p.patient \n" +
 | 
	
		
			
				|  |  |                     "\tand f.expenses_status=1\n" +
 | 
	
		
			
				|  |  |                     "\tAND f.STATUS >= 1 \n" +
 | 
	
		
			
				|  |  |                     "\tAND ( f.doctor = '"+doctorCode+"' OR f.doctor_health = '"+doctorCode+"' )  ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql += " where 1=1 ";
 | 
	
		
			
				|  |  |         if(todaybacklog!=null&&todaybacklog==1){
 | 
	
		
			
				|  |  |             String todayStart = DateUtil.getStringDateShort()+" "+"00:00:00";
 | 
	
		
			
				|  |  |             String todayEnd = DateUtil.getStringDateShort()+" "+"23:59:59";
 | 
	
		
			
				|  |  |             sql += " and a.execute_time>='"+todayStart+"' and a.execute_time<='"+todayEnd+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(planType!=null){
 | 
	
		
			
				|  |  |             sql += " and p.plan_type="+planType;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotEmpty(diseaseCode)){
 | 
	
		
			
				|  |  |             sql+=" and p.disease='"+diseaseCode+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotEmpty(patientCondition)){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             sql += " and " + AesEncryptUtils.decryptMysqlNo("p.name") + " like '%"+patientCondition+"%' ";
 | 
	
		
			
				|  |  |         if(StringUtils.isNotEmpty(patientCondition)){//姓名idcard模糊查询
 | 
	
		
			
				|  |  |             sql +=" AND EXISTS (select code from wlyy.wlyy_patient where  `code` = p.patient and ( `name` LIKE '%"+patientCondition+"%' or idcard like '%"+patientCondition+"%') )";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (doctorType==1){
 | 
	
		
			
				|  |  |             sql +=" AND (p.create_user = '"+doctorCode+"' \n" +
 | 
	
		
			
				|  |  |                     "\tOR a.doctor = '"+doctorCode+"' ) ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.wlyy_patient_rehabilitation_planAll2(sql);
 | 
	
		
			
				|  |  |         String finalSql = "";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String todayStart = DateUtil.getStringDateShort()+" "+"00:00:00";
 | 
	
		
			
				|  |  |         String todayEnd = DateUtil.getStringDateShort()+" "+"23:59:59";
 | 
	
		
			
				|  |  |         String condition ="";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(todaybacklog!=null&&todaybacklog==1){
 | 
	
		
			
				|  |  |             condition += " and execute_time>='"+todayStart+"' and execute_time<='"+todayEnd+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         finalSql =" select DISTINCT b.* from (select  plan_id,doctor from wlyy_specialist.wlyy_rehabilitation_plan_detail where  1=1 "+condition+") a " +
 | 
	
		
			
				|  |  |                 " JOIN ("+sql+") b on a.plan_id=b.id ";
 | 
	
		
			
				|  |  |         if(doctorType==1){//专科医生是根据计划的创建者字段过滤
 | 
	
		
			
				|  |  |             finalSql += " where  b.create_user = '"+doctorCode+"' or a.doctor ='"+doctorCode+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(finalSql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         int count = 0;
 | 
	
		
			
				|  |  |         if(rstotal!=null&&rstotal.size()>0&&rstotal.get(0).get("id")!=null){
 | 
	
		
			
				|  |  |             count = rstotal.size();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         finalSql += " ORDER BY b.create_time DESC LIMIT "+(page-1)*pageSize+","+pageSize;
 | 
	
		
			
				|  |  |         List<Map<String,Object>> patientRehabilitationPlanDOList = jdbcTemplate.queryForList(finalSql);
 | 
	
		
			
				|  |  |         sql += " ORDER BY p.create_time DESC LIMIT "+(page-1)*pageSize+","+pageSize;
 | 
	
		
			
				|  |  |         List<Map<String,Object>> patientRehabilitationPlanDOList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> resultList = new ArrayList<>();
 | 
	
		
			
				|  |  |         if(patientRehabilitationPlanDOList.size()>0&&patientRehabilitationPlanDOList.get(0).get("id")!=null){
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -1198,14 +1193,17 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |                 detailDO.setRelationCode(relationCode);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             rehabilitationDetailDao.save(detailDO);
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(node)){
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(image)&&StringUtils.isNoneBlank(node)){
 | 
	
		
			
				|  |  |                 int j = rehabilitationOperateRecordsDao.updateNodeAndRelationRecordImg(node,image,planDeatilId);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             else if (StringUtils.isNoneBlank(node)){
 | 
	
		
			
				|  |  |                 int j = rehabilitationOperateRecordsDao.updateNodeByPlanDetailId(node,planDeatilId);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(image)){//
 | 
	
		
			
				|  |  |             else if (StringUtils.isNoneBlank(image)){//
 | 
	
		
			
				|  |  |                 int j = rehabilitationOperateRecordsDao.updateImagByPlanDetailId(image,planDeatilId);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(image)&&StringUtils.isNoneBlank(node)){
 | 
	
		
			
				|  |  |                 int j = rehabilitationOperateRecordsDao.updateNodeAndRelationRecordImg(node,image,planDeatilId);
 | 
	
		
			
				|  |  |             else{//跟新为已完成
 | 
	
		
			
				|  |  |                 int j = rehabilitationOperateRecordsDao.updateStatus(1,planDeatilId);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //如果整个计划的服务项都完成了,整个计划也完成了
 | 
	
		
			
				|  |  |             String allSql ="SELECT * FROM wlyy_rehabilitation_plan_detail where plan_id = (SELECT plan_id FROM `wlyy_rehabilitation_plan_detail` WHERE id='"+planDeatilId+"')";
 |