minghao-chen 2 éve%!(EXTRA string=óta)
szülő
commit
493d1781c5
21 módosított fájl, 171 hozzáadás és 32 törlés
  1. 9 4
      beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/ship/FocusShipController.java
  2. 11 7
      beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/ship/ShipArchivesController.java
  3. 5 0
      beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/ship/ShipWarningRecordController.java
  4. 2 2
      beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/ship/ShipWarningRuleController.java
  5. 1 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/archives/domain/ShipArchivesData.java
  6. 1 1
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/archives/mapper/ShipArchivesMapper.java
  7. 1 1
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/archives/service/ShipArchivesService.java
  8. 2 2
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/archives/service/impl/ShipArchivesServiceImpl.java
  9. 1 1
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/focus/domain/FocusShipData.java
  10. 1 1
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/task/ShipSchedulersTask.java
  11. 11 1
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/model/mapper/ShipWarningModelMapper.java
  12. 16 9
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/model/service/impl/ShipWarningServiceImpl.java
  13. 24 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/record/domain/SimpleRecord.java
  14. 25 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/record/domain/WarningRecordResult.java
  15. 7 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/record/mapper/WarningRecordMapper.java
  16. 2 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/record/service/WarningRecordService.java
  17. 5 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/record/service/impl/WarningRecordServiceImpl.java
  18. 6 0
      beidou-ship/src/main/resources/mapper/ShipArchivesMapper.xml
  19. 3 3
      beidou-ship/src/main/resources/mapper/ShipTrackMapper.xml
  20. 7 0
      beidou-ship/src/main/resources/mapper/ShipWarningModelMapper.xml
  21. 31 0
      beidou-ship/src/main/resources/mapper/WarningRecordMapper.xml

+ 9 - 4
beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/ship/FocusShipController.java

@@ -35,8 +35,9 @@ public class FocusShipController extends BaseController {
     @PostMapping("/addFocusShip")
     public R addFocusShip(@RequestBody FocusShipData focusShipData){
         try{
-            focusShipData.setFocusId(new SnowFlakeIdWorker(1,0).nextId());
-            focusShipData.setUserId(String.valueOf(SecurityUtils.getUserId()));
+            String userId = String.valueOf(SecurityUtils.getUserId());
+            focusShipData.setFocusId(focusShipData.getDevideNo()+userId);
+            focusShipData.setUserId(userId);
             focusShipService.insertFocusShip(focusShipData);
             return R.ok();
         }catch (Exception e){
@@ -46,8 +47,10 @@ public class FocusShipController extends BaseController {
 
     @ApiOperation("移除关注船舶")
     @GetMapping("/delFocusShip")
-    public R delFocusShip(Long focusId){
+    public R delFocusShip(String devideNo){
         try{
+            String id =devideNo+SecurityUtils.getUserId();
+            long focusId = Long.parseLong(id);
             int i = focusShipService.deleteFocusShip(focusId);
             if(i<1){
                 R.fail("取消关注失败");
@@ -60,8 +63,10 @@ public class FocusShipController extends BaseController {
 
     @ApiOperation("关注船舶详情")
     @GetMapping("/findFocusShip")
-    public R<FocusShipResult> findFocusShip(Long focusId){
+    public R<FocusShipResult> findFocusShip(String devideNo){
         try{
+            String id =devideNo+SecurityUtils.getUserId();
+            long focusId = Long.parseLong(id);
             return R.ok(focusShipService.selectById(focusId));
         }catch (Exception e){
             return R.fail(e.getMessage());

+ 11 - 7
beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/ship/ShipArchivesController.java

@@ -72,18 +72,22 @@ public class ShipArchivesController extends BaseController {
         }
     }
 
-    @ApiOperation("船舶档案统计")
+    @ApiOperation(value = "船舶档案统计",notes = "speed参数为前端拼的sql语句")
     @GetMapping("/getShipTotal")
-    public R<ShipArchivesTotal> getShipTotal(String deptId){
+    public R<ShipArchivesTotal> getShipTotal(String deptId,String speed){
         try {
             ShipArchivesTotal total = null;
             if (StringUtils.isBlank(deptId) || "4635".equals(deptId)){
-                 total = redisCache.getCacheObject("SHIP_TOTAL_4635");
-                 if(total == null){
-                     total = shipArchivesService.getShipTotal(deptId);
-                 }
+                if(StringUtils.isBlank(speed)){
+                    total = redisCache.getCacheObject("SHIP_TOTAL_4635");
+                    if(total == null){
+                        total = shipArchivesService.getShipTotal(deptId,null);
+                    }
+                }else {
+                    total = shipArchivesService.getShipTotal(deptId,speed);
+                }
             }else {
-                 total = shipArchivesService.getShipTotal(deptId);
+                 total = shipArchivesService.getShipTotal(deptId,speed);
             }
             return R.ok(total);
         }catch (Exception e){

+ 5 - 0
beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/ship/ShipWarningRecordController.java

@@ -98,6 +98,11 @@ public class ShipWarningRecordController extends BaseController {
         return R.ok(warningRecordService.getDisposeStatus());
     }
 
+    @ApiOperation("根据北斗号获取船舶预警")
+    @GetMapping("/getRecordByDeviceId")
+    public R<List<WarningRecordResult>> getRecordByDeviceId(String deviceId){
+        return R.ok(warningRecordService.getRecordByDeviceId(deviceId));
+    }
 
 
 }

+ 2 - 2
beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/ship/ShipWarningRuleController.java

@@ -142,9 +142,9 @@ public class ShipWarningRuleController extends BaseController {
 
     @ApiOperation("获取区域列表")
     @GetMapping("/getAreaList")
-    public R<List<WarningAreaVo>> getAreaList(){
+    public R<List<WarningAreaVo>> getAreaList(String areaName){
         try {
-            return R.ok(shipWarningModelMapper.selectAreaList());
+            return R.ok(shipWarningModelMapper.selectAreaList(areaName));
         }catch (Exception e){
             return R.fail(e.getMessage());
         }

+ 1 - 0
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/archives/domain/ShipArchivesData.java

@@ -108,6 +108,7 @@ public class ShipArchivesData {
     private String deviceStatus;
 
     private String kwh;
+    private String speed;
 
     @ApiModelProperty("位置")
     private String location;

+ 1 - 1
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/archives/mapper/ShipArchivesMapper.java

@@ -60,7 +60,7 @@ public interface ShipArchivesMapper{
      * @param deptId
      * @return
      */
-    ShipArchivesTotal getShipTotal(@Param("deptId")String deptId);
+    ShipArchivesTotal getShipTotal(@Param("deptId")String deptId,@Param("speed") String speed);
 
 
 }

+ 1 - 1
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/archives/service/ShipArchivesService.java

@@ -32,7 +32,7 @@ public interface ShipArchivesService{
      * @param deptId
      * @return
      */
-    ShipArchivesTotal getShipTotal(String deptId);
+    ShipArchivesTotal getShipTotal(String deptId,String speed);
 
 
 }

+ 2 - 2
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/archives/service/impl/ShipArchivesServiceImpl.java

@@ -65,9 +65,9 @@ public class ShipArchivesServiceImpl implements ShipArchivesService {
     }
 
     @Override
-    public ShipArchivesTotal getShipTotal(String deptId){
+    public ShipArchivesTotal getShipTotal(String deptId,String speed){
 
-        ShipArchivesTotal total = shipArchivesMapper.getShipTotal(deptId);
+        ShipArchivesTotal total = shipArchivesMapper.getShipTotal(deptId,speed);
         int shipTotal = Integer.parseInt(total.getShipTotal());
         Integer online = Integer.parseInt(total.getOnlineTotal());
 

+ 1 - 1
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/focus/domain/FocusShipData.java

@@ -13,7 +13,7 @@ public class FocusShipData {
     /**
      * 重点关注id
      */
-    private Long focusId;
+    private String focusId;
     /**
      * 设备号
      */

+ 1 - 1
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/task/ShipSchedulersTask.java

@@ -28,7 +28,7 @@ public class ShipSchedulersTask {
      */
     @Scheduled(cron = "1/10 * * * * ?")
     public void setShipTotalToRedis(){
-        ShipArchivesTotal shipTotal = shipArchivesService.getShipTotal(null);
+        ShipArchivesTotal shipTotal = shipArchivesService.getShipTotal(null,null);
         redisCache.setCacheObject("SHIP_TOTAL_4635",shipTotal);
     }
 }

+ 11 - 1
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/model/mapper/ShipWarningModelMapper.java

@@ -134,7 +134,7 @@ public interface ShipWarningModelMapper {
      */
     List<WarningParamDictData> selectParamDict();
 
-    List<WarningAreaVo> selectAreaList();
+    List<WarningAreaVo> selectAreaList(String areaName);
 
     int updateParamById(@Param("paramId")String paramId,@Param("paramValue")String paramValue,@Param("userId")String userId);
 
@@ -210,6 +210,16 @@ public interface ShipWarningModelMapper {
 
     int delRuleModelParamByRId(String ruleId);
 
+    /**
+     * 获取规则模型参数的id
+     * @param ruleId
+     * @param modelId
+     * @param paramId
+     * @return
+     */
+    RuleModelParamData getRuleModelParamByRMP(@Param("ruleId") String ruleId,
+                                              @Param("modelId") String modelId,
+                                              @Param("paramId") String paramId);
 
     /**
      * 新增规则模型区域关系表

+ 16 - 9
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/model/service/impl/ShipWarningServiceImpl.java

@@ -66,7 +66,7 @@ public class ShipWarningServiceImpl implements ShipWarningService {
             //根据规则ID删除 规则模型区域关系
             shipWarningModelMapper.delRuleModelAreaByRId(paramRuleId);
             //删除规则下的规则模型参数关系
-            shipWarningModelMapper.delRuleModelParamByRId(paramRuleId);
+            //shipWarningModelMapper.delRuleModelParamByRId(paramRuleId);
             ruleId = paramRuleId;
         }else {
             if(shipWarningModelMapper.selectWarningRuleByName(name,null)>0){
@@ -81,14 +81,21 @@ public class ShipWarningServiceImpl implements ShipWarningService {
 
         String finalRuleId = ruleId;
         warningRuleReq.getParamList().stream().forEach(list->{
-            RuleModelParamData ruleModelParamData = new RuleModelParamData();
-            ruleModelParamData.setId(worker.nextId());
-            ruleModelParamData.setRuleId(finalRuleId);
-            ruleModelParamData.setModelId(modelId);
-            ruleModelParamData.setParamId(list.getParamId());
-            ruleModelParamData.setParamValue(list.getParamValue());
-            ruleModelParamData.setCreateBy(userId);
-            shipWarningModelMapper.insertRuleModelParam(ruleModelParamData);
+            RuleModelParamData ruleModelParamByRMP = shipWarningModelMapper.getRuleModelParamByRMP(finalRuleId, modelId, list.getParamId());
+            if(ruleModelParamByRMP!=null){
+                ruleModelParamByRMP.setParamValue(list.getParamValue());
+                shipWarningModelMapper.insertRuleModelParam(ruleModelParamByRMP);
+            }else {
+                RuleModelParamData ruleModelParamData = new RuleModelParamData();
+                ruleModelParamData.setId(worker.nextId());
+                ruleModelParamData.setRuleId(finalRuleId);
+                ruleModelParamData.setModelId(modelId);
+                ruleModelParamData.setParamId(list.getParamId());
+                ruleModelParamData.setParamValue(list.getParamValue());
+                ruleModelParamData.setCreateBy(userId);
+                shipWarningModelMapper.insertRuleModelParam(ruleModelParamData);
+            }
+
         });
 
         String[] splits = warningRuleReq.getAreaList().split(",");

+ 24 - 0
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/record/domain/SimpleRecord.java

@@ -0,0 +1,24 @@
+package cn.com.taiji.beidou.ship.warning.record.domain;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @Author CHEN
+ * @Date 2023/2/10 9:29
+ */
+@Data
+public class SimpleRecord {
+    @ApiModelProperty("预警Id")
+    private String warningId;
+    @ApiModelProperty("预警时间")
+    private String warningTime;
+    @ApiModelProperty("经度")
+    private String longitude;
+    @ApiModelProperty("纬度")
+    private String latitude;
+    @ApiModelProperty("预警详情")
+    private String warningDetail;
+    @ApiModelProperty("处置ID null值为未读")
+    private String disposeId;
+}

+ 25 - 0
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/record/domain/WarningRecordResult.java

@@ -0,0 +1,25 @@
+package cn.com.taiji.beidou.ship.warning.record.domain;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @Author CHEN
+ * @Date 2023/2/10 9:03
+ */
+@Data
+public class WarningRecordResult {
+
+    @ApiModelProperty("预警规则")
+    private String ruleId;
+    @ApiModelProperty("北斗ID")
+    private String deviceId;
+    @ApiModelProperty("预警规则名称")
+    private String ruleName;
+    @ApiModelProperty("预警数量")
+    private Integer count;
+    private List<SimpleRecord> records;
+
+}

+ 7 - 0
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/record/mapper/WarningRecordMapper.java

@@ -72,4 +72,11 @@ public interface WarningRecordMapper {
 
     WarningRecordData getRecordById(String id);
 
+    /**
+     * 根据北斗ID查询预警信息
+     * @param deviceId
+     * @return
+     */
+    List<WarningRecordResult> getRecordByDeviceId(String deviceId);
+
 }

+ 2 - 0
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/record/service/WarningRecordService.java

@@ -51,4 +51,6 @@ public interface WarningRecordService {
      * @return
      */
     List<Map<Integer,String>> getDisposeStatus();
+
+    List<WarningRecordResult> getRecordByDeviceId(String deviceId);
 }

+ 5 - 0
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/record/service/impl/WarningRecordServiceImpl.java

@@ -71,4 +71,9 @@ public class WarningRecordServiceImpl implements WarningRecordService {
     public List<Map<Integer, String>> getDisposeStatus() {
         return warningRecordMapper.getDisposeStatus();
     }
+
+    @Override
+    public List<WarningRecordResult> getRecordByDeviceId(String deviceId) {
+        return warningRecordMapper.getRecordByDeviceId(deviceId);
+    }
 }

+ 6 - 0
beidou-ship/src/main/resources/mapper/ShipArchivesMapper.xml

@@ -27,6 +27,7 @@
         <result property="latitude"    column="latitude"    />
         <result property="location"    column="location"    />
         <result property="kwh" column="kwh"/>
+        <result property="speed" column="speed"/>
     </resultMap>
 
     <resultMap id="disposeResult" type="ShipDisposeResult">
@@ -140,6 +141,7 @@
         location.longitude,
         location.latitude,
         location.location,
+        location.speed,
         dept.pscmc as dept_name
         from ax_beidou_ship_archives archives
         LEFT JOIN ax_beidou_ship_status sta ON archives.devide_no = sta.device_id
@@ -161,8 +163,12 @@
         from ax_beidou_ship_archives archives
             INNER JOIN ax_beidou_dept dept ON archives.police_station_id = dept.pscbh
             LEFT JOIN ax_beidou_ship_status sta ON archives.devide_no = sta.device_id
+            <if test="speed != null and speed != ''">
+                INNER JOIN ax_beidou_ship_location location on archives.devide_no = location.device_id
+            </if>
             where 1=1
             <if test="deptId != null and deptId != ''">and dept.xw_dept_id like concat('%',#{deptId},'%')</if>
+            <if test="speed != null and speed != ''">${speed}</if>
     </select>
 
 

+ 3 - 3
beidou-ship/src/main/resources/mapper/ShipTrackMapper.xml

@@ -7,7 +7,7 @@
     <resultMap type="shipTrackResult" id="shipTrackResult">
         <result property="serial" column="serial"/>
         <result property="deviceId" column="device_id"/>
-        <result property="sendTime" column="send_time"/>
+        <result property="sendTime" column="sendTime"/>
         <result property="longitude" column="longitude"/>
         <result property="latitude" column="latitude"/>
         <result property="direction" column="direction"/>
@@ -15,10 +15,10 @@
     </resultMap>
 
     <select id="selectShipTrackDetail" parameterType="shipTrackReq" resultMap="shipTrackResult">
-        select ROW_NUMBER() over(ORDER BY track.location_time) as serial,device_id,send_time,longitude,latitude,direction,speed from ax_beidou_track track
+        select ROW_NUMBER() over(ORDER BY track.location_time) as serial,device_id,track.location_time as sendTime,longitude,latitude,direction,speed from ax_beidou_track track
         where track.device_id = #{deviceId}
         <if test="endTime != null and endTime != ''">and track.location_time &lt; #{endTime}</if>
         <if test="startTime != null and startTime != ''">and track.location_time &gt; #{startTime}</if>
-        order by track.location_time ASC
+        order by track.location_time DESC
     </select>
 </mapper>

+ 7 - 0
beidou-ship/src/main/resources/mapper/ShipWarningModelMapper.xml

@@ -312,6 +312,7 @@
 
     <select id="selectAreaList" resultType="warningAreaVo">
         select id,`name`,location from ax_beidou_warning_area where del_flag = '0'
+        <if test="areaName != null and areaName != ''">and `name` like concat('%',#{areaName},'%')</if>
     </select>
 
     <update id="updateParamById" parameterType="string">
@@ -445,6 +446,12 @@
         delete from ax_beidou_warning_rule_model_param where rule_id = #{ruleId}
     </delete>
 
+    <select id="getRuleModelParamByRMP" parameterType="string" resultType="ruleModelParamData">
+        select id,rule_id as ruleId,model_id as modelId,param_id as paramId,create_by as createBy from ax_beidou_warning_rule_model_param
+        where rule_id = #{ruleId} and model_id = #{modelId} and param_id = #{paramId}
+    </select>
+
+
     <select id="selectWarningModelByName" parameterType="string" resultType="integer">
         select count(*) from ax_beidou_warning_model where del_flag = '0' and `name` = #{modelName}
         <if test="id != null and id != ''">

+ 31 - 0
beidou-ship/src/main/resources/mapper/WarningRecordMapper.xml

@@ -127,4 +127,35 @@
         from ax_beidou_warning_record where id = #{id} and (`start` is null or `start` != 'false')
     </select>
 
+    <resultMap id="RecordByDeviceId" type="warningRecordResult">
+        <result property="ruleId" column="rule_id"/>
+        <result property="deviceId" column="device_id"/>
+        <result property="ruleName" column="ruleName"/>
+        <result property="count" column="number"/>
+        <collection property="records" column="{ruleId= rule_id,deviceId= device_id}"
+                    ofType="simpleRecord" select="record">
+        </collection>
+    </resultMap>
+
+    <select id="getRecordByDeviceId" parameterType="string" resultMap="RecordByDeviceId">
+        SELECT rule_id,device_id,rule.`name` as ruleName,count(*) as number
+        from ax_beidou_warning_record
+        INNER JOIN ax_beidou_warning_rule rule ON rule.id = rule_id
+        where device_id = #{deviceId} and (`start` is null or `start` != 'false')
+        and warning_time>DATE_SUB(NOW(),INTERVAL 1 DAY)
+        GROUP BY rule_id,rule.`name`,device_id
+    </select>
+
+    <select id="record" resultType="simpleRecord">
+        select record.id as warningId, warning_time as warningTime,area.name as warningDetail,
+        dis.id AS disposeId,location.longitude,location.latitude
+        from ax_beidou_warning_record record
+        INNER JOIN ax_beidou_ship_status sta ON record.device_id = sta.device_id
+        LEFT JOIN ax_beidou_ship_location location ON location.device_id = record.device_id
+        LEFT JOIN ax_beidou_ship_dispose dis ON record.id = dis.warning_id
+        LEFT JOIN ax_beidou_warning_area area ON area.id = record.area_id
+        where record.device_id = #{deviceId} and (record.`start` is null or record.`start` != 'false')
+        and record.rule_id = #{ruleId} and warning_time>DATE_SUB(NOW(),INTERVAL 1 DAY)
+        ORDER BY warning_time DESC
+    </select>
 </mapper>