瀏覽代碼

船舶动态表增加提醒

shxiaoc 11 月之前
父節點
當前提交
6c1f3fc2bc

+ 37 - 0
src/main/java/com/steerinfo/dil/controller/TmsshipShipLocationController.java

@@ -156,4 +156,41 @@ public class TmsshipShipLocationController extends BaseRESTfulController {
         return success(map);
     }
 
+    @PostMapping(value = "/getWarnMsg")
+    public RESTfulResult getWarnMsg(@RequestBody(required = false) Map<String,Object> mapVal) throws Exception {
+        StringBuilder warnMsg = new StringBuilder();
+        List<Map<String, Object>> columnList = tmsshipShipLocationService.selectShipLocationList(mapVal);
+        List<String> list = new ArrayList<>();
+        if(columnList != null && !columnList.isEmpty()) {
+            for (Map<String, Object> map : columnList) {
+                String locationRouteTime = map.get("locationRouteTime").toString();
+                if(locationRouteTime != null && !"".equals(locationRouteTime) ){
+                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+                    Date locationRouteTimeDate = sdf.parse(locationRouteTime);
+                    long starTime=locationRouteTimeDate.getTime();
+                    long endTime=(new Date()).getTime();
+                    long num=endTime-starTime;//时间戳相差的毫秒数
+                    System.out.println("相差天数为:"+num/24/60/60/1000);
+                    //超过15天提醒
+                    if((num/(24*60*60*1000)) > 15){
+                        list.add(""+ map.get("materialName") +" \""+ map.get("foreignShipName") +"\" "+map.get("capacityName")
+                                +" 离岗日期"+ map.get("locationRouteTime") +" 离岗已超过十五天,请确定船舶状态;          ");
+                    }
+                }
+            }
+        }
+        if(list.isEmpty()){
+            warnMsg.append("暂无警告");
+        } else {
+             for (int i = 0; i < list.size(); i++) {
+                 int k=i+1;
+                 if(k == 1){
+                     warnMsg.append("警告:");
+                 }
+                 warnMsg.append(k).append("、").append(list.get(i));
+             }
+        }
+        return success(warnMsg);
+    }
+
 }

+ 1 - 1
src/main/resources/application-prod.yml

@@ -1,6 +1,6 @@
 spring:
   datasource:
-    url: jdbc:oracle:thin:@192.168.0.46:1521:STEER
+    url: jdbc:oracle:thin:@172.16.33.163:1521:ilsdbpri
     password: Dil123789
     username: dil
     driver-class-name: oracle.jdbc.OracleDriver