Sfoglia il codice sorgente

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

lyr 8 anni fa
parent
commit
b6b9398129

+ 35 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/controller/DataProcessController.java

@ -1,6 +1,8 @@
package com.yihu.wlyy.statistics.controller;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.yihu.wlyy.statistics.task.PatientDiseaseToLabel;
import com.yihu.wlyy.statistics.task.PatientGroupToLabelRunnable;
import com.yihu.wlyy.statistics.task.SignTeamAndGroupRunnable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -18,7 +20,7 @@ public class DataProcessController extends BaseController {
     * @return
     */
    @RequestMapping(value = "/sign_team_group_thread")
    public String getErrorPage(long start,long end){
    public String setTeamGroupPage(long start,long end){
        try {
            new Thread(new SignTeamAndGroupRunnable(start,end)).start();
            return write(200,"启动成功");
@ -27,4 +29,36 @@ public class DataProcessController extends BaseController {
            return error(-1, "启动失败");
        }
    }
    /**
     * 签约同步数据设置团队和分组
     *
     * @return
     */
    @RequestMapping(value = "/disease_to_label_thread")
    public String diseaseToLabel(long start){
        try {
            new Thread(new PatientDiseaseToLabel(start)).start();
            return write(200,"启动成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "启动失败");
        }
    }
    /**
     * 签约同步数据设置团队和分组
     *
     * @return
     */
    @RequestMapping(value = "/group_to_label_thread")
    public String diseaseToLabel(long start,long end){
        try {
            new Thread(new PatientGroupToLabelRunnable(start,end)).start();
            return write(200,"启动成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "启动失败");
        }
    }
}

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

@ -106,6 +106,6 @@ public interface DoctorPatientGroupInfoDao extends PagingAndSortingRepository<Do
	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 ")
	@Query("select a from DoctorPatientGroupInfo a where a.status = 1 and a.id >= ?1 and a.id < ?2 ")
	Page<DoctorPatientGroupInfo> findByIdRange(Long start, Long end, Pageable pageRequest);
}

+ 12 - 5
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/task/PatientDiseaseToLabel.java

@ -41,12 +41,14 @@ public class PatientDiseaseToLabel implements Runnable {
        while (flag) {
            PageRequest pageRequest = new PageRequest(0, 500);
            Page<PatientDisease> diseases = diseaseDao.findByIdRange(start,pageRequest);
            Page<PatientDisease> diseases = diseaseDao.findByIdRange(start, pageRequest);
            if (diseases != null && diseases.getContent().size() < 500) {
                flag = false;
            }
            start = diseases.getContent().get(diseases.getContent().size() - 1).getId() + 1;
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
@ -57,17 +59,22 @@ public class PatientDiseaseToLabel implements Runnable {
            } catch (Exception e) {
                transactionManager.rollback(status);
            }
            start = start + 500;
        }
    }
    void diseasesToLabel(Page<PatientDisease> diseases) {
        Map<String,SignPatientLabelInfo> labelInfos = new HashMap<>();
        Map<String, SignPatientLabelInfo> labelInfos = new HashMap<>();
        for (PatientDisease disease : diseases.getContent()) {
            SignPatientLabelInfo labelInfo = new SignPatientLabelInfo();
            SignPatientLabelInfo exLabelInfo = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(
                    disease.getPatient(), disease.getDisease(), "3", 1);
            if (exLabelInfo != null) {
                continue;
            }
            labelInfo.setPatient(disease.getPatient());
            labelInfo.setLabel(disease.getDisease());
            labelInfo.setLabelName(disease.getDiseaseName());
@ -75,7 +82,7 @@ public class PatientDiseaseToLabel implements Runnable {
            labelInfo.setStatus(1);
            labelInfo.setCzrq(new Date());
            labelInfos.put(disease.getPatient() + disease.getDisease(),labelInfo);
            labelInfos.put(disease.getPatient() + disease.getDisease(), labelInfo);
        }
        labelInfoDao.save(labelInfos.values());

+ 9 - 2
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/task/PatientGroupToLabelRunnable.java

@ -47,6 +47,8 @@ public class PatientGroupToLabelRunnable implements Runnable {
                flag = false;
            }
            start = groups.getContent().get(groups.getContent().size() - 1).getId() + 1;
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
@ -57,8 +59,6 @@ public class PatientGroupToLabelRunnable implements Runnable {
            } catch (Exception e) {
                transactionManager.rollback(status);
            }
            start = start + 100;
        }
    }
@ -92,6 +92,13 @@ public class PatientGroupToLabelRunnable implements Runnable {
            groupInfo.setStatus(2);
            SignPatientLabelInfo exLabelInfo = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(
                    groupInfo.getPatient(),labelInfo.getLabel(),"1",1);
            if(exLabelInfo != null){
                continue;
            }
            normalLabel.put(groupInfo.getPatient(), labelInfo);
        }

+ 19 - 15
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/task/SignTeamAndGroupRunnable.java

@ -23,9 +23,7 @@ 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;
import java.util.*;
/**
 * Created by lyr-pc on 2016/10/11.
@ -67,7 +65,7 @@ public class SignTeamAndGroupRunnable implements Runnable {
            if (signs != null && signs.getContent().size() < 100) {
                flag = false;
            }
            start = signs.getContent().get(signs.getContent().size() - 1).getId() + 1;
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
@ -78,15 +76,18 @@ public class SignTeamAndGroupRunnable implements Runnable {
            } 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()) {
        List<DoctorTeam> teams = new ArrayList<>();
        List<DoctorTeamMember> teamMembers = new ArrayList<>();
        List<DoctorPatientGroupInfo> groupList = new ArrayList<>();
        List<SignFamily> signList = signs.getContent();
        for (SignFamily sign : signList) {
            try {
                if (StringUtils.isNotEmpty(sign.getTeamCode())) {
                    continue;
@ -102,7 +103,7 @@ public class SignTeamAndGroupRunnable implements Runnable {
                doctorTeam.setSignType("2");//家庭签约
                doctorTeam.setDel("1");
                teamDao.save(doctorTeam);
                teams.add(doctorTeam);
                //添加团队成员
                if (StringUtils.isNotEmpty(sign.getDoctor())) {
@ -118,7 +119,7 @@ public class SignTeamAndGroupRunnable implements Runnable {
                    wlyyDoctorTeamDoctor.setCode(getCode());
                    wlyyDoctorTeamDoctor.setCzrq(new Date());
                    teamMemberDao.save(wlyyDoctorTeamDoctor);
                    teamMembers.add(wlyyDoctorTeamDoctor);
                }
                if (StringUtils.isNotEmpty(sign.getDoctorHealth())) {
                    //添加健康管理师
@ -133,7 +134,7 @@ public class SignTeamAndGroupRunnable implements Runnable {
                    wlyyDoctorTeamDoctor.setCode(getCode());
                    wlyyDoctorTeamDoctor.setCzrq(new Date());
                    teamMemberDao.save(wlyyDoctorTeamDoctor);
                    teamMembers.add(wlyyDoctorTeamDoctor);
                }
                //添加患者和团队的关系
@ -148,7 +149,7 @@ public class SignTeamAndGroupRunnable implements Runnable {
                wlyyDoctorTeamPatient.setCode(getCode());
                wlyyDoctorTeamPatient.setCzrq(new Date());
                teamMemberDao.save(wlyyDoctorTeamPatient);
                teamMembers.add(wlyyDoctorTeamPatient);
                if (StringUtils.isEmpty(sign.getIdcard())) {
                    System.out.println("error:sign-family-set-group:no-idcard:" + sign.getId());
@ -176,7 +177,7 @@ public class SignTeamAndGroupRunnable implements Runnable {
                    doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
                    doctorPatientGroupInfo.setSignType("2");//家庭签约
                    groupInfoDao.save(doctorPatientGroupInfo);
                    groupList.add(doctorPatientGroupInfo);
                }
                if (StringUtils.isNotEmpty(sign.getDoctor())) {
@ -193,7 +194,7 @@ public class SignTeamAndGroupRunnable implements Runnable {
                    doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
                    doctorPatientGroupInfo.setSignType("2");//家庭签约
                    groupInfoDao.save(doctorPatientGroupInfo);
                    groupList.add(doctorPatientGroupInfo);
                }
                List<DoctorPatientGroupInfo> groups = groupInfoDao.findPatientGroups(sign.getPatient());
@ -216,15 +217,18 @@ public class SignTeamAndGroupRunnable implements Runnable {
                        patientGroup.setQyrq(sign.getApplyDate());
                        patientGroup.setSignType("2");//家庭签约
                        groupInfoDao.save(patientGroup);
                        groupList.add(patientGroup);
                    }
                }
                sign.setTeamCode(doctorTeamCode);
                signFamilyDao.save(sign);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        teamDao.save(teams);
        teamMemberDao.save(teamMembers);
        groupInfoDao.save(groupList);
        signFamilyDao.save(signList);
        System.out.println("sign-patient-group-team:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    }
}