| 
					
				 | 
			
			
				@ -591,7 +591,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop<JSONObject,JSONObject> selectActivityRanking(String activityId,String patient,Integer page,Integer size,String street,String town){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop<JSONObject,JSONObject> selectActivityRanking(String activityId,String patient,Integer page,Integer size,String street,String town,String hospital){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        MixEnvelop<JSONObject,JSONObject> envelop = new MixEnvelop<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        ActivityDO activityDO = activityDao.selectById(activityId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -605,7 +605,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "ORDER BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " btpd.total DESC,btpd.create_time ASC LIMIT " + (page-1)*size+","+size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<TaskPatientDetailDO> patientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count=0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count=1L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int j =0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -632,7 +632,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "ORDER BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " btpd.couponTotal DESC,btpd.create_time ASC LIMIT " + (page-1)*size+","+size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<TaskPatientDetailDO> patientDetailDOS1 = jdbcTemplate.query(sqlCoupon,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count2 = 0l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count2 = 1l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int i=0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -685,6 +685,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " btpd1.activity_id = '"+activityDO.getId()+"' AND btpd1.sum >= (SELECT SUM(s.total) as total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM  wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND  s.activity_id='"+activityId+"')" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ORDER BY btpd1.sum desc "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " limit "+countTotal+",1" ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> rstotal9 = jdbcTemplate.queryForList(rankingSql9); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer total = 0; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -736,6 +737,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 " btpd1.sum >= (SELECT SUM(s.total) as total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM  wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND  s.activity_id='"+activityId+"')" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ORDER BY btpd1.sum desc "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " limit "+countTotal1+",1" ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> totalSql10 = jdbcTemplate.queryForList(rankingSql10); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer total2 = 0; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -759,7 +761,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "ORDER BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " btpd.total DESC)btpd1 WHERE  btpd1.patientId IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.street = '"+street+"')"+" ORDER BY btpd1.create_time "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<TaskPatientDetailDO> patientDetailDOS2 = jdbcTemplate.query(rankingSql3,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count3=0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count3=1L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String goodsSql = "select * from wlyy_health_bank_exchange_goods where patient_id ='"+taskPatientDetailDO.getPatientId()+"' " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -775,6 +777,20 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                count3+=1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //积分社区排行 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql1= "select s.rank,IFNULL(s.sum,0) as sum,s.patient_id from (SELECT @rownum :=@rownum + 1 AS rank, r.sum, r.patient_id FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "(SELECT@rowNum := 0) b," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (SELECT sum(bcd.integrate) AS sum, hbtd.patient_id, hbtd.create_time FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_health_bank_task_patient_detail hbtd " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  LEFT  JOIN wlyy_health_bank_credits_detail bcd ON hbtd.patient_id=bcd.patient_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND bcd.transaction_id='"+taskPatientDetailDO1.getTaskId()+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE hbtd.task_id = '"+taskPatientDetailDO1.getTaskId()+"' " +"and hbtd.hospital = '"+hospital+"'"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "GROUP BY hbtd.patient_id) r ORDER BY r.sum DESC,r.create_time DESC)s where s.patient_id ='"+patient+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> maps = jdbcTemplate.queryForList(sql1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count10=0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (maps!= null && maps.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            count10 =new Double((Double) maps.get(0).get("rank")).longValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //区排名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String rankingSql4  ="SELECT btpd1.patientId, btpd1.total, btpd1.create_time AS updateTime FROM (SELECT btpd.patient_id AS patientId,btpd.total,btpd.create_time AS create_time FROM ( SELECT sum(btpd.total) AS total, btpd.patient_id,btpd.create_time " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM wlyy_health_bank_task_patient_detail btpd " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -784,7 +800,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "ORDER BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " btpd.total DESC)btpd1 WHERE  btpd1.patientId IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.town = '"+town+"')"+" ORDER BY btpd1.create_time "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<TaskPatientDetailDO> patientDetailDOS3 = jdbcTemplate.query(rankingSql4,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count4=0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count4=1L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS3){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String goodsSql = "select * from wlyy_health_bank_exchange_goods where patient_id ='"+taskPatientDetailDO.getPatientId()+"' " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -811,7 +827,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "ORDER BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " btpd.couponTotal DESC )btpd1 WHERE  btpd1.patientId IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.street = '"+street+"') ORDER BY btpd1.create_time "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<TaskPatientDetailDO> patientDetailDOS4 = jdbcTemplate.query(rankingSql5,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count5 = 0l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count5 = 1l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS4){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String goodsSql = "select * from wlyy_health_bank_exchange_goods where patient_id ='"+taskPatientDetailDO.getPatientId()+"' " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -836,7 +852,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "ORDER BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " btpd.couponTotal DESC )btpd1 WHERE  btpd1.patientId IN(SELECT p.code FROM wlyy.wlyy_patient p WHERE p.town = '"+town+"') ORDER BY btpd1.create_time "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<TaskPatientDetailDO> patientDetailDOS5 = jdbcTemplate.query(rankingSql6,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count6 = 0l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count6 = 1l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (TaskPatientDetailDO taskPatientDetailDO:patientDetailDOS5){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String timeSeparated = DateUtils.getDatePoor(new Date(),taskPatientDetailDO.getUpdateTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String goodsSql = "select * from wlyy_health_bank_exchange_goods where patient_id ='"+taskPatientDetailDO.getPatientId()+"' " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -854,7 +870,20 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //社区排行 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql8= "select s.rank,IFNULL(s.sum,0) as sum,s.patient_id from (SELECT @rownum :=@rownum + 1 AS rank, r.sum, r.patient_id FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "(SELECT@rowNum := 0) b," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (SELECT sum(bcd.coupon) AS sum, hbtd.patient_id, hbtd.create_time FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_health_bank_task_patient_detail hbtd " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  LEFT  JOIN wlyy_health_bank_credits_detail bcd ON hbtd.patient_id=bcd.patient_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND bcd.transaction_id='"+taskPatientDetailDO1.getTaskId()+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE hbtd.task_id = '"+taskPatientDetailDO1.getTaskId()+"' " +"and hbtd.hospital = '"+hospital+"'"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "GROUP BY hbtd.patient_id) r ORDER BY r.sum DESC,r.create_time DESC)s where s.patient_id ='"+patient+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> maps1 = jdbcTemplate.queryForList(sql8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count11=0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (maps1!= null && maps1.size()!=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            count11 =  new Double((Double) maps1.get(0).get("rank")).longValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //街道排名 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1035,6 +1064,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("couponTotal",taskPatientDetailDO1.getCouponTotal());//本人活动劵总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("couponRanking",patientDetailDOS1);//活动劵人数排名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("signCouponRanking",count7);//活动劵团队排名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("activityHospitalCouponRanking",count11);//社区排名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (count2 ==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                jsonObject.put("differTotal",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1047,6 +1077,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("activityTownIntegrateRanking",count4);//积分全区排名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("activityRanking",count);//积分排名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("signRanking",count8);//积分团队排名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonObject.put("activityHospitalIntegrateRanking",count10);//社区排名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (count==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                jsonObject.put("differTotal",0);//相距前一个差多少积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 |