|  | @ -3,6 +3,7 @@ package com.yihu.jw.evaluate.score.service;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.score.BaseEvaluateScoreDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.evaluate.score.dao.BaseEvaluateScoreDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
	
	
		
			
				|  | @ -39,11 +40,23 @@ public class BaseEvaluateScoreService extends BaseJpaService<BaseEvaluateScoreDO
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String, Object> getScoreAndPercentage(String area, int level){
 | 
	
		
			
				|  |  |         HashMap<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |         //今日凌晨、当前时间
 | 
	
		
			
				|  |  |         String startTime = DateUtil.getStringDateShort()+" 00:00:00";
 | 
	
		
			
				|  |  |         String nowTime = DateUtil.getStringDate();
 | 
	
		
			
				|  |  |         //昨日时间
 | 
	
		
			
				|  |  |         String oneDayAgo = DateUtil.getNextDay(startTime, -1);
 | 
	
		
			
				|  |  |         String oneStrTime = oneDayAgo + " 00:00:00";
 | 
	
		
			
				|  |  |         String oneEndTime = oneDayAgo + " 23:59:59";
 | 
	
		
			
				|  |  |         //七天之前时间
 | 
	
		
			
				|  |  |         String sevenDayAgo = DateUtil.getNextDay(startTime, -7);
 | 
	
		
			
				|  |  |         String sevenStrTime = sevenDayAgo + " 00:00:00";
 | 
	
		
			
				|  |  |         String sevenEndTime = sevenDayAgo + " 23:59:59";
 | 
	
		
			
				|  |  |         //服务总评分
 | 
	
		
			
				|  |  |         Double avgScore = getAvgScore(null, null, area, level);
 | 
	
		
			
				|  |  |         map.put("totalAvgScore",avgScore);
 | 
	
		
			
				|  |  |         map.put("weekJudge",judgeScore(1.00,1.00));
 | 
	
		
			
				|  |  |         map.put("dayJudge",judgeScore(1.00,1.00));
 | 
	
		
			
				|  |  |         map.put("totalAvgScore",getAvgScore(null, null, area, level));
 | 
	
		
			
				|  |  |         //周同比
 | 
	
		
			
				|  |  |         map.put("weekJudge",judgeScore(getAvgScore(startTime, nowTime, area, level),getAvgScore(sevenStrTime, sevenEndTime, area, level)));
 | 
	
		
			
				|  |  |         //日环比
 | 
	
		
			
				|  |  |         map.put("dayJudge",judgeScore(getAvgScore(startTime, nowTime, area, level),getAvgScore(oneStrTime, oneEndTime, area, level)));
 | 
	
		
			
				|  |  |         return map;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -77,8 +90,14 @@ public class BaseEvaluateScoreService extends BaseJpaService<BaseEvaluateScoreDO
 | 
	
		
			
				|  |  |         double total = 0d;
 | 
	
		
			
				|  |  |         double score = 0d;
 | 
	
		
			
				|  |  |         if(rstotal != null && rstotal.size()>0){
 | 
	
		
			
				|  |  |             if (null == rstotal.get(0).get("score")){
 | 
	
		
			
				|  |  |                 return 0.0;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             total = Double.valueOf((rstotal.get(0).get("total")).toString());
 | 
	
		
			
				|  |  |             score = Double.valueOf((rstotal.get(0).get("score")).toString());
 | 
	
		
			
				|  |  |             if (0 == total || 0 == score){
 | 
	
		
			
				|  |  |                 return 0.0;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         double avgScore = score / total;
 | 
	
		
			
				|  |  |         DecimalFormat df = new DecimalFormat("0.0");//格式化小数,不足的补0
 | 
	
	
		
			
				|  | @ -95,10 +114,15 @@ public class BaseEvaluateScoreService extends BaseJpaService<BaseEvaluateScoreDO
 | 
	
		
			
				|  |  |     private Object judgeScore(Double nowScore, Double oldScore){
 | 
	
		
			
				|  |  |         JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |         if (nowScore > oldScore){
 | 
	
		
			
				|  |  |             Double difScore = nowScore - oldScore;
 | 
	
		
			
				|  |  |             String percentage = getPercentage((float) (difScore.intValue()), (float) oldScore.intValue());
 | 
	
		
			
				|  |  |             object.put("trend",1);
 | 
	
		
			
				|  |  |             object.put("percentage",percentage);
 | 
	
		
			
				|  |  |             if (oldScore == 0){
 | 
	
		
			
				|  |  |                 object.put("trend",1);
 | 
	
		
			
				|  |  |                 object.put("percentage","100%");
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 Double difScore = nowScore - oldScore;
 | 
	
		
			
				|  |  |                 String percentage = getPercentage((float) (difScore.intValue()), (float) oldScore.intValue());
 | 
	
		
			
				|  |  |                 object.put("trend",1);
 | 
	
		
			
				|  |  |                 object.put("percentage",percentage);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }else if (nowScore < oldScore){
 | 
	
		
			
				|  |  |             Double difScore = oldScore - nowScore;
 | 
	
		
			
				|  |  |             String percentage = getPercentage((float) (difScore.intValue()), (float) oldScore.intValue());
 |