|
@@ -26,7 +26,6 @@ import org.springframework.util.CollectionUtils;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.sql.Timestamp;
|
|
|
-import java.time.Duration;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -66,6 +65,12 @@ public class DemandService {
|
|
|
private PayloadRpcService payloadRpcService;
|
|
|
@Resource
|
|
|
private AlgSchemeStepWindowService algSchemeStepWindowService;
|
|
|
+ @Resource
|
|
|
+ StripMapper stripMapper;
|
|
|
+ @Resource
|
|
|
+ StepWindowControlPassRelationMapper stepWindowControlPassRelationMapper;
|
|
|
+ @Resource
|
|
|
+ StepWindowDataPassRelationMapper stepWindowDataPassRelationMapper;
|
|
|
|
|
|
private static final String DEMAND_TYPE_FULL = "1";
|
|
|
|
|
@@ -535,9 +540,17 @@ public class DemandService {
|
|
|
String parentIdSub = demandParam.getParentIds().get(0);
|
|
|
String parentIdSubstring = parentIdSub.substring(0, parentIdSub.lastIndexOf("_"));
|
|
|
algSchemeStepWindowList = algSchemeStepWindowService.getAlgSchemeStepWindowByParentIdSubstring(parentIdSubstring);
|
|
|
+ //1.2 重置strip_info表、step_window_control_pass_relation表、step_window_data_pass_relation表数据
|
|
|
+ stripMapper.initSelected(parentIdSubstring);
|
|
|
+ stepWindowControlPassRelationMapper.initSelected(parentIdSubstring);
|
|
|
+ stepWindowDataPassRelationMapper.initSelected(parentIdSubstring);
|
|
|
}else{
|
|
|
//2.1 根据传入的parent_id集合查询alg_scheme_step_window中parent_id一致的数据,然后按照卫星冲突检测规则进行时间筛选
|
|
|
algSchemeStepWindowList = algSchemeStepWindowService.getAlgSchemeStepWindowByParentIds(demandParam.getParentIds());
|
|
|
+ //2.2 重置strip_info表、step_window_control_pass_relation表、step_window_data_pass_relation表数据
|
|
|
+ stripMapper.initSelectedByList(demandParam.getParentIds());
|
|
|
+ stepWindowControlPassRelationMapper.initSelectedByList(demandParam.getParentIds());
|
|
|
+ stepWindowDataPassRelationMapper.initSelectedByList(demandParam.getParentIds());
|
|
|
}
|
|
|
//这里实现目标个数的统计
|
|
|
long targetParentIdCount= algSchemeStepWindowList.stream().map(AlgSchemeStepWindow::getParentId).distinct().count();
|
|
@@ -548,18 +561,114 @@ public class DemandService {
|
|
|
List<String> windowIds = selectedRecords.stream().map(AlgSchemeStepWindow::getId).collect(Collectors.toList());
|
|
|
// 根据windowIds查询alg_scheme_window_pass表,获取对应的数传站与测控站资源
|
|
|
List<AlgSchemeWindowPass> algSchemeWindowPassesByWindowIds = algSchemeWindowPassMapper.selectSchemeWindowPassByWindowIds(windowIds);
|
|
|
- //筛选测控站数据
|
|
|
- List<AlgSchemeWindowPass> controlWindowPass = algSchemeWindowPassesByWindowIds.stream().filter(e -> e.getPassType()==PassTypeEnum.DEMAND_CK.getCode()).collect(Collectors.toList());
|
|
|
- //筛选数传站数据
|
|
|
- List<AlgSchemeWindowPass> dataTransferWindowPass = algSchemeWindowPassesByWindowIds.stream().filter(e -> e.getPassType()==PassTypeEnum.DEMAND_SC.getCode()).collect(Collectors.toList());
|
|
|
//处理选择的条带窗口数据
|
|
|
Map<String,AlgSchemeStepWindow> stepWindowsMap = handleSelectedRecords(selectedRecords);
|
|
|
+ //这里处理获得对应条带窗口的测控数传资源
|
|
|
+ List<AlgSchemeWindowPass> ControlAndDataTransferPassList = getStripWindowControlAndDataTransferResource(stepWindowsMap, algSchemeWindowPassesByWindowIds);
|
|
|
+ //筛选测控站数据
|
|
|
+ List<AlgSchemeWindowPass> controlWindowPass = ControlAndDataTransferPassList.stream().filter(e -> e.getPassType()==PassTypeEnum.DEMAND_CK.getCode()).collect(Collectors.toList());
|
|
|
+ //筛选数传站数据
|
|
|
+ List<AlgSchemeWindowPass> dataTransferWindowPass = ControlAndDataTransferPassList.stream().filter(e -> e.getPassType()==PassTypeEnum.DEMAND_SC.getCode()).collect(Collectors.toList());
|
|
|
+
|
|
|
//处理测控站数据
|
|
|
- List<StepWindowControlPassRelation> stepWindowControlPassRelations = handleControlWindowPassData(stepWindowsMap, controlWindowPass);
|
|
|
+ List<StepWindowControlPassRelation> stepWindowControlPassRelations = controlWindowPass.stream().map(e -> {
|
|
|
+ AlgSchemeStepWindow algSchemeStepWindow = stepWindowsMap.get(e.getSchemeStepWindowId());
|
|
|
+ StepWindowControlPassRelation stepControlDataPassRelation = new StepWindowControlPassRelation();
|
|
|
+ stepControlDataPassRelation.setWindowId(e.getSchemeStepWindowId());
|
|
|
+ stepControlDataPassRelation.setStepId(algSchemeStepWindow.getSchemeStepId());
|
|
|
+ stepControlDataPassRelation.setControlStationWindowId(e.getId());
|
|
|
+ stepControlDataPassRelation.setIsConfirm(IS_CONFIRMED);
|
|
|
+ return stepControlDataPassRelation;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
//处理数传站数据
|
|
|
- List<StepWindowDataPassRelation> stepWindowDataPassRelations = handleDataTransferWindowPassData(stepWindowsMap, dataTransferWindowPass);
|
|
|
- //进行数据修改
|
|
|
- return AjaxResult.success(windowIds);
|
|
|
+ List<StepWindowDataPassRelation> stepWindowDataPassRelations = dataTransferWindowPass.stream().map(e -> {
|
|
|
+ AlgSchemeStepWindow algSchemeStepWindow = stepWindowsMap.get(e.getSchemeStepWindowId());
|
|
|
+ StepWindowDataPassRelation stepWindowDataPassRelation = new StepWindowDataPassRelation();
|
|
|
+ stepWindowDataPassRelation.setStepId(algSchemeStepWindow.getSchemeStepId());
|
|
|
+ stepWindowDataPassRelation.setDataStationWindowId(e.getId());
|
|
|
+ stepWindowDataPassRelation.setWindowId(e.getSchemeStepWindowId());
|
|
|
+ stepWindowDataPassRelation.setIsConfirm(IS_CONFIRMED);
|
|
|
+ return stepWindowDataPassRelation;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ //更新strip_info表、step_window_control_pass_relation表、step_window_data_pass_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);
|
|
|
+ return AjaxResult.success("方案生成成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理地面站资源数据
|
|
|
+ * @param stepWindowsMap:条带窗口集合
|
|
|
+ * @param algSchemeWindowPassesByWindowIds:条带窗口对应地面站资源数据集合
|
|
|
+ * @return 处理完成的地面站资源数据
|
|
|
+ */
|
|
|
+ private List<AlgSchemeWindowPass> getStripWindowControlAndDataTransferResource(Map<String, AlgSchemeStepWindow> stepWindowsMap, List<AlgSchemeWindowPass> algSchemeWindowPassesByWindowIds) {
|
|
|
+ List<AlgSchemeWindowPass> algSchemeWindowPassList = new ArrayList<>();
|
|
|
+ //筛选测控站数据
|
|
|
+ List<AlgSchemeWindowPass> controlWindowPass = algSchemeWindowPassesByWindowIds.stream().filter(e -> e.getPassType() == PassTypeEnum.DEMAND_CK.getCode()).collect(Collectors.toList());
|
|
|
+ //筛选数传站数据
|
|
|
+ List<AlgSchemeWindowPass> dataTransferWindowPass = algSchemeWindowPassesByWindowIds.stream().filter(e -> e.getPassType() == PassTypeEnum.DEMAND_SC.getCode()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //将测控站集合转换为Map<String,AlgSchemeWindowPass>的结构
|
|
|
+ Map<String, List<AlgSchemeWindowPass>> controlWindowPassMap = controlWindowPass.stream()
|
|
|
+ .collect(Collectors.groupingBy(AlgSchemeWindowPass::getSchemeStepWindowId));
|
|
|
+ //将数传站集合转换为Map<String,AlgSchemeWindowPass>的结构
|
|
|
+ Map<String, List<AlgSchemeWindowPass>> dataTransferWindowPassMap = dataTransferWindowPass.stream()
|
|
|
+ .collect(Collectors.groupingBy(AlgSchemeWindowPass::getSchemeStepWindowId));
|
|
|
+
|
|
|
+ for (Map.Entry<String, AlgSchemeStepWindow> algSchemeStepWindowEntry : stepWindowsMap.entrySet()) {
|
|
|
+ String windowId = algSchemeStepWindowEntry.getKey();
|
|
|
+ AlgSchemeStepWindow algSchemeStepWindow = algSchemeStepWindowEntry.getValue();
|
|
|
+
|
|
|
+ List<AlgSchemeWindowPass> algSchemeWindowDataTransferPasses = dataTransferWindowPassMap.get(windowId);
|
|
|
+ List<AlgSchemeWindowPass> algSchemeWindowControlPasses = controlWindowPassMap.get(windowId);
|
|
|
+
|
|
|
+ //数传站资源按进站时间顺序排序
|
|
|
+ algSchemeWindowDataTransferPasses.sort(Comparator.comparing(AlgSchemeWindowPass::getStartTime));
|
|
|
+ //测控站资源按出站时间顺序排序
|
|
|
+ algSchemeWindowControlPasses.sort(Comparator.comparing(AlgSchemeWindowPass::getEndTime));
|
|
|
+
|
|
|
+ //找到对应的测控站
|
|
|
+ for (AlgSchemeWindowPass controlPass : algSchemeWindowControlPasses) {
|
|
|
+ // 判断选择的测控站时间与已选择了测控站的时间是否有冲突
|
|
|
+ if (isTimeConflict(algSchemeWindowPassList, controlPass)) {
|
|
|
+ //不冲突则将其加入到已选择的地面站资源列表中
|
|
|
+ algSchemeWindowPassList.add(controlPass);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ //找到对应的数传站
|
|
|
+ for (AlgSchemeWindowPass dataTransferPass : algSchemeWindowDataTransferPasses) {
|
|
|
+ if (isTimeConflict(algSchemeWindowPassList, dataTransferPass)) {
|
|
|
+ //不冲突则将其加入到已选择的地面站资源列表中
|
|
|
+ algSchemeWindowPassList.add(dataTransferPass);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return algSchemeWindowPassList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断地面站资源是否时间冲突
|
|
|
+ * @param algSchemeWindowPassList:已选择的地面站资源列表
|
|
|
+ * @param controlPass:需要选择的地面站资源
|
|
|
+ * @return 是否冲突
|
|
|
+ */
|
|
|
+ private boolean isTimeConflict(List<AlgSchemeWindowPass> algSchemeWindowPassList, AlgSchemeWindowPass controlPass) {
|
|
|
+ boolean isStationConflict = algSchemeWindowPassList.stream().anyMatch(obj -> obj.getStationId().equals(controlPass.getStationId()));
|
|
|
+ if(!isStationConflict){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return !algSchemeWindowPassList.stream()
|
|
|
+ .allMatch(existObj -> controlPass.getEndTime().before(existObj.getStartTime())
|
|
|
+ || existObj.getEndTime().after(existObj.getEndTime()));
|
|
|
}
|
|
|
|
|
|
private Map<String, AlgSchemeStepWindow> handleSelectedRecords(List<AlgSchemeStepWindow> selectedRecords) {
|