Browse Source

modify some codes

master
xiaowuler 3 years ago
parent
commit
3405f50055
  1. 9
      04.系统编码/01.xxl-job/xxl-job-executor/src/main/java/com/ping/chuan/ahpmsdp/xxljobexecutor/jobhandler/TianQingRadarDataHandler.java
  2. 2
      04.系统编码/01.xxl-job/xxl-job-executor/src/main/java/com/ping/chuan/ahpmsdp/xxljobexecutor/service/IRadarService.java
  3. 13
      04.系统编码/01.xxl-job/xxl-job-executor/src/main/java/com/ping/chuan/ahpmsdp/xxljobexecutor/service/impl/RadarService.java
  4. 77
      04.系统编码/01.xxl-job/xxl-job-executor/src/main/java/com/ping/chuan/ahpmsdp/xxljobexecutor/service/impl/SchemaService.java
  5. 19
      04.系统编码/01.xxl-job/xxl-job-executor/src/test/java/com/ping/chuan/ahpmsdp/xxljobexecutor/XxlJobExecutorApplicationTests.java

9
04.系统编码/01.xxl-job/xxl-job-executor/src/main/java/com/ping/chuan/ahpmsdp/xxljobexecutor/jobhandler/TianQingRadarDataHandler.java

@ -29,6 +29,7 @@ import com.ping.chuan.ahpmsdp.xxljobexecutor.model.vo.TianQingFileVO;
import com.ping.chuan.ahpmsdp.xxljobexecutor.model.vo.TianQingResponse;
import com.ping.chuan.ahpmsdp.xxljobexecutor.service.IDataService;
import com.ping.chuan.ahpmsdp.xxljobexecutor.service.IDealInfoService;
import com.ping.chuan.ahpmsdp.xxljobexecutor.service.IRadarService;
import com.ping.chuan.ahpmsdp.xxljobexecutor.service.ITianQingSCMOCDataService;
import com.ping.chuan.ahpmsdp.xxljobexecutor.service.impl.BaseInfoService;
import com.ping.chuan.ahpmsdp.xxljobexecutor.template.CacheTemplate;
@ -50,14 +51,14 @@ public class TianQingRadarDataHandler {
private final BaseInfoService baseInfoService;
private final ITianQingSCMOCDataService tianQingSCMOCDataService;
private final IDealInfoService dealInfoService;
private final IDataService dataService;
private final IRadarService radarService;
public TianQingRadarDataHandler(ApplicationCommon applicationCommon, BaseInfoService baseInfoService, ITianQingSCMOCDataService tianQingSCMOCDataService, IDealInfoService dealInfoService, IDataService dataService){
public TianQingRadarDataHandler(ApplicationCommon applicationCommon, BaseInfoService baseInfoService, ITianQingSCMOCDataService tianQingSCMOCDataService, IDealInfoService dealInfoService, IRadarService radarService){
this.applicationCommon = applicationCommon;
this.baseInfoService = baseInfoService;
this.tianQingSCMOCDataService = tianQingSCMOCDataService;
this.dealInfoService = dealInfoService;
this.dataService = dataService;
this.radarService = radarService;
}
@XxlJob("readRadar")
@ -80,7 +81,7 @@ public class TianQingRadarDataHandler {
XxlJobHelper.log("总共需要解析文件{}个", results.size());
for(Map.Entry<DealInfo, Map.Entry<MetaInfo, Coordinate>> entry : results.entrySet()){
XxlJobHelper.log("文件:{} 开始解析", entry.getKey().getFileName());
String result = null;
String result = radarService.read(entry);
// if(paramInfo.isWind()){
// result = dataService.readWindElement(entry);
// }else {

2
04.系统编码/01.xxl-job/xxl-job-executor/src/main/java/com/ping/chuan/ahpmsdp/xxljobexecutor/service/IRadarService.java

@ -7,5 +7,5 @@ import com.ping.chuan.ahpmsdp.xxljobexecutor.model.domain.Coordinate;
import java.util.Map;
public interface IRadarService {
void read(Map.Entry<DealInfo, Map.Entry<MetaInfo, Coordinate>> entry);
String read(Map.Entry<DealInfo, Map.Entry<MetaInfo, Coordinate>> entry);
}

13
04.系统编码/01.xxl-job/xxl-job-executor/src/main/java/com/ping/chuan/ahpmsdp/xxljobexecutor/service/impl/RadarService.java

@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
import java.util.Map;
import com.xiaowuler.radar.core.exceptions.RadarReadException;
import com.xiaowuler.radar.core.weather.resolver.RadarReader;
/**
@ -16,7 +17,15 @@ import com.xiaowuler.radar.core.weather.resolver.RadarReader;
@Service
public class RadarService implements IRadarService {
@Override
public void read(Map.Entry<DealInfo, Map.Entry<MetaInfo, Coordinate>> entry) {
RadarReader radarReader = new RadarReader();
public String read(Map.Entry<DealInfo, Map.Entry<MetaInfo, Coordinate>> entry) {
try {
RadarReader radarReader = new RadarReader();
radarReader.read(entry.getKey().getLocalPath());
} catch (RadarReadException e) {
e.printStackTrace();
}
return null;
}
}

77
04.系统编码/01.xxl-job/xxl-job-executor/src/main/java/com/ping/chuan/ahpmsdp/xxljobexecutor/service/impl/SchemaService.java

@ -25,32 +25,36 @@ import com.ping.chuan.ahpmsdp.xxljobexecutor.util.CalcUtil;
@Service
public class SchemaService implements ISchemaService {
private static Map<String, DataType> partitionKey = new LinkedHashMap<>(2);
private static Map<String, DataType> dealPartitionKey = new LinkedHashMap<>(2);
private static Map<String, DataType> dealColumn = new LinkedHashMap<>(2);
static {
partitionKey.put("initial_time", DataType.timestamp());
partitionKey.put("forecast_time", DataType.timestamp());
private static Map<String, DataType> partitionKey = new LinkedHashMap<>(2){{
put("initial_time", DataType.timestamp());
put("forecast_time", DataType.timestamp());
}};
private static Map<String, DataType> dealPartitionKey = new LinkedHashMap<>(8){{
put("mode_code", DataType.varchar());
put("member_code", DataType.varchar());
put("element_code", DataType.varchar());
put("time_interval", DataType.cint());
put("time_length", DataType.cint());
put("height", DataType.decimal());
put("initial_time", DataType.timestamp());
put("forecast_time", DataType.timestamp());
}};
private static Map<String, DataType> dealColumn = new LinkedHashMap<>(8) {
{
put("local_path", DataType.varchar());
put("file_name", DataType.varchar());
put("try_count", DataType.cint());
put("message", DataType.varchar());
put("state", DataType.cint());
put("url", DataType.varchar());
put("update_time", DataType.timestamp());
put("create_time", DataType.timestamp());
}
};
dealPartitionKey.put("mode_code", DataType.varchar());
dealPartitionKey.put("member_code", DataType.varchar());
dealPartitionKey.put("element_code", DataType.varchar());
dealPartitionKey.put("time_interval", DataType.cint());
dealPartitionKey.put("time_length", DataType.cint());
dealPartitionKey.put("height", DataType.decimal());
dealPartitionKey.put("initial_time", DataType.timestamp());
dealPartitionKey.put("forecast_time", DataType.timestamp());
dealColumn.put("local_path", DataType.varchar());
dealColumn.put("file_name", DataType.varchar());
dealColumn.put("try_count", DataType.cint());
dealColumn.put("message", DataType.varchar());
dealColumn.put("state", DataType.cint());
dealColumn.put("url", DataType.varchar());
dealColumn.put("update_time", DataType.timestamp());
dealColumn.put("create_time", DataType.timestamp());
}
private static Map<String, DataType> radarPartitionKey = new LinkedHashMap<>(partitionKey){{
put("station", DataType.varchar());
}};
private final ISchemaRepository schemaRepository;
public SchemaService(ISchemaRepository schemaRepository){
@ -76,11 +80,30 @@ public class SchemaService implements ISchemaService {
private void buildDataTable(String keyspace){
for(Map.Entry<MetaInfo, Coordinate> entry : CacheTemplate.metaInfos.entrySet()){
String tableName = entry.getKey().toTableName();
Map<String, DataType> columns = toColumn(CalcUtil.calcClip(entry.getValue().getLatCount(), entry.getKey().getLatClipCount()), CalcUtil.calcClip(entry.getValue().getLonCount(), entry.getKey().getLonClipCount()));
schemaRepository.prepareTable(keyspace, tableName, partitionKey, columns);
Map<String, DataType> columns;
if (entry.getKey().getModeCode().equals("RADAR")){
columns = toColumn(20);
schemaRepository.prepareTable(keyspace, tableName, radarPartitionKey, columns);
}else {
columns = toColumn(CalcUtil.calcClip(entry.getValue().getLatCount(), entry.getKey().getLatClipCount()), CalcUtil.calcClip(entry.getValue().getLonCount(), entry.getKey().getLonClipCount()));
schemaRepository.prepareTable(keyspace, tableName, partitionKey, columns);
}
}
}
private Map<String, DataType> toColumn(int length){
Map<String, DataType> columns = new LinkedHashMap<>(length + 3){{
put("site_configuration", DataType.blob());
put("task_configuration", DataType.blob());
put("generic_header", DataType.blob());
}};
for(int index = 0; index < length; index++){
columns.put("col_%s".formatted(index), DataType.blob());
}
return columns;
}
private Map<String, DataType> toColumn(int latLength, int lonLength){
Map<String, DataType> columns = new LinkedHashMap<>(latLength * lonLength + 2);
columns.put("time_effect", DataType.cint());

19
04.系统编码/01.xxl-job/xxl-job-executor/src/test/java/com/ping/chuan/ahpmsdp/xxljobexecutor/XxlJobExecutorApplicationTests.java

@ -167,14 +167,17 @@ class XxlJobExecutorApplicationTests {
// metaInfos.add(Lists.newArrayList("CLDAS", "BABJ", "MXT", 60, 60, 1010, "1201_1401_0.05_0.05_0_60_70_140", 0, "H", 60, 60, 70, "Maximum_temperature_height_above_ground"));
// metaInfos.add(Lists.newArrayList("CLDAS", "BABJ", "MXWIN_U", 60, 60, 1010, "1201_1401_0.05_0.05_0_60_70_140", 0, "H", 60, 60, 70, "VAR0-2-102_FROM_38-0--1_height_above_ground"));
// metaInfos.add(Lists.newArrayList("CLDAS", "BABJ", "MXWIN_V", 60, 60, 1010, "1201_1401_0.05_0.05_0_60_70_140", 0, "H", 60, 60, 70, "VAR0-2-103_FROM_38-0--1_height_above_ground"));
metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "TMP", 180, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 180, "H", 60, 30, 30, "Temperature_height_above_ground"));
metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "EDA10_U", 180, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 180, "H", 60, 30, 30, "u-component_of_wind_height_above_ground"));
metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "EDA10_V", 180, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 180, "H", 60, 30, 30, "v-component_of_wind_height_above_ground"));
metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "ER03", 180, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 180, "H", 60, 30, 30, "Total_precipitation_surface_3_Hour_Accumulation"));
metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "PPH", 180, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 180, "H", 60, 30, 30, "Precipitation_type_surface_3_Hour_Accumulation"));
metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "TMAX", 1440, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 1440, "H", 60, 30, 30, "Maximum_temperature_height_above_ground_24_Hour_Maximum"));
metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "TMIN", 1440, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 1440, "H", 60, 30, 30, "Minimum_temperature_height_above_ground_24_Hour_Minimum"));
metaInfos.add(Lists.newArrayList("CMPA", "BABJ", "PRE", 60, 60, 1010, "1201_1401_0.05_0.05_0_60_70_140", 0, "H", 60, 60, 70, "Total_precipitation_surface"));
// metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "TMP", 180, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 180, "H", 60, 30, 30, "Temperature_height_above_ground"));
// metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "EDA10_U", 180, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 180, "H", 60, 30, 30, "u-component_of_wind_height_above_ground"));
// metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "EDA10_V", 180, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 180, "H", 60, 30, 30, "v-component_of_wind_height_above_ground"));
// metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "ER03", 180, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 180, "H", 60, 30, 30, "Total_precipitation_surface_3_Hour_Accumulation"));
// metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "PPH", 180, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 180, "H", 60, 30, 30, "Precipitation_type_surface_3_Hour_Accumulation"));
// metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "TMAX", 1440, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 1440, "H", 60, 30, 30, "Maximum_temperature_height_above_ground_24_Hour_Maximum"));
// metaInfos.add(Lists.newArrayList("SPCC", "BEHF", "TMIN", 1440, 4320, 1010, "243_221_0.025_0.025_29_35.05_114.5_120", 1440, "H", 60, 30, 30, "Minimum_temperature_height_above_ground_24_Hour_Minimum"));
// metaInfos.add(Lists.newArrayList("CMPA", "BABJ", "PRE", 60, 60, 1010, "1201_1401_0.05_0.05_0_60_70_140", 0, "H", 60, 60, 70, "Total_precipitation_surface"));
metaInfos.add(Lists.newArrayList("RADAR", "SAD", "CAP", 6, 6, 1010, "1201_1401_0.05_0.05_0_60_70_140", 0, "m", 6, 6, 70, ""));
metaInfos.add(Lists.newArrayList("RADAR", "CC", "CAP", 6, 6, 1010, "1201_1401_0.05_0.05_0_60_70_140", 0, "m", 6, 6, 70, ""));
metaInfos.add(Lists.newArrayList("RADAR", "SA", "CAP", 6, 6, 1010, "1201_1401_0.05_0.05_0_60_70_140", 0, "m", 6, 6, 70, ""));
return metaInfos;
}

Loading…
Cancel
Save