| 
						
						
						
					 | 
				
				 | 
				
					@ -1,175 +1,175 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					package com.ping.chuan.ahpmsdp.xxljobexecutor.model.domain; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.io.BufferedInputStream; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.io.FileInputStream; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.io.IOException; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.io.InputStream; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.nio.ByteBuffer; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.nio.CharBuffer; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.nio.charset.Charset; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.time.LocalDateTime; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.time.ZoneOffset; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.time.format.DateTimeFormatter; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.ArrayList; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.Arrays; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.Date; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.List; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.stream.Collectors; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.stream.IntStream; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.xxl.job.core.util.DateUtil; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.ping.chuan.ahpmsdp.xxljobexecutor.util.ByteUtil; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 * @describe: 雷达读取类 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 * @author: xiaowuler | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 * @createTime: 2022-02-28 09:18 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					public class RadarReader { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public RadarRead readBinaryFile(String filePath, String time) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        RadarRead radar = new RadarRead(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        try{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            InputStream inputStream = new FileInputStream(filePath); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            BufferedInputStream bi = new BufferedInputStream(inputStream); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setZoneName(readToString(bi, 12)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setDataName(readToString(bi, 38)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setFlag(readToString(bi, 8)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setVersion(readToString(bi, 8)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setYear(readToShort(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setMonth(readToShort(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setDay(readToShort(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setHour(readToShort(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setMinute(readToShort(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setInterval(readToShort(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setXNumGrids(readToShort(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setYNumGrids(readToShort(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setZNumGrids(readToShort(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            LocalDateTime initialTime = LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Date date = Date.from(initialTime.atZone(ZoneOffset.systemDefault()).toInstant()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setTime(DateUtil.addHours(date, 8)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setRadarCount(readToInt(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setStartLon(readToFloat(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setStartLat(readToFloat(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setCenterLon(readToFloat(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setCenterLat(readToFloat(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setXReso(readToFloat(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setYReso(readToFloat(bi)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setZHighGrids(setMultipleValue(bi, new float[40])); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setRadarStationName(setMultipleValue(bi, new String[20], 16)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setRadarLongitude(setMultipleValue(bi, new float[20])); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setRadarLatitude(setMultipleValue(bi, new float[20])); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setRadarAltitude(setMultipleValue(bi, new float[20])); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            byte[] bytes = new byte[20]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            bi.read(bytes); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setMosaicFlag(bytes); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setReserved(setMultipleValue(bi, 172)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setObserverValue(new float[radar.getZNumGrids() * radar.getYNumGrids() * radar.getXNumGrids()]); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            readValue(bi, radar, true); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<Float> targetValues = new ArrayList<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            List<Float> values =  IntStream.range(0, radar.getObserverValue().length) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    .mapToDouble(i -> radar.getObserverValue()[i]).boxed().map(i -> i.floatValue()).collect(Collectors.toList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            values = values.subList(305 * radar.getXNumGrids(), 700 * radar.getYNumGrids()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            for(int index = 0; index < 395; index++){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                int tempIndex = index * radar.getXNumGrids(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                targetValues.addAll(values.subList(tempIndex + 365, tempIndex + 700)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            float[] result = new float[132325]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            for(int index = 0, len = targetValues.size(); index < len; index++){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                result[index] = targetValues.get(index); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            radar.setObserverValue(result); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }catch (Exception e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            throw new RuntimeException(e); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return radar; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private void readValue(BufferedInputStream bis, RadarRead radar, boolean flag) throws IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (flag){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            for(int i = 0, len = radar.getXNumGrids() * radar.getYNumGrids() * radar.getZNumGrids(); i < len; i++) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                float value = bis.read(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (value != 0){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    radar.getObserverValue()[i] = (value - 66) / 2; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    continue; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                radar.getObserverValue()[i] = value; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            for(int i = 0; i < radar.getXNumGrids() * radar.getYNumGrids() * radar.getZNumGrids(); i++) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                int value = readToInt(bis); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                radar.getObserverValue()[i] = value / 1; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private String readToString(BufferedInputStream bi, Integer... infos) throws IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return convert(bi, (result, info) -> new String(result, info[1], info[2]), infos); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private short readToShort(BufferedInputStream bi) throws IOException{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return convert(bi, (result, infos) -> ByteUtil.toShort(result), 2); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private int readToInt(BufferedInputStream bi) throws IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return convert(bi, (result, infos) -> ByteUtil.toInt(result), 4); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private float readToFloat(BufferedInputStream bi) throws IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return convert(bi, (result, infos) -> ByteUtil.toFloat(result), 4); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private static <T> T convert(BufferedInputStream bi, Template<T> template, Integer... infos) throws IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (infos.length == 1){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            infos = Arrays.copyOf(infos,3); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            infos[1] = 0; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            infos[2] = infos[0]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        byte[] result = new byte[infos[0]]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        bi.read(result); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return template.readBytes(result, infos); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    interface Template<T>{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        T readBytes(byte[] result, Integer... infos) throws IOException; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private String[] setMultipleValue(BufferedInputStream bi, String[] result, Integer... infos) throws IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        for (int index = 0, len = result.length; index < len; index++){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            result[index] = readToString(bi, infos); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return result; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private float[] setMultipleValue(BufferedInputStream bi, float[] result) throws IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        for (int index = 0, len = result.length; index < len; index++){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            result[index] = readToFloat(bi); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return result; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private char[] setMultipleValue(BufferedInputStream bis, int length) throws IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        byte[] bytes = new byte[length]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        bis.read(bytes); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Charset cs = Charset.forName ("UTF-8"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ByteBuffer bb = ByteBuffer.allocate (bytes.length); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        bb.put (bytes); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        bb.flip (); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        CharBuffer cb = cs.decode (bb); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return cb.array(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//package com.ping.chuan.ahpmsdp.xxljobexecutor.model.domain;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.io.BufferedInputStream;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.io.FileInputStream;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.io.IOException;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.io.InputStream;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.nio.ByteBuffer;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.nio.CharBuffer;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.nio.charset.Charset;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.time.LocalDateTime;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.time.ZoneOffset;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.time.format.DateTimeFormatter;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.util.ArrayList;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.util.Arrays;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.util.Date;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.util.List;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.util.stream.Collectors;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import java.util.stream.IntStream;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import com.xxl.job.core.util.DateUtil;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//import com.ping.chuan.ahpmsdp.xxljobexecutor.util.ByteUtil;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					///**
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// * @describe: 雷达读取类
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// * @author: xiaowuler
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// * @createTime: 2022-02-28 09:18
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// */
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//public class RadarReader {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    public RadarRead readBinaryFile(String filePath, String time) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        RadarRead radar = new RadarRead();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        try{
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            InputStream inputStream = new FileInputStream(filePath);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            BufferedInputStream bi = new BufferedInputStream(inputStream);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setZoneName(readToString(bi, 12));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setDataName(readToString(bi, 38));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setFlag(readToString(bi, 8));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setVersion(readToString(bi, 8));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setYear(readToShort(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setMonth(readToShort(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setDay(readToShort(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setHour(readToShort(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setMinute(readToShort(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setInterval(readToShort(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setXNumGrids(readToShort(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setYNumGrids(readToShort(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setZNumGrids(readToShort(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            LocalDateTime initialTime = LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            Date date = Date.from(initialTime.atZone(ZoneOffset.systemDefault()).toInstant());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setTime(DateUtil.addHours(date, 8));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setRadarCount(readToInt(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setStartLon(readToFloat(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setStartLat(readToFloat(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setCenterLon(readToFloat(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setCenterLat(readToFloat(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setXReso(readToFloat(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setYReso(readToFloat(bi));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setZHighGrids(setMultipleValue(bi, new float[40]));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setRadarStationName(setMultipleValue(bi, new String[20], 16));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setRadarLongitude(setMultipleValue(bi, new float[20]));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setRadarLatitude(setMultipleValue(bi, new float[20]));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setRadarAltitude(setMultipleValue(bi, new float[20]));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            byte[] bytes = new byte[20];
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            bi.read(bytes);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setMosaicFlag(bytes);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setReserved(setMultipleValue(bi, 172));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setObserverValue(new float[radar.getZNumGrids() * radar.getYNumGrids() * radar.getXNumGrids()]);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            readValue(bi, radar, true);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            List<Float> targetValues = new ArrayList<>();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            List<Float> values =  IntStream.range(0, radar.getObserverValue().length)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                    .mapToDouble(i -> radar.getObserverValue()[i]).boxed().map(i -> i.floatValue()).collect(Collectors.toList());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            values = values.subList(305 * radar.getXNumGrids(), 700 * radar.getYNumGrids());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            for(int index = 0; index < 395; index++){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                int tempIndex = index * radar.getXNumGrids();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                targetValues.addAll(values.subList(tempIndex + 365, tempIndex + 700));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            float[] result = new float[132325];
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            for(int index = 0, len = targetValues.size(); index < len; index++){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                result[index] = targetValues.get(index);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            radar.setObserverValue(result);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        }catch (Exception e) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            throw new RuntimeException(e);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        return radar;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    private void readValue(BufferedInputStream bis, RadarRead radar, boolean flag) throws IOException {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        if (flag){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            for(int i = 0, len = radar.getXNumGrids() * radar.getYNumGrids() * radar.getZNumGrids(); i < len; i++) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                float value = bis.read();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                if (value != 0){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                    radar.getObserverValue()[i] = (value - 66) / 2;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                    continue;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                radar.getObserverValue()[i] = value;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        }else {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            for(int i = 0; i < radar.getXNumGrids() * radar.getYNumGrids() * radar.getZNumGrids(); i++) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                int value = readToInt(bis);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                radar.getObserverValue()[i] = value / 1;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    private String readToString(BufferedInputStream bi, Integer... infos) throws IOException {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        return convert(bi, (result, info) -> new String(result, info[1], info[2]), infos);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    private short readToShort(BufferedInputStream bi) throws IOException{
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        return convert(bi, (result, infos) -> ByteUtil.toShort(result), 2);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    private int readToInt(BufferedInputStream bi) throws IOException {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        return convert(bi, (result, infos) -> ByteUtil.toInt(result), 4);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    private float readToFloat(BufferedInputStream bi) throws IOException {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        return convert(bi, (result, infos) -> ByteUtil.toFloat(result), 4);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    private static <T> T convert(BufferedInputStream bi, Template<T> template, Integer... infos) throws IOException {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        if (infos.length == 1){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            infos = Arrays.copyOf(infos,3);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            infos[1] = 0;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            infos[2] = infos[0];
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        byte[] result = new byte[infos[0]];
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        bi.read(result);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        return template.readBytes(result, infos);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    interface Template<T>{
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        T readBytes(byte[] result, Integer... infos) throws IOException;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    private String[] setMultipleValue(BufferedInputStream bi, String[] result, Integer... infos) throws IOException {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        for (int index = 0, len = result.length; index < len; index++){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            result[index] = readToString(bi, infos);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        return result;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    private float[] setMultipleValue(BufferedInputStream bi, float[] result) throws IOException {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        for (int index = 0, len = result.length; index < len; index++){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            result[index] = readToFloat(bi);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        return result;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    private char[] setMultipleValue(BufferedInputStream bis, int length) throws IOException {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        byte[] bytes = new byte[length];
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        bis.read(bytes);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        Charset cs = Charset.forName ("UTF-8");
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        ByteBuffer bb = ByteBuffer.allocate (bytes.length);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        bb.put (bytes);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        bb.flip ();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        CharBuffer cb = cs.decode (bb);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        return cb.array();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//}
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
					 | 
				
				 | 
				
					
  |