Browse Source

:sparkles: 非现场执法

lag 1 year ago
parent
commit
4b3ed68426

+ 102 - 0
ghjg-item-server/src/main/java/com/shanghaichengdi/ghjgitem/controller/OffSiteEnforcementController.java

@@ -0,0 +1,102 @@
+package com.shanghaichengdi.ghjgitem.controller;
+
+import static com.shanghaigeography.Util.DateUtils.dateToString;
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.fastjson.JSONObject;
+import com.shanghaichengdi.ghjgitem.controller.model.res.OffSiteEnforcementTo;
+import com.shanghaichengdi.ghjgitem.enums.OutsideInterface;
+import com.shanghaichengdi.ghjgitem.service.IOffSiteEnforcementService;
+import com.shanghaichengdi.ghjgitem.util.CommonTools;
+import com.shanghaichengdi.ghjgitem.vo.OffSiteEnforcementVo;
+import com.shanghaigeography.entity.ResultMsg;
+import com.shanghaigeography.eum.ResultState;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import java.io.File;
+import java.util.*;
+import javax.annotation.Resource;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author gengaoliu
+ */
+@Api("非现场执法")
+@RestController
+@CrossOrigin
+@RequestMapping("/ghjg/offeSiteEnforcement")
+public class OffSiteEnforcementController {
+  @Resource
+  IOffSiteEnforcementService offSiteEnforcementService;
+  String ghjgFileservice = OutsideInterface.GHJG_FILE_SERVICE.getUrlString();
+  String url = OutsideInterface.GHJG_FILE_LOAD.getUrlString();
+
+  @PostMapping("/getAllPage")
+  @ApiOperation("非现场执法报表")
+  public String getAllPage(@RequestBody Map<String, Object> map) {
+    List<OffSiteEnforcementVo> voList = offSiteEnforcementService.getAllPage(map);
+    int count = CommonTools.getTotal(voList);
+    if (CollectionUtils.isEmpty(voList)) {
+      return new ResultMsg<String>()
+          .setCode(ResultState.ERROR_NEEDDATA)
+          .setMsg("暂无数据")
+          .setData(null)
+          .toJSON();
+    }
+    return new ResultMsg<String>()
+        .setCode(ResultState.SUCCESS)
+        .setMsg(String.valueOf(count))
+        .setData(JSONObject.toJSONString(voList))
+        .toJSON();
+  }
+
+  @ApiOperation("非现场执法报表导出")
+  @PostMapping("/getExcel")
+  public String getExcel(@RequestBody Map<String, Object> map) {
+    String newye = dateToString(new Date(), "yyyy");
+    long s = System.nanoTime();
+    String tkk =
+        url
+            + "supervise/shipIdentification/rectify/"
+            + newye
+            + "/"
+            + dateToString(new Date(), "MM")
+            + "/excel/";
+    new File(tkk).mkdirs();
+    String towofile = tkk + s + "非现场执法报表信息.xlsx";
+    List<OffSiteEnforcementTo> toList = new ArrayList<>();
+    map.replace("size", 50000);
+    JSONObject j = JSONObject.parseObject(this.getAllPage(map));
+    if (!"无数据".equals(j.get("msg"))) {
+      int i = 1;
+      List<OffSiteEnforcementVo> enforcementVoList =
+          j.getJSONArray("data").toJavaList(OffSiteEnforcementVo.class);
+      for (OffSiteEnforcementVo vo : enforcementVoList) {
+        OffSiteEnforcementTo enforcementTo = new OffSiteEnforcementTo();
+        BeanUtils.copyProperties(vo, enforcementTo);
+        enforcementTo.setNum(i);
+        toList.add(enforcementTo);
+        i++;
+      }
+    }
+    if (toList.size() >= 8000) {
+      return new ResultMsg<String>()
+          .setCode(ResultState.ERROR_NEEDDATA)
+          .setMsg("导出数量庞大,请选择条件以缩小导出范围")
+          .toJSON();
+    }
+    EasyExcel.write(towofile, OffSiteEnforcementTo.class).sheet("非现场执法报表信息").doWrite(() -> toList);
+    String pdfUrl = towofile.replace(url.replace("/test", ""), (ghjgFileservice + "supervise/"));
+    return new ResultMsg<String>().setCode(ResultState.SUCCESS).setMsg(pdfUrl).toJSON();
+  }
+
+
+  @GetMapping("getPicture/{warnCode}")
+  @ApiOperation("获取【船舶监控")
+  @ResponseBody
+  public String GetPicture(@PathVariable("warnCode") String warnCode) {
+    return offSiteEnforcementService.getPicture(warnCode);
+  }
+}

+ 47 - 0
ghjg-item-server/src/main/java/com/shanghaichengdi/ghjgitem/controller/model/res/OffSiteEnforcementTo.java

@@ -0,0 +1,47 @@
+package com.shanghaichengdi.ghjgitem.controller.model.res;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+
+/**
+ * @author gengaoliu
+ */
+@Data
+public class OffSiteEnforcementTo {
+  @ExcelProperty({"非现场执法报表信息", "序号"})
+  private Integer num;
+
+  @ExcelProperty({"非现场执法报表信息", "预警编号"})
+  private String warnCode;
+
+  @ExcelProperty({"非现场执法报表信息", "预警时间"})
+  private String warnTime;
+
+  @ExcelProperty({"非现场执法报表信息", "船舶名称"})
+  private String boatName;
+
+  @ExcelProperty({"非现场执法报表信息", "预警类型"})
+  private String warnType;
+
+  @ExcelProperty({"非现场执法报表信息", "船舶所有人"})
+  private String shipOwner;
+
+  @ExcelProperty({"非现场执法报表信息", "联系电话"})
+  private String ownerPhone;
+
+  @ExcelProperty({"非现场执法报表信息", "卡口名称"})
+  private String bayonetName;
+
+  @ExcelProperty({"非现场执法报表信息", "航向"})
+  private String direction;
+
+  @ExcelProperty({"非现场执法报表信息", "船舶类型"})
+  private String shipType;
+
+  @ExcelProperty({"非现场执法报表信息", "覆盖率"})
+  private String coverage;
+
+  @ExcelProperty({"非现场执法报表信息", "是否推送总队"})
+  private String pushStatus;
+}

+ 21 - 0
ghjg-item-server/src/main/java/com/shanghaichengdi/ghjgitem/mapper/OffSiteEnforcementMapper.java

@@ -0,0 +1,21 @@
+package com.shanghaichengdi.ghjgitem.mapper;
+
+
+import com.shanghaichengdi.ghjgitem.domain.Video;
+import com.shanghaichengdi.ghjgitem.vo.OffSiteEnforcementVo;
+import java.util.List;
+import java.util.Map;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @author gengaoliu
+ */
+@Mapper
+public interface OffSiteEnforcementMapper {
+
+  List<OffSiteEnforcementVo> getAllPageFromCoverage(Map<String, Object> info);
+  List<OffSiteEnforcementVo> getAllPageFromFlag(Map<String, Object> info);
+  List<OffSiteEnforcementVo> getAllPage(Map<String, Object> info);
+
+  Video getPicture(String warnCode);
+}

+ 16 - 0
ghjg-item-server/src/main/java/com/shanghaichengdi/ghjgitem/service/IOffSiteEnforcementService.java

@@ -0,0 +1,16 @@
+package com.shanghaichengdi.ghjgitem.service;
+
+
+import com.shanghaichengdi.ghjgitem.vo.OffSiteEnforcementVo;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author gengaoliu
+ */
+public interface IOffSiteEnforcementService {
+
+    List<OffSiteEnforcementVo> getAllPage(Map<String, Object> map);
+
+    String getPicture(String warnCode);
+}

+ 51 - 0
ghjg-item-server/src/main/java/com/shanghaichengdi/ghjgitem/service/impl/OffSiteEnforcementServiceImpl.java

@@ -0,0 +1,51 @@
+package com.shanghaichengdi.ghjgitem.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.shanghaichengdi.ghjgitem.domain.Video;
+import com.shanghaichengdi.ghjgitem.mapper.OffSiteEnforcementMapper;
+import com.shanghaichengdi.ghjgitem.service.IOffSiteEnforcementService;
+import com.shanghaichengdi.ghjgitem.vo.OffSiteEnforcementVo;
+import com.shanghaigeography.entity.ResultMsg;
+import com.shanghaigeography.eum.ResultState;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import javax.annotation.Resource;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author gengaoliu
+ */
+@Service
+public class OffSiteEnforcementServiceImpl implements IOffSiteEnforcementService {
+
+  @Resource
+  OffSiteEnforcementMapper mapper;
+
+  @Override
+  public List<OffSiteEnforcementVo> getAllPage(Map<String, Object> info) {
+    PageHelper.startPage((int) info.get("current"), (int) info.get("size"));
+    return mapper.getAllPage(info);
+  }
+
+  @Override
+  public String getPicture(String warnCode) {
+    Optional<Video> videoOptional = Optional.ofNullable(mapper.getPicture(warnCode));
+    if (!videoOptional.isPresent()) {
+      return new ResultMsg<String>()
+          .setCode(ResultState.ERROR_NEEDDATA)
+          .setMsg("该船舶没有对应的图片信息")
+          .toJSON();
+    }
+    String photoName = videoOptional.get().getPhotoname();
+    String[] split = photoName.split(";");
+    List<String> photoUrl = Arrays.stream(split).collect(Collectors.toList());
+    return new ResultMsg<String>()
+        .setCode(ResultState.SUCCESS)
+        .setData(JSONObject.toJSONString(photoUrl))
+        .toJSON();
+  }
+}

+ 123 - 0
ghjg-item-server/src/main/java/com/shanghaichengdi/ghjgitem/vo/OffSiteEnforcementVo.java

@@ -0,0 +1,123 @@
+package com.shanghaichengdi.ghjgitem.vo;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author gengaoliu
+ */
+@AllArgsConstructor
+@NoArgsConstructor
+public class OffSiteEnforcementVo {
+
+  String boatName;
+  String time;
+  String shipOwner;
+  String ownerPhone;
+  String bayonetName;
+  String direction;
+  String shipType;
+  String coverage;
+  String pushStatus;
+  String siteType;
+
+  public String getBoatName() {
+    return boatName;
+  }
+
+  public void setBoatName(String boatName) {
+    this.boatName = boatName;
+  }
+
+  public String getTime() {
+    return time;
+  }
+
+  public void setTime(String time) {
+    this.time = time;
+  }
+
+  public String getShipOwner() {
+    return shipOwner;
+  }
+
+  public void setShipOwner(String shipOwner) {
+    this.shipOwner = shipOwner;
+  }
+
+  public String getOwnerPhone() {
+    return ownerPhone;
+  }
+
+  public void setOwnerPhone(String ownerPhone) {
+    this.ownerPhone = ownerPhone;
+  }
+
+  public String getBayonetName() {
+    return bayonetName;
+  }
+
+  public void setBayonetName(String bayonetName) {
+    this.bayonetName = bayonetName;
+  }
+
+  public String getDirection() {
+    return direction;
+  }
+
+  public void setDirection(String direction) {
+    this.direction = direction;
+  }
+
+  public String getShipType() {
+    return shipType;
+  }
+
+  public void setShipType(String shipType) {
+    this.shipType = shipType;
+  }
+
+  public String getCoverage() {
+    return coverage;
+  }
+
+  public void setCoverage(String coverage) {
+    this.coverage = BigDecimal.valueOf(Double.parseDouble(coverage))
+        .multiply(BigDecimal.valueOf(100)).setScale(2,
+            RoundingMode.HALF_UP).toString() + "%";
+  }
+
+  public String getPushStatus() {
+    return pushStatus;
+  }
+
+  public void setPushStatus(String pushStatus) {
+    this.pushStatus = pushStatus;
+  }
+
+  public String getSiteType() {
+    return siteType;
+  }
+
+  public void setSiteType(String siteType) {
+    this.siteType = siteType;
+  }
+
+  @Override
+  public String toString() {
+    return "OffSiteEnforcementVo{" +
+        "boatName='" + boatName + '\'' +
+        ", time='" + time + '\'' +
+        ", shipOwner='" + shipOwner + '\'' +
+        ", ownerPhone='" + ownerPhone + '\'' +
+        ", bayonetName='" + bayonetName + '\'' +
+        ", direction='" + direction + '\'' +
+        ", shipType='" + shipType + '\'' +
+        ", coverage='" + coverage + '\'' +
+        ", pushStatus='" + pushStatus + '\'' +
+        ", siteType='" + siteType + '\'' +
+        '}';
+  }
+}

+ 113 - 0
ghjg-item-server/src/main/resources/mapper/OffSiteEnforcementMapper.xml

@@ -0,0 +1,113 @@
+<?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="com.shanghaichengdi.ghjgitem.mapper.OffSiteEnforcementMapper">
+    <select id="getAllPageFromCoverage" resultType="com.shanghaichengdi.ghjgitem.vo.ForecastOfIncomingShipsVo">
+      select info.BOAT_NAME boatName,
+      off.CREATE_TIME time,
+      mvw.SHIP_OWNER_CN shipOwner,
+      mvw.OWNER_CONTACT_PHONE ownerPhone,
+      mvw.SHIP_TYPE_NAME shipType,
+      decode(info.DIRECTION, 1, '出沪', 2, '入沪') direction,
+      decode(info.BAYONET_ID, '1', '杭申线卡口', '2', '长湖申线卡口','3','大治河船闸') bayonetName,
+      off.CONF coverage,
+      decode(site.AUDIT_STATUS, 1, '是', 2, '否') pushStatus
+      from BAYONET_DYNAMIC.COVERAGE_ANALYSIS off
+      left join bayonet_dynamic.DATAFUSION info on info.CODE = off.EVENT_CODE
+      left join ghjg_basics.mvw_boat_info mvw on mvw.SHIP_NAME_CN = info.BOAT_NAME
+      left join BAYONET_BUSSINESS.OFF_SITE_CASE site on site.SHIP_ID = mvw.SHIP_ID
+      where info.BOAT_NAME is not null
+      <if test="startTime !='' and startTime!=null">
+        and off.CREATE_TIME >= to_date(#{startTime},'yyyy-mm-dd hh24:mi:ss')
+      </if>
+      <if test="endTime !='' and endTime!=null">
+        and off.CREATE_TIME &lt;= to_date(#{endTime},'yyyy-mm-dd hh24:mi:ss')
+      </if>
+      <if test="shipName !='' and shipName!=null">
+        and info.BOAT_NAME like '%' || #{shipName} ||'%'
+      </if>
+      <if test="bayonetName !='' and bayonetName!=null">
+        and info.BAYONET_ID = #{bayonetName}
+      </if>
+      <if test="shipType !='' and shipType!=null">
+        and mvw.SHIP_TYPE_CODE = #{shipType}
+      </if>
+      order by off.CREATE_TIME desc
+    </select>
+
+    <select id="getAllPageFromFlag" resultType="com.shanghaichengdi.ghjgitem.vo.ForecastOfIncomingShipsVo">
+      select info.BOAT_NAME boatName,
+      off.CREATE_TIME time,
+      mvw.SHIP_OWNER_CN shipOwner,
+      mvw.OWNER_CONTACT_PHONE ownerPhone,
+      mvw.SHIP_TYPE_NAME shipType,
+      decode(info.DIRECTION, 1, '出沪', 2, '入沪') direction,
+      decode(info.BAYONET_ID, '1', '杭申线卡口', '2', '长湖申线卡口','3','大治河船闸') bayonetName,
+      decode(site.AUDIT_STATUS, 1, '是', 2, '否') pushStatus
+      from BAYONET_DYNAMIC.FLAG_ANALYSIS off
+      left join bayonet_dynamic.DATAFUSION info on info.CODE = off.EVENT_CODE
+      left join ghjg_basics.mvw_boat_info mvw on mvw.SHIP_NAME_CN = info.BOAT_NAME
+      left join BAYONET_BUSSINESS.OFF_SITE_CASE site on site.SHIP_ID = mvw.SHIP_ID
+      where info.BOAT_NAME is not null
+      <if test="startTime !='' and startTime!=null">
+        and off.CREATE_TIME >= to_date(#{startTime},'yyyy-mm-dd hh24:mi:ss')
+      </if>
+      <if test="endTime !='' and endTime!=null">
+        and off.CREATE_TIME &lt;= to_date(#{endTime},'yyyy-mm-dd hh24:mi:ss')
+      </if>
+      <if test="shipName !='' and shipName!=null">
+        and info.BOAT_NAME like '%' || #{shipName} ||'%'
+      </if>
+      <if test="bayonetName !='' and bayonetName!=null">
+        and info.BAYONET_ID = #{bayonetName}
+      </if>
+      <if test="shipType !='' and shipType!=null">
+        and mvw.SHIP_TYPE_CODE = #{shipType}
+      </if>
+      order by off.CREATE_TIME desc
+    </select>
+
+
+
+    <select id="getAllPage" resultType="com.shanghaichengdi.ghjgitem.vo.ForecastOfIncomingShipsVo">
+      select mvw.SHIP_NAME_CN boatName,
+      T.SHIP_OWNER shipOwner,
+      T.CONTACT_PHONE ownerPhone,
+      decode(T.TYPE, 1, '国旗悬挂', 2, '货物覆盖') siteType,
+      T.CREATE_TIME time,
+      decode(info.DIRECTION, 1, '出沪', 2, '入沪') direction,
+      decode(info.BAYONET_ID, '1', '杭申线卡口', '2', '长湖申线卡口','3','大治河船闸') bayonetName,
+      T.COVERAGE coverage,
+      decode(T.AUDIT_STATUS, 1, '是', 2, '否') pushStatus
+      from BAYONET_BUSSINESS.OFF_SITE_CASE T
+      left join ghjg_basics.mvw_boat_info mvw on T.SHIP_ID = T.SHIP_ID
+      left join bayonet_dynamic.DATAFUSION info on info.CODE = T.EVENT_CODE
+      where mvw.SHIP_NAME_CN is not null
+      <if test="startTime !='' and startTime!=null">
+        and T.CREATE_TIME >= to_date(#{startTime},'yyyy-mm-dd hh24:mi:ss')
+      </if>
+      <if test="endTime !='' and endTime!=null">
+        and T.CREATE_TIME &lt;= to_date(#{endTime},'yyyy-mm-dd hh24:mi:ss')
+      </if>
+      <if test="shipName !='' and shipName!=null">
+        and info.BOAT_NAME like '%' || #{shipName} ||'%'
+      </if>
+      <if test="bayonetName !='' and bayonetName!=null">
+        and info.BAYONET_ID = #{bayonetName}
+      </if>
+      <if test="shipType !='' and shipType!=null">
+        and mvw.SHIP_TYPE_CODE = #{shipType}
+      </if>
+      order by T.CREATE_TIME desc
+    </select>
+
+    <select id="getPicture" resultType="com.shanghaichengdi.ghjgitem.domain.Video">
+        select t.PHOTONAME
+        from BAYONET_DYNAMIC.VIDEO_ANALYSIS t
+        left join BAYONET_BUSSINESS.BOAT_WARNING warn on warn.EVENTCODE = t.EVENTCODE
+        where 1=1
+        <if test="warnCode !='' and warnCode!=null">
+            and warn.warnCode = #{warnCode}
+        </if>
+    </select>
+</mapper>