| 
					
				 | 
			
			
				@ -12,9 +12,11 @@ import com.yihu.jw.org.dao.BaseOrgDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.servicepackage.ServicePackageDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.servicepackage.ServicePackageItemDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.servicepackage.ServicePackageSignRecordDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.service.myFamily.MyFamilyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.useragent.UserAgent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.base.doctor.BaseDoctorOrgVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.base.org.OrgDistanceVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.patient.signPackage.ServicePackageRecordVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.patient.signPackage.ServicePackageVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.Envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.MixEnvelop; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -25,6 +27,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.servlet.http.HttpServletRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -58,6 +61,9 @@ public class PackageService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DictHospitalDeptDao dictHospitalDeptDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private MyFamilyService myFamilyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop findPackageService(String city,String labelCode,String labelType,Integer page,Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String totalSql ="SELECT " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -218,8 +224,10 @@ public class PackageService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return MixEnvelop.getSuccessListWithPage(PatientRequestMapping.SignPackage.api_success, list, page, size, count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop signPackage(ServicePackageSignRecordDO recordDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop signPackage(ServicePackageSignRecordDO recordDO) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        servicePackageSignRecordDao.save(recordDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return Envelop.getSuccess(PatientRequestMapping.SignPackage.api_success); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -244,7 +252,126 @@ public class PackageService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    public MixEnvelop findSignPackage(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop findPatientSignPackage(String label,String labelType,String patient,String operator,String familyModel,Integer status,String isHos, Integer page,Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String totalSql="SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_service_package_sign_record r  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " JOIN base_service_package p ON r.service_package_id = p.id "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(label)&&StringUtils.isNotBlank(labelType)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql += " JOIN base_package_label_info l ON r.service_package_id = l.service_package_id "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        totalSql +=" WHERE 1=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("1".equals(familyModel)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //自己 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(StringUtils.isNotBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                totalSql +=" AND r.patient = '"+patient+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if("2".equals(familyModel)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //未经授权查询家人,只查自己创建的 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(StringUtils.isNotBlank(patient)&&StringUtils.isNotBlank(operator)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                totalSql +=" AND r.operator = '"+operator+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " AND r.patient = '"+patient+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if("3".equals(familyModel)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //查询已经授权,自己创建和家人相关记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(StringUtils.isNotBlank(patient)&&StringUtils.isNotBlank(operator)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                totalSql +=" AND (r.operator = '"+operator+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " OR r.patient = '"+patient+"' )"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(status != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql +=" AND r.`status` ="+status; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(isHos)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql +=" AND r.`status` < 0 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql +=" AND r.`status` >= 0 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(label)&&StringUtils.isNotBlank(labelType)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql +=" AND l.label ='"+label+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND l.label_type ='"+labelType+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long count = 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (rstotal != null && rstotal.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            count =(long)rstotal.size(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql="SELECT DISTINCT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.id, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.saas_id AS saasId," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.id AS servicePackageId, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.name AS servicePackageName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.patient," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.name," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.idcard," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.sign_doctor AS signDoctor, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.sign_doctor_name AS signDoctorName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.ssc," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.hospital," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.hospital_name AS hospitalName," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.admin_team_code AS adminTeamCode," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.price," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.start_time AS startTime," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.end_time AS endTime," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.status," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.doctor_team_code AS doctorTeamCode," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.operator," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.create_time AS createTime," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.sort," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.introduce, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.end_introduce AS endIntroduce " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " base_service_package_sign_record r  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " JOIN base_service_package p ON r.service_package_id = p.id "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(StringUtils.isNotBlank(label)&&StringUtils.isNotBlank(labelType)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql += " JOIN base_package_label_info l ON r.service_package_id = l.service_package_id "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql +=" WHERE 1=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if("1".equals(familyModel)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //自己 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(StringUtils.isNotBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sql +=" AND r.patient = '"+patient+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if("2".equals(familyModel)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //未经授权查询家人,只查自己创建的 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(StringUtils.isNotBlank(patient)&&StringUtils.isNotBlank(operator)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sql +=" AND r.operator = '"+operator+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                              " AND r.patient = '"+patient+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if("3".equals(familyModel)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //查询已经授权,自己创建和家人相关记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(StringUtils.isNotBlank(patient)&&StringUtils.isNotBlank(operator)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sql +=" AND (r.operator = '"+operator+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                " OR r.patient = '"+patient+"' )"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(status != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql +=" AND r.`status` ="+status; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(StringUtils.isNotBlank(isHos)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql +=" AND r.`status` < 0 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql +=" AND r.`status` >= 0 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(StringUtils.isNotBlank(label)&&StringUtils.isNotBlank(labelType)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql +=" AND l.label ='"+label+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                          " AND l.label_type ='"+labelType+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql +=" ORDER BY r.sort ASC  "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                      " LIMIT " + (page - 1) * size + "," + size + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<ServicePackageRecordVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(ServicePackageRecordVO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return MixEnvelop.getSuccessListWithPage(PatientRequestMapping.SignPackage.api_success, list, page, size, count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |