浏览代码

Merge branch 'dev' of lyr/patient-co-management into dev

lyr 8 年之前
父节点
当前提交
eb692c99ec
共有 18 个文件被更改,包括 1177 次插入1 次删除
  1. 4 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/Application.java
  2. 30 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/controller/DataProcessController.java
  3. 6 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/DoctorPatientGroupInfoDao.java
  4. 29 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/DoctorTeamDao.java
  5. 60 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/DoctorTeamMemberDao.java
  6. 59 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/PatientDiseaseDao.java
  7. 3 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/SignFamilyDao.java
  8. 55 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/SignPatientLabelDao.java
  9. 66 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/SignPatientLabelInfoDao.java
  10. 96 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/label/SignPatientLabel.java
  11. 79 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/label/SignPatientLabelInfo.java
  12. 67 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/patient/PatientDisease.java
  13. 68 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/team/DoctorTeam.java
  14. 130 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/team/DoctorTeamMember.java
  15. 85 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/task/PatientDiseaseToLabel.java
  16. 109 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/task/PatientGroupToLabelRunnable.java
  17. 230 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/task/SignTeamAndGroupRunnable.java
  18. 1 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

+ 4 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/Application.java

@ -2,13 +2,16 @@ package com.yihu.wlyy.statistics;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
/**
 * Created by Administrator on 2016.10.12.
 */
@SpringBootApplication
public class Application {
    public static ApplicationContext ctx = null;
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
        ctx = SpringApplication.run(Application.class, args);
    }
}

+ 30 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/controller/DataProcessController.java

@ -0,0 +1,30 @@
package com.yihu.wlyy.statistics.controller;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.yihu.wlyy.statistics.task.SignTeamAndGroupRunnable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by lyr-pc on 2016/10/12.
 */
@RestController
@RequestMapping(value = "/data_process")
public class DataProcessController extends BaseController {
    /**
     * 签约同步数据设置团队和分组
     *
     * @return
     */
    @RequestMapping(value = "/sign_team_group_thread")
    public String getErrorPage(long start,long end){
        try {
            new Thread(new SignTeamAndGroupRunnable(start,end)).start();
            return write(200,"启动成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "启动失败");
        }
    }
}

+ 6 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/DoctorPatientGroupInfoDao.java

@ -5,8 +5,11 @@
 *******************************************************************************/
package com.yihu.wlyy.statistics.dao;
import com.yihu.wlyy.statistics.model.doctor.DoctorPatientGroup;
import com.yihu.wlyy.statistics.model.doctor.DoctorPatientGroupInfo;
import com.yihu.wlyy.statistics.model.patient.Patient;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
@ -102,4 +105,7 @@ public interface DoctorPatientGroupInfoDao extends PagingAndSortingRepository<Do
	List<DoctorPatientGroupInfo> findByPatientAndDoctor(String patient, String oldDoctorCode);
	List<DoctorPatientGroupInfo> findByGroupAndStatus(String group, Integer status);
	@Query("select a from DoctorPatientGroupInfo a where a.status = 1 and a.id >= ?2 and a.id < ?3 ")
	Page<DoctorPatientGroupInfo> findByIdRange(Long start, Long end, Pageable pageRequest);
}

+ 29 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/DoctorTeamDao.java

@ -0,0 +1,29 @@
package com.yihu.wlyy.statistics.dao;
import com.yihu.wlyy.statistics.model.team.DoctorTeam;
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.repository.PagingAndSortingRepository;
public interface DoctorTeamDao extends
PagingAndSortingRepository<DoctorTeam, Long>,
JpaSpecificationExecutor<DoctorTeam> {
	DoctorTeam findByCode(String code);
	//@Query("select dt from DoctorTeam dt,DoctorTeamMember dtm  where dt.code=dtm.team and dt.del=1 and dtm.del=1 and dtm.memberCode= ?1 and dtm.type= 5 and dtm.signType='2'")
	@Query("select dtt from DoctorTeam dtt where dtt.id = (select max(dt.id) from DoctorTeam dt,DoctorTeamMember dtm  where dt.code=dtm.team and dt.del=1 and dtm.del=1 and dtm.memberCode= ?1 and dtm.type= 5 and dtm.signType='2')")
	DoctorTeam findByParientCode(String parientCode);
	@Query("select dt from DoctorTeam dt,DoctorTeamMember dtm  where dt.code=dtm.team and dt.del=1 and dtm.del=1 and dtm.memberCode= ?1 and dtm.type= 5 and dtm.signType='1'")
	DoctorTeam findBySanshiParientCode(String parientCode);
	//@Query("select dt from DoctorTeam dt,DoctorTeamMember dtm  where dt.code=dtm.team and dt.del=1 and dtm.del=1 and dtm.memberCode= ?1 and dtm.type= 5 and dtm.signType=?2 order by dtm.id limit 1")
	@Query("select dtt from DoctorTeam dtt where dtt.id = (select max(dt.id) from DoctorTeam dt,DoctorTeamMember dtm  where dt.code=dtm.team and dt.del=1 and dtm.del=1 and dtm.memberCode= ?1 and dtm.type= 5 and dtm.signType=?2)")
	DoctorTeam findByParientCodeAndSignType(String parientCode, String type);
	@Modifying
	@Query("update DoctorTeam a set a.del =0  where a.code = ?1 and signType='2'")
	void deleteTeam(String teamCode);
}

+ 60 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/DoctorTeamMemberDao.java

@ -0,0 +1,60 @@
package com.yihu.wlyy.statistics.dao;
import com.yihu.wlyy.statistics.model.team.DoctorTeamMember;
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.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * Created by Administrator on 2016/7/30.
 */
public interface DoctorTeamMemberDao extends PagingAndSortingRepository<DoctorTeamMember, Long>, JpaSpecificationExecutor<DoctorTeamMember> {
    @Query(" FROM DoctorTeamMember a WHERE a.team=?1 and a.type=?2 and a.del='1'")
    DoctorTeamMember findDoctor2ByTeam(String code, int type);
    @Query(" FROM DoctorTeamMember a WHERE a.team=?1 and a.type=?2 and a.del='1'and signType='1'")
    DoctorTeamMember findDoctorSanshi2ByTeam(String code, int type);
    @Query(" FROM DoctorTeamMember a WHERE a.team=?1 and a.type=?2 and a.del='1'and signType='2'")
    DoctorTeamMember findDoctorJiating2ByTeam(String code, int type);
    @Query(" FROM DoctorTeamMember a WHERE a.team=?1 and a.memberCode=?2 and a.del='1'")
    DoctorTeamMember findMemberCodeAndTeam(String code, String doctor);
    @Modifying
    @Query("update DoctorTeamMember a set a.del = '0' where a.team = ?1 and a.type=1 ")
    void updateType1Del(String code);
    @Modifying
    @Query("update DoctorTeamMember a set a.del = '0' where a.team = ?1 and signType='2' ")
    void deleteMember(String code);
    @Query("select count(a) FROM DoctorTeamMember a WHERE a.memberCode =?1 and  a.del='1'")
    Integer teamListByDoctorCode(String doctorCode);
    @Query(" FROM DoctorTeamMember a WHERE a.team =?1 and  a.del='1' and  a.signType='1'")
    List<DoctorTeamMember> findBySanshiTeam(String teamCode);
    @Query(" FROM DoctorTeamMember a WHERE a.team =?1 and  a.del='1' and  a.signType='1' and  a.type=?2 ")
    DoctorTeamMember findSanshiByTeamAndType(String teamCode, int i);
    List<DoctorTeamMember> findByTeamAndDel(String team, String del);
    @Query(" FROM DoctorTeamMember a WHERE a.team =?1 and  a.del='1' and  a.signType='2' and  a.memberCode=?2 ")
    DoctorTeamMember findMemberByTeamAndCode(String teamCode, String oldDoctorCode);
    /**
     * 判断医生是否为三师签团队的成员。
     *
     * @param doctorCode
     * @return
     */
    @Query("SELECT case when count(a) > 0 THEN true else false END FROM DoctorTeamMember a WHERE a.signType = 1 AND a" +
            ".memberCode = :memberCode")
    Boolean isSanShiSigning(@Param("memberCode") String doctorCode);
}

+ 59 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/PatientDiseaseDao.java

@ -0,0 +1,59 @@
package com.yihu.wlyy.statistics.dao;
import com.yihu.wlyy.statistics.model.patient.PatientDisease;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * 患者疾病Dao
 *
 * Created by lyr on 2016/09/09.
 */
public interface PatientDiseaseDao extends PagingAndSortingRepository<PatientDisease, Long>, JpaSpecificationExecutor<PatientDisease> {
    /**
     * 根据居民code获取居民疾病
     *
     * @param patient
     * @return
     */
    List<PatientDisease> findByPatient(String patient);
    /**
     * 根据居民code获取居民疾病
     *
     * @param patient
     * @return
     */
    List<PatientDisease> findByPatientAndSignType(String patient, String signType);
    /**
     * 根据居民code获取居民疾病
     *
     * @param patient
     * @return
     */
    @Query("select a from PatientDisease a where a.patient = ?1 and a.signType = '1' and a.del ='1' ")
    List<PatientDisease> findByPatientSsDisease(String patient);
    /**
     * 删除患者疾病
     *
     * @param patient
     * @return
     */
    int deleteByPatient(String patient);
    @Modifying
    @Query("update PatientDisease set del = '0' where patient = ?1 and del = '1' and signType = '2' ")
    int updateDiseaseDel(String patient);
    @Query("select a from PatientDisease a where a.del = '1' and a.id > ?1 and a.id > ?2")
    Page<PatientDisease> findByIdRange(Long start, Long end, Pageable pageRequest);
}

+ 3 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/SignFamilyDao.java

@ -41,4 +41,7 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
	@Query(" from SignFamily a where  a.type =2 and a.status =100  and unix_timestamp(a.patientApplyDate)>=unix_timestamp(?1) and unix_timestamp(a.patientApplyDate)<unix_timestamp(?2) and a.expensesStatus=1 ")
	List<SignFamily> findByJiatingChaangeSignYesterdayExpensesStatus(String yesterday, String now);
	// 查询同步数据
	@Query("select a from SignFamily a where a.type = ?1 and a.signSource = ?2 and a.status > 0 and a.id >= ?3 and a.id <= ?4 order by a.id")
	Page<SignFamily> findByTypeAndSignSourceAndId(Integer type,String signSource,Long start,Long end,Pageable pageable);
}

+ 55 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/SignPatientLabelDao.java

@ -0,0 +1,55 @@
package com.yihu.wlyy.statistics.dao;
import com.yihu.wlyy.statistics.model.label.SignPatientLabel;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by lyr on 2016/10/9.
 */
public interface SignPatientLabelDao extends
        PagingAndSortingRepository<SignPatientLabel, Long>,
        JpaSpecificationExecutor<SignPatientLabel> {
    /**
     * 根据标签code、标签类型、状态查询标签
     *
     * @param labelCode 标签code
     * @param labelType 标签类型
     * @param status 状态
     * @return
     */
    SignPatientLabel findByLabelCodeAndLabelTypeAndStatus(String labelCode, String labelType, Integer status);
    /**
     * 查询某个类型系统标签
     *
     * @param labelType
     * @param status
     * @return
     */
    List<SignPatientLabel> findByLabelTypeAndStatus(String labelType, Integer status);
    /**
     * 查询非自定义系统标签
     *
     * @return
     */
    @Query("select a from SignPatientLabel a where a.status = 1 and a.isSystem = 1 and a.labelType < 4")
    List<SignPatientLabel> findSystemLabels();
    /**
     * 查询某个团队自定义标签
     *
     * @param teamCode
     * @return
     */
    @Query("select a from SignPatientLabel a where a.status = 1 and (a.isSystem = 1  or a.teamCode = ?1) and a.labelType = 4")
    List<SignPatientLabel> findCustomLabels(long teamCode);
    @Query("select a from SignPatientLabel a where a.status = 1 and a.labelName = ?1 and a.labelType = ?2 and a.teamCode = ?3")
    SignPatientLabel findByLabelNameAndLabelTypeAndTeamCode(String labelName, String labelType, Long teamCode);
}

+ 66 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/SignPatientLabelInfoDao.java

@ -0,0 +1,66 @@
package com.yihu.wlyy.statistics.dao;
import com.yihu.wlyy.statistics.model.label.SignPatientLabelInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by lyr on 2016/10/9.
 */
public interface SignPatientLabelInfoDao extends
        PagingAndSortingRepository<SignPatientLabelInfo, Long>,
        JpaSpecificationExecutor<SignPatientLabelInfo> {
    /**
     * 查询某个患者的标签
     *
     * @param patient 患者
     * @param status  状态
     * @return
     */
    List<SignPatientLabelInfo> findByPatientAndStatus(String patient, Integer status);
    /**
     * 查询某个患者的某个类型标签
     *
     * @param patient   患者
     * @param labelType 标签类型
     * @param status    状态
     * @return
     */
    List<SignPatientLabelInfo> findByPatientAndLabelTypeAndStatus(String patient, String labelType, Integer status);
    /**
     * 查询某个患者的某个类型的某个标签
     *
     * @param patient   患者
     * @param labelCode  标签代码
     * @param labelType 标签类型
     * @param status    状态
     * @return
     */
    SignPatientLabelInfo findByPatientAndLabelAndLabelTypeAndStatus(String patient, String labelCode, String labelType, Integer status);
    /**
     * 删除患者的某个标签类型的所有指定状态标签
     *
     * @param patient
     * @param labelType
     * @param status
     * @return
     */
    int deleteByPatientAndLabelTypeAndStatus(String patient, String labelType, Integer status);
    /**
     * 更新某个标签名称
     *
     * @param labelName
     * @param labelCode
     * @return
     */
    @Query("update SignPatientLabelInfo a set a.labelName = ?1 where a.label= ?2 and a.labelType = '4' ")
    int updateLabelName(String labelName, String labelCode);
}

+ 96 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/label/SignPatientLabel.java

@ -0,0 +1,96 @@
package com.yihu.wlyy.statistics.model.label;
import com.yihu.wlyy.statistics.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by lyr on 2016/10/9.
 */
@Entity
@Table(name = "wlyy_sign_patient_label")
public class SignPatientLabel extends IdEntity {
    // 标签code
    private String labelCode;
    // 标签名称
    private String labelName;
    // 标签类型 1:卫计委三大分组 2:健康情况 3:疾病类型 4:自定义
    private String labelType;
    // 是否系统标签
    private Integer isSystem;
    // 创建者
    private String creator;
    // 所属团队code
    private Long teamCode;
    // 排序
    private Integer sort;
    // 状态 0:无效 1:有效
    private Integer status;
    // 操作日期
    private Date czrq;
    public String getLabelCode() {
        return labelCode;
    }
    public void setLabelCode(String labelCode) {
        this.labelCode = labelCode;
    }
    public String getLabelName() {
        return labelName;
    }
    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }
    public String getLabelType() {
        return labelType;
    }
    public void setLabelType(String labelType) {
        this.labelType = labelType;
    }
    public Integer getIsSystem() {
        return isSystem;
    }
    public void setIsSystem(Integer isSystem) {
        this.isSystem = isSystem;
    }
    public String getCreator() {
        return creator;
    }
    public void setCreator(String creator) {
        this.creator = creator;
    }
    public Long getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(Long teamCode) {
        this.teamCode = teamCode;
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 79 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/label/SignPatientLabelInfo.java

@ -0,0 +1,79 @@
package com.yihu.wlyy.statistics.model.label;
import com.yihu.wlyy.statistics.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by lyr on 2016/10/9.
 */
@Entity
@Table(name = "wlyy_sign_patient_label_info")
public class SignPatientLabelInfo extends IdEntity {
    // 患者code
    private String patient;
    // 患者姓名
    private String pname;
    // 标签code
    private String label;
    // 标签名称
    private String labelName;
    // 标签类型
    private String labelType;
    // 状态 0:无效 1:有效
    private Integer status;
    // 操作日期
    private Date czrq;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPname() {
        return pname;
    }
    public void setPname(String pname) {
        this.pname = pname;
    }
    public String getLabel() {
        return label;
    }
    public void setLabel(String label) {
        this.label = label;
    }
    public String getLabelName() {
        return labelName;
    }
    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }
    public String getLabelType() {
        return labelType;
    }
    public void setLabelType(String labelType) {
        this.labelType = labelType;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 67 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/patient/PatientDisease.java

@ -0,0 +1,67 @@
package com.yihu.wlyy.statistics.model.patient;
import com.yihu.wlyy.statistics.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 患者疾病。
 *
 * @author lyr
 */
@Entity
@Table(name = "wlyy_patient_disease")
public class PatientDisease extends IdEntity implements Serializable {
    private String patient;         // 患者
    private String disease;         // 疾病代码
    private String diseaseName;     // 疾病名称
    private String del;              // 是否有效 1有效 0无效
    private String signType;        // 签约类型 1:三师 2:家庭
    private Date czrq;              // 操作日期
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getDisease() {
        return disease;
    }
    public void setDisease(String disease) {
        this.disease = disease;
    }
    public String getDiseaseName() {
        return diseaseName;
    }
    public void setDiseaseName(String diseaseName) {
        this.diseaseName = diseaseName;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
    public String getSignType() {
        return signType;
    }
    public void setSignType(String signType) {
        this.signType = signType;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 68 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/team/DoctorTeam.java

@ -0,0 +1,68 @@
package com.yihu.wlyy.statistics.model.team;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.statistics.model.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 三师团队/医生签约团队
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_doctor_team")
public class DoctorTeam extends IdEntity {
	private static final long serialVersionUID = 715817516721723210L;
	private String code;    // 组标识
	private String name;    // 组名
	private Date czrq;      // 更新时间
	private String del;     // 是否作废,1正常,0作废
	private String signType;//签约类型(1表示三师签约,2表示家庭签约)
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
	@Column(name = "sign_type")
	public String getSignType() {
		return signType;
	}
	public void setSignType(String signType) {
		this.signType = signType;
	}
}

+ 130 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/team/DoctorTeamMember.java

@ -0,0 +1,130 @@
package com.yihu.wlyy.statistics.model.team;
import com.yihu.wlyy.statistics.model.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.sql.Timestamp;
import java.util.Date;
/**
 * 医生签约团队成员。
 *
 * @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "wlyy_doctor_team_member")
public class DoctorTeamMember extends IdEntity {
    // Fields
    private String team;
    private String memberCode;
    private String code;
    private String name;
    private Integer type;//医生类型:1专科医生,2全科医生,3健康管理师,4临时专科 5.患者
    private Date czrq;
    private String del;//是否作废,1正常,0作废
    private String signType;//签约类型(1表示三师签约,2表示家庭签约)
    /**
     * default constructor
     */
    public DoctorTeamMember() {
    }
    /**
     * minimal constructor
     */
    public DoctorTeamMember(String team, String doctor, Integer type,
                            Timestamp czrq) {
        this.team = team;
        this.type = type;
        this.czrq = czrq;
    }
    /**
     * full constructor
     */
    public DoctorTeamMember(String team, String doctor, String name,
                            Integer type, Timestamp czrq, String del) {
        this.team = team;
        this.name = name;
        this.type = type;
        this.czrq = czrq;
        this.del = del;
    }
    @Column(name = "team", nullable = false, length = 50)
    public String getTeam() {
        return this.team;
    }
    public void setTeam(String team) {
        this.team = team;
    }
    @Column(name = "member_code", nullable = false, length = 50)
    public String getMemberCode() {
        return memberCode;
    }
    public void setMemberCode(String memberCode) {
        this.memberCode = memberCode;
    }
    @Column(name = "name", length = 50)
    public String getName() {
        return this.name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "type", nullable = false)
    public Integer getType() {
        return this.type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "czrq", nullable = false, length = 0)
    public Date getCzrq() {
        return this.czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
    @Column(name = "del", length = 1)
    public String getDel() {
        return this.del;
    }
    public void setDel(String del) {
        this.del = del;
    }
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "sign_type")
    public String getSignType() {
        return signType;
    }
    public void setSignType(String signType) {
        this.signType = signType;
    }
}

+ 85 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/task/PatientDiseaseToLabel.java

@ -0,0 +1,85 @@
package com.yihu.wlyy.statistics.task;
import com.yihu.wlyy.statistics.Application;
import com.yihu.wlyy.statistics.dao.PatientDiseaseDao;
import com.yihu.wlyy.statistics.dao.SignPatientLabelInfoDao;
import com.yihu.wlyy.statistics.model.doctor.DoctorPatientGroupInfo;
import com.yihu.wlyy.statistics.model.label.SignPatientLabelInfo;
import com.yihu.wlyy.statistics.model.patient.Patient;
import com.yihu.wlyy.statistics.model.patient.PatientDisease;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.util.*;
/**
 * Created by lyr-pc on 2016/10/13.
 */
public class PatientDiseaseToLabel implements Runnable {
    long start = 0;
    long end = 0;
    PatientDiseaseDao diseaseDao;
    SignPatientLabelInfoDao labelInfoDao;
    JpaTransactionManager transactionManager;
    public PatientDiseaseToLabel(Long start, Long end) {
        this.start = start;
        this.end = end;
        this.diseaseDao = Application.ctx.getBean(PatientDiseaseDao.class);
        this.labelInfoDao = Application.ctx.getBean(SignPatientLabelInfoDao.class);
        this.transactionManager = Application.ctx.getBean(JpaTransactionManager.class);
    }
    @Override
    public void run() {
        boolean flag = true;
        while (flag) {
            PageRequest pageRequest = new PageRequest(0, 500);
            Page<PatientDisease> diseases = diseaseDao.findByIdRange(start,end,pageRequest);
            if (diseases != null && diseases.getContent().size() < 500) {
                flag = false;
            }
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
            try {
                diseasesToLabel(diseases);
                //事物提交
                transactionManager.commit(status);
            } catch (Exception e) {
                transactionManager.rollback(status);
            }
            start = start + 500;
        }
    }
    void diseasesToLabel(Page<PatientDisease> diseases) {
        Map<String,SignPatientLabelInfo> labelInfos = new HashMap<>();
        for (PatientDisease disease : diseases.getContent()) {
            SignPatientLabelInfo labelInfo = new SignPatientLabelInfo();
            labelInfo.setPatient(disease.getPatient());
            labelInfo.setLabel(disease.getDisease());
            labelInfo.setLabelName(disease.getDiseaseName());
            labelInfo.setLabelType("3");
            labelInfo.setStatus(1);
            labelInfo.setCzrq(new Date());
            labelInfos.put(disease.getPatient() + disease.getDisease(),labelInfo);
        }
        labelInfoDao.save(labelInfos.values());
    }
}

+ 109 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/task/PatientGroupToLabelRunnable.java

@ -0,0 +1,109 @@
package com.yihu.wlyy.statistics.task;
import com.yihu.wlyy.statistics.Application;
import com.yihu.wlyy.statistics.dao.*;
import com.yihu.wlyy.statistics.model.doctor.DoctorPatientGroupInfo;
import com.yihu.wlyy.statistics.model.label.SignPatientLabelInfo;
import com.yihu.wlyy.statistics.model.patient.Patient;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.util.*;
/**
 * Created by lyr-pc on 2016/10/12.
 */
public class PatientGroupToLabelRunnable implements Runnable {
    long start = 0;
    long end = 0;
    DoctorPatientGroupInfoDao groupInfoDao;
    SignPatientLabelInfoDao labelInfoDao;
    JpaTransactionManager transactionManager;
    public PatientGroupToLabelRunnable(Long start, Long end) {
        this.start = start;
        this.end = end;
        this.groupInfoDao = Application.ctx.getBean(DoctorPatientGroupInfoDao.class);
        this.labelInfoDao = Application.ctx.getBean(SignPatientLabelInfoDao.class);
        this.transactionManager = Application.ctx.getBean(JpaTransactionManager.class);
    }
    @Override
    public void run() {
        boolean flag = true;
        while (flag) {
            PageRequest pageRequest = new PageRequest(0, 100);
            Page<DoctorPatientGroupInfo> groups = groupInfoDao.findByIdRange(start, end, pageRequest);
            if (groups != null && groups.getContent().size() < 100) {
                flag = false;
            }
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
            try {
                groupToLabel(groups);
                //事物提交
                transactionManager.commit(status);
            } catch (Exception e) {
                transactionManager.rollback(status);
            }
            start = start + 100;
        }
    }
    void groupToLabel(Page<DoctorPatientGroupInfo> groups) {
        Map<String, SignPatientLabelInfo> normalLabel = new HashMap<>();
        Map<String, SignPatientLabelInfo> manbingLabel = new HashMap<>();
        Map<String, SignPatientLabelInfo> sixFiveLabel = new HashMap<>();
        List<DoctorPatientGroupInfo> groupInfos = groups.getContent();
        for (DoctorPatientGroupInfo groupInfo : groupInfos) {
            SignPatientLabelInfo labelInfo = new SignPatientLabelInfo();
            labelInfo.setPatient(groupInfo.getPatient());
            labelInfo.setPname(groupInfo.getPname());
            if (groupInfo.getGroup().equals("1")) {
                labelInfo.setLabel("1");
                labelInfo.setLabelName("普通人群");
            } else if (groupInfo.getGroup().equals("2")) {
                labelInfo.setLabel("2");
                labelInfo.setLabelName("慢病人群");
            } else if (groupInfo.equals(3)) {
                labelInfo.setLabel("3");
                labelInfo.setLabelName("65岁以上人群");
            } else {
                continue;
            }
            labelInfo.setLabelType("1");
            labelInfo.setStatus(1);
            labelInfo.setCzrq(new Date());
            groupInfo.setStatus(2);
            normalLabel.put(groupInfo.getPatient(), labelInfo);
        }
        if (normalLabel.size() > 0) {
            labelInfoDao.save(normalLabel.values());
        }
        if (manbingLabel.size() > 0) {
            labelInfoDao.save(manbingLabel.values());
        }
        if (sixFiveLabel.size() > 0) {
            labelInfoDao.save(sixFiveLabel.values());
        }
        groupInfoDao.save(groups);
    }
}

+ 230 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/task/SignTeamAndGroupRunnable.java

@ -0,0 +1,230 @@
package com.yihu.wlyy.statistics.task;
import com.yihu.wlyy.statistics.Application;
import com.yihu.wlyy.statistics.dao.DoctorPatientGroupInfoDao;
import com.yihu.wlyy.statistics.dao.DoctorTeamDao;
import com.yihu.wlyy.statistics.dao.DoctorTeamMemberDao;
import com.yihu.wlyy.statistics.dao.SignFamilyDao;
import com.yihu.wlyy.statistics.model.doctor.DoctorPatientGroupInfo;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.team.DoctorTeam;
import com.yihu.wlyy.statistics.model.team.DoctorTeamMember;
import com.yihu.wlyy.statistics.util.IdCardUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
 * Created by lyr-pc on 2016/10/11.
 */
public class SignTeamAndGroupRunnable implements Runnable {
    long start = 0;
    long end = 0;
    SignFamilyDao signFamilyDao;
    DoctorPatientGroupInfoDao groupInfoDao;
    DoctorTeamDao teamDao;
    DoctorTeamMemberDao teamMemberDao;
    JpaTransactionManager transactionManager;
    public SignTeamAndGroupRunnable(Long start, Long end){
        this.start = start;
        this.end = end;
        this.signFamilyDao = Application.ctx.getBean(SignFamilyDao.class);
        this.groupInfoDao = Application.ctx.getBean(DoctorPatientGroupInfoDao.class);
        this.teamDao = Application.ctx.getBean(DoctorTeamDao.class);
        this.teamMemberDao = Application.ctx.getBean(DoctorTeamMemberDao.class);
        this.transactionManager = Application.ctx.getBean(JpaTransactionManager.class);
    }
    public String getCode() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
    @Override
    public void run() {
        boolean flag = true;
        while (flag) {
            PageRequest pageRequest = new PageRequest(0, 100);
            Page<SignFamily> signs = signFamilyDao.findByTypeAndSignSourceAndId(2, "1",start, end,pageRequest);
            if (signs != null && signs.getContent().size() < 100) {
                flag = false;
            }
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
            try {
                transform(signs);
                //事物提交
                transactionManager.commit(status);
            } catch (Exception e) {
                transactionManager.rollback(status);
            }
            start = start + 100;
        }
    }
    public void transform(Page<SignFamily> signs){
        System.out.println("sign-patient-group-team:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        for (SignFamily sign : signs.getContent()) {
            try {
                if (StringUtils.isNotEmpty(sign.getTeamCode())) {
                    continue;
                }
                //建立团队
                DoctorTeam doctorTeam = new DoctorTeam();
                String doctorTeamCode = getCode();
                doctorTeam.setCode(doctorTeamCode);
                doctorTeam.setCzrq(new Date());
                doctorTeam.setName("团队名称:" + sign.getName());
                doctorTeam.setSignType("2");//家庭签约
                doctorTeam.setDel("1");
                teamDao.save(doctorTeam);
                //添加团队成员
                if (StringUtils.isNotEmpty(sign.getDoctor())) {
                    //添加全科
                    DoctorTeamMember wlyyDoctorTeamDoctor = new DoctorTeamMember();
                    wlyyDoctorTeamDoctor.setTeam(doctorTeamCode);
                    wlyyDoctorTeamDoctor.setMemberCode(sign.getDoctor());
                    wlyyDoctorTeamDoctor.setName(sign.getDoctorName());
                    wlyyDoctorTeamDoctor.setDel("1");
                    wlyyDoctorTeamDoctor.setType(2);
                    wlyyDoctorTeamDoctor.setSignType("2");//家庭签约
                    wlyyDoctorTeamDoctor.setCode(getCode());
                    wlyyDoctorTeamDoctor.setCzrq(new Date());
                    teamMemberDao.save(wlyyDoctorTeamDoctor);
                }
                if (StringUtils.isNotEmpty(sign.getDoctorHealth())) {
                    //添加健康管理师
                    DoctorTeamMember wlyyDoctorTeamDoctor = new DoctorTeamMember();
                    wlyyDoctorTeamDoctor.setTeam(doctorTeamCode);
                    wlyyDoctorTeamDoctor.setMemberCode(sign.getDoctorHealth());
                    wlyyDoctorTeamDoctor.setName(sign.getDoctorHealthName());
                    wlyyDoctorTeamDoctor.setDel("1");
                    wlyyDoctorTeamDoctor.setType(3);
                    wlyyDoctorTeamDoctor.setSignType("2");//家庭签约
                    wlyyDoctorTeamDoctor.setCode(getCode());
                    wlyyDoctorTeamDoctor.setCzrq(new Date());
                    teamMemberDao.save(wlyyDoctorTeamDoctor);
                }
                //添加患者和团队的关系
                DoctorTeamMember wlyyDoctorTeamPatient = new DoctorTeamMember();
                wlyyDoctorTeamPatient.setTeam(doctorTeamCode);
                wlyyDoctorTeamPatient.setMemberCode(sign.getPatient());
                wlyyDoctorTeamPatient.setName(sign.getName());
                wlyyDoctorTeamPatient.setDel("1");
                wlyyDoctorTeamPatient.setSignType("2");//家庭签约
                wlyyDoctorTeamPatient.setType(5);
                wlyyDoctorTeamPatient.setCode(getCode());
                wlyyDoctorTeamPatient.setCzrq(new Date());
                teamMemberDao.save(wlyyDoctorTeamPatient);
                if (StringUtils.isEmpty(sign.getIdcard())) {
                    System.out.println("error:sign-family-set-group:no-idcard:" + sign.getId());
                    continue;
                }
                int age = IdCardUtil.getAgeForIdcard(sign.getIdcard());
                String groupCode = "1";
                if (age >= 65) {
                    groupCode = "3";
                }
                if (StringUtils.isNotEmpty(sign.getDoctorHealth())) {
                    //把病人添加到健康管理师的健康分组里
                    DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
                    doctorPatientGroupInfo.setCzrq(new Date());
                    doctorPatientGroupInfo.setDoctor(sign.getDoctorHealth());
                    doctorPatientGroupInfo.setStatus(1);
                    doctorPatientGroupInfo.setPatient(sign.getPatient());
                    doctorPatientGroupInfo.setPname(sign.getName());
                    doctorPatientGroupInfo.setPartAmount(0);
                    doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
                    doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
                    doctorPatientGroupInfo.setSignType("2");//家庭签约
                    groupInfoDao.save(doctorPatientGroupInfo);
                }
                if (StringUtils.isNotEmpty(sign.getDoctor())) {
                    //把病人添加到全科医生的健康分组里
                    DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
                    doctorPatientGroupInfo.setCzrq(new Date());
                    doctorPatientGroupInfo.setDoctor(sign.getDoctor());
                    doctorPatientGroupInfo.setStatus(1);
                    doctorPatientGroupInfo.setPatient(sign.getPatient());
                    doctorPatientGroupInfo.setPname(sign.getName());
                    doctorPatientGroupInfo.setPartAmount(0);
                    doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
                    doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
                    doctorPatientGroupInfo.setSignType("2");//家庭签约
                    groupInfoDao.save(doctorPatientGroupInfo);
                }
                List<DoctorPatientGroupInfo> groups = groupInfoDao.findPatientGroups(sign.getPatient());
                if (groups != null && groups.size() > 0) {
                    for (DoctorPatientGroupInfo group : groups) {
                        if (StringUtils.isNotEmpty(group.getSignType()) && group.getSignType().equals("2")) {
                            continue;
                        }
                        DoctorPatientGroupInfo patientGroup = new DoctorPatientGroupInfo();
                        patientGroup.setCzrq(new Date());
                        patientGroup.setDoctor(group.getDoctor());
                        patientGroup.setStatus(1);
                        patientGroup.setPatient(sign.getPatient());
                        patientGroup.setPname(sign.getName());
                        patientGroup.setPartAmount(0);
                        patientGroup.setGroup(group.getGroup());
                        patientGroup.setQyrq(sign.getApplyDate());
                        patientGroup.setSignType("2");//家庭签约
                        groupInfoDao.save(patientGroup);
                    }
                }
                sign.setTeamCode(doctorTeamCode);
                signFamilyDao.save(sign);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.out.println("sign-patient-group-team:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    }
}

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

@ -587,6 +587,7 @@ public class SignPatientLabelInfoService extends BaseService {
        Map<String, JSONObject> result = new HashMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        page = page*pagesize;
        Object[] args = null;
        String sql = "select a.*" +
                " from" +