瀏覽代碼

Merge branch 'master' of https://lekoxnfx.com:4000/tomcat/smart-port-platform

huangchunxi 3 月之前
父節點
當前提交
6e1ab94d13

+ 6 - 0
pom.xml

@@ -74,6 +74,12 @@
             <version>1.0-SNAPSHOT</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.cwp</groupId>
+            <artifactId>IOService</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+
     </dependencies>
 
 

+ 84 - 18
src/main/java/com/ecnu/platform/cwp/CwpDataService.groovy

@@ -1,6 +1,7 @@
 package com.ecnu.platform.cwp
 
-import com.ecnu.alg.pojo.port.data.AlgCwpImportData
+import com.ecnu.alg.pojo.port.datas.AlgCwpInputData
+import com.ecnu.alg.pojo.port.inputs.AlgBollard
 import com.ecnu.alg.pojo.port.inputs.AlgCraneBase
 import com.ecnu.alg.pojo.port.inputs.AlgCranePool
 import com.ecnu.alg.pojo.port.inputs.AlgStowDetail
@@ -40,13 +41,22 @@ class CwpDataService {
     public static final String AlgCwpBlockKey = "port:AlgCwpBlock:"
     public static final String AlgCwpParameterKey = "port:AlgCwpParameter:"
 
+    public static final String AlgBollardKey = "port:AlgBollard:"
+
     @Autowired
     private RedisUtil redisUtil;
 
     @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "导入CWP算法数据")
-    @Doc4MethodRes(key = "result", desc = "底图信息", refClasses = AlgCwpImportData.class)
-    AlgCwpImportData importData(Map<String, Object> map) throws Exception {
-        AlgCwpImportData algCwpImportData = new AlgCwpImportData();
+    @Doc4MethodRes(key = "result", desc = "底图信息", refClasses = AlgCwpInputData.class)
+    AlgCwpInputData importData(Map<String, Object> map) throws Exception {
+        AlgCwpInputData algCwpInputData = new AlgCwpInputData();
+        List<AlgBollard> algBollardList = redisUtil.getByPrefix(AlgBollardKey + "*") as List<AlgBollard>
+        Collections.sort(algBollardList, new Comparator<AlgBollard>() {
+            @Override
+            public int compare(AlgBollard o1, AlgBollard o2) {
+                return o1.getLocation().compareTo(o2.getLocation());
+            }
+        });
         // 解析船舶航次信息
         String vesselVisitId = null;
         SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy hh:mm:ss a", Locale.ENGLISH);
@@ -55,14 +65,30 @@ class CwpDataService {
             AlgVesselVisit algVesselVisit = new AlgVesselVisit()
             algVesselVisit.setVesselVisitId(smartScheduleIdInfo.get("berthId") as String)
             algVesselVisit.setVesselCode(smartScheduleIdInfo.get("vesselCode") as String)
+            algVesselVisit.setVesselName(smartScheduleIdInfo.get("vesselCode") as String)
             algVesselVisit.setVesselType(smartScheduleIdInfo.get("vesselType") as String)
             algVesselVisit.setPlanStartWorkTime(sdf.parse(smartScheduleIdInfo.get("planBeginWorkTime") as String))
             algVesselVisit.setPlanEndWorkTime(sdf.parse(smartScheduleIdInfo.get("planEndWorkTime") as String))
             algVesselVisit.setStartPst(smartScheduleIdInfo.get("planStartPst") as Double)
             algVesselVisit.setEndPst(smartScheduleIdInfo.get("planEndPst") as Double)
+            // 根据船舶停靠位置,找到缆桩编号
+            for (int i = 0; i < algBollardList.size(); i++) {
+                AlgBollard algBollard = algBollardList.get(i)
+                if (algVesselVisit.getStartPst() < algBollard.getLocation()) {
+                    algVesselVisit.setStartBollardId(algBollard.getId())
+                    break;
+                }
+            }
+            for (int i = 0; i < algBollardList.size(); i++) {
+                AlgBollard algBollard = algBollardList.get(i)
+                if (algVesselVisit.getEndPst() < algBollard.getLocation()) {
+                    algVesselVisit.setEndBollardId(algBollard.getId())
+                    break;
+                }
+            }
             algVesselVisit.setBerthDirection(smartScheduleIdInfo.get("planBerthDirect") as String)
             redisUtil.set(AlgVesselVisitKey + algVesselVisit.getVesselVisitId(), algVesselVisit)
-            algCwpImportData.getAlgVesselVisitList().add(algVesselVisit)
+            algCwpInputData.getAlgVesselVisitList().add(algVesselVisit)
             vesselVisitId = algVesselVisit.getVesselVisitId();
         }
         // 解析桥机信息
@@ -81,7 +107,7 @@ class CwpDataService {
             algCraneBase.setDschMph(smartCraneBaseInfo.get("unLoadEfficiency40") as Integer)
             algCraneBase.setTandemFlag(smartCraneBaseInfo.get("tandemFlag") as String)
             redisUtil.set(AlgCraneBaseKey + algCraneBase.getCraneId(), algCraneBase)
-            algCwpImportData.getAlgCraneBaseList().add(algCraneBase)
+            algCwpInputData.getAlgCraneBaseList().add(algCraneBase)
         }
         // 解析作业工艺设置信息
         List<Map> smartCraneWorkFlowInfoList = map.get("smartCraneWorkFlowInfoList") as List<Map>
@@ -95,7 +121,7 @@ class CwpDataService {
             algWorkFlow.setTandem(smartCraneWorkFlowInfo.get("tandem") == true ? "Y" : "N")
             algWorkFlow.setLdStrategy(smartCraneWorkFlowInfo.get("ldStrategy") as String)
             redisUtil.set(AlgWorkFlowKey + algWorkFlow.getVesselVisitId() + ":" + algWorkFlow.getHatchGkey(), algWorkFlow)
-            algCwpImportData.getAlgWorkFlowList().add(algWorkFlow)
+            algCwpInputData.getAlgWorkFlowList().add(algWorkFlow)
         }
         // 船舶结构相关
         // 解析舱位信息
@@ -113,7 +139,7 @@ class CwpDataService {
             algVstHatch.setType("H")
             algVstHatch.setGapM(1.0)
             algVstHatchMap.put(algVstHatch.getGkey(), algVstHatch)
-            algCwpImportData.getAlgVstHatchList().add(algVstHatch)
+            algCwpInputData.getAlgVstHatchList().add(algVstHatch)
         }
         // 解析倍位信息
         Map<String, AlgVstBay> algVstBayMap = new HashMap<>()
@@ -130,7 +156,7 @@ class CwpDataService {
             if (algVstHatch != null) {
                 algVstHatch.getBayNos().add(algVstBay.getNo())
                 algVstHatch.getBayInfos().add(algVstBay)
-                algCwpImportData.getAlgVstBayList().add(algVstBay)
+                algCwpInputData.getAlgVstBayList().add(algVstBay)
             }
         }
         // 解析排信息
@@ -209,10 +235,10 @@ class CwpDataService {
             }
         }
         // 存入缓存
-        for (AlgVstBay algVstBay : algCwpImportData.getAlgVstBayList()) {
+        for (AlgVstBay algVstBay : algCwpInputData.getAlgVstBayList()) {
             redisUtil.set(AlgVstBayKey + algVstBay.getVesselStructGkey() + ":" + algVstBay.getGkey(), algVstBay)
         }
-        for (AlgVstHatch algVstHatch : algCwpImportData.getAlgVstHatchList()) {
+        for (AlgVstHatch algVstHatch : algCwpInputData.getAlgVstHatchList()) {
             List<AlgVstBay> bayInfos = new ArrayList<>()
             for (AlgVstBay algVstBay : algVstHatch.getBayInfos()) {
                 AlgVstBay algVstBay1 = new AlgVstBay()
@@ -225,6 +251,7 @@ class CwpDataService {
                 algVstBay1.setRowNos(algVstBay.getRowNos())
                 bayInfos.add(algVstBay1)
             }
+            algVstHatch.setBayInfos(bayInfos)
             redisUtil.set(AlgVstHatchKey + algVstHatch.getVesselStructGkey() + ":" + algVstHatch.getGkey(), algVstHatch)
         }
         // 解析舱盖板信息
@@ -233,8 +260,6 @@ class CwpDataService {
             AlgVstHatchCover algVstHatchCover = new AlgVstHatchCover()
             algVstHatchCover.setGkey(smartVpsVslHatchcoversInfo.get("hatchCoverId") as String)
             algVstHatchCover.setVesselStructGkey(smartVpsVslHatchcoversInfo.get("vesselCode") as String)
-            algVstHatchCover.setHatchCoverId(smartVpsVslHatchcoversInfo.get("hatchCoverId") as String)
-            algVstHatchCover.setHatchCoverNo(smartVpsVslHatchcoversInfo.get("hatchCoverNo") as String)
             algVstHatchCover.setOpenSeq(smartVpsVslHatchcoversInfo.get("openSeq") as Integer)
             // 查询倍位信息
             Set<String> bayNos = new HashSet<>()
@@ -254,7 +279,7 @@ class CwpDataService {
             algVstHatchCover.setDeckToRowNo(smartVpsVslHatchcoversInfo.get("deckToRowNo") as String)
             algVstHatchCover.setWeightMt(smartVpsVslHatchcoversInfo.get("weight") as Double)
             redisUtil.set(AlgVstHatchCoverKey + algVstHatchCover.getVesselStructGkey() + ":" + algVstHatchCover.getGkey(), algVstHatchCover)
-            algCwpImportData.getAlgVstHatchCoverList().add(algVstHatchCover)
+            algCwpInputData.getAlgVstHatchCoverList().add(algVstHatchCover)
         }
         // 解析桥机池信息
         String poolId = null
@@ -272,11 +297,11 @@ class CwpDataService {
                     AlgCranePool algCranePool = new AlgCranePool()
                     algCranePool.setVesselVisitId(vesselVisitId)
                     algCranePool.setCraneId(smartCranePoolInfo.get("craneNo") as String)
-                    algCwpImportData.getAlgCranePoolList().add(algCranePool)
+                    algCwpInputData.getAlgCranePoolList().add(algCranePool)
                 }
             }
         }
-        redisUtil.set(AlgCranePoolKey + vesselVisitId, algCwpImportData.getAlgCranePoolList())
+        redisUtil.set(AlgCranePoolKey + vesselVisitId, algCwpInputData.getAlgCranePoolList())
         // 解析预配/积载信息
         Map<String, List<AlgStowDetail>> algStowDetailListMap = new HashMap<>()
         List<Map> smartVesselContainerInfoList = map.get("smartVesselContainerInfoList") as List<Map>
@@ -351,7 +376,7 @@ class CwpDataService {
                 algStowDetail.setUgIsHazardous(0)
             }
             algStowDetail.setTotalWeightKg(smartVesselContainerInfo.get("weight") as Double)
-            algCwpImportData.getAlgStowDetailList().add(algStowDetail)
+            algCwpInputData.getAlgStowDetailList().add(algStowDetail)
             algStowDetailListMap.putIfAbsent(algStowDetail.getVesselVisitId(), new ArrayList<AlgStowDetail>())
             algStowDetailListMap.get(algStowDetail.getVesselVisitId()).add(algStowDetail)
         }
@@ -360,6 +385,47 @@ class CwpDataService {
         }
         // 解析属性组信息
 
-        return algCwpImportData
+        return algCwpInputData
+    }
+
+    @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "查询CWP输入数据")
+    AlgCwpInputData queryAll(@BizRequestPm(key = "id", nullable = false, desc = "船舶航次主键,多个用英文逗号隔开") String id) throws Exception {
+        AlgCwpInputData algCwpInputData = new AlgCwpInputData();
+        // 查询船期信息
+        String[] ids = id.split(",");
+        for (String vesselVisitId : ids) {
+            AlgVesselVisit algVesselVisit = redisUtil.get(AlgVesselVisitKey + vesselVisitId) as AlgVesselVisit
+            algCwpInputData.getAlgVesselVisitList().add(algVesselVisit)
+        }
+        // 查询桥机信息
+        List<AlgCraneBase> algCraneBaseList = redisUtil.getByPrefix(AlgCraneBaseKey + "*") as List<AlgCraneBase>
+        algCwpInputData.setAlgCraneBaseList(algCraneBaseList)
+        // 查询作业桥机信息
+        for (String vesselVisitId : ids) {
+            List<AlgCranePool> algCranePoolList = redisUtil.get(AlgCranePoolKey + vesselVisitId) as List<AlgCranePool>
+            algCwpInputData.getAlgCranePoolList().addAll(algCranePoolList)
+        }
+        // 查询预配、积载信息
+        for (String vesselVisitId : ids) {
+            List<AlgStowDetail> algStowDetailList = redisUtil.get(AlgStowDetailKey + vesselVisitId) as List<AlgStowDetail>
+            algCwpInputData.getAlgStowDetailList().addAll(algStowDetailList)
+        }
+        // 查询船舶结构
+        // 查询倍位
+        for (AlgVesselVisit algVesselVisit : algCwpInputData.getAlgVesselVisitList()) {
+            List<AlgVstBay> algVstBayList = redisUtil.getByPrefix(AlgVstBayKey + algVesselVisit.getVesselCode() + ":*") as List<AlgVstBay>
+            algCwpInputData.getAlgVstBayList().addAll(algVstBayList)
+        }
+        // 查询舱位
+        for (AlgVesselVisit algVesselVisit : algCwpInputData.getAlgVesselVisitList()) {
+            List<AlgVstHatch> algVstHatchList = redisUtil.getByPrefix(AlgVstHatchKey + algVesselVisit.getVesselCode() + ":*") as List<AlgVstHatch>
+            algCwpInputData.getAlgVstHatchList().addAll(algVstHatchList)
+        }
+        // 查询舱盖板
+        for (AlgVesselVisit algVesselVisit : algCwpInputData.getAlgVesselVisitList()) {
+            List<AlgVstHatchCover> algVstHatchCoverList = redisUtil.getByPrefix(AlgVstHatchCoverKey + algVesselVisit.getVesselCode() + ":*") as List<AlgVstHatchCover>
+            algCwpInputData.getAlgVstHatchCoverList().addAll(algVstHatchCoverList)
+        }
+        return algCwpInputData
     }
 }

+ 22 - 0
src/main/java/com/ecnu/platform/cwp/CwpService.groovy

@@ -0,0 +1,22 @@
+package com.ecnu.platform.cwp
+
+import com.cwp.ioservice.impl.CwpDoServiceImpl
+import com.ecnu.alg.pojo.port.datas.AlgCwpInputData
+import com.ecnu.alg.pojo.port.datas.AlgCwpResultData
+import com.ecnu.alg.pojo.port.results.AlgReMessage
+import com.three.data_api.dm.annos.BizApiMethod
+import com.three.data_api.dm.annos.BizRequestPm
+import com.three.data_api.dm.constants.ThreeConstant
+
+class CwpService {
+
+    @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "执行CWP算法")
+    AlgCwpResultData doPlanCwp(@BizRequestPm(key = "body", nullable = false, desc = "CWP算法输入数据") AlgCwpInputData algCwpInputData) {
+        AlgCwpResultData algCwpResultData = new AlgCwpResultData()
+        CwpDoServiceImpl cwpDoService = new CwpDoServiceImpl();
+        cwpDoService.doPlanCwp(algCwpInputData, algCwpResultData)
+        AlgReMessage algReMessage = algCwpResultData.getAlgReMessage()
+        algReMessage.setVersion("22222")
+        return algCwpResultData
+    }
+}

+ 25 - 0
src/main/java/com/ecnu/platform/port/BollardService.groovy

@@ -1,6 +1,9 @@
 package com.ecnu.platform.port
 
 import com.ecnu.alg.pojo.port.inputs.AlgBollard
+import com.three.common.exception.ParamException
+import com.three.common.utils.IdWorker
+import com.three.common.utils.StringUtil
 import com.three.common.vo.PageResult
 import com.three.data_api.dm.annos.BizApiMethod
 import com.three.data_api.dm.annos.Doc4MethodRes
@@ -9,6 +12,7 @@ import com.three.data_api.dm.entity.AuqResult
 import com.three.redis.utils.RedisUtil
 import org.springframework.beans.factory.annotation.Autowired
 
+
 class BollardService {
 
     public static final String AlgBollardKey = "port:AlgBollard:"
@@ -26,4 +30,25 @@ class BollardService {
         auqResult.setResult(pageResult)
         return auqResult
     }
+
+    @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "新增缆桩信息")
+    void create(Map<String, Object> map) throws Exception {
+        // 先删除缆桩
+        redisUtil.del(redisUtil.getKeyByPrefix(AlgBollardKey + "*"))
+        for (int i = 1; i <= 40; i++) {
+            AlgBollard algBollard = new AlgBollard()
+            algBollard.setGkey(IdWorker.generateIdStr())
+            algBollard.setId(String.format("%02d", i) + "#")
+            algBollard.setLocation(50 + (i - 1) * 50)
+            redisUtil.set(AlgBollardKey + algBollard.getGkey(), algBollard)
+        }
+    }
+
+    @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "删除缆桩信息")
+    void delete(Map<String, Object> map) throws Exception {
+        if (StringUtil.isBlankStr(map.get("gkey"))) {
+            throw new ParamException("主键(gkey)不可以为空")
+        }
+        redisUtil.del(AlgBollardKey + map.get("gkey"))
+    }
 }

File diff suppressed because it is too large
+ 49 - 0
src/main/java/com/ecnu/platform/port/CraneResourcePlanService.groovy


File diff suppressed because it is too large
+ 52 - 0
src/main/java/com/ecnu/platform/port/CwpBlockVoService.groovy


+ 13 - 0
src/main/java/com/ecnu/platform/port/ShorelineService.groovy

@@ -1,6 +1,7 @@
 package com.ecnu.platform.port
 
 import com.ecnu.alg.pojo.port.inputs.AlgShoreline
+import com.three.common.utils.IdWorker
 import com.three.common.vo.PageResult
 import com.three.data_api.dm.annos.BizApiMethod
 import com.three.data_api.dm.annos.Doc4MethodRes
@@ -26,4 +27,16 @@ class ShorelineService {
         auqResult.setResult(pageResult)
         return auqResult
     }
+
+    @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "新增岸线信息")
+    void create(Map<String, Object> map) throws Exception {
+        // 先删除岸线
+        redisUtil.del(redisUtil.getKeyByPrefix(AlgShorelineKey + "*"))
+        AlgShoreline algShoreline = new AlgShoreline()
+        algShoreline.setGkey(IdWorker.generateIdStr())
+        algShoreline.setId("test")
+        algShoreline.setTmlId("test")
+        algShoreline.setLength(2000)
+        redisUtil.set(AlgShorelineKey + algShoreline.getGkey(), algShoreline)
+    }
 }

+ 15 - 0
src/main/java/com/ecnu/platform/port/TmlTaskSummaryService.groovy

@@ -0,0 +1,15 @@
+package com.ecnu.platform.port
+
+import com.three.common.vo.SelectOption
+import com.three.data_api.service.impl.BaseEntityServiceImpl
+
+class TmlTaskSummaryService extends BaseEntityServiceImpl{
+
+    @Override
+    List<SelectOption> getSelectOptions(Map<String, Object> map) throws Exception {
+        List<SelectOption> selectOptions = new ArrayList<>();
+        selectOptions.add(new SelectOption("洋山", "y4"));
+        selectOptions.add(new SelectOption("潍坊港", "wfg"));
+        return selectOptions
+    }
+}

File diff suppressed because it is too large
+ 46 - 0
src/main/java/com/ecnu/platform/port/TmlVesselVisitVoService.groovy


+ 100 - 0
src/main/java/com/ecnu/platform/port/VesselStructService.groovy

@@ -0,0 +1,100 @@
+package com.ecnu.platform.port
+
+import com.ecnu.alg.pojo.port.inputs.AlgVstBay
+import com.ecnu.alg.pojo.port.inputs.AlgVstHatch
+import com.ecnu.alg.pojo.port.inputs.AlgVstRow
+import com.three.data_api.dm.annos.BizApiMethod
+import com.three.data_api.dm.annos.BizRequestPm
+import com.three.data_api.dm.annos.Doc4MethodRes
+import com.three.data_api.dm.constants.ThreeConstant
+import com.three.redis.utils.RedisUtil
+import org.springframework.beans.factory.annotation.Autowired
+
+class VesselStructService {
+
+
+    public static final String AlgVstHatchKey = "port:AlgVstHatch:"
+    public static final String AlgVstBayKey = "port:AlgVstBay:"
+    public static final String AlgVstHatchCoverKey = "port:AlgVstHatchCover:"
+
+    @Autowired
+    private RedisUtil redisUtil;
+
+    @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "查询所有舱位信息,根据船舶结构主键查询")
+    @Doc4MethodRes(key = "result", desc = "舱位信息", refClasses = AlgVstHatch.class)
+    List<AlgVstHatch> selectHatchInfoList(@BizRequestPm(key = "body.vesselStructGkey", nullable = false, desc = "船舶结构主键") String vesselStructGkey) throws Exception {
+        // 查询舱位信息
+        List<AlgVstHatch> algVstHatchList = redisUtil.getByPrefix(AlgVstHatchKey + vesselStructGkey + ":*") as List<AlgVstHatch>
+        // 舱位排序
+        algVstHatchList.sort(new Comparator<AlgVstHatch>() {
+            @Override
+            int compare(AlgVstHatch o1, AlgVstHatch o2) {
+                return ((Double) o1.getStartPosM()).compareTo((Double) o2.getStartPosM());
+            }
+        });
+        // 倍位号排序
+        for (AlgVstHatch hatchInfo : algVstHatchList) {
+            List<String> bayNoList = new ArrayList<>(hatchInfo.getBayNos())
+            Collections.sort(bayNoList);
+            hatchInfo.setBayNos(bayNoList as Set<String>);
+            // 倍位信息排序
+            for (AlgVstBay bayInfo : hatchInfo.getBayInfos()) {
+                // 层号排序
+                List<String> tierNoList = new ArrayList<>(bayInfo.getTierNos())
+                Collections.sort(tierNoList);
+                bayInfo.setTierNos(new HashSet<String>(tierNoList));
+            }
+        }
+        return algVstHatchList
+    }
+
+    @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "查询舱位所有倍位信息,根据船舶结构主键、舱位主键查询")
+    @Doc4MethodRes(key = "result", desc = "倍位信息", refClasses = AlgVstBay.class)
+    List<AlgVstBay> selectBayInfoList(@BizRequestPm(key = "body.vesselStructGkey", nullable = false, desc = "船舶结构主键") String vesselStructGkey,
+                                      @BizRequestPm(key = "body.hatchGkey", nullable = false, desc = "舱位主键,多个用英文逗号隔开") String hatchGkey) throws Exception {
+        String[] hatchGkeys = hatchGkey.split(",")
+        // 查询舱位信息
+        Set<String> keys = new HashSet<>()
+        for (String hatchGkeyTmp : hatchGkeys) {
+            keys.add(AlgVstHatchKey + vesselStructGkey + ":" + hatchGkeyTmp)
+        }
+        List<AlgVstHatch> algVstHatchList = redisUtil.getMulti(keys) as List<AlgVstHatch>
+        // 查询倍位信息
+        Set<String> bayKeys = new HashSet<>()
+        for (AlgVstHatch algVstHatch : algVstHatchList) {
+            for (AlgVstBay bayInfo : algVstHatch.getBayInfos()) {
+                bayKeys.add(AlgVstBayKey + vesselStructGkey + ":" + bayInfo.getGkey())
+            }
+        }
+        List<AlgVstBay> algVstBayList = redisUtil.getMulti(bayKeys) as List<AlgVstBay>
+        // 倍位信息排序
+        for (AlgVstBay bayInfo : algVstBayList) {
+            // 层号排序
+            List<String> tierNoList = new ArrayList<>(bayInfo.getTierNos())
+            Collections.sort(tierNoList);
+            bayInfo.setTierNos(new LinkedHashSet<>(tierNoList));
+            // 排信息排序
+            List<AlgVstRow> rowInfoList = bayInfo.getRows()
+            rowInfoList.sort(new Comparator<AlgVstRow>() {
+                @Override
+                int compare(AlgVstRow o1, AlgVstRow o2) {
+                    return ((Integer) o1.getSeq()).compareTo((Integer) o2.getSeq())
+                }
+            })
+            // 排号顺序
+            Set<String> rowNos = new LinkedHashSet<>();
+            for (AlgVstRow rowInfo : rowInfoList) {
+                rowNos.add(rowInfo.getNo())
+            }
+            bayInfo.setRowNos(rowNos)
+        }
+        // 倍信息排序
+        algVstBayList.sort(new Comparator<AlgVstBay>() {
+            @Override
+            int compare(AlgVstBay o1, AlgVstBay o2) {
+                return o1.getNo().compareTo(o2.getNo())
+            }
+        })
+        return algVstBayList
+    }
+}

+ 31 - 0
src/main/java/com/ecnu/platform/port/VesselViewService.groovy

@@ -0,0 +1,31 @@
+package com.ecnu.platform.port
+
+import com.three.data_api.dm.annos.BizApiMethod
+import com.three.data_api.dm.annos.BizRequestPm
+import com.three.data_api.dm.constants.ThreeConstant
+
+class VesselViewService {
+
+    @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "获取船舶的侧视图")
+    Map getVesselZoneViews(@BizRequestPm(key = "body.viewTenses", nullable = false, desc = "视图时态") List<String> viewTenses,
+                           @BizRequestPm(key = "body.zone", nullable = false, desc = "载具访问编号") String zone,
+                           @BizRequestPm(key = "body.cvLevel", nullable = false, desc = "载具访问等级") String cvLevel,
+                           @BizRequestPm(key = "body.hbrCvGkey") String hbrCvGkey,
+                           @BizRequestPm(key = "body.tmlCvGkey") String tmlCvGkey) throws Exception {
+        Map<String, Object> result = new HashMap<>()
+
+        return result
+    }
+
+    @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "获取船舶的贝位视图")
+    Map getVesselBaysViews(@BizRequestPm(key = "body.viewTenses", nullable = false, desc = "视图时态") List<String> viewTenses,
+                           @BizRequestPm(key = "body.zone", nullable = false, desc = "载具访问编号") String zone,
+                           @BizRequestPm(key = "body.sBayNos", nullable = false, desc = "贝位号列表(小贝位)") List<String> sBayNos,
+                           @BizRequestPm(key = "body.cvLevel", nullable = false, desc = "载具访问等级") String cvLevel,
+                           @BizRequestPm(key = "body.hbrCvGkey") String hbrCvGkey,
+                           @BizRequestPm(key = "body.tmlCvGkey") String tmlCvGkey) throws Exception {
+        Map<String, Object> result = new HashMap<>()
+
+        return result
+    }
+}

File diff suppressed because it is too large
+ 53 - 0
src/main/java/com/ecnu/platform/port/VstHatchCoverService.groovy


+ 76 - 35
src/main/java/com/ecnu/platform/service/AlgExecutionService.groovy

@@ -1,14 +1,20 @@
 package com.ecnu.platform.service
 
 import com.ecnu.alg.pojo.path.data.AlgPathStrategyInputData
-import com.ecnu.alg.pojo.path.data.AlgPathStrategyOutputData
-import com.ecnu.alg.pojo.path.inputs.AlgVehicleTask
-import com.ecnu.alg.pojo.path.results.AlgRePathResult
+import com.ecnu.alg.pojo.path.data.AlgPathStrategyResultData
+import com.ecnu.alg.pojo.path.results.AlgReMessage
+import com.ecnu.alg.pojo.port.datas.AlgCwpInputData
+import com.ecnu.alg.pojo.port.datas.AlgCwpResultData
+import com.ecnu.alg.pojo.port.results.AlgReCwp
+import com.ecnu.alg.pojo.port.results.AlgReCwpBlock
+import com.ecnu.platform.cwp.CwpDataService
+import com.ecnu.platform.path.PathStrategyDataService
 import com.three.common.constants.RedisKeyPrefix
 import com.three.common.exception.ParamException
 import com.three.common.utils.GroovyUtil
 import com.three.common.utils.GsonUtil
 import com.three.common.utils.StringUtil
+import com.three.common.vo.ResponseData
 import com.three.data_api.dm.annos.BizApiMethod
 import com.three.data_api.dm.annos.BizRequestPm
 import com.three.data_api.dm.constants.ThreeConstant
@@ -26,10 +32,11 @@ import org.springframework.http.HttpMethod
 import org.springframework.http.ResponseEntity
 import org.springframework.web.client.RestTemplate
 
-import java.lang.reflect.Method
 
 class AlgExecutionService {
 
+    public static final String AlgReCwpBlockKey = "port:AlgReCwpBlock:"
+
     private static Logger logger = LoggerFactory.getLogger(AlgExecutionService.class)
 
     @Autowired
@@ -41,11 +48,11 @@ class AlgExecutionService {
     @Autowired
     private BeanService beanService;
 
-    @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "执行路线规划算法")
-    void exePathStrategy(@BizRequestPm(key = "mapId", nullable = false, desc = "底图ID") String mapId,
-                         @BizRequestPm(key = "versionGkey", nullable = false, desc = "算法版本主键") String versionGkey) {
+    @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "执行算法")
+    void exeAlg(@BizRequestPm(key = "id", nullable = false, desc = "底图ID/船舶航次主键(多个用英文逗号隔开)") String id,
+                @BizRequestPm(key = "versionGkey", nullable = false, desc = "算法版本主键") String versionGkey) {
         // 查询算法版本信息
-        Object algVersionObj = daoService.findOneByGkey(AlgVersionVoService.EN_AlgVersion, versionGkey)
+        Object algVersionObj = daoService.findOneByGkey(AlgVersionVoService.EN_AlgVersionVo, versionGkey)
         if (algVersionObj == null) {
             throw new ParamException("算法版本不存在")
         }
@@ -62,53 +69,87 @@ class AlgExecutionService {
         if (StringUtil.isBlank(interfaceName)) {
             throw new ParamException("算法版本接口名称为空")
         }
-        // 根据底图ID,查询路线规划算法需要的数据
-        Object pathStrategyDataService = beanService.getBeanById("PathStrategyDataService");
-        Method method = pathStrategyDataService.getClass().getMethod("queryAll", String.class)
-        AlgPathStrategyInputData algPathStrategyInputData = method.invoke(pathStrategyDataService, mapId) as AlgPathStrategyInputData
-        String inDataStr = GsonUtil.toJson(algPathStrategyInputData)
-        // 调用算法接口
+        // 算法调用记录
         Map<String, Object> valueMap = new HashMap<>()
         valueMap.put("versionGkey", versionGkey)
-        valueMap.put("shipId", mapId)
+        valueMap.put("shipId", id)
         valueMap.put("runVersion", GroovyUtil.getProperty(algVersionObj, "version"))
         long st = System.currentTimeMillis()
         try {
-            logger.info("路线规划算法开始执行。。。")
-            HttpHeaders headers = new HttpHeaders()
+            logger.info("算法[{}:{}]执行开始。。。", GroovyUtil.getProperty(algVersionObj, "algDefId"), GroovyUtil.getProperty(algVersionObj, "version"))
             // 获取账号token
+            HttpHeaders headers = new HttpHeaders()
             String reToken = (String) redisUtil.get(RedisKeyPrefix.AUTH_KEY_PREFIX_USER_TOKEN + LoginUserUtil.getLoginUsername() + RedisKeyPrefix.tokenKeyCon + "web");
             headers.add("Authorization", "Bearer " + reToken)
-            HttpEntity<AlgPathStrategyInputData> request = new HttpEntity<>(algPathStrategyInputData, headers)
-            RestTemplate restTemplate = new RestTemplate();
-            ResponseEntity<AlgPathStrategyOutputData> result = restTemplate.exchange(serviceAddress + "/" + interfaceName, HttpMethod.POST, request, AlgPathStrategyOutputData.class)
-            AlgPathStrategyOutputData algPathStrategyOutputData = result.getBody()
-            String outDataStr = GsonUtil.toJson(algPathStrategyOutputData);
-            valueMap.put("outData", outDataStr)
-            logger.info("路线规划算法返回结果:{}", outDataStr)
-            // 记录算法日志
-            if (algPathStrategyOutputData.getAlgReMessage() != null) {
-                valueMap.put("exeLog", algPathStrategyOutputData.getAlgReMessage().getExeLog())
-                valueMap.put("errorLog", algPathStrategyOutputData.getAlgReMessage().getErrorLog())
+            // restTemplate
+            RestTemplate restTemplate = new RestTemplate()
+            if ("PathStrategy".equals(GroovyUtil.getProperty(algVersionObj, "algDefId"))) {
+                // 根据ID,查询算法输入数据
+                PathStrategyDataService pathStrategyDataService = beanService.getBeanById(PathStrategyDataService.class.getSimpleName());
+                AlgPathStrategyInputData algPathStrategyInputData = pathStrategyDataService.queryAll(id)
+                String inDataStr = GsonUtil.toJson(algPathStrategyInputData)
+                valueMap.put("inData", inDataStr)
+                HttpEntity<AlgPathStrategyInputData> request = new HttpEntity<>(algPathStrategyInputData, headers)
+                // 调用算法
+                ResponseEntity<AlgPathStrategyResultData> result = restTemplate.exchange(serviceAddress + "/" + interfaceName, HttpMethod.POST, request, AlgPathStrategyResultData.class)
+                // 算法输出数据
+                AlgPathStrategyResultData algPathStrategyOutputData = result.getBody()
+                String outDataStr = GsonUtil.toJson(algPathStrategyOutputData);
+                valueMap.put("outData", outDataStr)
+                AlgReMessage algReMessage = algPathStrategyOutputData.getAlgReMessage()
+                // 记录算法日志
+                if (algReMessage != null) {
+                    valueMap.put("exeLog", algReMessage.getExeLog())
+                    valueMap.put("errorLog", algReMessage.getErrorLog())
+                }
+            } else if ("Cwp".equals(GroovyUtil.getProperty(algVersionObj, "algDefId"))) {
+                // 根据ID,查询算法输入数据
+                CwpDataService cwpDataService = beanService.getBeanById(CwpDataService.class.getSimpleName());
+                AlgCwpInputData algCwpInputData = cwpDataService.queryAll(id)
+                String inDataStr = GsonUtil.toJson(algCwpInputData)
+                valueMap.put("inData", inDataStr)
+                HttpEntity<AlgCwpInputData> request = new HttpEntity<>(algCwpInputData, headers)
+                // 调用算法
+                ResponseEntity<ResponseData> result = restTemplate.exchange(serviceAddress + "/" + interfaceName, HttpMethod.POST, request, ResponseData.class)
+                ResponseData responseData = result.getBody()
+                // 算法输出数据
+                String outDataStr = GsonUtil.toJson(responseData.getResult());
+                AlgCwpResultData algCwpResultData = GsonUtil.fromJsonObject(outDataStr, AlgCwpResultData.class)
+                // 将算法结果保存到缓存中
+                saveCwpResult(algCwpResultData)
+                valueMap.put("outData", outDataStr)
+                com.ecnu.alg.pojo.port.results.AlgReMessage algReMessage = algCwpResultData.getAlgReMessage()
+                // 记录算法日志
+                if (algReMessage != null) {
+                    valueMap.put("exeLog", algReMessage.getExecuteLog())
+                    valueMap.put("errorLog", algReMessage.getErrorLog())
+                }
+            } else if ("AutoStow".equals(GroovyUtil.getProperty(algVersionObj, "algDefId"))) {
+
             }
             valueMap.put("exeState", "OK")
+            logger.info("算法[{}:{}]执行结束。", GroovyUtil.getProperty(algVersionObj, "algDefId"), GroovyUtil.getProperty(algVersionObj, "version"))
         } catch (Exception e) {
-            logger.info("路线规划算法执行异常:", e)
+            logger.info("算法[{}:{}]执行异常:", GroovyUtil.getProperty(algVersionObj, "algDefId"), GroovyUtil.getProperty(algVersionObj, "version"), e)
             valueMap.put("exeState", "ERROR")
             valueMap.put("errorLog", ExceptionUtils.getStackTrace(e))
         }
         long et = System.currentTimeMillis()
         valueMap.put("costTime", et - st)
         valueMap.put("callSource", "test")
-        valueMap.put("inData", inDataStr)
         // 记录算法执行日志
         daoService.insertMetaEntityDefault(AlgExecutionLogService.EN_AlgExecutionLog, valueMap)
     }
 
-    AlgPathStrategyOutputData doPathStrategy(AlgPathStrategyInputData algPathStrategyInputData) {
-        AlgPathStrategyOutputData algPathStrategyOutputData = new AlgPathStrategyOutputData()
-        algPathStrategyOutputData.setAlgRePathResultList(new ArrayList<AlgRePathResult>())
-
-        return algPathStrategyOutputData
+    void saveCwpResult(AlgCwpResultData algCwpResultData) {
+        for (AlgReCwp algReCwp : algCwpResultData.getAlgReCwpList()) {
+            List<AlgReCwpBlock> algReCwpBlockList = algReCwp.getAlgReCwpBlockList()
+            for (AlgReCwpBlock algReCwpBlock : algReCwpBlockList) {
+                algReCwpBlock.setTmlCvGkey(algReCwp.getVesselVisitId())
+            }
+            redisUtil.set(AlgReCwpBlockKey + algReCwp.getVesselVisitId(), algReCwpBlockList)
+            // 默认取第一个结果
+            break
+        }
     }
 }

Some files were not shown because too many files changed in this diff