|  | @ -469,58 +469,58 @@ public class SignWebService extends BaseService {
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public JSONObject getSignInfo(String teamCode){
 |  |     public JSONObject getSignInfo(String teamCode){
 | 
												
													
														
															|  |           List<SignFamily> signFamilys = signFamilyDao.findByTeamCodeIsValid(teamCode);
 |  | 
 | 
												
													
														
															|  |           SignFamily signFamily =null;
 |  | 
 | 
												
													
														
															|  |           if(signFamilys==null||signFamilys.size()==0){
 |  | 
 | 
												
													
														
															|  |               throw new RuntimeException("找不到签约关系!");
 |  | 
 | 
												
													
														
															|  |           }else{
 |  | 
 | 
												
													
														
															|  |               signFamily = signFamilys.get(0);
 |  | 
 | 
												
													
														
															|  | ;          }
 |  | 
 | 
												
													
														
															|  |           Patient p = patientService.findByCode(signFamily.getPatient());
 |  | 
 | 
												
													
														
															|  |           String patient = p.getCode();
 |  | 
 | 
												
													
														
															|  |           JSONObject resultObject = new JSONObject();
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |           AdminTeam adminTeam = adminTeamService.getTeam(signFamily.getAdminTeamId());
 |  | 
 | 
												
													
														
															|  |           //查找到团队领导
 |  | 
 | 
												
													
														
															|  |           Doctor leader = doctorService.findDoctorByCode(adminTeam.getLeaderCode());
 |  | 
 | 
												
													
														
															|  |           JSONObject leaderObj = this.doctorParse(leader);
 |  | 
 | 
												
													
														
															|  |           resultObject.put("leader",leaderObj);
 |  | 
 | 
												
													
														
															|  |           String doctorHealth = signFamily.getDoctorHealth();
 |  | 
 | 
												
													
														
															|  |           String doctor = signFamily.getDoctor();
 |  | 
 | 
												
													
														
															|  |           //签约团队的健管师
 |  | 
 | 
												
													
														
															|  |           if(StringUtils.isNotBlank(doctorHealth)){
 |  | 
 | 
												
													
														
															|  |               Doctor health = doctorService.findDoctorByCode(doctorHealth);
 |  | 
 | 
												
													
														
															|  |               JSONObject healthObj = this.doctorParse(health);
 |  | 
 | 
												
													
														
															|  |               resultObject.put("doctorHealth",healthObj);
 |  | 
 | 
												
													
														
															|  |           }
 |  | 
 | 
												
													
														
															|  |          //签约团队的全科医生
 |  | 
 | 
												
													
														
															|  |           if(StringUtils.isNotBlank(doctor)){
 |  | 
 | 
												
													
														
															|  |               Doctor qk = doctorService.findDoctorByCode(doctor);
 |  | 
 | 
												
													
														
															|  |               JSONObject qkObj = this.doctorParse(qk);
 |  | 
 | 
												
													
														
															|  |               resultObject.put("doctor",qkObj);
 |  | 
 | 
												
													
														
															|  |           }
 |  | 
 | 
												
													
														
															|  |           Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00"));
 |  | 
 | 
												
													
														
															|  |           int year = calendar.get(Calendar.YEAR);
 |  | 
 | 
												
													
														
															|  |           //统计当年咨询数量
 |  | 
 | 
												
													
														
															|  |           String consult_sql = "select count(1) as count from wlyy_consult_team  w where w.doctor = ? and w.patient =? and YEAR(w.czrq) = ? ";
 |  | 
 | 
												
													
														
															|  |          //统计随访数量
 |  | 
 | 
												
													
														
															|  |           String followup_sql = "select count(1) as count from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ?  and w.followup_class is not null ";
 |  | 
 | 
												
													
														
															|  |          //统计待预约数量
 |  | 
 | 
												
													
														
															|  |           String reservation_sql = "select count(1) as count from wlyy_patient_reservation  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
 |  | 
 | 
												
													
														
															|  | 
 |  |         List<SignFamily> signFamilys = signFamilyDao.findByTeamCodeIsValid(teamCode);
 | 
												
													
														
															|  | 
 |  |         SignFamily signFamily =null;
 | 
												
													
														
															|  | 
 |  |         if(signFamilys==null||signFamilys.size()==0){
 | 
												
													
														
															|  | 
 |  |             throw new RuntimeException("找不到签约关系!");
 | 
												
													
														
															|  | 
 |  |         }else{
 | 
												
													
														
															|  | 
 |  |             signFamily = signFamilys.get(0);
 | 
												
													
														
															|  | 
 |  |             ;          }
 | 
												
													
														
															|  | 
 |  |         Patient p = patientService.findByCode(signFamily.getPatient());
 | 
												
													
														
															|  | 
 |  |         String patient = p.getCode();
 | 
												
													
														
															|  | 
 |  |         JSONObject resultObject = new JSONObject();
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         AdminTeam adminTeam = adminTeamService.getTeam(signFamily.getAdminTeamId());
 | 
												
													
														
															|  | 
 |  |         //查找到团队领导
 | 
												
													
														
															|  | 
 |  |         Doctor leader = doctorService.findDoctorByCode(adminTeam.getLeaderCode());
 | 
												
													
														
															|  | 
 |  |         JSONObject leaderObj = this.doctorParse(leader);
 | 
												
													
														
															|  | 
 |  |         resultObject.put("leader",leaderObj);
 | 
												
													
														
															|  | 
 |  |         String doctorHealth = signFamily.getDoctorHealth();
 | 
												
													
														
															|  | 
 |  |         String doctor = signFamily.getDoctor();
 | 
												
													
														
															|  | 
 |  |         //签约团队的健管师
 | 
												
													
														
															|  | 
 |  |         if(StringUtils.isNotBlank(doctorHealth)){
 | 
												
													
														
															|  | 
 |  |             Doctor health = doctorService.findDoctorByCode(doctorHealth);
 | 
												
													
														
															|  | 
 |  |             JSONObject healthObj = this.doctorParse(health);
 | 
												
													
														
															|  | 
 |  |             resultObject.put("doctorHealth",healthObj);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         //签约团队的全科医生
 | 
												
													
														
															|  | 
 |  |         if(StringUtils.isNotBlank(doctor)){
 | 
												
													
														
															|  | 
 |  |             Doctor qk = doctorService.findDoctorByCode(doctor);
 | 
												
													
														
															|  | 
 |  |             JSONObject qkObj = this.doctorParse(qk);
 | 
												
													
														
															|  | 
 |  |             resultObject.put("doctor",qkObj);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00"));
 | 
												
													
														
															|  | 
 |  |         int year = calendar.get(Calendar.YEAR);
 | 
												
													
														
															|  | 
 |  |         //统计当年咨询数量
 | 
												
													
														
															|  | 
 |  |         String consult_sql = "select count(1) as count from wlyy_consult_team  w where w.doctor = ? and w.patient =? and YEAR(w.czrq) = ? ";
 | 
												
													
														
															|  | 
 |  |         //统计随访数量
 | 
												
													
														
															|  | 
 |  |         String followup_sql = "select count(1) as count from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ?  and w.followup_class is not null ";
 | 
												
													
														
															|  | 
 |  |         //统计待预约数量
 | 
												
													
														
															|  | 
 |  |         String reservation_sql = "select count(1) as count from wlyy_patient_reservation  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
 | 
												
													
														
															|  |         //统计健康教育数量
 |  |         //统计健康教育数量
 | 
												
													
														
															|  |           String article_sql = "select count(1) as count from wlyy_health_edu_article_patient  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
 |  | 
 | 
												
													
														
															|  | 
 |  |         String article_sql = "select count(1) as count from wlyy_health_edu_article_patient  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
 | 
												
													
														
															|  |         //统计健康指导数量
 |  |         //统计健康指导数量
 | 
												
													
														
															|  |           String guidance_sql = "select count(1) as count from wlyy_patient_health_guidance  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |           StringBuffer countSql = new StringBuffer();
 |  | 
 | 
												
													
														
															|  |           countSql.append(consult_sql).append(" union all ").append(followup_sql).append(" union all ").append(reservation_sql).append(" union all ").append(article_sql).append(" union all ").append(guidance_sql);
 |  | 
 | 
												
													
														
															|  |           List<Map<String, Object>> resultCount  = jdbcTemplate.queryForList(countSql.toString(), new Object[]{doctorHealth, patient, year,doctorHealth,doctor,patient,year,doctorHealth,doctor,patient,year,doctorHealth,doctor,patient,year,doctorHealth,doctor,patient,year});
 |  | 
 | 
												
													
														
															|  |           resultObject.put("consultNum",resultCount.get(0).get("count"));
 |  | 
 | 
												
													
														
															|  |           resultObject.put("followupNum",resultCount.get(1).get("count"));
 |  | 
 | 
												
													
														
															|  |           resultObject.put("reservationNum",resultCount.get(2).get("count"));
 |  | 
 | 
												
													
														
															|  |           resultObject.put("articleNum",resultCount.get(3).get("count"));
 |  | 
 | 
												
													
														
															|  |           resultObject.put("guidanceNum",resultCount.get(4).get("count"));
 |  | 
 | 
												
													
														
															|  |           return resultObject;
 |  | 
 | 
												
													
														
															|  | 
 |  |         String guidance_sql = "select count(1) as count from wlyy_patient_health_guidance  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         StringBuffer countSql = new StringBuffer();
 | 
												
													
														
															|  | 
 |  |         countSql.append(consult_sql).append(" union all ").append(followup_sql).append(" union all ").append(reservation_sql).append(" union all ").append(article_sql).append(" union all ").append(guidance_sql);
 | 
												
													
														
															|  | 
 |  |         List<Map<String, Object>> resultCount  = jdbcTemplate.queryForList(countSql.toString(), new Object[]{doctorHealth, patient, year,doctorHealth,doctor,patient,year,doctorHealth,doctor,patient,year,doctorHealth,doctor,patient,year,doctorHealth,doctor,patient,year});
 | 
												
													
														
															|  | 
 |  |         resultObject.put("consultNum",resultCount.get(0).get("count"));
 | 
												
													
														
															|  | 
 |  |         resultObject.put("followupNum",resultCount.get(1).get("count"));
 | 
												
													
														
															|  | 
 |  |         resultObject.put("reservationNum",resultCount.get(2).get("count"));
 | 
												
													
														
															|  | 
 |  |         resultObject.put("articleNum",resultCount.get(3).get("count"));
 | 
												
													
														
															|  | 
 |  |         resultObject.put("guidanceNum",resultCount.get(4).get("count"));
 | 
												
													
														
															|  | 
 |  |         return resultObject;
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     private JSONObject doctorParse(Doctor doctor){
 |  |     private JSONObject doctorParse(Doctor doctor){
 | 
												
											
												
													
														
															|  | @ -1265,4 +1265,82 @@ public class SignWebService extends BaseService {
 | 
												
													
														
															|  |             messageDao.save(mes);
 |  |             messageDao.save(mes);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     public JSONObject getSignInfoOrRenewInfo(String teamCode){
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         //签约或续签参数
 | 
												
													
														
															|  | 
 |  |         String patientCode = null;
 | 
												
													
														
															|  | 
 |  |         Long adminTeamId = null;
 | 
												
													
														
															|  | 
 |  |         String doctorHealth = null;
 | 
												
													
														
															|  | 
 |  |         String doctor =null;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         List<SignFamilyRenew> renews = signFamilyRenewDao.findByTeamCodeIsValid(teamCode);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         if(renews==null&&renews.size()==0){
 | 
												
													
														
															|  | 
 |  |             List<SignFamily> signFamilys = signFamilyDao.findByTeamCodeIsValid(teamCode);
 | 
												
													
														
															|  | 
 |  |             if(signFamilys==null||signFamilys.size()==0){
 | 
												
													
														
															|  | 
 |  |                 throw new RuntimeException("找不到签约关系!");
 | 
												
													
														
															|  | 
 |  |             }else{
 | 
												
													
														
															|  | 
 |  |                 SignFamily signFamily = signFamilys.get(0);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |                 patientCode = signFamily.getPatient();
 | 
												
													
														
															|  | 
 |  |                 adminTeamId = signFamily.getAdminTeamId();
 | 
												
													
														
															|  | 
 |  |                 doctorHealth = signFamily.getDoctorHealth();
 | 
												
													
														
															|  | 
 |  |                 doctor = signFamily.getDoctor();
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |         }else{
 | 
												
													
														
															|  | 
 |  |             SignFamilyRenew renew = renews.get(0);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |             patientCode = renew.getPatient();
 | 
												
													
														
															|  | 
 |  |             adminTeamId = renew.getAdminTeamId();
 | 
												
													
														
															|  | 
 |  |             doctorHealth = renew.getDoctorHealth();
 | 
												
													
														
															|  | 
 |  |             doctor = renew.getDoctor();
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         Patient p = patientService.findByCode(patientCode);
 | 
												
													
														
															|  | 
 |  |         String patient = p.getCode();
 | 
												
													
														
															|  | 
 |  |         JSONObject resultObject = new JSONObject();
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         AdminTeam adminTeam = adminTeamService.getTeam(adminTeamId);
 | 
												
													
														
															|  | 
 |  |         //查找到团队领导
 | 
												
													
														
															|  | 
 |  |         Doctor leader = doctorService.findDoctorByCode(adminTeam.getLeaderCode());
 | 
												
													
														
															|  | 
 |  |         JSONObject leaderObj = this.doctorParse(leader);
 | 
												
													
														
															|  | 
 |  |         resultObject.put("leader",leaderObj);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         //签约团队的健管师
 | 
												
													
														
															|  | 
 |  |         if(StringUtils.isNotBlank(doctorHealth)){
 | 
												
													
														
															|  | 
 |  |             Doctor health = doctorService.findDoctorByCode(doctorHealth);
 | 
												
													
														
															|  | 
 |  |             JSONObject healthObj = this.doctorParse(health);
 | 
												
													
														
															|  | 
 |  |             resultObject.put("doctorHealth",healthObj);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         //签约团队的全科医生
 | 
												
													
														
															|  | 
 |  |         if(StringUtils.isNotBlank(doctor)){
 | 
												
													
														
															|  | 
 |  |             Doctor qk = doctorService.findDoctorByCode(doctor);
 | 
												
													
														
															|  | 
 |  |             JSONObject qkObj = this.doctorParse(qk);
 | 
												
													
														
															|  | 
 |  |             resultObject.put("doctor",qkObj);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00"));
 | 
												
													
														
															|  | 
 |  |         int year = calendar.get(Calendar.YEAR);
 | 
												
													
														
															|  | 
 |  |         //统计当年咨询数量
 | 
												
													
														
															|  | 
 |  |         String consult_sql = "select count(1) as count from wlyy_consult_team  w where w.doctor = ? and w.patient =? and YEAR(w.czrq) = ? ";
 | 
												
													
														
															|  | 
 |  |         //统计随访数量
 | 
												
													
														
															|  | 
 |  |         String followup_sql = "select count(1) as count from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ?  and w.followup_class is not null ";
 | 
												
													
														
															|  | 
 |  |         //统计待预约数量
 | 
												
													
														
															|  | 
 |  |         String reservation_sql = "select count(1) as count from wlyy_patient_reservation  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
 | 
												
													
														
															|  | 
 |  |         //统计健康教育数量
 | 
												
													
														
															|  | 
 |  |         String article_sql = "select count(1) as count from wlyy_health_edu_article_patient  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
 | 
												
													
														
															|  | 
 |  |         //统计健康指导数量
 | 
												
													
														
															|  | 
 |  |         String guidance_sql = "select count(1) as count from wlyy_patient_health_guidance  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         StringBuffer countSql = new StringBuffer();
 | 
												
													
														
															|  | 
 |  |         countSql.append(consult_sql).append(" union all ").append(followup_sql).append(" union all ").append(reservation_sql).append(" union all ").append(article_sql).append(" union all ").append(guidance_sql);
 | 
												
													
														
															|  | 
 |  |         List<Map<String, Object>> resultCount  = jdbcTemplate.queryForList(countSql.toString(), new Object[]{doctorHealth, patient, year,doctorHealth,doctor,patient,year,doctorHealth,doctor,patient,year,doctorHealth,doctor,patient,year,doctorHealth,doctor,patient,year});
 | 
												
													
														
															|  | 
 |  |         resultObject.put("consultNum",resultCount.get(0).get("count"));
 | 
												
													
														
															|  | 
 |  |         resultObject.put("followupNum",resultCount.get(1).get("count"));
 | 
												
													
														
															|  | 
 |  |         resultObject.put("reservationNum",resultCount.get(2).get("count"));
 | 
												
													
														
															|  | 
 |  |         resultObject.put("articleNum",resultCount.get(3).get("count"));
 | 
												
													
														
															|  | 
 |  |         resultObject.put("guidanceNum",resultCount.get(4).get("count"));
 | 
												
													
														
															|  | 
 |  |         return resultObject;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | }
 |  | }
 |