liyg 3 years ago
parent
commit
6af3263cf7

+ 22 - 0
src/main/java/com/steerinfo/inPlantNavigation/controller/MapVertexController.java

@@ -56,6 +56,7 @@ public class MapVertexController extends BaseRESTfulController {
         return success(mapVertexService.findAllAvailable());
     }
 
+
     @ApiOperation(value="获取最佳路径")
     @GetMapping(value = "/getObtainTheOptimalPath")
     public RESTfulResult getObtainTheOptimalPath(@RequestParam("startPoint") String startPoint,@RequestParam("endPoint")  String endPoint) throws VertexAngEdgeException {
@@ -65,4 +66,25 @@ public class MapVertexController extends BaseRESTfulController {
         Collections.reverse(obtainTheOptimalPath);
         return success(obtainTheOptimalPath);
     }
+
+    @ApiOperation(value="获取订单路径信息")
+    @GetMapping(value = "/findOrderDetails")
+    public RESTfulResult findOrderDetails(@RequestParam("orderId") String orderId) throws VertexAngEdgeException {
+        return success(mapVertexService.findOrderDetails(orderId));
+    }
+
+    @ApiOperation(value="获取当前订单导航路径")
+    @GetMapping(value = "/getPathByOrderID")
+    public RESTfulResult getPathByOrderID(@RequestParam("orderId") String orderId,@RequestParam("startStep")  String startStep,@RequestParam("endStep")  String endStep) throws VertexAngEdgeException {
+        Map<String, List<MapVertexEdge>> vertexEdgeList= mapVertexEdgeService.initVertexEdge();
+        Map<String, MapVertex> vertexList = mapVertexService.initMapVertex();
+        ArrayList<MapVertex> obtainTheOptimalPath= mapVertexService.getPathByOrderID(orderId,startStep,endStep,vertexList,vertexEdgeList);
+        return success(obtainTheOptimalPath);
+    }
+
+    @ApiOperation(value="查询所有可选地点")
+    @GetMapping(value = "/findSelections")
+    public RESTfulResult findSelections(){
+        return success(mapVertexService.findSelections());
+    }
 }

+ 14 - 0
src/main/java/com/steerinfo/inPlantNavigation/mapper/MapVertexMapper.java

@@ -1,16 +1,30 @@
 package com.steerinfo.inPlantNavigation.mapper;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.steerinfo.framework.mapper.IBaseMapper;
 import com.steerinfo.inPlantNavigation.model.MapVertex;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 @Mapper
 public interface MapVertexMapper extends IBaseMapper<MapVertex, BigDecimal> {
     //@Select("SELECT * FROM MAP_VERTEX WHERE STATUS=0")
     List<MapVertex> findAllAvailable();
+
+    //找订单路径细节
+    Map<String, Object> findOrderDetails(String orderId);
+    //找进出厂的大门的点
+    String getVertexIdByGatePostId(String gatepostId);
+    //找汽车衡
+    String getVertexIdByCalculateId(String calculateId);
+    //找作业点
+    String getVertexIdByWarehouseId(String warehouseId);
+    //查询导航选项,不包含路口、拐点等
+    ArrayList<MapVertex> findSelections();
 }

+ 9 - 0
src/main/java/com/steerinfo/inPlantNavigation/service/IMapVertexService.java

@@ -1,5 +1,6 @@
 package com.steerinfo.inPlantNavigation.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.steerinfo.inPlantNavigation.exception.VertexAngEdgeException;
 import com.steerinfo.inPlantNavigation.model.IPMMSVertex;
 import com.steerinfo.inPlantNavigation.model.IPMMSVertexEdge;
@@ -7,6 +8,7 @@ import com.steerinfo.inPlantNavigation.model.MapVertex;
 import com.steerinfo.inPlantNavigation.model.MapVertexEdge;
 
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -29,8 +31,15 @@ public interface IMapVertexService {
     int importVertex(String filePath) throws IOException;
     //查询所有点
     List<MapVertex> findAllAvailable();
+    //查询导航选点,不包含路口、拐点等
+    ArrayList<MapVertex> findSelections();
     //初始化顶点
     Map<String, MapVertex> initMapVertex();
     //获取最短路径
     ArrayList<MapVertex> getObtainTheOptimalPath(String startpoint, String endPoint, Map<String, List<MapVertexEdge>> vertexEdgeList, Map<String, MapVertex> vertexList) throws VertexAngEdgeException;
+    //查询订单路径细节
+    Map<String, Object> findOrderDetails(String orderId);
+    //根据订单号判断订单状况,找当前起点终点并返回最短路径
+    ArrayList<MapVertex> getPathByOrderID(String orderId,String startStep,String endStep,Map<String, MapVertex> vertexList,Map<String, List<MapVertexEdge>> vertexEdgeList) throws VertexAngEdgeException;
+
 }

+ 72 - 0
src/main/java/com/steerinfo/inPlantNavigation/service/impl/MapVertexServiceImpl.java

@@ -1,5 +1,6 @@
 package com.steerinfo.inPlantNavigation.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.steerinfo.inPlantNavigation.exception.VertexAngEdgeException;
 import com.steerinfo.inPlantNavigation.mapper.MapVertexMapper;
 import com.steerinfo.inPlantNavigation.model.IPMMSVertex;
@@ -72,6 +73,11 @@ public class MapVertexServiceImpl implements IMapVertexService {
         return mapVertexMapper.findAllAvailable();
     }
 
+    @Override
+    public ArrayList<MapVertex> findSelections() {
+        return mapVertexMapper.findSelections();
+    }
+
     @Override
     public Map<String, MapVertex> initMapVertex() {
         List<MapVertex> list=mapVertexMapper.findAllAvailable();
@@ -149,6 +155,7 @@ public class MapVertexServiceImpl implements IMapVertexService {
         return startPointToEndPointPath(endPoint,currentBestDinstance,vertexList);
     }
 
+
     //获得目前最短距离
     public String getStringMinimumValue(HashMap<String,Integer[]> currentBestDinstance,List<String> obtainTheOptimalPath){
 
@@ -213,4 +220,69 @@ public class MapVertexServiceImpl implements IMapVertexService {
         while (beforeDistance!=-1);
         return obtainOptimalPath;
     }
+
+    @Override
+    public Map<String, Object> findOrderDetails(String orderId) {
+        Map<String, Object> result=mapVertexMapper.findOrderDetails(orderId);
+        return result;
+    }
+
+    @Override
+    public ArrayList<MapVertex> getPathByOrderID(String orderId,String startStep,String endStep,Map<String, MapVertex> vertexList,Map<String, List<MapVertexEdge>> vertexEdgeList) throws VertexAngEdgeException {
+        //校验
+        if(orderId==null || startStep==null ||endStep==null){
+            return null;
+        }
+        //初始化
+        ArrayList<MapVertex> obtainOptimalPath=null;
+        Map<String, Object> details=mapVertexMapper.findOrderDetails(orderId);
+        String startPoint=null;
+        String endPoint=null;
+        //取得起点的顶点
+        startPoint=parseVertexID(startStep,details);
+        //取得终点的顶点
+        endPoint=parseVertexID(endStep,details);
+        //不为空则找寻最短路径
+        if(startPoint!=null && endPoint!=null){
+            obtainOptimalPath= getObtainTheOptimalPath(startPoint,endPoint,vertexEdgeList,vertexList);
+            Collections.reverse(obtainOptimalPath);//翻转
+        }
+        return obtainOptimalPath;
+    }
+    //转换成顶点编号
+    private String parseVertexID(String step,Map<String, Object> details){
+        //校验数据
+        if(step==null || details==null || details.size()<1){
+            return null;
+        }
+        //转换成顶点id
+        String point=null;
+        switch (step){
+            case "进厂":
+                if(details.get("entryGatepostId")!=null)
+                    point=mapVertexMapper.getVertexIdByGatePostId(details.get("entryGatepostId").toString());
+                break;
+            case "计皮":
+                if(details.get("tareCalculateId")!=null)
+                    point=mapVertexMapper.getVertexIdByCalculateId(details.get("tareCalculateId").toString());
+                break;
+            case "装货":
+                if(details.get("loadingID")!=null)
+                    point=mapVertexMapper.getVertexIdByWarehouseId(details.get("loadingID").toString());
+                break;
+            case "卸货":
+                if(details.get("unloadWarhouseId")!=null)
+                    point=mapVertexMapper.getVertexIdByWarehouseId(details.get("unloadWarhouseId").toString());
+                break;
+            case "计毛":
+                if(details.get("grossPlaceId")!=null)
+                    point=mapVertexMapper.getVertexIdByCalculateId(details.get("grossPlaceId").toString());
+                break;
+            case "出厂":
+                if(details.get("leaveGatepostId")!=null)
+                    point=mapVertexMapper.getVertexIdByGatePostId(details.get("leaveGatepostId").toString());
+                break;
+        }
+        return point;
+    }
 }

+ 68 - 0
src/main/resources/com/steerinfo/inPlantNavigation/mapper/MapVertexMapper.xml

@@ -341,4 +341,72 @@
   <select id="findAllAvailable" resultMap="BaseResultMap">
     SELECT * FROM MAP_VERTEX WHERE STATUS=0
   </select>
+  
+  <select id="findOrderDetails" resultType="java.util.Map">
+    SELECT DISTINCT ERG.GATEPOST_NAME            as "entryGatepost",
+                    ERG.GATEPOST_ID 						as "entryGatepostId",
+                    GRTC.TRUCK_CALCULATE_NUMBER  as "grossCalculate",
+                    TWR.RESULT_GROSS_PLACE_ID as "grossPlaceId",
+                    RWR.WAREHOUSE_NAME as "loadingPlace",
+                    RWR.WAREHOUSE_ID as "loadingID",
+                    RW.WAREHOUSE_NAME            as "unloadWarhouse",
+                    RW.WAREHOUSE_ID       as "unloadWarhouseId",
+                    TRTC.TRUCK_CALCULATE_NUMBER  as "tareCalculate",
+                    TWR.RESULT_TARE_PLACE_ID  as "tareCalculateId",
+                    LRG.GATEPOST_NAME            as "leaveGatepost",
+                    LRG.GATEPOST_ID           as "leaveGatepostId",
+                    OO.ORDER_LINE_SEQUENCE       as "orderLineSequence",
+                    OO.ORDER_TYPE                as "orderType"
+    FROM OMSTRUCK_ORDER OO
+           LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR
+                     ON TTR.ORDER_ID = OO.ORDER_ID
+           LEFT JOIN TMSTRUCK_ENFACTORY_RESULT TER
+                     ON TTR.RESULT_TOTAL_ID = TER.RESULT_TOTAL_ID
+           LEFT JOIN RMS_GATEPOST ERG --进厂门岗
+                     ON ERG.GATEPOST_ID = TER.GATEPOST_ID
+           LEFT JOIN TMSTRUCK_WEIGHT_RESULT TWR
+                     ON TTR.RESULT_TOTAL_ID = TWR.RESULT_TOTAL_ID
+           LEFT JOIN RMS_TRUCK_CALCULATE GRTC --毛重汽车衡
+                     ON TWR.RESULT_GROSS_PLACE_ID = GRTC.TRUCK_CALCULATE_ID
+           LEFT JOIN RMS_TRUCK_CALCULATE TRTC --皮重汽车衡
+                     ON TWR.RESULT_TARE_PLACE_ID = TRTC.TRUCK_CALCULATE_ID
+           LEFT JOIN TMSTRUCK_UNLOAD_RESULT TUR --卸货实绩
+                     ON TTR.RESULT_TOTAL_ID = TUR.RESULT_TOTAL_ID
+           LEFT JOIN TMSTRUCK_LOAD_RESULT TLR --装货实绩
+                     ON TTR.RESULT_TOTAL_ID = TLR.RESULT_TOTAL_ID
+           LEFT JOIN RMS_WAREHOUSE RWR --装货点
+                     ON TLR.LOADING_ID = RWR.WAREHOUSE_ID
+           LEFT JOIN RMS_WAREHOUSE RW --卸货点
+                     ON RW.WAREHOUSE_ID = TUR.RESULT_UNLOAD_PLACE_ID
+           LEFT JOIN TMSTRUCK_LEAVE_FACTORY_RESULT TLFR --出厂实绩
+                     ON TTR.RESULT_TOTAL_ID = TLFR.RESULT_TOTAL_ID
+           LEFT JOIN RMS_GATEPOST LRG --出厂门岗
+                     ON LRG.GATEPOST_ID = TLFR.GATEPOST_ID
+    WHERE OO.ORDER_ID =#{orderId}
+  </select>
+
+  <select id="getVertexIdByGatePostId" resultType="java.lang.String">
+    select MLM.VERTEX_ID
+    from MAP_LOCATION_MAPPING MLM,RMS_GATEPOST RG
+    where MLM.GATEPOST_ID = RG.GATEPOST_ID and RG.GATEPOST_ID=#{gatepostId}
+  </select>
+
+  <select id="getVertexIdByCalculateId" resultType="java.lang.String">
+    select MLM.VERTEX_ID
+    from MAP_LOCATION_MAPPING MLM,RMS_TRUCK_CALCULATE RTC
+    where MLM.TRUCK_CALCULATE_ID = RTC.TRUCK_CALCULATE_ID and RTC.TRUCK_CALCULATE_ID=#{calculateId}
+  </select>
+
+  <select id="getVertexIdByWarehouseId" resultType="java.lang.String">
+    select MLM.VERTEX_ID
+    from MAP_LOCATION_MAPPING MLM,RMS_WAREHOUSE RW
+    where MLM.WAREHOUSE_ID = RW.WAREHOUSE_ID and RW.WAREHOUSE_ID=#{warehouseId}
+  </select>
+
+  <select id="findSelections" resultMap="BaseResultMap">
+    SELECT  *
+    FROM MAP_VERTEX MV
+    WHERE MV.VERTEX_ID IN
+          (SELECT DISTINCT VERTEX_ID FROM MAP_LOCATION_MAPPING)
+  </select>
 </mapper>