| 
					
				 | 
			
			
				@@ -15,6 +15,7 @@ import com.zcxk.water.core.entity.MonitorDataEntity; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zcxk.water.core.entity.MonitorDataValueEntity; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zcxk.water.core.entity.mongo.DispatchPlanDataEntity; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zcxk.water.core.entity.mongo.DispatchPlanReportEntity; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.zcxk.water.xxl.common.Constants; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zcxk.water.xxl.common.RedisConstants; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang.StringUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -54,7 +55,15 @@ public class DispatchReportHandler { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private DispatchPlanClient dispatchPlanClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private static String HOUR = "%s:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 2小时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static int HOURS_2 = 60 * 60 * 2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 2天 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static int DAYS_2  = 60 * 60 * 24 * 2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Async 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void handler(MonitorDataEntity monitorDataEntity, JSONObject receiveData, Date receiveDateTime) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -88,26 +97,26 @@ public class DispatchReportHandler { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 dispatchPlanDataEntity.setReportTime(receiveDateTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 dispatchPlanDataEntity.setValueType(deviceParmEntity.getParmType() == 2 ? ValueTypeEnum.BOOLEAN.getCode() : ValueTypeEnum.NUMBER.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 dispatchPlanDataDao.saveDispatchPlan(dispatchPlanDataEntity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                saveReport(dispatchPlanDataEntity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this.saveReport(dispatchPlanDataEntity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private void saveReport(DispatchPlanDataEntity dispatchPlanDataEntity){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String md5Key       = String.format(RedisConstants.DISPATCH_PLAN_DATA, getMd5ByCurrentTime(dispatchPlanDataEntity)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String md5Key       = String.format(RedisConstants.DISPATCH_PLAN_DATA, getMd5ByCurrentHour(dispatchPlanDataEntity)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String md5LastKey   = String.format(RedisConstants.DISPATCH_PLAN_LAST_DATA, getMd5(dispatchPlanDataEntity)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String value = redisUtil.get(md5Key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         redisUtil.set(md5LastKey, dispatchPlanDataEntity.getDataValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        redisUtil.setExpire(md5LastKey, 10 * 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        redisUtil.setExpire(md5LastKey, DAYS_2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (StringUtils.isNotEmpty(value)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         redisUtil.set(md5Key, dispatchPlanDataEntity.getDataValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        redisUtil.setExpire(md5Key, 1000 * 10 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        redisUtil.setExpire(md5Key, HOURS_2 ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         DispatchPlanReportEntity dispatchPlanReportEntity = new DispatchPlanReportEntity(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         BeanCopyUtils.copyProperties(dispatchPlanDataEntity, dispatchPlanReportEntity, DispatchPlanReportEntity.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         dispatchPlanReportEntity.setStatDay(DateUtil.getDate(new Date())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        dispatchPlanReportEntity.setStatHour(String.format(HOUR, DateUtil.getHour())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        dispatchPlanReportEntity.setStatHour(String.format(Constants.HOUR, DateUtil.getHour())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         dispatchPlanReportDao.saveReportEntity(dispatchPlanReportEntity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -118,7 +127,7 @@ public class DispatchReportHandler { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return Md5.hash(builder.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    protected String getMd5ByCurrentTime(DispatchPlanDataEntity entity){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected String getMd5ByCurrentHour(DispatchPlanDataEntity entity){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         StringBuilder builder = new StringBuilder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         builder.append(entity.getTenantId()).append(entity.getDeviceId()).append(entity.getDeviceCode()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 .append(entity.getAttributeId()).append(entity.getParamType()).append(DateUtil.getHour()); 
			 |