Browse Source

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

8 years ago
parent
commit
372658eea4
34 changed files with 1667 additions and 978 deletions
  1. 3 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/storage/DBStorage.java
  2. 4 2
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/FollowUpJob.java
  3. 6 5
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/job/WlyyQuotaResult.java
  4. 6 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/statistics/WlyyQuotaResult.java
  5. 4 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  6. 13 14
      patient-co-wlyy/src/main/java/com/yihu/wlyy/job/SignAgainJob.java
  7. 15 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/deviece/PatientHealthTimeDao.java
  8. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/MedicinesDao.java
  9. 21 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientHealthRecordDietDao.java
  10. 20 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientHealthRecordMedicationDao.java
  11. 20 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientHealthRecordSportsDao.java
  12. 18 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  13. 10 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewDao.java
  14. 0 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/statistics/WlyyQuotaResultDao.java
  15. 35 21
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java
  16. 141 73
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  17. 57 31
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  18. 280 41
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  19. 119 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  20. 25 10
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  21. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  22. 10 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  23. 91 12
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendNews.java
  24. 5 60
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java
  25. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  26. 28 18
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java
  27. 59 45
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  28. 22 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  29. 16 16
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java
  30. 579 547
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java
  31. 48 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  32. 0 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java
  33. 0 16
      patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/util/WeiXinMessageReplyUtils.java
  34. 8 4
      patient-co-wlyy/src/main/resources/system.properties

+ 3 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/storage/DBStorage.java

@ -13,6 +13,7 @@ import com.yihu.wlyy.statistics.model.job.WlyyQuotaResult;
import com.yihu.wlyy.statistics.model.system.City;
import com.yihu.wlyy.statistics.model.system.City;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.Scope;
@ -29,6 +30,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.*;
/**
/**
@ -765,7 +767,7 @@ public class DBStorage   {
        wlyyQuotaResult.setCityName(cityName);
        wlyyQuotaResult.setCityName(cityName);
        wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
        wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
        wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
        wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
        wlyyQuotaResult.setQuotaDate(date);
        wlyyQuotaResult.setQuotaDate(DateUtil.strToDateShort(date));
        wlyyQuotaResult.setCreateTime(new Date());
        wlyyQuotaResult.setCreateTime(new Date());
        wlyyQuotaResult.setQkdoctorJobName(doctorJob);
        wlyyQuotaResult.setQkdoctorJobName(doctorJob);
        wlyyQuotaResult.setQkdoctorName(doctorName);
        wlyyQuotaResult.setQkdoctorName(doctorName);

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

@ -12,6 +12,7 @@ import com.yihu.wlyy.statistics.model.job.WlyyQuotaResult;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
@ -123,8 +124,9 @@ public class FollowUpJob implements Job {
        return string.toString();
        return string.toString();
    }
    }
    public String getYesterday() {
        return yesterday;
    public Date getYesterday() {
        return DateUtil.strToDateShort(yesterday);
    }
    }
    private void save(Map<String, Long> tjTownMap, String city, String cityName, String town, String townName, String org, String orgName, String doctorCode, String doctorName, String doctorJob, String level, String key) {
    private void save(Map<String, Long> tjTownMap, String city, String cityName, String town, String townName, String org, String orgName, String doctorCode, String doctorName, String doctorJob, String level, String key) {

+ 6 - 5
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/job/WlyyQuotaResult.java

@ -12,7 +12,7 @@ import java.util.Date;
@Table(name = "wlyy_quota_result")
@Table(name = "wlyy_quota_result")
public class WlyyQuotaResult implements java.io.Serializable {
public class WlyyQuotaResult implements java.io.Serializable {
    private String id;
    private String id;
    private String quotaDate;//统计时间
    private Date quotaDate;//统计时间
    private String quatoCode;//指标code
    private String quatoCode;//指标code
    private String quatoName;//指标name
    private String quatoName;//指标name
    private String result;//统计结果
    private String result;//统计结果
@ -63,15 +63,16 @@ public class WlyyQuotaResult implements java.io.Serializable {
        this.orgName = orgName;
        this.orgName = orgName;
    }
    }
    @Column(name = "quota_date", length = 0)
    public String getQuotaDate() {
        return this.quotaDate;
    @Column(name = "quota_date")
    public Date getQuotaDate() {
        return quotaDate;
    }
    }
    public void setQuotaDate(String quotaDate) {
    public void setQuotaDate(Date quotaDate) {
        this.quotaDate = quotaDate;
        this.quotaDate = quotaDate;
    }
    }
    @Column(name = "quato_code", length = 100)
    @Column(name = "quato_code", length = 100)
    public String getQuatoCode() {
    public String getQuatoCode() {
        return this.quatoCode;
        return this.quatoCode;

+ 6 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/statistics/WlyyQuotaResult.java

@ -16,7 +16,7 @@ import org.hibernate.annotations.GenericGenerator;
@Table(name = "wlyy_quota_result")
@Table(name = "wlyy_quota_result")
public class WlyyQuotaResult implements java.io.Serializable {
public class WlyyQuotaResult implements java.io.Serializable {
    private String id;
    private String id;
    private String quotaDate;//统计时间
    private Date quotaDate;//统计时间
    private String quatoCode;//指标code
    private String quatoCode;//指标code
    private String quatoName;//指标name
    private String quatoName;//指标name
    private String result;//统计结果
    private String result;//统计结果
@ -67,15 +67,16 @@ public class WlyyQuotaResult implements java.io.Serializable {
        this.orgName = orgName;
        this.orgName = orgName;
    }
    }
    @Column(name = "quota_date", length = 0)
    public String getQuotaDate() {
        return this.quotaDate;
    @Column(name = "quota_date")
    public Date getQuotaDate() {
        return quotaDate;
    }
    }
    public void setQuotaDate(String quotaDate) {
    public void setQuotaDate(Date quotaDate) {
        this.quotaDate = quotaDate;
        this.quotaDate = quotaDate;
    }
    }
    @Column(name = "quato_code", length = 100)
    @Column(name = "quato_code", length = 100)
    public String getQuatoCode() {
    public String getQuatoCode() {
        return this.quatoCode;
        return this.quatoCode;

+ 4 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -40,13 +40,13 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                System.out.println("evaluate_score_job exist");
                System.out.println("evaluate_score_job exist");
            }
            }
             //启动群发续签图文消息
             //启动群发续签图文消息
            if (!quartzHelper.isExistJob("sign_again_job")) {
//            if (!quartzHelper.isExistJob("sign_again_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("sign_again_job_trigger");
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("sign_again_job_trigger");
                quartzHelper.addJob(SignAgainJob.class, trigger, "sign_again_job", new HashMap<String, Object>());
                quartzHelper.addJob(SignAgainJob.class, trigger, "sign_again_job", new HashMap<String, Object>());
                System.out.println("sign_again_job start success");
                System.out.println("sign_again_job start success");
            } else {
                System.out.println("sign_again_job exist");
            }
//            } else {
//                System.out.println("sign_again_job exist");
//            }
        } catch (Exception e) {
        } catch (Exception e) {
            System.out.println("sign end job start failed");
            System.out.println("sign end job start failed");
        }
        }

+ 13 - 14
patient-co-wlyy/src/main/java/com/yihu/wlyy/job/SignAgainJob.java

@ -1,9 +1,13 @@
package com.yihu.wlyy.job;
package com.yihu.wlyy.job;
import com.google.zxing.datamatrix.encoder.SymbolShapeHint;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SendNews;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.common.account.WechatController;
import com.yihu.wlyy.web.common.account.WechatController;
import com.yihu.wlyy.wechat.process.WeiXinEventProcess;
import com.yihu.wlyy.wechat.process.WeiXinEventProcess;
import com.yihu.wlyy.wechat.util.WeiXinMessageReplyUtils;
import com.yihu.wlyy.wechat.util.WeiXinMessageReplyUtils;
@ -23,27 +27,22 @@ import java.util.Map;
/**
/**
 * Created by Reece on 2017/5/18.
 * Created by Reece on 2017/5/18.
 */
 */
public class SignAgainJob implements Job {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private PatientService patientService;
public class SignAgainJob extends WeixinBaseController implements Job {
    @Override
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
    public void execute(JobExecutionContext context) throws JobExecutionException {
        try {
        try {
            System.out.println("sign again job start1 SignAgainJob");
            System.out.println("sign again job start");
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
//            Calendar today = Calendar.getInstance();
            WechatController wechatController = new WechatController();
            wechatController.sendNews();
            System.out.println("sign again job end1 SignAgainJob");
            System.out.println(" ============job ===========>");
            String accessToken = getAccessToken();
//            SendNews sendNews = new SendNews();
            SendNews.sendNews(accessToken);
            System.out.println(" ==============================>");
            System.out.println("sign again job end");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            System.out.println("sign end job failed1 SignAgainJob");
            System.out.println("sign end job failed");
        }
        }
    }
    }
}
}

+ 15 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/deviece/PatientHealthTimeDao.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.repository.deviece;
package com.yihu.wlyy.repository.deviece;
import com.yihu.wlyy.entity.device.PatientHealthTime;
import com.yihu.wlyy.entity.device.PatientHealthTime;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -12,4 +13,18 @@ public interface PatientHealthTimeDao extends PagingAndSortingRepository<Patient
    @Query(value = "select t.* from wlyy_patient_health_time t where t.del = 1 and t.user = ?1 and t.device_sn = ?2 ", nativeQuery = true)
    @Query(value = "select t.* from wlyy_patient_health_time t where t.del = 1 and t.user = ?1 and t.device_sn = ?2 ", nativeQuery = true)
    PatientHealthTime findByUserAndSN(String user, String deviceSN);
    PatientHealthTime findByUserAndSN(String user, String deviceSN);
    //    根据居民和设备sn码修改自定义的血糖时间段
    @Modifying
    @Query("update PatientHealthTime t set t.fastingStart = ?1,t.fastingEnd = ?2,t.afterBreakfastStart = ?3,t.afterBreakfastEnd = ?4," +
            "t.beforeLunchStart = ?5 ,t.beforeLunchEnd = ?6 ,t.afterLunchStart = ?7,t.afterLunchEnd = ?8 ,t.beforeDinnerStart = ?9,t.beforeDinnerEnd = ?10," +
            "t.afterDinnerStart = ?11,t.afterDinnerEnd = ?12,t.beforeSleepStart = ?13,t.beforeSleepEnd = ?14 where t.del = 1 and t.user = ?15 and t.deviceSN = ?16 ")
    int modifyByUserAndSN(String fastingStart, String fastingEnd, String afterBreakfastStart, String afterBreakfastEnd, String beforeLunchStart, String beforeLunchEnd,
                          String afterLunchStart, String afterLunchEnd, String beforeDinnerStart, String beforeDinnerEnd, String afterDinnerStart, String afterDinnerEnd,
                          String beforeSleepStart, String beforeSleepEnd, String user, String deviceSN);
    //    根据居民和设备sn码删除自定义的血糖时间段
    @Modifying
    @Query("update PatientHealthTime t set t.del = 0 where t.user = ?1 and t.deviceSN = ?2 ")
    int deleteByUserAndSN(String user, String deviceSN);
}
}

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/MedicinesDao.java

@ -18,4 +18,6 @@ public interface MedicinesDao extends PagingAndSortingRepository<Medicines, Long
	@Query("select a from Medicines a where a.type = ?1 and a.del = '1'")
	@Query("select a from Medicines a where a.type = ?1 and a.del = '1'")
	List<Medicines> findAll(int type);
	List<Medicines> findAll(int type);
	Medicines findByCode(String code);
}
}

+ 21 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientHealthRecordDietDao.java

@ -3,23 +3,35 @@ package com.yihu.wlyy.repository.patient;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.patient.PatientHealthRecordDiet;
import com.yihu.wlyy.entity.patient.PatientHealthRecordDiet;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Date;
import java.util.Date;
public interface PatientHealthRecordDietDao extends PagingAndSortingRepository<PatientHealthRecordDiet, Long>, JpaSpecificationExecutor<PatientHealthRecordDiet> {
public interface PatientHealthRecordDietDao extends PagingAndSortingRepository<PatientHealthRecordDiet, Long>, JpaSpecificationExecutor<PatientHealthRecordDiet> {
	// 查询患者标识健康记录
	@Query("select a from PatientHealthRecordDiet a where a.patient = ?1 and a.del = '1'")
	Iterable<PatientHealthRecordDiet> findByPatient(String patient);
	
	// 查询最近的健康记录
	@Query("SELECT a FROM PatientHealthRecordDiet a WHERE a.patient = ?1 and a.del = '1' ORDER BY a.czrq DESC")
	Page<PatientHealthRecordDiet> findRecentByPatient(String patient, Pageable pageRequest);
    // 查询患者标识健康记录
    @Query("select a from PatientHealthRecordDiet a where a.patient = ?1 and a.del = '1'")
    Iterable<PatientHealthRecordDiet> findByPatient(String patient);
	@Query("SELECT a FROM PatientHealthRecordDiet a WHERE a.patient = ?1 and a.recordDate >= ?2 and a.recordDate <= ?3 and a.del = '1' ORDER BY a.recordDate DESC")
	Page<PatientHealthRecordDiet> findDietByPatient(String patient, Date start, Date end, Pageable pageRequest);
    // 查询最近的健康记录
    @Query("SELECT a FROM PatientHealthRecordDiet a WHERE a.patient = ?1 and a.del = '1' ORDER BY a.czrq DESC")
    Page<PatientHealthRecordDiet> findRecentByPatient(String patient, Pageable pageRequest);
    @Query("SELECT a FROM PatientHealthRecordDiet a WHERE a.patient = ?1 and a.recordDate >= ?2 and a.recordDate <= ?3 and a.del = '1' ORDER BY a.recordDate DESC")
    Page<PatientHealthRecordDiet> findDietByPatient(String patient, Date start, Date end, Pageable pageRequest);
    //	修改饮食记录
    @Modifying
    @Query("update PatientHealthRecordDiet a set a.recordDate = ?2,a.content = ?3,a.images= ?4 where a.id= ?1 ")
    void modifyDiet(long id,Date value1, String value2, String value3);
    //	删除饮食记录
    @Modifying
    @Query("update PatientHealthRecordDiet a set a.del = 0 where a.id= ?1 ")
    void deleteDiet(long id);
}
}

+ 20 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientHealthRecordMedicationDao.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.repository.patient;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -12,14 +13,24 @@ import java.util.Date;
public interface PatientHealthRecordMedicationDao extends PagingAndSortingRepository<PatientHealthRecordMedication, Long>, JpaSpecificationExecutor<PatientHealthRecordMedication> {
public interface PatientHealthRecordMedicationDao extends PagingAndSortingRepository<PatientHealthRecordMedication, Long>, JpaSpecificationExecutor<PatientHealthRecordMedication> {
	// 查询患者标识健康记录
	@Query("select a from PatientHealthRecordMedication a where a.patient = ?1 and a.del = '1'")
	Iterable<PatientHealthRecordMedication> findByPatient(String patient);
	
	// 查询最近的健康记录
	@Query("SELECT a FROM PatientHealthRecordMedication a WHERE a.patient = ?1 and a.del = '1' ORDER BY a.czrq DESC")
	Page<PatientHealthRecordMedication> findRecentByPatient(String patient, Pageable pageRequest);
    // 查询患者标识健康记录
    @Query("select a from PatientHealthRecordMedication a where a.patient = ?1 and a.del = '1'")
    Iterable<PatientHealthRecordMedication> findByPatient(String patient);
	@Query("SELECT a FROM PatientHealthRecordMedication a WHERE a.patient = ?1 and a.recordDate >= ?2 and a.recordDate <= ?3 and a.del = '1' ORDER BY a.recordDate DESC")
	Page<PatientHealthRecordMedication> findMedicalByPatient(String patient, Date start,Date end, Pageable pageRequest);
    // 查询最近的健康记录
    @Query("SELECT a FROM PatientHealthRecordMedication a WHERE a.patient = ?1 and a.del = '1' ORDER BY a.czrq DESC")
    Page<PatientHealthRecordMedication> findRecentByPatient(String patient, Pageable pageRequest);
    @Query("SELECT a FROM PatientHealthRecordMedication a WHERE a.patient = ?1 and a.recordDate >= ?2 and a.recordDate <= ?3 and a.del = '1' ORDER BY a.recordDate DESC")
    Page<PatientHealthRecordMedication> findMedicalByPatient(String patient, Date start, Date end, Pageable pageRequest);
    //	修改用药记录
    @Modifying
    @Query("update PatientHealthRecordMedication a set a.recordDate = ?2,a.medicines = ?3,a.medicinesName= ?4 where a.id= ?1 ")
    void modifyMedication(long id, Date value1, String value2,String medicationName);
    //	删除用药记录
    @Modifying
    @Query("update PatientHealthRecordMedication a set a.del = 0 where a.id= ?1 ")
    void deleteMedication(long id);
}
}

+ 20 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientHealthRecordSportsDao.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.repository.patient;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -12,15 +13,25 @@ import java.util.Date;
public interface PatientHealthRecordSportsDao extends PagingAndSortingRepository<PatientHealthRecordSports, Long>, JpaSpecificationExecutor<PatientHealthRecordSports> {
public interface PatientHealthRecordSportsDao extends PagingAndSortingRepository<PatientHealthRecordSports, Long>, JpaSpecificationExecutor<PatientHealthRecordSports> {
	// 查询患者标识健康记录
	@Query("select a from PatientHealthRecordSports a where a.patient = ?1 and a.del = '1'")
	Iterable<PatientHealthRecordSports> findByPatient(String patient);
	
	// 查询最近的健康记录
	@Query("SELECT a FROM PatientHealthRecordSports a WHERE a.patient = ?1 and a.del = '1' ORDER BY a.czrq DESC")
	Page<PatientHealthRecordSports> findRecentByPatient(String patient, Pageable pageRequest);
    // 查询患者标识健康记录
    @Query("select a from PatientHealthRecordSports a where a.patient = ?1 and a.del = '1'")
    Iterable<PatientHealthRecordSports> findByPatient(String patient);
	@Query("select a from PatientHealthRecordSports a where a.patient = ?1 and a.recordDate >= ?2 and a.recordDate <= ?3 and a.del = '1' order by a.recordDate desc")
	Page<PatientHealthRecordSports> findSportsByPatient(String patient, Date start, Date end, Pageable pageRequest);
    // 查询最近的健康记录
    @Query("SELECT a FROM PatientHealthRecordSports a WHERE a.patient = ?1 and a.del = '1' ORDER BY a.czrq DESC")
    Page<PatientHealthRecordSports> findRecentByPatient(String patient, Pageable pageRequest);
    @Query("select a from PatientHealthRecordSports a where a.patient = ?1 and a.recordDate >= ?2 and a.recordDate <= ?3 and a.del = '1' order by a.recordDate desc")
    Page<PatientHealthRecordSports> findSportsByPatient(String patient, Date start, Date end, Pageable pageRequest);
    //	修改运动记录
    @Modifying
    @Query("update PatientHealthRecordSports a set a.recordDate = ?2,a.sportsTime= ?3 ,a.sportsType = ?4,a.sportsTypeName= ?5,a.sports = ?6 ,a.sportsName= ?7 where a.id= ?1 ")
    void modifySports(long id, Date value1, Double value2, String value3, String typeName, String value4, String sportName);
    //	删除运动记录
    @Modifying
    @Query("update PatientHealthRecordSports a set a.del = 0 where a.id= ?1 ")
    void deleteSports(long id);
}
}

+ 18 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -42,6 +42,9 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    SignFamily findByTeamCode(String TeamCode);
    SignFamily findByTeamCode(String TeamCode);
    @Query("select a from SignFamily a where a.teamCode = ?1 and a.type = 2 and a.status >= 0")
    List<SignFamily> findByTeamCodeIsValid(String teamCode);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0")
    @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);
    SignFamily findByDoctorPatient(String doctor, String patient);
@ -67,6 +70,18 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @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")
    @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);
    List<SignFamily> findByDoctorAndPatient(String doctor, String patient);
    @Query(value = "select a from SignFamily a where a.doctor =?1 and a.patient = ?2 and a.status =0 and a.signYear =?3")
    List<SignFamily> findByDoctorAndPatientOverDue(String doctor,String patient,String signYear);
    @Query(value = "select a from SignFamily a where a.doctorHealth =?1 and a.patient = ?2 and a.status =0 and a.signYear =?3")
    List<SignFamily> findByDoctorHealthAndPatient(String doctorHealth,String patient,String signYear);
    @Query(value = "select a from SignFamily a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 1 and a.expensesStatus ='1'")
    List<SignFamily> findByDoctorAndPatientIsValid(String doctor,String patient,String signYear);
    @Query(value = "select a from SignFamily a where a.doctorHealth =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 1 and a.expensesStatus ='1'")
    List<SignFamily> findByDoctorHealthAndPatientIsValid(String doctorHealth,String patient,String signYear);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.status = 1 and a.type = 2")
    @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);
    SignFamily findByFamilyDoctorAndPatient(String doctor, String patient);
@ -271,6 +286,9 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status in (0,1,2)")
    @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);
    SignFamily findFamilySignByPatient(String patientCode);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status =-4 and a.signYear =?2")
    SignFamily findFamilySignByPatientOverDue(String patientCode,String signYear);
    @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)")
    @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);
    List<Object> findDoctorSignPatients(String doctor);

+ 10 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewDao.java

@ -27,10 +27,17 @@ public interface SignFamilyRenewDao extends PagingAndSortingRepository<SignFamil
    @Query(value = "select a from SignFamilyRenew a where a.patient = ?1 and a.status <> -1 and a.status <> -2")
    @Query(value = "select a from SignFamilyRenew a where a.patient = ?1 and a.status <> -1 and a.status <> -2")
    List<SignFamilyRenew> findAllActiveSignByPatient(String patient);
    List<SignFamilyRenew> findAllActiveSignByPatient(String patient);
    @Query(value = "select a from SignFamilyRenew a where a.doctor =?1 and a.patient = ?2 ")
    List<SignFamilyRenew> findByDoctorAndPatient(String doctor,String patient);
    @Query(value = "select a from SignFamilyRenew a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3")
    List<SignFamilyRenew> findByDoctorAndPatient(String doctor,String patient,String signYear);
    List<SignFamilyRenew> findByDoctorHealthAndPatient(String doctorHealth,String patient);
    @Query(value = "select a from SignFamilyRenew a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 1 and a.expensesStatus ='1'")
    List<SignFamilyRenew> findByDoctorAndPatientIsValid(String doctor,String patient,String signYear);
    @Query(value = "select a from SignFamilyRenew a where a.doctorHealth =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 1 and a.expensesStatus ='1'")
    List<SignFamilyRenew> findByDoctorHealthAndPatientIsValid(String doctorHealth,String patient,String signYear);
    @Query(value = "select a from SignFamilyRenew a where a.doctorHealth =?1 and a.patient = ?2 and a.signYear =?3")
    List<SignFamilyRenew> findByDoctorHealthAndPatient(String doctorHealth,String patient,String signYear);
    // 查询患者已生效的家庭续签约
    // 查询患者已生效的家庭续签约
    @Query("select a from SignFamilyRenew a where a.patient = ?1 and a.type = 2 and a.status = 0")
    @Query("select a from SignFamilyRenew a where a.patient = ?1 and a.type = 2 and a.status = 0")

+ 0 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/statistics/WlyyQuotaResultDao.java

@ -12,13 +12,5 @@ import java.util.List;
 * Created by Administrator on 2016/8/16.
 * Created by Administrator on 2016/8/16.
 */
 */
public interface WlyyQuotaResultDao extends PagingAndSortingRepository<WlyyQuotaResult, String>, JpaSpecificationExecutor<WlyyQuotaResult> {
public interface WlyyQuotaResultDao extends PagingAndSortingRepository<WlyyQuotaResult, String>, JpaSpecificationExecutor<WlyyQuotaResult> {
    @Query(" FROM WlyyQuotaResult a WHERE a.quotaDate =?1 and a.quatoCode=?2")
    List<WlyyQuotaResult> findByYesterday(String yesterday, String quatoCode);
    @Modifying
    @Query(" delete FROM WlyyQuotaResult a WHERE a.quotaDate =?1 and a.quatoCode=?2")
    void deleteByDateAndCode(String yesterday, String quatoCode);
    @Query(" FROM WlyyQuotaResult a WHERE a.level1Type =?1 and a.qkdoctorJobName != ?2 and a.quatoCode=1")
    List<WlyyQuotaResult> findByLevel1TypeAndQkdoctorJobName(String level1Type, String qkdoctorJobName);
}
}

+ 35 - 21
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java

@ -505,27 +505,41 @@ public class PatientDeviceService extends BaseService {
     */
     */
    public void setBloodTime(String user, String deviceSN, String fastingStart, String fastingEnd, String afterBreakfastStart, String afterBreakfastEnd, String beforeLunchStart, String beforeLunchEnd,
    public void setBloodTime(String user, String deviceSN, String fastingStart, String fastingEnd, String afterBreakfastStart, String afterBreakfastEnd, String beforeLunchStart, String beforeLunchEnd,
                             String afterLunchStart, String afterLunchEnd, String beforeDinnerStart, String beforeDinnerEnd, String afterDinnerStart, String afterDinnerEnd,
                             String afterLunchStart, String afterLunchEnd, String beforeDinnerStart, String beforeDinnerEnd, String afterDinnerStart, String afterDinnerEnd,
                             String beforeSleepStart, String beforeSleepEnd) throws  Exception{
        PatientHealthTime patientHealthTime = new PatientHealthTime();
        patientHealthTime.setUser(user);
        patientHealthTime.setDeviceSN(deviceSN);
        patientHealthTime.setFastingStart(fastingStart);
        patientHealthTime.setFastingEnd(fastingEnd);
        patientHealthTime.setAfterBreakfastStart(afterBreakfastStart);
        patientHealthTime.setAfterBreakfastEnd(afterBreakfastEnd);
        patientHealthTime.setBeforeLunchStart(beforeLunchStart);
        patientHealthTime.setBeforeLunchEnd(beforeLunchEnd);
        patientHealthTime.setAfterLunchStart(afterLunchStart);
        patientHealthTime.setAfterLunchEnd(afterLunchEnd);
        patientHealthTime.setBeforeDinnerStart(beforeDinnerStart);
        patientHealthTime.setBeforeDinnerEnd(beforeDinnerEnd);
        patientHealthTime.setAfterDinnerStart(afterDinnerStart);
        patientHealthTime.setAfterDinnerEnd(afterDinnerEnd);
        patientHealthTime.setBeforeSleepStart(beforeSleepStart);
        patientHealthTime.setBeforeSleepEnd(beforeSleepEnd);
        patientHealthTime.setDel(1);
        patientHealthTime.setCzrq(new Date());
        patientHealthTimeDao.save(patientHealthTime);
                             String beforeSleepStart, String beforeSleepEnd) throws Exception {
        if (StringUtils.isEmpty(fastingStart) && StringUtils.isEmpty(fastingEnd) && StringUtils.isEmpty(afterBreakfastStart) && StringUtils.isEmpty(afterBreakfastEnd) && StringUtils.isEmpty(beforeLunchStart)
                && StringUtils.isEmpty(beforeLunchEnd) && StringUtils.isEmpty(afterLunchStart) && StringUtils.isEmpty(afterLunchEnd) && StringUtils.isEmpty(beforeDinnerStart) && StringUtils.isEmpty(beforeDinnerEnd) && StringUtils.isEmpty(afterDinnerStart)
                && StringUtils.isEmpty(afterDinnerEnd) && StringUtils.isEmpty(beforeSleepStart) && StringUtils.isEmpty(beforeSleepEnd)) {
            patientHealthTimeDao.deleteByUserAndSN(user,deviceSN);
            return;
        }
        PatientHealthTime healthTime = patientHealthTimeDao.findByUserAndSN(user, deviceSN);
        if (healthTime == null) {
            PatientHealthTime patientHealthTime = new PatientHealthTime();
            patientHealthTime.setUser(user);
            patientHealthTime.setDeviceSN(deviceSN);
            patientHealthTime.setFastingStart(fastingStart);
            patientHealthTime.setFastingEnd(fastingEnd);
            patientHealthTime.setAfterBreakfastStart(afterBreakfastStart);
            patientHealthTime.setAfterBreakfastEnd(afterBreakfastEnd);
            patientHealthTime.setBeforeLunchStart(beforeLunchStart);
            patientHealthTime.setBeforeLunchEnd(beforeLunchEnd);
            patientHealthTime.setAfterLunchStart(afterLunchStart);
            patientHealthTime.setAfterLunchEnd(afterLunchEnd);
            patientHealthTime.setBeforeDinnerStart(beforeDinnerStart);
            patientHealthTime.setBeforeDinnerEnd(beforeDinnerEnd);
            patientHealthTime.setAfterDinnerStart(afterDinnerStart);
            patientHealthTime.setAfterDinnerEnd(afterDinnerEnd);
            patientHealthTime.setBeforeSleepStart(beforeSleepStart);
            patientHealthTime.setBeforeSleepEnd(beforeSleepEnd);
            patientHealthTime.setDel(1);
            patientHealthTime.setCzrq(new Date());
            patientHealthTimeDao.save(patientHealthTime);
        } else {
            int rows = patientHealthTimeDao.modifyByUserAndSN(fastingStart, fastingEnd, afterBreakfastStart, afterBreakfastEnd, beforeLunchStart, beforeLunchEnd,
                    afterLunchStart, afterLunchEnd, beforeDinnerStart, beforeDinnerEnd, afterDinnerStart, afterDinnerEnd, beforeSleepStart, beforeSleepEnd, user, deviceSN);
            int str = rows;
        }
    }
    }

+ 141 - 73
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -3,17 +3,20 @@ package com.yihu.wlyy.service.app.health;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.dict.Medicines;
import com.yihu.wlyy.entity.education.Sports;
import com.yihu.wlyy.entity.education.SportsType;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.dict.MedicinesDao;
import com.yihu.wlyy.repository.education.SportsDao;
import com.yihu.wlyy.repository.education.SportsTypeDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.PatientHealthStandardDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.task.HealthIndexUploadTask;
import com.yihu.wlyy.task.HealthIndexUploadTask;
@ -70,9 +73,72 @@ public class PatientHealthIndexService extends BaseService {
    private PatientDeviceDao patientDeviceDao;
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    @Autowired
    private DoctorWorkTimeService doctorWorkTimeService;
    private DoctorWorkTimeService doctorWorkTimeService;
    @Autowired
    private PatientHealthRecordDietDao patientHealthRecordDietDao;
    @Autowired
    private PatientHealthRecordSportsDao patientHealthRecordSportsDao;
    @Autowired
    private PatientHealthRecordMedicationDao patientHealthRecordMedicationDao;
    @Autowired
    private SportsTypeDao sportsTypeDao;
    @Autowired
    private SportsDao sportsDao;
    @Autowired
    private MedicinesDao medicinesDao;
    /**
     * 更改保健记录(包括手动记录的修改和所有的删除)
     *
     * @param id
     * @param type   饮食1,运动2,用药3
     * @param value1 记录时间
     * @param value2 饮食内容CONTETN  时长 用药
     * @param value3 上传图片 强度
     * @param value4 运动项目
     */
    public void modifyHealthCare(long id, int type, String value1, String value2, String value3, String value4) throws Exception {
        //value类字段值均为空为删除
        if (StringUtils.isEmpty(value1) && StringUtils.isEmpty(value2) && StringUtils.isEmpty(value3) && StringUtils.isEmpty(value4)) {
            switch (type) {
                case 1:
                    patientHealthRecordDietDao.deleteDiet(id);
                    break;
                case 2:
                    patientHealthRecordSportsDao.deleteSports(id);
                    break;
                case 3:
                    patientHealthRecordMedicationDao.deleteMedication(id);
                    break;
            }
        } else {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date recordDate = sdf.parse(value1);
            switch (type) {
                case 1:
                    patientHealthRecordDietDao.modifyDiet(id, recordDate, value2, value3);
                    break;
                case 2:
                    SportsType sportsType = sportsTypeDao.findByCode(value3);
                    String typeName = sportsType.getName();
                    Sports sport = sportsDao.findByCode(value4);
                    String sportName = sport.getName();
                    Double sportsTime = Double.parseDouble(value2);
                    patientHealthRecordSportsDao.modifySports(id, recordDate, sportsTime, value3, typeName, value4, sportName);
                    break;
                case 3:
                    Medicines medicines = medicinesDao.findByCode(value2);
                    String medicinesName = medicines.getName();
                    patientHealthRecordMedicationDao.modifyMedication(id, recordDate, value2, medicinesName);
                    break;
            }
        }
    }
    //更改接口(包括手动记录的修改和所有的删除)
    //更改接口(包括手动记录的修改和所有的删除)
    public void modify(long id, String value1, String value2, String value3, String value4) {
    public void modify(long id, String recordDate, String value1, String value2, String value3, String value4) throws Exception {
        Date record = null;
        Date time = new Date();
        Date time = new Date();
        String sql = "";
        String sql = "";
//            字段值均为空为删除
//            字段值均为空为删除
@ -81,20 +147,24 @@ public class PatientHealthIndexService extends BaseService {
            jdbcTemplate.update(sql, id);
            jdbcTemplate.update(sql, id);
        }
        }
        sql = " update device.wlyy_patient_health_index a set ";
        sql = " update device.wlyy_patient_health_index a set ";
        if (StringUtils.isNotEmpty(recordDate)) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            record = sdf.parse(recordDate);
        }
        if (StringUtils.isNotEmpty(value1)) {
        if (StringUtils.isNotEmpty(value1)) {
            sql += " a.value1 = " +value1+" , ";
            sql += " a.value1 = " + value1 + " , ";
        }
        }
        if (StringUtils.isNotEmpty(value2)) {
        if (StringUtils.isNotEmpty(value2)) {
            sql +=  " a.value2 = " +value2+" , ";
            sql += " a.value2 = " + value2 + " , ";
        }
        }
        if (StringUtils.isNotEmpty(value3)) {
        if (StringUtils.isNotEmpty(value3)) {
            sql +=  " a.value3 = " +value3+" , ";
            sql += " a.value3 = " + value3 + " , ";
        }
        }
        if (StringUtils.isNotEmpty(value4)) {
        if (StringUtils.isNotEmpty(value4)) {
            sql += " a.value4 = " +value4+", ";
            sql += " a.value4 = " + value4 + ", ";
        }
        }
         sql += " a.czrq = ?  where a.device_sn is null and a.id =? ";
        jdbcTemplate.update(sql, time, id);
        sql += "  a.record_date = ? ,a.czrq = ?  where a.device_sn is null and a.id =? ";
        jdbcTemplate.update(sql, record, time, id);
    }
    }
    /**
    /**
@ -438,57 +508,57 @@ public class PatientHealthIndexService extends BaseService {
     */
     */
    private com.alibaba.fastjson.JSONObject getPatientXT_Json(String patient, String dateString) {
    private com.alibaba.fastjson.JSONObject getPatientXT_Json(String patient, String dateString) {
        com.alibaba.fastjson.JSONObject obj = new com.alibaba.fastjson.JSONObject();
        com.alibaba.fastjson.JSONObject obj = new com.alibaba.fastjson.JSONObject();
        obj.put("user",patient);
        obj.put("user", patient);
        boolean hadData = false;
        boolean hadData = false;
        Date date = DateUtil.strToDateShort(dateString);
        Date date = DateUtil.strToDateShort(dateString);
        /***************** 按时间排序 ***************************/
        /***************** 按时间排序 ***************************/
        List<DevicePatientHealthIndex> list = patientHealthIndexDao.findByDateNative(patient, dateString);
        List<DevicePatientHealthIndex> list = patientHealthIndexDao.findByDateNative(patient, dateString);
        if (list != null && list.size() > 0) {
        if (list != null && list.size() > 0) {
            obj.put("type",1);
            obj.put("czrq",date);
            obj.put("recordDate",date);
            obj.put("sortDate",date);
            obj.put("type", 1);
            obj.put("czrq", date);
            obj.put("recordDate", date);
            obj.put("sortDate", date);
            for (DevicePatientHealthIndex item : list) {
            for (DevicePatientHealthIndex item : list) {
                String data = item.getValue1();
                String data = item.getValue1();
                String dataType = item.getValue2();
                String dataType = item.getValue2();
                String recordDate =DateUtil.dateToStr(item.getRecordDate(), DateUtil.YYYY_MM_DD_HH_MM_SS);
                String recordDate = DateUtil.dateToStr(item.getRecordDate(), DateUtil.YYYY_MM_DD_HH_MM_SS);
                Long id = item.getId();
                Long id = item.getId();
                if (data != null && dataType != null) {
                if (data != null && dataType != null) {
                    if (dataType.equals("1")) {
                    if (dataType.equals("1")) {
                        obj.put("value1",data);
                        obj.put("time1",recordDate);
                        obj.put("id1",id);
                        obj.put("value1", data);
                        obj.put("time1", recordDate);
                        obj.put("id1", id);
                        hadData = true;
                        hadData = true;
                    } else if (dataType.equals("2")) {
                    } else if (dataType.equals("2")) {
                        obj.put("value2",data);
                        obj.put("time2",recordDate);
                        obj.put("id2",id);
                        obj.put("value2", data);
                        obj.put("time2", recordDate);
                        obj.put("id2", id);
                        hadData = true;
                        hadData = true;
                    } else if (dataType.equals("3")) {
                    } else if (dataType.equals("3")) {
                        obj.put("value3",data);
                        obj.put("time3",recordDate);
                        obj.put("id3",id);
                        obj.put("value3", data);
                        obj.put("time3", recordDate);
                        obj.put("id3", id);
                        hadData = true;
                        hadData = true;
                    } else if (dataType.equals("4")) {
                    } else if (dataType.equals("4")) {
                        obj.put("value4",data);
                        obj.put("time4",recordDate);
                        obj.put("id4",id);
                        obj.put("value4", data);
                        obj.put("time4", recordDate);
                        obj.put("id4", id);
                        hadData = true;
                        hadData = true;
                    } else if (dataType.equals("5")) {
                    } else if (dataType.equals("5")) {
                        obj.put("value5",data);
                        obj.put("time5",recordDate);
                        obj.put("id5",id);
                        obj.put("value5", data);
                        obj.put("time5", recordDate);
                        obj.put("id5", id);
                        hadData = true;
                        hadData = true;
                    } else if (dataType.equals("6")) {
                    } else if (dataType.equals("6")) {
                        obj.put("value6",data);
                        obj.put("time6",recordDate);
                        obj.put("id6",id);
                        obj.put("value6", data);
                        obj.put("time6", recordDate);
                        obj.put("id6", id);
                        hadData = true;
                        hadData = true;
                    } else if (dataType.equals("7")) {
                    } else if (dataType.equals("7")) {
                        obj.put("value7",data);
                        obj.put("time7",recordDate);
                        obj.put("id7",id);
                        obj.put("value7", data);
                        obj.put("time7", recordDate);
                        obj.put("id7", id);
                        hadData = true;
                        hadData = true;
                    }
                    }
                }
                }
@ -595,6 +665,7 @@ public class PatientHealthIndexService extends BaseService {
     */
     */
    public DevicePatientHealthIndex addPatientHealthIndex(String data, String type, String patientCode, String deviceSn) throws Exception {
    public DevicePatientHealthIndex addPatientHealthIndex(String data, String type, String patientCode, String deviceSn) throws Exception {
        Map<String, String> map = (Map<String, String>) objectMapper.readValue(data, Map.class);
        Map<String, String> map = (Map<String, String>) objectMapper.readValue(data, Map.class);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        DevicePatientHealthIndex obj = new DevicePatientHealthIndex();
        DevicePatientHealthIndex obj = new DevicePatientHealthIndex();
        Date currentTime = new Date();
        Date currentTime = new Date();
@ -602,7 +673,9 @@ public class PatientHealthIndexService extends BaseService {
        obj.setDel("1");
        obj.setDel("1");
        Date time = currentTime;
        Date time = currentTime;
        if (map.containsKey("time")) {
        if (map.containsKey("time")) {
            time = DateUtil.strToDate(map.get("time"));
            String da = map.get("time");
//            time = DateUtil.strToDate(da);
            time = sdf.parse(da);
        }
        }
        obj.setRecordDate(time);    //记录时间
        obj.setRecordDate(time);    //记录时间
        obj.setSortDate(time);      //排序时间
        obj.setSortDate(time);      //排序时间
@ -738,27 +811,27 @@ public class PatientHealthIndexService extends BaseService {
    /**
    /**
     * 按时间段查询患者健康指标
     * 按时间段查询患者健康指标
     *
     *
     * @param type  健康指标类型(1血糖,2血压,3体重,4腰围)
     * @param type    健康指标类型(1血糖,2血压,3体重,4腰围)
     * @param gi_type 血糖就餐时间段(早餐前,早餐后等)
     * @param gi_type 血糖就餐时间段(早餐前,早餐后等)
     * @param begin 开始时间
     * @param end   结束时间
     * @param begin   开始时间
     * @param end     结束时间
     * @return
     * @return
     */
     */
    public List<DevicePatientHealthIndex> findChartByPatient(String patient, int type,int gi_type, String begin, String end) {
    public List<DevicePatientHealthIndex> findChartByPatient(String patient, int type, int gi_type, String begin, String end) {
        List<DevicePatientHealthIndex> re = new ArrayList<>();
        List<DevicePatientHealthIndex> re = new ArrayList<>();
        Date startDate = DateUtil.strToDate(begin, DateUtil.YYYY_MM_DD_HH_MM_SS);
        Date startDate = DateUtil.strToDate(begin, DateUtil.YYYY_MM_DD_HH_MM_SS);
        Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS);
        Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS);
        if(gi_type != 0){
        if (gi_type != 0) {
            Sort sort = new Sort(Direction.ASC, "recordDate");
            Sort sort = new Sort(Direction.ASC, "recordDate");
            PageRequest pageRequest = new PageRequest(0, 1000, sort);
            PageRequest pageRequest = new PageRequest(0, 1000, sort);
            re = patientHealthIndexDao.findIndexByPatientNative(patient, type,gi_type+"", startDate, endDate, pageRequest.getOffset(),pageRequest.getPageSize());
            re = patientHealthIndexDao.findIndexByPatientNative(patient, type, gi_type + "", startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
        }else{
        } else {
            // 排序
            // 排序
            Sort sort = new Sort(Direction.ASC, "recordDate");
            Sort sort = new Sort(Direction.ASC, "recordDate");
            PageRequest pageRequest = new PageRequest(0, 1000, sort);
            PageRequest pageRequest = new PageRequest(0, 1000, sort);
            re = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(),pageRequest.getPageSize());
            re = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
        }
        }
        return re;
        return re;
@ -787,7 +860,7 @@ public class PatientHealthIndexService extends BaseService {
        {
        {
            PageRequest pageRequest = new PageRequest(page, pageSize);
            PageRequest pageRequest = new PageRequest(page, pageSize);
            //根据时间过滤排序
            //根据时间过滤排序
            List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest.getOffset(),pageRequest.getPageSize());
            List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
            if (dateList != null && dateList.size() > 0) {
            if (dateList != null && dateList.size() > 0) {
                for (String dateString : dateList) {
                for (String dateString : dateList) {
                    DevicePatientHealthIndex obj = getPatientXT(patient, dateString);
                    DevicePatientHealthIndex obj = getPatientXT(patient, dateString);
@ -800,7 +873,7 @@ public class PatientHealthIndexService extends BaseService {
            // 排序
            // 排序
            Sort sort = new Sort(Direction.DESC, "recordDate");
            Sort sort = new Sort(Direction.DESC, "recordDate");
            PageRequest pageRequest = new PageRequest(page, pageSize, sort);
            PageRequest pageRequest = new PageRequest(page, pageSize, sort);
            List<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(),pageRequest.getPageSize());
            List<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
            re = list;
            re = list;
        }
        }
        return re;
        return re;
@ -830,7 +903,7 @@ public class PatientHealthIndexService extends BaseService {
        {
        {
            PageRequest pageRequest = new PageRequest(page, pageSize);
            PageRequest pageRequest = new PageRequest(page, pageSize);
            //根据时间过滤排序
            //根据时间过滤排序
            List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest.getOffset(),pageRequest.getPageSize());
            List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
            if (dateList != null && dateList.size() > 0) {
            if (dateList != null && dateList.size() > 0) {
                for (String dateString : dateList) {
                for (String dateString : dateList) {
                    com.alibaba.fastjson.JSONObject obj = getPatientXT_Json(patient, dateString);
                    com.alibaba.fastjson.JSONObject obj = getPatientXT_Json(patient, dateString);
@ -919,48 +992,48 @@ public class PatientHealthIndexService extends BaseService {
                JSONObject json = new JSONObject();
                JSONObject json = new JSONObject();
                // 设置健康指标类型(1血糖,2血压,3体重,4腰围)
                // 设置健康指标类型(1血糖,2血压,3体重,4腰围)
                json.put("type", phi.getType());
                json.put("type", phi.getType());
                if(1== phi.getType()&&StringUtils.isNotBlank(phi.getValue2())){
                if (1 == phi.getType() && StringUtils.isNotBlank(phi.getValue2())) {
                    int gi_type = Integer.parseInt(phi.getValue2());
                    int gi_type = Integer.parseInt(phi.getValue2());
                    switch (gi_type) {
                    switch (gi_type) {
                        case 1:
                        case 1:
                            // 设置血糖/收缩压/体重/腰围/早餐前空腹
                            // 设置血糖/收缩压/体重/腰围/早餐前空腹
                            json.put("value1", phi.getValue1());
                            json.put("value1", phi.getValue1());
                            json.put("time1",phi.getRecordDate());
                            json.put("time1", phi.getRecordDate());
                            break;
                            break;
                        case 2:
                        case 2:
                            // 设置舒张压/早餐后血糖
                            // 设置舒张压/早餐后血糖
                            json.put("value2", phi.getValue2());
                            json.put("value2", phi.getValue2());
                            json.put("time2",phi.getRecordDate());
                            json.put("time2", phi.getRecordDate());
                            break;
                            break;
                        case 3:
                        case 3:
                            // 设置午餐前血糖
                            // 设置午餐前血糖
                            json.put("value3", phi.getValue3());
                            json.put("value3", phi.getValue3());
                            json.put("time3",phi.getRecordDate());
                            json.put("time3", phi.getRecordDate());
                            break;
                            break;
                        case 4:
                        case 4:
                            // 设置午餐后血糖
                            // 设置午餐后血糖
                            json.put("value4", phi.getValue4());
                            json.put("value4", phi.getValue4());
                            json.put("time4",phi.getRecordDate());
                            json.put("time4", phi.getRecordDate());
                            break;
                            break;
                        case 5:
                        case 5:
                            // 设置晚餐前血糖
                            // 设置晚餐前血糖
                            json.put("value5", phi.getValue5());
                            json.put("value5", phi.getValue5());
                            json.put("time5",phi.getRecordDate());
                            json.put("time5", phi.getRecordDate());
                            break;
                            break;
                        case 6:
                        case 6:
                            // 设置晚餐后血糖
                            // 设置晚餐后血糖
                            json.put("value6", phi.getValue6());
                            json.put("value6", phi.getValue6());
                            json.put("time6",phi.getRecordDate());
                            json.put("time6", phi.getRecordDate());
                            break;
                            break;
                        case 7:
                        case 7:
                            // 设置睡前血糖
                            // 设置睡前血糖
                            json.put("value7", phi.getValue7());
                            json.put("value7", phi.getValue7());
                            json.put("time7",phi.getRecordDate());
                            json.put("time7", phi.getRecordDate());
                            break;
                            break;
                    }
                    }
                }else{
                    json.put("value1",phi.getValue1());
                    json.put("value2",phi.getValue2());
                } else {
                    json.put("value1", phi.getValue1());
                    json.put("value2", phi.getValue2());
                    // 设置午餐前血糖
                    // 设置午餐前血糖
                    json.put("value3", phi.getValue3());
                    json.put("value3", phi.getValue3());
                    // 设置午餐后血糖
                    // 设置午餐后血糖
@ -974,11 +1047,6 @@ public class PatientHealthIndexService extends BaseService {
                }
                }
                json.put("date", DateUtil.dateToStrShort(phi.getRecordDate()));
                json.put("date", DateUtil.dateToStrShort(phi.getRecordDate()));
                array.put(json);
                array.put(json);
            }
            }
@ -1045,15 +1113,15 @@ public class PatientHealthIndexService extends BaseService {
//                return null;
//                return null;
//            }
//            }
            return obj;
            return obj;
        } else if(type ==2) {  //其他指标
        } else if (type == 2) {  //其他指标
            return patientHealthIndexDao.findLastData(patientCode, 2);
            return patientHealthIndexDao.findLastData(patientCode, 2);
        }else{
        } else {
            return patientHealthIndexDao.findLastData(patientCode, type);
            return patientHealthIndexDao.findLastData(patientCode, type);
        }
        }
    }
    }
    public com.alibaba.fastjson.JSONObject findLastBypatient(String patientCode, int type){
        if(type==1){
    public com.alibaba.fastjson.JSONObject findLastBypatient(String patientCode, int type) {
        if (type == 1) {
            DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, 1);
            DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, 1);
            if (obj != null) {
            if (obj != null) {
                String dateString = DateUtil.dateToStrShort(obj.getRecordDate());
                String dateString = DateUtil.dateToStrShort(obj.getRecordDate());
@ -1061,11 +1129,11 @@ public class PatientHealthIndexService extends BaseService {
            } else {
            } else {
                return null;
                return null;
            }
            }
        }else{
        } else {
            DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, type);
            DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, type);
            if(obj != null){
            if (obj != null) {
                return JSON.parseObject(JSON.toJSONString(obj));
                return JSON.parseObject(JSON.toJSONString(obj));
            }else {
            } else {
                return null;
                return null;
            }
            }
        }
        }

+ 57 - 31
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -206,18 +206,18 @@ public class SignPatientLabelInfoService extends BaseService {
            json.put("wechatFocusRemind", 1);
            json.put("wechatFocusRemind", 1);
        }
        }
        String timeKey = DateUtil.dateToStr(new Date(),"yyyyMMdd");
        String flag = redisTemplate.opsForValue().get("renew:"+timeKey+":"+patient);
        if(StringUtils.isNotBlank(flag)){
            json.put("isRemindRenew","1");
        }else{
            json.put("isRemindRenew","0");
        String timeKey = DateUtil.dateToStr(new Date(), "yyyyMMdd");
        String flag = redisTemplate.opsForValue().get("renew:" + timeKey + ":" + patient);
        if (StringUtils.isNotBlank(flag)) {
            json.put("isRemindRenew", "1");
        } else {
            json.put("isRemindRenew", "0");
        }
        }
        String sql = "SELECT t.czrq FROM wlyy_sign_family_renew t WHERE t.status>=0 AND t.is_valid =0";
        String sql = "SELECT t.czrq FROM wlyy_sign_family_renew t WHERE t.status>=0 AND t.is_valid =0";
        List<Map<String,Object>> renews =  jdbcTemplate.queryForList(sql);
        if(renews!=null&&renews.size()>0){
            Map<String,Object> renew = renews.get(0);
            json.put("renewTime",renew.get("czrq"));
        List<Map<String, Object>> renews = jdbcTemplate.queryForList(sql);
        if (renews != null && renews.size() > 0) {
            Map<String, Object> renew = renews.get(0);
            json.put("renewTime", renew.get("czrq"));
        }
        }
        return json;
        return json;
@ -1275,7 +1275,7 @@ public class SignPatientLabelInfoService extends BaseService {
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public List findNoHealthSignFamilyHealth(String filter, Long teamCode,int page,int pagesize) throws Exception {
    public List findNoHealthSignFamilyHealth(String filter, Long teamCode, int page, int pagesize) throws Exception {
        List list = new ArrayList();
        List list = new ArrayList();
        String sql = "SELECT  DISTINCT " +
        String sql = "SELECT  DISTINCT " +
                "  p.photo photo, " +
                "  p.photo photo, " +
@ -1295,19 +1295,19 @@ public class SignPatientLabelInfoService extends BaseService {
                " AND ( sf.doctor_health is null or sf.doctor_health ='' ) " +
                " AND ( sf.doctor_health is null or sf.doctor_health ='' ) " +
                "  AND (p.name like ? or p.address like ? or p.idcard like ? ) " +
                "  AND (p.name like ? or p.address like ? or p.idcard like ? ) " +
                " ORDER BY  p.name DESC,p.address DESC, p.idcard DESC " +
                " ORDER BY  p.name DESC,p.address DESC, p.idcard DESC " +
                " limit "+(page-1)*pagesize+","+pagesize;
                " limit " + (page - 1) * pagesize + "," + pagesize;
        List<Map<String, Object>> datas = jdbcTemplate.queryForList(sql, teamCode, "%" + filter + "%", "%" + filter + "%", "%" + filter + "%");
        List<Map<String, Object>> datas = jdbcTemplate.queryForList(sql, teamCode, "%" + filter + "%", "%" + filter + "%", "%" + filter + "%");
        if (datas != null && datas.size() > 0) {
        if (datas != null && datas.size() > 0) {
            for (Map<String, Object> map : datas) {
            for (Map<String, Object> map : datas) {
                Map ma = new HashMap();
                Map ma = new HashMap();
                ma.put("age", IdCardUtil.getAgeForIdcard(map.get("idcard")==null?"":map.get("idcard").toString()));
                ma.put("photo",map.get("photo")==null?"":map.get("photo").toString());
                ma.put("name",map.get("name")==null?"":map.get("name").toString());
                ma.put("code",map.get("code")==null?"":map.get("code").toString());
                ma.put("sex",map.get("sex")==null?"":map.get("sex").toString());
                ma.put("address",map.get("address")==null?"":map.get("address").toString());
                ma.put("idcard",map.get("idcard")==null?"":map.get("idcard").toString());
                ma.put("age", IdCardUtil.getAgeForIdcard(map.get("idcard") == null ? "" : map.get("idcard").toString()));
                ma.put("photo", map.get("photo") == null ? "" : map.get("photo").toString());
                ma.put("name", map.get("name") == null ? "" : map.get("name").toString());
                ma.put("code", map.get("code") == null ? "" : map.get("code").toString());
                ma.put("sex", map.get("sex") == null ? "" : map.get("sex").toString());
                ma.put("address", map.get("address") == null ? "" : map.get("address").toString());
                ma.put("idcard", map.get("idcard") == null ? "" : map.get("idcard").toString());
                list.add(ma);
                list.add(ma);
            }
            }
        }
        }
@ -1542,24 +1542,50 @@ public class SignPatientLabelInfoService extends BaseService {
        Object[] args = null;
        Object[] args = null;
        String sql = "";
        String sql = "";
        //String reg = "(^\\d{15}$)|(^\\d{17}([0-9]|X)$)";
        //String reg = "(^\\d{15}$)|(^\\d{17}([0-9]|X)$)";
        String reg = "^(\\d+)([0-9]|X|x)$";
//        String reg = "^(\\d+)([0-9]|X|x)$";
//        匹配数字字符串
        String reg = "[0-9]{1,}";
        Pattern pattern = Pattern.compile(reg);
        Pattern pattern = Pattern.compile(reg);
        Matcher matcher = pattern.matcher(filter);
        Matcher matcher = pattern.matcher(filter);
        if (matcher.find()) {
        if (matcher.find()) {
            sql = " select DISTINCT t.* " +
                    " from" +
                    "     wlyy_sign_family t join wlyy_patient p " +
                    "     on t.patient = p.code " +
                    (StringUtils.isNotEmpty(labelCode) ? (" join wlyy_sign_patient_label_info l " +
                            " on t.patient = l.patient ") : "") +
                    " where " +
                    "    (t.doctor = ? or t.doctor_health = ?) " +
                    (teamCode > 0 ? ("    and t.admin_team_code = " + teamCode) : "") +
                    (StringUtils.isNotEmpty(labelCode) ? " and l.label = ? and l.label_type = ? " : "") +
                    "     and p.idcard like ? ";
//            sql = " select DISTINCT t.* " +
//                    " from" +
//                    "     wlyy_sign_family t join wlyy_patient p " +
//                    "     on t.patient = p.code " +
//                    (StringUtils.isNotEmpty(labelCode) ? (" join wlyy_sign_patient_label_info l " +
//                            " on t.patient = l.patient ") : "") +
//                    " where " +
//                    "    (t.doctor = ? or t.doctor_health = ?) " +
//                    (teamCode > 0 ? ("    and t.admin_team_code = " + teamCode) : "") +
//                    (StringUtils.isNotEmpty(labelCode) ? " and l.label = ? and l.label_type = ? " : "") +
//                    "     and p.idcard like ? ";
//            if (StringUtils.isNotEmpty(labelCode)) {
//                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%"};
//            } else {
//                args = new Object[]{doctor, doctor, "%" + filter + "%"};
//            }
            sql = "select " +
                    "    DISTINCT t1.* " +
                    " FROM " +
                    "    wlyy_sign_family t1 " +
                    (StringUtils.isNotEmpty(labelCode) ?
                            " join " : " left join ") +
                    "    wlyy_sign_patient_label_info t2 " +
                    " ON t1.patient = t2.patient " +
                    (teamCode > 0 ? " join (select * from wlyy_sign_patient_label where label_type != '4' or team_code = " + teamCode + " or (label_type = '4' and (label_code in (1,2)))) lb on t2.label = lb.label_code and t2.label_type = lb.label_type " : "") +
                    " WHERE " +
                    "    (t1.doctor = ? or t1.doctor_health = ?) " +
                    "    AND t1.status > 0 " +
                    "    AND (" + (StringUtils.isNotEmpty(labelCode) || StringUtils.isNotEmpty(labelType) ? "" : " t2.patient is null OR ") + " t2.status = 1) " +
                    (StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : "") +
                    (StringUtils.isNotEmpty(labelType) ? " AND t2.label_type = ? " : "") +
                    (teamCode > 0 ? (" AND admin_team_code = " + teamCode) : "") +
                    "  AND (t1.idcard like ?) ";
            if (StringUtils.isNotEmpty(labelCode)) {
            if (StringUtils.isNotEmpty(labelCode)) {
                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%"};
                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%"};
            } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
                args = new Object[]{doctor, doctor, labelType, "%" + filter + "%"};
            } else {
            } else {
                args = new Object[]{doctor, doctor, "%" + filter + "%"};
                args = new Object[]{doctor, doctor, "%" + filter + "%"};
            }
            }

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

@ -32,9 +32,11 @@ import com.yihu.wlyy.task.SignUploadTask;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONObject;
import org.springframework.beans.CachedIntrospectionResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.PageRequest;
@ -154,8 +156,8 @@ public class FamilyContractService extends BaseService {
     * @param patient
     * @param patient
     * @return
     * @return
     */
     */
    public SignFamilyRenew findSigningRenewByPatient(String patient) {
        return signFamilyRenewDao.findSigningByPatient(patient);
    public SignFamily findSigningRenewByPatient(String patient) {
        return signFamilyDao.findSigningByPatient(patient);
    }
    }
    /**
    /**
     * 查询医院列表
     * 查询医院列表
@ -1100,34 +1102,36 @@ public class FamilyContractService extends BaseService {
        }
        }
        String doctorTeamCode = null;//服务团队的CODE;
        String doctorTeamCode = null;//服务团队的CODE;
        if (type == 1) {
        if (type == 1) {
            //2017-5-27 屏蔽三师签约判断
            //判断是否有三师签约 并且判断全科医生一致
            //判断是否有三师签约 并且判断全科医生一致
            SignFamily sssignFamily = signFamilyDao.findSSByIdcard(p.getIdcard());
            if (sssignFamily != null) {
                if (StringUtils.isNotEmpty(doctor)) {
                    if (!doctor.equals(sssignFamily.getDoctor())) {
                        result.put("status", -2);
                        result.put("msg", "居民已签约三师,故全科医生只可为" + sssignFamily.getDoctorName() + "医生,请重新选择全科医生");
                        return result;
                    }
                    List<AdminTeam> teams = adminTeamService.findDoctorsTeams(sf.getDoctorHealth(), sssignFamily.getDoctor());
                    if (teams == null || teams.size() < 1) {
                        result.put("status", -4);
                        result.put("msg", "居民已签约三师,三师签约的全科医生" + sssignFamily.getDoctorName() + "与该签约申请的健管师" + sf.getDoctorHealthName() + "不在同一个团队,该签约申请已失效");
                        messageService.readHealth(msgid);
                        updateSignStatus(p.getIdcard());
                        return result;
                    }
                }
                if (StringUtils.isNotEmpty(healthDoctor) && !sf.getDoctor().equals(sssignFamily.getDoctor())) {
                    result.put("status", -3);
                    result.put("msg", "对不起,居民已签约三师,故只可与" + sssignFamily.getDoctorName() + "医生签约,该签约申请已失效");
                    messageService.readHealth(msgid);
                    updateSignStatus(p.getIdcard());
                    return result;
                }
            }
//            SignFamily sssignFamily = signFamilyDao.findSSByIdcard(p.getIdcard());
//
//            if (sssignFamily != null) {
//                if (StringUtils.isNotEmpty(doctor)) {
//                    if (!doctor.equals(sssignFamily.getDoctor())) {
//                        result.put("status", -2);
//                        result.put("msg", "居民已签约三师,故全科医生只可为" + sssignFamily.getDoctorName() + "医生,请重新选择全科医生");
//                        return result;
//                    }
//                    List<AdminTeam> teams = adminTeamService.findDoctorsTeams(sf.getDoctorHealth(), sssignFamily.getDoctor());
//
//                    if (teams == null || teams.size() < 1) {
//                        result.put("status", -4);
//                        result.put("msg", "居民已签约三师,三师签约的全科医生" + sssignFamily.getDoctorName() + "与该签约申请的健管师" + sf.getDoctorHealthName() + "不在同一个团队,该签约申请已失效");
//                        messageService.readHealth(msgid);
//                        updateSignStatus(p.getIdcard());
//                        return result;
//                    }
//                }
//                if (StringUtils.isNotEmpty(healthDoctor) && !sf.getDoctor().equals(sssignFamily.getDoctor())) {
//                    result.put("status", -3);
//                    result.put("msg", "对不起,居民已签约三师,故只可与" + sssignFamily.getDoctorName() + "医生签约,该签约申请已失效");
//                    messageService.readHealth(msgid);
//                    updateSignStatus(p.getIdcard());
//                    return result;
//                }
//            }
            //List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
            //List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
            Calendar cal = Calendar.getInstance();
            Calendar cal = Calendar.getInstance();
@ -1173,7 +1177,7 @@ public class FamilyContractService extends BaseService {
            sf.setBegin(begin.getTime());
            sf.setBegin(begin.getTime());
            sf.setEnd(end.getTime());
            sf.setEnd(end.getTime());
            //签约类型:1三师签约,2家庭签约
            // 改为签约生效
            // 改为签约生效
            sf.setStatus(1);
            sf.setStatus(1);
            sf.setSignType("1");//患者发起签约
            sf.setSignType("1");//患者发起签约
@ -1207,7 +1211,7 @@ public class FamilyContractService extends BaseService {
            //建立团队
            //建立团队
            DoctorTeam doctorTeam = new DoctorTeam();
            DoctorTeam doctorTeam = new DoctorTeam();
            doctorTeamCode = getCode();
            doctorTeamCode = getCode();
            doctorTeam.setName("三师签约团队患者:" + p.getName());
            doctorTeam.setName("签约团队患者:" + p.getName());
            doctorTeam.setCode(doctorTeamCode);
            doctorTeam.setCode(doctorTeamCode);
            doctorTeam.setCzrq(new Date());
            doctorTeam.setCzrq(new Date());
            doctorTeam.setSignType("2");
            doctorTeam.setSignType("2");
@ -2921,11 +2925,11 @@ public class FamilyContractService extends BaseService {
            return -1;
            return -1;
        }
        }
        List<SignFamilyRenew> sc = signFamilyRenewDao.findByIdcard(p.getIdcard());
        //判断身份证号是否已签约
        if (sc != null&&sc.size()>0) {
            return -2;
        }
//        List<SignFamilyRenew> sc = signFamilyRenewDao.findByIdcard(p.getIdcard());
//        //判断身份证号是否已签约
//        if (sc != null&&sc.size()>0) {
//            return -2;
//        }
        Doctor d = doctorDao.findByCode(doctor);
        Doctor d = doctorDao.findByCode(doctor);
        Doctor hd = doctorDao.findByCode(healthDoctor);
        Doctor hd = doctorDao.findByCode(healthDoctor);
@ -2934,8 +2938,14 @@ public class FamilyContractService extends BaseService {
            return -3;
            return -3;
        }
        }
        SignFamilyRenew sf = new SignFamilyRenew();
        SignFamilyRenew sf = new SignFamilyRenew();
        Calendar cal = Calendar.getInstance();
        int year =cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH)+1;
        String sql = "";
        //判断是否有生效记录SQL
        //判断是否有生效记录SQL
        String sql = "SELECT t.doctor,t.team_code teamCode,t.admin_team_code adminTeamCode FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1'";
        sql ="SELECT t.doctor,t.team_code teamCode,t.admin_team_code adminTeamCode FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1' AND t.sign_year ='"+(year-1)+"'";
        List<Map<String,Object>> signs = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> signs = jdbcTemplate.queryForList(sql);
        if(signs==null||signs.size()==0){
        if(signs==null||signs.size()==0){
            return -4;
            return -4;
@ -2945,7 +2955,8 @@ public class FamilyContractService extends BaseService {
        if(doctor.equals((String)sign.get("doctor"))){
        if(doctor.equals((String)sign.get("doctor"))){
            //如果一致保存团队信息
            //如果一致保存团队信息
            sf.setTeamCode((String)sign.get("teamCode"));
            sf.setTeamCode((String)sign.get("teamCode"));
            sf.setAdminTeamId((Long)sign.get("adminTeamId"));
            Integer c=(Integer)sign.get("adminTeamCode");
            sf.setAdminTeamId(c.longValue());
        }else {
        }else {
            //如果不一致 查看医生团队
            //如果不一致 查看医生团队
            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
@ -3037,8 +3048,7 @@ public class FamilyContractService extends BaseService {
        sf.setSignSource("2");//签约来源【1 社区签约 2 移动签约】
        sf.setSignSource("2");//签约来源【1 社区签约 2 移动签约】
        //******************扣费接口**********************/
        //******************扣费接口**********************/
        sf.setExpensesStatus("0");   //扣费状态 【0未扣费 1已扣费 2已退费】
        sf.setExpensesStatus("0");   //扣费状态 【0未扣费 1已扣费 2已退费】
        Calendar cal = Calendar.getInstance();
        int year =cal.get(Calendar.YEAR);
        sf.setSignYear(year+"");
        sf.setSignYear(year+"");
        sf.setIsValid(0);
        sf.setIsValid(0);
        sf.setBegin(new Date());
        sf.setBegin(new Date());
@ -3063,7 +3073,176 @@ public class FamilyContractService extends BaseService {
            message.setSignStatus("8");//续签
            message.setSignStatus("8");//续签
            message.setSex(p.getSex());
            message.setSex(p.getSex());
            message.setOver("1");//未处理
            message.setOver("1");//未处理
            message.setData(temp.getCode());
            message.setData(sf.getCode());
            messageDao.save(message);
            // 发送消息给医生
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
            if (jsonObject.getString("status").equals("1")) {
                //如果在工作时间内就推送
                PushMsgTask.getInstance().put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), p.getName()+"申请与您续签家庭医生", patient);
            }
        }
        return 1;
    }
    /**
     * 续签申请(7月之后)
     *
     * @param doctor  签约医生
     * @param patient 居民code
     * @return
     */
    @Transactional
    public int signRenewOverdue(String doctor,String healthDoctor, String patient) throws Exception {
        Patient p = patientDao.findByCode(patient);
        if (p == null) {
            return -1;
        }
        Doctor d = doctorDao.findByCode(doctor);
        Doctor hd = doctorDao.findByCode(healthDoctor);
        if (d == null) {
            return -3;
        }
        SignFamily sf = new SignFamily();
        Calendar cal = Calendar.getInstance();
        int year =cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH)+1;
        String sql  ="SELECT t.doctor,t.team_code teamCode,t.admin_team_code adminTeamCode FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status=-4 AND t.expenses_status='1' AND t.sign_year ='"+(year-1)+"'";
        List<Map<String,Object>> signs = jdbcTemplate.queryForList(sql);
        if(signs==null||signs.size()==0){
            return -4;
        }
        Map<String,Object> sign = signs.get(0);
        //判断续签医生是否一致
        if(doctor.equals((String)sign.get("doctor"))){
            //如果一致保存团队信息
            sf.setTeamCode((String)sign.get("teamCode"));
            Integer c=(Integer)sign.get("adminTeamCode");
            sf.setAdminTeamId(c.longValue());
        }else {
            //如果不一致 查看医生团队
            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
            List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
            if(ids!=null&&ids.size()>0){
                Integer id =  (Integer)ids.get(0).get("id");
                Long lid = id.longValue();
                sf.setAdminTeamId(lid);
            }else{
                //未找到团队信息
                return -5;
            }
            //新建咨询团队组
            DoctorTeam team = new DoctorTeam();
            String code = getCode();
            team.setCode(code);
            team.setCzrq(new Date());
            team.setDel("1");
            team.setSignType("2");
            //判断是否有健康管理师
            if(hd!=null&&StringUtils.isNotBlank(hd.getName())){
                team.setName(d.getName()+","+hd.getName()+","+p.getName());
                //新建健康管理师
                DoctorTeamMember hdmb = new DoctorTeamMember();
                hdmb.setName(hd.getName());
                hdmb.setMemberCode(healthDoctor);
                hdmb.setCode(getCode());
                hdmb.setDel("1");
                hdmb.setCzrq(new Date());
                hdmb.setTeam(code);
                hdmb.setType(hd.getLevel());
                hdmb.setSignType("2");
                doctorTeamDoctor.save(hdmb);
            }else{
                team.setName(d.getName()+","+p.getName());
            }
            //新建医生成员
            DoctorTeamMember dmb = new DoctorTeamMember();
            dmb.setName(d.getName());
            dmb.setMemberCode(doctor);
            dmb.setCode(getCode());
            dmb.setDel("1");
            dmb.setCzrq(new Date());
            dmb.setTeam(code);
            dmb.setType(d.getLevel());
            dmb.setSignType("2");
            //新建病人
            DoctorTeamMember pmb = new DoctorTeamMember();
            pmb.setName(p.getName());
            pmb.setMemberCode(patient);
            pmb.setCode(getCode());
            pmb.setDel("1");
            pmb.setCzrq(new Date());
            pmb.setTeam(code);
            pmb.setType(5);
            pmb.setSignType("2");
            doctorTeamDoctor.save(dmb);
            doctorTeamDoctor.save(pmb);
            doctorTeamDao.save(team);
            //关联新团队
            sf.setTeamCode(code);
        }
        sf.setCode(getCode());
        sf.setCzrq(new Date());
        sf.setPatientApplyDate(new Date());
        if(d!=null){
            sf.setDoctor(doctor);
            sf.setDoctorName(d.getName());
        }
        if(hd!=null){
            sf.setDoctorHealth(healthDoctor);
            sf.setDoctorHealthName(hd.getName());
        }
        sf.setMobile(p.getMobile());
        sf.setName(p.getName());
        sf.setIdcard(p.getIdcard());
        sf.setOpenid(p.getOpenid());
        sf.setPatient(patient);
        sf.setHospital(d.getHospital());
        sf.setHospitalName(d.getHospitalName());
        sf.setSsc(p.getSsc());
        sf.setStatus(0);//0为初始状态
        sf.setType(2);// 设置为家庭签约
        sf.setSignType("1");//用户申请
        sf.setSignSource("2");//签约来源【1 社区签约 2 移动签约】
        //******************扣费接口**********************/
        sf.setExpensesStatus("0");   //扣费状态 【0未扣费 1已扣费 2已退费】
        sf.setSignYear(year+"");
        sf.setBegin(new Date());
        sf.setEnd(DateUtil.stringToDate(year+1+"-07-01 00:00:00","yyyy-MM-dd HH:mmm:ss"));
        SignFamily temp = signFamilyDao.save(sf);
        if (temp != null) {
            // 添加签约消息
            Message message = new Message();
            message.setCzrq(new Date());
            message.setCreateTime(new Date());
            message.setContent("您有一条新的家庭医生续签申请!");
            message.setRead(1);//设置未读
            message.setReceiver(doctor);//设置接受医生的code
            message.setSender(patient);//设置发送的用户
            message.setSenderName(p.getName());
            message.setCode(getCode());
            message.setSenderPhoto(p.getPhoto());
            message.setTitle("家庭续签申请");
            message.setType(1);//家庭签约信息
            message.setReadonly(1);//是否只读消息
            message.setSignStatus("8");//续签
            message.setSex(p.getSex());
            message.setOver("1");//未处理
            message.setData(sf.getCode());
            messageDao.save(message);
            messageDao.save(message);
            // 发送消息给医生
            // 发送消息给医生
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
@ -3095,4 +3274,64 @@ public class FamilyContractService extends BaseService {
        }
        }
        return "";
        return "";
    }
    }
    public JSONArray getSignDoctorMessageOverDue(String patientCode) {
        JSONArray jsonArray = new JSONArray();
        //找出患者的三师签约信息
        Patient patient = patientDao.findByCode(patientCode);
        Calendar cal = Calendar.getInstance();
        int year = cal.get(Calendar.YEAR);
        //得到家庭签约
        SignFamily jtSignFamily = signFamilyDao.findFamilySignByPatientOverDue(patientCode,(year-1)+"");
        if (jtSignFamily != null) {
            //家庭签约只找全科医生
            Doctor doctor = doctorDao.findByCode(jtSignFamily.getDoctor());
            Doctor doctorHealth = doctorDao.findByCode(jtSignFamily.getDoctorHealth());
            if (doctor != null) {
                JSONObject jo = new JSONObject();
                jo.put("code", doctor.getCode());
                jo.put("sex", doctor.getSex());
                jo.put("name", doctor.getName());
                jo.put("photo", doctor.getPhoto());
                jo.put("hosptialName", doctor.getHospitalName());
                jo.put("level", doctor.getLevel());
                jo.put("signType", "2");//三师签约
                jo.put("signStatus", jtSignFamily.getStatus());
                jo.put("jobName", doctor.getJobName());
                jo.put("disease", patient.getDisease());//0健康,1高血压,2糖尿病,3高血压+糖尿病
                if (jtSignFamily.getStatus() == 0) {
                    jo.put("sqDate", DateUtil.dateToStrShort(jtSignFamily.getPatientApplyDate()));//申请时间
                } else {
                    jo.put("qyDate", DateUtil.dateToStrShort(jtSignFamily.getBegin()));//签约时间
                    jo.put("endDate", DateUtil.dateToStrShort(jtSignFamily.getEnd()));//结束时间
                }
                jsonArray.put(jo);
            }
            if (doctorHealth != null) {
                JSONObject jo = new JSONObject();
                jo.put("code", doctorHealth.getCode());
                jo.put("sex", doctorHealth.getSex());
                jo.put("name", doctorHealth.getName());
                jo.put("photo", doctorHealth.getPhoto());
                jo.put("hosptialName", doctorHealth.getHospitalName());
                jo.put("level", doctorHealth.getLevel());
                jo.put("signType", "2");//三师签约
                jo.put("signStatus", jtSignFamily.getStatus());
                jo.put("jobName", doctorHealth.getJobName());
                jo.put("disease", patient.getDisease());//0健康,1高血压,2糖尿病,3高血压+糖尿病
                if (jtSignFamily.getStatus() == 0) {
                    jo.put("sqDate", DateUtil.dateToStrShort(jtSignFamily.getPatientApplyDate()));//申请时间
                } else {
                    jo.put("qyDate", DateUtil.dateToStrShort(jtSignFamily.getBegin()));//签约时间
                    jo.put("endDate", DateUtil.dateToStrShort(jtSignFamily.getEnd()));//结束时间
                }
                jsonArray.put(jo);
            }
        }
        return jsonArray;
    }
}
}

+ 119 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -469,10 +469,13 @@ public class SignWebService extends BaseService {
    }
    }
    public JSONObject getSignInfo(String teamCode){
    public JSONObject getSignInfo(String teamCode){
          SignFamily signFamily = signFamilyDao.findByTeamCode(teamCode);
          if(signFamily==null){
          List<SignFamily> signFamilys = signFamilyDao.findByTeamCodeIsValid(teamCode);
          SignFamily signFamily =null;
          if(signFamilys==null||signFamilys.size()==0){
              throw new RuntimeException("找不到签约关系!");
              throw new RuntimeException("找不到签约关系!");
          }
          }else{
              signFamily = signFamilys.get(0);
;          }
          Patient p = patientService.findByCode(signFamily.getPatient());
          Patient p = patientService.findByCode(signFamily.getPatient());
          String patient = p.getCode();
          String patient = p.getCode();
          JSONObject resultObject = new JSONObject();
          JSONObject resultObject = new JSONObject();
@ -898,11 +901,12 @@ public class SignWebService extends BaseService {
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public int agreeRenew(String access_token,String dotorCode,String patientCode,String state,Long mesId) throws Exception{
        List<SignFamilyRenew> renews =  signFamilyRenewDao.findByDoctorAndPatient(dotorCode,patientCode);
    public int agreeRenew(String access_token,String dotorCode,String patientCode,String state,Long mesId,String signYear) throws Exception{
        List<SignFamilyRenew> renews =  signFamilyRenewDao.findByDoctorAndPatient(dotorCode,patientCode,signYear);
        if(renews==null||renews.size()==0){
        if(renews==null||renews.size()==0){
            renews =  signFamilyRenewDao.findByDoctorHealthAndPatient(dotorCode,patientCode);
            renews =  signFamilyRenewDao.findByDoctorHealthAndPatient(dotorCode,patientCode,signYear);
        }
        }
        if(renews!=null&&renews.size()>0){
        if(renews!=null&&renews.size()>0){
@ -976,6 +980,93 @@ public class SignWebService extends BaseService {
        return 1;
        return 1;
    }
    }
    /**
     * 同意或拒绝签约签约(七月份的流程)
     * @param access_token
     * @param dotorCode
     * @param state 1成功 0拒绝
     * @return
     * @throws Exception
     */
    public int agreeRenewOverDue (String access_token,String dotorCode,String patientCode,String state,Long mesId,String signYear) throws Exception{
        List<SignFamily> renews =  signFamilyDao.findByDoctorAndPatientOverDue(dotorCode,patientCode,signYear);
        if(renews==null||renews.size()==0){
            renews =  signFamilyDao.findByDoctorHealthAndPatient(dotorCode,patientCode,signYear);
        }
        if(renews!=null&&renews.size()>0){
            for(SignFamily renew : renews){
                if(StringUtils.isNotBlank(state)){
                    if ("0".equals(state)){
                        renew.setStatus(-2);
                    }else if("1".equals(state)){
                        renew.setStatus(1);
                    }
                }
                renew.setApplyDate(new Date());
                signFamilyDao.save(renew);
                if(mesId!=null&&mesId>0){
                    Message mes = messageDao.findOne(mesId);
                    mes.setRead(0);//设置已读
                    mes.setOver("0");//设置消息操作结束
                    mes.setCzrq(new Date());
                    messageDao.save(mes);
                }
                //发送微信模板消息
                JSONObject data = new JSONObject();
                data.put("doctorName",renew.getDoctorName());
                data.put("date",DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                data.put("content","家庭医生续签");
                data.put("doctor",dotorCode);
                data.put("toUser",patientCode);
                data.put("toName",renew.getName());
                Patient patient = patientService.findByCode(renew.getPatient());
                if(patient!=null && StringUtils.isNotBlank(patient.getOpenid())){
                    if ("0".equals(state)){
                        data.put("first",renew.getName()+",您好!\n"+
                                "您的家庭医生续签申请已被拒绝");
                        data.put("remark","您可在到期后选择其他医生进行签约。");
                        PushMsgTask.getInstance().putWxMsg(access_token, 2, patient.getOpenid(), patient.getName(), data);
                    }else if("1".equals(state)){
                        data.put("first",renew.getName()+",您好!\n"+
                                "您的家庭医生续签申请已通过");
                        data.put("remark","待自动扣费成功后,家庭医生将续签成功。");
                        PushMsgTask.getInstance().putWxMsg(access_token, 1, patient.getOpenid(), patient.getName(), data);
                    }
                }else{
                    //如果自己没有绑定,则发给家人
                    JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(patient.getCode());
                    Patient member = (Patient)j.get("member");
                    if(StringUtils.isNotBlank(member.getOpenid())){
                        if ("0".equals(state)){
                            data.put("first",weiXinOpenIdUtils.getTitleMes(patient,(int)j.get("relation"),member.getName())+"\n"+
                                    patient.getName()+",您好!\n" +
                                    "您的家庭医生续签申请已被拒绝");
                            data.put("remark","您可在到期后选择其他医生进行签约。");
                            PushMsgTask.getInstance().putWxMsg(access_token, 2, member.getOpenid(), member.getName(), data);
                        }else if("1".equals(state)){
                            data.put("first",weiXinOpenIdUtils.getTitleMes(patient,(int)j.get("relation"),member.getName())+"\n"+
                                    patient.getName()+",您好!\n" +
                                    "您的家庭医生续签申请已通过");
                            data.put("remark","待自动扣费成功后,家庭医生将续签成功。");
                            PushMsgTask.getInstance().putWxMsg(access_token, 1, member.getOpenid(), member.getName(), data);
                        }
                    }
                }
            }
        }else{
            return 0;
        }
        return 1;
    }
    /**
    /**
     * 获取年度列表
     * 获取年度列表
     * @return
     * @return
@ -1140,4 +1231,26 @@ public class SignWebService extends BaseService {
        String dateKey = DateUtil.dateToStr(new Date(),"yyyyMMdd");
        String dateKey = DateUtil.dateToStr(new Date(),"yyyyMMdd");
        redisTemplate.opsForValue().set("renew:"+dateKey+":"+patient,"1");
        redisTemplate.opsForValue().set("renew:"+dateKey+":"+patient,"1");
    }
    }
    //判断用户当前年度是否有已经付费的签约记录
    public int checkNowYearSign(String doctor,String patient){
        List<SignFamilyRenew> renews1 = signFamilyRenewDao.findByDoctorAndPatientIsValid(doctor,patient,DateUtil.getNowYear()+"");
        if(renews1!=null&&renews1.size()>0){
            return 0;
        }
        List<SignFamilyRenew> renews2 = signFamilyRenewDao.findByDoctorHealthAndPatientIsValid(doctor,patient,DateUtil.getNowYear()+"");
        if(renews2!=null&&renews2.size()>0){
            return 0;
        }
        List<SignFamily> sign1 = signFamilyDao.findByDoctorAndPatientIsValid(doctor,patient,DateUtil.getNowYear()+"");
        if(sign1!=null&&sign1.size()>0){
            return 0;
        }
        List<SignFamily> sign2 = signFamilyDao.findByDoctorHealthAndPatientIsValid(doctor,patient,DateUtil.getNowYear()+"");
        if(sign2!=null&&sign2.size()>0){
            return 0;
        }
        return 1;
    }
}
}

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

@ -383,11 +383,11 @@ public class PatientService extends TokenService {
        //判断是否有生效记录SQL
        //判断是否有生效记录SQL
        String sql = "SELECT t.id,t.sign_year signYear FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1'";
        String sql = "SELECT t.id,t.sign_year signYear FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1'";
        //用于判断续签表是否有记录QL,有记录则不允许续签
        //用于判断续签表是否有记录QL,有记录则不允许续签
        String sqlRenew = "SELECT t.id,t.sign_year signYear FROM wlyy_sign_family_renew t WHERE t.patient ='" + patient + "' AND t.status>=0 ";
        String sqlRenew = "SELECT t.id,t.sign_year signYear,t.status FROM wlyy_sign_family_renew t WHERE t.patient ='" + patient + "' AND t.status>=0 ";
        //判读是否有当前年度的记录SQL
        //判读是否有当前年度的记录SQL
        String signSql = "SELECT t.id,t.sign_year signYear FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1' AND t.sign_year ='" + year + "'";
        String signSql = "SELECT t.id,t.sign_year signYear ,t.status  FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0  AND t.sign_year ='" + year + "'";
        //判读是否有旧的已到期记录SQL
        //判读是否有旧的已到期记录SQL
        String oldSignSql = "SELECT t.id,t.sign_year signYear FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status=-4 AND  t.expenses_status='1' AND t.sign_year ='" + (year - 1) + "'";
        String oldSignSql = "SELECT t.id,t.sign_year signYear,t.status FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status=-4 AND  t.expenses_status='1' AND t.sign_year ='" + (year - 1) + "'";
        //判断时间是否在6月30之前
        //判断时间是否在6月30之前
        if (month < 7) {
        if (month < 7) {
            //判断是否有签约记录
            //判断是否有签约记录
@ -419,14 +419,21 @@ public class PatientService extends TokenService {
            }
            }
        } else {
        } else {
            //如果在签约七月份之后判断是否已经生效,判断是否有旧数据
            //如果在签约七月份之后判断是否已经生效,判断是否有旧数据
            List<SignFamily> signFamilys1 = jdbcTemplate.queryForList(signSql, SignFamily.class);
            List<Map<String,Object>> signFamilys1 = jdbcTemplate.queryForList(signSql);
            if (signFamilys1 != null && signFamilys1.size() > 0) {
            if (signFamilys1 != null && signFamilys1.size() > 0) {
                rs.put("mes", "当前年度已经签约");
                rs.put("code", "-2");
                Map<String,Object> map = signFamilys1.get(0);
                int state = (int)map.get("status");
                if(state==1){
                    rs.put("mes", "医生已经同意续签");
                    rs.put("code", "-5");
                }else {
                    rs.put("mes", "当前年度已经签约");
                    rs.put("code", "-2");
                }
                return rs;
                return rs;
            }
            }
            List<SignFamily> signFamilys2 = jdbcTemplate.queryForList(oldSignSql, SignFamily.class);
            if (signFamilys1 != null && signFamilys1.size() > 0) {
            List<Map<String,Object>> signFamilys2 = jdbcTemplate.queryForList(oldSignSql);
            if (signFamilys2 != null && signFamilys2.size() > 0) {
                rs.put("mes", "可以续签(已到期)");
                rs.put("mes", "可以续签(已到期)");
                rs.put("code", "2");
                rs.put("code", "2");
                return rs;
                return rs;
@ -442,8 +449,15 @@ public class PatientService extends TokenService {
        List<Map<String,Object>> renews = jdbcTemplate.queryForList(sqlRenew);
        List<Map<String,Object>> renews = jdbcTemplate.queryForList(sqlRenew);
        //如果续签表没有数据,则可以续签,有数据提示已经续签
        //如果续签表没有数据,则可以续签,有数据提示已经续签
        if (renews != null && renews.size() > 0) {
        if (renews != null && renews.size() > 0) {
            rs.put("mes", "已经提交续签");
            rs.put("code", "-3");
            Map<String,Object> remew = renews.get(0);
            int state = (int)remew.get("status");
            if(state==1){
                rs.put("mes", "医生已经同意续签");
                rs.put("code", "-5");
            }else{
                rs.put("mes", "已经提交续签");
                rs.put("code", "-3");
            }
            return rs;
            return rs;
        } else {
        } else {
            rs.put("mes", "可以续签(未到期)");
            rs.put("mes", "可以续签(未到期)");
@ -474,4 +488,5 @@ public class PatientService extends TokenService {
        return "";
        return "";
    }
    }
}
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -525,7 +525,7 @@ public class PushMsgTask {
                keyword1.setValue(json.getString("keyword1"));
                keyword1.setValue(json.getString("keyword1"));
                m.put("keyword1", keyword1);
                m.put("keyword1", keyword1);
            }else if(type == 16){
            }else if(type == 16){
                temp.setUrl(url + "yszx/html/consulting-doctor.html?openid=" + openid + "&consult=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name);
                //temp.setUrl(url + "yszx/html/consulting-doctor.html?openid=" + openid + "&consult=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name);
                temp.setTemplate_id(SystemConf.getInstance().getSystemProperties().getProperty("template_doctor_survey"));
                temp.setTemplate_id(SystemConf.getInstance().getSystemProperties().getProperty("template_doctor_survey"));
                WechatTemplateData  keyword1= new WechatTemplateData();
                WechatTemplateData  keyword1= new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setColor("#000000");

+ 10 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -755,4 +755,14 @@ public class DateUtil {
		}
		}
		return date;
		return date;
	}
	}
	public static int getNowMonth(){
		Calendar cal = Calendar.getInstance();
		return cal.get(Calendar.MONTH)+1;
	}
	public static int getNowYear(){
		Calendar cal = Calendar.getInstance();
		return cal.get(Calendar.YEAR);
	}
}
}

+ 91 - 12
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendNews.java

@ -1,16 +1,37 @@
package com.yihu.wlyy.util;
package com.yihu.wlyy.util;
import com.yihu.wlyy.entity.security.AccessToken;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.security.AccessTokenDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.AccessTokenService;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springside.modules.utils.Clock;
import java.io.*;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import static sun.management.Agent.error;
/**
/**
 * Created by Reece on 2017/5/20.
 * Created by Reece on 2017/5/20.
 */
 */
@Component
public class SendNews {
public class SendNews {
    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
@ -107,33 +128,91 @@ public class SendNews {
    /**
    /**
     * 上传图文消息文字素材
     * 上传图文消息文字素材
     *
     * @param accessToken
     * @param accessToken
     * @param data 图文消息文字素材内容
     * @param data        图文消息文字素材内容
     * @return
     * @return
     */
     */
    public static String uploadNesText(String accessToken,String url,JSONObject data){
        url = url.replaceFirst("ACCESS_TOKEN",accessToken);
    public static String uploadNesText(String accessToken, String url, JSONObject data) throws Exception {
        url = url.replaceFirst("ACCESS_TOKEN", accessToken);
        //上传的图文消息数据,其中thumb_media_id是文件上传图片上传的id
        //上传的图文消息数据,其中thumb_media_id是文件上传图片上传的id
//        data = "{\"articles\": [{\"thumb_media_id\":\"BW4eDIdYSvO7AFjfsZKsQ9ujNma_TkCj3VSo3JNTQkYmk_iPuhpUKm48oZ4umHED\",\"author\":\"xxx\",\"title\":\"Happy Day\",\"content_source_url\":\"www.qq.com\",\"content\":\"content\",\"digest\":\"digest\",\"show_cover_pic\":\"0\"}]}";
        String result = HttpClientUtil.postBody(url,data);
        String result = HttpClientUtil.postBody(url, data);
        return result;
        return result;
    }
    }
    /**
    /**
     * 发送图文消息
     * 发送图文消息
     *
     * @param accessToken
     * @param accessToken
     * @param openidData  群发图文消息内容
     * @param openidData  群发图文消息内容
     * @return
     * @return
     */
     */
    public static String sendNewspMessage(String accessToken,String url, JSONObject openidData){
        url = url.replace("ACCESS_TOKEN",accessToken);
        String group1data = "{\"filter\":{\"is_to_all\":false,\"group_id\":\"2\"},\"text\":{\"content\":\"群发消息测试\"},\"msgtype\":\"text\"}\";";
        String openid1data = "{\"touser\":[\"obGXiwHTGN_4HkR2WToFj_3uaEKY\",\"obGXiwNu0z2o_RRWaODvaZctdWEM\"],\"msgtype\": \"text\",\"text\": {\"content\": \"测试文本消息\"}}";
        String openid2data = "{\"touser\":[\"obGXiwHTGN_4HkR2WToFj_3uaEKY\",\"obGXiwNu0z2o_RRWaODvaZctdWEM\"], \"voice\": {\"media_id\":\"UfMRvSiXAD5_iUS8u0Gc3JrKGWOABE9ivQbgrX6i-mVrKGBRL9KnKlioK1BxTPc3\"},\"msgtype\":\"voice\"}";
        String openid3data = "{\"touser\":[\"obGXiwHTGN_4HkR2WToFj_3uaEKY\",\"obGXiwNu0z2o_RRWaODvaZctdWEM\"], \"image\": {\"media_id\":\"fNUzGbYzTRui4N7-eyx9e3viP8uJuzztAvA32lIdjX4Cucj7mGN_1jpWjn7O80c8\"},\"msgtype\":\"image\"}";
        String json = HttpClientUtil.postBody(url,openidData);
    public static String sendNewspMessage(String accessToken, String url, JSONObject openidData) throws Exception {
        url = url.replace("ACCESS_TOKEN", accessToken);
        String json = HttpClientUtil.postBody(url, openidData);
        return json;
        return json;
    }
    }
    public static String sendNews(String accessToken) throws Exception {
        // 配置信息
        Properties systemConf = SystemConf.getInstance().getSystemProperties();
        //本地上传图片的路径
        /*String renewPath = systemConf.getProperty("patient_sign_again_pic_url");
        String renewUrl = systemConf.getProperty("patient_sign_again_url");
        String signPath = systemConf.getProperty("doctor_qrcode_pic_url");
        String signUrl = systemConf.getProperty("doctor_subscribe_url");
        String sendUrl = "http://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN&type=image";
        String mediaurl = "https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=ACCESS_TOKEN";//ACCESS_TOKEN是获取到的access_token
        String groupUrl = "https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token=ACCESS_TOKEN";//根据openid发群发消息地址
        sendUrl = sendUrl.replace("ACCESS_TOKEN", accessToken);
        String renewImage = SendNews.uploadImage(sendUrl, renewPath);
        String signImage = SendNews.uploadImage(sendUrl, signPath);
        JSONObject newsTextData = new JSONObject();
        JSONArray newsText = new JSONArray();
//            续签图文
        JSONObject data = new JSONObject();
        data.put("thumb_media_id", new JSONObject(renewImage).get("url"));
        data.put("author", "作者");
        data.put("content_source_url", renewUrl);
        data.put("content", "续签图文消息内容");
        data.put("digest", "续签图文消息描述");
        data.put("show_cover_pic", 1);
//            签约图文
        JSONObject data1 = new JSONObject();
        data1.put("thumb_media_id", new JSONObject(signImage).get("url"));
//            data1.put("author","作者");
        data1.put("content_source_url", signUrl);
        data1.put("content", "签约图文消息内容");
//            data1.put("digest","签约图文消息描述");
//            data1.put("show_cover_pic",1);
        newsText.put(data1);
        newsText.put(data);
        newsTextData.put("articles", newsText);
        String media = SendNews.uploadNesText(accessToken, mediaurl, newsTextData);
        JSONObject news = new JSONObject();
        JSONObject mapnews = new JSONObject();
        mapnews.put("media_id", new JSONObject(media).get("media_id"));*/
       /* String sql = "select distinct p.openid from Patient p where p.openid is not null and p.openid <> '' ";
        JdbcTemplate jdbcTemplate = new JdbcTemplate();
        List<String> openIds = jdbcTemplate.queryForList(sql, String.class);*/
//        List<String> openIds = patientDao.findOpenids();
       /* news.put("touser", openIds);
        news.put("mpnews", mapnews);
        news.put("msgtype", "mpnews");
        news.put("send_ignore_reprint", 1);
        SendNews.sendNewspMessage(accessToken, groupUrl, news);*/
        return null;
    }
}
}

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

@ -7,11 +7,13 @@ import java.util.*;
import com.yihu.wlyy.entity.login.LoginLog;
import com.yihu.wlyy.entity.login.LoginLog;
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
import com.yihu.wlyy.entity.security.AccessToken;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.family.FamilyMemberService;
import com.yihu.wlyy.service.app.family.FamilyMemberService;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.service.common.account.AccessTokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
@ -61,6 +63,8 @@ public class WechatController extends WeixinBaseController {
    private FamilyMemberService familyMemberService;
    private FamilyMemberService familyMemberService;
    @Autowired
    @Autowired
    WeiXinOpenIdUtils weiXinOpenIdUtils;
    WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    AccessTokenService accessTokenService;
    /**
    /**
@ -575,7 +579,7 @@ public class WechatController extends WeixinBaseController {
                map.put("noncestr", noncestr);
                map.put("noncestr", noncestr);
                map.put("timestamp", timestamp);
                map.put("timestamp", timestamp);
                map.put("signature", signature);
                map.put("signature", signature);
                return write(200, "获取签名成功", "data", map);
                return write(200, "获取签名成功", "data", "map");
            } else
            } else
                return error(-1, "获取签名失败");
                return error(-1, "获取签名失败");
@ -725,63 +729,4 @@ public class WechatController extends WeixinBaseController {
        }
        }
    }
    }
    /**
     * 根据openID群发图文消息
     *
     * @return
     */
    @RequestMapping(value = "/sendNews")
    @ResponseBody
    public String sendNews() {
        try {
            String accessToken = getAccessToken();
//            本地上传图片的路径
            String filePath = SystemConf.getInstance().getChatPath();
            String sendUrl = "http://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN&type=image";
            String mediaurl = "https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=ACCESS_TOKEN";//ACCESS_TOKEN是获取到的access_token
            String groupUrl = "https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token=ACCESS_TOKEN";//根据openid发群发消息地址
            sendUrl = sendUrl.replace("ACCESS_TOKEN", accessToken);
            String image = SendNews.uploadImage(sendUrl, filePath);
            JSONObject newsTextData = new JSONObject();
            JSONArray newsText = new JSONArray();
//            续签图文
            JSONObject data = new JSONObject();
            data.put("thumb_media_id", new JSONObject(image).get("url"));
            data.put("author", "作者");
            data.put("content_source_url", "图文跳转链接");
            data.put("content", "图文消息内容");
            data.put("digest", "图文消息描述");
            data.put("show_cover_pic", 1);
//            签约图文
//            JSONObject data1 = new JSONObject();
//            data1.put("thumb_media_id",new JSONObject(image).get("url"));
//            data1.put("author","作者");
//            data1.put("content_source_url","图文跳转链接");
//            data1.put("content","图文消息内容");
//            data1.put("digest","图文消息描述");
//            data1.put("show_cover_pic",1);
            newsText.put(data);
//            newsText.put(data1);
            newsTextData.put("articles", newsText);
            String media = SendNews.uploadNesText(accessToken, mediaurl, newsTextData);
            JSONObject news = new JSONObject();
            JSONObject mapnews = new JSONObject();
            mapnews.put("media_id", new JSONObject(media).get("media_id"));
            List<String> openIds = patientDao.findOpenids();
            news.put("touser", openIds);
            news.put("mpnews", mapnews);
            news.put("msgtype", "mpnews");
            news.put("send_ignore_reprint", 1);
            SendNews.sendNewspMessage(accessToken, groupUrl, news);
            return write(200, "群发图文成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "群发图文失败!");
        }
    }
}
}

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

@ -1812,7 +1812,7 @@ public class DoctorController extends BaseController {
            @RequestParam(required = false) String typeId) {
            @RequestParam(required = false) String typeId) {
        try {
        try {
            Long teamCode = Long.parseLong(teamId);
            Long teamCode = Long.parseLong(teamId);
//            patients不为空是由团队中搜索居民 否则是分组分配健管师
//            patients不为空是由团队中分配及转移的搜索居民 转移健管师 否则是分组分配健管师
            if (StringUtils.isNotEmpty(patients)) {
            if (StringUtils.isNotEmpty(patients)) {
                String result = updateTeamHealthDoctors(newDoctorCode, oldDoctorCode, patients, null);
                String result = updateTeamHealthDoctors(newDoctorCode, oldDoctorCode, patients, null);
                return result;
                return result;

+ 28 - 18
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java

@ -124,25 +124,35 @@ public class DoctorHealthController extends BaseController {
										  @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
										  @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
											  @RequestParam(value="pagesize",required = true) int pagesize) {
											  @RequestParam(value="pagesize",required = true) int pagesize) {
		try {
		try {
			List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient(patient, type, begin,end,page, pagesize);
			JSONArray jsonArray = new JSONArray();
			JSONArray jsonArray = new JSONArray();
			for (DevicePatientHealthIndex model : list) {
				JSONObject modelJson = new JSONObject();
				modelJson.put("id", model.getId());
				modelJson.put("patient", model.getUser());
				modelJson.put("value1", model.getValue1());
				modelJson.put("value2", model.getValue2());
				modelJson.put("value3", model.getValue3());
				modelJson.put("value4", model.getValue4());
				modelJson.put("value5", model.getValue5());
				modelJson.put("value6", model.getValue6());
				modelJson.put("value7", model.getValue7());
				modelJson.put("type", model.getType());
				modelJson.put("date", DateUtil.dateToStrShort(model.getRecordDate()));
				modelJson.put("sortDate", DateUtil.dateToStrLong(model.getSortDate()));
				modelJson.put("czrq", DateUtil.dateToStr(model.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
				jsonArray.put(modelJson);
			if (type == 1) {
				List<Object> list = healthIndexService.findIndexByPatient2(getUID(), type, begin, end, page, pagesize);
				jsonArray = new JSONArray(list);
			}else{
				List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient(getUID(), type, begin, end, page, pagesize);
				if (list != null) {
					for (DevicePatientHealthIndex model : list) {
						JSONObject modelJson = new JSONObject();
						modelJson.put("id", model.getId());
						modelJson.put("patient", model.getUser());
						modelJson.put("value1", model.getValue1());
						modelJson.put("value2", model.getValue2());
						modelJson.put("value3", model.getValue3());
						modelJson.put("value4", model.getValue4());
						modelJson.put("value5", model.getValue5());
						modelJson.put("value6", model.getValue6());
						modelJson.put("value7", model.getValue7());
						modelJson.put("type", model.getType());
						if (type == 2) {
							modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD_HH_MM_SS));
						} else {
							modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD));
						}
						modelJson.put("sortDate", DateUtil.dateToStrLong(model.getSortDate()));
						modelJson.put("czrq", DateUtil.dateToStr(model.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
						jsonArray.put(modelJson);
					}
				}
			}
			}
			return write(200, "查询成功", "list", jsonArray);
			return write(200, "查询成功", "list", jsonArray);

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

@ -8,7 +8,6 @@ import java.util.concurrent.TimeUnit;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
@ -77,7 +76,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
     *
     *
     * @param filter
     * @param filter
     * @param teamCode
     * @param teamCode
     * @param doctor 健管师编码
     * @param doctor   健管师编码
     * @param page
     * @param page
     * @param pagesize
     * @param pagesize
     * @return
     * @return
@ -212,7 +211,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject list = familyContractService.getPatientByLable(doctorcode, labelType, level, team);
            JSONObject list = familyContractService.getPatientByLable(doctorcode, labelType, level, team);
            return write(200, "查询成功", "data", list);
            return write(200, "查询成功", "data", list);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -234,13 +232,13 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                JSONArray jsonArray = list.getJSONArray(label.getLabelName());
                JSONArray jsonArray = list.getJSONArray(label.getLabelName());
                List codes = new ArrayList();
                List codes = new ArrayList();
                for (int i = 0 ;i<jsonArray.length();i++){
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject json = jsonArray.getJSONObject(i);
                    JSONObject json = jsonArray.getJSONObject(i);
                    Map info = new HashMap();
                    Map info = new HashMap();
                    String code = json.getString("code");
                    String code = json.getString("code");
                    String name = json.getString("name");
                    String name = json.getString("name");
                    info.put("code",code);
                    info.put("name",name);
                    info.put("code", code);
                    info.put("name", name);
                    codes.add(info);
                    codes.add(info);
                }
                }
                int length = codes.size();
                int length = codes.size();
@ -248,14 +246,13 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                map.put("codes", codes);
                map.put("codes", codes);
                map.put("number", length);
                map.put("number", length);
                listNum.add(map);
                listNum.add(map);
                count+=length;
                count += length;
            }
            }
            Map map = new HashMap();
            Map map = new HashMap();
            map.put("count",count);
            map.put("patients",listNum);
            map.put("count", count);
            map.put("patients", listNum);
            return write(200, "查询成功", "data", map);
            return write(200, "查询成功", "data", map);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -513,7 +510,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                        }
                        }
                    }
                    }
                } catch (Exception e) {
                } catch (Exception e) {
                    error(e);
                    e.printStackTrace();
                }
                }
            }
            }
@ -749,7 +746,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
//                    }
//                    }
//                }
//                }
            } catch (Exception e) {
            } catch (Exception e) {
                error(e);
                e.printStackTrace();
            }
            }
            result = familyContractService.getSanshiSingInfoByPatientIdCard(idCard);
            result = familyContractService.getSanshiSingInfoByPatientIdCard(idCard);
@ -761,7 +758,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            return write(200, "查询成功!", "data", result);
            return write(200, "查询成功!", "data", result);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
            return error(-1, "查询失败!");
        }
        }
    }
    }
@ -800,7 +796,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return write(-1, "不存在该患者签约");
                return write(-1, "不存在该患者签约");
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "更新失败");
            return error(-1, "更新失败");
        }
        }
    }
    }
@ -871,7 +866,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return error(-1, "患者信息查询失败!");
                return error(-1, "患者信息查询失败!");
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            e.printStackTrace();
            return error(-1, "患者信息查询失败");
            return error(-1, "患者信息查询失败");
        }
        }
    }
    }
@ -926,7 +921,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                    json.put("diseases", "");
                    json.put("diseases", "");
                }
                }
                SignFamilyRenew jtSign = familyContractService.findSigningRenewByPatient(patient);
                SignFamily jtSign = familyContractService.findSigningRenewByPatient(patient);
                // 家庭签约
                // 家庭签约
                if (jtSign != null) {
                if (jtSign != null) {
@ -942,7 +937,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return error(-1, "患者信息查询失败!");
                return error(-1, "患者信息查询失败!");
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            e.printStackTrace();
            return error(-1, "患者信息查询失败");
            return error(-1, "患者信息查询失败");
        }
        }
    }
    }
@ -975,7 +970,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            return write(200, "查询成功", "data", json);
            return write(200, "查询成功", "data", json);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1001,7 +995,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            return write(200, "查询成功", "data", new JSONObject(signFamily));
            return write(200, "查询成功", "data", new JSONObject(signFamily));
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            e.printStackTrace();
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1035,7 +1029,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            }
            }
            return write(200, "更新成功");
            return write(200, "更新成功");
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "更新失败");
            return error(-1, "更新失败");
        }
        }
    }
    }
@ -1057,45 +1050,71 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            Map patients = new HashMap();
            Map patients = new HashMap();
            JSONObject list = familyContractService.findNoHealthSignFamilyHealth(getUID(), labelType, patientName, teamCode);
            JSONObject list = familyContractService.findNoHealthSignFamilyHealth(getUID(), labelType, patientName, teamCode);
            List<SignFamily> signFamily = familyContractService.findNoHealthSignFamilyNum(teamCode);
            List<SignFamily> signFamily = familyContractService.findNoHealthSignFamilyNum(teamCode);
            if (!"4".equals(labelType)){
            if (!"4".equals(labelType)) {
                List<SignPatientLabel> s = labelDao.findByLabelTypeAndStatusAndTeamCode(labelType, 1, teamCode);
                List<SignPatientLabel> s = labelDao.findByLabelTypeAndStatusAndTeamCode(labelType, 1, teamCode);
                for (SignPatientLabel label : s) {
                for (SignPatientLabel label : s) {
                    Map map = new HashMap();
                    Map map = new HashMap();
                    String labelName = label.getLabelName();
                    String labelName = label.getLabelName();
                    JSONArray jsonArray = list.getJSONArray(label.getLabelName());
                    JSONArray jsonArray = list.getJSONArray(label.getLabelName());
               /* List codes = new ArrayList();
                for (Object patient:jsonArray) {
                    JSONObject jsonObject = new JSONObject(patient.toString());
                    String code = jsonObject.get("code").toString();
                    codes.add(code);
                }*/
                    List codes = new ArrayList();
                    for (Object patient : jsonArray) {
                        Map tempmap = new HashMap();
                        JSONObject jsonObject = new JSONObject(patient.toString());
                        String code = jsonObject.get("code").toString();
                        tempmap.put("code",code);
                        codes.add(tempmap);
                    }
                    int length = jsonArray.length();
                    int length = jsonArray.length();
                    map.put("label", labelName);
                    map.put("label", labelName);
                    map.put("number", length);
                    map.put("number", length);
//                map.put("codes", codes);
                    map.put("codes", codes);
                    listNum.add(map);
                    listNum.add(map);
                }
                }
            }else {
            } else {
                JSONArray jsonArray = list.getJSONArray("孕产妇");
                JSONArray jsonArray = list.getJSONArray("孕产妇");
                Map map = new HashMap();
                Map map = new HashMap();
                map.put("label", "孕产妇");
                map.put("label", "孕产妇");
                List temp = new ArrayList();
                for (Object str : jsonArray) {
                    Map tempmap = new HashMap();
                    Object code = new JSONObject(str.toString()).get("code");
                    tempmap.put("code",code);
                    temp.add(tempmap);
                }
                map.put("codes", temp);
                map.put("number", jsonArray.length());
                map.put("number", jsonArray.length());
                listNum.add(map);
                listNum.add(map);
                JSONArray jsonArray1 = list.getJSONArray("未标注");
                JSONArray jsonArray1 = list.getJSONArray("未标注");
                Map map1 = new HashMap();
                Map map1 = new HashMap();
                map1.put("label", "未标注");
                map1.put("label", "未标注");
                List temp1 = new ArrayList();
                for (Object str : jsonArray1) {
                    Map tempmap = new HashMap();
                    Object code = new JSONObject(str.toString()).get("code");
                    tempmap.put("code",code);
                    temp1.add(tempmap);
                }
                map1.put("codes", temp1);
                map1.put("number", jsonArray1.length());
                map1.put("number", jsonArray1.length());
                listNum.add(map1);
                listNum.add(map1);
                JSONArray jsonArray2 = list.getJSONArray("儿童");
                JSONArray jsonArray2 = list.getJSONArray("儿童");
                Map map2 = new HashMap();
                Map map2 = new HashMap();
                map2.put("label", "儿童");
                map2.put("label", "儿童");
                List temp2 = new ArrayList();
                for (Object str : jsonArray2) {
                    Map tempmap = new HashMap();
                    Object code = new JSONObject(str.toString()).get("code");
                    tempmap.put("code",code);
                    temp2.add(tempmap);
                }
                map2.put("codes", temp2);
                map2.put("number", jsonArray2.length());
                map2.put("number", jsonArray2.length());
                listNum.add(map2);
                listNum.add(map2);
            }
            }
            patients.put("count",list.length());
            patients.put("count",signFamily.size());
            patients.put("patients",listNum);
            patients.put("count", list.length());
            patients.put("count", signFamily.size());
            patients.put("patients", listNum);
            return write(200, "查询成功!", "data", patients);
            return write(200, "查询成功!", "data", patients);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            error(e);
@ -1119,7 +1138,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject list = familyContractService.findNoHealthSignFamilyHealth(getUID(), labelType, patientName, teamCode);
            JSONObject list = familyContractService.findNoHealthSignFamilyHealth(getUID(), labelType, patientName, teamCode);
            return write(200, "签约数据加载成功!", "data", list);
            return write(200, "签约数据加载成功!", "data", list);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            e.printStackTrace();
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1139,7 +1158,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject list = familyContractService.findNoHealthSignFamilyHealthByParams(getUID(), teamCode, params);
            JSONObject list = familyContractService.findNoHealthSignFamilyHealthByParams(getUID(), teamCode, params);
            return write(200, "签约数据加载成功!", "data", list);
            return write(200, "签约数据加载成功!", "data", list);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1159,7 +1177,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject list = familyContractService.findByParamsWithDoctor(doctor, teamCode, params, level);
            JSONObject list = familyContractService.findByParamsWithDoctor(doctor, teamCode, params, level);
            return write(200, "签约数据加载成功!", "data", list);
            return write(200, "签约数据加载成功!", "data", list);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1184,7 +1201,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            }
            }
            return write(200, "查询成功", "data", jo);
            return write(200, "查询成功", "data", jo);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            e.printStackTrace();
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1255,7 +1272,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            }
            }
            return write(200, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            e.printStackTrace();
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1280,7 +1297,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.isPatientAndDoctorExistSign(patient, doctor);
            JSONObject result = familyContractService.isPatientAndDoctorExistSign(patient, doctor);
            return write(200, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1305,7 +1321,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.isPatientAndDoctorCanSign(patient, doctor);
            JSONObject result = familyContractService.isPatientAndDoctorCanSign(patient, doctor);
            return write(200, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            e.printStackTrace();
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1326,7 +1342,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.getPatientDoctors(patient, getUID());
            JSONObject result = familyContractService.getPatientDoctors(patient, getUID());
            return write(200, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1347,7 +1362,6 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.getTeamDoctors(sessionId, getUID());
            JSONObject result = familyContractService.getTeamDoctors(sessionId, getUID());
            return write(200, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1366,7 +1380,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.getPatientSignDoctors(patient);
            JSONObject result = familyContractService.getPatientSignDoctors(patient);
            return write(200, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            e.printStackTrace();
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1384,7 +1398,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.getPatientSignDoctorsByTeam(sessionId);
            JSONObject result = familyContractService.getPatientSignDoctorsByTeam(sessionId);
            return write(200, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            e.printStackTrace();
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1401,7 +1415,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.getPatientAndDoctorTeams(patient, getUID());
            JSONObject result = familyContractService.getPatientAndDoctorTeams(patient, getUID());
            return write(200, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            e.printStackTrace();
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
@ -1469,7 +1483,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            }
            }
            return write(200, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            e.printStackTrace();
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }

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

@ -447,10 +447,28 @@ public class DoctorSignController extends WeixinBaseController {
                             @RequestParam(required = true)String patient,
                             @RequestParam(required = true)String patient,
                             @RequestParam(required = false) Long mesId ){
                             @RequestParam(required = false) Long mesId ){
        try{
        try{
            int rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId);
            int isNowYearSign = signWebService.checkNowYearSign(getUID(),patient);
            if(isNowYearSign==0){
                return  write(200, "已经存在下个年度的签约关系", "data", -1);
            }
            Calendar cal = Calendar.getInstance();
            int year = cal.get(Calendar.YEAR);
            int month = cal.get(Calendar.MONTH)+1;
            int rs = 0;
            if(month<7){
                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"");
//            int rs =signWebService.agreeRenew(getAccessToken(),"test00000000005",patient,state);
//            int rs =signWebService.agreeRenew(getAccessToken(),"test00000000005",patient,state);
            }else{
                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"");
                //如果没有续签记录,走签约记录
                if(rs==0){
                    rs =signWebService.agreeRenewOverDue(getAccessToken(),getUID(),patient,state,mesId,year+"");
                }
            }
            if(rs == 0){
            if(rs == 0){
                return error(-1, "操作失败");
                return  write(200, "未找到签约记录", "data", rs);
            }else{
            }else{
                return write(200, "操作成功!", "data", rs);
                return write(200, "操作成功!", "data", rs);
            }
            }
@ -522,8 +540,8 @@ public class DoctorSignController extends WeixinBaseController {
    @ApiOperation(value = "提醒居民续签")
    @ApiOperation(value = "提醒居民续签")
    public String remindPatientRenew(@RequestParam(required = true)String patient){
    public String remindPatientRenew(@RequestParam(required = true)String patient){
        try{
        try{
            int rs =signWebService.remainPatientRenew(getAccessToken(),patient,getUID());
            //int rs =signWebService.remainPatientRenew(getAccessToken(),patient,"test00000000006");
            //int rs =signWebService.remainPatientRenew(getAccessToken(),patient,getUID());
            int rs =signWebService.remainPatientRenew(getAccessToken(),patient,"zbqD201703150222");
            if(rs==-1){
            if(rs==-1){
                return error(-1, "提醒失败");
                return error(-1, "提醒失败");
            }else if(rs ==1){
            }else if(rs ==1){

+ 16 - 16
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -38,7 +38,7 @@ public class PatientDeviceController extends BaseController {
    /**
    /**
     * 设置血糖仪时间段
     * 设置及修改血糖仪时间段
     * 默认时间段如下
     * 默认时间段如下
     * fasting: 00:00-07:59
     * fasting: 00:00-07:59
     * afterBreakfast: 08:00-09:59
     * afterBreakfast: 08:00-09:59
@ -48,23 +48,23 @@ public class PatientDeviceController extends BaseController {
     * afterDinner: 18:00-19:59
     * afterDinner: 18:00-19:59
     * beforeSleep: 20:00-23:59
     * beforeSleep: 20:00-23:59
     */
     */
    @ApiOperation("设置血糖仪时间段")
    @ApiOperation("设置修改血糖仪时间段")
    @RequestMapping(value = "/setBloodTime", method = RequestMethod.GET)
    @RequestMapping(value = "/setBloodTime", method = RequestMethod.GET)
    @ResponseBody
    @ResponseBody
    public String setBloodTime(@RequestParam String fastingStart,
                               @RequestParam String fastingEnd,
                               @RequestParam String afterBreakfastStart,
                               @RequestParam String afterBreakfastEnd,
                               @RequestParam String beforeLunchStart,
                               @RequestParam String beforeLunchEnd,
                               @RequestParam String afterLunchStart,
                               @RequestParam String afterLunchEnd,
                               @RequestParam String beforeDinnerStart,
                               @RequestParam String beforeDinnerEnd,
                               @RequestParam String afterDinnerStart,
                               @RequestParam String afterDinnerEnd,
                               @RequestParam String beforeSleepStart,
                               @RequestParam String beforeSleepEnd,
    public String setBloodTime(@RequestParam(required = false) String fastingStart,
                               @RequestParam(required = false) String fastingEnd,
                               @RequestParam(required = false) String afterBreakfastStart,
                               @RequestParam(required = false) String afterBreakfastEnd,
                               @RequestParam(required = false) String beforeLunchStart,
                               @RequestParam(required = false) String beforeLunchEnd,
                               @RequestParam(required = false) String afterLunchStart,
                               @RequestParam(required = false) String afterLunchEnd,
                               @RequestParam(required = false) String beforeDinnerStart,
                               @RequestParam(required = false) String beforeDinnerEnd,
                               @RequestParam(required = false) String afterDinnerStart,
                               @RequestParam(required = false) String afterDinnerEnd,
                               @RequestParam(required = false)String beforeSleepStart,
                               @RequestParam(required = false)String beforeSleepEnd,
                               @RequestParam String deviceSN) {
                               @RequestParam String deviceSN) {
        try {
        try {

+ 579 - 547
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java

@ -1,9 +1,11 @@
package com.yihu.wlyy.web.patient.health;
package com.yihu.wlyy.web.patient.health;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSON;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.util.SendNews;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
@ -30,576 +32,606 @@ import com.yihu.wlyy.web.BaseController;
@Api(description = "患者指标")
@Api(description = "患者指标")
public class PatientHealthController extends BaseController {
public class PatientHealthController extends BaseController {
	@Autowired
	private PatientHealthIndexService healthIndexService;
    @Autowired
    private PatientHealthIndexService healthIndexService;
	/**
	 * 更改接口(包括手动记录的修改和所有的删除)
	 * 血糖  value1 血糖值 value2 1234567血糖时间段
	 * 血压  value1 高压 value2 低压 value3脉搏 value4心率不齐(0否 1是)
	 * 体重 value1 体重值
	 * 腰围 value1 腰围值
	 *
	 * @param id
	 * @param value1 字段值
	 * @return
	 */
	@RequestMapping(value = "/modify", method = RequestMethod.GET)
	@ResponseBody
	public String modify(@RequestParam long id,
						 @RequestParam(required = false) String value1,
						 @RequestParam(required = false) String value2,
						 @RequestParam(required = false) String value3,
						 @RequestParam(required = false) String value4) {
		try {
			healthIndexService.modify(id, value1, value2, value3, value4);
			return write(200, "更改成功!");
		} catch (Exception e) {
			error(e);
			return invalidUserException(e, -1, "更改失败!");
		}
	}
    /**
     * 更改接口(包括手动记录的修改和所有的删除)
     * 血糖  value1 血糖值 value2 1234567血糖时间段
     * 血压  value1 高压 value2 低压 value3脉搏 value4心率不齐(0否 1是)
     * 体重 value1 体重值
     * 腰围 value1 腰围值
     *
     * @param id
     * @param recordDate 记录时间
     * @param value1 字段值
     * @return
     */
    @RequestMapping(value = "/modify", method = RequestMethod.GET)
    @ResponseBody
    public String modify(@RequestParam long id,
                         @RequestParam(required = false) String recordDate,
                         @RequestParam(required = false) String value1,
                         @RequestParam(required = false) String value2,
                         @RequestParam(required = false) String value3,
                         @RequestParam(required = false) String value4) {
        try {
            healthIndexService.modify(id,recordDate, value1, value2, value3, value4);
            return write(200, "更改成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "更改失败!");
        }
    }
	/**
	 * 患者最近的各项健康信息
	 *
	 * @return
	 */
	@RequestMapping(value = "/getRecentData")
	@ResponseBody
	public String getRecentData() {
		try {
			List list = new ArrayList();
			String patient = getUID();
    /**
     * 保健记录更改接口(包括手动记录的修改和所有的删除)
     *
     * @param id
     * @param type   饮食1,运动2,用药3
     * @param value1 记录时间
     * @param value2 饮食内容CONTETN  时长 用药
     * @param value3 上传图片 强度
     * @param value4 运动项目
     * @return
     */
    @RequestMapping(value = "/modifyHealthCare", method = RequestMethod.GET)
    @ResponseBody
    public String modifyHealthCare(@RequestParam long id,
                                   @RequestParam int type,
                                   @RequestParam(required = false) String value1,
                                   @RequestParam(required = false) String value2,
                                   @RequestParam(required = false) String value3,
                                   @RequestParam(required = false) String value4) {
        try {
            healthIndexService.modifyHealthCare(id, type, value1, value2, value3, value4);
            return write(200, "更改成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "更改失败!");
        }
    }
    /**
     * 患者最近的各项健康信息
     *
     * @return
     */
    @RequestMapping(value = "/getRecentData")
    @ResponseBody
    public String getRecentData() {
        try {
            List list = new ArrayList();
            String patient = getUID();
//            健康指标类型(1血糖,2血压,3体重,4腰围)
//            健康指标类型(1血糖,2血压,3体重,4腰围)
			Map map = healthIndexService.findDataByPatient(patient, 1);
			Map map1 = healthIndexService.findDataByPatient(patient, 2);
			Map map2 = healthIndexService.findDataByPatient(patient, 3);
			Map map3 = healthIndexService.findDataByPatient(patient, 4);
            Map map = healthIndexService.findDataByPatient(patient, 1);
            Map map1 = healthIndexService.findDataByPatient(patient, 2);
            Map map2 = healthIndexService.findDataByPatient(patient, 3);
            Map map3 = healthIndexService.findDataByPatient(patient, 4);
//            血糖各个时间段取值
//            血糖各个时间段取值
			if (map.size() != 0) {
				Map sugar = new HashMap();
				Object time = map.get("time");
				String isDevice = map.get("isDevice").toString();
				Object value1 = map.get("value1");
				Object value2 = map.get("value2");
				Object value3 = map.get("value3");
				Object value4 = map.get("value4");
				Object value5 = map.get("value5");
				Object value6 = map.get("value6");
				Object value7 = map.get("value7");
				sugar.put("type", 1);
				sugar.put("isDevice", isDevice);
				if (time != null) {
					sugar.put("time", time);
				}
				if (value1 != null) {
					sugar.put("value1", value1);
				}
				if (value2 != null) {
					sugar.put("value2", value2);
				}
				if (value3 != null) {
					sugar.put("value3", value3);
				}
				if (value4 != null) {
					sugar.put("value4", value4);
				}
				if (value5 != null) {
					sugar.put("value5", value5);
				}
				if (value6 != null) {
					sugar.put("value6", value6);
				}
				if (value7 != null) {
					sugar.put("value7", value7);
				}
				list.add(sugar);
			}
            if (map.size() != 0) {
                Map sugar = new HashMap();
                Object time = map.get("time");
                String isDevice = map.get("isDevice").toString();
                Object value1 = map.get("value1");
                Object value2 = map.get("value2");
                Object value3 = map.get("value3");
                Object value4 = map.get("value4");
                Object value5 = map.get("value5");
                Object value6 = map.get("value6");
                Object value7 = map.get("value7");
                sugar.put("type", 1);
                sugar.put("isDevice", isDevice);
                if (time != null) {
                    sugar.put("time", time);
                }
                if (value1 != null) {
                    sugar.put("value1", value1);
                }
                if (value2 != null) {
                    sugar.put("value2", value2);
                }
                if (value3 != null) {
                    sugar.put("value3", value3);
                }
                if (value4 != null) {
                    sugar.put("value4", value4);
                }
                if (value5 != null) {
                    sugar.put("value5", value5);
                }
                if (value6 != null) {
                    sugar.put("value6", value6);
                }
                if (value7 != null) {
                    sugar.put("value7", value7);
                }
                list.add(sugar);
            }
//            血压  value1高压 value2低压 value3脉搏 value4心率不齐
//            血压  value1高压 value2低压 value3脉搏 value4心率不齐
			if (map1.size() != 0) {
				Map pa = new HashMap();
				Object time = map1.get("time");
				String isDevice = map1.get("isDevice").toString();
				Object value1 = map1.get("value1");
				Object value2 = map1.get("value2");
				Object value3 = map1.get("value3");
				Object value4 = map1.get("value4");
				Object value5 = map1.get("value5");
				Object value6 = map1.get("value6");
				Object value7 = map1.get("value7");
				pa.put("type", 2);
				pa.put("isDevice", isDevice);
				if (time != null) {
					pa.put("time", time);
				}
				if (value1 != null) {
					pa.put("value1", value1);
				}
				if (value2 != null) {
					pa.put("value2", value2);
				}
				if (value3 != null) {
					pa.put("value3", value3);
				}
				if (value4 != null) {
					pa.put("value4", value4);
				}
				if (value5 != null) {
					pa.put("value5", value5);
				}
				if (value6 != null) {
					pa.put("value6", value6);
				}
				if (value7 != null) {
					pa.put("value7", value7);
				}
				list.add(pa);
			}
            if (map1.size() != 0) {
                Map pa = new HashMap();
                Object time = map1.get("time");
                String isDevice = map1.get("isDevice").toString();
                Object value1 = map1.get("value1");
                Object value2 = map1.get("value2");
                Object value3 = map1.get("value3");
                Object value4 = map1.get("value4");
                Object value5 = map1.get("value5");
                Object value6 = map1.get("value6");
                Object value7 = map1.get("value7");
                pa.put("type", 2);
                pa.put("isDevice", isDevice);
                if (time != null) {
                    pa.put("time", time);
                }
                if (value1 != null) {
                    pa.put("value1", value1);
                }
                if (value2 != null) {
                    pa.put("value2", value2);
                }
                if (value3 != null) {
                    pa.put("value3", value3);
                }
                if (value4 != null) {
                    pa.put("value4", value4);
                }
                if (value5 != null) {
                    pa.put("value5", value5);
                }
                if (value6 != null) {
                    pa.put("value6", value6);
                }
                if (value7 != null) {
                    pa.put("value7", value7);
                }
                list.add(pa);
            }
//            体重 value1 体重
//            体重 value1 体重
			if (map2.size() != 0) {
				Map weight = new HashMap();
				Object time = map2.get("time");
				String isDevice = map2.get("isDevice").toString();
				Object value1 = map2.get("value1");
				Object value2 = map2.get("value2");
				Object value3 = map2.get("value3");
				Object value4 = map2.get("value4");
				Object value5 = map2.get("value5");
				Object value6 = map2.get("value6");
				Object value7 = map2.get("value7");
				weight.put("type", 3);
				weight.put("isDevice", isDevice);
				if (time != null) {
					weight.put("time", time);
				}
				if (value1 != null) {
					weight.put("value1", value1);
				}
				if (value2 != null) {
					weight.put("value2", value2);
				}
				if (value3 != null) {
					weight.put("value3", value3);
				}
				if (value4 != null) {
					weight.put("value4", value4);
				}
				if (value5 != null) {
					weight.put("value5", value5);
				}
				if (value6 != null) {
					weight.put("value6", value6);
				}
				if (value7 != null) {
					weight.put("value7", value7);
				}
				list.add(weight);
			}
            if (map2.size() != 0) {
                Map weight = new HashMap();
                Object time = map2.get("time");
                String isDevice = map2.get("isDevice").toString();
                Object value1 = map2.get("value1");
                Object value2 = map2.get("value2");
                Object value3 = map2.get("value3");
                Object value4 = map2.get("value4");
                Object value5 = map2.get("value5");
                Object value6 = map2.get("value6");
                Object value7 = map2.get("value7");
                weight.put("type", 3);
                weight.put("isDevice", isDevice);
                if (time != null) {
                    weight.put("time", time);
                }
                if (value1 != null) {
                    weight.put("value1", value1);
                }
                if (value2 != null) {
                    weight.put("value2", value2);
                }
                if (value3 != null) {
                    weight.put("value3", value3);
                }
                if (value4 != null) {
                    weight.put("value4", value4);
                }
                if (value5 != null) {
                    weight.put("value5", value5);
                }
                if (value6 != null) {
                    weight.put("value6", value6);
                }
                if (value7 != null) {
                    weight.put("value7", value7);
                }
                list.add(weight);
            }
//            腰围 value1腰围
//            腰围 value1腰围
			if (map3.size() != 0) {
				Map waist = new HashMap();
				Object time = map3.get("time");
				String isDevice = map3.get("isDevice").toString();
				Object value1 = map3.get("value1");
				Object value2 = map3.get("value2");
				Object value3 = map3.get("value3");
				Object value4 = map3.get("value4");
				Object value5 = map3.get("value5");
				Object value6 = map3.get("value6");
				Object value7 = map3.get("value7");
				waist.put("type", 4);
				waist.put("isDevice", isDevice);
				if (time != null) {
					waist.put("time", time);
				}
				if (value1 != null) {
					waist.put("value1", value1);
				}
				if (value2 != null) {
					waist.put("value2", value2);
				}
				if (value3 != null) {
					waist.put("value3", value3);
				}
				if (value4 != null) {
					waist.put("value4", value4);
				}
				if (value5 != null) {
					waist.put("value5", value5);
				}
				if (value6 != null) {
					waist.put("value6", value6);
				}
				if (value7 != null) {
					waist.put("value7", value7);
				}
				list.add(waist);
			}
			return write(200, "查询成功", "data", list);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
            if (map3.size() != 0) {
                Map waist = new HashMap();
                Object time = map3.get("time");
                String isDevice = map3.get("isDevice").toString();
                Object value1 = map3.get("value1");
                Object value2 = map3.get("value2");
                Object value3 = map3.get("value3");
                Object value4 = map3.get("value4");
                Object value5 = map3.get("value5");
                Object value6 = map3.get("value6");
                Object value7 = map3.get("value7");
                waist.put("type", 4);
                waist.put("isDevice", isDevice);
                if (time != null) {
                    waist.put("time", time);
                }
                if (value1 != null) {
                    waist.put("value1", value1);
                }
                if (value2 != null) {
                    waist.put("value2", value2);
                }
                if (value3 != null) {
                    waist.put("value3", value3);
                }
                if (value4 != null) {
                    waist.put("value4", value4);
                }
                if (value5 != null) {
                    waist.put("value5", value5);
                }
                if (value6 != null) {
                    waist.put("value6", value6);
                }
                if (value7 != null) {
                    waist.put("value7", value7);
                }
                list.add(waist);
            }
            return write(200, "查询成功", "data", list);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
	/**
	 * 患者最近填写的健康指标
	 *
	 * @return
	 */
	@RequestMapping(value = "recent")
	@ResponseBody
	public String recent() {
		try {
			JSONArray array = healthIndexService.findRecentByPatient(getUID());
			if (array != null) {
				return write(200, "查询成功", "list", array);
			} else {
				return error(-1, "查询失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
    /**
     * 患者最近填写的健康指标
     *
     * @return
     */
    @RequestMapping(value = "recent")
    @ResponseBody
    public String recent() {
        try {
            JSONArray array = healthIndexService.findRecentByPatient(getUID());
            if (array != null) {
                return write(200, "查询成功", "list", array);
            } else {
                return error(-1, "查询失败");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
	/**
	 * 获取患者最后填写的健康指标(新)
	 *
	 * @return
	 */
	@RequestMapping(value = "last")
	@ResponseBody
	public String last() {
		try {
			Map<String, Object> map = new HashMap<>();
			String patient = getUID();
			DevicePatientHealthIndex xt = healthIndexService.findLastByPatien(patient, 1);
			if (xt != null) {
				map.put("xt", xt);
			}
			DevicePatientHealthIndex xy = healthIndexService.findLastByPatien(patient, 2);
			if (xy != null) {
				map.put("xy", xy);
			}
			DevicePatientHealthIndex tz = healthIndexService.findLastByPatien(patient, 3);
			if (tz != null) {
				map.put("tz", tz);
			}
			DevicePatientHealthIndex sg = healthIndexService.findLastByPatien(patient, 4);
			if (sg != null) {
				map.put("sg", sg);
			}
			return write(200, "查询成功", "data", map);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
    /**
     * 获取患者最后填写的健康指标(新)
     *
     * @return
     */
    @RequestMapping(value = "last")
    @ResponseBody
    public String last() {
        try {
            Map<String, Object> map = new HashMap<>();
            String patient = getUID();
            DevicePatientHealthIndex xt = healthIndexService.findLastByPatien(patient, 1);
            if (xt != null) {
                map.put("xt", xt);
            }
            DevicePatientHealthIndex xy = healthIndexService.findLastByPatien(patient, 2);
            if (xy != null) {
                map.put("xy", xy);
            }
            DevicePatientHealthIndex tz = healthIndexService.findLastByPatien(patient, 3);
            if (tz != null) {
                map.put("tz", tz);
            }
            DevicePatientHealthIndex sg = healthIndexService.findLastByPatien(patient, 4);
            if (sg != null) {
                map.put("sg", sg);
            }
            return write(200, "查询成功", "data", map);
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
	/**
	 * 保存患者健康指标 (旧)
	 *
	 * @param intervene 干预标志
	 * @param time      记录时间
	 * @param value1    血糖/收缩压/体重/腰围/早餐前空腹
	 * @param value2    舒张压/早餐后空腹
	 * @param value3    午餐空腹
	 * @param value4    午餐后
	 * @param value5    晚餐空腹
	 * @param value6    晚餐后
	 * @param value7    睡前
	 * @param type      健康指标类型(1血糖,2血压,3体重,4腰围)
	 * @return 操作结果
	 */
	@RequestMapping(value = "add")
	@ResponseBody
	public String add(@RequestParam(required = false) String intervene, String time, String value1, String value2, String value3, String value4, String value5, String value6, String value7, int type) {
		try {
    /**
     * 保存患者健康指标 (旧)
     *
     * @param intervene 干预标志
     * @param time      记录时间
     * @param value1    血糖/收缩压/体重/腰围/早餐前空腹
     * @param value2    舒张压/早餐后空腹
     * @param value3    午餐空腹
     * @param value4    午餐后
     * @param value5    晚餐空腹
     * @param value6    晚餐后
     * @param value7    睡前
     * @param type      健康指标类型(1血糖,2血压,3体重,4腰围)
     * @return 操作结果
     */
    @RequestMapping(value = "add")
    @ResponseBody
    public String add(@RequestParam(required = false) String intervene, String time, String value1, String value2, String value3, String value4, String value5, String value6, String value7, int type) {
        try {
			DevicePatientHealthIndex healthIndex = null;
			if (type == 1) {
				// 血糖等一天只能存在一条数据
				Iterable<DevicePatientHealthIndex> list = healthIndexService.findByPatienDate(getUID(), type, DateUtil.strToDate(time, DateUtil.YYYY_MM_DD));
				if (list != null) {
					for (DevicePatientHealthIndex model : list) {
						healthIndex = model;
					}
				}
			}
			if (healthIndex == null) {
				healthIndex = new DevicePatientHealthIndex();
			}
			// 设置患者标识
			healthIndex.setUser(getUID());
			// 设置干预标识,默认为NULL
			healthIndex.setIntervene(intervene);
            DevicePatientHealthIndex healthIndex = null;
            if (type == 1) {
                // 血糖等一天只能存在一条数据
                Iterable<DevicePatientHealthIndex> list = healthIndexService.findByPatienDate(getUID(), type, DateUtil.strToDate(time, DateUtil.YYYY_MM_DD));
                if (list != null) {
                    for (DevicePatientHealthIndex model : list) {
                        healthIndex = model;
                    }
                }
            }
            if (healthIndex == null) {
                healthIndex = new DevicePatientHealthIndex();
            }
            // 设置患者标识
            healthIndex.setUser(getUID());
            // 设置干预标识,默认为NULL
            healthIndex.setIntervene(intervene);
			int index = 0;
			double value = 0;
            int index = 0;
            double value = 0;
			// 设置血糖/收缩压/体重/腰围/早餐前空腹
			if (NumberUtils.toDouble(value1, 0) > 0) {
				healthIndex.setValue1(value1);
				index = 1;
				value = NumberUtils.toDouble(value1, 0);
			}
			// 设置 舒张压/早餐后血糖
			if (NumberUtils.toDouble(value2, 0) > 0) {
				healthIndex.setValue2(value2);
				index = 2;
				value = NumberUtils.toDouble(value2, 0);
			}
			// 设置午餐前血糖
			if (NumberUtils.toDouble(value3, 0) > 0) {
				healthIndex.setValue3(value3);
				index = 3;
				value = NumberUtils.toDouble(value3, 0);
			}
			// 设置午餐后血糖
			if (NumberUtils.toDouble(value4, 0) > 0) {
				healthIndex.setValue4(value4);
				index = 4;
				value = NumberUtils.toDouble(value4, 0);
			}
			// 设置晚餐前血糖
			if (NumberUtils.toDouble(value5, 0) > 0) {
				healthIndex.setValue5(value5);
				index = 5;
				value = NumberUtils.toDouble(value5, 0);
			}
			// 设置晚餐后血糖
			if (NumberUtils.toDouble(value6, 0) > 0) {
				healthIndex.setValue6(value6);
				index = 6;
				value = NumberUtils.toDouble(value6, 0);
			}
			// 设置睡前血糖
			if (NumberUtils.toDouble(value7, 0) > 0) {
				healthIndex.setValue7(value7);
				index = 7;
				value = NumberUtils.toDouble(value7, 0);
			}
			// 设置健康指标类型(1血糖,2血压,3体重,4腰围)
			healthIndex.setType(type);
			// 设置记录时间
			if (type == 2) {
				healthIndex.setRecordDate(DateUtil.strToDate(time, DateUtil.YYYY_MM_DD_HH_MM_SS));
			} else {
				healthIndex.setRecordDate(DateUtil.strToDate(time, DateUtil.YYYY_MM_DD));
			}
			healthIndex.setSortDate(DateUtil.strToDateAppendNowTime(time, DateUtil.YYYY_MM_DD_HH_MM_SS));
			// 保存到数据库
			healthIndex = healthIndexService.save(healthIndex, index, value, getUID());
			if (healthIndex == null) {
				return error(-1, "保存失败!");
			}
			return success("保存成功!");
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "保存失败!");
		}
	}
            // 设置血糖/收缩压/体重/腰围/早餐前空腹
            if (NumberUtils.toDouble(value1, 0) > 0) {
                healthIndex.setValue1(value1);
                index = 1;
                value = NumberUtils.toDouble(value1, 0);
            }
            // 设置 舒张压/早餐后血糖
            if (NumberUtils.toDouble(value2, 0) > 0) {
                healthIndex.setValue2(value2);
                index = 2;
                value = NumberUtils.toDouble(value2, 0);
            }
            // 设置午餐前血糖
            if (NumberUtils.toDouble(value3, 0) > 0) {
                healthIndex.setValue3(value3);
                index = 3;
                value = NumberUtils.toDouble(value3, 0);
            }
            // 设置午餐后血糖
            if (NumberUtils.toDouble(value4, 0) > 0) {
                healthIndex.setValue4(value4);
                index = 4;
                value = NumberUtils.toDouble(value4, 0);
            }
            // 设置晚餐前血糖
            if (NumberUtils.toDouble(value5, 0) > 0) {
                healthIndex.setValue5(value5);
                index = 5;
                value = NumberUtils.toDouble(value5, 0);
            }
            // 设置晚餐后血糖
            if (NumberUtils.toDouble(value6, 0) > 0) {
                healthIndex.setValue6(value6);
                index = 6;
                value = NumberUtils.toDouble(value6, 0);
            }
            // 设置睡前血糖
            if (NumberUtils.toDouble(value7, 0) > 0) {
                healthIndex.setValue7(value7);
                index = 7;
                value = NumberUtils.toDouble(value7, 0);
            }
            // 设置健康指标类型(1血糖,2血压,3体重,4腰围)
            healthIndex.setType(type);
            // 设置记录时间
            if (type == 2) {
                healthIndex.setRecordDate(DateUtil.strToDate(time, DateUtil.YYYY_MM_DD_HH_MM_SS));
            } else {
                healthIndex.setRecordDate(DateUtil.strToDate(time, DateUtil.YYYY_MM_DD));
            }
            healthIndex.setSortDate(DateUtil.strToDateAppendNowTime(time, DateUtil.YYYY_MM_DD_HH_MM_SS));
            // 保存到数据库
            healthIndex = healthIndexService.save(healthIndex, index, value, getUID());
            if (healthIndex == null) {
                return error(-1, "保存失败!");
            }
            return success("保存成功!");
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "保存失败!");
        }
    }
	@RequestMapping(value = "addPatientHealthIndex", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("新增患者指标")
	public String addPatientHealthIndex(@ApiParam(name = "data", value = "指标数据", defaultValue = "{\"gi\":\"5.5\",\"gi_type\":\"1\"}")
										@RequestParam(value = "data", required = true) String data,
										@ApiParam(name = "type", value = "指标类型", defaultValue = "1")
										@RequestParam(value = "type", required = true) String type) {
		try {
			DevicePatientHealthIndex obj = healthIndexService.addPatientHealthIndex(data, type, getUID(), null);
			//血糖和血压需要校验
			if (type.equals("1") || type.equals("2")) {
				healthIndexService.verifyHealthIndex(obj.getId());
			}
    @RequestMapping(value = "addPatientHealthIndex", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("新增患者指标")
    public String addPatientHealthIndex(@ApiParam(name = "data", value = "指标数据", defaultValue = "{\"gi\":\"5.5\",\"gi_type\":\"1\"}")
                                        @RequestParam(value = "data", required = true) String data,
                                        @ApiParam(name = "type", value = "指标类型", defaultValue = "1")
                                        @RequestParam(value = "type", required = true) String type) {
        try {
            DevicePatientHealthIndex obj = healthIndexService.addPatientHealthIndex(data, type, getUID(), null);
            //血糖和血压需要校验
            if (type.equals("1") || type.equals("2")) {
                healthIndexService.verifyHealthIndex(obj.getId());
            }
			return success("新增患者指标成功!");
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
            return success("新增患者指标成功!");
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
	@RequestMapping(value = "verifyPatientHealthIndex", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("校验患者指标")
	public String verifyPatientHealthIndex(@ApiParam(name = "id", value = "指标id", defaultValue = "")
										   @RequestParam(value = "id", required = true) Long id) {
		try {
			healthIndexService.verifyHealthIndex(id);
    @RequestMapping(value = "verifyPatientHealthIndex", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("校验患者指标")
    public String verifyPatientHealthIndex(@ApiParam(name = "id", value = "指标id", defaultValue = "")
                                           @RequestParam(value = "id", required = true) Long id) {
        try {
            healthIndexService.verifyHealthIndex(id);
			return success("校验患者指标成功!");
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
            return success("校验患者指标成功!");
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
	/**
	 * 根据患者标志获取健康指标
	 *
	 * @param type 健康指标类型(1血糖,2血压,3体重,4腰围)
	 * @return 操作结果
	 */
	@RequestMapping(value = "chart", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("根据患者标志获取健康指标(图表)")
	public String getHealthIndexChartByPatient(@ApiParam(name = "type", value = "指标类型", defaultValue = "1")
											   @RequestParam(value = "type", required = true) int type,
											   @ApiParam(name = "gi_type", value = "就餐类型", defaultValue = "1")
											   @RequestParam(value = "gi_type", required = false) int gi_type,
											   @ApiParam(name = "begin", value = "开始时间", defaultValue = "2016-08-23 00:00:00")
											   @RequestParam(value = "begin", required = true) String begin,
											   @ApiParam(name = "end", value = "结束时间", defaultValue = "2016-09-23 00:00:00")
											   @RequestParam(value = "end", required = true) String end) {
		try {
			List<DevicePatientHealthIndex> list =
					healthIndexService.findChartByPatient(getUID(), type, gi_type, begin, end);
    /**
     * 根据患者标志获取健康指标
     *
     * @param type 健康指标类型(1血糖,2血压,3体重,4腰围)
     * @return 操作结果
     */
    @RequestMapping(value = "chart", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("根据患者标志获取健康指标(图表)")
    public String getHealthIndexChartByPatient(@ApiParam(name = "type", value = "指标类型", defaultValue = "1")
                                               @RequestParam(value = "type", required = true) int type,
                                               @ApiParam(name = "gi_type", value = "就餐类型", defaultValue = "1")
                                               @RequestParam(value = "gi_type", required = false) int gi_type,
                                               @ApiParam(name = "begin", value = "开始时间", defaultValue = "2016-08-23 00:00:00")
                                               @RequestParam(value = "begin", required = true) String begin,
                                               @ApiParam(name = "end", value = "结束时间", defaultValue = "2016-09-23 00:00:00")
                                               @RequestParam(value = "end", required = true) String end) {
        try {
            List<DevicePatientHealthIndex> list =
                    healthIndexService.findChartByPatient(getUID(), type, gi_type, begin, end);
			if (list == null) {
				return success("查询成功!");
			}
			JSONArray jsonArray = new JSONArray();
			for (DevicePatientHealthIndex model : list) {
				JSONObject modelJson = new JSONObject();
				modelJson.put("patient", model.getUser());
				modelJson.put("value1", model.getValue1());
				modelJson.put("value2", model.getValue2());
				modelJson.put("value3", model.getValue3());
				modelJson.put("value4", model.getValue4());
				modelJson.put("value5", model.getValue5());
				modelJson.put("value6", model.getValue6());
				modelJson.put("value7", model.getValue7());
				modelJson.put("type", model.getType());
				if (type == 2) {
					modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD_HH_MM_SS));
				} else {
					modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD));
				}
				modelJson.put("czrq", DateUtil.dateToStr(model.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
				jsonArray.put(modelJson);
			}
			return write(200, "查询成功", "list", jsonArray);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
            if (list == null) {
                return success("查询成功!");
            }
            JSONArray jsonArray = new JSONArray();
            for (DevicePatientHealthIndex model : list) {
                JSONObject modelJson = new JSONObject();
                modelJson.put("patient", model.getUser());
                modelJson.put("value1", model.getValue1());
                modelJson.put("value2", model.getValue2());
                modelJson.put("value3", model.getValue3());
                modelJson.put("value4", model.getValue4());
                modelJson.put("value5", model.getValue5());
                modelJson.put("value6", model.getValue6());
                modelJson.put("value7", model.getValue7());
                modelJson.put("type", model.getType());
                if (type == 2) {
                    modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD_HH_MM_SS));
                } else {
                    modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD));
                }
                modelJson.put("czrq", DateUtil.dateToStr(model.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
                jsonArray.put(modelJson);
            }
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
	/**
	 * 根据患者标志获取健康指标
	 *
	 * @param type     健康指标类型(1血糖,2血压,3体重,4腰围)
	 * @param pagesize 页数
	 * @return 操作结果
	 */
	@RequestMapping(value = "list", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("患者获取健康指标")
	public String getHealthIndexByPatient(@ApiParam(name = "type", value = "指标类型", defaultValue = "1")
										  @RequestParam(value = "type", required = true) int type,
										  @ApiParam(name = "start", value = "开始时间", defaultValue = "2016-07-23 00:00:00")
										  @RequestParam(value = "start", required = true) String start,
										  @ApiParam(name = "end", value = "结束时间", defaultValue = "2016-08-23 00:00:00")
										  @RequestParam(value = "end", required = true) String end,
										  @ApiParam(name = "page", value = "第几页", defaultValue = "1")
										  @RequestParam(value = "page", required = true) int page,
										  @ApiParam(name = "pagesize", value = "每页几行", defaultValue = "10")
										  @RequestParam(value = "pagesize", required = true) int pagesize) {
		try {
			JSONArray jsonArray = new JSONArray();
			if (type == 1) {
				List<Object> list = healthIndexService.findIndexByPatient2(getUID(), type, start, end, page, pagesize);
				jsonArray = new JSONArray(list);
			}else{
				List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient(getUID(), type, start, end, page, pagesize);
				if (list != null) {
					for (DevicePatientHealthIndex model : list) {
						JSONObject modelJson = new JSONObject();
						modelJson.put("id", model.getId());
						modelJson.put("patient", model.getUser());
						modelJson.put("value1", model.getValue1());
						modelJson.put("value2", model.getValue2());
						modelJson.put("value3", model.getValue3());
						modelJson.put("value4", model.getValue4());
						modelJson.put("value5", model.getValue5());
						modelJson.put("value6", model.getValue6());
						modelJson.put("value7", model.getValue7());
						modelJson.put("type", model.getType());
						if (type == 2) {
							modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD_HH_MM_SS));
						} else {
							modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD));
						}
						modelJson.put("sortDate", DateUtil.dateToStrLong(model.getSortDate()));
						modelJson.put("czrq", DateUtil.dateToStr(model.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
						jsonArray.put(modelJson);
					}
				}
			}
    /**
     * 根据患者标志获取健康指标
     *
     * @param type     健康指标类型(1血糖,2血压,3体重,4腰围)
     * @param pagesize 页数
     * @return 操作结果
     */
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("患者获取健康指标")
    public String getHealthIndexByPatient(@ApiParam(name = "type", value = "指标类型", defaultValue = "1")
                                          @RequestParam(value = "type", required = true) int type,
                                          @ApiParam(name = "start", value = "开始时间", defaultValue = "2016-07-23 00:00:00")
                                          @RequestParam(value = "start", required = true) String start,
                                          @ApiParam(name = "end", value = "结束时间", defaultValue = "2016-08-23 00:00:00")
                                          @RequestParam(value = "end", required = true) String end,
                                          @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                                          @RequestParam(value = "page", required = true) int page,
                                          @ApiParam(name = "pagesize", value = "每页几行", defaultValue = "10")
                                          @RequestParam(value = "pagesize", required = true) int pagesize) {
        try {
            JSONArray jsonArray = new JSONArray();
            if (type == 1) {
                List<Object> list = healthIndexService.findIndexByPatient2(getUID(), type, start, end, page, pagesize);
                jsonArray = new JSONArray(list);
            } else {
                List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient(getUID(), type, start, end, page, pagesize);
                if (list != null) {
                    for (DevicePatientHealthIndex model : list) {
                        JSONObject modelJson = new JSONObject();
                        modelJson.put("id", model.getId());
                        modelJson.put("patient", model.getUser());
                        modelJson.put("value1", model.getValue1());
                        modelJson.put("value2", model.getValue2());
                        modelJson.put("value3", model.getValue3());
                        modelJson.put("value4", model.getValue4());
                        modelJson.put("value5", model.getValue5());
                        modelJson.put("value6", model.getValue6());
                        modelJson.put("value7", model.getValue7());
                        modelJson.put("type", model.getType());
                        if (type == 2) {
                            modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD_HH_MM_SS));
                        } else {
                            modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD));
                        }
                        modelJson.put("sortDate", DateUtil.dateToStrLong(model.getSortDate()));
                        modelJson.put("czrq", DateUtil.dateToStr(model.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
                        jsonArray.put(modelJson);
                    }
                }
            }
			return write(200, "查询成功", "list", jsonArray);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
	/**
	 * 患者健康指标预警值查询
	 *
	 * @return
	 */
	@RequestMapping(value = "standard")
	@ResponseBody
	public String standard() {
		try {
			JSONArray standardArray = new JSONArray();
			JSONArray userArray = new JSONArray();
			Iterable<PatientHealthStandard> iterable = healthIndexService.findStandardByPatient(getUID());
			Iterator<PatientHealthStandard> iterator = null;
			if (iterable != null) {
				iterator = iterable.iterator();
			}
			// 预警值未设置,返回默认值
			StringBuffer sb = new StringBuffer();
			sb.append("[");
			// 默认血糖(餐前,餐后二小时)
			sb.append("{min_value_1:3.9, max_value_1:6.1, min_value_2:4.4, max_value_2:7.8, type:1},");
			// 默认血压(收缩压,舒张压)
			sb.append("{min_value_1:90, max_value_1:139, min_value_2:60, max_value_2:89, type:2}");
			sb.append("]");
			standardArray = new JSONArray(sb.toString());
			if (iterator != null) {
				while (iterator.hasNext()) {
					PatientHealthStandard phs = iterator.next();
					if (phs == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					// 最低安全值(血糖餐前\收缩压\体重\腰围)
					json.put("min_value_1", phs.getMinValue1());
					// 最高安全值(血糖餐前\收缩压\体重\腰围)
					json.put("max_value_1", phs.getMaxValue1());
					// 最低安全值(血糖餐后\舒张压)
					json.put("min_value_2", phs.getMinValue2());
					// 最高安全值(血糖餐后\舒张压)
					json.put("max_value_2", phs.getMaxValue2());
					// 健康指标类型:1血糖,2血压,3体重,4腰围
					json.put("type", phs.getType());
					userArray.put(json);
				}
			}
			JSONObject json = new JSONObject();
			json.put("standard", standardArray);
			json.put("custom", userArray);
			return write(200, "查询成功", "data", json);
		} catch (Exception e) {
			error(e);
			return invalidUserException(e, -1, "查询失败!");
		}
	}
    /**
     * 患者健康指标预警值查询
     *
     * @return
     */
    @RequestMapping(value = "standard")
    @ResponseBody
    public String standard() {
        try {
            JSONArray standardArray = new JSONArray();
            JSONArray userArray = new JSONArray();
            Iterable<PatientHealthStandard> iterable = healthIndexService.findStandardByPatient(getUID());
            Iterator<PatientHealthStandard> iterator = null;
            if (iterable != null) {
                iterator = iterable.iterator();
            }
            // 预警值未设置,返回默认值
            StringBuffer sb = new StringBuffer();
            sb.append("[");
            // 默认血糖(餐前,餐后二小时)
            sb.append("{min_value_1:3.9, max_value_1:6.1, min_value_2:4.4, max_value_2:7.8, type:1},");
            // 默认血压(收缩压,舒张压)
            sb.append("{min_value_1:90, max_value_1:139, min_value_2:60, max_value_2:89, type:2}");
            sb.append("]");
            standardArray = new JSONArray(sb.toString());
            if (iterator != null) {
                while (iterator.hasNext()) {
                    PatientHealthStandard phs = iterator.next();
                    if (phs == null) {
                        continue;
                    }
                    JSONObject json = new JSONObject();
                    // 最低安全值(血糖餐前\收缩压\体重\腰围)
                    json.put("min_value_1", phs.getMinValue1());
                    // 最高安全值(血糖餐前\收缩压\体重\腰围)
                    json.put("max_value_1", phs.getMaxValue1());
                    // 最低安全值(血糖餐后\舒张压)
                    json.put("min_value_2", phs.getMinValue2());
                    // 最高安全值(血糖餐后\舒张压)
                    json.put("max_value_2", phs.getMaxValue2());
                    // 健康指标类型:1血糖,2血压,3体重,4腰围
                    json.put("type", phs.getType());
                    userArray.put(json);
                }
            }
            JSONObject json = new JSONObject();
            json.put("standard", standardArray);
            json.put("custom", userArray);
            return write(200, "查询成功", "data", json);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "查询失败!");
        }
    }
}
}

+ 48 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.service.common.account.*;
import com.yihu.wlyy.service.common.account.*;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.DateUtil;
@ -17,11 +18,13 @@ import com.yihu.wlyy.util.RSAUtils;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.entity.patient.invitation.PatientInvitationLog;
import com.yihu.wlyy.entity.patient.invitation.PatientInvitationLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Page;
import org.springframework.http.CacheControl;
import org.springframework.http.MediaType;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -30,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseBody;
import java.net.URLDecoder;
import java.net.URLDecoder;
import java.util.Calendar;
import java.util.List;
import java.util.List;
/**
/**
@ -52,6 +56,8 @@ public class FamilyContractController extends BaseController {
    private FamilyService familyService;
    private FamilyService familyService;
    @Autowired
    @Autowired
    private DoctorPatientGroupInfoDao doctorPatientGroupInfoDao;
    private DoctorPatientGroupInfoDao doctorPatientGroupInfoDao;
    @Autowired
    private SignWebService signWebService;
    /**
    /**
     * 得到患者的签约的医生的信息
     * 得到患者的签约的医生的信息
@ -73,6 +79,20 @@ public class FamilyContractController extends BaseController {
        }
        }
    }
    }
    @RequestMapping(value = "getSignMessageOverdue")
    @ResponseBody
    public String getSignDoctorMessageOverDue(String patientCode) {
        try {
            JSONArray array = familyContractService.getSignDoctorMessageOverDue(patientCode);
            return write(200, "获取列表成功!", "list", array);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取列表失败!");
        }
    }
    /**
    /**
     * 社区医院列表查询接口
     * 社区医院列表查询接口
@ -479,8 +499,15 @@ public class FamilyContractController extends BaseController {
            if (StringUtils.isEmpty(doctor)) {
            if (StringUtils.isEmpty(doctor)) {
                return error(-1, "签约医生不能为空");
                return error(-1, "签约医生不能为空");
            }
            }
            Calendar cal = Calendar.getInstance();
            int month = cal.get(Calendar.MONTH)+1;
            int result = -1;
            if(month<7){
                result = familyContractService.signRenew(doctor,healthDoctor,patient);
            }else{
                result = familyContractService.signRenewOverdue(doctor,healthDoctor,patient);
            }
            int result = familyContractService.signRenew(doctor,healthDoctor,patient);
            if (result == -1) {
            if (result == -1) {
                return error(-1, "用户信息查询失败");
                return error(-1, "用户信息查询失败");
@ -668,4 +695,24 @@ public class FamilyContractController extends BaseController {
            return error(-1, "查询失败");
            return error(-1, "查询失败");
        }
        }
    }
    }
    /**
     *
     *统计
     * 咨询量、获取待预约、获取健康教育、获取健康指导
     * @return
     */
    @RequestMapping("/getSignCountInfoInYear")
    @ApiOperation(value = "统计咨询量、获取待预约、获取健康教育、获取健康指导")
    @ResponseBody
    public String getSignCountInfoInYear(@RequestParam(required = true)String patient){
        try{
            JSONObject rs =signWebService.getSignCountInfoInYear(patient);
            //JSONObject rs =signWebService.getRenewYearCount("64de930c-5b15-11e6-8344-fa163e8aee56");
            return write(200, "操作成功!", "data", rs);
        }catch (Exception e){
            error(e);
            return error(-1, "请求失败");
        }
    }
}
}

+ 0 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java

@ -523,12 +523,10 @@ public class WeiXinEventProcess {
        List<Map<String, String>> articles = new ArrayList<>();
        List<Map<String, String>> articles = new ArrayList<>();
        Map videoText = getNews("doctor_subscribe_url", "doctor_qrcode_pic_url", "欢迎关注厦门i健康,快来签约家庭医生吧~", null);
        Map videoText = getNews("doctor_subscribe_url", "doctor_qrcode_pic_url", "欢迎关注厦门i健康,快来签约家庭医生吧~", null);
        Map videoText1 = getNews("patient_sign_again_url", "patient_sign_again_pic_url", "家庭医生续签提醒", null);
        Map videoText1 = getNews("patient_sign_again_url", "patient_sign_again_pic_url", "家庭医生续签提醒", null);
        System.out.println("255");
        articles.add(videoText);
        articles.add(videoText);
        articles.add(videoText1);
        articles.add(videoText1);
        // 构建回复消息XML
        // 构建回复消息XML
        result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        System.out.println("256");
        return result;
        return result;
    }
    }

+ 0 - 16
patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/util/WeiXinMessageReplyUtils.java

@ -49,20 +49,4 @@ public class WeiXinMessageReplyUtils {
        return result.toString();
        return result.toString();
    }
    }
    /**
     * 公众号群发图文消息
     *
     * @param toUser
     * @param fromUser
     * @param articles
     * @return
     * @throws Exception
     */
    public static String mapNewsMessage(String toUser,String fromUser,List<Map<String,String>> articles) throws Exception {
//1.上传图片到微信服务器
//2.上传图文消息素材到微信服务器
// 3.根据openID列表群发
        return null;
    }
}
}

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

@ -36,11 +36,13 @@ patient_operatinginstrutions_pic_url={server}/images/operatinginstructions.png
patient_booking_pic_url={server}/images/booking.png
patient_booking_pic_url={server}/images/booking.png
patient_device_pic_url={server}/images/device.png
patient_device_pic_url={server}/images/device.png
patient_family_pic_url={server}/images/myfamily.png
patient_family_pic_url={server}/images/myfamily.png
patient_sign_again_pic_url={server}/images/renew.png
patient_consult_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2fyszx.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_consult_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2fyszx.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_booking_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2fyygh.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_booking_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2fyygh.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_device_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2ftzsb.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_device_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2ftzsb.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_family_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2ffamily.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_family_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2ffamily.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_sign_again_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fxuqian%2fhtml%2finformation.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
# SMS短信配置
# SMS短信配置
yihu_sms_url=https://smsapi.ums86.com:9600/sms/Api/Send.do
yihu_sms_url=https://smsapi.ums86.com:9600/sms/Api/Send.do
@ -64,6 +66,9 @@ admin_token=0a5c5258-8863-4b07-a3f9-88c768528ab4
# 签约到期JOB触发时间
# 签约到期JOB触发时间
sign_end_job_trigger=0 0 0 * * ?
sign_end_job_trigger=0 0 0 * * ?
# 续签提醒JOB触发时间 (每5分钟一次)
sign_again_job_trigger=0 0/1 * * * ?
evaluate_score_job = 59 59 23 * * ?
evaluate_score_job = 59 59 23 * * ?
#-------------------------开发环境配置-------------------------#
#-------------------------开发环境配置-------------------------#
@ -82,8 +87,7 @@ chat_server=http://weixin.xmtyw.cn/res/chat/
sign_check_upload=http://172.19.103.87:8011/wlyy_service
sign_check_upload=http://172.19.103.87:8011/wlyy_service
# IM配置
# IM配置
#im_list_get=http://172.19.103.88:3000/
im_list_get=http://192.168.131.107:3000/
im_list_get=http://172.19.103.88:3000/
im_group_server=http://172.19.103.29:3000/api/v1/chats/gm
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
msg_push_server=http://172.19.103.29:3000/api/v1/chats/sm
@ -185,10 +189,10 @@ fastdfs_file_url=http://172.19.103.54:80/
#template_doctor_change=V5h0F84t972kUzQvWy8qYrgdaYGJVj10pFeFVl19Nb8
#template_doctor_change=V5h0F84t972kUzQvWy8qYrgdaYGJVj10pFeFVl19Nb8
#问卷调查
#问卷调查
#template_doctor_survey=OqQXrb-e43_TJpq_70_K_y6vYJgY5mpjFYY4c5RWFP4
#template_doctor_survey=OqQXrb-e43_TJpq_70_K_y6vYJgY5mpjFYY4c5RWFP4
#
## FastDFS文件Http访问地址
## FastDFS文件Http访问地址
#fastdfs_file_url=http://172.19.103.54:80/
#fastdfs_file_url=http://172.19.103.54:80/
#
##健康之路开放平台
##健康之路开放平台
#yihu_OpenPlatform_url=http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/
#yihu_OpenPlatform_url=http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/
#yihu_OpenPlatform_appId=9000276
#yihu_OpenPlatform_appId=9000276