@ -1,8 +1,11 @@
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					package  com.mh.user.device ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import  com.mh.common.utils.StringUtils ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import  com.mh.user.utils.ExchangeStringUtil ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import  java.io.IOException ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import  java.time.LocalDateTime ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					import  java.time.format.DateTimeFormatter ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					/ * *  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					 *  @Classname  CRC16Test   
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -66,12 +69,21 @@ public class CRC16Test {
					 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    //测试
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    public  static  void  main ( String [ ]  args )  throws  IOException  {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					//        c0a8020a1f90ff04fb0000000100010200000300000400000500000600000700140800000901cb0a00000b00000c00000d00000e00000f0000100000110025120000130910
  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        byte [ ]  buffer ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        String  string  =  "c0a8020a1f90ff02fd0000000100000200000300000400000500000600000700000800010900000a00780b00010c8c310d00000e00000f0000100000110022120000132d1e140000150000160000170001182c381900001a01a61b00001c00001d00011e00011f25cd20000121b1332200002300002400002500002600712700002834202900002a00002b00002c00002d00402e00002f0363a6ff" ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        buffer  =  ExchangeStringUtil . HexString2Bytes ( string ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        int  crc16  =  CRC16Test . calcCrc16 ( buffer , buffer . length ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        System . out . println ( String . format ( "0x%04x" ,  crc16 ) ) ; //0x7c09
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        String  lastHourTime  =  "2020-06-03 01:00:00" ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        // lastHourTime转换成LocalDateTime
   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        LocalDateTime  lastHour1  =  null ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if ( lastHourTime  ! =  null  & &  ! "" . equals ( lastHourTime ) ) {   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            DateTimeFormatter  formatter  =  DateTimeFormatter . ofPattern ( "yyyy-MM-dd HH:mm:ss" ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            lastHour1  =  LocalDateTime . parse ( lastHourTime ,  formatter ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            System . out . println ( lastHour1 ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        LocalDateTime  now  =  lastHour1 ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            LocalDateTime  lastHour  =  now . minusHours ( 1 ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            DateTimeFormatter  formatter  =  DateTimeFormatter . ofPattern ( "yyyy-MM-dd HH:00:00" ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            lastHourTime  =  lastHour . format ( formatter ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        System . out . println ( lastHourTime ) ;   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    }   
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					}