|
@@ -0,0 +1,276 @@
|
|
|
+package com.ecnu.platform.cwp
|
|
|
+
|
|
|
+import com.ecnu.alg.pojo.port.data.AlgCwpImportData
|
|
|
+import com.ecnu.alg.pojo.port.inputs.AlgCraneBase
|
|
|
+import com.ecnu.alg.pojo.port.inputs.AlgCranePool
|
|
|
+import com.ecnu.alg.pojo.port.inputs.AlgVesselVisit
|
|
|
+import com.ecnu.alg.pojo.port.inputs.AlgVstBay
|
|
|
+import com.ecnu.alg.pojo.port.inputs.AlgVstHatch
|
|
|
+import com.ecnu.alg.pojo.port.inputs.AlgVstHatchCover
|
|
|
+import com.ecnu.alg.pojo.port.inputs.AlgVstRow
|
|
|
+import com.ecnu.alg.pojo.port.inputs.AlgVstSlot
|
|
|
+import com.ecnu.alg.pojo.port.inputs.AlgWorkFlow
|
|
|
+import com.three.common.exception.ParamException
|
|
|
+import com.three.common.utils.StringUtil
|
|
|
+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
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat
|
|
|
+
|
|
|
+class CwpDataService {
|
|
|
+
|
|
|
+ public static final String AlgVesselVisitKey = "port:AlgVesselVisit:"
|
|
|
+ public static final String AlgCraneBaseKey = "port:AlgCraneBase:"
|
|
|
+ public static final String AlgStowDetailKey = "port:AlgStowDetail:"
|
|
|
+ public static final String AlgAssistEquipmentKey = "port:AlgAssistEquipment:"
|
|
|
+ public static final String AlgHatchCoverWorkKey = "port:AlgHatchCoverWork:"
|
|
|
+ public static final String AlgWorkFlowKey = "port:AlgWorkFlow:"
|
|
|
+ public static final String AlgVstHatchKey = "port:AlgVstHatch:"
|
|
|
+ public static final String AlgVstBayKey = "port:AlgVstBay:"
|
|
|
+ public static final String AlgVstHatchCoverKey = "port:AlgVstHatchCover:"
|
|
|
+ public static final String AlgCranePoolKey = "port:AlgCranePool:"
|
|
|
+ public static final String AlgCraneWorkKey = "port:AlgCraneWork:"
|
|
|
+ public static final String AlgCraneMaintainKey = "port:AlgCraneMaintain:"
|
|
|
+ public static final String AlgCraneMoveRangeKey = "port:AlgCraneMoveRange:"
|
|
|
+ public static final String AlgCwpBlockKey = "port:AlgCwpBlock:"
|
|
|
+ public static final String AlgCwpParameterKey = "port:AlgCwpParameter:"
|
|
|
+
|
|
|
+ @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();
|
|
|
+ // 解析船舶航次信息
|
|
|
+ String vesselVisitId = null;
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy hh:mm:ss a", Locale.ENGLISH);
|
|
|
+ List<Map> smartScheduleIdInfoList = map.get("smartScheduleIdInfoList") as List<Map>
|
|
|
+ for (Map smartScheduleIdInfo : smartScheduleIdInfoList) {
|
|
|
+ AlgVesselVisit algVesselVisit = new AlgVesselVisit()
|
|
|
+ algVesselVisit.setVesselVisitId(smartScheduleIdInfo.get("berthId") as String)
|
|
|
+ algVesselVisit.setVesselCode(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)
|
|
|
+ algVesselVisit.setBerthDirection(smartScheduleIdInfo.get("planBerthDirect") as String)
|
|
|
+ redisUtil.set(AlgVesselVisitKey + algVesselVisit.getVesselVisitId(), algVesselVisit)
|
|
|
+ algCwpImportData.getAlgVesselVisitList().add(algVesselVisit)
|
|
|
+ vesselVisitId = algVesselVisit.getVesselVisitId();
|
|
|
+ }
|
|
|
+ // 解析桥机信息
|
|
|
+ List<Map> smartCraneBaseInfoList = map.get("smartCraneBaseInfoList") as List<Map>
|
|
|
+ for (Map smartCraneBaseInfo : smartCraneBaseInfoList) {
|
|
|
+ AlgCraneBase algCraneBase = new AlgCraneBase()
|
|
|
+ algCraneBase.setCraneId(smartCraneBaseInfo.get("craneNo") as String)
|
|
|
+ algCraneBase.setMoveRangeFrom(smartCraneBaseInfo.get("moveRangeFrom") as Double)
|
|
|
+ algCraneBase.setMoveRangeTo(smartCraneBaseInfo.get("moveRangeTo") as Double)
|
|
|
+ algCraneBase.setCraneSafeSpan(smartCraneBaseInfo.get("craneSafeSpan") as Double)
|
|
|
+ algCraneBase.setCraneSeq(smartCraneBaseInfo.get("craneSeq") as Integer)
|
|
|
+ algCraneBase.setCraneSpeed(smartCraneBaseInfo.get("craneSpeed") as Double)
|
|
|
+ algCraneBase.setCraneWidth(smartCraneBaseInfo.get("craneWidth") as Double)
|
|
|
+ algCraneBase.setMaxCarryWeight(smartCraneBaseInfo.get("craneMaxCarryWeight") as Integer)
|
|
|
+ algCraneBase.setLoadEfficiency(smartCraneBaseInfo.get("loadEfficiency40") as Integer)
|
|
|
+ algCraneBase.setDschEfficiency(smartCraneBaseInfo.get("unLoadEfficiency40") as Integer)
|
|
|
+ algCraneBase.setTandemFlag(smartCraneBaseInfo.get("tandemFlag") as String)
|
|
|
+ redisUtil.set(AlgCraneBaseKey + algCraneBase.getCraneId(), algCraneBase)
|
|
|
+ algCwpImportData.getAlgCraneBaseList().add(algCraneBase)
|
|
|
+ }
|
|
|
+ // 解析预配/积载信息
|
|
|
+ // 解析属性组信息
|
|
|
+
|
|
|
+ // 解析作业工艺设置信息
|
|
|
+ List<Map> smartCraneWorkFlowInfoList = map.get("smartCraneWorkFlowInfoList") as List<Map>
|
|
|
+ for (Map smartCraneWorkFlowInfo : smartCraneWorkFlowInfoList) {
|
|
|
+ AlgWorkFlow algWorkFlow = new AlgWorkFlow()
|
|
|
+ algWorkFlow.setVesselVisitId(smartCraneWorkFlowInfo.get("berthId") as String)
|
|
|
+ algWorkFlow.setHatchGkey(smartCraneWorkFlowInfo.get("hatchId") as String)
|
|
|
+ algWorkFlow.setHatchNo(smartCraneWorkFlowInfo.get("hatchNo") as String)
|
|
|
+ algWorkFlow.setDeckOrHatch(smartCraneWorkFlowInfo.get("deckOrHatch") as String)
|
|
|
+ algWorkFlow.setTwin(smartCraneWorkFlowInfo.get("twin") == true ? "Y" : "N")
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ // 船舶结构相关
|
|
|
+ // 解析舱位信息
|
|
|
+ Map<String, AlgVstHatch> algVstHatchMap = new HashMap<>()
|
|
|
+ List<Map> smartVpsVslHatchsInfoList = map.get("smartVpsVslHatchsInfoList") as List<Map>
|
|
|
+ for (Map smartVpsVslHatchsInfo : smartVpsVslHatchsInfoList) {
|
|
|
+ AlgVstHatch algVstHatch = new AlgVstHatch()
|
|
|
+ algVstHatch.setGkey(smartVpsVslHatchsInfo.get("hatchId") as String)
|
|
|
+ algVstHatch.setVesselStructGkey(smartVpsVslHatchsInfo.get("vesselCode") as String)
|
|
|
+ algVstHatch.setNo(smartVpsVslHatchsInfo.get("hatchNo") as String)
|
|
|
+ algVstHatch.setSeq(smartVpsVslHatchsInfo.get("hatchSeq") as Integer)
|
|
|
+ algVstHatch.setStartPosM(smartVpsVslHatchsInfo.get("hatchPosition") as Double)
|
|
|
+ algVstHatch.setLengthM(smartVpsVslHatchsInfo.get("hatchLength") as Double)
|
|
|
+ algVstHatch.setWidthM(smartVpsVslHatchsInfo.get("hatchWidth") as Double)
|
|
|
+ algVstHatch.setType("H")
|
|
|
+ algVstHatch.setGapM(1.0)
|
|
|
+ algVstHatchMap.put(algVstHatch.getGkey(), algVstHatch)
|
|
|
+ algCwpImportData.getAlgVstHatchList().add(algVstHatch)
|
|
|
+ }
|
|
|
+ // 解析倍位信息
|
|
|
+ Map<String, AlgVstBay> algVstBayMap = new HashMap<>()
|
|
|
+ List<Map> smartVpsVslBaysInfoList = map.get("smartVpsVslBaysInfoList") as List<Map>
|
|
|
+ for (Map smartVpsVslBaysInfo : smartVpsVslBaysInfoList) {
|
|
|
+ AlgVstBay algVstBay = new AlgVstBay()
|
|
|
+ algVstBay.setGkey(smartVpsVslBaysInfo.get("bayId") as String)
|
|
|
+ algVstBay.setVesselStructGkey(smartVpsVslBaysInfo.get("vesselCode") as String)
|
|
|
+ algVstBay.setHatchGkey(smartVpsVslBaysInfo.get("hatchId") as String)
|
|
|
+ algVstBay.setNo(smartVpsVslBaysInfo.get("bayNo") as String)
|
|
|
+ algVstBay.setDeckOrHatch(smartVpsVslBaysInfo.get("deckOrHatch") as String)
|
|
|
+ algVstBayMap.put(algVstBay.getGkey(), algVstBay)
|
|
|
+ AlgVstHatch algVstHatch = algVstHatchMap.get(algVstBay.getHatchGkey())
|
|
|
+ if (algVstHatch != null) {
|
|
|
+ algVstHatch.getBayNos().add(algVstBay.getNo())
|
|
|
+ algVstHatch.getBayInfos().add(algVstBay)
|
|
|
+ algCwpImportData.getAlgVstBayList().add(algVstBay)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 解析排信息
|
|
|
+ List<Map> smartVpsVslRowsInfoList = map.get("smartVpsVslRowsInfoList") as List<Map>
|
|
|
+ for (Map smartVpsVslRowsInfo : smartVpsVslRowsInfoList) {
|
|
|
+ AlgVstRow algVstRow = new AlgVstRow()
|
|
|
+ algVstRow.setGkey(smartVpsVslRowsInfo.get("bayId") as String + "" + smartVpsVslRowsInfo.get("rowNo") as String)
|
|
|
+ algVstRow.setBayGkey(smartVpsVslRowsInfo.get("bayId") as String)
|
|
|
+ algVstRow.setVesselStructGkey(smartVpsVslRowsInfo.get("vesselCode") as String)
|
|
|
+ algVstRow.setNo(smartVpsVslRowsInfo.get("rowNo") as String)
|
|
|
+ algVstRow.setSeq(smartVpsVslRowsInfo.get("rowSeq") as Integer)
|
|
|
+ algVstRow.setWeightMt(smartVpsVslRowsInfo.get("maxWeight20") as Double)
|
|
|
+ AlgVstBay algVstBay = algVstBayMap.get(algVstRow.getBayGkey())
|
|
|
+ if (algVstBay != null) {
|
|
|
+ algVstBay.getRows().add(algVstRow)
|
|
|
+ algVstBay.getRowNos().add(algVstRow.getNo())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 解析船箱位信息
|
|
|
+ List<Map> smartVpsVslLocationsInfoList = map.get("smartVpsVslLocationsInfoList") as List<Map>
|
|
|
+ for (Map smartVpsVslLocationsInfo : smartVpsVslLocationsInfoList) {
|
|
|
+ AlgVstBay algVstBay = algVstBayMap.get(smartVpsVslLocationsInfo.get("bayId") as String)
|
|
|
+ if (algVstBay != null) {
|
|
|
+ String location = smartVpsVslLocationsInfo.get("location") as String
|
|
|
+ String bayNo = location.substring(0, 2)
|
|
|
+ String rowNo = location.substring(2, 4)
|
|
|
+ String tierNo = location.substring(4, location.length())
|
|
|
+ algVstBay.getTierNos().add(tierNo)
|
|
|
+ AlgVstRow algVstRow = algVstBay.getAlgVstRowByNo(rowNo)
|
|
|
+ if (algVstRow != null) {
|
|
|
+ AlgVstSlot algVstSlot = new AlgVstSlot()
|
|
|
+ algVstSlot.setRowGkey(algVstRow.getGkey())
|
|
|
+ algVstSlot.setVesselStructGkey(smartVpsVslLocationsInfo.get("vesselCode") as String)
|
|
|
+ algVstSlot.setLocation(smartVpsVslLocationsInfo.get("location") as String)
|
|
|
+ AlgVstHatch algVstHatch = algVstHatchMap.get(algVstBay.getHatchGkey())
|
|
|
+ if (algVstHatch != null) {
|
|
|
+ algVstSlot.setHatchNo(algVstHatch.getNo())
|
|
|
+ }
|
|
|
+ algVstSlot.setBayNo(bayNo)
|
|
|
+ algVstSlot.setRowNo(rowNo)
|
|
|
+ algVstSlot.setTierNo(tierNo)
|
|
|
+ String size1 = smartVpsVslLocationsInfo.get("size") as String;
|
|
|
+ String size = "20-40";
|
|
|
+ if ("1".equals(size1)) {
|
|
|
+ size = "20";
|
|
|
+ } else if ("2".equals(size1)) {
|
|
|
+ size = "20-40";
|
|
|
+ } else if ("3".equals(size1)) {
|
|
|
+ size = "20-40";
|
|
|
+ } else if ("4".equals(size1)) {
|
|
|
+ size = "40";
|
|
|
+ } else if ("5".equals(size1)) {
|
|
|
+ size = "40";
|
|
|
+ } else if ("6".equals(size1)) {
|
|
|
+ size = "45";
|
|
|
+ } else if ("7".equals(size1)) {
|
|
|
+ size = "45";
|
|
|
+ } else if ("8".equals(size1)) {
|
|
|
+ size = "20-45";
|
|
|
+ } else if ("9".equals(size1)) {
|
|
|
+ size = "20-45";
|
|
|
+ } else if ("A".equals(size1)) {
|
|
|
+ size = "40-45";
|
|
|
+ } else if ("B".equals(size1)) {
|
|
|
+ size = "40-45";
|
|
|
+ } else if ("C".equals(size1)) {
|
|
|
+ size = "20-40-45";
|
|
|
+ } else if ("D".equals(size1)) {
|
|
|
+ size = "20-40-45";
|
|
|
+ }
|
|
|
+ algVstSlot.setSize(size)
|
|
|
+ algVstSlot.setRfFg(smartVpsVslLocationsInfo.get("rffg") as String)
|
|
|
+ algVstSlot.setHighFg(smartVpsVslLocationsInfo.get("highfg") as String)
|
|
|
+ algVstBay.getSlots().add(algVstSlot)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 存入缓存
|
|
|
+ for (AlgVstBay algVstBay : algCwpImportData.getAlgVstBayList()) {
|
|
|
+ redisUtil.set(AlgVstBayKey + algVstBay.getVesselStructGkey() + ":" + algVstBay.getGkey(), algVstBay)
|
|
|
+ }
|
|
|
+ for (AlgVstHatch algVstHatch : algCwpImportData.getAlgVstHatchList()) {
|
|
|
+ for (AlgVstBay algVstBay : algVstHatch.getBayInfos()) {
|
|
|
+ algVstBay.getRows().clear()
|
|
|
+ algVstBay.getSlots().clear()
|
|
|
+ }
|
|
|
+ redisUtil.set(AlgVstHatchKey + algVstHatch.getVesselStructGkey() + ":" + algVstHatch.getGkey(), algVstHatch)
|
|
|
+ }
|
|
|
+ // 解析舱盖板信息
|
|
|
+ List<Map> smartVpsVslHatchcoversInfoList = map.get("smartVpsVslHatchcoversInfoList") as List<Map>
|
|
|
+ for (Map smartVpsVslHatchcoversInfo : smartVpsVslHatchcoversInfoList) {
|
|
|
+ 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<>()
|
|
|
+ AlgVstBay algVstBay1 = algVstBayMap.get(smartVpsVslHatchcoversInfo.get("bayIdFrom") as String)
|
|
|
+ AlgVstBay algVstBay2 = algVstBayMap.get(smartVpsVslHatchcoversInfo.get("bayIdTo") as String)
|
|
|
+ if (algVstBay1 != null) {
|
|
|
+ bayNos.add(algVstBay1.getNo())
|
|
|
+ }
|
|
|
+ if (algVstBay2 != null) {
|
|
|
+ bayNos.add(algVstBay2.getNo())
|
|
|
+ }
|
|
|
+ algVstHatchCover.setBayNo(String.join(",", bayNos))
|
|
|
+ algVstHatchCover.setHatchFromRowNo(smartVpsVslHatchcoversInfo.get("hatchFromRowNo") as String)
|
|
|
+ algVstHatchCover.setHatchToRowNo(smartVpsVslHatchcoversInfo.get("hatchToRowNo") as String)
|
|
|
+ algVstHatchCover.setDeckFromRowNo(smartVpsVslHatchcoversInfo.get("deckFromRowNo") as String)
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ // 解析桥机池信息
|
|
|
+ String poolId = null
|
|
|
+ List<Map> smartVesselCranePoolInfoList = map.get("smartVesselCranePoolInfoList") as List<Map>
|
|
|
+ for (Map smartVesselCranePoolInfo : smartVesselCranePoolInfoList) {
|
|
|
+ if ((smartVesselCranePoolInfo.get("berthId") as String).equals(vesselVisitId)) {
|
|
|
+ poolId = smartVesselCranePoolInfo.get("poolId") as String
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (poolId != null) {
|
|
|
+ List<Map> smartCranePoolInfoList = map.get("smartCranePoolInfoList") as List<Map>
|
|
|
+ for (Map smartCranePoolInfo : smartCranePoolInfoList) {
|
|
|
+ if (poolId.equals(smartCranePoolInfo.get("poolId") as String)) {
|
|
|
+ AlgCranePool algCranePool = new AlgCranePool()
|
|
|
+ algCranePool.setVesselVisitId(vesselVisitId)
|
|
|
+ algCranePool.setCraneId(smartCranePoolInfo.get("craneNo") as String)
|
|
|
+ algCwpImportData.getAlgCranePoolList().add(algCranePool)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ redisUtil.set(AlgCranePoolKey + vesselVisitId, algCwpImportData.getAlgCranePoolList())
|
|
|
+
|
|
|
+ return algCwpImportData
|
|
|
+ }
|
|
|
+}
|