Browse Source

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

lyr 8 years ago
parent
commit
2418fc2427
67 changed files with 3292 additions and 2479 deletions
  1. 1 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/QuartzJobConfigDao.java
  2. 2 2
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/FollowUpDataFilter.java
  3. 5 20
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java
  4. 3 21
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/FollowUpJob.java
  5. 0 2
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/message/FollowupPlanJob.java
  6. 6 2
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/JobService.java
  7. 13 0
      patient-co-statistics/src/main/resources/application.yml
  8. 19 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/education/HealthEduArticlePatient.java
  9. 31 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/Followup.java
  10. 10 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/Patient.java
  11. 19 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientHealthGuidance.java
  12. 18 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientReservation.java
  13. 64 68
      patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java
  14. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java
  15. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultDao.java
  16. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java
  17. 8 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  18. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientHealthGuidanceDao.java
  19. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientReservationDao.java
  20. 280 266
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  21. 41 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  22. 594 563
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  23. 127 89
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticleService.java
  24. 44 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthGuidanceService.java
  25. 20 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  26. 246 225
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reservation/PatientReservationService.java
  27. 90 20
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  28. 284 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/ServiceStatisticsService.java
  29. 6 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  30. 102 122
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java
  31. 26 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpClientUtil.java
  32. 4 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java
  33. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/area/AreaController.java
  34. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/hospital/HospitalCommonController.java
  35. 9 16
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/qrcode/QrCodeController.java
  36. 0 10
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java
  37. 0 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/WlyySerivceController.java
  38. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/verified/VerifiedController.java
  39. 0 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  40. 25 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java
  41. 0 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/discussion/DoctorDiscussionGroupController.java
  42. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/family/DoctorFamilyController.java
  43. 326 305
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java
  44. 444 364
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  45. 35 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java
  46. 291 273
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java
  47. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/DoctorPatientGroupController.java
  48. 0 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientDiseaseController.java
  49. 43 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/ServiceStatisticsController.java
  50. 0 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelController.java
  51. 5 7
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  52. 0 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/reply/DoctorQuickReplyController.java
  53. 0 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheduling/DoctorWorkTimeController.java
  54. 20 13
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  55. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  56. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java
  57. 0 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java
  58. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  59. 0 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java
  60. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthGuidanceController.java
  61. 0 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  62. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/quota/JobController.java
  63. 0 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java
  64. 4 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java
  65. 0 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatCoreController.java
  66. 1 1
      patient-co-wlyy/src/main/resources/system.properties
  67. 12 12
      patient-co-wlyy/src/main/webapp/WEB-INF/web.xml

+ 1 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/QuartzJobConfigDao.java

@ -18,7 +18,7 @@ public interface QuartzJobConfigDao extends PagingAndSortingRepository<QuartzJob
    @Query(" FROM QuartzJobConfig a WHERE a.status=?1 and a.del='1'")
    List<QuartzJobConfig> findByAll(String s);
    @Query(" FROM QuartzJobConfig a WHERE a.id in (1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17)  and a.del='1' ")
    @Query(" FROM QuartzJobConfig a WHERE a.id in (1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,20,21)  and a.del='1' ")
    List<QuartzJobConfig> findByIds();
    @Query(" FROM QuartzJobConfig a WHERE a.id=?1 and a.del='1'")

+ 2 - 2
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/FollowUpDataFilter.java

@ -74,7 +74,7 @@ public class FollowUpDataFilter {
        errorModels=new ArrayList<ErrorModel>();
        for(Map<String,Object> plan:plans){
            ETLModel etlModel=new ETLModel();
            Object idCard=plan.get("id_card");//得到隨訪的身份證
            Object idCard=plan.get("idcard");//得到隨訪的身份證
            if(StringUtils.isEmpty(idCard)){
                errorModels.add(ErrorModel.newEM(plan.get("id").toString(),ErrorModel.fv_idcard_null));
                isAll=false;
@ -92,7 +92,7 @@ public class FollowUpDataFilter {
                isAll=false;
                continue;
            }
            AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamCode());
            AdminTeam adminTeam=adminTeamMap.get(adminTeamId+"");
            if(adminTeam==null){
                errorModels.add(ErrorModel.newEM(plan.get("id").toString(),ErrorModel.fv_adminTeam_noExist));
                isAll=false;

+ 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();
@ -107,7 +89,7 @@ public class FollowUpJob implements Job {
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            String sql = " select * from fv_plan a where a.update_time>='" + daybefore + Constant.quota_date_last + "' and a.update_time< '" + yesterday + Constant.quota_date_last + "'  ";
            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.queryForList(sql);
            FilterModel etlModels = followUpDataFilter.filter(plans, sql, yesterday);

+ 0 - 2
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/message/FollowupPlanJob.java

@ -29,8 +29,6 @@ public class FollowupPlanJob implements Job {
    @Autowired
    private MessageDao messageDao;
    public static String cron="0 5 0 * * ?";
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);

+ 6 - 2
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/JobService.java

@ -22,6 +22,7 @@ import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.SchedulerException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -478,10 +479,13 @@ public class JobService {
    }
    /******************************* 随访计划任务 *******************************************************/
    private String followupJob = "FOLLOWUP_PLAN_JOB";
    @Value("${spring.followupMessage.jobId}")
    private String followupJob;
    @Value("${spring.followupMessage.cron}")
    private String followupJobCron;
    public void startFollowupPlantJob() throws Exception {
        if (!quartzHelper.isExistJob(followupJob)) {
            quartzHelper.addJob(FollowupPlanJob.class, FollowupPlanJob.cron, followupJob, new HashMap<>());
            quartzHelper.addJob(FollowupPlanJob.class, followupJobCron, followupJob, new HashMap<>());
        } else {
            throw new Exception("已经启动");
        }

+ 13 - 0
patient-co-statistics/src/main/resources/application.yml

@ -132,6 +132,11 @@ spring:
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
  followupMessage:
    cron : 0 5 0 * * ?
    jobId : FOLLOWUP_PLAN_JOB
fv:
  jdbc:
    driver: com.mysql.jdbc.Driver
@ -161,6 +166,10 @@ spring:
    host: 120.41.253.95 # Redis server host.
    port: 6380 # Redis server port.
  followupMessage:
    cron : 0 5 0 * * ?
    jobId : FOLLOWUP_PLAN_JOB
fv:
  jdbc:
    driver: com.mysql.jdbc.Driver
@ -191,6 +200,10 @@ spring:
    host: 172.19.103.47 # Redis server host.
    port: 6379 # Redis server port.
  followupMessage:
    cron : 0 5 0 * * ?
    jobId : FOLLOWUP_PLAN_JOB
fv:
  jdbc:
    driver: com.mysql.jdbc.Driver

+ 19 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/education/HealthEduArticlePatient.java

@ -41,6 +41,10 @@ public class HealthEduArticlePatient extends IdEntity {
	private Integer read;
	// 发布时间
	private Date czrq;
	// 签约类型 1三师 2家庭
	private Integer signType;
	// 行政团队
	private Long adminTeamCode;
	public String getPatient() {
		return patient;
@ -116,4 +120,19 @@ public class HealthEduArticlePatient extends IdEntity {
		this.czrq = czrq;
	}
	public Integer getSignType() {
		return signType;
	}
	public void setSignType(Integer signType) {
		this.signType = signType;
	}
	public Long getAdminTeamCode() {
		return adminTeamCode;
	}
	public void setAdminTeamCode(Long adminTeamCode) {
		this.adminTeamCode = adminTeamCode;
	}
}

+ 31 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/Followup.java

@ -53,8 +53,14 @@ public class Followup extends IdEntity {
	private String followupContentPhone;
	//创建时间
	private Date createTime;
	//更新时间
	private Date updateTime;
	//创建者
	private String creater;
	// 签约类型 1三师 2家庭
	private Integer signType;
	// 行政团队
	private Long adminTeamCode;
	public Date getFollowupPlanDate() {
		return followupPlanDate;
@ -187,6 +193,15 @@ public class Followup extends IdEntity {
		this.createTime = createTime;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	public String getStatus() {
		return status;
	}
@ -210,4 +225,20 @@ public class Followup extends IdEntity {
	public void setCreater(String creater) {
		this.creater = creater;
	}
	public Integer getSignType() {
		return signType;
	}
	public void setSignType(Integer signType) {
		this.signType = signType;
	}
	public Long getAdminTeamCode() {
		return adminTeamCode;
	}
	public void setAdminTeamCode(Long adminTeamCode) {
		this.adminTeamCode = adminTeamCode;
	}
}

+ 10 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/Patient.java

@ -83,6 +83,8 @@ public class Patient extends IdEntity implements Serializable {
	private Date czrq;
	// 微信编号
	private String openid;
	//微信时间
	private Date openidTime;
	// 用户状态:1正常,0禁用,-1恶意注册,2审核中
	private Integer status;
@ -344,4 +346,12 @@ public class Patient extends IdEntity implements Serializable {
	public void setMobileRemarks(String mobileRemarks) {
		this.mobileRemarks = mobileRemarks;
	}
	public Date getOpenidTime() {
		return openidTime;
	}
	public void setOpenidTime(Date openidTime) {
		this.openidTime = openidTime;
	}
}

+ 19 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientHealthGuidance.java

@ -36,6 +36,10 @@ public class PatientHealthGuidance extends IdEntity {
	private String del;
	// 添加时间
	private Date czrq;
	// 签约类型 1三师 2家庭
	private Integer signType;
	// 行政团队
	private Long adminTeamCode;
	public String getPatient() {
		return patient;
@ -94,4 +98,19 @@ public class PatientHealthGuidance extends IdEntity {
		this.voice = voice;
	}
	public Integer getSignType() {
		return signType;
	}
	public void setSignType(Integer signType) {
		this.signType = signType;
	}
	public Long getAdminTeamCode() {
		return adminTeamCode;
	}
	public void setAdminTeamCode(Long adminTeamCode) {
		this.adminTeamCode = adminTeamCode;
	}
}

+ 18 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientReservation.java

@ -68,6 +68,10 @@ public class PatientReservation extends IdEntity {
	private Date czrq;
	// 0 健康之路 1智业
	private String type;
	// 签约类型 1三师 2家庭
	private Integer signType;
	// 行政团队
	private Long adminTeamCode;
	public String getCode() {
		return code;
@ -257,4 +261,18 @@ public class PatientReservation extends IdEntity {
		this.type = type;
	}
	public Integer getSignType() {
		return signType;
	}
	public void setSignType(Integer signType) {
		this.signType = signType;
	}
	public Long getAdminTeamCode() {
		return adminTeamCode;
	}
	public void setAdminTeamCode(Long adminTeamCode) {
		this.adminTeamCode = adminTeamCode;
	}
}

+ 64 - 68
patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java

@ -15,81 +15,77 @@ import java.util.Date;
/**
 * 医生权限校验
 *
 * @author George
 *
 */
public class DoctorInterceptor extends BaseInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean flag = true;
        try {
            response.setCharacterEncoding("UTF-8");
            JSONObject json = getAgent(request);
            if (json == null) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                return false;
            }
            String tokenStr = json.has("token") ? json.getString("token") : "";
            String uid = json.has("uid") ? json.getString("uid") : "";
            String imei = json.has("imei") ? json.getString("imei") : "";
            String observer = json.has("observer") ? json.getString("observer") : "";
            //如果是观察者直接返回true
            if (!org.springframework.util.StringUtils.isEmpty(observer) && observer.equals("1")) {
                return true;
            }
            if (StringUtils.isEmpty(tokenStr) || StringUtils.isEmpty(imei) || StringUtils.isEmpty(uid)) {
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                return false;
            }
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		boolean flag = true;
		try {
			response.setCharacterEncoding("UTF-8");
			JSONObject json = getAgent(request);
			if (json == null) {
				// 未登录
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				return false;
			}
			String tokenStr = json.has("token") ? json.getString("token") : "";
			String uid = json.has("uid") ? json.getString("uid") : "";
			String imei = json.has("imei") ? json.getString("imei") : "";
			if (StringUtils.isEmpty(tokenStr) || StringUtils.isEmpty(imei) || StringUtils.isEmpty(uid)) {
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				return false;
			}
            Token token = SystemData.doctorTokens.get(uid);
            if (token == null) {
                token = tokenDao.findByPatient(uid, 2);
                if (token != null) {
                    // 加入缓存
                    SystemData.doctorTokens.put(uid, token);
                }
            }
            if (token == null || token.getPlatform() != 2) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
                flag = false;
            } else {
                if (token.getTimeout().getTime() < new Date().getTime()) {
                    // 登录超时
                    response.getOutputStream().write(error(SystemConf.LOGIN_TIMEOUT, "登录超时,请重新登录").getBytes());
                    flag = false;
                } else if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(uid, token.getUser()) || !StringUtils.equals(imei, token.getImei())) {
                    // 别处登录
                    response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes());
                    flag = false;
                } else {
                    // 一天只更新一次
                    if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
                        // 今天未更新,则更新缓存
                        token.setCzrq(new Date());
                        // 更新内存
                        SystemData.doctorTokens.put(uid, token);
                        // 更新数据库
                        tokenDao.save(token);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }
			Token token = SystemData.doctorTokens.get(uid);
			if (token == null) {
				token = tokenDao.findByPatient(uid, 2);
				if (token != null) {
					// 加入缓存
					SystemData.doctorTokens.put(uid, token);
				}
			}
			if (token == null || token.getPlatform() != 2) {
				// 未登录
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				flag = false;
			} else {
				if (token.getTimeout().getTime() < new Date().getTime()) {
					// 登录超时
					response.getOutputStream().write(error(SystemConf.LOGIN_TIMEOUT, "登录超时,请重新登录").getBytes());
					flag = false;
				} else if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(uid, token.getUser()) || !StringUtils.equals(imei, token.getImei())) {
					// 别处登录
					response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes());
					flag = false;
				} else {
					// 一天只更新一次
					if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
						// 今天未更新,则更新缓存
						token.setCzrq(new Date());
						// 更新内存
						SystemData.doctorTokens.put(uid, token);
						// 更新数据库
						tokenDao.save(token);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flag;
	}
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
    }
	}
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
    }
	}
}

+ 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;

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultDao.java

@ -30,4 +30,7 @@ public interface ConsultDao extends PagingAndSortingRepository<Consult, Long>, J
	@Query("select count(a) from Consult a,ConsultTeamDoctor b  where a.code = b.consult and a.patient=?1 and b.to=?2 and b.from is null")
	Integer findByPatient(String patientCode,String doctorCode);
	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.adminTeamId from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and b.adminTeamId = ?2 and a.del = '1' order by a.czrq desc")
	Page<Object> findByPatientAndTeam(String patient,Long team, Pageable pageRequest);
}

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java

@ -28,4 +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" +
            ",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);
}

+ 8 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -53,4 +53,12 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("select count(a) from Message a where a.read = 0 and a.over ='0'  and a.receiver=?1 and a.type=?2 ")
    int findMessageNum(String doctor, Integer type);
    @Query("update Message a set a.read = 0,a.over = '0' where a.receiver = ?1 and a.type = ?2")
    @Modifying
    int setMessageReaded(String doctor,Integer type);
    @Query("update Message a set a.read = 0,a.over = '0' where a.receiver = ?1 and a.type not in (1,2)")
    @Modifying
    int setSysMessageReaded(String doctor);
}

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientHealthGuidanceDao.java

@ -54,4 +54,7 @@ public interface PatientHealthGuidanceDao extends PagingAndSortingRepository<Pat
	@Query("SELECT count(a) from PatientHealthGuidance a WHERE  a.patient=?2 and a.doctor=?1 ")
	Integer findbydoctorAndPatient(String doctor, String patientCode);
	@Query("select b.name, b.photo, a.id, a.content, a.czrq,b.level,b.code,a.adminTeamCode from PatientHealthGuidance a, Doctor b where a.doctor = b.code and a.patient = ?1 and a.adminTeamCode = ?2 and a.del = '1'")
	Page<Object> findByPatientAndTeamCode(String patient, Long teamCode, Pageable pageable);
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientReservationDao.java

@ -23,7 +23,7 @@ public interface PatientReservationDao extends PagingAndSortingRepository<Patien
	List<PatientReservation> findByPatient(String patient, Pageable page);
	List<PatientReservation> findByPatientAndDoctor(String patient,String doctor,Pageable page);
	List<PatientReservation> findByPatientAndAdminTeamCode(String patient,Long teamCode,Pageable page);
	List<PatientReservation> findByDoctor(String doctor,Pageable page);

+ 280 - 266
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,302 +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 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);
}

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

@ -35,6 +35,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
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.data.domain.Page;
@ -567,6 +568,41 @@ 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;
    }
    /**
     * 添加咨询记录
     *
@ -1376,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;
    }

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

@ -21,8 +21,12 @@ import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.task.FollowupUploadTask;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import io.swagger.annotations.ApiParam;
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;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
@ -36,589 +40,616 @@ import java.util.*;
/**
 * 随访服务
 * @author hzp add 2016-12-07
 *
 * @author hzp add 2016-12-07
 */
@Component
@Transactional(rollbackOn = Exception.class)
public class FollowUpService extends BaseService {
	@Autowired
	private DoctorDao doctorDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private PatientDao patientDao;
	@Autowired
	private PatientDao patientDao;
    @Autowired
    private FollowUpDao followupDao;
	@Autowired
	private FollowUpDao followupDao;
    @Autowired
    private FollowupContentDao followupContentDao;
	@Autowired
	private FollowupContentDao followupContentDao;
    @Autowired
    private SystemDictService systemDictService;
	@Autowired
	private SystemDictService systemDictService;
    @Autowired
    private ObjectMapper objectMapper;
	@Autowired
	private ObjectMapper objectMapper;
    @Autowired
    private SignFamilyDao signFamilyDao;
	@Autowired
	private SignFamilyDao signFamilyDao;
    @Autowired
    private DrHealthTeamService drHealthTeamService;
	@Autowired
	private DrHealthTeamService drHealthTeamService;
    @Autowired
    private MessageDao messageDao;
	@Autowired
	private MessageDao messageDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
	@Autowired
	private JdbcTemplate jdbcTemplate;
    @Autowired
    SystemDictService dictService;
	/**
	 * 转译随访信息
    /**
     * 转译随访信息
     */
    private Map<String, String> getFollowupDetail(Followup followup) throws Exception {
        Map<String, String> re = new HashMap<>();
        //患者信息
        String patientCode = followup.getPatientCode();
        Patient patient = patientDao.findByCode(patientCode);
        if (patient != null) {
            re.put("patientCode", patientCode);
            re.put("patientName", patient.getName());
            re.put("idcard", patient.getIdcard());
            String mobile = patient.getMobile();
            if (StringUtils.isEmpty(mobile)) {
                mobile = patient.getMobileRemarks();
            }
            re.put("mobile", mobile);
            re.put("sex", String.valueOf(patient.getSex()));
            re.put("birthday", DateUtil.dateToStrLong(patient.getBirthday()));
            re.put("photo", patient.getPhoto());
        } else {
            throw new Exception("not exit patient:" + patientCode);
        }
        re.put("id", String.valueOf(followup.getId()));
        re.put("followupNo", followup.getFollowupNo());
        re.put("followupDate", DateUtil.dateToStrLong(followup.getFollowupDate()));
        re.put("followupNextDate", DateUtil.dateToStrLong(followup.getFollowupNextDate()));
        //随访方式转译
        re.put("followupType", followup.getFollowupType());
        String followupTypeName = systemDictService.getDictValue("FOLLOWUP_WAY_DICT", followup.getFollowupType());
        re.put("followupTypeName", followupTypeName);
        //随访类别转译
        re.put("followupClass", followup.getFollowupClass());
        String followupClassName = systemDictService.getDictValue("FOLLOWUP_CLASS_DICT", followup.getFollowupClass());
        re.put("followupClassName", followupClassName);
        //随访管理状态转译
        re.put("followupManagerStatus", followup.getFollowupManagerStatus());
        String followupManagerStatusName = systemDictService.getDictValue("FOLLOWUP_MANAGER_STATUS", followup.getFollowupManagerStatus());
        re.put("followupManagerStatusName", followupManagerStatusName);
        re.put("doctorCode", followup.getDoctorCode());
        re.put("doctorName", followup.getDoctorName());
        re.put("orgCode", followup.getOrgCode());
        re.put("orgName", followup.getOrgName());
        re.put("dataFrom", followup.getDataFrom());
        re.put("status", followup.getStatus());
        re.put("followupContentPhone", followup.getFollowupContentPhone());
        re.put("createTime", DateUtil.dateToStrLong(followup.getCreateTime()));
        re.put("creater", followup.getCreater());
        return re;
    }
    /**
     * 获取医生随访列表
     */
    public List<Map<String, String>> getListByDoctor(String doctorCode, String startTime, String endTime, String page, String pageSize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        // 排序
        Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
        // 分页信息
        int pageInt = Integer.valueOf(page) - 1;
        int pageSizeInt = Integer.valueOf(pageSize);
        Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
        List<Followup> list = followupDao.findByDoctor(doctorCode, DateUtil.strToDate(startTime), DateUtil.strToDate(endTime), pageRequest);
        if (list != null && list.size() > 0) {
            for (Followup followup : list) {
                Map<String, String> map = getFollowupDetail(followup);
                re.add(map);
            }
        }
        return re;
    }
    /**
     * 查询居民随访列表
     *
     * @param patient
     * @param teamCode
     * @param page
     * @param pageSize
     * @return
     */
    public JSONArray getListByPatientAndTeam(String patient, Long teamCode, int page, int pageSize) {
        PageRequest pageRequest = new PageRequest(page, pageSize);
        Page<Object> result = followupDao.findByPatientAndTeam(patient, teamCode, pageRequest);
        JSONArray array = new JSONArray();
        if (result != null && result.getContent().size() > 0) {
            Map<String, String> dictMap = new HashMap<>();
            Map<String, String> statusMap = new HashMap<>();
            Map<String, String> mngStatusMap = new HashMap<>();
            List<SystemDict> dicts = dictService.getDictByDictName("FOLLOWUP_WAY_DICT");
            List<SystemDict> mngDicts = dictService.getDictByDictName("FOLLOWUP_MANAGER_STATUS");
            if (dicts != null) {
                for (SystemDict dict : dicts) {
                    dictMap.put(dict.getCode(), dict.getValue());
                }
            }
            if (mngDicts != null) {
                for (SystemDict dict : mngDicts) {
                    mngStatusMap.put(dict.getCode(), dict.getValue());
                }
            }
            statusMap.put("0", "取消");
            statusMap.put("1", "已完成");
            statusMap.put("2", "未开始");
            statusMap.put("3", "进行中");
            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]);
                followup.put("followupType", objArr[3] == null ? "" : objArr[3]);
                followup.put("followupTypeName", objArr[3] == null ? "" : (dictMap.get(objArr[3].toString()) != null ? dictMap.get(objArr[3].toString()) : ""));
                followup.put("followupClass", objArr[4] == null ? "" : objArr[4]);
                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] != 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);
            }
        }
        return array;
    }
    /**
     * 获取医生随访列表(创建者)
     */
    public List<Map<String, String>> getListByCreater(String doctorCode, String startTime, String endTime, String page, String pageSize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        // 排序
        Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
        // 分页信息
        int pageInt = Integer.valueOf(page) - 1;
        int pageSizeInt = Integer.valueOf(pageSize);
        Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
        List<Followup> list = followupDao.findByCreater(doctorCode, DateUtil.strToDate(startTime), DateUtil.strToDate(endTime), pageRequest);
        if (list != null && list.size() > 0) {
            for (Followup followup : list) {
                Map<String, String> map = getFollowupDetail(followup);
                re.add(map);
            }
        }
        return re;
    }
    /**
     * 新增随访计划(批量)
     */
    @Transactional
    public void addFollowupPlan(String doctorCode, String patientCode, String data) throws Exception {
        //批量随访计划
        JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Map.class);
        List<Map<String, String>> list = objectMapper.readValue(data, javaType);
        if (list != null && list.size() > 0) {
            //获取患者信息
            Patient patient = patientDao.findByCode(patientCode);
            if (patient == null) {
                throw new Exception("not exit patient:" + patientCode + ".\r\n");
            }
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
            if (signFamily == null) {
                throw new Exception("can not find patient's family sign info");
            }
            List<Followup> followupPlan = new ArrayList<>();
            for (Map<String, String> map : list) {
                //获取医生信息
                Doctor doctor = doctorDao.findByCode(map.get("doctor"));
                if (doctor == null) {
                    throw new Exception("not exit doctor:" + doctorCode + ".\r\n");
                }
                Followup followup = new Followup();
                followup.setFollowupType(map.get("type"));
                Date date = DateUtil.strToDate(map.get("date"));
                followup.setFollowupDate(date);
                followup.setFollowupPlanDate(date);
                followup.setDoctorCode(doctor.getCode());
                followup.setDoctorName(doctor.getName());
                followup.setOrgCode(doctor.getHospital());
                followup.setOrgName(doctor.getHospitalName());
                followup.setPatientCode(patientCode);
                followup.setPatientName(patient.getName());
                followup.setIdcard(patient.getIdcard());
                followup.setDataFrom("2");//数据来源 1基卫 2APP
                followup.setStatus("2");     //状态 0取消 1已完成 2未开始 3进行中
                followup.setCreateTime(new Date());
                followup.setCreater(doctorCode);
                followup.setAdminTeamCode(signFamily.getAdminTeamId());
                followup.setSignType(2);
                followupPlan.add(followup);
            }
            followupDao.save(followupPlan);
        }
    }
    /**
     * 编辑随访计划
     */
    public void editFollowupPlan(String doctorCode, String id, String date, String followupType) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            Date followupDate = DateUtil.strToDate(date);
            followup.setFollowupDate(followupDate);
            followup.setFollowupPlanDate(followupDate);
            followup.setFollowupType(followupType);
            followup.setCreater(doctorCode);
            followupDao.save(followup);
        } else {
            throw new Exception("not exit follow:" + id + ".\r\n");
        }
    }
    /**
     * 开始随访记录
     */
    public void startFollowup(String id, String date, String followupType, String followupClass, String followupManagerStatus) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            followup.setFollowupDate(DateUtil.strToDate(date));
            followup.setFollowupType(followupType);
            followup.setFollowupClass(followupClass);
            followup.setFollowupManagerStatus(followupManagerStatus);
            followup.setStatus("3");  //状态 0取消 1已完成 2未开始 3进行中
            followupDao.save(followup);
        } else {
            throw new Exception("not exit follow:" + id + ".\r\n");
        }
    }
    /**
     * 新增临时随访记录(返回ID)
     */
    public String addFollowup(String doctorCode, String patientCode, String date, String followupType, String followupClass, String followupManagerStatus) throws Exception {
        String re = "";
        //获取医生信息
        Doctor doctor = doctorDao.findByCode(doctorCode);
        if (doctor == null) {
            throw new Exception("not exit doctor:" + doctorCode + ".\r\n");
        }
        //获取患者信息
        Patient patient = patientDao.findByCode(patientCode);
        if (patient == null) {
            throw new Exception("not exit patient:" + patientCode + ".\r\n");
        }
        SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
        if (signFamily == null) {
            throw new Exception("can not find patient's family sign info");
        }
        Followup followup = new Followup();
        Date followDate = DateUtil.strToDate(date);
        followup.setFollowupDate(followDate);
        followup.setFollowupPlanDate(followDate);
        followup.setDoctorCode(doctorCode);
        followup.setDoctorName(doctor.getName());
        followup.setOrgCode(doctor.getHospital());
        followup.setOrgName(doctor.getHospitalName());
        followup.setPatientCode(patientCode);
        followup.setPatientName(patient.getName());
        followup.setIdcard(patient.getIdcard());
        followup.setFollowupType(followupType);
        followup.setFollowupClass(followupClass);
        followup.setFollowupManagerStatus(followupManagerStatus);
        followup.setDataFrom("2");//数据来源 1基卫 2APP
        followup.setStatus("3");     //状态 0取消 1已完成 2未开始 3进行中
        followup.setCreateTime(new Date());
        followup.setCreater(doctorCode);
        followup.setAdminTeamCode(signFamily.getAdminTeamId());
        followup.setSignType(2);
        followupDao.save(followup);
        re = String.valueOf(followup.getId());
        return re;
    }
    /**
     * 取消随访计划
     */
	private Map<String,String> getFollowupDetail(Followup followup) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		//患者信息
		String patientCode = followup.getPatientCode();
		Patient patient = patientDao.findByCode(patientCode);
		if(patient!=null) {
			re.put("patientCode",patientCode);
			re.put("patientName",patient.getName());
			re.put("idcard",patient.getIdcard());
			String mobile = patient.getMobile();
			if(StringUtils.isEmpty(mobile))
			{
				mobile = patient.getMobileRemarks();
			}
			re.put("mobile", mobile);
			re.put("sex",String.valueOf(patient.getSex()));
			re.put("birthday",DateUtil.dateToStrLong(patient.getBirthday()));
			re.put("photo",patient.getPhoto());
		}
		else{
			throw new Exception("not exit patient:"+patientCode);
		}
		re.put("id",String.valueOf(followup.getId()));
		re.put("followupNo",followup.getFollowupNo());
		re.put("followupDate",DateUtil.dateToStrLong(followup.getFollowupDate()));
		re.put("followupNextDate",DateUtil.dateToStrLong(followup.getFollowupNextDate()));
		//随访方式转译
		re.put("followupType",followup.getFollowupType());
		String followupTypeName = systemDictService.getDictValue("FOLLOWUP_WAY_DICT",followup.getFollowupType());
		re.put("followupTypeName",followupTypeName);
		//随访类别转译
		re.put("followupClass",followup.getFollowupClass());
		String followupClassName = systemDictService.getDictValue("FOLLOWUP_CLASS_DICT",followup.getFollowupClass());
		re.put("followupClassName",followupClassName);
		//随访管理状态转译
		re.put("followupManagerStatus",followup.getFollowupManagerStatus());
		String followupManagerStatusName = systemDictService.getDictValue("FOLLOWUP_MANAGER_STATUS",followup.getFollowupManagerStatus());
		re.put("followupManagerStatusName",followupManagerStatusName);
		re.put("doctorCode",followup.getDoctorCode());
		re.put("doctorName",followup.getDoctorName());
		re.put("orgCode",followup.getOrgCode());
		re.put("orgName",followup.getOrgName());
		re.put("dataFrom",followup.getDataFrom());
		re.put("status",followup.getStatus());
		re.put("followupContentPhone",followup.getFollowupContentPhone());
		re.put("createTime",DateUtil.dateToStrLong(followup.getCreateTime()));
		re.put("creater",followup.getCreater());
		return re;
	}
	/**
	 * 获取医生随访列表
    public void cancelFollowupPlan(String id) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            followup.setStatus("0");  //状态 0取消 1已完成 2未开始 3进行中
            followupDao.save(followup);
        } else {
            throw new Exception("not exit follow:" + id + ".\r\n");
        }
    }
    /**
     * 完成随访记录,并上传随访记录
     */
    public void finishFollowup(String id) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            followup.setStatus("1");  //状态 0取消 1已完成 2未开始 3进行中
            followupDao.save(followup);
            //上传随访计划
            new Thread(new FollowupUploadTask(String.valueOf(followup.getId()))).start();
        } else {
            throw new Exception("not exit follow:" + id + ".\r\n");
        }
    }
    /*********************************** 随访详情 *******************************************************************/
    /**
     * 获取面访项目列表
     */
    public Map<String, String> getFollowup(String id) throws Exception {
        Map<String, String> re = new HashMap<>();
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            re = getFollowupDetail(followup);
        } else {
            throw new Exception("not exit follow:" + id + ".\r\n");
        }
        return re;
    }
    /**
     * 获取面访项目列表
     */
    public List<Map<String, String>> getFollowupProject(String id) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        //获取已填写的面访项目
        List<String> project = followupContentDao.findProjectByFollowupId(Long.valueOf(id));
        //获取所有面访项目
        List<SystemDict> dictList = systemDictService.getDictByDictName("FOLLOWUP_PROJECT");
        if (dictList != null && dictList.size() > 0) {
            for (SystemDict dict : dictList) {
                Map<String, String> map = new HashMap<>();
                String code = dict.getCode();
                map.put("projectCode", code);
                map.put("projectName", dict.getValue());
                if (project != null && project.contains(code)) {
                    map.put("status", "1"); //已填写
                } else {
                    map.put("status", "0");//未填写
                }
                re.add(map);
            }
        }
        return re;
    }
    /**
     * 获取面访项目数据
     */
    public Map<String, String> getFollowupProjectData(String id, String followupProject) throws Exception {
        Map<String, String> re = new HashMap<>();
        List<FollowupContent> dataList = followupContentDao.findByFollowupIdAndFollowupProject(Long.valueOf(id), followupProject);
        for (FollowupContent item : dataList) {
            re.put(item.getFollowupKey(), item.getFollowupValue());
        }
        return re;
    }
    /**
     * 保存面访项目数据
     */
    @Transactional
    public void saveFollowupProjectData(String id, String followupProject, String followupProjectData) throws Exception {
        List<FollowupContent> dataList = followupContentDao.findByFollowupIdAndFollowupProject(Long.valueOf(id), followupProject);
        //删除原有记录
        followupContentDao.delete(dataList);
        Map<String, String> data = objectMapper.readValue(followupProjectData, Map.class);
        if (data != null && data.keySet().size() > 0) {
            List<FollowupContent> newList = new ArrayList<>();
            for (String key : data.keySet()) {
                FollowupContent item = new FollowupContent();
                item.setFollowupId(Long.valueOf(id));
                item.setFollowupProject(followupProject);
                item.setFollowupKey(key);
                item.setFollowupValue(data.get(key));
                item.setCreateTime(new Date());
                newList.add(item);
            }
            followupContentDao.save(newList);
        }
    }
    /*********************************** 电话随访 *****************************************************************/
    /**
     * 获取电话随访内容
     */
    public String getFollowupPhone(String id) throws Exception {
        String re = "";
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            re = followup.getFollowupContentPhone();
        } else {
            throw new Exception("not exit followup:" + id + ".\r\n");
        }
        return re;
    }
    /**
     * 记录电话随访内容
     */
    public void saveFollowupPhone(String id, String content) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            followup.setFollowupContentPhone(content);
            followupDao.save(followup);
        } else {
            throw new Exception("not exit followup:" + id + ".\r\n");
        }
    }
    /*************************************** 上次随访 ********************************************/
    /**
     * 获取团队医生
     */
	public List<Map<String,String>> getListByDoctor(String doctorCode,String startTime,String endTime,String page,String pageSize) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		// 排序
		Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
		// 分页信息
		int pageInt = Integer.valueOf(page)-1;
		int pageSizeInt =  Integer.valueOf(pageSize);
		Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
		List<Followup> list = followupDao.findByDoctor(doctorCode,DateUtil.strToDate(startTime),DateUtil.strToDate(endTime),pageRequest);
		if(list!=null && list.size()>0)
		{
		    for(Followup followup : list)
			{
				Map<String,String> map = getFollowupDetail(followup);
				re.add(map);
			}
		}
		return re;
	}
	/**
	 * 获取医生随访列表(创建者)
	 */
	public List<Map<String,String>> getListByCreater(String doctorCode,String startTime,String endTime,String page,String pageSize) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		// 排序
		Sort sort = new Sort(Sort.Direction.ASC, "followupDate");
		// 分页信息
		int pageInt = Integer.valueOf(page)-1;
		int pageSizeInt =  Integer.valueOf(pageSize);
		Pageable pageRequest = new PageRequest(pageInt, pageSizeInt, sort);
		List<Followup> list = followupDao.findByCreater(doctorCode,DateUtil.strToDate(startTime),DateUtil.strToDate(endTime),pageRequest);
		if(list!=null && list.size()>0)
		{
			for(Followup followup : list)
			{
				Map<String,String> map = getFollowupDetail(followup);
				re.add(map);
			}
		}
		return re;
	}
	/**
	 *新增随访计划(批量)
	 */
	@Transactional
	public void addFollowupPlan(String doctorCode,String patientCode,String data) throws Exception {
		//批量随访计划
		JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Map.class);
		List<Map<String,String>> list = objectMapper.readValue(data,javaType);
		if(list!=null && list.size()>0)
		{
			//获取患者信息
			Patient patient = patientDao.findByCode(patientCode);
			if(patient==null)
			{
				throw new Exception("not exit patient:"+patientCode+".\r\n");
			}
			List<Followup> followupPlan = new ArrayList<>();
			for(Map<String,String> map : list)
			{
				//获取医生信息
				Doctor doctor = doctorDao.findByCode(map.get("doctor"));
				if(doctor==null)
				{
					throw new Exception("not exit doctor:"+doctorCode+".\r\n");
				}
				Followup followup = new Followup();
				followup.setFollowupType(map.get("type"));
				Date date =  DateUtil.strToDate(map.get("date"));
				followup.setFollowupDate(date);
				followup.setFollowupPlanDate(date);
				followup.setDoctorCode(doctor.getCode());
				followup.setDoctorName(doctor.getName());
				followup.setOrgCode(doctor.getHospital());
				followup.setOrgName(doctor.getHospitalName());
				followup.setPatientCode(patientCode);
				followup.setPatientName(patient.getName());
				followup.setIdcard(patient.getIdcard());
				followup.setDataFrom("2");//数据来源 1基卫 2APP
				followup.setStatus("2");     //状态 0取消 1已完成 2未开始 3进行中
				followup.setCreateTime(new Date());
				followup.setCreater(doctorCode);
				followupPlan.add(followup);
			}
			followupDao.save(followupPlan);
		}
	}
	/**
	 *编辑随访计划
	 */
	public void editFollowupPlan(String doctorCode,String id,String date,String followupType) throws Exception {
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			Date followupDate = DateUtil.strToDate(date);
			followup.setFollowupDate(followupDate);
			followup.setFollowupPlanDate(followupDate);
			followup.setFollowupType(followupType);
			followup.setCreater(doctorCode);
			followupDao.save(followup);
		}
		else{
			throw new Exception("not exit follow:"+id+".\r\n");
		}
	}
	/**
	 *开始随访记录
	 */
	public void startFollowup(String id,String date,String followupType,String followupClass,String followupManagerStatus) throws Exception {
		 Followup followup = followupDao.findOne(Long.valueOf(id));
		 if(followup!=null)
		 {
			 followup.setFollowupDate(DateUtil.strToDate(date));
			 followup.setFollowupType(followupType);
			 followup.setFollowupClass(followupClass);
			 followup.setFollowupManagerStatus(followupManagerStatus);
			 followup.setStatus("3");  //状态 0取消 1已完成 2未开始 3进行中
			 followupDao.save(followup);
		 }
		else{
			 throw new Exception("not exit follow:"+id+".\r\n");
		 }
	}
	/**
	 *新增临时随访记录(返回ID)
	 */
	public String addFollowup(String doctorCode,String patientCode,String date,String followupType,String followupClass,String followupManagerStatus) throws Exception {
		String re ="";
		//获取医生信息
		Doctor doctor = doctorDao.findByCode(doctorCode);
		if(doctor==null)
		{
			throw new Exception("not exit doctor:"+doctorCode+".\r\n");
		}
		//获取患者信息
		Patient patient = patientDao.findByCode(patientCode);
		if(patient==null)
		{
			throw new Exception("not exit patient:"+patientCode+".\r\n");
		}
		Followup followup = new Followup();
		Date followDate = DateUtil.strToDate(date);
		followup.setFollowupDate(followDate);
		followup.setFollowupPlanDate(followDate);
		followup.setDoctorCode(doctorCode);
		followup.setDoctorName(doctor.getName());
		followup.setOrgCode(doctor.getHospital());
		followup.setOrgName(doctor.getHospitalName());
		followup.setPatientCode(patientCode);
		followup.setPatientName(patient.getName());
		followup.setIdcard(patient.getIdcard());
		followup.setFollowupType(followupType);
		followup.setFollowupClass(followupClass);
		followup.setFollowupManagerStatus(followupManagerStatus);
		followup.setDataFrom("2");//数据来源 1基卫 2APP
		followup.setStatus("3");     //状态 0取消 1已完成 2未开始 3进行中
		followup.setCreateTime(new Date());
		followup.setCreater(doctorCode);
		followupDao.save(followup);
		re = String.valueOf(followup.getId());
		return re;
	}
	/**
	 *取消随访计划
	 */
	public void cancelFollowupPlan(String id) throws Exception {
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			followup.setStatus("0");  //状态 0取消 1已完成 2未开始 3进行中
			followupDao.save(followup);
		}
		else{
			throw new Exception("not exit follow:"+id+".\r\n");
		}
	}
	/**
	 * 完成随访记录,并上传随访记录
    private List<Doctor> getTeamDoctors(String doctor, String patient) throws Exception {
        List<Doctor> doctors = new ArrayList<>();
        //获取医生团队成员
        SignFamily signFamily = signFamilyDao.findByFamilyDoctorAndPatient(doctor, patient);
        // 查询家庭医生团队
        if (signFamily != null) {
            doctors = drHealthTeamService.findTeamDoctors(signFamily.getTeamCode());
        }
        // 查询三师团队医生
        if (doctors == null || doctors.size() == 0) {
            SignFamily sanshiSign = signFamilyDao.findBySanshiDoctorAndPatient(doctor, patient);
            if (sanshiSign != null) {
                doctors = drHealthTeamService.findTeamDoctors(patient, 1);
            } else {
                doctors = new ArrayList<>();
            }
        }
        return doctors;
    }
    /**
     * 获取上次随访
     */
	public void finishFollowup(String id) throws Exception {
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			followup.setStatus("1");  //状态 0取消 1已完成 2未开始 3进行中
			followupDao.save(followup);
			//上传随访计划
			new Thread(new FollowupUploadTask(String.valueOf(followup.getId()))).start();
		}
		else{
			throw new Exception("not exit follow:"+id+".\r\n");
		}
	}
	/*********************************** 随访详情 *******************************************************************/
	/**
	 * 获取面访项目列表
	 */
	public Map<String,String> getFollowup(String id) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			re = getFollowupDetail(followup);
		}
		else{
			throw new Exception("not exit follow:"+id+".\r\n");
		}
		return re;
	}
	/**
	 * 获取面访项目列表
	 */
	public List<Map<String,String>> getFollowupProject(String id) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		//获取已填写的面访项目
		List<String> project = followupContentDao.findProjectByFollowupId(Long.valueOf(id));
		//获取所有面访项目
		List<SystemDict> dictList = systemDictService.getDictByDictName("FOLLOWUP_PROJECT");
		if (dictList!=null && dictList.size()>0)
		{
			for(SystemDict dict:dictList)
			{
				Map<String,String> map = new HashMap<>();
				String code = dict.getCode();
				map.put("projectCode",code);
				map.put("projectName",dict.getValue());
				if(project!=null && project.contains(code))
				{
					map.put("status","1"); //已填写
				}
				else{
					map.put("status","0");//未填写
				}
				re.add(map);
			}
		}
		return re;
	}
	/**
	 * 获取面访项目数据
	 */
	public Map<String,String> getFollowupProjectData(String id,String followupProject) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		List<FollowupContent> dataList =  followupContentDao.findByFollowupIdAndFollowupProject(Long.valueOf(id),followupProject);
		for(FollowupContent item:dataList)
		{
			re.put(item.getFollowupKey(),item.getFollowupValue());
		}
		return re;
	}
	/**
	 *保存面访项目数据
	 */
	@Transactional
	public void saveFollowupProjectData(String id,String followupProject,String followupProjectData) throws Exception {
		List<FollowupContent> dataList = followupContentDao.findByFollowupIdAndFollowupProject(Long.valueOf(id),followupProject);
		//删除原有记录
		followupContentDao.delete(dataList);
		Map<String,String> data =  objectMapper.readValue(followupProjectData,Map.class);
		if(data!=null && data.keySet().size()>0)
		{
			List<FollowupContent> newList = new ArrayList<>();
			for (String key : data.keySet()) {
				FollowupContent item = new FollowupContent();
				item.setFollowupId(Long.valueOf(id));
				item.setFollowupProject(followupProject);
				item.setFollowupKey(key);
				item.setFollowupValue(data.get(key));
				item.setCreateTime(new Date());
				newList.add(item);
			}
			followupContentDao.save(newList);
		}
	}
	/*********************************** 电话随访 *****************************************************************/
	/**
	 *获取电话随访内容
	 */
	public String getFollowupPhone(String id) throws Exception {
		String re = "";
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			re = followup.getFollowupContentPhone();
		}
		else {
			throw new Exception("not exit followup:"+id+".\r\n");
		}
		return re;
	}
	/**
	 *记录电话随访内容
	 */
	public void saveFollowupPhone(String id,String content) throws Exception {
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			followup.setFollowupContentPhone(content);
			followupDao.save(followup);
		}
		else {
			throw new Exception("not exit followup:"+id+".\r\n");
		}
	}
	/*************************************** 上次随访 ********************************************/
	/**
	 * 获取团队医生
    public Map<String, String> getLastFollowup(String doctor, String patient, String followClass) throws Exception {
        Map<String, String> re = new HashMap<>();
        //获取医生团队成员
        String[] doctors = new String[]{doctor};
        List<Doctor> doctorList = getTeamDoctors(doctor, patient);
        if (doctorList != null && doctorList.size() > 1) {
            doctors = new String[doctorList.size()];
            for (int i = 0; i < doctorList.size(); i++) {
                doctors[i] = doctorList.get(i).getCode();
            }
        }
        //获取最新的随访记录
        Followup followup = followupDao.findLastFollowup(doctors, patient, followClass);
        if (followup != null) {
            re.put("id", String.valueOf(followup.getId()));
            re.put("followupDate", DateUtil.dateToStrShort(followup.getFollowupDate()));
        } else {
            re = null;
        }
        return re;
    }
    /**
     * 获取上次随访
     */
	private List<Doctor>  getTeamDoctors(String doctor,String patient) throws Exception
	{
		List<Doctor> doctors = new ArrayList<>();
		//获取医生团队成员
		SignFamily signFamily = signFamilyDao.findByFamilyDoctorAndPatient(doctor, patient);
		// 查询家庭医生团队
		if (signFamily != null) {
			doctors = drHealthTeamService.findTeamDoctors(signFamily.getTeamCode());
		}
		// 查询三师团队医生
		if (doctors == null || doctors.size() == 0) {
			SignFamily sanshiSign = signFamilyDao.findBySanshiDoctorAndPatient(doctor, patient);
			if (sanshiSign != null) {
				doctors = drHealthTeamService.findTeamDoctors(patient, 1);
			} else {
				doctors = new ArrayList<>();
			}
		}
		return doctors;
	}
	/**
	 * 获取上次随访
	 */
	public Map<String,String> getLastFollowup(String doctor,String patient,String followClass) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		//获取医生团队成员
		String[] doctors = new String[]{doctor};
		List<Doctor> doctorList = getTeamDoctors(doctor,patient);
		if(doctorList!=null&& doctorList.size()>1)
		{
			doctors = new String[doctorList.size()];
			for(int i=0;i<doctorList.size();i++)
			{
				doctors[i] = doctorList.get(i).getCode();
			}
		}
		//获取最新的随访记录
		Followup followup = followupDao.findLastFollowup(doctors,patient,followClass);
		if(followup!=null)
		{
			re.put("id",String.valueOf(followup.getId()));
			re.put("followupDate",DateUtil.dateToStrShort(followup.getFollowupDate()));
		}
		else{
			re = null;
		}
		return re;
	}
	/**
	 * 获取上次随访
	 */
	public void copyFollowup(Long id,Long fromId) throws Exception
	{
		List<FollowupContent> list = followupContentDao.findByFollowupId(fromId);
		if(list!=null && list.size()>0)
		{
			List<FollowupContent> copyList = new ArrayList<>();
			for (FollowupContent item :list)
			{
				FollowupContent copyItem = new FollowupContent();
				copyItem.setFollowupId(id);
				copyItem.setFollowupKey(item.getFollowupKey());
				copyItem.setFollowupValue(item.getFollowupValue());
				copyItem.setFollowupProject(item.getFollowupProject());
				copyItem.setCreateTime(new Date());
				copyList.add(copyItem);
			}
			followupContentDao.save(copyList);
		}
	}
	/**************************************** 随访计划消息 ******************************************/
	/**
	 * 每日发送随访计划提醒消息
    public void copyFollowup(Long id, Long fromId) throws Exception {
        List<FollowupContent> list = followupContentDao.findByFollowupId(fromId);
        if (list != null && list.size() > 0) {
            List<FollowupContent> copyList = new ArrayList<>();
            for (FollowupContent item : list) {
                FollowupContent copyItem = new FollowupContent();
                copyItem.setFollowupId(id);
                copyItem.setFollowupKey(item.getFollowupKey());
                copyItem.setFollowupValue(item.getFollowupValue());
                copyItem.setFollowupProject(item.getFollowupProject());
                copyItem.setCreateTime(new Date());
                copyList.add(copyItem);
            }
            followupContentDao.save(copyList);
        }
    }
    /**************************************** 随访计划消息 ******************************************/
    /**
     * 每日发送随访计划提醒消息
     */
	@Transactional
	public void sendMessage(String date)
	{
	    try{
			String start = date +" 00:00:00";
			String end = date +" 23:59:59";
			String sql = "select doctor_code,count(1) count from wlyy_followup where status not in ('0','1') and followup_plan_date>='"+start+"' and followup_plan_date<='"+end+"' group by doctor_code";
			//获取所有未执行随访计划
			List<Map<String,Object>> followupToday = jdbcTemplate.queryForList(sql);
			if(followupToday!=null)
			{
				List<Message> list = new ArrayList<>();
				for(Map<String,Object> map:followupToday)
				{
					String doctor = String.valueOf(map.get("doctor_code"));
					String count = String.valueOf(map.get("count"));
					// 添加签约消息
					String title = "随访计划提醒";
					String content = "您今日有" +count+"个随访计划待处理";
					Message message = new Message();
					message.setCode(getCode());
					message.setCzrq(new Date());
					message.setContent(content);
					message.setRead(1);//设置未读
					message.setReceiver(doctor);//设置接受医生的code
					message.setSender("system");//设置发送的用户
					message.setTitle(title);
					message.setType(4);//随访计划提醒
					message.setReadonly(1);//是否只读消息
					list.add(message);
					// 推送消息给医生
					PushMsgTask.getInstance().put(doctor,"4",title,content,"");
				}
				messageDao.save(list);
			}
		}
		catch (Exception e)
		{
		   e.printStackTrace();
		}
	}
    @Transactional
    public void sendMessage(String date) {
        try {
            String start = date + " 00:00:00";
            String end = date + " 23:59:59";
            String sql = "select doctor_code,count(1) count from wlyy_followup where status not in ('0','1') and followup_plan_date>='" + start + "' and followup_plan_date<='" + end + "' group by doctor_code";
            //获取所有未执行随访计划
            List<Map<String, Object>> followupToday = jdbcTemplate.queryForList(sql);
            if (followupToday != null) {
                List<Message> list = new ArrayList<>();
                for (Map<String, Object> map : followupToday) {
                    String doctor = String.valueOf(map.get("doctor_code"));
                    String count = String.valueOf(map.get("count"));
                    // 添加签约消息
                    String title = "随访计划提醒";
                    String content = "您今日有" + count + "个随访计划待处理";
                    Message message = new Message();
                    message.setCode(getCode());
                    message.setCzrq(new Date());
                    message.setContent(content);
                    message.setRead(1);//设置未读
                    message.setReceiver(doctor);//设置接受医生的code
                    message.setSender("system");//设置发送的用户
                    message.setTitle(title);
                    message.setType(4);//随访计划提醒
                    message.setReadonly(1);//是否只读消息
                    list.add(message);
                    // 推送消息给医生
                    PushMsgTask.getInstance().put(doctor, "4", title, content, "");
                }
                messageDao.save(list);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 127 - 89
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticleService.java

@ -27,107 +27,145 @@ import com.yihu.wlyy.service.BaseService;
/**
 * 健康教育业务控制类
 * @author George
 *
 * @author George
 */
@Component
@Transactional(rollbackFor = Exception.class)
public class HealthEduArticleService extends BaseService {
	@Autowired
	private HealthEduArticleDao healthEduArticleDao;
	@Autowired
	private HealthEduArticlePatientDao healthEduArticlePatientDao;
	@Autowired
	private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
	@Autowired
	private HealthEduArticleLabelService healthEduArticleLabelService;
	@Autowired
	private JdbcTemplate jdbcTemplate;
    @Autowired
    private HealthEduArticleDao healthEduArticleDao;
    @Autowired
    private HealthEduArticlePatientDao healthEduArticlePatientDao;
    @Autowired
    private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
    @Autowired
    private HealthEduArticleLabelService healthEduArticleLabelService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 查询文章信息
     *
     * @param code
     * @return
     */
    public HealthEduArticle findArticleByCode(String code) {
        return healthEduArticleDao.findByCode(code);
    }
    /**
     * 获取文章列表
     *
     * @param page     页码
     * @param pagesize 分页大小
     * @return 列表
     */
    public List<Map<String, Object>> findAll(int page, int pagesize, String filter, String doctor, String patient) {
        if (pagesize <= 0) {
            pagesize = 10;
        }
        if (page < 0) {
            page = 0;
        }
        List<Object> params = new ArrayList<Object>();
        StringBuffer sql = new StringBuffer();
        sql.append("select a.id,a.code,a.title,a.url,a.czrq,a.content,a.keyword");
        sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 1) as readAmount");
        sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 2) as collectionAmount");
        sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 3) as repeatAmount");
        sql.append(",(select count(1) from wlyy_health_edu_article_doctor c where c.article = a.code and c.doctor =?) as collection");
        params.add(doctor);
        if (StringUtils.isNotBlank(patient)) {
            sql.append(",(select count(1) from wlyy_health_edu_article_patient c where c.article = a.code and c.doctor = ? and c.patient= ? ) as send");
            params.add(doctor);
            params.add(patient);
        }
        sql.append(" from wlyy_health_edu_article a ");//内联取文章内容
        String where = " ";
        if (StringUtils.isNotBlank(filter)) {
            //记录搜索记录
            healthEduArticleLabelService.saveOrUpdateLabel(filter, doctor);
            filter = "%" + filter + "%";
            where += " where ( a.title like ? or a.keyword like ? )";
            params.add(filter);
            params.add(filter);
        }
        int start = page * pagesize;
	/**
	 * 查询文章信息
	 * @param code
	 * @return
	 */
	public HealthEduArticle findArticleByCode(String code) {
		return healthEduArticleDao.findByCode(code);
	}
        String pageInfo = " limit " + start + "," + pagesize;
	/**
	 * 获取文章列表
	 * @param page 页码
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	public List<Map<String, Object>> findAll(int page, int pagesize,String filter,String doctor,String patient) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		if(page<0){
			page = 0;
		}
		List<Object> params = new ArrayList<Object>();
		StringBuffer sql = new StringBuffer();
		sql.append("select a.id,a.code,a.title,a.url,a.czrq,a.content,a.keyword");
		sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 1) as readAmount");
		sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 2) as collectionAmount");
		sql.append(",(select count(1) from wlyy_health_edu_article_op_history c where c.code = a.code and c.status = 3) as repeatAmount");
		sql.append(",(select count(1) from wlyy_health_edu_article_doctor c where c.article = a.code and c.doctor =?) as collection");
		params.add(doctor);
		if(StringUtils.isNotBlank(patient)) {
			sql.append(",(select count(1) from wlyy_health_edu_article_patient c where c.article = a.code and c.doctor = ? and c.patient= ? ) as send");
			params.add(doctor);
			params.add(patient);
		}
		sql.append(" from wlyy_health_edu_article a ");//内联取文章内容
		String where = " ";
		if(StringUtils.isNotBlank(filter)){
			//记录搜索记录
			healthEduArticleLabelService.saveOrUpdateLabel(filter,doctor);
			filter="%"+filter+"%";
			where+=" where ( a.title like ? or a.keyword like ? )";
			params.add(filter);
			params.add(filter);
		}
		int start = page * pagesize;
        String orderBy = " order by a.czrq,a.id desc";
		String pageInfo = " limit "+start+","+pagesize;
        sql.append(where).append(orderBy).append(pageInfo);
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString(), params.toArray());
        return result;
    }
		String orderBy = " order by a.czrq,a.id desc";
    /**
     * 查询给患者发送的健康教育文章
     *
     * @param patient
     * @param teamCode
     * @param page
     * @param pageSize
     * @return
     */
    public List<Map<String, Object>> findByPatientAndTeam(String patient, long teamCode, int page, int pageSize) {
        List<Object> params = new ArrayList<Object>();
        String sql = "select " +
                "    a.article" +
                "    ,a.title" +
                "    ,a.url" +
                "    ,a.czrq" +
                "    ,a.content" +
                "    ,d.code" +
                "    ,d.name" +
                "    ,d.photo" +
                "    ,a.admin_team_code" +
                "  from" +
                "    wlyy_health_edu_article_patient a" +
                "    ,wlyy_doctor d" +
                "  where" +
                "    a.doctor = d.code " +
                "    and a.patient = ?" +
                "    and a.admin_team_code = ?" +
                "  order by a.czrq desc limit " + page*pageSize + "," + pageSize;
		sql.append(where).append(orderBy).append(pageInfo);
		List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString(),params.toArray());
		return result;
	}
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql,new Object[]{patient,teamCode});
        return result;
    }
	/**
	 * 文章更新为已读
	 * @param patient
	 * @param article
	 * @return
	 */
	public int updateRead(String patient, String article) {
		return healthEduArticlePatientDao.updateRead(patient, article);
	}
    /**
     * 文章更新为已读
     *
     * @param patient
     * @param article
     * @return
     */
    public int updateRead(String patient, String article) {
        return healthEduArticlePatientDao.updateRead(patient, article);
    }
	/**
	 * 发送文章列表
	 * @param list
	 * @return
	 */
	public int send(List<HealthEduArticlePatient> list) {
		Iterable<HealthEduArticlePatient> iterable = healthEduArticlePatientDao.save(list);
		//记录转发量
		for(HealthEduArticlePatient healthEduArticlePatient:list){
			healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.REPEAT_STATUS,healthEduArticlePatient.getArticle(),healthEduArticlePatient.getTitle(),healthEduArticlePatient.getDoctor());
		}
		Iterator<HealthEduArticlePatient> iterator = iterable.iterator();
		if (iterator.hasNext()) {
			return 1;
		} else {
			return 0;
		}
    /**
     * 发送文章列表
     *
     * @param list
     * @return
     */
    public int send(List<HealthEduArticlePatient> list) {
        Iterable<HealthEduArticlePatient> iterable = healthEduArticlePatientDao.save(list);
        //记录转发量
        for (HealthEduArticlePatient healthEduArticlePatient : list) {
            healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.REPEAT_STATUS, healthEduArticlePatient.getArticle(), healthEduArticlePatient.getTitle(), healthEduArticlePatient.getDoctor());
        }
        Iterator<HealthEduArticlePatient> iterator = iterable.iterator();
        if (iterator.hasNext()) {
            return 1;
        } else {
            return 0;
        }
	}
    }
}

+ 44 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthGuidanceService.java

@ -2,6 +2,8 @@ package com.yihu.wlyy.service.app.health;
import java.util.Date;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -9,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -37,6 +40,8 @@ public class PatientHealthGuidanceService extends BaseService {
	private PatientDao patientDao;
	@Autowired
	private PatientHealthGuidanceDao patientHealthGuidanceDao;
	@Autowired
	SignFamilyDao signFamilyDao;
	public JSONObject findById(Long id){
		PatientHealthGuidance guidance = patientHealthGuidanceDao.findOne(id);
@ -63,12 +68,19 @@ public class PatientHealthGuidanceService extends BaseService {
	 * @param guidance
	 * @return
	 */
	public PatientHealthGuidance add(PatientHealthGuidance guidance, String accessToken) {
	public PatientHealthGuidance add(PatientHealthGuidance guidance, String accessToken) throws Exception {
		Doctor doctor = doctorDao.findByCode(guidance.getDoctor());
		Patient patient = patientDao.findByCode(guidance.getPatient());
		SignFamily signFamily = signFamilyDao.findByjiatingPatient(guidance.getPatient());
		if(signFamily == null){
			throw new Exception("can not find patient's family sign info");
		}
		guidance.setCzrq(new Date());
		guidance.setDel("1");
		guidance.setAdminTeamCode(signFamily.getAdminTeamId());
		guidance.setSignType(2);
		guidance = patientHealthGuidanceDao.save(guidance);
		if (guidance != null && StringUtils.isNotEmpty(patient.getOpenid())) {
			// 推送消息到微信端
@ -147,6 +159,37 @@ public class PatientHealthGuidanceService extends BaseService {
		return array;
	}
	/**
	 * 健康指导查询
	 *
	 * @param patient
	 * @param teamCode
	 * @param page
	 * @param pageSize
	 * @return
	 */
	public JSONArray findByPatientAndGuidanceAndTeam(String patient,long teamCode,int page,int pageSize){
		Sort sort = new Sort(Sort.Direction.DESC,"czrq");
		PageRequest pageRequest = new PageRequest(0, pageSize, sort);
		Page<Object> result = patientHealthGuidanceDao.findByPatientAndTeamCode(patient,teamCode,pageRequest);
		JSONArray array = new JSONArray();
		if (result != null) {
			for (Object obj : result) {
				Object[] temp = (Object[]) obj;
				JSONObject json = new JSONObject();
				json.put("doctorCode", temp[6]);
				json.put("doctorName", temp[0]);
				json.put("doctorPhoto", temp[1]);
				json.put("id", temp[2]);
				json.put("content", temp[3]);
				json.put("czrq", DateUtil.dateToStrLong((Date) temp[4]));
				json.put("adminTeamCode", temp[7]);
				array.put(json);
			}
		}
		return array;
	}
	/**
	 * 查询患者的健康指导
	 * @param patient 患者标识

+ 20 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -332,7 +332,10 @@ public class MessageService extends BaseService {
                map.put("value2", String.valueOf(item.getValue2()));
                map.put("czrq", DateUtil.dateToStrLong(item.getCzrq()));
                re.add(map);
                item.setRead(0);//把消息设置为已读
            }
            messageDao.save(list);
        }
        return re;
    }
@ -340,12 +343,25 @@ public class MessageService extends BaseService {
    /**
     * 获取系统消息
     */
    public List<Message> getSystemMessage(String doctor,Integer page,Integer pagesize) throws Exception
    {
    public List<Message> getSystemMessage(String doctor, Integer page, Integer pagesize) throws Exception {
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC, "czrq");
        // 分页信息
        Pageable pageRequest = new PageRequest(page - 1, pagesize,sort);
        return messageDao.getSystemMessage(doctor,pageRequest);
        Pageable pageRequest = new PageRequest(page - 1, pagesize, sort);
        return messageDao.getSystemMessage(doctor, pageRequest);
    }
    /**
     * 设置某类消息已读
     *
     * @param doctor
     * @param type
     */
    public void setMessageReaded(String doctor, int type) {
        if (type == 3) {
            messageDao.setSysMessageReaded(doctor);
        } else {
            messageDao.setMessageReaded(doctor, type);
        }
    }
}

+ 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,String doctor, 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(StringUtils.isNotBlank(doctor)){//传入医生查询医生帮此患者的预约记录
			list = patientReservationDao.findByPatientAndDoctor(patient, doctor, 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);
    }
}

+ 90 - 20
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -869,18 +869,18 @@ public class FamilyContractService extends BaseService {
        Calendar begin = Calendar.getInstance();
        Calendar end = Calendar.getInstance();
        // 起始时间
        begin.set(Calendar.HOUR,0);
        begin.set(Calendar.MINUTE,0);
        end.set(Calendar.SECOND,0);
        begin.set(Calendar.MILLISECOND,0);
        begin.set(Calendar.HOUR, 0);
        begin.set(Calendar.MINUTE, 0);
        end.set(Calendar.SECOND, 0);
        begin.set(Calendar.MILLISECOND, 0);
        // 结束时间
        end.set(Calendar.HOUR,0);
        end.set(Calendar.MINUTE,0);
        end.set(Calendar.SECOND,0);
        end.set(Calendar.MILLISECOND,0);
        end.set(Calendar.HOUR, 0);
        end.set(Calendar.MINUTE, 0);
        end.set(Calendar.SECOND, 0);
        end.set(Calendar.MILLISECOND, 0);
        end.set(Calendar.MONTH, 5);
        end.set(Calendar.DATE,30);
        end.set(Calendar.DATE, 30);
        if (month < 2 || month > 5) {
            if (month > 5) {
@ -888,7 +888,7 @@ public class FamilyContractService extends BaseService {
            }
        } else {
            begin.set(Calendar.MONTH, 6);
            begin.set(Calendar.DATE,1);
            begin.set(Calendar.DATE, 1);
            end.add(Calendar.YEAR, 1);
        }
@ -1057,18 +1057,18 @@ public class FamilyContractService extends BaseService {
            Calendar begin = Calendar.getInstance();
            Calendar end = Calendar.getInstance();
            // 起始时间
            begin.set(Calendar.HOUR,0);
            begin.set(Calendar.MINUTE,0);
            end.set(Calendar.SECOND,0);
            begin.set(Calendar.MILLISECOND,0);
            begin.set(Calendar.HOUR, 0);
            begin.set(Calendar.MINUTE, 0);
            end.set(Calendar.SECOND, 0);
            begin.set(Calendar.MILLISECOND, 0);
            // 结束时间
            end.set(Calendar.HOUR,0);
            end.set(Calendar.MINUTE,0);
            end.set(Calendar.SECOND,0);
            end.set(Calendar.MILLISECOND,0);
            end.set(Calendar.HOUR, 0);
            end.set(Calendar.MINUTE, 0);
            end.set(Calendar.SECOND, 0);
            end.set(Calendar.MILLISECOND, 0);
            end.set(Calendar.MONTH, 5);
            end.set(Calendar.DATE,30);
            end.set(Calendar.DATE, 30);
            if (month < 2 || month > 5) {
                if (month > 5) {
@ -1076,7 +1076,7 @@ public class FamilyContractService extends BaseService {
                }
            } else {
                begin.set(Calendar.MONTH, 6);
                begin.set(Calendar.DATE,1);
                begin.set(Calendar.DATE, 1);
                end.add(Calendar.YEAR, 1);
            }
@ -2367,4 +2367,74 @@ public class FamilyContractService extends BaseService {
        Integer count = jdbcTemplate.queryForObject(sql, parms, Integer.class);
        return count;
    }
    /**
     * 查询医生与居民的团队
     *
     * @param patient
     * @param doctor
     * @return
     */
    public JSONObject getPatientAndDoctorTeams(String patient, String doctor) {
        JSONObject result = new JSONObject();
        SignFamily ssSign = signFamilyDao.findSignByPatient(patient, 1);
        SignFamily jtSign = signFamilyDao.findSignByPatient(patient, 2);
        if (ssSign != null && ssSign.getAdminTeamId() != null) {
            JSONObject ssTeam = new JSONObject();
            if (doctor.equals(ssSign.getDoctor()) || doctor.equals(ssSign.getDoctorHealth())) {
                ssTeam.put("hasSign", 1);
            } else {
                ssTeam.put("hasSign", 0);
            }
            AdminTeam team = adminTeamService.getTeam(ssSign.getAdminTeamId());
            if (team != null) {
                if (doctor.equals(team.getLeaderCode())) {
                    ssTeam.put("isLeader", 1);
                } else {
                    ssTeam.put("isLeader", 0);
                }
                ssTeam.put("team", new JSONObject(team));
                if (ssTeam.getInt("hasSign") == 1 || ssTeam.getInt("isLeader") == 1) {
                    result.put("ssTeam", ssTeam);
                }
            }
        }
        if (jtSign != null) {
            JSONObject jtTeam = new JSONObject();
            if (doctor.equals(jtSign.getDoctor()) || doctor.equals(jtSign.getDoctorHealth())) {
                jtTeam.put("hasSign", 1);
            } else {
                jtTeam.put("hasSign", 0);
            }
            AdminTeam team = adminTeamService.getTeam(jtSign.getAdminTeamId());
            if (team != null) {
                if (doctor.equals(team.getLeaderCode())) {
                    jtTeam.put("isLeader", 1);
                } else {
                    jtTeam.put("isLeader", 0);
                }
                jtTeam.put("team", new JSONObject(team));
                if (jtTeam.getInt("hasSign") == 1 || jtTeam.getInt("isLeader") == 1) {
                    result.put("jtTeam", jtTeam);
                }
            }
        }
        if (result.has("jtTeam") || result.has("ssTeam")) {
            result.put("hasSign",1);
        } else {
            result.put("hasSign",0);
        }
        return result;
    }
}

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

@ -0,0 +1,284 @@
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;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
/**
 * Created by lyr-pc on 2017/1/10.
 */
@Service
public class ServiceStatisticsService extends BaseService {
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    SignFamilyDao signFamilyDao;
    @Autowired
    AdminTeamService teamService;
    public JSONObject getServiceStatistics(String patient, long teamCode, String doctor) throws Exception {
        JSONObject result = new JSONObject();
        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";
        String yearBegin = DateUtil.dateToStrShort(signFamily.getBegin()) + " 00:00:00";
        String yearEnd = DateUtil.dateToStrShort(signFamily.getEnd()) + " 23:59:59";
        JSONObject consult = getConsultStatistics(patient, teamCode, yearBegin, yearEnd, monthBegin);
        result.put("consult", consult);
        JSONObject followup = getFollowupStatistics(patient, teamCode, yearBegin, yearEnd, monthBegin);
        result.put("followup", followup);
        JSONObject reservation = getReservationStatistics(patient, teamCode, yearBegin, yearEnd, monthBegin);
        result.put("reservation", reservation);
        JSONObject guidance = getGuidanceStatistics(patient, teamCode, yearBegin, yearEnd, monthBegin);
        result.put("guidance", guidance);
        JSONObject article = getArticleStatistics(patient, teamCode, yearBegin, yearEnd, monthBegin);
        result.put("article", article);
        return result;
    }
    /**
     * 咨询统计
     *
     * @param patient
     * @param teamCode
     * @param yearBegin
     * @param yearEnd
     * @param monthBegin
     * @return
     */
    public JSONObject getConsultStatistics(String patient, long teamCode, String yearBegin, String yearEnd, String monthBegin) {
        JSONObject result = new JSONObject();
        result.put("history", 0);
        result.put("history", 0);
        result.put("history", 0);
        String sqlHistory = "select count(1) h from wlyy_consult_team where patient = ? and admin_team_code = ?";
        String sqlYear = "select count(1) y from wlyy_consult_team where patient = ? and admin_team_code = ? and czrq >= ? and czrq <= ?";
        String sqlMonth = "select count(1) m from wlyy_consult_team where patient = ? and admin_team_code = ? and czrq >= ?";
        String sql = "select * from " +
                "(" + sqlHistory + ") a" +
                ",(" + sqlYear + ") b" +
                ",(" + sqlMonth + ") c";
        List<Map<String, Object>> counts = jdbcTemplate.queryForList(sql, new Object[]{patient, teamCode,
                patient, teamCode, yearBegin, yearEnd, patient, teamCode, monthBegin
        });
        if (counts != null && counts.size() > 0) {
            result.put("history", counts.get(0).get("h").toString());
            result.put("year", counts.get(0).get("y").toString());
            result.put("month", counts.get(0).get("m").toString());
        }
        return result;
    }
    /**
     * 健康教育统计
     *
     * @param patient
     * @param teamCode
     * @param yearBegin
     * @param yearEnd
     * @param monthBegin
     * @return
     */
    public JSONObject getArticleStatistics(String patient, long teamCode, String yearBegin, String yearEnd, String monthBegin) {
        JSONObject result = new JSONObject();
        result.put("history", 0);
        result.put("year", 0);
        result.put("month", 0);
        String sqlHistory = "select count(1) h from wlyy_health_edu_article_patient where patient = ? and admin_team_code = ?";
        String sqlYear = "select count(1) y from wlyy_health_edu_article_patient where patient = ? and admin_team_code = ? and czrq >= ? and czrq <= ?";
        String sqlMonth = "select count(1) m from wlyy_health_edu_article_patient where patient = ? and admin_team_code = ? and czrq >= ?";
        String sql = "select * from " +
                "(" + sqlHistory + ") a" +
                ",(" + sqlYear + ") b" +
                ",(" + sqlMonth + ") c";
        List<Map<String, Object>> counts = jdbcTemplate.queryForList(sql, new Object[]{patient, teamCode,
                patient, teamCode, yearBegin, yearEnd, patient, teamCode, monthBegin
        });
        if (counts != null && counts.size() > 0) {
            result.put("history", counts.get(0).get("h").toString());
            result.put("year", counts.get(0).get("y").toString());
            result.put("month", counts.get(0).get("m").toString());
        }
        return result;
    }
    /**
     * 健康指导统计
     *
     * @param patient
     * @param teamCode
     * @param yearBegin
     * @param yearEnd
     * @param monthBegin
     * @return
     */
    public JSONObject getGuidanceStatistics(String patient, long teamCode, String yearBegin, String yearEnd, String monthBegin) {
        JSONObject result = new JSONObject();
        result.put("history", 0);
        result.put("year", 0);
        result.put("month", 0);
        String sqlHistory = "select count(1) h from wlyy_patient_health_guidance where patient = ? and admin_team_code = ?";
        String sqlYear = "select count(1) y from wlyy_patient_health_guidance where patient = ? and admin_team_code = ? and czrq >= ? and czrq <= ?";
        String sqlMonth = "select count(1) m from wlyy_patient_health_guidance where patient = ? and admin_team_code = ? and czrq >= ?";
        String sql = "select * from " +
                "(" + sqlHistory + ") a" +
                ",(" + sqlYear + ") b" +
                ",(" + sqlMonth + ") c";
        List<Map<String, Object>> counts = jdbcTemplate.queryForList(sql, new Object[]{patient, teamCode,
                patient, teamCode, yearBegin, yearEnd, patient, teamCode, monthBegin
        });
        if (counts != null && counts.size() > 0) {
            result.put("history", counts.get(0).get("h").toString());
            result.put("year", counts.get(0).get("y").toString());
            result.put("month", counts.get(0).get("m").toString());
        }
        return result;
    }
    /**
     * 随访计划统计
     *
     * @param patient
     * @param teamCode
     * @param yearBegin
     * @param yearEnd
     * @param monthBegin
     * @return
     */
    public JSONObject getFollowupStatistics(String patient, long teamCode, String yearBegin, String yearEnd, String monthBegin) {
        JSONObject result = new JSONObject();
        result.put("history", 0);
        result.put("year", 0);
        result.put("month", 0);
        String sqlHistory = "select count(1) h from wlyy_followup where patient_code = ? and admin_team_code = ?";
        String sqlYear = "select count(1) y from wlyy_followup where patient_code = ? and admin_team_code = ? and create_time >= ? and create_time <= ?";
        String sqlMonth = "select count(1) m from wlyy_followup where patient_code = ? and admin_team_code = ? and create_time >= ?";
        String sql = "select * from " +
                "(" + sqlHistory + " and status > 0" + ") a" +
                ",(" + sqlYear + " and status > 0" + ") b" +
                ",(" + sqlMonth + " and status > 0" + ") c" +
                ",(" + sqlHistory.replace(" h ", " hh ") + " and status = 1" + ") d" +
                ",(" + sqlYear.replace(" y ", " yy ") + " and status = 1" + ") e" +
                ",(" + 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
        });
        if (counts != null && counts.size() > 0) {
            result.put("history", counts.get(0).get("hh").toString() + "/" + counts.get(0).get("h").toString());
            result.put("year", counts.get(0).get("yy").toString() + "/" + counts.get(0).get("y").toString());
            result.put("month", counts.get(0).get("mm").toString() + "/" + counts.get(0).get("m").toString());
        }
        return result;
    }
    /**
     * 随访计划统计
     *
     * @param patient
     * @param teamCode
     * @param yearBegin
     * @param yearEnd
     * @param monthBegin
     * @return
     */
    public JSONObject getReservationStatistics(String patient, long teamCode, String yearBegin, String yearEnd, String monthBegin) {
        JSONObject result = new JSONObject();
        result.put("history", 0);
        result.put("year", 0);
        result.put("month", 0);
        String sqlHistory = "select count(1) h from wlyy_patient_reservation where patient = ? and admin_team_code = ?";
        String sqlYear = "select count(1) y from wlyy_patient_reservation where patient = ? and admin_team_code = ? and czrq >= ? and czrq <= ?";
        String sqlMonth = "select count(1) m from wlyy_patient_reservation where patient = ? and admin_team_code = ? and czrq >= ?";
        String sql = "select * from " +
                "(" + sqlHistory + ") a" +
                ",(" + sqlYear + ") b" +
                ",(" + sqlMonth + ") c";
        List<Map<String, Object>> counts = jdbcTemplate.queryForList(sql, new Object[]{patient, teamCode,
                patient, teamCode, yearBegin, yearEnd, patient, teamCode, monthBegin
        });
        if (counts != null && counts.size() > 0) {
            result.put("history", counts.get(0).get("h").toString());
            result.put("year", counts.get(0).get("y").toString());
            result.put("month", counts.get(0).get("m").toString());
        }
        return result;
    }
}

+ 6 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -1,6 +1,6 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.service.common.account;
@ -120,6 +120,7 @@ public class PatientService extends TokenService {
                    continue;
                }
                p.setOpenid("");
                p.setOpenidTime(null);
                signFamilyDao.updateOpenidByPatient("", p.getCode());
                patientDao.save(p);
                tokenDao.delete(token);
@ -127,7 +128,10 @@ public class PatientService extends TokenService {
                break;
            }
        }
        //如果之前患者的openId为空并且openID有值更新时间
        if (!org.springframework.util.StringUtils.isEmpty(openid) && org.springframework.util.StringUtils.isEmpty(patient.getOpenid())) {
            patient.setOpenidTime(new Date());
        }
        patient.setOpenid(openid);
        Patient ps = patientDao.save(patient);
        System.out.print(new JSONObject(ps));

+ 102 - 122
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -3,8 +3,10 @@ package com.yihu.wlyy.service.third.guahao;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientReservationDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.util.DateUtil;
@ -38,7 +40,7 @@ public class GuahaoXMService implements IGuahaoService {
    private String ORDER_CREATE = "WebRegisterVerify";  //新建预约
    private String ORDER_CANCEL = "Unregister";   //取消预约
    private String ORDER_INFO = "GetReservationRecord";//预约信息
    private String REG_LIST ="GetRegList";//获取市民预约挂号信息
    private String REG_LIST = "GetRegList";//获取市民预约挂号信息
    @Autowired
    private PatientService patientService;
@ -49,31 +51,29 @@ public class GuahaoXMService implements IGuahaoService {
    @Autowired
    private PatientReservationDao patientReservationDao;
    @Autowired
    SignFamilyDao signFamilyDao;
    private ObjectMapper objectMapper = new ObjectMapper();
    /**
     * 解析挂号后
     */
    private String CreateOrderAfter(String response,String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String sectionType,String startTime,String endTime,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode) throws Exception
    {
    private String CreateOrderAfter(String response, String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String sectionType, String startTime, String endTime, String patient, String patientName, String cardNo, String clinicCard, String patientPhone, String dname, String dcode) throws Exception {
        String code = "";
        if(response.startsWith("error")||response.startsWith("System-Error"))
        {
        if (response.startsWith("error") || response.startsWith("System-Error")) {
            throw new Exception(response);
        }
        else if (response.toLowerCase().startsWith("ok")) {      //预约成功
        } else if (response.toLowerCase().startsWith("ok")) {      //预约成功
            // 预约成功,获取预约号
            code = response.replace("OK:", "").replace("ok:", "");
        }
        else if(response.split("\\|").length==3){
        } else if (response.split("\\|").length == 3) {
            code = response.split("\\|")[0];
        }
        else{
        } else {
            throw new Exception(response);
        }
        // 查询医生职称和头像
        GuahaoDoctor doctor =  GetDoctorInfo(doctorId,hospitalId,hosDeptId);
        GuahaoDoctor doctor = GetDoctorInfo(doctorId, hospitalId, hosDeptId);
        // 保存预约记录
        PatientReservation reservation = new PatientReservation();
        reservation.setCode(code);
@ -96,12 +96,20 @@ public class GuahaoXMService implements IGuahaoService {
        reservation.setStartTime(startTime);
        reservation.setEndTime(endTime);
        reservation.setStatus(1);
        if(StringUtils.isNotBlank(dname)){
        if (StringUtils.isNotEmpty(dcode)) {
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
            if (signFamily == null) {
                throw new Exception("can not find patient's family sign info");
            }
            reservation.setSignType(2);
            reservation.setAdminTeamCode(signFamily.getAdminTeamId());
        }
        if (StringUtils.isNotBlank(dname)) {
            reservation.setDname(dname);//代理签约维护待签约人名称
        }
        if(StringUtils.isNotBlank(dcode)){
        if (StringUtils.isNotBlank(dcode)) {
            reservation.setDoctor(dcode);//代理签约维护待签约人编码
            SendP2PUtil.sendP2Pmsg(dcode,patient,"1","我已成功为您预约:"+startTime+","+hospitalName+hosDeptName+doctorName+"医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='"+code+"'>点击查看详情</a>");
            SendP2PUtil.sendP2Pmsg(dcode, patient, "1", "我已成功为您预约:" + startTime + "," + hospitalName + hosDeptName + doctorName + "医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='" + code + "'>点击查看详情</a>");
        }
        // 保存预约记录
        patientReservationDao.save(reservation);
@ -112,22 +120,21 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 预约排班xml转列表
     */
    private List<Map<String,Object>> xmlToList(String xml) throws Exception{
        List<Map<String,Object>> re = new ArrayList<>();
    private List<Map<String, Object>> xmlToList(String xml) throws Exception {
        List<Map<String, Object>> re = new ArrayList<>();
        if (StringUtils.isEmpty(xml)) {
            // 请求失败
            throw new Exception("获取医生排班表失败!");
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        if(root.element("doctor")!=null)     //包含doctor节点
        if (root.element("doctor") != null)     //包含doctor节点
        {
            root = root.element("doctor");
        }
@ -145,7 +152,7 @@ public class GuahaoXMService implements IGuahaoService {
            String used = e.attributeValue("used");
            // 1正常、2满号、3已过期
            String status = e.attributeValue("status");
            Map<String,Object> map = new HashMap<>();
            Map<String, Object> map = new HashMap<>();
            map.put("date", date);
            map.put("time", time);
            map.put("max", max);
@ -153,7 +160,7 @@ public class GuahaoXMService implements IGuahaoService {
            map.put("status", status);
            // 排班信息
            List<?> sections = e.elements();
            List<Map<String,String>> arrangeList = new ArrayList<>();
            List<Map<String, String>> arrangeList = new ArrayList<>();
            for (Object s : sections) {
                Element section = (Element) s;
                // 限号
@ -165,7 +172,7 @@ public class GuahaoXMService implements IGuahaoService {
                // 结束时间
                String end_time = section.attributeValue("end_time");
                Map<String,String> item = new HashMap<>();
                Map<String, String> item = new HashMap<>();
                item.put("max", s_max);
                item.put("used", s_used);
                item.put("startTime", start_time);
@ -184,23 +191,20 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 获取医院列表
     */
    public List<Map<String,String>> GetOrgList(String city,String filter,String type,Integer pageIndex,Integer pageSize) throws Exception{
        List<Map<String,String>> re = new ArrayList<>();
    public List<Map<String, String>> GetOrgList(String city, String filter, String type, Integer pageIndex, Integer pageSize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        String[] values = null;
        //医院列表
        if(type.equals("1"))
        {
        if (type.equals("1")) {
            values = SOAPUtil.getCredential("<?xml version=\"1.0\" encoding=\"utf-8\"?><root type=\"1\"></root>", true);
        }
        else if(type.equals("2")) //社区列表
        } else if (type.equals("2")) //社区列表
        {
            values = SOAPUtil.getCredential("<?xml version=\"1.0\" encoding=\"utf-8\"?><root type=\"2\"></root>", true);
        }
        if(values!=null && values.length==3)
        {
        if (values != null && values.length == 3) {
            JSONArray params = new JSONArray();
            JSONObject param1 = new JSONObject();
@ -225,8 +229,7 @@ public class GuahaoXMService implements IGuahaoService {
            } else if (StringUtils.startsWith(xml, "System-Error")) {
                // 调用失败
                throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
            }
            else if (StringUtils.startsWith(xml, "Error")) {
            } else if (StringUtils.startsWith(xml, "Error")) {
                // 调用失败
                throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
            }
@ -238,24 +241,24 @@ public class GuahaoXMService implements IGuahaoService {
                String shortName = e.attribute("short_name").getValue();
                String code = e.attribute("code").getValue();
                String name = e.getText();
                Map<String,String> map = new HashMap<>();
                Map<String, String> map = new HashMap<>();
                map.put("id", code);
                map.put("name", shortName);
                map.put("address", name);
                String photo = hospitalMappingDao.getPhotoByMappingCode(code,"1");
                String photo = hospitalMappingDao.getPhotoByMappingCode(code, "1");
                map.put("photo", photo);
                re.add(map);
            }
        }
        return  re;
        return re;
    }
    /**
     * 获取科室接口
     */
    public List<Map<String,String>> GetOrgDepList(String hospitalId,String filter,Integer pageIndex,Integer pageSize) throws Exception{
        List<Map<String,String>> re = new ArrayList<>();
    public List<Map<String, String>> GetOrgDepList(String hospitalId, String filter, Integer pageIndex, Integer pageSize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        JSONArray params = new JSONArray();
        JSONObject param1 = new JSONObject();
@ -270,8 +273,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -280,24 +282,23 @@ public class GuahaoXMService implements IGuahaoService {
        List<?> child = root.elements();
        for (Object o : child) {
            Element e = (Element) o;
            if(e.getName().equals("dept"))
            {
            if (e.getName().equals("dept")) {
                String code = e.attribute("code").getValue();
                String name = e.attribute("name").getValue();
                Map<String,String> map = new HashMap<>();
                Map<String, String> map = new HashMap<>();
                map.put("id", code);
                map.put("name", name);
                map.put("hospitalId", hospitalId);
                re.add(map);
            }
        }
        return  re;
        return re;
    }
    /**
     * 获取医生列表接口
     */
    public List<GuahaoDoctor> GetDoctorList(String hospitalId,String hosDeptId,String filter,Integer pageIndex,Integer pageSize) throws Exception{
    public List<GuahaoDoctor> GetDoctorList(String hospitalId, String hosDeptId, String filter, Integer pageIndex, Integer pageSize) throws Exception {
        List<GuahaoDoctor> re = new ArrayList<>();
        JSONArray params = new JSONArray();
@ -319,7 +320,7 @@ public class GuahaoXMService implements IGuahaoService {
        JSONObject param4 = new JSONObject();
        param4.put("key", "?strEnd");
        param4.put("value", DateUtil.getNextDay(nowDate,nextDays));  //一周后时间
        param4.put("value", DateUtil.getNextDay(nowDate, nextDays));  //一周后时间
        params.put(param4);
        String xml = SOAPUtil.post(DOCTOR_LIST, params);
@ -329,8 +330,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -353,8 +353,7 @@ public class GuahaoXMService implements IGuahaoService {
            String name = e.attributeValue("name");
            // 照片
            String photo = "";
            if(e.attribute("photo")!=null)
            {
            if (e.attribute("photo") != null) {
                photo = e.attributeValue("photo");
            }
            // 挂号费
@ -382,14 +381,14 @@ public class GuahaoXMService implements IGuahaoService {
            doctor.setHospitalName(orgname);
            re.add(doctor);
        }
        return  re;
        return re;
    }
    /**
     * 获取医生排班接口(包含排班详细)
     * status 0 停诊、1正常、2满号、3已过期
     */
    public List<Map<String,Object>> GetDoctorArrange(String hospitalId,String hosDeptId,String doctorId) throws Exception{
    public List<Map<String, Object>> GetDoctorArrange(String hospitalId, String hosDeptId, String doctorId) throws Exception {
        JSONArray params = new JSONArray();
        JSONObject param1 = new JSONObject();
@ -415,20 +414,20 @@ public class GuahaoXMService implements IGuahaoService {
        JSONObject param5 = new JSONObject();
        param5.put("key", "?strEnd");
        param5.put("value", DateUtil.getNextDay(nowDate,nextDays));  //一周后时间
        param5.put("value", DateUtil.getNextDay(nowDate, nextDays));  //一周后时间
        params.put(param5);
        String xml = SOAPUtil.post(DOCTOR_ARRANGE, params);
        return  xmlToList(xml);
        return xmlToList(xml);
    }
    /**
     * 获取医生排班接口(一级)
     * status 0 停诊、1正常、2满号、3已过期
     */
    public List<Map<String,String>> GetDoctorArrangeSimple(String hospitalId,String hosDeptId,String doctorId) throws Exception{
        List<Map<String,String>> re = new ArrayList<>();
    public List<Map<String, String>> GetDoctorArrangeSimple(String hospitalId, String hosDeptId, String doctorId) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        JSONArray params = new JSONArray();
        JSONObject param1 = new JSONObject();
@ -454,7 +453,7 @@ public class GuahaoXMService implements IGuahaoService {
        JSONObject param5 = new JSONObject();
        param5.put("key", "?strEnd");
        param5.put("value", DateUtil.getNextDay(nowDate,nextDays));  //一周后时间
        param5.put("value", DateUtil.getNextDay(nowDate, nextDays));  //一周后时间
        params.put(param5);
        String xml = SOAPUtil.post(DOCTOR_ARRANGE_SIMPLE, params);
@ -464,8 +463,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -484,7 +482,7 @@ public class GuahaoXMService implements IGuahaoService {
            String used = e.attributeValue("used");
            // 1正常、2满号、3已过期
            String status = e.attributeValue("status");
            Map<String,String> map = new HashMap<>();
            Map<String, String> map = new HashMap<>();
            map.put("date", date);
            map.put("time", time);
            map.put("max", max);
@ -493,13 +491,13 @@ public class GuahaoXMService implements IGuahaoService {
            re.add(map);
        }
        return  re;
        return re;
    }
    /**
     * 创建挂号单
     */
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception{
    public String CreateOrder(String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String arrangeDate, String patient, String patientName, String cardNo, String clinicCard, String patientPhone) throws Exception {
        String re = "";
        Patient p = patientService.findByCode(patient);
@ -507,8 +505,8 @@ public class GuahaoXMService implements IGuahaoService {
            throw new Exception("患者信息不存在!");
        }
        Map<String,String> map = objectMapper.readValue(arrangeDate,Map.class);
        if(map.containsKey("sectionType") && map.containsKey("startTime")) {
        Map<String, String> map = objectMapper.readValue(arrangeDate, Map.class);
        if (map.containsKey("sectionType") && map.containsKey("startTime")) {
            String sectionType = map.get("sectionType");
            String startTime = map.get("startTime");
            String endTime = map.get("endTime");
@ -555,14 +553,13 @@ public class GuahaoXMService implements IGuahaoService {
            } else if (StringUtils.startsWith(response, "System-Error")) {
                // 调用失败
                throw new Exception(response.substring(response.indexOf(":") + 1, response.length()));
            }  else if (StringUtils.startsWith(response, "Error")) {
            } else if (StringUtils.startsWith(response, "Error")) {
                // 调用失败
                throw new Exception(response.substring(response.indexOf(":") + 1, response.length()));
            }
            re = CreateOrderAfter(response,hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,sectionType,startTime,endTime,patient,patientName,cardNo,clinicCard,patientPhone,null,null);
        }
        else{
            re = CreateOrderAfter(response, hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, sectionType, startTime, endTime, patient, patientName, cardNo, clinicCard, patientPhone, null, null);
        } else {
            throw new Exception("该排班信息错误或者不存在!");
        }
@ -570,13 +567,10 @@ public class GuahaoXMService implements IGuahaoService {
    }
    /**
     * 取消挂号单
     */
    public boolean CancelOrder(String orderId,String clinicCard)   throws Exception
    {
    public boolean CancelOrder(String orderId, String clinicCard) throws Exception {
        JSONArray params = new JSONArray();
        JSONObject param1 = new JSONObject();
@ -608,8 +602,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -624,8 +617,7 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 获取医生信息
     */
    public GuahaoDoctor GetDoctorInfo(String doctorId,String hospitalId,String hosDeptId) throws Exception
    {
    public GuahaoDoctor GetDoctorInfo(String doctorId, String hospitalId, String hosDeptId) throws Exception {
        GuahaoDoctor doctor = new GuahaoDoctor();
        JSONArray params = new JSONArray();
@ -644,7 +636,7 @@ public class GuahaoXMService implements IGuahaoService {
        params.put(param3);
        JSONObject param4 = new JSONObject();
        param4.put("key", "?strEnd");
        param4.put("value", DateUtil.getNextDay(nowDate,nextDays));  //一周后时间
        param4.put("value", DateUtil.getNextDay(nowDate, nextDays));  //一周后时间
        params.put(param4);
        String xml = SOAPUtil.post(DOCTOR_LIST, params);
@ -654,8 +646,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -667,8 +658,7 @@ public class GuahaoXMService implements IGuahaoService {
            // 医生编码
            String code = e.attributeValue("code");
            if(code.equals(doctorId))
            {
            if (code.equals(doctorId)) {
                // 性别
                String sex = e.attributeValue("sex");
                // 职称
@ -681,8 +671,7 @@ public class GuahaoXMService implements IGuahaoService {
                String name = e.attributeValue("name");
                // 照片
                String photo = "";
                if(e.attribute("photo")!=null)
                {
                if (e.attribute("photo") != null) {
                    photo = e.attributeValue("photo");
                }
                // 挂号费
@ -711,15 +700,14 @@ public class GuahaoXMService implements IGuahaoService {
                break;
            }
        }
        return  doctor;
        return doctor;
    }
    /**
     * 获取预约状态
     * 0 撤销 1 确认 2 已诊  3停诊
     */
    public Integer GetOrderStatus(String hospitalId,String orderId,String clinicCard) throws Exception
    {
    public Integer GetOrderStatus(String hospitalId, String orderId, String clinicCard) throws Exception {
        Integer re = null;
        try {
            StringBuffer sb = new StringBuffer();
@ -789,9 +777,7 @@ public class GuahaoXMService implements IGuahaoService {
            } else {
                throw new Exception("获取预约状态失败!");
            }
        }
        catch (Exception ex)
        {
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return re;
@ -800,10 +786,9 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 根据患者医保卡获取近三个月的预约记录
     */
    public List<PatientReservation> GetRegList(String patientCode,String strStart,String strEnd) throws Exception
    {
    public List<PatientReservation> GetRegList(String patientCode, String strStart, String strEnd) throws Exception {
        Patient patient = patientService.findByCode(patientCode);
        if(patient==null){
        if (patient == null) {
            throw new Exception("不存在该用户!");
        }
@ -830,7 +815,7 @@ public class GuahaoXMService implements IGuahaoService {
        params.put(param4);
        JSONObject param5 = new JSONObject();
        param5.put("key", "?strKey");
        param5.put("value",values[2]);  //一周后时间
        param5.put("value", values[2]);  //一周后时间
        params.put(param5);
        String xml = SOAPUtil.post(REG_LIST, params);
        if (StringUtils.isEmpty(xml)) {
@ -839,8 +824,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -849,7 +833,7 @@ public class GuahaoXMService implements IGuahaoService {
        List<?> child = root.elements();
        if(child.size()>0) {
        if (child.size() > 0) {
            for (Object o : child) {
                Element e = (Element) o;
                // 医生编码
@ -918,8 +902,7 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 根据患者,预约编号,机构编号获取单条记录预约记录
     */
    public PatientReservation getRegDetail(String patientCode,String orgCode,String regCode) throws Exception
    {
    public PatientReservation getRegDetail(String patientCode, String orgCode, String regCode) throws Exception {
        //获取签名信息
        Patient patient = patientService.findByCode(patientCode);
        StringBuffer sb = new StringBuffer();
@ -953,8 +936,7 @@ public class GuahaoXMService implements IGuahaoService {
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error"))  {
        } else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
@ -962,12 +944,11 @@ public class GuahaoXMService implements IGuahaoService {
        Element root = document.getRootElement();
        List<?> child = root.elements();
        if(patient==null){
        if (patient == null) {
            throw new Exception("获取挂号人员信息失败!");
        }
        if(child.size()>0)
        {
        if (child.size() > 0) {
            Element e = (Element) child.get(0);
            // 医生编码
            String regdate = e.attributeValue("regdate");//预约日期
@ -979,14 +960,14 @@ public class GuahaoXMService implements IGuahaoService {
            String OrgCode = e.attributeValue("org_code");//医疗机构编码
            String org = e.attributeValue("org_name");//医疗机构名称
            String DeptCode = e.attributeValue("dept_code");//科室代码
            String dept =e.attributeValue("dept_name");//科室
            String dept = e.attributeValue("dept_name");//科室
            String DoctorCode = e.attributeValue("doctor_code");//医生代码
            String doctor = e.attributeValue("doctor_name");//医生
            String Introduction = e.attributeValue("introduction");//医生简介
            String status = e.attributeValue("status");//状态:删除、新建、确认、已诊
            String enter_time = e.attributeValue("enter_time");//预约登记时间
            String notes = e.attributeValue("notes");//备注
            String code  = e.getText();//预约号
            String code = e.getText();//预约号
            PatientReservation patientReservation = new PatientReservation();
            patientReservation.setCode(code);
            patientReservation.setSectionType(time);
@ -1005,7 +986,7 @@ public class GuahaoXMService implements IGuahaoService {
            patientReservation.setName(patient.getName());
            patientReservation.setIdcard(patient.getIdcard());
            patientReservation.setPhone(patient.getMobile());
            switch (status){
            switch (status) {
                case "删除":
                    patientReservation.setStatus(0);
                    break;
@ -1018,30 +999,31 @@ public class GuahaoXMService implements IGuahaoService {
                case "已诊":
                    patientReservation.setStatus(3);
                    break;
                default:patientReservation.setStatus(4);
            };
                default:
                    patientReservation.setStatus(4);
            }
            ;
            patientReservation.setSsc(patient.getSsc());
            GuahaoDoctor guahaoDoctor = GetDoctorInfo(DoctorCode, OrgCode, DeptCode);
            patientReservation.setDoctorPhoto(guahaoDoctor.getPhoto());//照片
            patientReservation.setDoctorJob(guahaoDoctor.getTitle());//职称
            return patientReservation;
        }
        else{
        } else {
            return null;
        }
    }
    @Autowired
    JwSmjkService jwSmjkService;
    /******************************** 基卫内网服务 ************************************************/
    public List<Map<String,Object>> GetDoctorArrangeTenDay(String hospitalId,String hosDeptId,String doctorId) throws Exception {
    public List<Map<String, Object>> GetDoctorArrangeTenDay(String hospitalId, String hosDeptId, String doctorId) throws Exception {
        String strStart = DateUtil.getStringDateShort(); //当前时间;
        String strEnd = DateUtil.getNextDay(strStart,11);         //10天预约
        String strEnd = DateUtil.getNextDay(strStart, 11);         //10天预约
        String response = jwSmjkService.getRegDeptSpeDoctorSectionList(hospitalId,hosDeptId,strStart,strEnd,doctorId);
        String response = jwSmjkService.getRegDeptSpeDoctorSectionList(hospitalId, hosDeptId, strStart, strEnd, doctorId);
        return xmlToList(response);
    }
@ -1049,8 +1031,7 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 转诊预约挂号
     */
    public String CreateOrderByDoctor(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode) throws Exception
    {
    public String CreateOrderByDoctor(String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String arrangeDate, String patient, String patientName, String cardNo, String clinicCard, String patientPhone, String dname, String dcode) throws Exception {
        String re = "";
        Patient p = patientService.findByCode(patient);
@ -1058,17 +1039,16 @@ public class GuahaoXMService implements IGuahaoService {
            throw new Exception("患者信息不存在!");
        }
        Map<String,String> map = objectMapper.readValue(arrangeDate,Map.class);
        if(map.containsKey("sectionType") && map.containsKey("startTime")) {
        Map<String, String> map = objectMapper.readValue(arrangeDate, Map.class);
        if (map.containsKey("sectionType") && map.containsKey("startTime")) {
            String sectionType = map.get("sectionType");
            String startTime = map.get("startTime");
            String endTime = map.get("endTime");
            String response = jwSmjkService.webRegisterByFamily(cardNo,patientName,clinicCard,sectionType,startTime,hospitalId,hosDeptId,hosDeptName,doctorId,doctorName);
            String response = jwSmjkService.webRegisterByFamily(cardNo, patientName, clinicCard, sectionType, startTime, hospitalId, hosDeptId, hosDeptName, doctorId, doctorName);
            re = CreateOrderAfter(response,hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,sectionType,startTime,endTime,patient,patientName,cardNo,clinicCard,patientPhone,dname,dcode);
        }
        else{
            re = CreateOrderAfter(response, hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, sectionType, startTime, endTime, patient, patientName, cardNo, clinicCard, patientPhone, dname, dcode);
        } else {
            throw new Exception("该排班信息错误或者不存在!");
        }

+ 26 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpClientUtil.java

@ -15,6 +15,10 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
public class HttpClientUtil {
@ -99,4 +103,26 @@ public class HttpClientUtil {
		return null;
	}
	public static String postBody(String url,JSONObject params){
		RestTemplate restTemplate = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
		headers.setContentType(type);
		headers.add("Accept", MediaType.APPLICATION_JSON.toString());
		org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
		String ret = restTemplate.postForObject(url, formEntity, String.class);
		return ret;
	}
	public static void putBody(String url,JSONObject params){
		RestTemplate restTemplate = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
		headers.setContentType(type);
		headers.add("Accept", MediaType.APPLICATION_JSON.toString());
		org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
		restTemplate.put(url, formEntity, String.class);
	}
}

+ 4 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java

@ -198,7 +198,6 @@ public class WechatController extends WeixinBaseController {
            return write(200, "验证成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "验证失败");
        }
    }
@ -303,7 +302,10 @@ public class WechatController extends WeixinBaseController {
            password = StringUtils.reverse(password);
            patient.setPassword(MD5.GetMD5Code(password + salt));
            patient.setSsc(ssc);
            patient.setOpenid(openid);
            if(!org.springframework.util.StringUtils.isEmpty(openid)){
                patient.setOpenid(openid);
                patient.setOpenidTime(new Date());
            }
            JSONObject json = patientService.register(idcard, ssc, name, mobile, MD5.GetMD5Code(password + salt)
                    , salt, openid, 3);
            if (json != null) {

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/area/AreaController.java

@ -37,7 +37,6 @@ public class AreaController extends BaseController {
            List<Town> towns = areaService.getCityTowns(city);
            return write(200, "查询成功", "data", towns == null ? new ArrayList<Town>() : towns);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/hospital/HospitalCommonController.java

@ -29,7 +29,6 @@ public class HospitalCommonController extends BaseController {
            List<Hospital> hospitals = hospitalService.getHositalByTownCode(town);
            return write(200, "查询成功", "data", hospitals == null ? new ArrayList<Hospital>() : hospitals);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

+ 9 - 16
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/qrcode/QrCodeController.java

@ -42,7 +42,6 @@ public class QrCodeController extends WeixinBaseController {
                return error(-1, "生成二维码失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "生成二维码失败!");
        }
    }
@ -63,7 +62,6 @@ public class QrCodeController extends WeixinBaseController {
                return error(-1, "生成二维码失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "生成二维码失败!");
        }
    }
@ -84,7 +82,6 @@ public class QrCodeController extends WeixinBaseController {
                return error(-1, "生成二维码失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "生成二维码失败!");
        }
    }
@ -105,7 +102,6 @@ public class QrCodeController extends WeixinBaseController {
                return error(-1, "生成二维码失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "生成二维码失败!");
        }
    }
@ -142,14 +138,14 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
                response.setStatus(404);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
@ -184,7 +180,7 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
@ -235,7 +231,7 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
@ -284,14 +280,14 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
                throw new Exception("医生信息不存在!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            response.setStatus(500);
        }
    }
@ -319,14 +315,13 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
                response.setStatus(500);
            }
        } catch (Exception e) {
            e.printStackTrace();
            response.setStatus(500);
        }
    }
@ -355,14 +350,13 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
                response.setStatus(500);
            }
        } catch (Exception e) {
            e.printStackTrace();
            response.setStatus(500);
        }
    }
@ -391,14 +385,13 @@ public class QrCodeController extends WeixinBaseController {
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
                response.setStatus(500);
            }
        } catch (Exception e) {
            e.printStackTrace();
            response.setStatus(500);
        }
    }

+ 0 - 10
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java

@ -69,7 +69,6 @@ public class ManagerUtilController extends BaseController {
            diseaseService.updateToDisease();
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -85,7 +84,6 @@ public class ManagerUtilController extends BaseController {
        try {
            return write(200, "查询成功", "data", redisTemplate.opsForValue().get("disease:" + patient));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -106,7 +104,6 @@ public class ManagerUtilController extends BaseController {
                return write(200, "任务已存在");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "启动失败");
        }
    }
@ -122,7 +119,6 @@ public class ManagerUtilController extends BaseController {
            workTimeService.consultTimesRemain(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -139,7 +135,6 @@ public class ManagerUtilController extends BaseController {
            statisticsService.peopleNumToRedis();
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -155,7 +150,6 @@ public class ManagerUtilController extends BaseController {
            manageUtilService.signPatientSetGroup();
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -171,7 +165,6 @@ public class ManagerUtilController extends BaseController {
            manageUtilService.setSignTeamAndGroupByPage(page);
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -187,7 +180,6 @@ public class ManagerUtilController extends BaseController {
            manageUtilService.setSignTeamAndGroupById(id);
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -208,7 +200,6 @@ public class ManagerUtilController extends BaseController {
                return write(200, "查询成功","data",ManageUtilService.errorSigns);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -224,7 +215,6 @@ public class ManagerUtilController extends BaseController {
            new Thread(new SignTeamAndGroupRunnable(start,end)).start();
            return write(200,"启动成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "启动失败");
        }
    }

+ 0 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/WlyySerivceController.java

@ -52,7 +52,6 @@ public class WlyySerivceController extends BaseController{
                return write(200,"调用成功","data",jsonString);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"调用失败");
        }
    }
@ -98,7 +97,6 @@ public class WlyySerivceController extends BaseController{
                return write(200,"调用成功","data",jsonString);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"调用失败");
        }
    }
@ -145,7 +143,6 @@ public class WlyySerivceController extends BaseController{
                return write(200,"调用成功","data",jsonString);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"调用失败");
        }
    }
@ -187,7 +184,6 @@ public class WlyySerivceController extends BaseController{
                return write(200,"调用成功","data",jsonString);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"调用失败");
        }
    }

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/verified/VerifiedController.java

@ -69,7 +69,6 @@ public class VerifiedController extends BaseController {
			return write(200, "人脸识别成功!");
		} catch (Exception e) {
			e.printStackTrace();
			return error(-1, e.getMessage());
		}
	}

+ 0 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -269,7 +269,6 @@ public class DoctorController extends BaseController {
            return write(200, "查询成功", "data", hos);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -330,7 +329,6 @@ public class DoctorController extends BaseController {
            JSONArray doctors = doctorInfoService.findWorkingDoctorListByDept(dept, hospital, level, key, page, pagesize);
            return write(200, "查询成功", "data", doctors);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -1435,7 +1433,6 @@ public class DoctorController extends BaseController {
            }
            return write(200, "查询成功!", "doctors", array);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
@ -1481,7 +1478,6 @@ public class DoctorController extends BaseController {
                return error(-1, "更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -1529,7 +1525,6 @@ public class DoctorController extends BaseController {
                return error(-1, "更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -1602,7 +1597,6 @@ public class DoctorController extends BaseController {
        } catch (Exception e) {
            redisTemplate.opsForValue().set("jianguanshifenpei:" + getUID(), "0");
            redisTemplate.expire("jianguanshifenpei:" + getUID(), 10, TimeUnit.MINUTES);
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -1679,7 +1673,6 @@ public class DoctorController extends BaseController {
                return write(-1, "手机号更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "手机号更新失败");
        }
    }
@ -1734,7 +1727,6 @@ public class DoctorController extends BaseController {
            doctorInfoService.updatePassword(newPassword1, newPassword2, oldPassword, doctorCode);
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
@ -1773,7 +1765,6 @@ public class DoctorController extends BaseController {
        try {
            return write(200, "成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

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

@ -15,6 +15,8 @@ import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.MessageType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -164,6 +166,29 @@ public class DoctorConsultController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "list_by_team", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value = "居民咨询列表查询")
    public String listByTeam(@RequestParam @ApiParam(value = "居民Code") String patient,
                             @RequestParam @ApiParam(value = "团队Code") Long teamCode,
                             @RequestParam @ApiParam(value = "第几页") int page,
                             @RequestParam @ApiParam(value = "页大小") int pagesize) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "请输入需查询的居民");
            }
            if (teamCode == null || teamCode < 1) {
                return error(-1, "请输入需查询的居民的团队");
            }
            page = page > 0 ? page - 1 : 0;
            JSONArray jsonArray = consultTeamService.findByPatientAndTeam(patient, teamCode, page, pagesize);
            return write(200, "查询成功", "data", jsonArray);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "查询失败!");
        }
    }
    /**
     * 获取三师家庭咨询
     *

+ 0 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/discussion/DoctorDiscussionGroupController.java

@ -363,7 +363,6 @@ public class DoctorDiscussionGroupController extends BaseController {
                return error(-1, "创建讨论组失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "创建讨论组失败");
        }
    }
@ -401,7 +400,6 @@ public class DoctorDiscussionGroupController extends BaseController {
            return write(200, "查询成功", "data", group);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -561,7 +559,6 @@ public class DoctorDiscussionGroupController extends BaseController {
            return write(200, "添加成员成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加成员失败!");
        }
    }

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/family/DoctorFamilyController.java

@ -58,7 +58,6 @@ public class DoctorFamilyController extends WeixinBaseController {
            return write(200, "查询成功", "list", result.size() > 0 ? new JSONArray(result.values()) : new JSONArray());
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }

+ 326 - 305
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -13,10 +13,7 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
@ -26,313 +23,337 @@ import com.yihu.wlyy.web.BaseController;
/**
 * 医生端:随访接口
 * 
 * @author hzp add 2016-12-07
 *
 * @author hzp add 2016-12-07
 */
@Controller
@RequestMapping(value = "/doctor/followup", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-随访接口")
public class DoctorFollowUpController extends BaseController {
	@Autowired
	private FollowUpService followUpService;
	/*************************************** 随访计划 ****************************************************************************/
	@ApiOperation("获取随访列表")
	@RequestMapping(value = "/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getList(@ApiParam(name="startTime",value="开始时间",defaultValue = "2016-12-07 00:00:00")
							  @RequestParam(value="startTime",required = true) String startTime,
							  @ApiParam(name="endTime",value="结束时间",defaultValue = "2016-12-14 00:00:00")
							  @RequestParam(value="endTime",required = true) String endTime,
						      @ApiParam(name="page",value="第几页",defaultValue = "1")
							  @RequestParam(value="page",required = true) String page,
							  @ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
							  @RequestParam(value="pageSize",required = true) String pageSize) {
		try {
			List<Map<String,String>> result = followUpService.getListByDoctor(getUID(),startTime,endTime,page,pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
			return write(200, "获取随访列表成功!", "data", result);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取随访列表失败!"+e.getMessage());
		}
	}
	@ApiOperation("获取随访列表(创建者)")
	@RequestMapping(value = "/createrList", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getCreaterList(@ApiParam(name="startTime",value="开始时间",defaultValue = "2016-12-07 00:00:00")
						  @RequestParam(value="startTime",required = true) String startTime,
						  @ApiParam(name="endTime",value="结束时间",defaultValue = "2016-12-14 00:00:00")
						  @RequestParam(value="endTime",required = true) String endTime,
						  @ApiParam(name="page",value="第几页",defaultValue = "1")
						  @RequestParam(value="page",required = true) String page,
						  @ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
						  @RequestParam(value="pageSize",required = true) String pageSize) {
		try {
			List<Map<String,String>> result = followUpService.getListByCreater(getUID(),startTime,endTime,page,pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
			return write(200, "获取随访列表成功!", "data", result);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取随访列表失败!"+e.getMessage());
		}
	}
	@ApiOperation("新增随访计划(批量)")
	@RequestMapping(value = "/addFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String addFollowupPlan(@ApiParam(name="patient",value="患者代码",defaultValue = "443a196ef8744536a531260eb26c05d7")
						  @RequestParam(value="patient",required = true) String patient,
						  @ApiParam(name="data",value="随访计划列表json",defaultValue = "[{\"date\":\"2016-12-16 20:00:00\",\"type\":\"10\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"},{\"date\":\"2016-12-17 15:00:00\",\"type\":\"3\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"}]")
						  @RequestParam(value="data",required = true) String data) {
		try {
			followUpService.addFollowupPlan(getUID(),patient,data);
			return write(200, "新增随访计划成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "新增随访计划失败!"+e.getMessage());
		}
	}
	@ApiOperation("编辑随访计划")
	@RequestMapping(value = "/editFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String editFollowupPlan(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
								@RequestParam(value="id",required = true) String id,
								@ApiParam(name="planDate",value="随访计划时间",defaultValue = "2016-12-14 20:00:00")
								@RequestParam(value="planDate",required = true) String planDate,
								@ApiParam(name="followupType",value="随访方式【字典FOLLOWUP_WAY_DICT】",defaultValue = "12")
								@RequestParam(value="followupType",required = true) String followupType) {
		try {
			followUpService.editFollowupPlan(getUID(),id,planDate,followupType);
			return write(200, "编辑随访计划成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "编辑随访计划失败!"+e.getMessage());
		}
	}
	@ApiOperation("开始随访记录")
	@RequestMapping(value = "/startFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String startFollowup(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
								 @RequestParam(value="id",required = true) String id,
								 @ApiParam(name="date",value="随访时间",defaultValue = "2016-12-14 20:00:00")
								 @RequestParam(value="date",required = true) String date,
								 @ApiParam(name="followupType",value="随访方式【字典FOLLOWUP_WAY_DICT】",defaultValue = "12")
								 @RequestParam(value="followupType",required = true) String followupType,
								 @ApiParam(name="followupClass",value="随访类别【1.高血压 2.糖尿病】",defaultValue = "1")
								 @RequestParam(value="followupClass",required = true) String followupClass,
								 @ApiParam(name="followupManagerStatus",value="随访管理状态【字典FOLLOWUP_MANAGER_STATUS】",defaultValue = "1")
								 @RequestParam(value="followupManagerStatus",required = false) String followupManagerStatus) {
		try {
			followUpService.startFollowup(id,date,followupType,followupClass,followupManagerStatus);
			return write(200, "开始随访记录成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "开始随访记录失败!"+e.getMessage());
		}
	}
	@ApiOperation("新增临时随访记录(返回ID)")
	@RequestMapping(value = "/addFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String addFollowup(@ApiParam(name="patient",value="患者代码",defaultValue = "443a196ef8744536a531260eb26c05d7")
								@RequestParam(value="patient",required = true) String patient,
								@ApiParam(name="date",value="下次随访时间",defaultValue = "2016-12-15 20:00:00")
								@RequestParam(value="date",required = true) String date,
								@ApiParam(name="followupType",value="随访方式【字典FOLLOWUP_WAY_DICT】",defaultValue = "12")
								@RequestParam(value="followupType",required = true) String followupType,
								@ApiParam(name="followupClass",value="随访类别【1.高血压 2.糖尿病】",defaultValue = "1")
								@RequestParam(value="followupClass",required = true) String followupClass,
								@ApiParam(name="followupManagerStatus",value="随访管理状态【字典FOLLOWUP_MANAGER_STATUS】",defaultValue = "1")
								@RequestParam(value="followupManagerStatus",required = false) String followupManagerStatus) {
		try {
			String response = followUpService.addFollowup(getUID(),patient,date,followupType,followupClass,followupManagerStatus);
			return write(200, "新增临时随访记录成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "新增临时随访记录失败!"+e.getMessage());
		}
	}
	@ApiOperation("取消随访计划")
	@RequestMapping(value = "/cancelFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String cancelFollowupPlan(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
								      @RequestParam(value="id",required = true) String id)
	{
		try {
			followUpService.cancelFollowupPlan(id);
			return write(200, "取消随访计划成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "取消随访计划失败!"+e.getMessage());
		}
	}
	@ApiOperation("完成随访记录")
	@RequestMapping(value = "/finishFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String finishFollowup(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
									 @RequestParam(value="id",required = true) String id)
	{
		try {
			followUpService.finishFollowup(id);
			return write(200, "完成随访记录成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "完成随访记录失败!"+e.getMessage());
		}
	}
	/*********************************** 随访详情 *******************************************************************/
	@ApiOperation("获取随访信息")
	@RequestMapping(value = "/getFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getFollowup(@ApiParam(name="id",value="随访记录ID",defaultValue = "4")
									 @RequestParam(value="id",required = true) String id)
	{
		try {
			Map<String,String> response = followUpService.getFollowup(id);
			return write(200, "获取随访信息成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取随访信息失败!"+e.getMessage());
		}
	}
	@ApiOperation("获取随访项目列表")
	@RequestMapping(value = "/getFollowupProject", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getFollowupProject(@ApiParam(name="id",value="随访记录ID",defaultValue = "4")
									 @RequestParam(value="id",required = true) String id)
	{
		try {
			List<Map<String,String>> list = followUpService.getFollowupProject(id);
			return write(200, "获取随访项目列表成功!","data",list);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取随访项目列表失败!"+e.getMessage());
		}
	}
	@ApiOperation("获取随访项目数据")
	@RequestMapping(value = "/getFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getFollowupProjectData(@ApiParam(name="id",value="随访记录ID",defaultValue = "4")
									 @RequestParam(value="id",required = true) String id,
									 @ApiParam(name="followupProject",value="随访项目",defaultValue = "2")
									 @RequestParam(value="followupProject",required = true) String followupProject)
	{
		try {
			Map<String,String> response = followUpService.getFollowupProjectData(id,followupProject);
			return write(200, "获取随访项目数据成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取随访项目数据失败!"+e.getMessage());
		}
	}
	@ApiOperation("保存随访项目数据")
	@RequestMapping(value = "/saveFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String saveFollowupProjectData(@ApiParam(name="id",value="随访记录ID",defaultValue = "4")
								   @RequestParam(value="id",required = true) String id,
								   @ApiParam(name="followupProject",value="随访项目",defaultValue = "2")
								   @RequestParam(value="followupProject",required = true) String followupProject,
								   @ApiParam(name="followupProjectData",value="随访项目数据",defaultValue = "{\"WEIGHT\":\"76\",\"WEIGHT_EXP\":\"60\",\"BMI\":\"11\"}")
								   @RequestParam(value="followupProjectData",required = true) String followupProjectData)
	{
		try {
			followUpService.saveFollowupProjectData(id,followupProject,followupProjectData);
			return write(200, "保存随访项目数据成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "保存随访项目数据失败!"+e.getMessage());
		}
	}
	/*********************************** 电话随访 *****************************************************************/
	@ApiOperation("获取电话随访内容")
	@RequestMapping(value = "/getFollowupPhone", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getFollowupPhone(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
									@RequestParam(value="id",required = true) String id) {
		try {
			String response = followUpService.getFollowupPhone(id);
			return write(200, "获取电话随访内容成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取电话随访内容失败!"+e.getMessage());
		}
	}
	@ApiOperation("记录电话随访内容")
	@RequestMapping(value = "/saveFollowupPhone", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String saveFollowupPhone(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
								  @RequestParam(value="id",required = true) String id,
								  @ApiParam(name="content",value="电话随访内容",defaultValue = "")
								  @RequestParam(value="content",required = true) String content) {
		try {
			followUpService.saveFollowupPhone(id,content);
			return write(200, "记录电话随访内容成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "记录电话随访内容失败!"+e.getMessage());
		}
	}
	/*************************************** 上次随访 ********************************************/
	@ApiOperation("获取上次随访")
	@RequestMapping(value = "/getLastFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getLastFollowup(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
								   @RequestParam(value="patient",required = true) String patient,
								   @ApiParam(name="followClass",value="随访类别",defaultValue = "1")
								   @RequestParam(value="followClass",required = true) String followClass)
	{
		try {
			Map<String,String> response = followUpService.getLastFollowup(getUID(),patient,followClass);
			return write(200, "获取上次随访成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取上次随访失败!"+e.getMessage());
		}
	}
	@ApiOperation("复制上次随访数据")
	@RequestMapping(value = "/copyFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String copyFollowup(@ApiParam(name="id",value="本地随访ID",defaultValue = "")
								  @RequestParam(value="id",required = true) Long id,
								  @ApiParam(name="fromId",value="拷贝随访记录ID",defaultValue = "")
								  @RequestParam(value="fromId",required = true) Long fromId)
	{
		try {
			followUpService.copyFollowup(id,fromId);
			return write(200, "复制上次随访成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "复制上次随访失败!"+e.getMessage());
		}
	}
	/*************************************** 发送随访计划消息 ********************************************/
	@ApiOperation("发送随访计划消息")
	@RequestMapping(value = "/sendMessage", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String sendMessage(@ApiParam(name="date",value="日期",defaultValue = "2017-01-05")
								  @RequestParam(value="date",required = true) String date)
	{
		try {
			followUpService.sendMessage(date);
			return write(200, "发送随访计划消息成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "发送随访计划消息失败!"+e.getMessage());
		}
	}
    @Autowired
    private FollowUpService followUpService;
    /*************************************** 随访计划 ****************************************************************************/
    @ApiOperation("获取随访列表")
    @RequestMapping(value = "/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getList(@ApiParam(name = "startTime", value = "开始时间", defaultValue = "2016-12-07 00:00:00")
                          @RequestParam(value = "startTime", required = true) String startTime,
                          @ApiParam(name = "endTime", value = "结束时间", defaultValue = "2016-12-14 00:00:00")
                          @RequestParam(value = "endTime", required = true) String endTime,
                          @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                          @RequestParam(value = "page", required = true) String page,
                          @ApiParam(name = "pageSize", value = "每页几行", defaultValue = "10")
                          @RequestParam(value = "pageSize", required = true) String pageSize) {
        try {
            List<Map<String, String>> result = followUpService.getListByDoctor(getUID(), startTime, endTime, page, pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
            return write(200, "获取随访列表成功!", "data", result);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访列表失败!" + e.getMessage());
        }
    }
    /**
     * 查询居民随访列表
     *
     * @param patient
     * @param teamCode
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "/list_by_team")
    @ResponseBody
    @ApiOperation(value = "查询居民随访列表")
    public String getListByPatientAndTeam(@RequestParam @ApiParam(value = "居民Code") String patient,
                                          @RequestParam @ApiParam(value = "团队code") Long teamCode,
                                          @RequestParam @ApiParam(value = "第几页") int page,
                                          @RequestParam @ApiParam(value = "页大小") int pagesize) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "请输入需查询的居民");
            }
            if (teamCode == null || teamCode < 1) {
                return error(-1, "请输入需查询的居民的团队");
            }
            page = page > 0 ? page - 1 : 0;
            JSONArray result = followUpService.getListByPatientAndTeam(patient, teamCode, page, pagesize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @ApiOperation("获取随访列表(创建者)")
    @RequestMapping(value = "/createrList", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getCreaterList(@ApiParam(name = "startTime", value = "开始时间", defaultValue = "2016-12-07 00:00:00")
                                 @RequestParam(value = "startTime", required = true) String startTime,
                                 @ApiParam(name = "endTime", value = "结束时间", defaultValue = "2016-12-14 00:00:00")
                                 @RequestParam(value = "endTime", required = true) String endTime,
                                 @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                                 @RequestParam(value = "page", required = true) String page,
                                 @ApiParam(name = "pageSize", value = "每页几行", defaultValue = "10")
                                 @RequestParam(value = "pageSize", required = true) String pageSize) {
        try {
            List<Map<String, String>> result = followUpService.getListByCreater(getUID(), startTime, endTime, page, pageSize);     //"64de9952-5b15-11e6-8344-fa163e8aee56"
            return write(200, "获取随访列表成功!", "data", result);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访列表失败!" + e.getMessage());
        }
    }
    @ApiOperation("新增随访计划(批量)")
    @RequestMapping(value = "/addFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String addFollowupPlan(@ApiParam(name = "patient", value = "患者代码", defaultValue = "443a196ef8744536a531260eb26c05d7")
                                  @RequestParam(value = "patient", required = true) String patient,
                                  @ApiParam(name = "data", value = "随访计划列表json", defaultValue = "[{\"date\":\"2016-12-16 20:00:00\",\"type\":\"10\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"},{\"date\":\"2016-12-17 15:00:00\",\"type\":\"3\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"}]")
                                  @RequestParam(value = "data", required = true) String data) {
        try {
            followUpService.addFollowupPlan(getUID(), patient, data);
            return write(200, "新增随访计划成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "新增随访计划失败!" + e.getMessage());
        }
    }
    @ApiOperation("编辑随访计划")
    @RequestMapping(value = "/editFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String editFollowupPlan(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                   @RequestParam(value = "id", required = true) String id,
                                   @ApiParam(name = "planDate", value = "随访计划时间", defaultValue = "2016-12-14 20:00:00")
                                   @RequestParam(value = "planDate", required = true) String planDate,
                                   @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                                   @RequestParam(value = "followupType", required = true) String followupType) {
        try {
            followUpService.editFollowupPlan(getUID(), id, planDate, followupType);
            return write(200, "编辑随访计划成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "编辑随访计划失败!" + e.getMessage());
        }
    }
    @ApiOperation("开始随访记录")
    @RequestMapping(value = "/startFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String startFollowup(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                @RequestParam(value = "id", required = true) String id,
                                @ApiParam(name = "date", value = "随访时间", defaultValue = "2016-12-14 20:00:00")
                                @RequestParam(value = "date", required = true) String date,
                                @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                                @RequestParam(value = "followupType", required = true) String followupType,
                                @ApiParam(name = "followupClass", value = "随访类别【1.高血压 2.糖尿病】", defaultValue = "1")
                                @RequestParam(value = "followupClass", required = true) String followupClass,
                                @ApiParam(name = "followupManagerStatus", value = "随访管理状态【字典FOLLOWUP_MANAGER_STATUS】", defaultValue = "1")
                                @RequestParam(value = "followupManagerStatus", required = false) String followupManagerStatus) {
        try {
            followUpService.startFollowup(id, date, followupType, followupClass, followupManagerStatus);
            return write(200, "开始随访记录成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "开始随访记录失败!" + e.getMessage());
        }
    }
    @ApiOperation("新增临时随访记录(返回ID)")
    @RequestMapping(value = "/addFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String addFollowup(@ApiParam(name = "patient", value = "患者代码", defaultValue = "443a196ef8744536a531260eb26c05d7")
                              @RequestParam(value = "patient", required = true) String patient,
                              @ApiParam(name = "date", value = "下次随访时间", defaultValue = "2016-12-15 20:00:00")
                              @RequestParam(value = "date", required = true) String date,
                              @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                              @RequestParam(value = "followupType", required = true) String followupType,
                              @ApiParam(name = "followupClass", value = "随访类别【1.高血压 2.糖尿病】", defaultValue = "1")
                              @RequestParam(value = "followupClass", required = true) String followupClass,
                              @ApiParam(name = "followupManagerStatus", value = "随访管理状态【字典FOLLOWUP_MANAGER_STATUS】", defaultValue = "1")
                              @RequestParam(value = "followupManagerStatus", required = false) String followupManagerStatus) {
        try {
            String response = followUpService.addFollowup(getUID(), patient, date, followupType, followupClass, followupManagerStatus);
            return write(200, "新增临时随访记录成功!", "data", response);
        } catch (Exception e) {
            return invalidUserException(e, -1, "新增临时随访记录失败!" + e.getMessage());
        }
    }
    @ApiOperation("取消随访计划")
    @RequestMapping(value = "/cancelFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String cancelFollowupPlan(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                     @RequestParam(value = "id", required = true) String id) {
        try {
            followUpService.cancelFollowupPlan(id);
            return write(200, "取消随访计划成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "取消随访计划失败!" + e.getMessage());
        }
    }
    @ApiOperation("完成随访记录")
    @RequestMapping(value = "/finishFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String finishFollowup(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                 @RequestParam(value = "id", required = true) String id) {
        try {
            followUpService.finishFollowup(id);
            return write(200, "完成随访记录成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "完成随访记录失败!" + e.getMessage());
        }
    }
    /*********************************** 随访详情 *******************************************************************/
    @ApiOperation("获取随访信息")
    @RequestMapping(value = "/getFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getFollowup(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                              @RequestParam(value = "id", required = true) String id) {
        try {
            Map<String, String> response = followUpService.getFollowup(id);
            return write(200, "获取随访信息成功!", "data", response);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访信息失败!" + e.getMessage());
        }
    }
    @ApiOperation("获取随访项目列表")
    @RequestMapping(value = "/getFollowupProject", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getFollowupProject(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                                     @RequestParam(value = "id", required = true) String id) {
        try {
            List<Map<String, String>> list = followUpService.getFollowupProject(id);
            return write(200, "获取随访项目列表成功!", "data", list);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访项目列表失败!" + e.getMessage());
        }
    }
    @ApiOperation("获取随访项目数据")
    @RequestMapping(value = "/getFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getFollowupProjectData(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                                         @RequestParam(value = "id", required = true) String id,
                                         @ApiParam(name = "followupProject", value = "随访项目", defaultValue = "2")
                                         @RequestParam(value = "followupProject", required = true) String followupProject) {
        try {
            Map<String, String> response = followUpService.getFollowupProjectData(id, followupProject);
            return write(200, "获取随访项目数据成功!", "data", response);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取随访项目数据失败!" + e.getMessage());
        }
    }
    @ApiOperation("保存随访项目数据")
    @RequestMapping(value = "/saveFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String saveFollowupProjectData(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                                          @RequestParam(value = "id", required = true) String id,
                                          @ApiParam(name = "followupProject", value = "随访项目", defaultValue = "2")
                                          @RequestParam(value = "followupProject", required = true) String followupProject,
                                          @ApiParam(name = "followupProjectData", value = "随访项目数据", defaultValue = "{\"WEIGHT\":\"76\",\"WEIGHT_EXP\":\"60\",\"BMI\":\"11\"}")
                                          @RequestParam(value = "followupProjectData", required = true) String followupProjectData) {
        try {
            followUpService.saveFollowupProjectData(id, followupProject, followupProjectData);
            return write(200, "保存随访项目数据成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "保存随访项目数据失败!" + e.getMessage());
        }
    }
    /*********************************** 电话随访 *****************************************************************/
    @ApiOperation("获取电话随访内容")
    @RequestMapping(value = "/getFollowupPhone", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getFollowupPhone(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                   @RequestParam(value = "id", required = true) String id) {
        try {
            String response = followUpService.getFollowupPhone(id);
            return write(200, "获取电话随访内容成功!", "data", response);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取电话随访内容失败!" + e.getMessage());
        }
    }
    @ApiOperation("记录电话随访内容")
    @RequestMapping(value = "/saveFollowupPhone", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String saveFollowupPhone(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                    @RequestParam(value = "id", required = true) String id,
                                    @ApiParam(name = "content", value = "电话随访内容", defaultValue = "")
                                    @RequestParam(value = "content", required = true) String content) {
        try {
            followUpService.saveFollowupPhone(id, content);
            return write(200, "记录电话随访内容成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "记录电话随访内容失败!" + e.getMessage());
        }
    }
    /*************************************** 上次随访 ********************************************/
    @ApiOperation("获取上次随访")
    @RequestMapping(value = "/getLastFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getLastFollowup(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20161008001")
                                  @RequestParam(value = "patient", required = true) String patient,
                                  @ApiParam(name = "followClass", value = "随访类别", defaultValue = "1")
                                  @RequestParam(value = "followClass", required = true) String followClass) {
        try {
            Map<String, String> response = followUpService.getLastFollowup(getUID(), patient, followClass);
            return write(200, "获取上次随访成功!", "data", response);
        } catch (Exception e) {
            return invalidUserException(e, -1, "获取上次随访失败!" + e.getMessage());
        }
    }
    @ApiOperation("复制上次随访数据")
    @RequestMapping(value = "/copyFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String copyFollowup(@ApiParam(name = "id", value = "本地随访ID", defaultValue = "")
                               @RequestParam(value = "id", required = true) Long id,
                               @ApiParam(name = "fromId", value = "拷贝随访记录ID", defaultValue = "")
                               @RequestParam(value = "fromId", required = true) Long fromId) {
        try {
            followUpService.copyFollowup(id, fromId);
            return write(200, "复制上次随访成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "复制上次随访失败!" + e.getMessage());
        }
    }
    /*************************************** 发送随访计划消息 ********************************************/
    @ApiOperation("发送随访计划消息")
    @RequestMapping(value = "/sendMessage", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String sendMessage(@ApiParam(name = "date", value = "日期", defaultValue = "2017-01-05")
                              @RequestParam(value = "date", required = true) String date) {
        try {
            followUpService.sendMessage(date);
            return write(200, "发送随访计划消息成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "发送随访计划消息失败!" + e.getMessage());
        }
    }
}

+ 444 - 364
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java

@ -4,6 +4,8 @@ import java.util.*;
import com.yihu.wlyy.entity.education.*;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.health.*;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.common.account.PatientService;
@ -11,6 +13,8 @@ import com.yihu.wlyy.util.SendP2PUtil;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.doctor.message.DoctorMessageController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.htmlparser.Parser;
import org.htmlparser.beans.StringBean;
@ -36,375 +40,451 @@ import com.yihu.wlyy.web.BaseController;
/**
 * 医生端:健康教育控制类
 * @author George
 *
 * @author George
 */
@Controller
@RequestMapping(value = "/doctor/health/edu", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "健康教育")
public class DoctorHealthEduArticleController extends WeixinBaseController {
	@Autowired
	private HealthEduArticleService healthEduArticleService;
	@Autowired
	private DoctorService doctorService;
	@Autowired
	private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
	@Autowired
	private SignPatientLabelInfoService signPatientLabelInfoService;
	@Autowired
	private HealthEduArticlePatientService healthEduArticlePatientService;
	@Autowired
	private HealthEduArticleDoctorService healthEduArticleDoctorService;
	@Autowired
	private HealthEduArticleLabelService healthEduArticleLabelService;
	@Autowired
	private PatientService patientService;
	/**
	 * 查询
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	@RequestMapping(value = "list")
	@ResponseBody
	public String list(@RequestParam(value = "page",required = true)int page, @RequestParam(value = "pagesize",required = true)int pagesize,@RequestParam(value = "filter",required = false)String filter,@RequestParam(value = "patient",required = false)String patient) {
		try {
			List<Map<String, Object>> list = healthEduArticleService.findAll(page, pagesize,filter,getUID(),patient);
			JSONArray jsonArray = new JSONArray();
			if (list != null) {
				for (Map<String, Object> map : list) {
					JSONObject json = new JSONObject();
					json.put("id", map.get("id"));
					// 文章标识
					json.put("code", map.get("code"));
					// 文章标题
					json.put("title", map.get("title"));
					// 文章查看URL
					json.put("url", map.get("url"));
					// 文章简介
					json.put("content", parsrHtml(map.get("content").toString()));
					// 添加日期
					json.put("czrq", DateUtil.dateToStrLong((Date)map.get("czrq")));
					json.put("keyword", map.get("keyword")==null?"":map.get("keyword"));
					json.put("send", map.get("send"));
					//阅读量
					json.put("readAmount", map.get("readAmount"));
					//收藏量
					json.put("collectionAmount", map.get("collectionAmount"));
					//转发量
					json.put("repeatAmount", map.get("repeatAmount"));
					json.put("collection",map.get("collection"));
					jsonArray.put(json);
				}
			}
			return write(200, "查询成功", "list", jsonArray);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 查询医生收藏列表
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	@RequestMapping(value = "listDoctor")
	@ResponseBody
	public String listDoctor(@RequestParam(value = "page",required = true)int page, @RequestParam(value = "pagesize",required = true)int pagesize,@RequestParam(value = "filter",required = false)String filter,@RequestParam(value = "patient",required = false)String patient) {
		try {
			List<Map<String, Object>> list = healthEduArticleDoctorService.list(page, pagesize,filter,getUID(),patient);
			JSONArray jsonArray = new JSONArray();
			for(Map<String, Object> map:list){
				JSONObject json = new JSONObject();
				json.put("id", map.get("id"));
				// 文章标识
				json.put("code", map.get("article"));
				// 文章标题
				json.put("title", map.get("title"));
				// 文章查看URL
				json.put("url", map.get("url"));
				// 文章简介
				json.put("content", parsrHtml(map.get("content").toString()));
				// 添加日期
				json.put("czrq", DateUtil.dateToStrLong((Date)map.get("czrq")));
				json.put("keyword", map.get("keyword"));
				json.put("send", map.get("send"));
				//阅读量
				json.put("readAmount", map.get("readAmount"));
				//收藏量
				json.put("collectionAmount", map.get("collectionAmount"));
				//转发量
				json.put("repeatAmount", map.get("repeatAmount"));
				//是否收藏(医生收藏的列表肯定是收藏的无需额外校验)
				json.put("collection",1);
				jsonArray.put(json);
			}
			return write(200, "查询成功", "list", jsonArray);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 查询标签列表
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	@RequestMapping(value = "listLabel")
	@ResponseBody
	public String listLabel(@RequestParam(value = "page",required = true)int page, @RequestParam(value = "pagesize",required = true)int pagesize,@RequestParam(value = "type",required = false,defaultValue = "0")int type) {
		try {
			Page<HealthEduArticleLabel> list = healthEduArticleLabelService.findAll(page,pagesize,type,getUID());
			return write(200, "查询成功", "list", list);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 查询文章列表
	 * @param code 数据文章唯一标示code
	 * @return 列表
	 */
	@RequestMapping(value = "article")
	@ResponseBody
	public String article(@RequestParam(value = "code",required = true) String code) {
		try {
			//获取单条文章记录
			HealthEduArticle healthEduArticle = healthEduArticleService.findArticleByCode(code);
			int isRead  = healthEduArticleOpHistoryService.countByUserStatus(getUID(), HealthEduArticleOpHistory.READ_STATUS);
			//插入文章读取状态第一次阅读记录浏览数量
			if(isRead==0){
				//更新浏览量
				healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.READ_STATUS,healthEduArticle.getCode(),healthEduArticle.getTitle(),getUID());
			}
			JSONObject json = new JSONObject();
			json.put("id", healthEduArticle.getId());
			// 文章标识
			json.put("code", healthEduArticle.getCode());
			// 文章标题
			json.put("title", healthEduArticle.getTitle());
			json.put("url", healthEduArticle.getUrl()==null?"":healthEduArticle.getUrl());
			// 文章内容
			json.put("content", healthEduArticle.getContent());
			// 添加日期
			json.put("czrq", DateUtil.dateToStrLong(healthEduArticle.getCzrq()));
			int readAmount = healthEduArticleOpHistoryService.countReadAmount(code);
			json.put("readAmount",readAmount);
			HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(healthEduArticle.getCode(), getUID());
			if(healthEduArticleDoctor==null){
				json.put("collection",0);
			}else{
				json.put("collection",1);
			}
			return write(200, "查询成功", "data", json);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 发送文章给患者
	 * @param code 文章标识,多个以逗号分隔
	 * @param patient 患者标识,多个以逗号分隔
	 * @param  group 所选群组,多个用逗号分隔
	 * @return
	 */
	@RequestMapping(value = "send")
	@ResponseBody
	public String send(@RequestParam(value = "code")String code,
					   @RequestParam(value = "patient",required = false)String patient,
					   @RequestParam(value = "group",required = false,defaultValue = "")String group,
					   @RequestParam(value = "labelType",required = false)String labelType,
					   @RequestParam(value = "teamCode",required = false)long teamCode) {
		try {
			List<HealthEduArticlePatient> list = new ArrayList<HealthEduArticlePatient>();
			if (StringUtils.isEmpty(code)) {
				return error(-1, "请至少选择一篇文章!");
			}
			if (StringUtils.isEmpty(patient)&&StringUtils.isEmpty(group)) {
				return error(-1, "请至少选择一个患者!");
			}
			String[] articles = code.split(",");
			String[] patients = patient.split(",");
			String[] groups = group.split(",");
			if (articles.length == 0) {
				return error(-1, "请至少选择一篇文章!");
			}
			if (patients.length == 0&&groups.length==0) {
				return error(-1, "请至少选择一个患者!");
			}
			Map<String, HealthEduArticle> maps = new HashMap<String, HealthEduArticle>();
			Set<String> patientSet = new HashSet<>();
			if(StringUtils.isNotBlank(group)&&groups.length>0){
				//递归患者数据
				for(String g :groups){
					getPatientByGroup(g,labelType,teamCode,patientSet,0,100);
				}
			}
			//去重操作
			for (String p : patients) {
				if(StringUtils.isNotBlank(p)){
					patientSet.add(p);
				}
			}
			if(patientSet.size()==0){
				return error(-1, "请至少选择一个患者!");
			}
			// 查询医生信息
			Doctor doctor = doctorService.findDoctorByCode(getUID());
			String msgHead =  doctor.getName()+"医生给您发来了一篇患教文章";
			String endMsg = "为了您的健康,"+doctor.getName()+"医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
			JSONArray messages = new JSONArray();
			for (String p : patientSet) {
				Patient patientTemp = patientService.findByCode(p);
				for (String a : articles) {
					// 查询文章信息
					HealthEduArticle temp = maps.get(a);
					if (temp == null) {
						temp = healthEduArticleService.findArticleByCode(a);
						// 添加到缓存
						maps.put(a, temp);
					}
					HealthEduArticlePatient heap = new HealthEduArticlePatient();
					// 设置文章标识
					heap.setArticle(a);
					// 设置文章简介
					heap.setContent(temp.getContent());
					// 设置文章标题
					heap.setTitle(temp.getTitle());
					// 设置文章查看URL
					heap.setUrl(temp.getUrl());
					// 设置发送时间
					heap.setCzrq(new Date());
					// 设置医生标识
					heap.setDoctor(doctor.getCode());
					// 设置医生姓名
					heap.setDoctorName(doctor.getName());
					// 设置患者标识
					heap.setPatient(p);
					// 设置为示读
					heap.setRead(1);
					list.add(heap);
					SendP2PUtil.sendP2Pmsg(doctor.getCode(), p, "4", "{\"title\":\"" + temp.getTitle() + "\",\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}");
					if (StringUtils.isNotEmpty(patientTemp.getOpenid())) {
						// 推送消息给微信端
						JSONObject json = new JSONObject();
						json.put("first", patientTemp.getName() + ",您好!\n" + msgHead);
						json.put("toUser",p);
						json.put("article",temp.getCode()+"");
						json.put("title",temp.getTitle());
						json.put("doctorName",doctor.getName());
						json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
						json.put("remark", endMsg);
						PushMsgTask.getInstance().putWxMsg(getAccessToken(), 9, patientTemp.getOpenid(), patientTemp.getName(), json);
					}
				}
			}
			// 保存到数据库
			int row = healthEduArticleService.send(list);
			if (row <= 0) {
				return error(-1, "发送失败!");
			} else {
				// 推送消息给患者
				PushMsgTask.getInstance().put(messages);
				return success("发送成功!");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "发送失败!");
		}
	}
	private void getPatientByGroup(String labelCode, String labelType, Long teamCode,Set<String> patientSet,int page,int pagesize) throws Exception{
		JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize);
		for(Object o : result){
			JSONObject json  = (JSONObject)o;
			String patient  = (String)json.get("code");
			patientSet.add(patient);
		}
		if(result.length()==100){
			getPatientByGroup(labelCode,labelType,teamCode,patientSet,page+1,pagesize);
		}
	}
	/**
	 * 文章收藏
	 * @param article 文章CODE
	 * @return
	 */
	@RequestMapping(value = "collectionArticle")
	@ResponseBody
	public String collectionArticle(@RequestParam(value = "article",required = true)String article){
		HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(article,getUID());
		if(healthEduArticleDoctor!=null){
			return error(-1, "收藏失败,该文章已经收藏!");
		}
		HealthEduArticle healthEduArticle =	healthEduArticleService.findArticleByCode(article);
		healthEduArticleDoctor = new HealthEduArticleDoctor();
		try{
			BeanUtils.copyProperties(healthEduArticle,healthEduArticleDoctor);
			healthEduArticleDoctor.setDoctor(getUID());
			healthEduArticleDoctor.setArticle(healthEduArticle.getCode());
			healthEduArticleDoctorService.save(healthEduArticleDoctor);
			//更新收藏量
			healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.COLLECTION_STATUS,healthEduArticle.getCode(),healthEduArticle.getTitle(),getUID());
			return success("收藏成功!");
		}catch (Exception e){
			error(e);
			return error(-1, "收藏失败!");
		}
	}
	/**
	 * 文章收藏
	 * @param article 文章CODE
	 * @return
	 */
	@RequestMapping(value = "uncollectionArticle")
	@ResponseBody
	public String uncollectionArticle(@RequestParam(value = "article",required = true)String article){
		try{
			healthEduArticleDoctorService.delete(article,getUID());
			return success("取消收藏成功!");
		}catch (Exception e){
			error(e);
			return error(-1, "取消收藏失败!");
		}
	}
	private String parsrHtml(String html) {
		html =("<span>"+html+"</span>");//拼接一个HTML标签,防止纯文字字符串转换在linux下面出现的异常。
		Parser parser = null;
		try{
			parser = new Parser(html);
			TextExtractingVisitor visitor = new TextExtractingVisitor();
			parser.visitAllNodesWith(visitor);
			return StringUtils.isNotBlank(visitor.getExtractedText())?visitor.getExtractedText():"内容为图集,请点击查看";
		}catch (ParserException e){
			return html;//纯文本内容会转换失败,直接返回文本内容
		}
	}
	public static void main(String arg[]){
		System.out.println(MessageType.MESSAGE_TYPE_PATIENT_HEALTH_EDU.P_HE_01.name());
	}
    @Autowired
    private HealthEduArticleService healthEduArticleService;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
    @Autowired
    private SignPatientLabelInfoService signPatientLabelInfoService;
    @Autowired
    private HealthEduArticlePatientService healthEduArticlePatientService;
    @Autowired
    private HealthEduArticleDoctorService healthEduArticleDoctorService;
    @Autowired
    private HealthEduArticleLabelService healthEduArticleLabelService;
    @Autowired
    private PatientService patientService;
    @Autowired
    SignFamilyDao signFamilyDao;
    /**
     * 查询
     *
     * @param pagesize 分页大小
     * @return 列表
     */
    @RequestMapping(value = "list")
    @ResponseBody
    public String list(@RequestParam(value = "page", required = true) int page, @RequestParam(value = "pagesize", required = true) int pagesize, @RequestParam(value = "filter", required = false) String filter, @RequestParam(value = "patient", required = false) String patient) {
        try {
            List<Map<String, Object>> list = healthEduArticleService.findAll(page, pagesize, filter, getUID(), patient);
            JSONArray jsonArray = new JSONArray();
            if (list != null) {
                for (Map<String, Object> map : list) {
                    JSONObject json = new JSONObject();
                    json.put("id", map.get("id"));
                    // 文章标识
                    json.put("code", map.get("code"));
                    // 文章标题
                    json.put("title", map.get("title"));
                    // 文章查看URL
                    json.put("url", map.get("url"));
                    // 文章简介
                    json.put("content", parsrHtml(map.get("content").toString()));
                    // 添加日期
                    json.put("czrq", DateUtil.dateToStrLong((Date) map.get("czrq")));
                    json.put("keyword", map.get("keyword") == null ? "" : map.get("keyword"));
                    json.put("send", map.get("send"));
                    //阅读量
                    json.put("readAmount", map.get("readAmount"));
                    //收藏量
                    json.put("collectionAmount", map.get("collectionAmount"));
                    //转发量
                    json.put("repeatAmount", map.get("repeatAmount"));
                    json.put("collection", map.get("collection"));
                    jsonArray.put(json);
                }
            }
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    /**
     * 查询发送给居民的文章列表
     *
     * @param pagesize 分页大小
     * @return 列表
     */
    @RequestMapping(value = "list_by_team", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value = "查询发送给居民的文章列表")
    public String listByTeam(@RequestParam @ApiParam(value = "第几页") int page,
                             @RequestParam @ApiParam(value = "页大小") int pagesize,
                             @RequestParam @ApiParam(value = "居民code") String patient,
                             @RequestParam @ApiParam(value = "团队code") Long teamCode) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "请输入需查询的居民");
            }
            if (teamCode == null || teamCode < 1) {
                return error(-1, "请输入需查询的居民的团队");
            }
            page = page > 0 ? page - 1 : 0;
            List<Map<String, Object>> list = healthEduArticleService.findByPatientAndTeam(patient, teamCode, page, pagesize);
            JSONArray jsonArray = new JSONArray();
            if (list != null) {
                for (Map<String, Object> map : list) {
                    JSONObject json = new JSONObject();
                    // 文章标识
                    json.put("doctorCode", map.get("code"));
                    // 文章标识
                    json.put("doctorName", map.get("name"));
                    // 文章标识
                    json.put("doctorPhoto", map.get("photo"));
                    // 文章标识
                    json.put("code", map.get("article"));
                    // 文章标题
                    json.put("title", map.get("title"));
                    // 文章查看URL
                    json.put("url", map.get("url"));
                    // 文章简介
                    json.put("content", parsrHtml(map.get("content").toString()));
                    // 发送日期
                    json.put("czrq", DateUtil.dateToStrLong((Date) map.get("czrq")));
                    // 发送团队
                    json.put("adminTeamCode", map.get("admin_team_code"));
                    jsonArray.put(json);
                }
            }
            return write(200, "查询成功", "data", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    /**
     * 查询医生收藏列表
     *
     * @param pagesize 分页大小
     * @return 列表
     */
    @RequestMapping(value = "listDoctor")
    @ResponseBody
    public String listDoctor(@RequestParam(value = "page", required = true) int page, @RequestParam(value = "pagesize", required = true) int pagesize, @RequestParam(value = "filter", required = false) String filter, @RequestParam(value = "patient", required = false) String patient) {
        try {
            List<Map<String, Object>> list = healthEduArticleDoctorService.list(page, pagesize, filter, getUID(), patient);
            JSONArray jsonArray = new JSONArray();
            for (Map<String, Object> map : list) {
                JSONObject json = new JSONObject();
                json.put("id", map.get("id"));
                // 文章标识
                json.put("code", map.get("article"));
                // 文章标题
                json.put("title", map.get("title"));
                // 文章查看URL
                json.put("url", map.get("url"));
                // 文章简介
                json.put("content", parsrHtml(map.get("content").toString()));
                // 添加日期
                json.put("czrq", DateUtil.dateToStrLong((Date) map.get("czrq")));
                json.put("keyword", map.get("keyword"));
                json.put("send", map.get("send"));
                //阅读量
                json.put("readAmount", map.get("readAmount"));
                //收藏量
                json.put("collectionAmount", map.get("collectionAmount"));
                //转发量
                json.put("repeatAmount", map.get("repeatAmount"));
                //是否收藏(医生收藏的列表肯定是收藏的无需额外校验)
                json.put("collection", 1);
                jsonArray.put(json);
            }
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    /**
     * 查询标签列表
     *
     * @param pagesize 分页大小
     * @return 列表
     */
    @RequestMapping(value = "listLabel")
    @ResponseBody
    public String listLabel(@RequestParam(value = "page", required = true) int page, @RequestParam(value = "pagesize", required = true) int pagesize, @RequestParam(value = "type", required = false, defaultValue = "0") int type) {
        try {
            Page<HealthEduArticleLabel> list = healthEduArticleLabelService.findAll(page, pagesize, type, getUID());
            return write(200, "查询成功", "list", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    /**
     * 查询文章列表
     *
     * @param code 数据文章唯一标示code
     * @return 列表
     */
    @RequestMapping(value = "article")
    @ResponseBody
    public String article(@RequestParam(value = "code", required = true) String code) {
        try {
            //获取单条文章记录
            HealthEduArticle healthEduArticle = healthEduArticleService.findArticleByCode(code);
            int isRead = healthEduArticleOpHistoryService.countByUserStatus(getUID(), HealthEduArticleOpHistory.READ_STATUS);
            //插入文章读取状态第一次阅读记录浏览数量
            if (isRead == 0) {
                //更新浏览量
                healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.READ_STATUS, healthEduArticle.getCode(), healthEduArticle.getTitle(), getUID());
            }
            JSONObject json = new JSONObject();
            json.put("id", healthEduArticle.getId());
            // 文章标识
            json.put("code", healthEduArticle.getCode());
            // 文章标题
            json.put("title", healthEduArticle.getTitle());
            json.put("url", healthEduArticle.getUrl() == null ? "" : healthEduArticle.getUrl());
            // 文章内容
            json.put("content", healthEduArticle.getContent());
            // 添加日期
            json.put("czrq", DateUtil.dateToStrLong(healthEduArticle.getCzrq()));
            int readAmount = healthEduArticleOpHistoryService.countReadAmount(code);
            json.put("readAmount", readAmount);
            HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(healthEduArticle.getCode(), getUID());
            if (healthEduArticleDoctor == null) {
                json.put("collection", 0);
            } else {
                json.put("collection", 1);
            }
            return write(200, "查询成功", "data", json);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    /**
     * 发送文章给患者
     *
     * @param code    文章标识,多个以逗号分隔
     * @param patient 患者标识,多个以逗号分隔
     * @param group   所选群组,多个用逗号分隔
     * @return
     */
    @RequestMapping(value = "send")
    @ResponseBody
    public String send(@RequestParam(value = "code") String code,
                       @RequestParam(value = "patient", required = false) String patient,
                       @RequestParam(value = "group", required = false, defaultValue = "") String group,
                       @RequestParam(value = "labelType", required = false) String labelType,
                       @RequestParam(value = "teamCode", required = false) long teamCode) {
        try {
            List<HealthEduArticlePatient> list = new ArrayList<HealthEduArticlePatient>();
            if (StringUtils.isEmpty(code)) {
                return error(-1, "请至少选择一篇文章!");
            }
            if (StringUtils.isEmpty(patient) && StringUtils.isEmpty(group)) {
                return error(-1, "请至少选择一个患者!");
            }
            String[] articles = code.split(",");
            String[] patients = patient.split(",");
            String[] groups = group.split(",");
            if (articles.length == 0) {
                return error(-1, "请至少选择一篇文章!");
            }
            if (patients.length == 0 && groups.length == 0) {
                return error(-1, "请至少选择一个患者!");
            }
            Map<String, HealthEduArticle> maps = new HashMap<String, HealthEduArticle>();
            Set<String> patientSet = new HashSet<>();
            if (StringUtils.isNotBlank(group) && groups.length > 0) {
                //递归患者数据
                for (String g : groups) {
                    getPatientByGroup(g, labelType, teamCode, patientSet, 0, 100);
                }
            }
            //去重操作
            for (String p : patients) {
                if (StringUtils.isNotBlank(p)) {
                    patientSet.add(p);
                }
            }
            if (patientSet.size() == 0) {
                return error(-1, "请至少选择一个患者!");
            }
            // 查询医生信息
            Doctor doctor = doctorService.findDoctorByCode(getUID());
            String msgHead = doctor.getName() + "医生给您发来了一篇患教文章";
            String endMsg = "为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
            JSONArray messages = new JSONArray();
            for (String p : patientSet) {
                Patient patientTemp = patientService.findByCode(p);
                SignFamily signFamily = signFamilyDao.findByjiatingPatient(p);
                if(signFamily == null){
                    throw new Exception("can not find patient's family sign info");
                }
                for (String a : articles) {
                    // 查询文章信息
                    HealthEduArticle temp = maps.get(a);
                    if (temp == null) {
                        temp = healthEduArticleService.findArticleByCode(a);
                        // 添加到缓存
                        maps.put(a, temp);
                    }
                    HealthEduArticlePatient heap = new HealthEduArticlePatient();
                    // 设置文章标识
                    heap.setArticle(a);
                    // 设置文章简介
                    heap.setContent(temp.getContent());
                    // 设置文章标题
                    heap.setTitle(temp.getTitle());
                    // 设置文章查看URL
                    heap.setUrl(temp.getUrl());
                    // 设置发送时间
                    heap.setCzrq(new Date());
                    // 设置医生标识
                    heap.setDoctor(doctor.getCode());
                    // 设置医生姓名
                    heap.setDoctorName(doctor.getName());
                    // 设置患者标识
                    heap.setPatient(p);
                    // 设置为示读
                    heap.setRead(1);
                    // 签约类型
                    heap.setSignType(2);
                    // 行政团队
                    heap.setAdminTeamCode(signFamily.getAdminTeamId());
                    list.add(heap);
                    SendP2PUtil.sendP2Pmsg(doctor.getCode(), p, "4", "{\"title\":\"" + temp.getTitle() + "\",\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}");
                    if (StringUtils.isNotEmpty(patientTemp.getOpenid())) {
                        // 推送消息给微信端
                        JSONObject json = new JSONObject();
                        json.put("first", patientTemp.getName() + ",您好!\n" + msgHead);
                        json.put("toUser", p);
                        json.put("article", temp.getCode() + "");
                        json.put("title", temp.getTitle());
                        json.put("doctorName", doctor.getName());
                        json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
                        json.put("remark", endMsg);
                        PushMsgTask.getInstance().putWxMsg(getAccessToken(), 9, patientTemp.getOpenid(), patientTemp.getName(), json);
                    }
                }
            }
            // 保存到数据库
            int row = healthEduArticleService.send(list);
            if (row <= 0) {
                return error(-1, "发送失败!");
            } else {
                // 推送消息给患者
                PushMsgTask.getInstance().put(messages);
                return success("发送成功!");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "发送失败!");
        }
    }
    private void getPatientByGroup(String labelCode, String labelType, Long teamCode, Set<String> patientSet, int page, int pagesize) throws Exception {
        JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize);
        for (Object o : result) {
            JSONObject json = (JSONObject) o;
            String patient = (String) json.get("code");
            patientSet.add(patient);
        }
        if (result.length() == 100) {
            getPatientByGroup(labelCode, labelType, teamCode, patientSet, page + 1, pagesize);
        }
    }
    /**
     * 文章收藏
     *
     * @param article 文章CODE
     * @return
     */
    @RequestMapping(value = "collectionArticle")
    @ResponseBody
    public String collectionArticle(@RequestParam(value = "article", required = true) String article) {
        HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(article, getUID());
        if (healthEduArticleDoctor != null) {
            return error(-1, "收藏失败,该文章已经收藏!");
        }
        HealthEduArticle healthEduArticle = healthEduArticleService.findArticleByCode(article);
        healthEduArticleDoctor = new HealthEduArticleDoctor();
        try {
            BeanUtils.copyProperties(healthEduArticle, healthEduArticleDoctor);
            healthEduArticleDoctor.setDoctor(getUID());
            healthEduArticleDoctor.setArticle(healthEduArticle.getCode());
            healthEduArticleDoctorService.save(healthEduArticleDoctor);
            //更新收藏量
            healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.COLLECTION_STATUS, healthEduArticle.getCode(), healthEduArticle.getTitle(), getUID());
            return success("收藏成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "收藏失败!");
        }
    }
    /**
     * 文章收藏
     *
     * @param article 文章CODE
     * @return
     */
    @RequestMapping(value = "uncollectionArticle")
    @ResponseBody
    public String uncollectionArticle(@RequestParam(value = "article", required = true) String article) {
        try {
            healthEduArticleDoctorService.delete(article, getUID());
            return success("取消收藏成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "取消收藏失败!");
        }
    }
    private String parsrHtml(String html) {
        html = ("<span>" + html + "</span>");//拼接一个HTML标签,防止纯文字字符串转换在linux下面出现的异常。
        Parser parser = null;
        try {
            parser = new Parser(html);
            TextExtractingVisitor visitor = new TextExtractingVisitor();
            parser.visitAllNodesWith(visitor);
            return StringUtils.isNotBlank(visitor.getExtractedText()) ? visitor.getExtractedText() : "内容为图集,请点击查看";
        } catch (ParserException e) {
            return html;//纯文本内容会转换失败,直接返回文本内容
        }
    }
    public static void main(String arg[]) {
        System.out.println(MessageType.MESSAGE_TYPE_PATIENT_HEALTH_EDU.P_HE_01.name());
    }
}

+ 35 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java

@ -2,6 +2,8 @@ package com.yihu.wlyy.web.doctor.health;
import com.yihu.wlyy.util.SendP2PUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -48,7 +50,6 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
			JSONObject guidance = patientHealthGuidanceService.findById(id);
			return write(200,"查询成功","data",guidance);
		}catch (Exception e){
			e.printStackTrace();
			return error(-1,"查询失败");
		}
	}
@ -116,4 +117,37 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
		}
	}
	/**
	 * 查询患者的健康指导
	 *
	 * @param patient
	 * @param teamCode
	 * @param page
	 * @param pagesize
	 * @return
	 */
	@RequestMapping(value = "list_by_team", method = {RequestMethod.GET, RequestMethod.POST})
	@ResponseBody
	@ApiOperation(value = "查询居民健康指导记录")
	public String list(@RequestParam @ApiParam(value = "居民code") String patient,
					   @RequestParam @ApiParam(value = "团队Code") Long teamCode,
					   @RequestParam @ApiParam(value = "第几页") int page,
					   @RequestParam @ApiParam(value = "页大小") int pagesize) {
		try {
			if (StringUtils.isEmpty(patient)) {
				return error(-1, "请输入需查询的居民");
			}
			if (teamCode == null || teamCode < 1) {
				return error(-1, "请输入需查询的居民的团队");
			}
			page = page > 0 ? page - 1 : 0;
			JSONArray result = patientHealthGuidanceService.findByPatientAndGuidanceAndTeam(patient,teamCode,page,pagesize);
			return write(200, "查询成功!", "data", result);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
}

+ 291 - 273
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java

@ -28,297 +28,315 @@ import java.util.Map;
@Api(description = "医生端-消息")
public class DoctorMessageController extends BaseController {
	@Autowired
	private MessageService messageService;
    @Autowired
    private MessageService messageService;
	@RequestMapping(value = "messages")
	@ResponseBody
	@ApiOperation("查询医生未读消息和最后消息")
	public String messages() {
		try {
			JSONObject json = messageService.findDoctorAllMessage(getUID());
			return write(200, "获取消息总数成功!", "data", json);
		} catch (Exception e) {
			error(e);
			return error(-1, e.getMessage());
		}
	}
    @RequestMapping(value = "messages")
    @ResponseBody
    @ApiOperation("查询医生未读消息和最后消息")
    public String messages() {
        try {
            JSONObject json = messageService.findDoctorAllMessage(getUID());
            return write(200, "获取消息总数成功!", "data", json);
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
	/**
	 * 医生消息总数统计接口
	 * @return
	 */
	@RequestMapping(value = "amount")
	@ResponseBody
	public String amount() {
		try {
			JSONObject json = messageService.findDoctorAllMessageAmount(getUID());
			if (json == null) {
				return error(-1, "获取消息总数失败!");
			} else {
				return write(200, "获取消息总数成功!", "data", json);
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息总数失败!");
		}
	}
    /**
     * 医生消息总数统计接口
     *
     * @return
     */
    @RequestMapping(value = "amount")
    @ResponseBody
    public String amount() {
        try {
            JSONObject json = messageService.findDoctorAllMessageAmount(getUID());
            if (json == null) {
                return error(-1, "获取消息总数失败!");
            } else {
                return write(200, "获取消息总数成功!", "data", json);
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "获取消息总数失败!");
        }
    }
	/**
	 * 健康咨询消息列表查询接口
	 * @param id
	 * @param pagesize 分页大小
	 * @return
	 */
	@RequestMapping(value = "consults")
	@ResponseBody
	public String consultList(long id, int pagesize) {
		try {
			JSONArray array = new JSONArray();
			Page<ConsultTeam> list = messageService.findConsultListByDoctor(getUID(), id, pagesize);
			for (ConsultTeam consult : list) {
				if (consult == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				json.put("id", consult.getId());
				// 设置咨询标识
				json.put("consult", consult.getConsult());
				// 设置患者标识
				json.put("patient", consult.getPatient());
				// 设置患者头像
				json.put("photo", consult.getPhoto());
				// 设置主要症状
				json.put("symptoms", consult.getSymptoms());
				// 设置患者姓名
				json.put("name", consult.getName());
				// 设置状态(0进行中,1已完成,-1患者取消)
				json.put("status", consult.getStatus());
				// 设置消息未读数量
				json.put("unread", consult.getDoctorRead());
				// 设置咨询时间
				json.put("time", DateUtil.dateToStr(consult.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
				array.put(json);
			}
			return write(200, "获取健康咨询列表成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取健康咨询列表失败!");
		}
	}
    /**
     * 健康咨询消息列表查询接口
     *
     * @param id
     * @param pagesize 分页大小
     * @return
     */
    @RequestMapping(value = "consults")
    @ResponseBody
    public String consultList(long id, int pagesize) {
        try {
            JSONArray array = new JSONArray();
            Page<ConsultTeam> list = messageService.findConsultListByDoctor(getUID(), id, pagesize);
            for (ConsultTeam consult : list) {
                if (consult == null) {
                    continue;
                }
                JSONObject json = new JSONObject();
                json.put("id", consult.getId());
                // 设置咨询标识
                json.put("consult", consult.getConsult());
                // 设置患者标识
                json.put("patient", consult.getPatient());
                // 设置患者头像
                json.put("photo", consult.getPhoto());
                // 设置主要症状
                json.put("symptoms", consult.getSymptoms());
                // 设置患者姓名
                json.put("name", consult.getName());
                // 设置状态(0进行中,1已完成,-1患者取消)
                json.put("status", consult.getStatus());
                // 设置消息未读数量
                json.put("unread", consult.getDoctorRead());
                // 设置咨询时间
                json.put("time", DateUtil.dateToStr(consult.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
                array.put(json);
            }
            return write(200, "获取健康咨询列表成功!", "list", array);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取健康咨询列表失败!");
        }
    }
	/**
	 * 更新体征消息为已读
	 * @param msgid
	 * @return
	 */
	@RequestMapping(value = "read_health")
	@ResponseBody
	@ApiOperation("消息设置成已读")
	public String readHealth(long msgid) {
		try {
			messageService.readHealth(msgid);
			return success("操作成功!");
		} catch (Exception e) {
			error(e);
			return error(-1, "操作失败!");
		}
	}
    /**
     * 更新体征消息为已读
     *
     * @param msgid
     * @return
     */
    @RequestMapping(value = "read_health")
    @ResponseBody
    @ApiOperation("消息设置成已读")
    public String readHealth(long msgid) {
        try {
            messageService.readHealth(msgid);
            return success("操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
	/**
	 * 根据参数查询发送给我的消息
	 * @return
	 */
	@RequestMapping(value = "find")
	@ResponseBody
	@ApiOperation("查询发送给我的消息")
	public String findMyMessage(String sender, String signStatus) {
		try {
			Message msg = messageService.findUnreadSign(sender, getUID(), signStatus);
			JSONObject json = null;
			if (msg != null) {
				json = new JSONObject();
				json.put("id", msg.getId());
				json.put("sender", msg.getSender());
				json.put("senderName", msg.getSenderName());
				json.put("type", msg.getType());
				json.put("read", msg.getRead()); // 是否已读:1未读,0已读
				json.put("signStatus", msg.getSignStatus());
				json.put("status", msg.getOver());
				json.put("reason", msg.getReason());
			}
			return write(200, "获取消息成功!", "data", json);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
		}
	}
    /**
     * 根据参数查询发送给我的消息
     *
     * @return
     */
    @RequestMapping(value = "find")
    @ResponseBody
    @ApiOperation("查询发送给我的消息")
    public String findMyMessage(String sender, String signStatus) {
        try {
            Message msg = messageService.findUnreadSign(sender, getUID(), signStatus);
            JSONObject json = null;
            if (msg != null) {
                json = new JSONObject();
                json.put("id", msg.getId());
                json.put("sender", msg.getSender());
                json.put("senderName", msg.getSenderName());
                json.put("type", msg.getType());
                json.put("read", msg.getRead()); // 是否已读:1未读,0已读
                json.put("signStatus", msg.getSignStatus());
                json.put("status", msg.getOver());
                json.put("reason", msg.getReason());
            }
            return write(200, "获取消息成功!", "data", json);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取消息失败!");
        }
    }
    /**
     * 系统消息(分配健管师 + 随访计划消息 )
     */
    @RequestMapping(value = "getSystemMessage", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取系统消息")
    public String getSystemMessage(@ApiParam(value = "第几页", defaultValue = "1")
                                   @RequestParam Integer page,
                                   @ApiParam(value = "每页几行", defaultValue = "10")
                                   @RequestParam Integer pagesize) {
        try {
            List<Message> list = messageService.getSystemMessage(getUID(), page, pagesize);
            return write(200, "获取消息成功!", "list", list);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取消息失败!");
        }
    }
	/**
	 * 系统消息(分配健管师 + 随访计划消息 )
	 */
	@RequestMapping(value = "getSystemMessage",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取系统消息")
	public String getSystemMessage(@ApiParam(value="第几页",defaultValue = "1")
							  @RequestParam Integer page,
							  @ApiParam(value="每页几行",defaultValue = "10")
							  @RequestParam Integer pagesize) {
		try {
			List<Message> list = messageService.getSystemMessage(getUID(),page,pagesize);
			return write(200, "获取消息成功!", "list", list);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
		}
	}
    @RequestMapping(value = "getHealthIndexMessage", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取超标指标消息--根据患者分组")
    public String getHealthIndexMessage() throws Exception {
        try {
            List<Map<String, Object>> list = messageService.getHealthIndexMessage(getUID());     //"D20161008003"
	@RequestMapping(value = "getHealthIndexMessage",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取超标指标消息--根据患者分组")
	public String getHealthIndexMessage()throws Exception{
		try {
			List<Map<String,Object>> list = messageService.getHealthIndexMessage(getUID());     //"D20161008003"
            return write(200, "获取超标指标消息成功", "data", list);
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
			return write(200, "获取超标指标消息成功", "data", list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
    @RequestMapping(value = "getHealthIndexMessageByPatient", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取患者超标指标消息")
    public String getHealthIndexMessageByPatient(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20161008001")
                                                 @RequestParam(value = "patient", required = true) String patient,
                                                 @ApiParam(name = "type", value = "健康指标类型1血糖,2血压,3体重", defaultValue = "1")
                                                 @RequestParam(value = "type", required = true) String type,
                                                 @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                                                 @RequestParam(value = "page", required = true) Integer page,
                                                 @ApiParam(name = "pagesize", value = "每页几行", defaultValue = "10")
                                                 @RequestParam(value = "pagesize", required = true) Integer pagesize) throws Exception {
        try {
            List<Map<String, String>> list = messageService.getHealthIndexMessageByPatient(getUID(), patient, type, page, pagesize);
	@RequestMapping(value = "getHealthIndexMessageByPatient",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取患者超标指标消息")
	public String getHealthIndexMessageByPatient(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
												 @RequestParam(value="patient",required = true) String patient,
												 @ApiParam(name="type",value="健康指标类型1血糖,2血压,3体重",defaultValue = "1")
												 @RequestParam(value="type",required = true) String type,
												 @ApiParam(name="page",value="第几页",defaultValue = "1")
												 @RequestParam(value="page",required = true) Integer page,
												 @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
												 @RequestParam(value="pagesize",required = true) Integer pagesize)throws Exception{
		try {
			List<Map<String,String>> list = messageService.getHealthIndexMessageByPatient(getUID(),patient,type,page,pagesize);
            return write(200, "获取超标指标消息成功", "data", list);
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
			return write(200, "获取超标指标消息成功", "data", list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
    /**
     * @param type 消息类型  1.是家庭签约信息  2.体征消息  3分配健管师
     */
    @RequestMapping(value = "findMessageNum")
    @ResponseBody
    @ApiOperation("获取未读消息数(1.2.8版本作废)")
    public String findMessageNum(@ApiParam(value = "消息类型", defaultValue = "3")
                                 @RequestParam Integer type) {
        try {
            JSONObject obj = messageService.findMessageNum(getUID(), type);
            return write(200, "获取消息成功!", "list", obj);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取消息失败!");
        }
    }
    /**
     * 体征指标消息查询接口
     *
     * @param isRead 1未读,0已读
     */
    @RequestMapping(value = "health")
    @ResponseBody
    @ApiOperation("体征指标消息查询接口(1.2.8版本作废)")
    public String health(long id, int pagesize, @RequestParam(required = false) String isRead) {
        try {
            JSONArray array = new JSONArray();
            Page<Message> list = messageService.findHealthListByDoctor(getUID(), id, pagesize, isRead);
            for (Message msg : list) {
                if (msg == null) {
                    continue;
                }
                JSONObject json = new JSONObject();
                // 消息ID
                json.put("id", msg.getId());
                // 发送人标识
                json.put("sender", msg.getSender());
                // 发送人姓名
                json.put("senderName", msg.getSenderName());
                // 发送人头像
                json.put("senderPhoto", msg.getSenderPhoto());
                // 消息类型:1血糖,2血压
                json.put("type", msg.getTzType());
                // 是否已读:1未读,0已读
                json.put("read", msg.getRead());
                // 是否已读:
                json.put("sex", msg.getSex());
                // 当前值/收缩压,正数为高,负数为低
                json.put("value1", msg.getValue1());
                // 上次值/舒张压,正数为高,负数为低
                json.put("value2", msg.getValue2());
                // 发送时间
                json.put("czrq", DateUtil.dateToStrLong(msg.getCzrq()));
                array.put(json);
            }
            return write(200, "获取体征消息成功!", "list", array);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取体征消息失败!");
        }
    }
    /**
     * @param type 消息类型  1.是家庭签约信息  2.体征消息  3系统消息(分配健管师 + 随访计划消息 )
     */
    @RequestMapping(value = "findMessage")
    @ResponseBody
    @ApiOperation("获取某类消息(1.2.8版本作废)")
    public String findMessage(String type,
                              long id,
                              int pagesize) {
        try {
            JSONArray array = new JSONArray();
            Page<Message> list = messageService.find(getUID(), type, id, pagesize);
            for (Message msg : list) {
                if (msg == null) {
                    continue;
                }
                JSONObject json = new JSONObject();
                // 消息ID
                json.put("id", msg.getId());
                // 发送人标识
                json.put("sender", msg.getSender());
                // 消息內容
                json.put("content", msg.getContent());
                // 发送人姓名
                json.put("senderName", msg.getSenderName());
                // 发送人头像
                json.put("senderPhoto", msg.getSenderPhoto());
                // 是否已读:1已读,0未读
                json.put("read", msg.getRead());
                // 是否已读:
                json.put("sex", msg.getSex());
                // 发送时间
                json.put("czrq", DateUtil.dateToStrNoSecond(msg.getCzrq()));
                array.put(json);
            }
            return write(200, "获取消息成功!", "list", array);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取消息失败!");
        }
    }
	/**
	 * @param type 消息类型  1.是家庭签约信息  2.体征消息  3分配健管师
	 */
	@RequestMapping(value = "findMessageNum")
	@ResponseBody
	@ApiOperation("获取未读消息数(1.2.8版本作废)")
	public String findMessageNum(@ApiParam(value="消息类型",defaultValue = "3")
								 @RequestParam Integer type) {
		try {
			JSONObject obj = messageService.findMessageNum(getUID(), type);
			return write(200, "获取消息成功!", "list", obj);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
		}
	}
	/**
	 * 体征指标消息查询接口
	 * @param isRead 1未读,0已读
	 */
	@RequestMapping(value = "health")
	@ResponseBody
	@ApiOperation("体征指标消息查询接口(1.2.8版本作废)")
	public String health(long id, int pagesize, @RequestParam(required = false) String isRead) {
		try {
			JSONArray array = new JSONArray();
			Page<Message> list = messageService.findHealthListByDoctor(getUID(), id, pagesize, isRead);
			for (Message msg : list) {
				if (msg == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				// 消息ID
				json.put("id", msg.getId());
				// 发送人标识
				json.put("sender", msg.getSender());
				// 发送人姓名
				json.put("senderName", msg.getSenderName());
				// 发送人头像
				json.put("senderPhoto", msg.getSenderPhoto());
				// 消息类型:1血糖,2血压
				json.put("type", msg.getTzType());
				// 是否已读:1未读,0已读
				json.put("read", msg.getRead());
				// 是否已读:
				json.put("sex", msg.getSex());
				// 当前值/收缩压,正数为高,负数为低
				json.put("value1", msg.getValue1());
				// 上次值/舒张压,正数为高,负数为低
				json.put("value2", msg.getValue2());
				// 发送时间
				json.put("czrq", DateUtil.dateToStrLong(msg.getCzrq()));
				array.put(json);
			}
			return write(200, "获取体征消息成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取体征消息失败!");
		}
	}
	/**
	 * @param type 消息类型  1.是家庭签约信息  2.体征消息  3系统消息(分配健管师 + 随访计划消息 )
	 */
	@RequestMapping(value = "findMessage")
	@ResponseBody
	@ApiOperation("获取某类消息(1.2.8版本作废)")
	public String findMessage(String type,
							  long id,
							  int pagesize) {
		try {
			JSONArray array = new JSONArray();
			Page<Message> list = messageService.find(getUID(), type,id,pagesize);
			for (Message msg : list) {
				if (msg == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				// 消息ID
				json.put("id", msg.getId());
				// 发送人标识
				json.put("sender", msg.getSender());
				// 消息內容
				json.put("content", msg.getContent());
				// 发送人姓名
				json.put("senderName", msg.getSenderName());
				// 发送人头像
				json.put("senderPhoto", msg.getSenderPhoto());
				// 是否已读:1已读,0未读
				json.put("read", msg.getRead());
				// 是否已读:
				json.put("sex", msg.getSex());
				// 发送时间
				json.put("czrq", DateUtil.dateToStrNoSecond(msg.getCzrq()));
				array.put(json);
			}
			return write(200, "获取消息成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取消息失败!");
		}
	}
    /**
     * 设置某类消息已读
     *
     * @param type 消息类型
     * @return
     */
    @RequestMapping(value = "setMessageReaded")
    @ResponseBody
    @ApiOperation("设置某类消息已读")
    public String setMessageReaded(@RequestParam @ApiParam(value = "消息类型") Integer type) {
        try {
            messageService.setMessageReaded(getUID(),type);
            return write(200,"设置成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"设置失败");
        }
    }
}

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/DoctorPatientGroupController.java

@ -429,7 +429,6 @@ public class DoctorPatientGroupController extends BaseController {
            System.out.println("patients_disease_end:" + new Date());
            return write(200, "患者疾病分组列表查询成功!", "data", array);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }

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

@ -52,7 +52,6 @@ public class PatientDiseaseController extends BaseController {
                return write(200, "查询成功", "data", new JSONArray(redisTemplate.opsForValue().get("disease:" + patient)));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -114,7 +113,6 @@ public class PatientDiseaseController extends BaseController {
                return error(-1, "更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }

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

@ -0,0 +1,43 @@
package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.service.app.statistics.ServiceStatisticsService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by lyr-pc on 2017/1/10.
 */
@RestController
@RequestMapping(value = "/doctor/patient/service")
public class ServiceStatisticsController extends BaseController {
    @Autowired
    ServiceStatisticsService serviceStatistics;
    /**
     * 居民服务统计查询
     *
     * @param patient 居民
     * @return
     */
    @RequestMapping(value = "/statistics", method = {RequestMethod.GET, RequestMethod.POST})
    @ApiOperation(value = "居民服务统计查询")
    public String statistics(@RequestParam @ApiParam(value = "居民code") String patient,
                             @RequestParam @ApiParam(value = "团队Code") Long teamCode) {
        try {
            JSONObject result = serviceStatistics.getServiceStatistics(patient, teamCode, getUID());
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}

+ 0 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelController.java

@ -66,7 +66,6 @@ public class SignPatientLabelController extends BaseController {
                return error(-1, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
@ -132,7 +131,6 @@ public class SignPatientLabelController extends BaseController {
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -182,7 +180,6 @@ public class SignPatientLabelController extends BaseController {
            return write(200, "查询成功", "data", labels);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -238,7 +235,6 @@ public class SignPatientLabelController extends BaseController {
            return write(200, "查询成功", "data", labels);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

+ 5 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -57,7 +57,6 @@ public class SignPatientLabelInfoController extends BaseController {
            JSONObject p = labelInfoService.getPatient(patient);
            return write(200, "查询成功", "data", p);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -218,7 +217,11 @@ public class SignPatientLabelInfoController extends BaseController {
        try {
            int result = labelInfoService.getPatientAmountByTeam(teamCode);
            int resultFocus =labelInfoService.getPatientFocusAmountByTeam(teamCode);
            return write(200, "查询成功", "data", resultFocus + "/" + result);
            JSONObject re = new JSONObject();
            re.put("amount",result);
            re.put("focusAmount",resultFocus);
            return write(200, "查询成功", "data", re);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
@ -266,7 +269,6 @@ public class SignPatientLabelInfoController extends BaseController {
                return error(-1, "更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -333,7 +335,6 @@ public class SignPatientLabelInfoController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -395,7 +396,6 @@ public class SignPatientLabelInfoController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -454,7 +454,6 @@ public class SignPatientLabelInfoController extends BaseController {
                return error(-1, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
@ -525,7 +524,6 @@ public class SignPatientLabelInfoController extends BaseController {
                return error(-1, "删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "删除失败");
        }
    }

+ 0 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/reply/DoctorQuickReplyController.java

@ -42,7 +42,6 @@ public class DoctorQuickReplyController extends BaseController {
                return error(-1, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
@ -90,7 +89,6 @@ public class DoctorQuickReplyController extends BaseController {
                return error(-1, "删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "删除失败");
        }
    }
@ -144,7 +142,6 @@ public class DoctorQuickReplyController extends BaseController {
                return error(-1, "排序失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "排序失败");
        }
    }

+ 0 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheduling/DoctorWorkTimeController.java

@ -41,7 +41,6 @@ public class DoctorWorkTimeController extends BaseController {
            return write(200, "查询成功!", "data", workTime);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
@ -112,7 +111,6 @@ public class DoctorWorkTimeController extends BaseController {
                return write(-1, "保存失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "保存失败!");
        }
    }
@ -167,7 +165,6 @@ public class DoctorWorkTimeController extends BaseController {
                return error(-1, "设置失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "设置失败");
        }
    }
@ -206,7 +203,6 @@ public class DoctorWorkTimeController extends BaseController {
            JSONObject result = doctorWorkTimeService.isFamousDoctorWorking(doctor);
            return write(200,result.getString("msg"),"data",result.getString("status"));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
@ -243,7 +239,6 @@ public class DoctorWorkTimeController extends BaseController {
            JSONObject json = doctorWorkTimeService.findDoctorWeekWorkTime(doctor, week);
            return write(200, "查询成功", "data", json);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

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

@ -123,7 +123,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject list = familyContractService.getPatientByLable(doctorcode, labelType, level, team);
            return write(200, "查询成功", "data", list);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -659,7 +658,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return write(-1, "不存在该患者签约");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -763,7 +761,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            return write(200, "查询成功", "data", json);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -823,7 +820,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            }
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
@ -864,7 +860,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject list = familyContractService.findNoHealthSignFamilyHealthByParams(getUID(), teamCode, params);
            return write(200, "签约数据加载成功!", "data", list);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -880,13 +875,12 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    public String findNoHealthSignFamilyNum(long teamCode) {
        try {
            List<SignFamily> signFamily = familyContractService.findNoHealthSignFamilyNum(teamCode);
            int count = familyContractService.findNoHealthSignFamilyFocusNum(teamCode);
            JSONObject jo = new JSONObject();
            if (signFamily != null && signFamily.size() > 0) {
                jo.put("date", DateUtil.dateToStr(signFamily.get(0).getCzrq(), "yyyy-MM-dd"));
                jo.put("num", count + "/" + signFamily.size());
                jo.put("num", signFamily.size());
            } else {
                jo.put("num", "0/0");
                jo.put("num", 0);
            }
            return write(200, "查询成功", "data", jo);
        } catch (Exception e) {
@ -934,7 +928,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
        } catch (Exception e) {
            redisTemplate.opsForValue().set("expenses:remind:doctor:" + getUID(), "0");
            redisTemplate.expire("expenses:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
            e.printStackTrace();
            return error(-1, "提醒失败");
        }
    }
@ -987,7 +980,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.isPatientAndDoctorExistSign(patient, doctor);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -1033,7 +1025,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.getPatientDoctors(patient, getUID());
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -1056,6 +1047,23 @@ public class DoctorFamilyContractController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "/patient_doctor_teams", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value = "查询医生与居民的团队")
    public String getPatientAndDoctorTeams(@RequestParam @ApiParam(value = "居民code") String patient) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "居民不能为空");
            }
            JSONObject result = familyContractService.getPatientAndDoctorTeams(patient, getUID());
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "/wechat_focus_remind", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value = "微信关注提醒")
@ -1092,7 +1100,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
        } catch (Exception e) {
            redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + getUID(), "0");
            redisTemplate.expire("wechat:focus:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
            e.printStackTrace();
            return error(-1, "微信关注提醒失败");
        }
    }
@ -1105,7 +1112,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
     */
    @RequestMapping(value = "/is_patient_remind_focus")
    @ResponseBody
    public String isPatientRemindFocusToday(String patient){
    public String isPatientRemindFocusToday(String patient) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "患者不能为空");

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -325,7 +325,6 @@ public class DoctorSignController extends BaseController {
        try{
            return write(200,"查询成功","data",signWebService.isRemindFocusAll(getUID()));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java

@ -309,7 +309,6 @@ public class AdminTeamController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

+ 0 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -750,7 +750,6 @@ public class PatientController extends WeixinBaseController {
                return write(-1, "手机号更新失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "手机号更新失败");
        }
    }
@ -801,7 +800,6 @@ public class PatientController extends WeixinBaseController {
            patientInfoService.updatePassword(newPassword1, newPassword2, oldPassword, getUID());
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }

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

@ -566,7 +566,7 @@ public class ConsultController extends WeixinBaseController {
     */
    @RequestMapping(value = "finish")
    @ResponseBody
    public String finish(String code) {
    public String finish(@RequestParam(required = true) String code) {
        try {
            int row = consultTeamService.finish(code, getUID(), 1);
            if (row > 0) {

+ 0 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java

@ -72,7 +72,6 @@ public class FamilyMemberController extends BaseController {
                return write(200, "添加成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
@ -134,7 +133,6 @@ public class FamilyMemberController extends BaseController {
                return write(200, "删除成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "删除失败");
        }
    }
@ -179,7 +177,6 @@ public class FamilyMemberController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthGuidanceController.java

@ -61,7 +61,6 @@ public class PatientHealthGuidanceController extends BaseController {
			JSONObject guidance = patientHealthGuidanceService.findById(id);
			return write(200,"查询成功","data",guidance);
		}catch (Exception e){
			e.printStackTrace();
			return error(-1,"查询失败");
		}
	}

+ 0 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java

@ -463,7 +463,6 @@ public class FamilyContractController extends BaseController {
                return write(200, "签约申请成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "签约申请失败");
        }
    }
@ -614,7 +613,6 @@ public class FamilyContractController extends BaseController {
            JSONObject result = familyContractService.isPatientAndDoctorCanSign(getUID(),doctor);
            return write(200,"查询成功","data",result);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/quota/JobController.java

@ -237,7 +237,6 @@ public class JobController extends BaseController {
            diseaseService.updateToDisease();
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }

+ 0 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -43,7 +43,6 @@ public class StatisticsController extends BaseController {
        try {
            return write(200, "查询成功", "data", statisticsService.getStatisticsTime());
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -80,7 +79,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功!", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, tag + "查询失败!");
        }
    }
@ -142,7 +140,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -208,7 +205,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -279,7 +275,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -340,7 +335,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功!", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
@ -410,7 +404,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -470,7 +463,6 @@ public class StatisticsController extends BaseController {
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }

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

@ -453,7 +453,7 @@ public class BookingController extends WeixinBaseController {
    }
    /********************************************* 医生端查询 **************************************************************************/
    @RequestMapping(value = "GetPatientReservationList", method = RequestMethod.POST)
    @RequestMapping(value = "GetPatientReservationList", method = {RequestMethod.POST,RequestMethod.GET})
    @ResponseBody
    @ApiOperation("获取患者预约信息列表接口-医生端")
    public String GetPatientReservation(@ApiParam(name = "pageIndex", value = "第几页", defaultValue = "1")
@ -462,10 +462,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 = "doctor", value = "医生编号", defaultValue = "shiliuD20160926005")
                                        @RequestParam(value = "doctor", required = false) String doctor) {
                                        @ApiParam(name = "teamCode", value = "行政团队")
                                        @RequestParam(value = "teamCode", required = false) Long teamCode) {
        try {
            List<PatientReservation> list = patientReservationService.getReservationByPatient(patient, doctor, pageIndex, pageSize);
            JSONArray list = patientReservationService.getReservationByPatient(patient, teamCode, pageIndex, pageSize);
            return write(200, "获取患者预约信息列表成功!", "data", list);
        } catch (Exception e) {

+ 0 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatCoreController.java

@ -55,7 +55,6 @@ public class WechatCoreController extends WeixinBaseController {
                response.setStatus(401);
            }
        } catch (Exception e) {
            e.printStackTrace();
            // 服务器错误
            response.setStatus(500);
        }
@ -180,7 +179,6 @@ public class WechatCoreController extends WeixinBaseController {
                return write(-1,"创建失败!","data",jsonStr);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"创建失败");
        }
    }

+ 1 - 1
patient-co-wlyy/src/main/resources/system.properties

@ -50,7 +50,7 @@ chat_server=http://weixin.xmtyw.cn/res/chat/
sign_check_upload=http://172.19.103.87:8011/wlyy_service
# IM配置
im_list_get=http://172.19.103.29:3000/
im_list_get=http://192.168.131.109:3008/
im_group_server=http://172.19.103.29:3000/api/v1/chats/gm
msg_push_server=http://172.19.103.29:3000/api/v1/chats/sm

+ 12 - 12
patient-co-wlyy/src/main/webapp/WEB-INF/web.xml

@ -77,16 +77,16 @@
  <session-config>
    <session-timeout>20</session-timeout>
  </session-config>
  <error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/WEB-INF/views/error/500.jsp</location>
  </error-page>
  <error-page>
    <error-code>500</error-code>
    <location>/WEB-INF/views/error/500.jsp</location>
  </error-page>
  <error-page>
    <error-code>404</error-code>
    <location>/WEB-INF/views/error/404.jsp</location>
  </error-page>
  <!--<error-page>-->
    <!--<exception-type>java.lang.Throwable</exception-type>-->
    <!--<location>/WEB-INF/views/error/500.jsp</location>-->
  <!--</error-page>-->
  <!--<error-page>-->
    <!--<error-code>500</error-code>-->
    <!--<location>/WEB-INF/views/error/500.jsp</location>-->
  <!--</error-page>-->
  <!--<error-page>-->
    <!--<error-code>404</error-code>-->
    <!--<location>/WEB-INF/views/error/404.jsp</location>-->
  <!--</error-page>-->
</web-app>