| 
					
				 | 
			
			
				@ -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())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |