Przeglądaj źródła

202411041704 #comment 条带计算改为单线程

lhq 3 tygodni temu
rodzic
commit
2d87938f53

+ 60 - 75
orbit-base-plan/base-plan-service/src/main/java/com/base/plan/service/StripService.java

@@ -794,21 +794,6 @@ public class StripService extends ServiceImpl<StripMapper, StripInfo> {
     }*/
     public void getPayloadInfosByReqId(List<TargetDemandRpcDTO> targetDemandRpcDTOS) {
         if (CollectionUtils.isEmpty(targetDemandRpcDTOS)) return;
-        ThreadPoolTaskExecutor threadPoolTaskExecutor = null;
-        try {
-            threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
-            threadPoolTaskExecutor.setCorePoolSize(COUR_SIZE);
-            threadPoolTaskExecutor.setMaxPoolSize(MAX_COUR_SIZE);
-            threadPoolTaskExecutor.setQueueCapacity(MAX_COUR_SIZE * 2 * 10);
-            threadPoolTaskExecutor.setKeepAliveSeconds(60);
-            threadPoolTaskExecutor.setThreadNamePrefix("threadExecutor-");
-            threadPoolTaskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
-            threadPoolTaskExecutor.setWaitForTasksToCompleteOnShutdown(true);
-            threadPoolTaskExecutor.initialize();
-            log.info("线程池初始化成功");
-        } catch (Exception e) {
-            log.info("初始化线程池失败:{}", e.getMessage());
-        }
         List<PayloadRpcDTO> payloadRpcDTOList = payloadRpcService.getAllList();
         ArrayList<StripCalcResult> stripCalcResults = new ArrayList<>();
         AtomicLong primaryKeyGenerator = new AtomicLong(1);
@@ -822,73 +807,73 @@ public class StripService extends ServiceImpl<StripMapper, StripInfo> {
 
 
             log.info("开始计算:{}", System.currentTimeMillis());
-            threadPoolTaskExecutor.execute(() -> {
-                List<PointRpcDTO> value=targetRelationDTO.getPointDTOList();
-                /**
-                 * 1.构建观测区域
-                 * 2.根据观测区域获取可见星下点数据
-                 */
-                System.out.println("====================构建观测区域===================");
-
-                //判断是那个类型的目标 目前只有移动点目标 线目标 点群目标需要做单独处理
-                if (targetRelationDTO.getType()==1){
-                    //移动点目标
-                    //根据 航向 航速 时间进行轨迹推算 取得所需时刻后的目标点位
-                    String startlon=value.get(0).getLongitude() ;
-                    String startlat=value.get(0).getLatitude();
-                    PointRpcDTO pointRpcDTO=LaLonUtil.deadReckoning(startlon,startlat,"10","1","90");
-                    value.get(0).setLatitude(pointRpcDTO.getLatitude());
-                    value.get(0).setLongitude(pointRpcDTO.getLongitude());
-                }
 
-                Map<Integer, List<PointRpcDTO>> PointRpcDTOmapNew=new HashMap<>();
-
-                if (targetRelationDTO.getType()==3){
-                    //线目标
-                    //先将多点目标按照时间连城线并绘制区域
-                    PointRpcDTO pointRpcDTO1=new PointRpcDTO();
-                    PointRpcDTO pointRpcDTO2=new PointRpcDTO();
-                    for (int i=0;i<value.size();i++){
-                        if (i!=value.size()-1){
-                            pointRpcDTO1=value.get(i);
-                            pointRpcDTO2=value.get(i+1);
-                            //两点连线转区域
-                            List<PointRpcDTO> pointRpcDTOList2=new ArrayList<>();
-                            pointRpcDTOList2= LaLonUtil.draw(pointRpcDTO1,pointRpcDTO2);
-                            PointRpcDTOmapNew.put(i,pointRpcDTOList2);
-                        }
-                    }
+            List<PointRpcDTO> value = targetRelationDTO.getPointDTOList();
+            /**
+             * 1.构建观测区域
+             * 2.根据观测区域获取可见星下点数据
+             */
+            System.out.println("====================构建观测区域===================");
+
+            //判断是那个类型的目标 目前只有移动点目标 线目标 点群目标需要做单独处理
+            if (targetRelationDTO.getType() == 1) {
+                //移动点目标
+                //根据 航向 航速 时间进行轨迹推算 取得所需时刻后的目标点位
+                String startlon = value.get(0).getLongitude();
+                String startlat = value.get(0).getLatitude();
+                PointRpcDTO pointRpcDTO = LaLonUtil.deadReckoning(startlon, startlat, "10", "1", "90");
+                value.get(0).setLatitude(pointRpcDTO.getLatitude());
+                value.get(0).setLongitude(pointRpcDTO.getLongitude());
+            }
 
-                }
-                if (targetRelationDTO.getType()==4){
-                    //点群目标
-                    //先绘制点群外接四边形区域
-                    List<PointRpcDTO> pointRpcDTOList2=new ArrayList<>();
-                    pointRpcDTOList2=LaLonUtil.getregion(value);
-                    value=new ArrayList<>();
-                    value=pointRpcDTOList2;
+            Map<Integer, List<PointRpcDTO>> PointRpcDTOmapNew = new HashMap<>();
+
+            if (targetRelationDTO.getType() == 3) {
+                //线目标
+                //先将多点目标按照时间连城线并绘制区域
+                PointRpcDTO pointRpcDTO1 = new PointRpcDTO();
+                PointRpcDTO pointRpcDTO2 = new PointRpcDTO();
+                for (int i = 0; i < value.size(); i++) {
+                    if (i != value.size() - 1) {
+                        pointRpcDTO1 = value.get(i);
+                        pointRpcDTO2 = value.get(i + 1);
+                        //两点连线转区域
+                        List<PointRpcDTO> pointRpcDTOList2 = new ArrayList<>();
+                        pointRpcDTOList2 = LaLonUtil.draw(pointRpcDTO1, pointRpcDTO2);
+                        PointRpcDTOmapNew.put(i, pointRpcDTOList2);
+                    }
                 }
 
-                if (!CollectionUtils.isEmpty(PointRpcDTOmapNew)) {
-                    PointRpcDTOmapNew.forEach((key1, value1) -> {
-                        targetRelationDTO.setPointDTOList(value1);
-                        count( targetRelationDTO, payloadRpcDTOList, stripCalcResults, primaryKeyGenerator
-                        );
-                    });
+            }
+            if (targetRelationDTO.getType() == 4) {
+                //点群目标
+                //先绘制点群外接四边形区域
+                List<PointRpcDTO> pointRpcDTOList2 = new ArrayList<>();
+                pointRpcDTOList2 = LaLonUtil.getregion(value);
+                value = new ArrayList<>();
+                value = pointRpcDTOList2;
+            }
 
-                }else {
-                    targetRelationDTO.setPointDTOList(value);
-                    count( targetRelationDTO, payloadRpcDTOList, stripCalcResults, primaryKeyGenerator
+            if (!CollectionUtils.isEmpty(PointRpcDTOmapNew)) {
+                PointRpcDTOmapNew.forEach((key1, value1) -> {
+                    targetRelationDTO.setPointDTOList(value1);
+                    count(targetRelationDTO, payloadRpcDTOList, stripCalcResults, primaryKeyGenerator
                     );
-                }
-            });
+                });
+
+            } else {
+                targetRelationDTO.setPointDTOList(value);
+                count(targetRelationDTO, payloadRpcDTOList, stripCalcResults, primaryKeyGenerator
+                );
+            }
+
             log.info("结束计算:{}", System.currentTimeMillis());
         }
     }
 
-    public void count(TargetDemandRpcDTO targetRelationDTO ,List<PayloadRpcDTO> payloadRpcDTOList
-            ,ArrayList<StripCalcResult> stripCalcResults
-            ,AtomicLong primaryKeyGenerator) {
+    public void count(TargetDemandRpcDTO targetRelationDTO, List<PayloadRpcDTO> payloadRpcDTOList
+            , ArrayList<StripCalcResult> stripCalcResults
+            , AtomicLong primaryKeyGenerator) {
         List<SatelliteIdAndPayloadDTO> dtos = satelliteIdCastDTO(targetRelationDTO.getSatelliteSelected());
         for (SatelliteIdAndPayloadDTO dto : dtos) {
             //根据卫星id查询载荷
@@ -960,7 +945,7 @@ public class StripService extends ServiceImpl<StripMapper, StripInfo> {
                         /*regionCoreDTO.setBizSerial(req.getReqIds().get(0));*/
                         bizReq.setRegion(regionCoreDTO);
                         List<SubPointDataRpcDTO> subPointDataRpcDTOS = regionService.getSubPoint(regionCoreDTO, payloadRpcDTO, targetRelationDTO);
-                        log.info("查询到星下点条数!:"+subPointDataRpcDTOS.size());
+                        log.info("查询到星下点条数!:" + subPointDataRpcDTOS.size());
                         if (!CollectionUtils.isEmpty(subPointDataRpcDTOS)) {
                                     /*EphTrack ephTrack = ephTrackService.convertEphTrack(subPointDataRpcDTOS, payloadInfo, fzTaskInfo);
                                     ephdatas.add(ephTrack);*/
@@ -977,7 +962,7 @@ public class StripService extends ServiceImpl<StripMapper, StripInfo> {
                             List<AlgSchemeStepWindow> algSchemeStepWindows = formatAndBatch(stripDTOList, payloadRpcDTO, targetRelationDTO.getParentId());
                             try {
                                 saveStrips(stripDTOList, payloadRpcDTO, targetRelationDTO.getParentId(), targetRelationDTO.getPointDTOList().get(0));
-                            }catch (Exception e){
+                            } catch (Exception e) {
                                 /*stripCalcResult.setIsSucceeded(STRIP_CALC_RESULT_FAILED);*/
                                 log.info("条带保存失败!");
                             }
@@ -992,7 +977,7 @@ public class StripService extends ServiceImpl<StripMapper, StripInfo> {
                 }
             }
         }
-       /* stripCalcResultService.saveBatch(stripCalcResults);*/
+        /* stripCalcResultService.saveBatch(stripCalcResults);*/
     }
 
     /**