Forráskód Böngészése

Merge remote-tracking branch 'origin/master'

liangjianf 2 éve%!(EXTRA string=óta)
szülő
commit
72ae819225
28 módosított fájl, 476 hozzáadás és 100 törlés
  1. 5 1
      beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/common/CommonController.java
  2. 14 9
      beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/ship/ShipArchivesController.java
  3. 2 2
      beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/ship/ShipStatusController.java
  4. 83 0
      beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/ship/ShipTrackController.java
  5. 17 7
      beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/ship/ShipWarningRuleController.java
  6. 1 0
      beidou-common/src/main/java/cn/com/taiji/beidou/common/constant/Constants.java
  7. 4 7
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/archives/domain/ShipArchivesData.java
  8. 3 3
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/archives/mapper/ShipArchivesMapper.java
  9. 2 3
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/archives/service/ShipArchivesService.java
  10. 27 3
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/archives/service/impl/ShipArchivesServiceImpl.java
  11. 5 2
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/focus/domain/FocusShipResult.java
  12. 1 1
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/status/domain/ShipStatusResult.java
  13. 20 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/track/domain/ShipTrackReq.java
  14. 27 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/track/domain/ShipTrackResult.java
  15. 22 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/track/mapper/ShipTrackMapper.java
  16. 34 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/track/service/ShipTrackService.java
  17. 36 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/track/service/impl/ShipTrackServiceImpl.java
  18. 23 2
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/model/mapper/ShipWarningModelMapper.java
  19. 9 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/model/service/ShipWarningService.java
  20. 7 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/model/service/impl/ShipWarningServiceImpl.java
  21. 2 0
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/record/domain/SimpleWarningRecordResult.java
  22. 5 2
      beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/record/service/impl/WarningRecordServiceImpl.java
  23. 21 10
      beidou-ship/src/main/resources/mapper/FocusShipMapper.xml
  24. 14 15
      beidou-ship/src/main/resources/mapper/ShipArchivesMapper.xml
  25. 10 4
      beidou-ship/src/main/resources/mapper/ShipStatusMapper.xml
  26. 24 0
      beidou-ship/src/main/resources/mapper/ShipTrackMapper.xml
  27. 51 23
      beidou-ship/src/main/resources/mapper/ShipWarningModelMapper.xml
  28. 7 6
      beidou-ship/src/main/resources/mapper/WarningRecordMapper.xml

+ 5 - 1
beidou-admin/src/main/java/cn/com/taiji/beidou/web/controller/common/CommonController.java

@@ -13,6 +13,7 @@ import io.swagger.annotations.ApiOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -41,6 +42,8 @@ public class CommonController
 
     private static final String FILE_DELIMETER = ",";
 
+    @Value("${server.port}")
+    private String port;
     /**
      * 通用下载请求
      * 
@@ -87,7 +90,8 @@ public class CommonController
             String filePath = RuoYiConfig.getUploadPath();
             // 上传并返回新文件名称
             String fileName = FileUploadUtils.upload(filePath, file);
-            String url = serverConfig.getUrl() + fileName;
+            String path = serverConfig.getUrl();
+            String url =  path.substring(0,path.lastIndexOf(":")+1)+port+ fileName;
             AjaxResult ajax = AjaxResult.success();
             ajax.put("url", url);
             ajax.put("fileName", fileName);

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

@@ -3,6 +3,7 @@ package cn.com.taiji.beidou.web.controller.ship;
 import cn.com.taiji.beidou.common.core.controller.BaseController;
 import cn.com.taiji.beidou.common.core.domain.R;
 import cn.com.taiji.beidou.common.core.page.TableDataInfo;
+import cn.com.taiji.beidou.common.core.redis.RedisCache;
 import cn.com.taiji.beidou.common.utils.MathUtils;
 import cn.com.taiji.beidou.ship.archives.domain.*;
 import cn.com.taiji.beidou.ship.archives.service.ShipArchivesService;
@@ -10,6 +11,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -26,6 +28,8 @@ public class ShipArchivesController extends BaseController {
     @Resource
     private ShipArchivesService shipArchivesService;
 
+    @Resource
+    private RedisCache redisCache;
 
     @ApiOperation("获取船舶档案列表")
     @PostMapping("/shipList")
@@ -70,16 +74,17 @@ public class ShipArchivesController extends BaseController {
 
     @ApiOperation("船舶档案统计")
     @GetMapping("/getShipTotal")
-    public R<ShipArchivesTotal> getShipTotal(String shipId,String deptId){
+    public R<ShipArchivesTotal> getShipTotal(String deptId){
         try {
-            ShipArchivesTotal total = shipArchivesService.getShipTotal(shipId,deptId);
-            Double shipTotal = Double.parseDouble(total.getShipTotal());
-
-            total.setOnlineTotalRate(MathUtils.getHalfUp(Double.parseDouble(total.getOnlineTotal())/shipTotal*100,2));
-            total.setOfflineTotalRate(MathUtils.getHalfUp(Double.parseDouble(total.getOfflineTotal())/shipTotal*100,2));
-            total.setInPortRate(MathUtils.getHalfUp(Double.parseDouble(total.getInPort())/shipTotal*100,2));
-            total.setOffPortRate(MathUtils.getHalfUp(Double.parseDouble(total.getOffPort())/shipTotal*100,2));
-            total.setMarkRate(MathUtils.getHalfUp(Double.parseDouble(total.getMark())/shipTotal*100,2));
+            ShipArchivesTotal total = null;
+            if (StringUtils.isBlank(deptId) || "4635".equals(deptId)){
+                 total = redisCache.getCacheObject("SHIP_TOTAL_4635");
+                 if(total == null){
+                     total = shipArchivesService.getShipTotal(deptId);
+                 }
+            }else {
+                 total = shipArchivesService.getShipTotal(deptId);
+            }
             return R.ok(total);
         }catch (Exception e){
             return R.fail(e.getMessage());

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

@@ -69,7 +69,7 @@ public class ShipStatusController extends BaseController {
     @GetMapping("/stasisShipById")
     public R<ShipStatusResult> stasisShipById(String devideNo){
         try{
-            return R.ok(shipStatusService.selectById(devideNo,null,"1"));
+            return R.ok(shipStatusService.selectById(devideNo,null,"TRUE"));
         }catch (Exception e){
             return R.fail(e.getMessage());
         }
@@ -81,7 +81,7 @@ public class ShipStatusController extends BaseController {
         ShipStatusReq shipStatusReq = new ShipStatusReq();
         BeanUtils.copyProperties(req,shipStatusReq);
         shipStatusReq.setDevideNo(req.getShipId());
-        shipStatusReq.setIsStasis("1");
+        shipStatusReq.setIsStasis("TRUE");
         startPage(req.getPageNum(),req.getPageSize());
         List<ShipStatusResult> shipStatusResults = shipStatusService.selectShipStatusList(shipStatusReq);
         return getDataTable(shipStatusResults);

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

@@ -0,0 +1,83 @@
+package cn.com.taiji.beidou.web.controller.ship;
+
+import cn.com.taiji.beidou.common.config.RuoYiConfig;
+import cn.com.taiji.beidou.common.core.controller.BaseController;
+import cn.com.taiji.beidou.common.core.domain.AjaxResult;
+import cn.com.taiji.beidou.common.core.domain.R;
+import cn.com.taiji.beidou.common.core.page.TableDataInfo;
+import cn.com.taiji.beidou.common.utils.StringUtils;
+import cn.com.taiji.beidou.common.utils.file.FileUtils;
+import cn.com.taiji.beidou.common.utils.poi.ExcelUtil;
+import cn.com.taiji.beidou.ship.track.domain.ShipTrackReq;
+import cn.com.taiji.beidou.ship.track.domain.ShipTrackResult;
+import cn.com.taiji.beidou.ship.track.service.ShipTrackService;
+import cn.com.taiji.beidou.ship.warning.record.domain.WarningRecordExcel;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * @Author CHEN
+ * @Date 2023/1/12 18:09
+ */
+@Api(tags = "北斗轨迹")
+@RestController
+public class ShipTrackController extends BaseController {
+    private static final Logger log = LoggerFactory.getLogger(ShipWarningRecordController.class);
+    @Resource
+    private ShipTrackService shipTrackService;
+
+    @ApiOperation("北斗轨迹详情")
+    @PostMapping("/getTrackDetail")
+    public TableDataInfo getTrackDetail(@RequestBody ShipTrackReq req){
+
+        startPage(req.getPageNum(),req.getPageSize());
+        return getDataTable(shipTrackService.selectShipTrackDetail(req));
+
+    }
+
+    @ApiOperation("航速分析")
+    @PostMapping("/speedAnalysis")
+    public R<List<ShipTrackResult>> speedAnalysis(@RequestBody ShipTrackReq req){
+
+        return R.ok(shipTrackService.selectShipTrackDetail(req));
+
+    }
+
+    @ApiOperation("轨迹导出")
+    @PostMapping("/getTrackExcel")
+    public void getTrackDetailExcel(@RequestBody ShipTrackReq req, HttpServletResponse response){
+
+            List<ShipTrackResult> shipTrackResults = shipTrackService.selectShipTrackDetail(req);
+            ExcelUtil<ShipTrackResult> util = new ExcelUtil<ShipTrackResult>(ShipTrackResult.class);
+            AjaxResult result = util.exportExcel(shipTrackResults, "北斗轨迹-"+req.getDeviceId());
+            String fileName = (String) result.get("msg");
+            try {
+                if (!FileUtils.checkAllowDownload(fileName)){
+                    throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
+                }
+                String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
+                String filePath = RuoYiConfig.getDownloadPath() + fileName;
+                response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
+                FileUtils.setAttachmentResponseHeader(response, realFileName);
+                FileUtils.writeBytes(filePath, response.getOutputStream());
+                //是否删除已下载文件
+                FileUtils.deleteFile(filePath);
+            }
+            catch (Exception e)
+            {
+                log.error("下载文件失败", e);
+            }
+    }
+
+}

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

@@ -73,16 +73,16 @@ public class ShipWarningRuleController extends BaseController {
 
     @ApiOperation("预警规则列表")
     @GetMapping("/warn-rule/list")
-    public TableDataInfo getWarningRuleList(Integer pageNum, Integer pageSize){
+    public TableDataInfo getWarningRuleList(String ruleName, Integer pageNum, Integer pageSize){
         startPage(pageNum,pageSize);
-        List<WarningRuleResult> results = shipWarningModelMapper.selectRuleList(null,null);
+        List<WarningRuleResult> results = shipWarningModelMapper.selectRuleList(ruleName,null,null);
         return getDataTable(results);
     }
 
     @ApiOperation("预警规则列表(预警接入)")
     @GetMapping("/warn-rule/lists")
     public R<List<WarningRuleResult>> lists(){
-        List<WarningRuleResult> results = shipWarningModelMapper.selectRuleList(null,null);
+        List<WarningRuleResult> results = shipWarningModelMapper.selectRuleList(null,null,null);
         if (results==null||results.size()<0){
             return R.fail();
         }
@@ -92,7 +92,7 @@ public class ShipWarningRuleController extends BaseController {
     @ApiOperation("预警规则详情")
     @GetMapping("/warn-rule/get-by-id")
     public R<WarningRuleResult> getWarningRuleById(String id){
-        List<WarningRuleResult> results = shipWarningModelMapper.selectRuleList(null,id);
+        List<WarningRuleResult> results = shipWarningModelMapper.selectRuleList(null,null,id);
         if(results==null||results.size()<1){
             return R.fail();
         }
@@ -102,9 +102,9 @@ public class ShipWarningRuleController extends BaseController {
 
     @ApiOperation("预警模型列表")
     @GetMapping("/getWarningModelList")
-    public TableDataInfo getWarningModelList(Integer pageNum, Integer pageSize){
+    public TableDataInfo getWarningModelList(String modelName, Integer pageNum, Integer pageSize){
         startPage(pageNum,pageSize);
-        List<WarningModelResult> results = shipWarningModelMapper.selectModelList(null);
+        List<WarningModelResult> results = shipWarningModelMapper.selectModelList(modelName,null);
         TableDataInfo dataTable = getDataTable(results);
         return dataTable;
     }
@@ -112,7 +112,7 @@ public class ShipWarningRuleController extends BaseController {
     @ApiOperation(value = "预警模型详情",notes = "参数是预警模型ID,返回该模型关联的预警参数和预警区域")
     @GetMapping("/WarningModelById")
     public R<WarningModelResult> WarningModelById(String id){
-        List<WarningModelResult> results = shipWarningModelMapper.selectModelList(id);
+        List<WarningModelResult> results = shipWarningModelMapper.selectModelList(null,id);
         if(results==null||results.size()<1){
             return R.fail();
         }
@@ -169,4 +169,14 @@ public class ShipWarningRuleController extends BaseController {
             return R.fail(e.getMessage());
         }
     }
+
+    @ApiOperation(value = "勾选区域",notes = "参数ids是字符串,多个区域id以英文符号逗号隔开")
+    @PostMapping("/getAreaByIds")
+    public R getWarningAreaById(String ids){
+        try {
+            return R.ok(shipWarningService.findInId(ids));
+        }catch (Exception e){
+            return R.fail(e.getMessage());
+        }
+    }
 }

+ 1 - 0
beidou-common/src/main/java/cn/com/taiji/beidou/common/constant/Constants.java

@@ -140,6 +140,7 @@ public class Constants
     public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
             "org.springframework", "org.apache", "cn.com.taiji.beidou.common.utils.file" };
 
+    public static final String ZERO = "0";
 
     public static final String ONE = "1";
 

+ 4 - 7
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/archives/domain/ShipArchivesData.java

@@ -88,18 +88,12 @@ public class ShipArchivesData {
     /**
      * 最后状态
      */
-    @ApiModelProperty("最后状态 1在线,2离线,3回收,4遮挡,5损坏,6故障,7丢失,8馈电,9查扣、没收,10拆卸,0正常")
+    @ApiModelProperty("最后状态 1在线,2离线,3已标记")
     private Integer lastStatus;
 
     private String deptName;
 
     /**
-     * 入库时间
-     */
-    @ApiModelProperty("入库时间")
-    private String locationTime;
-
-    /**
      * 经度
      */
     @ApiModelProperty("经度")
@@ -117,4 +111,7 @@ public class ShipArchivesData {
 
     @ApiModelProperty("位置")
     private String location;
+
+    @ApiModelProperty("关注ID")
+    private String focusId;
 }

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

@@ -43,9 +43,10 @@ public interface ShipArchivesMapper{
     /**
      * 船只详情
      * @param devideNo
+     * @param userId
      * @return
      */
-    ShipArchivesData selectById(@Param("devideNo") String devideNo);
+    ShipArchivesData selectById(@Param("devideNo") String devideNo,@Param("userId") String userId);
 
     /**
      * 处置详情
@@ -56,11 +57,10 @@ public interface ShipArchivesMapper{
 
     /**
      * 统计
-     * @param shipId
      * @param deptId
      * @return
      */
-    ShipArchivesTotal getShipTotal(@Param("shipId")String shipId,@Param("deptId")String deptId);
+    ShipArchivesTotal getShipTotal(@Param("deptId")String deptId);
 
 
 }

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

@@ -28,12 +28,11 @@ public interface ShipArchivesService{
     ShipDisposeResult selectDisposeById(String devideNo, String warningId);
 
     /**
-     *
-     * @param shipId
+     *船舶档案统计
      * @param deptId
      * @return
      */
-    ShipArchivesTotal getShipTotal(String shipId,String deptId);
+    ShipArchivesTotal getShipTotal(String deptId);
 
 
 }

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

@@ -1,6 +1,7 @@
 package cn.com.taiji.beidou.ship.archives.service.impl;
 
 import cn.com.taiji.beidou.common.constant.Constants;
+import cn.com.taiji.beidou.common.utils.MathUtils;
 import cn.com.taiji.beidou.common.utils.SecurityUtils;
 import cn.com.taiji.beidou.common.utils.uuid.SnowFlakeIdWorker;
 import cn.com.taiji.beidou.ship.archives.domain.*;
@@ -36,13 +37,20 @@ public class ShipArchivesServiceImpl implements ShipArchivesService {
         }else if(Constants.THREE.equals(online)){
             req.setOnline("MARK");
         }
+        String inPort = req.getInPort();
+        if(Constants.ZERO.equals(inPort)){
+            req.setInPort("FALSE");
+        }else if(Constants.ONE.equals(inPort)){
+            req.setInPort("TRUE");
+        }
         List<ShipArchivesData> list = shipArchivesMapper.selectShipArchivesList(req);
         return list;
     }
 
     @Override
     public ShipArchivesData findShipById(String devideNo) {
-        ShipArchivesData data = shipArchivesMapper.selectById(devideNo);
+        String userId = String.valueOf(SecurityUtils.getUserId());
+        ShipArchivesData data = shipArchivesMapper.selectById(devideNo,userId);
         if(null==data.getLastStatus()){
             data.setLastStatus(1);
         }
@@ -56,8 +64,24 @@ public class ShipArchivesServiceImpl implements ShipArchivesService {
     }
 
     @Override
-    public ShipArchivesTotal getShipTotal(String shipId,String deptId){
-        return shipArchivesMapper.getShipTotal(shipId,deptId);
+    public ShipArchivesTotal getShipTotal(String deptId){
+
+        ShipArchivesTotal total = shipArchivesMapper.getShipTotal(deptId);
+
+        int shipTotal = Integer.parseInt(total.getShipTotal());
+        int online = Integer.parseInt(total.getOnlineTotal());
+        int mark = Integer.parseInt(total.getMark());
+
+        //int offline = shipTotal - (online + mark);
+        //total.setOfflineTotal(String.valueOf(offline));
+
+        total.setOnlineTotalRate(MathUtils.getHalfUp((double)online/shipTotal*100,2));
+        total.setOfflineTotalRate(MathUtils.getHalfUp(Double.parseDouble(total.getOfflineTotal())/shipTotal*100,2));
+        total.setInPortRate(MathUtils.getHalfUp(Double.parseDouble(total.getInPort())/shipTotal*100,2));
+        total.setOffPortRate(MathUtils.getHalfUp(Double.parseDouble(total.getOffPort())/shipTotal*100,2));
+        total.setMarkRate(MathUtils.getHalfUp((double)mark/shipTotal*100,2));
+
+        return total;
     }
 
 }

+ 5 - 2
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/focus/domain/FocusShipResult.java

@@ -15,7 +15,7 @@ import java.util.Date;
 public class FocusShipResult {
 
     @ApiModelProperty("关注ID")
-    private Long focusId;
+    private String focusId;
     @ApiModelProperty("关注人ID")
     private String userId;
 
@@ -110,9 +110,12 @@ public class FocusShipResult {
     /**
      * 最后状态
      */
-    @ApiModelProperty("最后状态")
+    @ApiModelProperty("最后状态 1在线,2离线,3已标记")
     private Integer lastStatus;
 
     @ApiModelProperty("终端状态")
     private Integer deviceStatus;
+
+    private String kwh;
+    private String location;
 }

+ 1 - 1
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/status/domain/ShipStatusResult.java

@@ -128,7 +128,7 @@ public class ShipStatusResult {
     /**
      * 最后状态
      */
-    @ApiModelProperty("最后状态")
+    @ApiModelProperty("最后状态 1在线,2离线,3已标记")
     private Integer lastStatus;
 
     private String deptName;

+ 20 - 0
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/track/domain/ShipTrackReq.java

@@ -0,0 +1,20 @@
+package cn.com.taiji.beidou.ship.track.domain;
+
+import lombok.Data;
+
+/**
+ * @Author CHEN
+ * @Date 2023/1/12 17:55
+ */
+@Data
+public class ShipTrackReq {
+
+    private String deviceId;
+
+    private String startTime;
+    private String endTime;
+
+    private Integer pageNum;
+    private Integer pageSize;
+
+}

+ 27 - 0
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/track/domain/ShipTrackResult.java

@@ -0,0 +1,27 @@
+package cn.com.taiji.beidou.ship.track.domain;
+
+import cn.com.taiji.beidou.common.annotation.Excel;
+import lombok.Data;
+
+/**
+ * @Author CHEN
+ * @Date 2023/1/12 17:58
+ */
+@Data
+public class ShipTrackResult {
+
+    private String id;
+    @Excel(name = "设备编号")
+    private String deviceId;
+
+    @Excel(name = "发送位置时间")
+    private String sendTime;
+    @Excel(name = "船速")
+    private String speed;
+    @Excel(name = "船向")
+    private String direction;
+    @Excel(name = "经度")
+    private String longitude;
+    @Excel(name = "纬度")
+    private String latitude;
+}

+ 22 - 0
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/track/mapper/ShipTrackMapper.java

@@ -0,0 +1,22 @@
+package cn.com.taiji.beidou.ship.track.mapper;
+
+import cn.com.taiji.beidou.ship.track.domain.ShipTrackReq;
+import cn.com.taiji.beidou.ship.track.domain.ShipTrackResult;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * @Author CHEN
+ * @Date 2023/1/12 17:51
+ */
+@Mapper
+public interface ShipTrackMapper {
+
+    /**
+     * 查询轨迹详情
+     * @param shipTrackReq
+     * @return
+     */
+    List<ShipTrackResult> selectShipTrackDetail(ShipTrackReq shipTrackReq);
+}

+ 34 - 0
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/track/service/ShipTrackService.java

@@ -0,0 +1,34 @@
+package cn.com.taiji.beidou.ship.track.service;
+
+import cn.com.taiji.beidou.ship.track.domain.ShipTrackReq;
+import cn.com.taiji.beidou.ship.track.domain.ShipTrackResult;
+
+import java.util.List;
+
+/**
+ * @Author CHEN
+ * @Date 2023/1/12 18:06
+ */
+public interface ShipTrackService {
+    /**
+     * 查询轨迹详情
+     * @param shipTrackReq
+     * @return
+     */
+    List<ShipTrackResult> selectShipTrackDetail(ShipTrackReq shipTrackReq);
+
+
+    /**
+     * 将经纬度转换为度分秒格式
+     *
+     * @param du 116.41884740.0897315
+     * @return 116°25'7.85"       40°5'23.03"
+     */
+    default  String latLng2Dfm(double du) {
+        int du1 = (int) du;
+        double tp = (du - du1) * 60;
+        int fen = (int) tp;
+        String miao = String.format("%.0f", Math.abs(((tp - fen) * 60)));
+        return du1 + "°" + Math.abs(fen) + "'" + miao + "\"";
+    }
+}

+ 36 - 0
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/track/service/impl/ShipTrackServiceImpl.java

@@ -0,0 +1,36 @@
+package cn.com.taiji.beidou.ship.track.service.impl;
+
+import cn.com.taiji.beidou.ship.track.domain.ShipTrackReq;
+import cn.com.taiji.beidou.ship.track.domain.ShipTrackResult;
+import cn.com.taiji.beidou.ship.track.mapper.ShipTrackMapper;
+import cn.com.taiji.beidou.ship.track.service.ShipTrackService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @Author CHEN
+ * @Date 2023/1/12 18:07
+ */
+@Service
+public class ShipTrackServiceImpl implements ShipTrackService {
+
+    @Resource
+    private ShipTrackMapper shipTrackMapper;
+
+    @Override
+    public List<ShipTrackResult> selectShipTrackDetail(ShipTrackReq shipTrackReq) {
+        List<ShipTrackResult> results = shipTrackMapper.selectShipTrackDetail(shipTrackReq);
+        //经纬度格式转换
+        results.stream().forEach(result->{
+            BigDecimal longitude = new BigDecimal(result.getLongitude());
+            result.setLongitude(latLng2Dfm(longitude.doubleValue()));
+            BigDecimal latitude = new BigDecimal(result.getLatitude());
+            result.setLatitude(latLng2Dfm(latitude.doubleValue()));
+        });
+
+        return results;
+    }
+}

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

@@ -15,9 +15,22 @@ import java.util.List;
 public interface ShipWarningModelMapper {
 
 
-    List<WarningModelResult> selectModelList(String id);
+    /**
+     * 模型列表
+     * @param modelName
+     * @param id
+     * @return
+     */
+    List<WarningModelResult> selectModelList(@Param("modelName")String modelName,@Param("id")String id);
 
-    List<WarningRuleResult> selectRuleList(@Param("enabled") String enabled,@Param("id")String id);
+    /**
+     * 规则列表
+     * @param ruleName
+     * @param enabled
+     * @param id
+     * @return
+     */
+    List<WarningRuleResult> selectRuleList(@Param("ruleName")String ruleName,@Param("enabled") String enabled,@Param("id")String id);
 
     /**
      * 启用停用
@@ -227,4 +240,12 @@ public interface ShipWarningModelMapper {
      * @return
      */
     int selectWarningRuleByName(@Param("ruleName")String ruleName,@Param("id")String id);
+
+
+    /**
+     * 根据勾选区域返回对应的区域信息
+     * @param ids
+     * @return
+     */
+    List<WarningAreaVo> findInId(String[] ids);
 }

+ 9 - 0
beidou-ship/src/main/java/cn/com/taiji/beidou/ship/warning/model/service/ShipWarningService.java

@@ -4,6 +4,8 @@ import cn.com.taiji.beidou.ship.warning.model.domain.*;
 import cn.com.taiji.beidou.ship.warning.rule.domain.UpdateEnabledReq;
 import cn.com.taiji.beidou.ship.warning.rule.domain.WarningRuleData;
 
+import java.util.List;
+
 /**
  * @Author CHEN
  * @Date 2022/11/20 9:50
@@ -43,4 +45,11 @@ public interface ShipWarningService {
      * @return
      */
     int delModel(String id);
+
+    /**
+     * 勾选区域
+     * @param ids
+     * @return
+     */
+    List<WarningAreaVo> findInId(String ids);
 }

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

@@ -253,4 +253,11 @@ public class ShipWarningServiceImpl implements ShipWarningService {
         shipWarningModelMapper.delModelAndParam(id);
         return shipWarningModelMapper.delModel(id);
     }
+
+    @Override
+    public List<WarningAreaVo> findInId(String ids) {
+        String[] array = ids.split(",");
+
+        return shipWarningModelMapper.findInId(array);
+    }
 }

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

@@ -1,6 +1,7 @@
 package cn.com.taiji.beidou.ship.warning.record.domain;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 /**
@@ -14,5 +15,6 @@ public class SimpleWarningRecordResult {
     @JsonFormat(shape =JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
     private String warningTime;
 
+    @ApiModelProperty("处置ID 有值是已读,null是未读")
     private String disposeId;
 }

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

@@ -1,5 +1,6 @@
 package cn.com.taiji.beidou.ship.warning.record.service.impl;
 
+import cn.com.taiji.beidou.common.constant.Constants;
 import cn.com.taiji.beidou.common.utils.SecurityUtils;
 import cn.com.taiji.beidou.common.utils.uuid.SnowFlakeIdWorker;
 import cn.com.taiji.beidou.ship.archives.domain.ShipDisposeData;
@@ -55,9 +56,11 @@ public class WarningRecordServiceImpl implements WarningRecordService {
         shipDisposeData.setDisposeUserId(String.valueOf(SecurityUtils.getUserId()));
         shipDisposeData.setId(new SnowFlakeIdWorker(1,0).nextId());
 
-        //更新处置状态
         WarningRecordData byId = warningRecordMapper.getRecordById(shipDisposeData.getWarningId());
-        shipStatusMapper.updateMark("MARK",byId.getDeviceId());
+        //更新处置状态  如果处置类型是正常,则不添加标记
+        if(!Constants.ZERO.equals(shipDisposeData.getDisposeType())){
+            shipStatusMapper.updateMark("MARK",byId.getDeviceId());
+        }
         shipDisposeData.setDevideNo(byId.getDeviceId());
         return warningRecordMapper.insertDispose(shipDisposeData);
     }

+ 21 - 10
beidou-ship/src/main/resources/mapper/FocusShipMapper.xml

@@ -25,12 +25,14 @@
         <result property="createTime"    column="create_time"    />
         <result property="modifyTime"      column="modify_time"      />
         <result property="ownerType"    column="owner_type"    />
-        <result property="lastStatus"    column="last_status"    />
+        <result property="lastStatus"    column="STATUS"    />
         <result property="deviceStatus"    column="device_status"    />
+        <result property="location"    column="location"    />
+        <result property="kwh" column="kwh"/>
     </resultMap>
 
     <insert id="insertFocusShip" parameterType="focusShipData">
-        insert ax_beidou_focus_ship(
+        insert into ax_beidou_focus_ship(
             focus_id,
             <if test="devideNo != null and devideNo != ''">devide_no,</if>
             <if test="shipId != null and shipId != ''">ship_id,</if>
@@ -52,22 +54,31 @@
     </delete>
 
     <select id="selectById" parameterType="long" resultMap="focusShipDetail">
-        select focus.user_id,focus.focus_id,focus.focus_type,focus.create_time as focus_create,st.mark as device_status,
-                dept.pscmc as dept_name,archives.*
+        select focus.user_id,focus.focus_id as focus_id,focus.focus_type,focus.create_time as focus_create,
+            (CASE st.is_online WHEN 'ONLINE' THEN 1 WHEN 'OFFLINE' THEN 2 WHEN 'MARK' THEN 3 ELSE 1 END ) AS STATUS,
+            dept.pscmc as dept_name,location.kwh,location.location,IFNULL(dispose.dispose_type,'0') as device_status,
+            archives.*
             from ax_beidou_ship_archives archives
             INNER JOIN ax_beidou_focus_ship focus on archives.devide_no = focus.devide_no
             INNER JOIN ax_beidou_dept dept on archives.police_station_id = dept.pscbh
-            INNER JOIN ax_beidou_ship_status st on st.devide_no = focus.devide_no
+            INNER JOIN ax_beidou_ship_status st on st.device_id = focus.devide_no
+            LEFT JOIN ax_beidou_ship_location location on focus.devide_no = location.device_id
+            LEFT JOIN (select id,devide_no,dispose_type from ax_beidou_ship_dispose
+            where devide_no=#{devideNo} ORDER BY id DESC limit 1) as dispose on dispose.devide_no = archives.devide_no
             where focus.focus_id = #{focusId}
     </select>
 
     <select id="selectList" parameterType="focusShipReq"  resultMap="focusShipDetail">
-        select focus.user_id,focus.focus_id,focus.focus_type,focus.create_time as focus_create,dept.pscmc as dept_name,archives.*
+        select focus.user_id,focus.focus_id,focus.focus_type,focus.create_time as focus_create,dept.pscmc as dept_name,
+        (CASE st.is_online WHEN 'ONLINE' THEN 1 WHEN 'OFFLINE' THEN 2 WHEN 'MARK' THEN 3 ELSE 1 END ) AS STATUS,
+        location.kwh,location.location,archives.*
         from ax_beidou_ship_archives archives
-        INNER JOIN ax_beidou_focus_ship focus
-        INNER JOIN ax_beidou_dept dept
-        where archives.devide_no = focus.devide_no and archives.police_station_id = dept.pscbh
-        <if test="shipId != null and shipId != ''">and (archives.ship_id like concat('%', #{shipId},'%') or archives.devide_no like concat('%', #{devideNo},'%'))</if>
+        INNER JOIN ax_beidou_focus_ship focus on archives.devide_no = focus.devide_no
+        INNER JOIN ax_beidou_dept dept on archives.police_station_id = dept.pscbh
+        LEFT JOIN ax_beidou_ship_status st on st.device_id = focus.devide_no
+        LEFT JOIN ax_beidou_ship_location location on focus.devide_no = location.device_id
+        where 1=1
+        <if test="shipId != null and shipId != ''">and (archives.ship_id like concat('%', #{shipId},'%') or archives.devide_no like concat('%', #{shipId},'%'))</if>
         <if test="deptId != null and deptId != ''">and dept.xw_dept_id like concat('%',#{deptId},'%')</if>
         <if test="userId != null and userId != ''">and focus.user_id=#{userId}</if>
         <if test="sortField != null and sortField != ''">ORDER BY ${sortField} </if>

+ 14 - 15
beidou-ship/src/main/resources/mapper/ShipArchivesMapper.xml

@@ -23,7 +23,6 @@
         <result property="ownerType"    column="owner_type"    />
         <result property="lastStatus"    column="status"    />
         <result property="deviceStatus"    column="device_status"    />
-        <result property="locationTime"    column="location_time"    />
         <result property="longitude"    column="longitude"    />
         <result property="latitude"    column="latitude"    />
         <result property="location"    column="location"    />
@@ -109,8 +108,8 @@
     <select id="selectShipArchivesList" parameterType="shipArchivesREQ" resultMap="ShipResult">
         SELECT
         archives.*,
-        ( CASE sta.is_online WHEN 'ONLINE' THEN 1 WHEN 'OFFLINE' THEN 2 WHEN 'MARK' THEN 3 ELSE 1 END ) AS STATUS,
-        ( CASE ISNULL(disp.dispose_type) WHEN 0 THEN disp.dispose_type WHEN 1 THEN 1 END) AS device_status,
+        ( CASE sta.is_online WHEN 'ONLINE' THEN 1 WHEN 'OFFLINE' THEN 2 WHEN 'MARK' THEN dispose_temp.dispose_type ELSE 2 END ) AS STATUS,
+        IFNULL(dispose_temp.dispose_type,'0') as device_status,
         dept.pscmc AS dept_name,
         location.longitude,
         location.latitude,
@@ -121,9 +120,8 @@
         LEFT JOIN ax_beidou_ship_status sta ON archives.devide_no = sta.device_id
         INNER JOIN ax_beidou_dept dept ON archives.police_station_id = dept.pscbh
         LEFT JOIN ax_beidou_ship_location location ON archives.devide_no = location.device_id
-        LEFT JOIN ax_beidou_ship_dispose disp ON archives.devide_no = disp.devide_no
-        <!--LEFT JOIN (select devide_no,max(id) as id from ax_beidou_ship_dispose GROUP BY devide_no) as dispose on dispose.devide_no = archives.devide_no
-        LEFT JOIN ax_beidou_ship_dispose dispose_temp on dispose.id = dispose_temp.id-->
+        LEFT JOIN (select devide_no,max(id) as id from ax_beidou_ship_dispose GROUP BY devide_no) as dispose on dispose.devide_no = archives.devide_no
+        LEFT JOIN ax_beidou_ship_dispose dispose_temp on dispose.id = dispose_temp.id
         where
             1=1
         <if test="shipId != null and shipId != ''">and (archives.ship_id like concat('%', #{shipId},'%') or archives.devide_no like concat('%', #{devideNo},'%'))</if>
@@ -137,14 +135,15 @@
     <select id="selectById" parameterType="string" resultMap="ShipResult">
         select archives.*,
         (CASE sta.is_online WHEN 'ONLINE' THEN 1  WHEN 'OFFLINE' THEN 2 WHEN 'MARK' THEN 3 END) as status,
-        dispose_temp.dispose_type as device_status,location.kwh as kwh,
+        IFNULL(dispose.dispose_type,'0') as device_status,location.kwh as kwh,focus.focus_id as focusId,
         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
         INNER JOIN ax_beidou_dept dept on archives.police_station_id = dept.pscbh
-        LEFT JOIN (select devide_no,max(id) as id from ax_beidou_ship_dispose GROUP BY devide_no) as dispose on dispose.devide_no = archives.devide_no
-        LEFT JOIN ax_beidou_ship_dispose dispose_temp on dispose.id = dispose_temp.id
+        LEFT JOIN (select id,devide_no,dispose_type from ax_beidou_ship_dispose
+        where devide_no=#{devideNo} ORDER BY id DESC limit 1) as dispose on dispose.devide_no = archives.devide_no
         LEFT JOIN ax_beidou_ship_location location on archives.devide_no = location.device_id
+        LEFT JOIN ax_beidou_focus_ship focus on archives.devide_no = focus.devide_no and focus.user_id=#{userId}
         where  archives.devide_no=#{devideNo}
     </select>
 
@@ -153,12 +152,13 @@
             SUM(CASE sta.is_online WHEN 'MARK' THEN 1 ELSE 0 END ) as mark,
             SUM(CASE sta.is_online WHEN 'ONLINE' THEN 1 ELSE 0 END ) as onlineTotal,
             SUM(CASE sta.is_online WHEN 'OFFLINE' THEN 1 ELSE 0 END ) as offlineTotal,
-            SUM(CASE sta.is_inport WHEN 1 THEN 1 ELSE 0 END)  as inport,
-            SUM(CASE sta.is_inport WHEN 0 THEN 1 ELSE 0 END)  as offport
+            SUM(CASE sta.is_inport WHEN 'TRUE' THEN 1 ELSE 0 END)  as inport,
+            SUM(CASE sta.is_inport WHEN 'FALSE' THEN 1 ELSE 0 END)  as offport
             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
             where 1=1
-            <if test="deptId != null and deptId != ''">and sta.dept_id like concat('%',#{deptId},'%')</if>
+            <if test="deptId != null and deptId != ''">and dept.xw_dept_id like concat('%',#{deptId},'%')</if>
     </select>
 
 
@@ -166,10 +166,9 @@
         select dis.id,dis.warning_id,dis.dispose_type,dis.dispose_suggestion,dis.dispose_picture,
          dis.dispose_user_id,dis.dispose_time,record.warning_time from ax_beidou_ship_dispose dis
         inner join ax_beidou_warning_record record on dis.warning_id = record.id
-        <where>
-            <if test="warningId != null and warningId != ''">dis.warning_id = #{warningId}</if>
+        where (record.`start` is null or record.`start` != 'false')
+            <if test="warningId != null and warningId != ''">and dis.warning_id = #{warningId}</if>
             <if test="devideNo != null and devideNo != ''">and record.device_id = #{devideNo}</if>
-        </where>
         ORDER BY dispose_time DESC
         limit 1
     </select>

+ 10 - 4
beidou-ship/src/main/resources/mapper/ShipStatusMapper.xml

@@ -34,6 +34,7 @@
         <result property="numberDay"    column="number_day"    />
         <result property="deviceStatus"    column="device_status"    />
         <result property="status" column="status"/>
+        <result property="lastStatus" column="status"/>
     </resultMap>
 
     <select id="selectById" parameterType="string" resultMap="shipStatusResult">
@@ -42,6 +43,7 @@
         st.is_inport,location.longitude,location.latitude,location.location,st.online_change_time,
 		location.kwh as kwh,
         dept.pscmc as dept_name,
+        IFNULL(dispose.dispose_type,'0') as device_status,
         <if test="isOnline != null and isOnline != ''">
         TIMESTAMPDIFF(DAY,st.online_change_time,NOW()) as number_day
         </if>
@@ -52,6 +54,8 @@
         inner join ax_beidou_ship_archives archives on st.device_id = archives.devide_no
         inner join ax_beidou_dept dept on archives.police_station_id = dept.pscbh
         LEFT JOIN ax_beidou_ship_location location on archives.devide_no = location.device_id
+        LEFT JOIN (select id,devide_no,dispose_type from ax_beidou_ship_dispose
+        where devide_no=#{devideNo} ORDER BY id DESC limit 1) as dispose on dispose.devide_no = archives.devide_no
         where  1=1
         <if test="devideNo != null and devideNo != ''">
             and st.device_id = #{devideNo}
@@ -61,12 +65,13 @@
         </if>
         <if test="isStasis != null and isStasis != ''">
             and st.is_anchor = #{isStasis}
-            and TIMESTAMPDIFF(MINUTE,st.anchor_change_time,NOW())>24*60*7
+--             and TIMESTAMPDIFF(MINUTE,st.anchor_change_time,NOW())>24*60*7
         </if>
     </select>
 
     <select id="selectShipStatusList" parameterType="shipStatusReq" resultMap="shipStatusResult">
-        select archives.*,(CASE st.is_online WHEN 'ONLINE' THEN 1  WHEN 'OFFLINE' THEN 2 WHEN 'MARK' THEN 3 END) as is_online,
+        select archives.*,
+        (CASE st.is_online WHEN 'ONLINE' THEN 1  WHEN 'OFFLINE' THEN 2 WHEN 'MARK' THEN 3 END) as is_online,
         st.is_inport,location.longitude,location.latitude,location.location,
         st.online_change_time ,
         location.kwh as kwh,
@@ -90,7 +95,7 @@
         </if>
         <if test="isStasis != null and isStasis != ''">
             and st.is_anchor = #{isStasis}
-            and TIMESTAMPDIFF(MINUTE,st.anchor_change_time,NOW())>24*60*7
+--             and TIMESTAMPDIFF(MINUTE,st.anchor_change_time,NOW())>24*60*7
         </if>
         <if test="shipId != null and shipId != ''">and (archives.ship_id like concat('%', #{shipId},'%') or archives.devide_no like concat('%', #{devideNo},'%'))</if>
         <if test="deptId != null and deptId != ''">and dept.xw_dept_id like concat('%',#{deptId},'%')</if>
@@ -127,7 +132,8 @@
         <if test="deptId != null and deptId != ''">
         inner join ax_beidou_dept dept on archives.police_station_id = dept.pscbh
         </if>
-        where st.is_anchor='1' and TIMESTAMPDIFF(MINUTE,st.anchor_change_time,NOW())>24*60*7
+        where st.is_anchor='TRUE'
+--         and TIMESTAMPDIFF(MINUTE,st.anchor_change_time,NOW())>24*60*7
         <if test="shipId != null and shipId != ''">and (archives.ship_id like concat('%', #{shipId},'%') or archives.devide_no like concat('%', #{devideNo},'%'))</if>
         <if test="deptId != null and deptId != ''">and dept.xw_dept_id like concat('%',#{deptId},'%')</if>
     </select>

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

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.taiji.beidou.ship.track.mapper.ShipTrackMapper">
+
+    <resultMap type="shipTrackResult" id="shipTrackResult">
+        <id property="id" column="id"/>
+        <result property="deviceId" column="device_id"/>
+        <result property="sendTime" column="send_time"/>
+        <result property="longitude" column="longitude"/>
+        <result property="latitude" column="latitude"/>
+        <result property="direction" column="direction"/>
+        <result property="speed" column="speed"/>
+    </resultMap>
+
+    <select id="selectShipTrackDetail" parameterType="shipTrackReq" resultMap="shipTrackResult">
+        select id,device_id,send_time,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
+    </select>
+</mapper>

+ 51 - 23
beidou-ship/src/main/resources/mapper/ShipWarningModelMapper.xml

@@ -35,34 +35,50 @@
         where  rule.del_flag='0'
         <if test="enabled != null">and rule.enabled = #{enabled}</if>
         <if test="id != null and id != ''">and rule.id = #{id}</if>
+        <if test="ruleName != null and ruleName != ''">and rule.name like concat('%',#{ruleName},'%')</if>
         ORDER BY rule.create_time DESC
     </select>
 
-    <select id="modelList" parameterType="string" resultMap="ruleModelResult">
-        select model.id as id,rm.rule_id as rule_id,model.`name` as model_name,model.code,model.description,model.del_flag
-		from ax_beidou_warning_rule_model rm
-        inner join ax_beidou_warning_model model on model.id = rm.model_id
-        where model.del_flag='0' and rm.rule_id = #{id}
-    </select>
+    <resultMap id="ruleModelResult1" type="warningModelResult">
+        <id property="id" column="id"/>
+        <result property="modelName" column="model_name"/>
+        <result property="code" column="code"/>
+        <result property="description" column="description"/>
+        <collection property="paramList" ofType="warningParamVo"
+                    column="{modelId=id,ruleId=rule_id}">
+            <id property="id" column="param_id"/>
+            <result property="paramProperty" column="param_property"/>
+            <result property="paramName" column="param_name"/>
+            <result property="paramValue" column="param_value"/>
+            <result property="isMust" column="is_must"/>
+            <result property="dictId" column="dict_id"/>
+            <result property="recommend" column="recommend"/>
+        </collection>
 
-    <select id="ruleParamList" resultMap="paramVo">
-        select param.id as param_id,rp.param_value,param.recommend,
-                param.is_must,param.del_flag as param_del_flag,
-                dict.param_code as param_property,dict.param_name,dict.id as dict_id
-        from ax_beidou_warning_model_param mp
-        inner join ax_beidou_warning_rule_model_param rp on mp.param_id = rp.param_id
-        left join ax_beidou_warning_param param on param.id = mp.param_id
+        <collection property="areaList" ofType="warningAreaVo"
+                    column="{modelId=id,ruleId=rule_id}">
+            <id property="id" column="area_id"/>
+            <result property="name" column="area_name"/>
+            <result property="location" column="location"/>
+        </collection>
+    </resultMap>
+
+    <select id="modelList" resultMap="ruleModelResult1">
+        select model.id as id,rm.rule_id as rule_id,model.`name` as model_name,model.code,model.description,model.del_flag,
+                param.id as param_id,rp.param_value,param.recommend,param.is_must,param.del_flag as param_del_flag,
+                dict.param_code as param_property,dict.param_name,dict.id as dict_id,
+                area.id as area_id,area.`name` as area_name,area.location
+        from ax_beidou_warning_rule_model rm
+        inner join ax_beidou_warning_model model on model.id = rm.model_id and model.del_flag = '0'
+        left JOIN ax_beidou_warning_model_param mp on mp.model_id = model.id
+        left join ax_beidou_warning_rule_model_param rp on mp.param_id = rp.param_id and rp.model_id = rm.model_id and rp.rule_id = rm.rule_id
+        left join ax_beidou_warning_param param on param.id = mp.param_id and param.del_flag = '0'
         left join ax_beidou_warning_param_dict dict on param.dict_id = dict.id
-        where param.del_flag = '0' and mp.model_id = #{modelId} and rp.rule_id = #{ruleId}
+        left JOIN ax_beidou_warning_rule_model_area ma on ma.model_id = model.id and ma.rule_id = rm.rule_id
+        left join ax_beidou_warning_area area on area.id = ma.area_id and area.del_flag = '0'
+        where model.del_flag='0' and rm.rule_id = #{id}
     </select>
 
-    <select id="ruleAreaList"  resultMap="areaVo">
-        select area.id as area_id,area.`name` as area_name,area.location,
-        area.del_flag as area_del_flag
-        from ax_beidou_warning_rule_model_area ma
-        left join ax_beidou_warning_area area on area.id = ma.area_id
-        where  area.del_flag = '0' and ma.model_id = #{modelId} and ma.rule_id = #{ruleId}
-    </select>
     <!--预警规则列表 end-->
 
 
@@ -99,6 +115,7 @@
 		from ax_beidou_warning_model model
         where model.del_flag='0'
         <if test="id != null and id != ''">and model.id = #{id}</if>
+        <if test="modelName != null and modelName != ''">and model.name like concat('%',#{modelName},'%')</if>
         ORDER BY model.create_time DESC
     </select>
 
@@ -429,16 +446,27 @@
     </delete>
 
     <select id="selectWarningModelByName" parameterType="string" resultType="integer">
-        select count(*) from ax_beidou_warning_model where `name` = #{modelName}
+        select count(*) from ax_beidou_warning_model where del_flag = '0' and `name` = #{modelName}
         <if test="id != null and id != ''">
             and id != #{id}
         </if>
     </select>
 
     <select id="selectWarningRuleByName" parameterType="string" resultType="integer">
-        select count(*) from ax_beidou_warning_rule where `name` = #{ruleName}
+        select count(*) from ax_beidou_warning_rule where del_flag = '0' and `name` = #{ruleName}
         <if test="id != null and id != ''">
             and id != #{id}
         </if>
     </select>
+
+    <!--按勾选区域查询预警区域-->
+    <select id="findInId" parameterType="string" resultType="warningAreaVo">
+        select id,`name`,location from ax_beidou_warning_area
+        where del_flag = '0'
+        and id in
+        <foreach collection="array" index="index" item="item" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
+
 </mapper>

+ 7 - 6
beidou-ship/src/main/resources/mapper/WarningRecordMapper.xml

@@ -39,12 +39,13 @@
         INNER JOIN ax_beidou_dept dept ON archives.police_station_id = dept.pscbh
         </if>
         <where>
-            record.rule_id = #{ruleId}
+            record.rule_id = #{ruleId} and (record.`start` is null or record.`start` != 'false')
             <if test="deptId != null and deptId != ''">
                 and dept.xw_dept_id like concat('%',#{deptId},'%')
             </if>
             <if test="shipId != null and shipId != ''">
-                and archives.ship_id like concat('%',#{shipId},'%')
+                and (archives.ship_id like concat('%',#{shipId},'%')
+                or archives.devide_no like concat('%',#{shipId},'%'))
             </if>
             <if test="startTime != null and startTime != ''">and record.warning_time &gt; #{startTime}</if>
             <if test="endTime != null and endTime != ''">and record.warning_time &lt; #{endTime}</if>
@@ -56,7 +57,7 @@
        select record.id,warning_time as warningTime,dis.id as disposeId
         from ax_beidou_warning_record record
         LEFT JOIN ax_beidou_ship_dispose dis ON dis.warning_id = record.id
-        where record.device_id = #{devideNo} and record.rule_id = #{ruleId} ORDER BY warning_time DESC
+        where record.device_id = #{devideNo} and record.rule_id = #{ruleId} and (record.`start` is null or record.`start` != 'false') ORDER BY warning_time DESC
     </select>
 
     <select id="warningRecordExcel" parameterType="string" resultType="warningRecordExcel">
@@ -67,7 +68,7 @@
         INNER JOIN ax_beidou_dept dept ON archives.police_station_id = dept.pscbh
         LEFT JOIN ax_beidou_ship_location location ON location.device_id = record.device_id
         <where>
-            record.rule_id = #{ruleId}
+            record.rule_id = #{ruleId} and (record.`start` is null or record.`start` != 'false')
             <if test="deptId != null and deptId != ''">
                 and dept.xw_dept_id = #{deptId}
             </if>
@@ -104,8 +105,8 @@
     </select>
 
     <select id="getRecordById" parameterType="string" resultType="warningRecordData">
-        select id,rule_id as ruleId, model_id as modelId,warning_time as warningTime,device_id as deviceId from ax_beidou_warning_record where id = #{id}
+        select id,rule_id as ruleId, model_id as modelId,warning_time as warningTime,device_id as deviceId
+        from ax_beidou_warning_record where id = #{id} and (`start` is null or `start` != 'false')
     </select>
 
-
 </mapper>