|
@@ -66,6 +66,9 @@ public class DemandService {
|
|
|
private PayloadRpcService payloadRpcService;
|
|
|
@Resource
|
|
|
private AlgSchemeStepWindowService algSchemeStepWindowService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ AlgSchemeStepService algSchemeStepService;
|
|
|
@Resource
|
|
|
StripMapper stripMapper;
|
|
|
@Resource
|
|
@@ -336,10 +339,20 @@ public class DemandService {
|
|
|
});
|
|
|
int timeVal = kjckDTOS.size();
|
|
|
AlgSchemeStep algSchemeStep = AlgSchemeStep.builder()
|
|
|
- .id(algId).earliestObservationTime(earilyTime).createdDate(DateUtils.getNowDate())
|
|
|
- .maxScoutFre(new BigDecimal(maxTimeInterVal / 1000)).minScoutFre(new BigDecimal(minTimeInterVal / 1000)).loadType(types.toString())
|
|
|
- .observeNum(new BigDecimal(timeVal)).priority(demandDTO.getPriority()).daily(new BigDecimal(timeVal / days)).satCount(dtos.size()).stepName(demandDTO.getTargetName())
|
|
|
- .maxLoadResolution(new BigDecimal(maxResolution)).minLoadResolution(new BigDecimal(minResolution)).isConfirm(2)
|
|
|
+ .id(algId)
|
|
|
+ .earliestObservationTime(earilyTime)
|
|
|
+ .createdDate(DateUtils.getNowDate())
|
|
|
+ .maxScoutFre(new BigDecimal(maxTimeInterVal / 1000))
|
|
|
+ .minScoutFre(new BigDecimal(minTimeInterVal / 1000))
|
|
|
+ .loadType(types.toString())
|
|
|
+ .observeNum(new BigDecimal(timeVal))
|
|
|
+ .priority(demandDTO.getPriority())
|
|
|
+ .daily(new BigDecimal(timeVal / days))
|
|
|
+ .satCount(dtos.size())
|
|
|
+ .stepName(demandDTO.getTargetName())
|
|
|
+ .maxLoadResolution(new BigDecimal(maxResolution))
|
|
|
+ .minLoadResolution(new BigDecimal(minResolution))
|
|
|
+ .isConfirm(2)
|
|
|
.build();
|
|
|
|
|
|
return algSchemeStep;
|
|
@@ -541,11 +554,13 @@ public class DemandService {
|
|
|
String parentIdSub = demandParam.getParentIds().get(0);
|
|
|
String parentIdSubstring = parentIdSub.substring(0, parentIdSub.lastIndexOf("_"));
|
|
|
algSchemeStepWindowList = algSchemeStepWindowService.getAlgSchemeStepWindowByParentIdSubstring(parentIdSubstring);
|
|
|
+ List<String> parentIds = algSchemeStepWindowList.stream().map(AlgSchemeStepWindow::getParentId).distinct().collect(Collectors.toList());
|
|
|
//1.2 重置strip_info表、step_window_control_pass_relation表、step_window_data_pass_relation表数据
|
|
|
stripMapper.initSelected(parentIdSubstring);
|
|
|
stepWindowControlPassRelationMapper.initSelected(parentIdSubstring);
|
|
|
stepWindowDataPassRelationMapper.initSelected(parentIdSubstring);
|
|
|
stepWindowRelationMapper.initConfirmStatus(parentIdSubstring);
|
|
|
+ algSchemeStepMapper.delete(new QueryWrapper<AlgSchemeStep>().in("parent_id",parentIds));
|
|
|
}else{
|
|
|
//2.1 根据传入的parent_id集合查询alg_scheme_step_window中parent_id一致的数据,然后按照卫星冲突检测规则进行时间筛选
|
|
|
algSchemeStepWindowList = algSchemeStepWindowService.getAlgSchemeStepWindowByParentIds(demandParam.getParentIds());
|
|
@@ -558,6 +573,74 @@ public class DemandService {
|
|
|
//这里实现目标个数的统计
|
|
|
long targetParentIdCount= algSchemeStepWindowList.stream().map(AlgSchemeStepWindow::getParentId).distinct().count();
|
|
|
selectedRecords = findFilteredData(algSchemeStepWindowList,targetParentIdCount);
|
|
|
+ //准备构建alg_scheme_step对象数据
|
|
|
+ ArrayList<AlgSchemeStep> algSchemeSteps = new ArrayList<>();
|
|
|
+ Set<String> parentIds = selectedRecords.stream().map(AlgSchemeStepWindow::getParentId).collect(Collectors.toSet());
|
|
|
+ List<String> satelliteIds = selectedRecords.stream().map(AlgSchemeStepWindow::getSatelliteId).distinct().collect(Collectors.toList());
|
|
|
+ List<TargetDemandRpcDTO> targetDemandRpcDTOS = tragetDemandRpcService.selTargetDemandByParentId(parentIds);
|
|
|
+ List<PayloadRpcDTO> payloadRpcDTOs = payloadRpcService.getPayloadListBySatelliteIds(satelliteIds);
|
|
|
+ Map<String, TargetDemandRpcDTO> TargetDemandMap = targetDemandRpcDTOS.stream()
|
|
|
+ .collect(Collectors.toMap(TargetDemandRpcDTO::getParentId, Function.identity()));
|
|
|
+ Map<String, PayloadRpcDTO> payloadRpcMap = payloadRpcDTOs.stream().collect(Collectors.toMap(PayloadRpcDTO::getSatelliteId, Function.identity()));
|
|
|
+ Map<String, List<AlgSchemeStepWindow>> algSchemeStepWindowMap = algSchemeStepWindowList.stream()
|
|
|
+ .collect(Collectors.groupingBy(AlgSchemeStepWindow::getParentId));
|
|
|
+ List<StepWindowRelation> stepWindowRelations = new ArrayList<>();
|
|
|
+ for(AlgSchemeStepWindow algSchemeStepWindow : selectedRecords){
|
|
|
+ String algSchemeStepId = UUID.randomUUID().toString();
|
|
|
+
|
|
|
+ String parentId = algSchemeStepWindow.getParentId();
|
|
|
+ String satelliteId = algSchemeStepWindow.getSatelliteId();
|
|
|
+
|
|
|
+ TargetDemandRpcDTO targetDemandRpcDTO = TargetDemandMap.get(parentId);
|
|
|
+ PayloadRpcDTO payloadRpcDTO = payloadRpcMap.get(satelliteId);
|
|
|
+ List<AlgSchemeStepWindow> algSchemeStepWindows = algSchemeStepWindowMap.get(parentId);
|
|
|
+ List<Long> windowGapTimes = algSchemeStepWindows.stream().map(t -> {
|
|
|
+ return DateUtils.trByDate(t.getStartTime(), t.getEndTime());
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ Long maxWindowGapTime = Collections.max(windowGapTimes);
|
|
|
+ Long minWindowGapTime = Collections.min(windowGapTimes);
|
|
|
+ AlgSchemeStepWindow earlyAccessTimeAlgSchemeStepWindow = algSchemeStepWindows.stream().min(Comparator.comparing(AlgSchemeStepWindow::getAccessTime)).get();
|
|
|
+ Date accessTime = earlyAccessTimeAlgSchemeStepWindow.getAccessTime();
|
|
|
+ long satelliteSize = algSchemeStepWindows.stream().map(AlgSchemeStepWindow::getSatelliteId).distinct().count();
|
|
|
+
|
|
|
+ AlgSchemeStepWindow earlyAlgSchemeStepWindow = algSchemeStepWindows.stream().min(Comparator.comparing(AlgSchemeStepWindow::getStartTime)).get();
|
|
|
+ AlgSchemeStepWindow latestAlgSchemeStepWindow = algSchemeStepWindows.stream().max(Comparator.comparing(AlgSchemeStepWindow::getEndTime)).get();
|
|
|
+ int days = DateUtils.differentDaysByMillisecond(earlyAlgSchemeStepWindow.getStartTime()
|
|
|
+ , latestAlgSchemeStepWindow.getEndTime()) == 0 ? 1 : DateUtils.differentDaysByMillisecond(earlyAlgSchemeStepWindow.getStartTime(), latestAlgSchemeStepWindow.getEndTime());
|
|
|
+
|
|
|
+ //获取最大地面分辨率
|
|
|
+ double maxLoadResolution = payloadRpcDTOs.stream().mapToDouble(YxInfoSatellitePayload -> YxInfoSatellitePayload.getGroundResolution().floatValue()).max().getAsDouble();
|
|
|
+ //获取最小地面分辨率
|
|
|
+ double minLoadResolution = payloadRpcDTOs.stream().mapToDouble(YxInfoSatellitePayload -> YxInfoSatellitePayload.getGroundResolution().floatValue()).min().getAsDouble();
|
|
|
+
|
|
|
+
|
|
|
+ AlgSchemeStep algSchemeStep = new AlgSchemeStep();
|
|
|
+ algSchemeStep.setId(algSchemeStepId);
|
|
|
+ algSchemeStep.setEarliestObservationTime(accessTime);
|
|
|
+ algSchemeStep.setMaxScoutFre(new BigDecimal(maxWindowGapTime / 1000));
|
|
|
+ algSchemeStep.setMinScoutFre(new BigDecimal(minWindowGapTime / 1000));
|
|
|
+ algSchemeStep.setLoadType(payloadRpcDTO.getPayloadType());
|
|
|
+ algSchemeStep.setObserveNum(new BigDecimal(satelliteSize));
|
|
|
+ algSchemeStep.setPriority(targetDemandRpcDTO.getPriority());
|
|
|
+ algSchemeStep.setDaily(new BigDecimal(satelliteSize / days));
|
|
|
+ algSchemeStep.setSatCount((int) satelliteSize);
|
|
|
+ algSchemeStep.setStepName(targetDemandRpcDTO.getTargetName());
|
|
|
+ algSchemeStep.setMaxLoadResolution(new BigDecimal(maxLoadResolution));
|
|
|
+ algSchemeStep.setMinLoadResolution(new BigDecimal(minLoadResolution));
|
|
|
+ algSchemeStep.setIsConfirm(IS_CONFIRMED);
|
|
|
+ algSchemeStep.setCreatedDate(DateUtils.getNowDate());
|
|
|
+ algSchemeStep.setParentId(algSchemeStepWindow.getParentId());
|
|
|
+
|
|
|
+ StepWindowRelation stepWindowRelation = new StepWindowRelation();
|
|
|
+ stepWindowRelation.setStepId(algSchemeStepId);
|
|
|
+ stepWindowRelation.setWindowId(algSchemeStepWindow.getId());
|
|
|
+ stepWindowRelation.setIsConfirm(IS_CONFIRMED);
|
|
|
+ //更新alg_scheme_step_window表中scheme_step_id字段
|
|
|
+ algSchemeStepWindowMapper.updateStepIdByParentId(algSchemeStepId,parentId);
|
|
|
+ algSchemeStepWindow.setSchemeStepId(algSchemeStepId);
|
|
|
+ algSchemeSteps.add(algSchemeStep);
|
|
|
+ stepWindowRelations.add(stepWindowRelation);
|
|
|
+ }
|
|
|
log.info("筹划方案生成结果条数:{}", selectedRecords.size());
|
|
|
//目标对应条带窗口已经筛选完成,这里开始处理对应条带与数传站
|
|
|
//筛选拍摄目标条带的satelliteId
|
|
@@ -593,16 +676,92 @@ public class DemandService {
|
|
|
stepWindowDataPassRelation.setIsConfirm(IS_CONFIRMED);
|
|
|
return stepWindowDataPassRelation;
|
|
|
}).collect(Collectors.toList());
|
|
|
- //更新strip_info表、step_window_control_pass_relation表、step_window_data_pass_relation表数据
|
|
|
+ //更新strip_info表、新增或修改step_window_control_pass_relation表、step_window_data_pass_relation表、step_window_relation表的数据
|
|
|
stripMapper.batchUpdateSelectedStatus(windowIds);
|
|
|
- List<String> controlWindowIds = stepWindowControlPassRelations.stream().map(StepWindowControlPassRelation::getControlStationWindowId).collect(Collectors.toList());
|
|
|
- List<String> dataWindowIds = stepWindowDataPassRelations.stream().map(StepWindowDataPassRelation::getDataStationWindowId).collect(Collectors.toList());
|
|
|
- stepWindowControlPassRelationMapper.batchUpdateConfirmStatus(controlWindowIds);
|
|
|
- stepWindowDataPassRelationMapper.batchUpdateConfirmStatus(dataWindowIds);
|
|
|
- stepWindowRelationMapper.batchUpdateConfirmStatus(windowIds);
|
|
|
+ algSchemeStepService.saveBatch(algSchemeSteps);
|
|
|
+ saveOrUpdateRelationData(stepWindowControlPassRelations, stepWindowDataPassRelations, stepWindowRelations);
|
|
|
return AjaxResult.success("方案生成成功");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存或更新step_window_control_pass_relation表、step_window_data_pass_relation表、step_window_relation表的数据
|
|
|
+ * @param stepWindowControlPassRelations: 控制站资源集合
|
|
|
+ * @param stepWindowDataPassRelations: 数传站资源集合
|
|
|
+ * @param stepWindowRelations: 条带窗口关系表集合
|
|
|
+ */
|
|
|
+ private void saveOrUpdateRelationData(List<StepWindowControlPassRelation> stepWindowControlPassRelations, List<StepWindowDataPassRelation> stepWindowDataPassRelations, List<StepWindowRelation> stepWindowRelations) {
|
|
|
+ List<String> controlWindowIds = new ArrayList<>();
|
|
|
+ List<String> dataWindowIds = new ArrayList<>();
|
|
|
+ List<String> updateWindowIds = new ArrayList<>();
|
|
|
+
|
|
|
+ for(StepWindowControlPassRelation stepWindowControlPassRelation : stepWindowControlPassRelations){
|
|
|
+ QueryWrapper<StepWindowControlPassRelation> stepWindowControlPassRelationQueryWrapper = getStepWindowControlPassRelationQueryWrapper(stepWindowControlPassRelation);
|
|
|
+ List<StepWindowControlPassRelation> stepWindowControlPassRelationIsExist = stepWindowControlPassRelationMapper.selectList(stepWindowControlPassRelationQueryWrapper);
|
|
|
+
|
|
|
+ if(stepWindowControlPassRelationIsExist.isEmpty()){
|
|
|
+ stepWindowControlPassRelation.setId(System.currentTimeMillis());
|
|
|
+ stepWindowControlPassRelation.setCreateTime(DateUtils.getNowDate());
|
|
|
+ stepWindowControlPassRelationMapper.insert(stepWindowControlPassRelation);
|
|
|
+ }else {
|
|
|
+ controlWindowIds.add(stepWindowControlPassRelation.getControlStationWindowId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(StepWindowDataPassRelation stepWindowDataPassRelation : stepWindowDataPassRelations){
|
|
|
+ QueryWrapper<StepWindowDataPassRelation> stepWindowDataPassRelationQueryWrapper = getStepWindowDataPassRelationQueryWrapper(stepWindowDataPassRelation);
|
|
|
+ List<StepWindowDataPassRelation> stepWindowDataPassRelationIsExist = stepWindowDataPassRelationMapper.selectList(stepWindowDataPassRelationQueryWrapper);
|
|
|
+
|
|
|
+ if(stepWindowDataPassRelationIsExist.isEmpty()){
|
|
|
+ stepWindowDataPassRelation.setId(System.currentTimeMillis());
|
|
|
+ stepWindowDataPassRelation.setCreateTime(DateUtils.getNowDate());
|
|
|
+ stepWindowDataPassRelationMapper.insert(stepWindowDataPassRelation);
|
|
|
+ }else {
|
|
|
+ dataWindowIds.add(stepWindowDataPassRelation.getDataStationWindowId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(StepWindowRelation stepWindowRelation : stepWindowRelations){
|
|
|
+ QueryWrapper<StepWindowRelation> stepWindowRelationQueryWrapper = new QueryWrapper<>();
|
|
|
+ HashMap<String, String> stepParamMap = new HashMap<>();
|
|
|
+ stepParamMap.put("window_id", stepWindowRelation.getWindowId());
|
|
|
+ stepWindowRelationQueryWrapper.allEq(stepParamMap);
|
|
|
+ List<StepWindowRelation> stepWindowRelationIsExist = stepWindowRelationMapper.selectList(stepWindowRelationQueryWrapper);
|
|
|
+
|
|
|
+ if(stepWindowRelationIsExist.isEmpty()){
|
|
|
+ stepWindowRelation.setId(System.currentTimeMillis());
|
|
|
+ stepWindowRelation.setCreateTime(DateUtils.getNowDate());
|
|
|
+ stepWindowRelationMapper.insert(stepWindowRelation);
|
|
|
+ }else {
|
|
|
+ updateWindowIds.add(stepWindowRelation.getWindowId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!controlWindowIds.isEmpty()){
|
|
|
+ stepWindowControlPassRelationMapper.batchUpdateConfirmStatus(controlWindowIds);
|
|
|
+ }
|
|
|
+ if (!dataWindowIds.isEmpty()){
|
|
|
+ stepWindowDataPassRelationMapper.batchUpdateConfirmStatus(dataWindowIds);
|
|
|
+ }
|
|
|
+ if(!updateWindowIds.isEmpty()){
|
|
|
+ stepWindowRelationMapper.batchUpdateConfirmStatus(updateWindowIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private QueryWrapper<StepWindowDataPassRelation> getStepWindowDataPassRelationQueryWrapper(StepWindowDataPassRelation stepWindowDataPassRelation) {
|
|
|
+ QueryWrapper<StepWindowDataPassRelation> stepWindowDataPassRelationQueryWrapper = new QueryWrapper<>();
|
|
|
+ HashMap<String, String> dataPassParamMap = new HashMap<>();
|
|
|
+ dataPassParamMap.put("window_id", stepWindowDataPassRelation.getWindowId());
|
|
|
+ dataPassParamMap.put("data_station_window_id", stepWindowDataPassRelation.getDataStationWindowId());
|
|
|
+ stepWindowDataPassRelationQueryWrapper.allEq(dataPassParamMap);
|
|
|
+ return stepWindowDataPassRelationQueryWrapper;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static QueryWrapper<StepWindowControlPassRelation> getStepWindowControlPassRelationQueryWrapper(StepWindowControlPassRelation stepWindowControlPassRelation) {
|
|
|
+ QueryWrapper<StepWindowControlPassRelation> stepWindowControlPassRelationQueryWrapper = new QueryWrapper<>();
|
|
|
+ HashMap<String, String> controlPassParamMap = new HashMap<>();
|
|
|
+ controlPassParamMap.put("window_id", stepWindowControlPassRelation.getWindowId());
|
|
|
+ controlPassParamMap.put("control_station_window_id", stepWindowControlPassRelation.getControlStationWindowId());
|
|
|
+ stepWindowControlPassRelationQueryWrapper.allEq(controlPassParamMap);
|
|
|
+ return stepWindowControlPassRelationQueryWrapper;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 处理地面站资源数据
|
|
|
* @param stepWindowsMap:条带窗口集合
|
|
@@ -806,9 +965,6 @@ public class DemandService {
|
|
|
}
|
|
|
|
|
|
private boolean isOverlapping(List<AlgSchemeStepWindow> records, AlgSchemeStepWindow newRecord, int leadTime, int postTime) {
|
|
|
- if(newRecord.getParentId().equals("240906_XQCH_10017_0025") || newRecord.getParentId().equals("240906_XQCH_10017_0020")){
|
|
|
- log.info("进入了断点");
|
|
|
- }
|
|
|
for (AlgSchemeStepWindow record : records) {
|
|
|
long existStartTime = record.getStartTime().getTime() - (long) leadTime * 60 * 1000;
|
|
|
long existEndTime = record.getEndTime().getTime() + (long) postTime * 60 * 1000;
|