Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

hzp 8 years ago
parent
commit
6895dc8765
16 changed files with 816 additions and 830 deletions
  1. 5 20
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java
  2. 3 21
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/FollowUpJob.java
  3. 6 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/consult/ConsultTeam.java
  4. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java
  5. 2 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java
  6. 280 269
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  7. 185 230
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  8. 7 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  9. 246 225
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reservation/PatientReservationService.java
  10. 46 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/ServiceStatisticsService.java
  11. 13 46
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpUtil.java
  12. 5 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java
  13. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/ServiceStatisticsController.java
  14. 7 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  15. 4 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  16. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

+ 5 - 20
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java

@ -66,10 +66,8 @@ public class CurrentDayAllQuotaJob implements Job {
    private HealthGuideDataFilter healthGuideDataFilter;
    @Autowired
    private FollowUpDataFilter followUpDataFilter;
    private org.apache.tomcat.jdbc.pool.DataSource fvdataSource = new org.apache.tomcat.jdbc.pool.DataSource();//随访数据源
    private JdbcTemplate fv_jdbcTemplate = new JdbcTemplate();
    @Autowired
    private JdbcTemplate jdbcTemplate;
    List<Town> towns = null;//厦门市全部的区
    List<Hospital> hospitals = null;//系统全部的机构
@ -82,19 +80,11 @@ public class CurrentDayAllQuotaJob implements Job {
    private String tomorrow = getDayString(1);
    private StringBuffer allContent=new StringBuffer();//日志内容
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Value("${fv.jdbc.driver}")
    String fv_jdbc_driver;
    @Value("${fv.jdbc.url}")
    String fv_jdbc_url;
    @Value("${fv.jdbc.username}")
    String fv_jdbc_username;
    @Value("${fv.jdbc.password}")
    String fv_jdbc_password;
    @Value("${redis.quota.current.expire}")
    String currentExpire="2";
@ -104,12 +94,7 @@ public class CurrentDayAllQuotaJob implements Job {
            throws JobExecutionException {
        try {
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            fvdataSource.setDriverClassName(fv_jdbc_driver);
            fvdataSource.setUrl(fv_jdbc_url);
            fvdataSource.setUsername(fv_jdbc_username);
            fvdataSource.setPassword(fv_jdbc_password);
            fv_jdbcTemplate.setDataSource(fvdataSource);//初始化随访的数据源
            towns = townDao.findByCityCode(Constant.city); //查找出厦门市全部的区
            hospitals = hospitalDao.findHospitalzxFWZ(); //查找出系统全部的机构
            adminTeams=doctorAdminTeamDao.findAllTeam();//查找出系统全部的全科医生
@ -504,10 +489,10 @@ public class CurrentDayAllQuotaJob implements Job {
        String quotaId="4";
        try{
            //找出今天的随访信息
            String sql=" select * from fv_plan a where  a.update_time< '"+tomorrow+"' and a.update_time>= '"+now+"' ";
            String sql=" select * from wlyy_followup a where  a.update_time< '"+tomorrow+"' and a.update_time>= '"+now+"' ";
            //找出今天的随访信息
            List<Map<String, Object>> plans = fv_jdbcTemplate.queryForList(sql);
            List<Map<String, Object>> plans = jdbcTemplate.queryForList(sql);
            FilterModel etlModels = followUpDataFilter.filter(plans, sql, null);
            // 统计数据

+ 3 - 21
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/FollowUpJob.java

@ -45,7 +45,7 @@ public class FollowUpJob implements Job {
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate_wlyy;
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
@ -53,20 +53,8 @@ public class FollowUpJob implements Job {
    @Autowired
    private FollowUpDataFilter followUpDataFilter;
    private org.apache.tomcat.jdbc.pool.DataSource fvdataSource = new org.apache.tomcat.jdbc.pool.DataSource();//随访数据源
    private JdbcTemplate jdbcTemplate = new JdbcTemplate();
    String yesterday;
    String daybefore;
    @Value("${fv.jdbc.driver}")
    String fv_jdbc_driver;
    @Value("${fv.jdbc.url}")
    String fv_jdbc_url;
    @Value("${fv.jdbc.username}")
    String fv_jdbc_username;
    @Value("${fv.jdbc.password}")
    String fv_jdbc_password;
    @Override
    public void execute(JobExecutionContext context)
@ -78,12 +66,6 @@ public class FollowUpJob implements Job {
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            fvdataSource.setDriverClassName(fv_jdbc_driver);
            fvdataSource.setUrl(fv_jdbc_url);
            fvdataSource.setUsername(fv_jdbc_username);
            fvdataSource.setPassword(fv_jdbc_password);
            //计算指标
            jdbcTemplate.setDataSource(fvdataSource);//初始化随访的数据源
            //線刪除今天的数据
            daybefore = StringUtils.isEmpty(map.get("daybefore")) ? SignJob.getDayString(-2) : map.get("daybefore").toString();
            yesterday = StringUtils.isEmpty(map.get("yesterday")) ? SignJob.getDayString(-1) : map.get("yesterday").toString();
@ -99,7 +81,7 @@ public class FollowUpJob implements Job {
    @Transactional
    private void computequota() {
        try {
            jdbcTemplate_wlyy.execute("delete from wlyy_quota_result where quota_date='" + yesterday + "' and quato_code='" + 4 + "'");
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='" + yesterday + "' and quato_code='" + 4 + "'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
@ -109,7 +91,7 @@ public class FollowUpJob implements Job {
            String sql = " select * from wlyy_followup a where a.update_time>='" + daybefore + Constant.quota_date_last + "' and a.update_time< '" + yesterday + Constant.quota_date_last + "'  ";
            //找出今天的随访信息
            List<Map<String, Object>> plans = jdbcTemplate_wlyy.queryForList(sql);
            List<Map<String, Object>> plans = jdbcTemplate.queryForList(sql);
            FilterModel etlModels = followUpDataFilter.filter(plans, sql, yesterday);
            // 统计数据
            List<Map<String, List<ETLModel>>> returnDatas = levelRole.elt(etlModels.getEtlModelList());

+ 6 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/consult/ConsultTeam.java

@ -44,9 +44,9 @@ public class ConsultTeam extends IdEntity {
	private Long guidance;   //关联指导
	private String doctorName;//醫生名字
	//起始消息id
	private String startMsgId;
	private Integer startMsgId;
	//结束消息id
	private String endMsgId;
	private Integer endMsgId;
	// 结束人
	private String endOperator;
	// 结束人类型
@ -256,19 +256,19 @@ public class ConsultTeam extends IdEntity {
	}
	public String getStartMsgId() {
	public Integer getStartMsgId() {
		return startMsgId;
	}
	public void setStartMsgId(String startMsgId) {
	public void setStartMsgId(Integer startMsgId) {
		this.startMsgId = startMsgId;
	}
	public String getEndMsgId() {
	public Integer getEndMsgId() {
		return endMsgId;
	}
	public void setEndMsgId(String endMsgId) {
	public void setEndMsgId(Integer endMsgId) {
		this.endMsgId = endMsgId;
	}

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java

@ -24,6 +24,9 @@ public class PatientInterceptor extends BaseInterceptor {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		boolean flag = true;
		if(flag){
			return true;
		}
		try {
			if(request.getRequestURI().contains("/patient/hosptail/getHositalByTownCode")){
				return true;

+ 2 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java

@ -28,6 +28,7 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    @Query(value = "select a.* from wlyy_followup a where a.doctor_code in ?1 and a.patient_code = ?2 and a.followup_class=?3 and a.status ='1' order by a.followup_date DESC limit 1",nativeQuery = true)
    Followup findLastFollowup(String[] doctors,String patientCode,String followClass) throws Exception;
    @Query("select d.code,d.name,d.photo,a.followupType,a.followupClass,a.status,a.createTime,a.updateTime,a.followupManagerStatus,c.code,c.name,c.photo from Followup a, Doctor d, Doctor c where a.doctorCode = d.code and a.creater = c.code and a.patientCode = ?1 and a.adminTeamCode = ?2 ")
    @Query("select d.code,d.name,d.photo,a.followupType,a.followupClass,a.status,a.createTime,a.updateTime,a.followupManagerStatus,c.code,c.name,c.photo" +
            ",a.followupDate,a.followupPlanDate,a.followupNextDate,a.id,a.followupNo from Followup a, Doctor d, Doctor c where a.doctorCode = d.code and a.creater = c.code and a.patientCode = ?1 and a.adminTeamCode = ?2 ")
    Page<Object> findByPatientAndTeam(String patient, Long teamCode, Pageable pageable);
}

+ 280 - 269
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -20,12 +20,12 @@ import com.yihu.wlyy.entity.patient.SignFamily;
public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Long>, JpaSpecificationExecutor<SignFamily> {
	@Query("select count(1) from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status >= 0")
	int hasSingStatus(String idcard);
    @Query("select count(1) from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status >= 0")
    int hasSingStatus(String idcard);
	@Modifying
	@Query("update SignFamily a set a.mobile = ?2 where a.patient = ?1")
	int updatePatientMobile(String patient,String mobile);
    @Modifying
    @Query("update SignFamily a set a.mobile = ?2 where a.patient = ?1")
    int updatePatientMobile(String patient, String mobile);
    @Query("select a from SignFamily a where a.idcard = ?1 and status = ?2 and a.type = 2")
    SignFamily findByPatientStatus(String idcard, int status);
@ -34,305 +34,316 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    SignFamily findByPatientCodeStatus(String patient, int status);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = ?2 and a.status >= 1")
    SignFamily findByPatientAndType(String patient,int type);
    SignFamily findByPatientAndType(String patient, int type);
	SignFamily findByCode(String code);
    SignFamily findByCode(String code);
	SignFamily findByCodeAndType(String code,Integer type);
    SignFamily findByCodeAndType(String code, Integer type);
	SignFamily findByFamilyCode(String familyCode);
    SignFamily findByFamilyCode(String familyCode);
	@Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0")
	SignFamily findByDoctorPatient(String doctor, String patient);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0")
    SignFamily findByDoctorPatient(String doctor, String patient);
	@Query("select a from SignFamily a where a.doctorHealth = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0 ")
	SignFamily findByDoctorHealthPatient(String doctor, String patient);
    @Query("select a from SignFamily a where a.doctorHealth = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0 ")
    SignFamily findByDoctorHealthPatient(String doctor, String patient);
	@Query("select p from Patient p,SignFamily a where a.doctorHealth = ?1  and a.adminTeamId=?2 and a.patient =p.code and a.type = 2 and a.status >= 0")
	List<Patient> findByDoctorHealthPatient(String doctor,Long team);
    @Query("select p from Patient p,SignFamily a where a.doctorHealth = ?1  and a.adminTeamId=?2 and a.patient =p.code and a.type = 2 and a.status >= 0")
    List<Patient> findByDoctorHealthPatient(String doctor, Long team);
	@Query("select p from Patient p,SignFamily a where (a.doctorHealth = ?1 or a.doctor=?2 ) and a.patient =p.code and a.type = 2 and a.status >= 0")
	List<Patient> findByDoctorOrDoctorHealthPatient(String doctorHealth,String doctor);
    @Query("select p from Patient p,SignFamily a where (a.doctorHealth = ?1 or a.doctor=?2 ) and a.patient =p.code and a.type = 2 and a.status >= 0")
    List<Patient> findByDoctorOrDoctorHealthPatient(String doctorHealth, String doctor);
	@Query("select p from Patient p,SignFamily a where a.doctor = ?1 and a.adminTeamId=?2 and a.patient =p.code and a.type = 2 and a.status >= 0")
	List<Patient> findByDoctorPatient(String doctor,Long team);
    @Query("select p from Patient p,SignFamily a where a.doctor = ?1 and a.adminTeamId=?2 and a.patient =p.code and a.type = 2 and a.status >= 0")
    List<Patient> findByDoctorPatient(String doctor, Long team);
	@Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.type = 1 and a.status > 0")
	SignFamily findSsSignByDoctorPatient(String doctor, String patient);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.type = 1 and a.status > 0")
    SignFamily findSsSignByDoctorPatient(String doctor, String patient);
	@Query("select a from SignFamily a,DoctorTeamMember w where a.teamCode = w.team and w.del = '1' and w.memberCode = ?1 and a.patient = ?2 and a.status > 0")
	List<SignFamily> findByDoctorAndPatient(String doctor,String patient);
    @Query("select a from SignFamily a,DoctorTeamMember w where a.teamCode = w.team and w.del = '1' and w.memberCode = ?1 and a.patient = ?2 and a.status > 0")
    List<SignFamily> findByDoctorAndPatient(String doctor, String patient);
	@Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.status = 1 and a.type = 2")
	SignFamily findByFamilyDoctorAndPatient(String doctor,String patient);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.status = 1 and a.type = 2")
    SignFamily findByFamilyDoctorAndPatient(String doctor, String patient);
	@Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.status = 1 and a.type = 1")
	SignFamily findBySanshiDoctorAndPatient(String doctor,String patient);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.status = 1 and a.type = 1")
    SignFamily findBySanshiDoctorAndPatient(String doctor, String patient);
	@Query("select a from SignFamily a where a.doctor = ?1 and a.openid = ?2 and a.type = 2 and a.status >= 0")
	SignFamily findByDoctorOpenid(String doctor, String openid);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.openid = ?2 and a.type = 2 and a.status >= 0")
    SignFamily findByDoctorOpenid(String doctor, String openid);
	@Query("select a from SignFamily a where a.doctor = ?1 and a.idcard = ?2 and a.type = 2 and a.status >= 0")
	SignFamily findByDoctorIdcard(String doctor, String idcard);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.idcard = ?2 and a.type = 2 and a.status >= 0")
    SignFamily findByDoctorIdcard(String doctor, String idcard);
	@Query("select a from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status >= 0")
	SignFamily findByIdcard(String idcard);
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status >= 0")
    SignFamily findByIdcard(String idcard);
	@Query("select a from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status > 0 and a.expensesStatus ='1'")
	SignFamily getExpensesSignByIdcard(String idcard);
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status > 0 and a.expensesStatus ='1'")
    SignFamily getExpensesSignByIdcard(String idcard);
	@Query("select a from SignFamily a where a.idcard = ?1 and a.type =1 and a.status >= 0")
	SignFamily findSSByIdcard(String idcard);
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type =1 and a.status >= 0")
    SignFamily findSSByIdcard(String idcard);
	@Query("select a from SignFamily a where a.idcard = ?1 ")
	List<SignFamily> findAllByIdcard(String idcard);
    @Query("select a from SignFamily a where a.idcard = ?1 ")
    List<SignFamily> findAllByIdcard(String idcard);
	@Query("select a from SignFamily a where a.idcard = ?1 and a.status >= 0")
	List<SignFamily> findSSandJTByIdcard(String idcard);
    @Query("select a from SignFamily a where a.idcard = ?1 and a.status >= 0")
    List<SignFamily> findSSandJTByIdcard(String idcard);
	@Query("select a from SignFamily a where a.openid = ?1 and a.type = 2 and a.status >= 0")
	SignFamily findByOpenid(String openid);
    @Query("select a from SignFamily a where a.openid = ?1 and a.type = 2 and a.status >= 0")
    SignFamily findByOpenid(String openid);
	// 取消签约申请
	@Modifying
	@Query("update SignFamily a set a.status = -1 where a.patient = ?1 and a.doctor = ?2 and a.type = 2 and a.status = 0")
	void unsignByPatient(String patient, String doctor);
    // 取消签约申请
    @Modifying
    @Query("update SignFamily a set a.status = -1 where a.patient = ?1 and a.doctor = ?2 and a.type = 2 and a.status = 0")
    void unsignByPatient(String patient, String doctor);
	// 取消签约申请
	@Modifying
	@Query("update SignFamily a set a.status = -1 where a.openid = ?1 and a.doctor = ?2 and a.type = 2 and a.status = 0")
	void unsignByOpenid(String openid, String doctor);
    // 取消签约申请
    @Modifying
    @Query("update SignFamily a set a.status = -1 where a.openid = ?1 and a.doctor = ?2 and a.type = 2 and a.status = 0")
    void unsignByOpenid(String openid, String doctor);
	// 查询医生的签约数量
	@Query("select count(1) from SignFamily a where a.doctor = ?1")
	int countByDoctor(String doctor);
    // 查询医生的签约数量
    @Query("select count(1) from SignFamily a where a.doctor = ?1")
    int countByDoctor(String doctor);
	// 查询医生的签约数量
	@Query("select count(1) from SignFamily a")
	int countByDoctor();
	// 更新状态为待解约
	@Modifying
	@Query("update SignFamily a set a.status = 2 where a.patient = ?1 and a.doctor = ?2 and a.status = 1 and a.type = 2")
	int surrender(String patient, String doctor);
    // 查询医生的签约数量
    @Query("select count(1) from SignFamily a")
    int countByDoctor();
	// 更新待签约状态为拒绝或同意状态
	@Modifying
	@Query("update SignFamily a set a.status = ?1 where a.patient = ?2 and a.status = 0 and a.type = 2")
	int handleSign(int status, String patient);
    // 更新状态为待解约
    @Modifying
    @Query("update SignFamily a set a.status = 2 where a.patient = ?1 and a.doctor = ?2 and a.status = 1 and a.type = 2")
    int surrender(String patient, String doctor);
	// 更新已签约状态为解约
	@Modifying
	@Query("update SignFamily a set a.status = -3, a.reason = ?1 where a.patient = ?2 and a.status = 2 and a.type = 2")
	int handleSurrender(String reason, String patient);
    // 更新待签约状态为拒绝或同意状态
    @Modifying
    @Query("update SignFamily a set a.status = ?1 where a.patient = ?2 and a.status = 0 and a.type = 2")
    int handleSign(int status, String patient);
	// 拒绝解约
	@Modifying
	@Query("update SignFamily a set a.status = 1 where a.patient = ?1 and a.status = 2 and a.type = 2")
	int refuseSurrender(String patient);
    // 更新已签约状态为解约
    @Modifying
    @Query("update SignFamily a set a.status = -3, a.reason = ?1 where a.patient = ?2 and a.status = 2 and a.type = 2")
    int handleSurrender(String reason, String patient);
	// 查询患者已生效的家庭签约
	@Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status > 0")
	SignFamily findSignByPatient(String patient);
    // 拒绝解约
    @Modifying
    @Query("update SignFamily a set a.status = 1 where a.patient = ?1 and a.status = 2 and a.type = 2")
    int refuseSurrender(String patient);
	@Modifying
	@Query("update SignFamily a set a.openid = ?1 where patient = ?2")
	int updateOpenidByPatient(String openid, String patient);
    // 查询患者已生效的家庭签约
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status > 0")
    SignFamily findSignByPatient(String patient);
	// 查询已签约的总数
	@Query("select count(1) from SignFamily a where (a.doctor = ?1 or a.doctorHealth = ?1) and (a.status = 1 or a.status = 2) and a.type = 2")
	int countAmountSignedByDoctor(String doctor);
    @Modifying
    @Query("update SignFamily a set a.openid = ?1 where patient = ?2")
    int updateOpenidByPatient(String openid, String patient);
	// 查询待签约总数
	@Query("select count(1) from SignFamily a where (a.doctor = ?1 or a.doctorHealth = ?1) and a.status = 0 and a.type = 2")
	int countAmountUnsignByDoctor(String doctor);
    // 查询已签约的总数
    @Query("select count(1) from SignFamily a where (a.doctor = ?1 or a.doctorHealth = ?1) and (a.status = 1 or a.status = 2) and a.type = 2")
    int countAmountSignedByDoctor(String doctor);
	// 查询团队中的健康管理师 sf.doctorHealth,sf.doctorHealthName,
	//select sf.doctorHealth,sf.doctorHealthName,count(*) totalContract from SignFamily sf where sf.healthDoctor = ?1
	@Query("select sf.doctorHealth,sf.doctorHealthName,count(sf)  from SignFamily sf where sf.doctorHealth = ?1")
    // 查询待签约总数
    @Query("select count(1) from SignFamily a where (a.doctor = ?1 or a.doctorHealth = ?1) and a.status = 0 and a.type = 2")
    int countAmountUnsignByDoctor(String doctor);
    // 查询团队中的健康管理师 sf.doctorHealth,sf.doctorHealthName,
    //select sf.doctorHealth,sf.doctorHealthName,count(*) totalContract from SignFamily sf where sf.healthDoctor = ?1
    @Query("select sf.doctorHealth,sf.doctorHealthName,count(sf)  from SignFamily sf where sf.doctorHealth = ?1")
    List<Object> findTeamHealthDoctors(String healthDoctor);
	// 查询团队中的全科医生 sf.doctor,sf.doctorName,d.hosptialName,
	//select sf.doctor,sf.doctorName,d.hosptialName,count(*) totalContract from SignFamily sf left join Doctor d on sf.doctor = d.code where sf.doctor = ?1
	@Query("select sf.doctor,sf.doctorName,d.hospitalName,count(sf) from SignFamily sf, Doctor d  where ( sf.doctor is null or sf.doctor = d.code) and sf.doctor = ?1")
    // 查询团队中的全科医生 sf.doctor,sf.doctorName,d.hosptialName,
    //select sf.doctor,sf.doctorName,d.hosptialName,count(*) totalContract from SignFamily sf left join Doctor d on sf.doctor = d.code where sf.doctor = ?1
    @Query("select sf.doctor,sf.doctorName,d.hospitalName,count(sf) from SignFamily sf, Doctor d  where ( sf.doctor is null or sf.doctor = d.code) and sf.doctor = ?1")
    List<Object> findTeamQkDoctors(String doctor);
	// 待签约 待解决 已签约
	@Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b,DoctorTeam t,DoctorTeamMember td where a.patient=b.code and a.teamCode=t.code and t.code=td.team and td.memberCode=?1 and td.type=?2 and a.status=?3 order by a.begin desc")
	Page<Object> findToBeSignSignWebByDoctor(String doctor, int doctorType,int status, Pageable pageRequest);
	/**
	 * 查询全科医生签约患者
	 *
	 * @param doctor
	 * @param status
	 * @param pageRequest
	 * @return
	 */
	@Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b where a.patient=b.code and a.doctor = ?1 and a.status=?2 order by a.begin desc")
	Page<Object> findSignedPatientByQkDoctor(String doctor,int status, Pageable pageRequest);
	/**
	 * 查询健康管理师签约患者
	 *
	 * @param doctor
	 * @param status
	 * @param pageRequest
	 * @return
	 */
	@Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b where a.patient=b.code and a.doctorHealth = ?1 and a.status=?2 order by a.begin desc")
	Page<Object> findSignedPatientByJkDoctor(String doctor,int status, Pageable pageRequest);
	/**
	 * 查询全科医生已解约患者
	 *
	 * @param doctor
	 * @param pageRequest
	 * @return
	 */
	@Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b where a.patient=b.code and a.doctor = ?1 and (a.status=-3 or a.status=-4) order by a.begin desc")
	Page<Object> findUnSignedPatientByQkDoctor(String doctor,Pageable pageRequest);
	/**
	 * 查询健康管理师已解约患者
	 *
	 * @param doctor
	 * @param pageRequest
	 * @return
	 */
	@Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b where a.patient=b.code and a.doctorHealth = ?1 and (a.status=-3 or a.status=-4) order by a.begin desc")
	Page<Object> findUnSignedPatientByJkDoctor(String doctor,Pageable pageRequest);
	//已经解约
	@Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b,DoctorTeam t,DoctorTeamMember td where a.patient=b.code and a.teamCode=t.code and t.code=td.team and td.memberCode=?1 and td.type=?2 and(a.status=-3 or a.status=-4 ) order by a.begin desc")
	Page<Object> findToBeSignSignWebByDoctor_34(String doctor, int doctorType, Pageable pageRequest);
	@Query("select a from SignFamily a where a.mobile = ?1 and a.type = 2 and a.status >= 0")
	SignFamily findByMobile(String mobile);
	@Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b where a.patient=b.code and a.doctor=?1 and a.status=?2 order by a.begin desc")
	Page<Object> findToBeSignSignWebByDoctor_0(String doctor,  int i, Pageable pageRequest);
	@Query("select a from SignFamily a where a.patient = ?1 and a.type =1 and a.status >= 1")
	SignFamily findBySanshiPatient(String code);
	@Query("select a from SignFamily a where a.patient = ?1 and a.type =1 and a.status >= 0")
	SignFamily findBySsPatient(String code);
	@Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >= 1")
	SignFamily findByjiatingPatient(String code);
	@Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status = 1")
	SignFamily findByjiatingPatientYes(String code);
	@Query("select a from SignFamily a where a.patient = ?1 and a.type =1 and a.status = 1")
	SignFamily findBySanshiPatientYes(String id);
	@Query("select a from SignFamily a where a.idcard = ?1 and a.type = 1 and a.status in (0,1,2,3)")
	SignFamily findByPatientSanshiSignInfo(String idCard);
	@Query("select a from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status in (0,1,2,3)")
	SignFamily findByPatientFamilySignInfo(String idCard);
	@Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >=0")
	SignFamily findByjiatingPatientStatus0(String patient);
	//查找昨天的家庭签约数据
	@Query(" from SignFamily a where  a.type =2 and a.status = 1  and unix_timestamp(a.applyDate)>=unix_timestamp(?1) and unix_timestamp(a.applyDate)<unix_timestamp(?2) and a.expensesStatus=1 ")
	List<SignFamily> findByJiatingSignYesterdayExpensesStatus(String yesterday,String today);
	//查找昨天的家庭签约数据
	@Query(" from SignFamily a where  a.type =2 and a.status >= 1  and  unix_timestamp(a.applyDate)<=unix_timestamp(?1) and a.expensesStatus=1 ")
	List<SignFamily> findByJiatingSignYesterdayExpensesStatus(String yesterday);
	//查找昨天的家庭签约数据
	@Query(" from SignFamily a where  a.type =2 and a.status >= 1  and  unix_timestamp(a.applyDate)<=unix_timestamp(?1) ")
	List<SignFamily> findByJiatingSignYesterday(String yesterday);
	//查找昨天的家庭解约数据
	@Query(" from SignFamily a where  a.type =2 and a.status in (-3,-4) and unix_timestamp(a.applyUnsignDate)>=unix_timestamp(?1) and unix_timestamp(a.applyUnsignDate)<unix_timestamp(?2) and a.expensesStatus=1")
	List<SignFamily> findByJiatingUnSignYesterdayExpensesStatus(String yesterday,String today);
	//查找昨天的家庭待数据
	@Query(" from SignFamily a where  a.type =2 and a.status =0  and unix_timestamp(a.patientApplyDate)>=unix_timestamp(?1) and unix_timestamp(a.patientApplyDate)<unix_timestamp(?2)")
	List<SignFamily> findByJiatingWaitSignYesterdayExpensesStatus(String yesterday,String today);
	//查找昨天的家庭待改签
	@Query(" from SignFamily a where  a.type =2 and a.status =100  and unix_timestamp(a.patientApplyDate)>=unix_timestamp(?1) and unix_timestamp(a.patientApplyDate)<unix_timestamp(?2) and a.expensesStatus=1 ")
	List<SignFamily> findByJiatingChaangeSignYesterdayExpensesStatus(String yesterday, String now);
	@Query("select a from SignFamily a where a.patient = ?1 and a.type = 1 and a.status in (0,1,2)")
	SignFamily findSanshiSignByPatient(String patientCode);
	@Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status in (0,1,2)")
	SignFamily findFamilySignByPatient(String patientCode);
	@Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and a.patient = p.code and a.status in (1,2,3)")
	List<Object> findDoctorSignPatients(String doctor);
	@Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard  from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and p.name like ?2 and a.patient = p.code and a.status in (1,2,3)")
	List<Object> findDoctorSignPatientsLikeName(String doctor,String name);
	@Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard  from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and a.type = ?2 and a.patient = p.code and a.status in (1,2,3)")
	List<Object> findDoctorSignPatientsBySignType(String doctor,int type);
	@Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard  from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and a.type = ?2 and p.name like ?3 and a.patient = p.code and a.status in (1,2,3)")
	List<Object> findDoctorSignPatientsByTypeName(String doctor,int type,String name);
	@Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >= 0")
	SignFamily findByPatient(String patient);
	@Query("select a from SignFamily a where a.idcard = ?1 and a.type = 1 and a.status >= 0")
	SignFamily findBySanshiIdcard(String idcard);
	@Query("select a from SignFamily a where a.patient = ?1 and a.type = ?2 and a.status > 0")
	SignFamily findSignByPatient(String patient,int type);
	@Query(" from SignFamily a where a.patient = ?1 and a.type = ?2 and (a.status=-3 or a.status=-4)  order by a.id desc")
	List<SignFamily> findLastJySignByPatient(String patient,int type);
	@Query(" from SignFamily a where  a.type =1 and unix_timestamp(a.czrq)=unix_timestamp( ?1 )  ")
	List<SignFamily> findByDate(String s);
	@Modifying
	@Query("update SignFamily set expenses_type = ?1 where patient = ?2 and status > 0 and type = 2")
	int updateExpensesType(String expensesType,String patient);
	@Query("select count(*) from SignFamily where patient = ?1 and status > 0 and type = 1")
	int countPatientSsSign(String patient);
	@Query("select count(*) from SignFamily where patient = ?1 and status > 0 and type = 2")
	int countPatientJtSign(String patient);
	// 查询患者已生效的家庭签约
	@Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status = 0")
	SignFamily findSigningByPatient(String patient);
	//找出家庭签约中 团队是空的值
	@Query("select a from SignFamily a where a.type = 2 and a.status = 1 and a.adminTeamId is null")
	List<SignFamily> findBySignTypeAndTeamCode();
	//找出没有健康管理师的签约数据
	@Query("select a from SignFamily a where a.type = 2 and a.status >= 1 and a.doctorHealth is null and a.adminTeamId = ?1 order by a.czrq desc")
	List<SignFamily> findNoHealthSignFamilyNum(Long teamCode);
	//找出没有健康管理师的签约数据
	@Query("select a from SignFamily a where a.type = 2 and a.status >= 1 and a.doctorHealth is null and a.doctor=?1 order by a.czrq desc")
	Page<SignFamily> findNoHealthSignFamilyHealth(String doctor, Pageable pageRequest);
	@Query("select a from SignFamily a where a.type = ?1 and a.signSource = ?2 and a.status > 0 order by a.id")
	Page<SignFamily> findByTypeAndSignSource(Integer type,String signSource,Pageable pageable);
	@Query("select a from SignFamily a where a.type = ?1 and a.signSource = ?2 and a.status > 0 and a.id >= ?3 and a.id <= ?4 order by a.id")
	Page<SignFamily> findByTypeAndSignSourceAndId(Integer type,String signSource,Long start,Long end,Pageable pageable);
	@Query("select a from SignFamily a where a.patient = ?1 and a.status >= 0")
	List<SignFamily> findAllSignByPatient(String patient);
	@Query("select a.patient from SignFamily a where a.doctor = ?1 and a.type = 2 and a.status > 0 and a.doctorHealth is null")
	List<String> findNohealthByDoctor(String doctor);
	/**
	 * 获取团队中有效的患者
	 * @param teamCode
	 * @param status
	 * @return
	 */
	@Query("select count(f) from SignFamily f where f.adminTeamId = ?1 and f.status >= ?2 ")
	int findByAdminTeamIdAndStatus(long teamCode,int status);
	@Query("select f from SignFamily f where f.patient = ?1 and f.adminTeamId = ?2 and f.status > 0")
	SignFamily findByPatientAndAdminTeamId(String patient,Long teamCode);
    // 待签约 待解决 已签约
    @Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b,DoctorTeam t,DoctorTeamMember td where a.patient=b.code and a.teamCode=t.code and t.code=td.team and td.memberCode=?1 and td.type=?2 and a.status=?3 order by a.begin desc")
    Page<Object> findToBeSignSignWebByDoctor(String doctor, int doctorType, int status, Pageable pageRequest);
    /**
     * 查询全科医生签约患者
     *
     * @param doctor
     * @param status
     * @param pageRequest
     * @return
     */
    @Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b where a.patient=b.code and a.doctor = ?1 and a.status=?2 order by a.begin desc")
    Page<Object> findSignedPatientByQkDoctor(String doctor, int status, Pageable pageRequest);
    /**
     * 查询健康管理师签约患者
     *
     * @param doctor
     * @param status
     * @param pageRequest
     * @return
     */
    @Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b where a.patient=b.code and a.doctorHealth = ?1 and a.status=?2 order by a.begin desc")
    Page<Object> findSignedPatientByJkDoctor(String doctor, int status, Pageable pageRequest);
    /**
     * 查询全科医生已解约患者
     *
     * @param doctor
     * @param pageRequest
     * @return
     */
    @Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b where a.patient=b.code and a.doctor = ?1 and (a.status=-3 or a.status=-4) order by a.begin desc")
    Page<Object> findUnSignedPatientByQkDoctor(String doctor, Pageable pageRequest);
    /**
     * 查询健康管理师已解约患者
     *
     * @param doctor
     * @param pageRequest
     * @return
     */
    @Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b where a.patient=b.code and a.doctorHealth = ?1 and (a.status=-3 or a.status=-4) order by a.begin desc")
    Page<Object> findUnSignedPatientByJkDoctor(String doctor, Pageable pageRequest);
    //已经解约
    @Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b,DoctorTeam t,DoctorTeamMember td where a.patient=b.code and a.teamCode=t.code and t.code=td.team and td.memberCode=?1 and td.type=?2 and(a.status=-3 or a.status=-4 ) order by a.begin desc")
    Page<Object> findToBeSignSignWebByDoctor_34(String doctor, int doctorType, Pageable pageRequest);
    @Query("select a from SignFamily a where a.mobile = ?1 and a.type = 2 and a.status >= 0")
    SignFamily findByMobile(String mobile);
    @Query("select a.code,a.doctor,b.code,b.name,b.provinceName,b.cityName,b.townName,b.address,b.photo,a.status,a.id,a.applyDate,a.reason,b.streetName,b.sex from SignFamily a,Patient b where a.patient=b.code and a.doctor=?1 and a.status=?2 order by a.begin desc")
    Page<Object> findToBeSignSignWebByDoctor_0(String doctor, int i, Pageable pageRequest);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =1 and a.status >= 1")
    SignFamily findBySanshiPatient(String code);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =1 and a.status >= 0")
    SignFamily findBySsPatient(String code);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >= 1")
    SignFamily findByjiatingPatient(String code);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status = 1")
    SignFamily findByjiatingPatientYes(String code);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =1 and a.status = 1")
    SignFamily findBySanshiPatientYes(String id);
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 1 and a.status in (0,1,2,3)")
    SignFamily findByPatientSanshiSignInfo(String idCard);
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 2 and a.status in (0,1,2,3)")
    SignFamily findByPatientFamilySignInfo(String idCard);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >=0")
    SignFamily findByjiatingPatientStatus0(String patient);
    //查找昨天的家庭签约数据
    @Query(" from SignFamily a where  a.type =2 and a.status = 1  and unix_timestamp(a.applyDate)>=unix_timestamp(?1) and unix_timestamp(a.applyDate)<unix_timestamp(?2) and a.expensesStatus=1 ")
    List<SignFamily> findByJiatingSignYesterdayExpensesStatus(String yesterday, String today);
    //查找昨天的家庭签约数据
    @Query(" from SignFamily a where  a.type =2 and a.status >= 1  and  unix_timestamp(a.applyDate)<=unix_timestamp(?1) and a.expensesStatus=1 ")
    List<SignFamily> findByJiatingSignYesterdayExpensesStatus(String yesterday);
    //查找昨天的家庭签约数据
    @Query(" from SignFamily a where  a.type =2 and a.status >= 1  and  unix_timestamp(a.applyDate)<=unix_timestamp(?1) ")
    List<SignFamily> findByJiatingSignYesterday(String yesterday);
    //查找昨天的家庭解约数据
    @Query(" from SignFamily a where  a.type =2 and a.status in (-3,-4) and unix_timestamp(a.applyUnsignDate)>=unix_timestamp(?1) and unix_timestamp(a.applyUnsignDate)<unix_timestamp(?2) and a.expensesStatus=1")
    List<SignFamily> findByJiatingUnSignYesterdayExpensesStatus(String yesterday, String today);
    //查找昨天的家庭待数据
    @Query(" from SignFamily a where  a.type =2 and a.status =0  and unix_timestamp(a.patientApplyDate)>=unix_timestamp(?1) and unix_timestamp(a.patientApplyDate)<unix_timestamp(?2)")
    List<SignFamily> findByJiatingWaitSignYesterdayExpensesStatus(String yesterday, String today);
    //查找昨天的家庭待改签
    @Query(" from SignFamily a where  a.type =2 and a.status =100  and unix_timestamp(a.patientApplyDate)>=unix_timestamp(?1) and unix_timestamp(a.patientApplyDate)<unix_timestamp(?2) and a.expensesStatus=1 ")
    List<SignFamily> findByJiatingChaangeSignYesterdayExpensesStatus(String yesterday, String now);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 1 and a.status in (0,1,2)")
    SignFamily findSanshiSignByPatient(String patientCode);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status in (0,1,2)")
    SignFamily findFamilySignByPatient(String patientCode);
    @Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and a.patient = p.code and a.status in (1,2,3)")
    List<Object> findDoctorSignPatients(String doctor);
    @Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard  from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and p.name like ?2 and a.patient = p.code and a.status in (1,2,3)")
    List<Object> findDoctorSignPatientsLikeName(String doctor, String name);
    @Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard  from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and a.type = ?2 and a.patient = p.code and a.status in (1,2,3)")
    List<Object> findDoctorSignPatientsBySignType(String doctor, int type);
    @Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard  from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and a.type = ?2 and p.name like ?3 and a.patient = p.code and a.status in (1,2,3)")
    List<Object> findDoctorSignPatientsByTypeName(String doctor, int type, String name);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >= 0")
    SignFamily findByPatient(String patient);
    @Query("select a from SignFamily a where a.idcard = ?1 and a.type = 1 and a.status >= 0")
    SignFamily findBySanshiIdcard(String idcard);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = ?2 and a.status > 0")
    SignFamily findSignByPatient(String patient, int type);
    @Query(" from SignFamily a where a.patient = ?1 and a.type = ?2 and (a.status=-3 or a.status=-4)  order by a.id desc")
    List<SignFamily> findLastJySignByPatient(String patient, int type);
    @Query(" from SignFamily a where  a.type =1 and unix_timestamp(a.czrq)=unix_timestamp( ?1 )  ")
    List<SignFamily> findByDate(String s);
    @Modifying
    @Query("update SignFamily set expenses_type = ?1 where patient = ?2 and status > 0 and type = 2")
    int updateExpensesType(String expensesType, String patient);
    @Query("select count(*) from SignFamily where patient = ?1 and status > 0 and type = 1")
    int countPatientSsSign(String patient);
    @Query("select count(*) from SignFamily where patient = ?1 and status > 0 and type = 2")
    int countPatientJtSign(String patient);
    // 查询患者已生效的家庭签约
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status = 0")
    SignFamily findSigningByPatient(String patient);
    //找出家庭签约中 团队是空的值
    @Query("select a from SignFamily a where a.type = 2 and a.status = 1 and a.adminTeamId is null")
    List<SignFamily> findBySignTypeAndTeamCode();
    //找出没有健康管理师的签约数据
    @Query("select a from SignFamily a where a.type = 2 and a.status >= 1 and a.doctorHealth is null and a.adminTeamId = ?1 order by a.czrq desc")
    List<SignFamily> findNoHealthSignFamilyNum(Long teamCode);
    //找出没有健康管理师的签约数据
    @Query("select a from SignFamily a where a.type = 2 and a.status >= 1 and a.doctorHealth is null and a.doctor=?1 order by a.czrq desc")
    Page<SignFamily> findNoHealthSignFamilyHealth(String doctor, Pageable pageRequest);
    @Query("select a from SignFamily a where a.type = ?1 and a.signSource = ?2 and a.status > 0 order by a.id")
    Page<SignFamily> findByTypeAndSignSource(Integer type, String signSource, Pageable pageable);
    @Query("select a from SignFamily a where a.type = ?1 and a.signSource = ?2 and a.status > 0 and a.id >= ?3 and a.id <= ?4 order by a.id")
    Page<SignFamily> findByTypeAndSignSourceAndId(Integer type, String signSource, Long start, Long end, Pageable pageable);
    @Query("select a from SignFamily a where a.patient = ?1 and a.status >= 0")
    List<SignFamily> findAllSignByPatient(String patient);
    @Query("select a.patient from SignFamily a where a.doctor = ?1 and a.type = 2 and a.status > 0 and a.doctorHealth is null")
    List<String> findNohealthByDoctor(String doctor);
    /**
     * 获取团队中有效的患者
     *
     * @param teamCode
     * @param status
     * @return
     */
    @Query("select count(f) from SignFamily f where f.adminTeamId = ?1 and f.status >= ?2 ")
    int findByAdminTeamIdAndStatus(long teamCode, int status);
    @Query("select f from SignFamily f where f.patient = ?1 and f.adminTeamId = ?2 and f.status > 0 and f.type = ?3")
    SignFamily findByPatientAndAdminTeamId(String patient, Long teamCode, Integer type);
}

+ 185 - 230
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -38,20 +38,15 @@ import org.apache.poi.hssf.util.HSSFColor;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
@ -516,41 +511,6 @@ public class ConsultTeamService extends ConsultService {
        }
    }
    /**
     * 查询居民咨询记录
     *
     * @param patient
     * @param teamCode
     * @param page
     * @param pageSize
     * @return
     */
    public JSONArray findByPatientAndTeam(String patient, Long teamCode, int page, int pageSize) {
        PageRequest pageRequest = new PageRequest(page, pageSize);
        Patient p = patientDao.findByCode(patient);
        Page<Object> result = consultDao.findByPatientAndTeam(patient, teamCode, pageRequest);
        JSONArray array = new JSONArray();
        for (Object obj : result) {
            JSONObject consult = new JSONObject();
            Object[] objArr = (Object[]) obj;
            consult.put("id", objArr[0]);
            consult.put("code", objArr[2]);
            consult.put("type", objArr[1]);
            consult.put("title", objArr[3]);
            consult.put("symptoms", objArr[4]);
            consult.put("czrq", objArr[5]);
            consult.put("status", objArr[6]);
            consult.put("adminTeamCode", objArr[7]);
            consult.put("patient", patient);
            consult.put("patientName", p.getName());
            consult.put("patientPhoto", p.getPhoto());
            array.put(consult);
        }
        return array;
    }
    /**
     * 网络咨询咨询日志查询
     *
@ -594,18 +554,53 @@ public class ConsultTeamService extends ConsultService {
     * @return
     */
    public void reply(List<ConsultTeamLog> logs, String patient) throws Exception {
        //ConsultTeam consultTeam = consultTeamDao.findByConsult(logs.get(0).getConsult());
        //WlyyTalkGroup wlyyTalkGroup = talkGroupService.findConsultTalkGroupByType(logs.get(0).getConsult(), 2);
        //for (ConsultTeamLog log : logs) {
        //    reply(log, patient, null, log.getType());
        //    //判断当前咨询是否创建讨论租
        //    if (wlyyTalkGroup != null) {
        //        sendGroupIM(patient, wlyyTalkGroup.getCode(), log.getChatType() + "", log.getContent());
        //    } else {
        //        //推送给IM
        //        sendIM(patient, consultTeam.getDoctor(), log.getChatType() + "", log.getContent());
        //    }
        //}
        ConsultTeam consultTeam = consultTeamDao.findByConsult(logs.get(0).getConsult());
        WlyyTalkGroup wlyyTalkGroup = talkGroupService.findConsultTalkGroupByType(logs.get(0).getConsult(), 2);
        for (ConsultTeamLog log : logs) {
            reply(log, patient, null, log.getType());
            //判断当前咨询是否创建讨论租
            if (wlyyTalkGroup != null) {
                sendGroupIM(patient, wlyyTalkGroup.getCode(), log.getChatType() + "", log.getContent());
            } else {
                //推送给IM
                sendIM(patient, consultTeam.getDoctor(), log.getChatType() + "", log.getContent());
            }
        }
    }
    /**
     * 查询居民咨询记录
     *
     * @param patient
     * @param teamCode
     * @param page
     * @param pageSize
     * @return
     */
    public JSONArray findByPatientAndTeam(String patient, Long teamCode, int page, int pageSize) {
        PageRequest pageRequest = new PageRequest(page, pageSize);
        Patient p = patientDao.findByCode(patient);
        Page<Object> result = consultDao.findByPatientAndTeam(patient, teamCode, pageRequest);
        JSONArray array = new JSONArray();
        for (Object obj : result) {
            JSONObject consult = new JSONObject();
            Object[] objArr = (Object[]) obj;
            consult.put("id", objArr[0]);
            consult.put("code", objArr[2]);
            consult.put("type", objArr[1]);
            consult.put("title", objArr[3]);
            consult.put("symptoms", objArr[4]);
            consult.put("czrq", objArr[5]);
            consult.put("status", objArr[6]);
            consult.put("adminTeamCode", objArr[7]);
            consult.put("patient", patient);
            consult.put("patientName", p.getName());
            consult.put("patientPhoto", p.getPhoto());
            array.put(consult);
        }
        return array;
    }
    /**
@ -663,7 +658,6 @@ public class ConsultTeamService extends ConsultService {
     * @throws Exception
     */
    public int addTeamConsult(ConsultTeam ct, String patient) throws Exception {
        JSONObject users = new JSONObject();
        // 咨询三师
        if (ct.getType() == 1) {
            // 查询三师签约信息
@ -675,22 +669,15 @@ public class ConsultTeamService extends ConsultService {
            ct.setTeam(sc.getTeamCode());
            // 设置健康管理师,三师咨询默认给健康管理师处理
            //查找病人所在的团队
             DoctorTeam doctorTeam = doctorTeamDao.findBySanshiParientCode(patient);
            DoctorTeam doctorTeam = doctorTeamDao.findBySanshiParientCode(patient);
            //得到团队的健康管理师
            DoctorTeamMember doctorTeamMemberHealthy = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 3);
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 2);
            if (doctorTeamMemberHealthy == null) {
                ct.setDoctor(doctorTeamMember.getMemberCode());
                users.put(doctorTeamMember.getMemberCode(),0);
            }else{
                users.put(doctorTeamMemberHealthy.getMemberCode(),0);
                if(doctorTeamMember!=null){
                    users.put(doctorTeamMember.getMemberCode(),1);
                }
                ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 3);
            if (doctorTeamMember == null) {
                doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 2);
            }
            // 设置家庭医生
            ct.setDoctor(doctorTeamMember.getMemberCode());
            ct.setAdminTeamId(sc.getAdminTeamId());
        } else if (ct.getType() == 2) {
            // 咨询家庭医生
@ -703,19 +690,14 @@ public class ConsultTeamService extends ConsultService {
            //查找病人所在的团队
            DoctorTeam doctorTeam = doctorTeamDao.findByParientCode(patient);
            //得到团队的健康管理师
            DoctorTeamMember doctorTeamMemberHealthy = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 3);
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
            if (doctorTeamMemberHealthy == null) {
                ct.setDoctor(doctorTeamMember.getMemberCode());
                users.put(doctorTeamMemberHealthy.getMemberCode(),0);
            }else{
                users.put(doctorTeamMemberHealthy.getMemberCode(),0);
                if(doctorTeamMember!=null){
                    users.put(doctorTeamMember.getMemberCode(),1);
                }
                ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 3);
            if (doctorTeamMember == null) {
                doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
            }
            ct.setTeam(sf.getTeamCode());
            // 设置家庭医生
            ct.setDoctor(doctorTeamMember.getMemberCode());
            ct.setAdminTeamId(sf.getAdminTeamId());
        }
        // 设置患者信息
@ -751,113 +733,48 @@ public class ConsultTeamService extends ConsultService {
        cd.setTo(ct.getDoctor());
        // 添加医生咨询日志
        String content = addLogs(ct);
        //推送给IM去创建议题,取得成员消息
        DoctorTeam doctorTeam = doctorTeamDao.findByParientCode(patient);
        JSONObject messages = new JSONObject();
        messages.put("description",consult.getSymptoms());
        messages.put("title",consult.getTitle());
        messages.put("img",consult.getImages());
        messages.put("senderId",patient);
        messages.put("senderName",tempPatient.getName());
        users.put(patient,0);
        JSONObject obj  = createTopics(UUID.randomUUID().toString(),consult.getCode(),"咨询问题:"+consult.getSymptoms(),users,messages,"1");
        if(obj==null){
            throw new RuntimeException("IM消息结束异常!");
        //推送给IM文字消息
        String returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
        JSONObject jo = new JSONObject(returnJson);
        if (jo.has("startId")) {
            //设置消息ID
            ct.setStartMsgId(jo.getInt("startId"));
            //推送给IM图片
            if (StringUtils.isNotEmpty(ct.getImages())) {
                String[] images = ct.getImages().split(",");
                for (String image : images) {
                    if (StringUtils.isNoneEmpty(image)) {
                        sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
                    }
                }
            }
        }
        ct.setStartMsgId(obj.get("id").toString());
        consultTeamDao.save(ct);
        consultDao.save(consult);
        consultTeamDoctorDao.save(cd);
        return 1;
    }
    /**
     * 发送消息给IM
     *
     * @param from        来自
     * @param to
     * @param contentType 1文字 2图片消息
     * @param content     内容
     */
    private String sendIM(String from,String fromName, String sessionId, String contentType, String content) {
        String imAddr = SystemConf.getInstance().getImListGet() + "/api/v2/sessions/"+sessionId+"/messages";
        JSONObject params = new JSONObject();
        params.put("sender_id", from);
        params.put("sender_name", fromName);
        params.put("content_type", contentType);
        params.put("content", content);
        params.put("sessionId", sessionId);;
        String response = HttpClientUtil.postBody(imAddr, params);
    private String sendIM(String from, String to, String contentType, String content) {
        String imAddr = SystemConf.getInstance().getImListGet() + "api/v1/chats/pm";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("from", from));
        params.add(new BasicNameValuePair("to", to));
        params.add(new BasicNameValuePair("contentType", contentType));
        params.add(new BasicNameValuePair("content", content));
        String response = HttpClientUtil.post(imAddr, params, "UTF-8");
        return response;
    }
    /**
     * 创建议题
     *
     * @param topicId  议题ID
     * @param topicName  议题名称
     * @param participants 成员
     */
    private JSONObject createTopics(String sessionId, String topicId,String topicName, JSONObject participants,JSONObject messages,String sessionType) {
        String imAddr = SystemConf.getInstance().getImListGet() + "api/v2/sessions/"+sessionId+"/topics";
        JSONObject params = new JSONObject();
        params.put("topic_id", topicId);
        params.put("topic_name", topicName);
        params.put("participants", participants.toString());
        params.put("messages", messages.toString());
        params.put("session_id", sessionId);
        params.put("session_type", sessionType);
        String ret = HttpClientUtil.postBody(imAddr,params);
        JSONObject obj  = null;
        try{
            obj = new JSONObject(ret);
        }catch (Exception e){
            return null;
        }
        return obj;
    }
    /**
     * 结束议题
     *
     * @param topicId  议题ID
     * @param endUser  结束人
     * @param endUserName 结束人名字
     * @param sessionId 会话ID
     */
    private JSONObject endTopics(String sessionId,String endUser, String endUserName,String topicId) {
        String imAddr = SystemConf.getInstance().getImListGet() + "api/v2/sessions/"+sessionId+"/topics/"+topicId+"/ended";
        JSONObject params = new JSONObject();
        params.put("session_id", sessionId);
        params.put("end_user", endUser);
        params.put("end_user_name",endUserName);
        params.put("topic_id", topicId);
        String ret = HttpClientUtil.postBody(imAddr,params);
        JSONObject obj  = null;
        try{
            obj = new JSONObject(ret);
        }catch (Exception e){
            return null;
        }
        return obj;
    }
    /**
     * 议题邀请人员
     * @param user 结束人名字
     * @param sessionId 会话ID
     */
    private void updateTopicUser(String sessionId,String user) {
        String imAddr = SystemConf.getInstance().getImListGet() + "api/v2/sessions/"+sessionId+"/participants/"+user;
        JSONObject params = new JSONObject();
        params.put("user", user+":"+0);
        HttpClientUtil.putBody(imAddr,params);
    }
    /**
     * 发送消息给IM
     *
@ -1015,24 +932,38 @@ public class ConsultTeamService extends ConsultService {
    public int finish(String consult, String endOperator, int endType) throws Exception {
        ConsultTeam consultTeam = consultTeamDao.findByConsult(consult);
        String endName = "";
        String endId = "";
        String name = "";
        String returnJson = "";
        //推送给IM文字消息
        if (endType == 1) {
            Patient p = patientDao.findByCode(endOperator);
            endName = p.getName();
            endId = p.getCode();
            name = p.getName();
            returnJson = sendIM(consultTeam.getPatient(), consultTeam.getDoctor(), "7", name + "结束了本次咨询");
        } else {
            Doctor d = doctorDao.findByCode(endOperator);
            endId = d.getCode();
            endName = d.getName();
            name = d.getName();
            returnJson = sendIM(consultTeam.getDoctor(), consultTeam.getPatient(), "7", name + "结束了本次咨询");
        }
        JSONObject obj = endTopics(consultTeam.getPatient(),endId,endName,consultTeam.getConsult());
        if(obj==null){
            throw new RuntimeException("IM消息结束异常!");
        if (StringUtils.isEmpty(returnJson)) {
            throw new Exception("send consult finished IM message failed");
        } else {
            JSONObject jo = new JSONObject(returnJson);            //设置消息ID
            consultTeam.setEndMsgId(jo.getInt("startId"));
            consultTeam.setEndOperator(endOperator);
            consultTeam.setEndType(endType);
        }
        JSONObject group = talkGroupService.findConsultTalkGroup(consultTeam.getConsult());
        if (group != null) {
            String json = sendGroupIM(endOperator, group.getString("code"), "7", name + "结束了本次咨询");
            if (StringUtils.isEmpty(json)) {
                throw new Exception("send consult finished IM message failed");
            }
        }
        consultTeam.setType(endType);
        consultTeam.setEndMsgId(obj.get("id").toString());
        return consultTeamDao.updateStatusByConsult(consult);
    }
@ -1234,7 +1165,6 @@ public class ConsultTeamService extends ConsultService {
    public void addFamousTeamConsult(ConsultTeam ct, String uid, String type) throws Exception {
        // 设置患者信息
        ct.setPatient(uid);
        JSONObject messages = new JSONObject();
        if ("1".equals(type)) {
            // 查询患者信息
            Patient tempPatient = patientDao.findByCode(uid);
@ -1246,11 +1176,6 @@ public class ConsultTeamService extends ConsultService {
            ct.setSex(tempPatient.getSex());
            // 设置患者头像
            ct.setPhoto(tempPatient.getPhoto());
            messages.put("senderId",tempPatient.getCode());
            messages.put("senderName",tempPatient.getName());
        } else if ("2".equals(type)) {
            Doctor doctorTemp = doctorDao.findByCode(uid);
            // 设置医生姓名
@ -1283,19 +1208,20 @@ public class ConsultTeamService extends ConsultService {
        // 添加医生咨询日志
        String content = addLogs(ct);
        //推送给IM文字消息
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(ct.getPatient(),0);
        jsonObject.put(ct.getDoctor(),0);
        messages.put("description",consult.getSymptoms());
        messages.put("title",consult.getTitle());
        messages.put("img",consult.getImages());
        JSONObject obj = createTopics(String.valueOf(jsonObject.hashCode()),consult.getCode(),consult.getSymptoms(),jsonObject,messages,"2");
        if(obj==null){
            throw new RuntimeException("im消息创建异常!");
        }
        String returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
        ;
        JSONObject jo = new JSONObject(returnJson);
        //设置消息ID
        ct.setStartMsgId(obj.get("id").toString());
        ct.setStartMsgId(jo.getInt("startId"));
        //推送给IM图片
        if (StringUtils.isNotEmpty(ct.getImages())) {
            String[] images = ct.getImages().split(",");
            for (String image : images) {
                if (StringUtils.isNoneEmpty(image)) {
                    sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
                }
            }
        }
        consultTeamDao.save(ct);  // 保存医生咨询信息
        consultTeamDoctorDao.save(cd);
        consultDao.save(consult);
@ -1396,31 +1322,36 @@ public class ConsultTeamService extends ConsultService {
        // 添加医生咨询日志
        String content = addLogs(ct);
        //推送给IM文字消息
        JSONObject messages = new JSONObject();
        messages.put("description",content);
        messages.put("title",consult.getTitle());
        messages.put("img",consult.getImages());
        messages.put("senderId",doctorTemp.getCode());
        messages.put("senderName",doctorTemp.getName());
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(ct.getPatient(),0);
        jsonObject.put(ct.getDoctor(),0);
        //设置消息ID
        JSONObject obj = createTopics(String.valueOf(jsonObject.hashCode()),consult.getCode(),"咨询求助:"+doctorTemp.getName(),jsonObject,messages,"2");
        if(obj==null){
            throw new RuntimeException("im消息创建异常!");
        }
        ct.setStartMsgId(obj.get("id").toString());
        //转发咨询问题
        if(StringUtils.isNotBlank(oldConsultCode)){
            Consult oldConsult = consultDao.findByCode(oldConsultCode);
        String returnJson = null;
        JSONObject jo;
        if(StringUtils.isNotEmpty(oldConsultCode)){
            ConsultTeam oldConsult =  consultTeamDao.findByConsult(oldConsultCode);
            if(oldConsult!=null){
                sendIM(doctorTemp.getCode(),doctorTemp.getName(),String.valueOf(jsonObject.hashCode()),"6",content);
                if(StringUtils.isNotBlank(oldConsult.getImages())){
                    String imgs[] = oldConsult.getImages().split(",");
                    for(String url :imgs)
                       sendIM(doctorTemp.getCode(),doctorTemp.getName(),String.valueOf(jsonObject.hashCode()),"2",url);
                returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", "居民问题:" +oldConsult.getSymptoms());
                //推送给IM图片
                if (StringUtils.isNotEmpty(oldConsult.getImages())) {
                    String[] images = oldConsult.getImages().split(",");
                    for (String image : images) {
                        if (StringUtils.isNoneEmpty(image)) {
                            sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
                        }
                    }
                }
            }
        }
        if(StringUtils.isEmpty(returnJson))
            returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
        else
            sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
        jo = new JSONObject(returnJson);
        //设置消息ID
        ct.setStartMsgId(jo.getInt("startId"));
        //推送给IM图片
        if (StringUtils.isNotEmpty(ct.getImages())) {
            String[] images = ct.getImages().split(",");
            for (String image : images) {
                if (StringUtils.isNoneEmpty(image)) {
                    sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
                }
            }
        }
@ -1430,12 +1361,38 @@ public class ConsultTeamService extends ConsultService {
    }
    /**
     * @param ct
     * @param uid
     * @throws Exception
     */
    public void sendForHelpMsg(String oldConsultCode,String userId) throws Exception {
        Consult consult = consultDao.findByCode(oldConsultCode);
    public void sendForHelpMsg(ConsultTeam ct, String uid, String oldConsultCode) throws Exception {
        ct.setPatient(uid);
        //推送给IM文字消息
        updateTopicUser(consult.getPatient(),userId);
        if(StringUtils.isNotEmpty(oldConsultCode)){
            ConsultTeam oldConsult =  consultTeamDao.findByConsult(oldConsultCode);
            if(oldConsult!=null){
                sendIM(ct.getPatient(), ct.getDoctor(), "6", "居民问题:" +oldConsult.getSymptoms());
                //推送给IM图片
                if (StringUtils.isNotEmpty(oldConsult.getImages())) {
                    String[] images = oldConsult.getImages().split(",");
                    for (String image : images) {
                        if (StringUtils.isNoneEmpty(image)) {
                            sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
                        }
                    }
                }
            }
        }
        sendIM(ct.getPatient(), ct.getDoctor(), "6", "咨询问题:"+ ct.getSymptoms());
        //推送给IM图片
        if (StringUtils.isNotEmpty(ct.getImages())) {
            String[] images = ct.getImages().split(",");
            for (String image : images) {
                if (StringUtils.isNoneEmpty(image)) {
                    sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
                }
            }
        }
    }
    /**
@ -1455,11 +1412,11 @@ public class ConsultTeamService extends ConsultService {
    public boolean isCommonTeam(String docCode1, String docCode2){
        String sqlQuSum =
                "SELECT c.team_id FROM " +
                    "(SELECT a.* FROM wlyy_admin_team_member a where a.doctor_code='"+ docCode1 +"' ) c " +
                    "LEFT JOIN " +
                    "(SELECT b.* FROM wlyy_admin_team_member b where b.doctor_code='"+ docCode2 +"' ) d " +
                    "on c.team_id=d.team_id " +
                    "WHERE d.team_id IS NOT NULL";
                        "(SELECT a.* FROM wlyy_admin_team_member a where a.doctor_code='"+ docCode1 +"' ) c " +
                        "LEFT JOIN " +
                        "(SELECT b.* FROM wlyy_admin_team_member b where b.doctor_code='"+ docCode2 +"' ) d " +
                        "on c.team_id=d.team_id " +
                        "WHERE d.team_id IS NOT NULL";
        List ls = jdbcTemplate.queryForList(sqlQuSum);
        return ls!=null && ls.size()>0;
    }
@ -1472,6 +1429,4 @@ public class ConsultTeamService extends ConsultService {
    public List findByTeam(String consult){
        return consultTeamDao.findByTeamAndType(consult, 10);
    }
}

+ 7 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -199,6 +199,8 @@ public class FollowUpService extends BaseService {
            for (Object obj : result) {
                JSONObject followup = new JSONObject();
                Object[] objArr = (Object[]) obj;
                followup.put("id", objArr[15]);
                followup.put("followupNo", objArr[16]);
                followup.put("doctorCode", objArr[0]);
                followup.put("doctorName", objArr[1]);
                followup.put("doctorPhoto", objArr[2]);
@ -208,13 +210,16 @@ public class FollowUpService extends BaseService {
                followup.put("followupClassName", objArr[4] == null ? "" : (objArr[4].toString().equals("1") ? "高血压" : "糖尿病"));
                followup.put("status", objArr[5] == null ? "" : objArr[5]);
                followup.put("statusName", objArr[5] == null ? "" : (statusMap.get(objArr[5].toString()) != null ? statusMap.get(objArr[5].toString()) : ""));
                followup.put("createTime", objArr[6]);
                followup.put("updateTime", objArr[7]);
                followup.put("createTime", objArr[6] != null ? DateUtil.dateToStrLong((Date)objArr[6]) : "");
                followup.put("updateTime", objArr[7] != null ? DateUtil.dateToStrLong((Date)objArr[7]) : "");
                followup.put("managerStatus", objArr[8] == null ? "" : objArr[8]);
                followup.put("managerStatusName", objArr[8] == null ? "" : (mngStatusMap.get(objArr[8].toString()) != null ? mngStatusMap.get(objArr[8].toString()) : ""));
                followup.put("creatorCode", objArr[9]);
                followup.put("creatorName", objArr[10]);
                followup.put("creatorPhoto", objArr[11]);
                followup.put("followupDate", objArr[12] != null ? DateUtil.dateToStrLong((Date)objArr[12]) : "");
                followup.put("followupPlanDate", objArr[13] != null ? DateUtil.dateToStrLong((Date)objArr[13]) : "");
                followup.put("followupNextDate", objArr[14] != null ? DateUtil.dateToStrLong((Date)objArr[14]) : "");
                array.put(followup);
            }
        }

+ 246 - 225
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reservation/PatientReservationService.java

@ -6,9 +6,12 @@ import javax.transaction.Transactional;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.third.guahao.GuahaoXMService;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@ -29,247 +32,265 @@ import com.yihu.wlyy.service.BaseService;
/**
 * 预约挂号业务处理类
 * @author George
 *
 * @author George
 */
@Component
@Transactional(rollbackOn = Exception.class)
public class PatientReservationService extends BaseService {
	@Autowired
	private PatientReservationDao patientReservationDao;
	@Autowired
	private PatientReservationDoctorDao patientReservationDoctorDao;
    @Autowired
    private PatientReservationDao patientReservationDao;
    @Autowired
    private PatientReservationDoctorDao patientReservationDoctorDao;
	@Autowired
	private GuahaoXMService  guahaoXMService;
    @Autowired
    private GuahaoXMService guahaoXMService;
	@Autowired
	private ObjectMapper objectMapper;
    @Autowired
    private ObjectMapper objectMapper;
	@Autowired
	private PatientDao patientDao;
    @Autowired
    private PatientDao patientDao;
	public PatientReservation findByCode(String code){
		return patientReservationDao.findByCode(code);
	}
    @Autowired
    private DoctorDao doctorDao;
	public PatientReservation findById(Long id) throws Exception{
		PatientReservation re = patientReservationDao.findById(id);
    public PatientReservation findByCode(String code) {
        return patientReservationDao.findByCode(code);
    }
		if(re==null)
		{
			throw new Exception("not exit result!id:"+id);
		}
    public PatientReservation findById(Long id) throws Exception {
        PatientReservation re = patientReservationDao.findById(id);
		return re;
	}
        if (re == null) {
            throw new Exception("not exit result!id:" + id);
        }
        return re;
    }
	/**
	 * 实体转map
	 */
	private Map<String, String> entityToMap(PatientReservation obj) throws Exception {
		String mapString = objectMapper.writeValueAsString(obj);
		return objectMapper.readValue(mapString, Map.class);
	}
	/**
	 * 更新预约状态
    /**
     * 实体转map
     */
    private Map<String, String> entityToMap(PatientReservation obj) throws Exception {
        String mapString = objectMapper.writeValueAsString(obj);
        return objectMapper.readValue(mapString, Map.class);
    }
    /**
     * 更新预约状态
     */
    @Transactional
    public void updateStatus(Long id, Integer status) {
        PatientReservation obj = patientReservationDao.findOne(id);
        if (!obj.getStatus().equals(status)) {
            obj.setStatus(status);
            patientReservationDao.save(obj);
        }
    }
    /**
     * 保存预约挂号记录
     *
     * @param code         预约号/流水号
     * @param doctor       医生标识
     * @param patient      患者标识
     * @param idcard       患者身份证号
     * @param name         患者姓名
     * @param phone        患者手机号
     * @param ssc          患者社保卡号
     * @param section_type 预约时间段:AM (上午)或者PM (下午)
     * @param start_time   一次预约段的开始时间
     * @param org_code     医生所在医疗机构编码
     * @param org_name     医疗机构名称
     * @param dept_code    科室编码
     * @param dept_name    科室名称
     * @param doctor_code  专家ID/编码
     * @param doctor_name  专家姓名
     * @param doctor_photo 专家头像
     * @return
     */
    public void save(String code, Doctor doctor, String patient, String idcard, String name, String phone, String ssc, String section_type, String start_time, String org_code, String org_name, String dept_code, String dept_name, String doctor_code, String doctor_name, String doctor_job, String doctor_photo) {
        try {
            PatientReservation reservation = new PatientReservation();
            reservation.setCode(code);
            reservation.setCzrq(new Date());
            reservation.setType("1");
            reservation.setDeptCode(dept_code);
            reservation.setDeptName(dept_name);
            if (doctor != null) {
                reservation.setDname(doctor.getName());
                reservation.setDoctor(doctor.getCode());
            }
            reservation.setDoctorCode(doctor_code);
            reservation.setDoctorName(doctor_name);
            reservation.setDoctorJob(doctor_job);
            reservation.setDoctorPhoto(doctor_photo);
            reservation.setIdcard(idcard);
            reservation.setName(doctor_name);
            reservation.setOrgCode(org_code);
            reservation.setOrgName(org_name);
            reservation.setPatient(patient);
            reservation.setPhone(phone);
            reservation.setSectionType(section_type);
            reservation.setSsc(ssc);
            reservation.setStartTime(start_time);
            reservation.setStatus(1);
            // 保存记录
            PatientReservation temp = patientReservationDao.save(reservation);
            if (temp != null) {
                // 先删除,防止重复
                patientReservationDoctorDao.deleteByPatient(patient, org_code, dept_code, doctor_code);
                // 添加预约过的医生
                PatientReservationDoctor prd = new PatientReservationDoctor();
                prd.setDeptCode(dept_code);
                prd.setDeptName(dept_name);
                prd.setDoctorCode(doctor_code);
                prd.setDoctorName(doctor_name);
                prd.setOrgCode(org_code);
                prd.setOrgName(org_name);
                prd.setPatient(patient);
                patientReservationDoctorDao.save(prd);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 查询患者预约过的医生列表
     *
     * @param patient
     * @return
     */
    public Page<PatientReservationDoctor> findRecordByPatient(String patient, long id, int pagesize) {
        // 排序
        Sort sort = new Sort(Direction.DESC, "id");
        // 分页信息
        PageRequest pageRequest = new PageRequest(0, pagesize, sort);
        // 设置查询条件
        Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
        // 未指定医生
        filters.put("patient", new SearchFilter("patient", Operator.EQ, patient));
        if (id > 0) {
            filters.put("id", new SearchFilter("id", Operator.LT, id));
        }
        Specification<PatientReservationDoctor> spec = DynamicSpecifications.bySearchFilter(filters.values(), PatientReservationDoctor.class);
        return patientReservationDoctorDao.findAll(spec, pageRequest);
    }
    /**
     * 分页获取患者预约记录,医生为空查患者所有
     */
	@Transactional
	public void updateStatus(Long id,Integer status)
	{
		PatientReservation obj=  patientReservationDao.findOne(id);
		if(!obj.getStatus().equals(status))
		{
			obj.setStatus(status);
			patientReservationDao.save(obj);
		}
	}
	/**
	 * 保存预约挂号记录
	 * @param code 预约号/流水号
	 * @param doctor 医生标识
	 * @param patient 患者标识
	 * @param idcard 患者身份证号
	 * @param name 患者姓名
	 * @param phone 患者手机号
	 * @param ssc 患者社保卡号
	 * @param section_type 预约时间段:AM (上午)或者PM (下午)
	 * @param start_time 一次预约段的开始时间
	 * @param org_code 医生所在医疗机构编码
	 * @param org_name 医疗机构名称
	 * @param dept_code 科室编码
	 * @param dept_name 科室名称
	 * @param doctor_code 专家ID/编码
	 * @param doctor_name 专家姓名
	 * @param doctor_photo 专家头像
	 * @return
	 */
	public void save(String code, Doctor doctor, String patient, String idcard, String name, String phone, String ssc, String section_type, String start_time, String org_code, String org_name, String dept_code, String dept_name, String doctor_code, String doctor_name, String doctor_job, String doctor_photo) {
		try {
			PatientReservation reservation = new PatientReservation();
			reservation.setCode(code);
			reservation.setCzrq(new Date());
			reservation.setType("1");
			reservation.setDeptCode(dept_code);
			reservation.setDeptName(dept_name);
			if (doctor != null) {
				reservation.setDname(doctor.getName());
				reservation.setDoctor(doctor.getCode());
			}
			reservation.setDoctorCode(doctor_code);
			reservation.setDoctorName(doctor_name);
			reservation.setDoctorJob(doctor_job);
			reservation.setDoctorPhoto(doctor_photo);
			reservation.setIdcard(idcard);
			reservation.setName(doctor_name);
			reservation.setOrgCode(org_code);
			reservation.setOrgName(org_name);
			reservation.setPatient(patient);
			reservation.setPhone(phone);
			reservation.setSectionType(section_type);
			reservation.setSsc(ssc);
			reservation.setStartTime(start_time);
			reservation.setStatus(1);
			// 保存记录
			PatientReservation temp = patientReservationDao.save(reservation);
			if (temp != null) {
				// 先删除,防止重复
				patientReservationDoctorDao.deleteByPatient(patient, org_code, dept_code, doctor_code);
				// 添加预约过的医生
				PatientReservationDoctor prd = new PatientReservationDoctor();
				prd.setDeptCode(dept_code);
				prd.setDeptName(dept_name);
				prd.setDoctorCode(doctor_code);
				prd.setDoctorName(doctor_name);
				prd.setOrgCode(org_code);
				prd.setOrgName(org_name);
				prd.setPatient(patient);
				patientReservationDoctorDao.save(prd);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 查询患者预约过的医生列表
	 * @param patient
	 * @return
	 */
	public Page<PatientReservationDoctor> findRecordByPatient(String patient, long id, int pagesize) {
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		// 未指定医生
		filters.put("patient", new SearchFilter("patient", Operator.EQ, patient));
		if (id > 0) {
			filters.put("id", new SearchFilter("id", Operator.LT, id));
		}
		Specification<PatientReservationDoctor> spec = DynamicSpecifications.bySearchFilter(filters.values(), PatientReservationDoctor.class);
		return patientReservationDoctorDao.findAll(spec, pageRequest);
	}
	/**
	 * 分页获取患者预约记录,医生为空查患者所有
    @Transactional
    public JSONArray getReservationByPatient(String patient, Long teamCode, int page, int pagesize) throws Exception {
        List<PatientReservation> list = new ArrayList<>();
        JSONArray array = new JSONArray();
        // 排序
        Sort sort = new Sort(Direction.DESC, "id");
        // 分页信息
        PageRequest pageRequest = new PageRequest(page - 1, pagesize, sort);
        if (teamCode != null && teamCode > 0) {//传入医生查询医生帮此患者的预约记录
            list = patientReservationDao.findByPatientAndAdminTeamCode(patient, teamCode, pageRequest);
        } else {
            list = patientReservationDao.findByPatient(patient, pageRequest);
        }
        //更新当前状态
        if (list != null) {
            //遍历更新预约状态
            for (PatientReservation item : list) {
                String type = item.getType();
                String code = item.getCode();
                if (type.equals("0")) {  //医护网接口
                } else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    Integer status = guahaoXMService.GetOrderStatus(item.getOrgCode(), code, item.getSsc());
                    //更新状态
                    if (status != null && !status.equals(item.getStatus())) {
                        item.setStatus(status);
                    }
                }
            }
            patientReservationDao.save(list);
        }
        if (list != null) {
            Map<String, Doctor> doctors = new HashMap<>();
            for (PatientReservation item : list) {
                JSONObject obj = new JSONObject(item);
                if (!StringUtils.isEmpty(item.getDoctor())) {
                    if (doctors.get(item.getDoctor()) != null) {
                        obj.put("photo", doctors.get(item.getDoctor()).getPhoto());
                    } else {
                        Doctor doc = doctorDao.findByCode(item.getDoctor());
                        if (doc != null) {
                            doctors.put(doc.getCode(), doc);
                            obj.put("photo", doc.getPhoto());
                        }
                    }
                }
                array.put(obj);
            }
        }
        return array;
    }
    /**
     * 分页获取患者预约记录(医生端)
     */
	@Transactional
	public List<PatientReservation> getReservationByPatient(String patient,Long teamCode, int page, int pagesize) throws Exception
	{
		List<PatientReservation> list = new ArrayList<>();
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page-1, pagesize, sort);
		if(teamCode != null && teamCode > 0){//传入医生查询医生帮此患者的预约记录
			list = patientReservationDao.findByPatientAndAdminTeamCode(patient, teamCode, pageRequest);
		}else{
			list = patientReservationDao.findByPatient(patient, pageRequest);
		}
		//更新当前状态
		if(list!=null)
		{
			//遍历更新预约状态
			for (PatientReservation item : list) {
				String type = item.getType();
				String code = item.getCode();
				if (type.equals("0")) {  //医护网接口
				}
				else if (type.equals("1"))   //厦门市民健康预约接口
				{
					Integer status = guahaoXMService.GetOrderStatus(item.getOrgCode(), code, item.getSsc());
					//更新状态
					if (status != null && !status.equals(item.getStatus())) {
						item.setStatus(status);
					}
				}
			}
			patientReservationDao.save(list);
		}
		return list;
	}
	/**
	 * 分页获取患者预约记录(医生端)
	 */
	public List<Map<String,String>> getReservationByDoctor(String doctor, int page, int pagesize) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page-1, pagesize, sort);
		List<PatientReservation> list = patientReservationDao.findByDoctor(doctor, pageRequest);
		//更新当前状态
		if(list!=null)
		{
			//遍历更新预约状态
			for (PatientReservation item : list) {
				String type = item.getType();
				String code = item.getCode();
				if (type.equals("0")) {  //医护网接口
				}
				else if (type.equals("1"))   //厦门市民健康预约接口
				{
					Integer status = guahaoXMService.GetOrderStatus(item.getOrgCode(), code, item.getSsc());
					//更新状态
					if (status != null && !status.equals(item.getStatus())) {
						item.setStatus(status);
					}
				}
			}
			patientReservationDao.save(list);
		}
		//返回患者头像
		for (PatientReservation item : list) {
			Map<String,String> map = entityToMap(item);
			Patient patient = patientDao.findByCode(item.getPatient());
			if(patient!=null){
				map.put("photo",patient.getPhoto());
			}
			re.add(map);
		}
		return re;
	}
	public Long countReservationByDoctorForPatient(String doctor,String patient){
		return patientReservationDao.countReservationByDoctorForPatient(doctor,patient);
	}
    public List<Map<String, String>> getReservationByDoctor(String doctor, int page, int pagesize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        // 排序
        Sort sort = new Sort(Direction.DESC, "id");
        // 分页信息
        PageRequest pageRequest = new PageRequest(page - 1, pagesize, sort);
        List<PatientReservation> list = patientReservationDao.findByDoctor(doctor, pageRequest);
        //更新当前状态
        if (list != null) {
            //遍历更新预约状态
            for (PatientReservation item : list) {
                String type = item.getType();
                String code = item.getCode();
                if (type.equals("0")) {  //医护网接口
                } else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    Integer status = guahaoXMService.GetOrderStatus(item.getOrgCode(), code, item.getSsc());
                    //更新状态
                    if (status != null && !status.equals(item.getStatus())) {
                        item.setStatus(status);
                    }
                }
            }
            patientReservationDao.save(list);
        }
        //返回患者头像
        for (PatientReservation item : list) {
            Map<String, String> map = entityToMap(item);
            Patient patient = patientDao.findByCode(item.getPatient());
            if (patient != null) {
                map.put("photo", patient.getPhoto());
            }
            re.add(map);
        }
        return re;
    }
    public Long countReservationByDoctorForPatient(String doctor, String patient) {
        return patientReservationDao.countReservationByDoctorForPatient(doctor, patient);
    }
}

+ 46 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/ServiceStatisticsService.java

@ -1,9 +1,12 @@
package com.yihu.wlyy.service.app.statistics;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.util.DateUtil;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
@ -26,9 +29,49 @@ public class ServiceStatisticsService extends BaseService {
    @Autowired
    SignFamilyDao signFamilyDao;
    public JSONObject getServiceStatistics(String patient, long teamCode) {
    @Autowired
    AdminTeamService teamService;
    public JSONObject getServiceStatistics(String patient, long teamCode, String doctor) throws Exception {
        JSONObject result = new JSONObject();
        SignFamily signFamily = signFamilyDao.findByPatientAndAdminTeamId(patient, teamCode);
        AdminTeam team = teamService.getTeam(teamCode);
        SignFamily signFamily = signFamilyDao.findByPatientAndAdminTeamId(patient, teamCode, 2);
        if (signFamily == null) {
            signFamily = signFamilyDao.findByPatientAndAdminTeamId(patient, teamCode, 1);
            if (signFamily == null) {
                throw new Exception("patient and doctor no sign relation");
            } else {
                if((!doctor.equals(team.getLeaderCode()) && !doctor.equals(signFamily.getDoctor())
                        && !doctor.equals(signFamily.getDoctorHealth()))) {
                    throw new Exception("patient and doctor no sign relation");
                }
            }
        } else {
            if((!doctor.equals(team.getLeaderCode()) && !doctor.equals(signFamily.getDoctor())
                    && !doctor.equals(signFamily.getDoctorHealth()))) {
                signFamily = signFamilyDao.findByPatientAndAdminTeamId(patient, teamCode, 1);
                if (signFamily == null) {
                    throw new Exception("patient and doctor no sign relation");
                } else {
                    if((!doctor.equals(team.getLeaderCode()) && !doctor.equals(signFamily.getDoctor())
                            && !doctor.equals(signFamily.getDoctorHealth()))) {
                        throw new Exception("patient and doctor no sign relation");
                    }
                }
            }
        }
        if (signFamily == null) {
            signFamily = signFamilyDao.findByPatientAndAdminTeamId(patient, teamCode, 1);
            if (signFamily == null) {
                throw new Exception("sign info can not find");
            }
        }
        Calendar today = Calendar.getInstance();
        today.set(Calendar.DATE, 1);
        String monthBegin = DateUtil.dateToStrShort(today.getTime()) + " 00:00:00";
@ -188,7 +231,7 @@ public class ServiceStatisticsService extends BaseService {
                ",(" + sqlMonth.replace(" m ", " mm ") + " and status = 1" + ") f";
        List<Map<String, Object>> counts = jdbcTemplate.queryForList(sql, new Object[]{patient, teamCode,
                patient, teamCode, yearBegin, yearEnd, patient, teamCode, monthBegin,patient, teamCode,
                patient, teamCode, yearBegin, yearEnd, patient, teamCode, monthBegin, patient, teamCode,
                patient, teamCode, yearBegin, yearEnd, patient, teamCode, monthBegin
        });

+ 13 - 46
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpUtil.java

@ -132,11 +132,20 @@ public class HttpUtil {
	 * @param data 消息数据
	 */
	public static boolean pushMessage(String receiver, String msgType, String title, String msg, String data) {
//		JSONObject param = new JSONObject();
//		param.put("to_uid", receiver);
//		param.put("content", msg);
//		param.put("type", msgType);
//		param.put("title", title);
//		param.put("data", data);
		try{
			JSONObject sessionObj  = createSession(receiver);
			JSONObject params = new JSONObject();
			sendIM("system","系统通知",String.valueOf(sessionObj.get("id")),msgType, msg);
			List<NameValuePair> params = new ArrayList<>();
			params.add(new BasicNameValuePair("to", receiver));
			params.add(new BasicNameValuePair("content", msg));
			params.add(new BasicNameValuePair("contentType", msgType));
			params.add(new BasicNameValuePair("title", title));
			params.add(new BasicNameValuePair("summary", data));
			String response = HttpClientUtil.post(SystemConf.getInstance().getMsgPushServer(), params, "UTF-8");
			return true;
		}catch (Exception e){
			e.printStackTrace();
@ -144,48 +153,6 @@ public class HttpUtil {
		return false;
	}
	/**
	 * 发送消息给IM
	 *
	 * @param from        来自
	 * @param contentType 1文字 2图片消息
	 * @param content     内容
	 */
	private static String sendIM(String from,String fromName, String sessionId, String contentType, String content) {
		String imAddr = SystemConf.getInstance().getImListGet() + "/api/v2/sessions/"+sessionId+"/messages";
		JSONObject params = new JSONObject();
		params.put("sender_id", from);
		params.put("sender_name", fromName);
		params.put("business_type", contentType);
		params.put("content_type", 1);
		params.put("content", content);
		params.put("sessionId", sessionId);;
		String response = HttpClientUtil.postBody(imAddr, params);
		return response;
	}
	/**
	 * 创建会话(system)
	 *
	 */
	private static JSONObject createSession(String receiver) {
		String imAddr = SystemConf.getInstance().getImListGet() + "api/v2/sessions";
		String participants[]=new String[]{"system:0",receiver+":"+"0"};
		JSONObject params = new JSONObject();
		params.put("participants", participants);
		params.put("session_name", "系统消息");
		params.put("session_type", 0);
		String ret = HttpClientUtil.postBody(imAddr,params);
		JSONObject obj  = null;
		try{
			obj = new JSONObject(ret);
		}catch (Exception e){
			return null;
		}
		return obj;
	}
	/**
	 * 发送消息到websocket服务器,然后由websocket服务器中转给微信端
	 * @param userid 接收数据的患者id

+ 5 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java

@ -188,6 +188,7 @@ public class DoctorConsultController extends WeixinBaseController {
            return invalidUserException(e, -1, "查询失败!");
        }
    }
    /**
     * 获取三师家庭咨询
     *
@ -361,6 +362,7 @@ public class DoctorConsultController extends WeixinBaseController {
            List<Map<String, Object>> list = consultTeamService.getConsultSign(consults.split(","));
            return write(200, "查询成功", "data", new JSONArray(list));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -717,6 +719,7 @@ public class DoctorConsultController extends WeixinBaseController {
                return write(200, "查询成功", "data", "");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -842,7 +845,7 @@ public class DoctorConsultController extends WeixinBaseController {
            consult.setDoctor(doctorCode);//设置专科医生
            // 保存到数据库
            if(consultTeamService.isCommonTeam( doctorCode, getUID() ))
                consultTeamService.sendForHelpMsg(oldConsultCode,doctorCode);
                consultTeamService.sendForHelpMsg( consult, getUID(), oldConsultCode );
            else
                consultTeamService.addForHelpTeamConsult( consult, getUID(), oldConsultCode );
@ -928,6 +931,7 @@ public class DoctorConsultController extends WeixinBaseController {
            ConsultTeam ct = consultTeamService.findByConsultCode(consult);
            return write(200, "查询咨询状态成功", "data", ct.getStatus());
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询咨询状态失败");
        }
    }

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/ServiceStatisticsController.java

@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
 * Created by lyr-pc on 2017/1/10.
 */
@RestController
@RequestMapping(value = "/patient/service")
@RequestMapping(value = "/doctor/patient/service")
public class ServiceStatisticsController extends BaseController {
    @Autowired
@ -32,7 +32,7 @@ public class ServiceStatisticsController extends BaseController {
    public String statistics(@RequestParam @ApiParam(value = "居民code") String patient,
                             @RequestParam @ApiParam(value = "团队Code") Long teamCode) {
        try {
            JSONObject result = serviceStatistics.getServiceStatistics(patient, teamCode);
            JSONObject result = serviceStatistics.getServiceStatistics(patient, teamCode, getUID());
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();

+ 7 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -874,9 +874,14 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    @ResponseBody
    public String findNoHealthSignFamilyNum(long teamCode) {
        try {
            int count = familyContractService.findNoHealthSignFamilyFocusNum(teamCode);
            List<SignFamily> signFamily = familyContractService.findNoHealthSignFamilyNum(teamCode);
            JSONObject jo = new JSONObject();
            jo.put("num", count);
            if (signFamily != null && signFamily.size() > 0) {
                jo.put("date", DateUtil.dateToStr(signFamily.get(0).getCzrq(), "yyyy-MM-dd"));
                jo.put("num", signFamily.size());
            } else {
                jo.put("num", 0);
            }
            return write(200, "查询成功", "data", jo);
        } catch (Exception e) {
            e.printStackTrace();

+ 4 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -124,6 +124,7 @@ public class ConsultController extends WeixinBaseController {
            return write(200, "查询成功!", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
@ -160,6 +161,7 @@ public class ConsultController extends WeixinBaseController {
            JSONObject result = doctorWorkTimeService.isDoctorWorking(doctor);
            return write(200, result.getString("msg"), "data", result.getString("status"));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -195,6 +197,7 @@ public class ConsultController extends WeixinBaseController {
            int result = doctorWorkTimeService.getDoctorConsultTimesRemain(doctor);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -236,6 +239,7 @@ public class ConsultController extends WeixinBaseController {
                return write(200, "查询成功", "data", "");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -466,10 +466,10 @@ public class BookingController extends WeixinBaseController {
                                        @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                        @ApiParam(name = "patient", value = "患者编号", defaultValue = "4afdbce6194e412fbc770eb4dfbe7b00")
                                        @RequestParam(value = "patient", required = false) String patient,
                                        @ApiParam(name = "teamCode", value = "行政团队", defaultValue = "shiliuD20160926005")
                                        @ApiParam(name = "teamCode", value = "行政团队")
                                        @RequestParam(value = "teamCode", required = false) Long teamCode) {
        try {
            List<PatientReservation> list = patientReservationService.getReservationByPatient(patient, teamCode, pageIndex, pageSize);
            JSONArray list = patientReservationService.getReservationByPatient(patient, teamCode, pageIndex, pageSize);
            return write(200, "获取患者预约信息列表成功!", "data", list);
        } catch (Exception e) {