|  | @ -1,12 +1,15 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.care.service.doctor;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachOrderDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.care.service.role.RoleService;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.DoctorSpecialDiseaseDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.im.service.ImService;
 | 
	
		
			
				|  |  | import com.yihu.jw.org.dao.BaseOrgDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.PageEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.IdCardUtil;
 | 
	
	
		
			
				|  | @ -50,6 +53,10 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |     private BaseDoctorHospitalDao doctorHospitalDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private JdbcTemplate jdbcTemplate;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoorCoachOrderDao baseDoorCoachOrderDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private ImService imService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取医生详情
 | 
	
	
		
			
				|  | @ -228,14 +235,14 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = new ArrayList<>();
 | 
	
		
			
				|  |  |         //未入学
 | 
	
		
			
				|  |  |         String sql0 = "select Distinct sor.patient from base_course_sales_order_record sor INNER JOIN base_course bc on sor.course_id = bc.id " +
 | 
	
		
			
				|  |  |                 " and bc.del=1 where bc.doctor ='"+doctor+"'  and sor.`status` =5 and not EXISTS (select DISTINCT rsr.patient " +
 | 
	
		
			
				|  |  |                 " and bc.del=1 where bc.doctor ='"+doctor+"'  and sor.`status` =2 and not EXISTS (select DISTINCT rsr.patient " +
 | 
	
		
			
				|  |  |                 " from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` and org.del=1 " +
 | 
	
		
			
				|  |  |                 " INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where rsr.patient=sor.patient and " +
 | 
	
		
			
				|  |  |                 " dh.doctor_code='"+doctor+"'   and rsr.del<>0  and rsr.`status` = 3  )";
 | 
	
		
			
				|  |  |                 " dh.doctor_code='"+doctor+"'   and rsr.del<>0  and rsr.`status` = 2  )";
 | 
	
		
			
				|  |  |         //已入学
 | 
	
		
			
				|  |  |         String sql1=" select DISTINCT rsr.patient from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` " +
 | 
	
		
			
				|  |  |                 "and org.del=1 INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where dh.doctor_code='"+doctor+"' " +
 | 
	
		
			
				|  |  |                 "and rsr.del<>0  and rsr.`status` = 3 GROUP BY dh.doctor_code  ";
 | 
	
		
			
				|  |  |                 "and rsr.del<>0  and rsr.`status` = 2 GROUP BY dh.doctor_code  ";
 | 
	
		
			
				|  |  |         String sql = "select p.id,p.name,p.photo,p.sex,p.idcard,p.openid,p.mobile,group_concat( pd.category_code) deviceType from ( {sqlReplace} )tmp Inner JOIN base_patient p on tmp.patient  = p.id " +
 | 
	
		
			
				|  |  |                 " LEFT JOIN wlyy_patient_device pd on pd.`user`=p.id and pd.category_code BETWEEN 1 and 2 GROUP BY p.id ";
 | 
	
		
			
				|  |  |         String sqlcpunt = "select count(Distinct p.id) from ( {sqlReplace} )tmp Inner JOIN base_patient p on tmp.patient  = p.id " +
 | 
	
	
		
			
				|  | @ -275,14 +282,14 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |         Map<String,Long> result = new HashMap<>();
 | 
	
		
			
				|  |  |         //未入学
 | 
	
		
			
				|  |  |         String sql0 = "select Distinct sor.patient from base_course_sales_order_record sor INNER JOIN base_course bc on sor.course_id = bc.id " +
 | 
	
		
			
				|  |  |                 " and bc.del=1 where bc.doctor ='"+doctor+"'  and sor.`status` =5 and not EXISTS (select DISTINCT rsr.patient " +
 | 
	
		
			
				|  |  |                 " and bc.del=1 where bc.doctor ='"+doctor+"'  and sor.`status` =2 and not EXISTS (select DISTINCT rsr.patient " +
 | 
	
		
			
				|  |  |                 " from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` and org.del=1 " +
 | 
	
		
			
				|  |  |                 " INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where rsr.patient=sor.patient and " +
 | 
	
		
			
				|  |  |                 " dh.doctor_code='"+doctor+"'   and rsr.del<>0  and rsr.`status` = 3  )";
 | 
	
		
			
				|  |  |                 " dh.doctor_code='"+doctor+"'   and rsr.del<>0  and rsr.`status` = 2  )";
 | 
	
		
			
				|  |  |         //已入学
 | 
	
		
			
				|  |  |         String sql1=" select DISTINCT rsr.patient from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` " +
 | 
	
		
			
				|  |  |                 "and org.del=1 INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where dh.doctor_code='"+doctor+"' " +
 | 
	
		
			
				|  |  |                 "and rsr.del<>0  and rsr.`status` = 3 GROUP BY dh.doctor_code  ";
 | 
	
		
			
				|  |  |                 "and rsr.del<>0  and rsr.`status` = 2 GROUP BY dh.doctor_code  ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String sqlcpunt = "select count(Distinct p.id) from ( {sqlReplace} )tmp Inner JOIN base_patient p on tmp.patient  = p.id " +
 | 
	
		
			
				|  |  |                 " LEFT JOIN wlyy_patient_device pd on pd.`user`=p.id and pd.category_code BETWEEN 1 and 2  ";
 | 
	
	
		
			
				|  | @ -293,4 +300,20 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |         result.put("enrol",count);
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public JSONObject getNotificationCount(String doctor,Integer type){
 | 
	
		
			
				|  |  |         JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |         // 上门辅导工单 待完成
 | 
	
		
			
				|  |  |         List<BaseDoorCoachOrderDO> coachOrderDOList = baseDoorCoachOrderDao.getUnFinishOrderByDoctor(doctor);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (type > 0){
 | 
	
		
			
				|  |  |             return object;
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             Integer unreadMessageCount = imService.SessionsUnreadMessageCountByUserId(doctor);
 | 
	
		
			
				|  |  |             object.put("unreadMessageCount",unreadMessageCount);
 | 
	
		
			
				|  |  |             object.put("doorCoachOrder",coachOrderDOList.size());//上门辅导待完成数量
 | 
	
		
			
				|  |  |             return object;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |