Browse Source

浦东新增船舶联系人查询接口:根据mmsi批量查询48小时内进出港申报和船舶所有人联系电话

sbj 2 months ago
parent
commit
5f64b78727

+ 28 - 0
ghjg-item-datashare-server/src/main/java/com/shanghaichengdi/ghjgitem/controller/BoatController.java

@@ -6,6 +6,7 @@ import com.shanghaichengdi.ghjgitem.constant.HttpStatus;
 import com.shanghaichengdi.ghjgitem.exception.EnumException;
 import com.shanghaichengdi.ghjgitem.service.CommonService;
 import com.shanghaichengdi.ghjgitem.util.CommonTools;
+import com.shanghaichengdi.ghjgitem.util.PrintLogUtils;
 import com.shanghaichengdi.ghjgitem.vo.*;
 import com.shanghaichengdi.ghjgitem.vo.request.BoatAisRealTimeReq;
 import com.shanghaichengdi.ghjgitem.vo.request.BoatPathReq;
@@ -168,6 +169,33 @@ public class BoatController extends CommonController {
     return ReturnMsg.success("获取成功", encodedData);
   }
 
+  @PostMapping("/getBoatContactByMmsi")
+  public ReturnMsg getBoatContactByMmsi(@RequestBody @Validated ObjectBodyVo vo){
+    try{
+      if (!checkDbKey(vo.getKey())) {
+        return ReturnMsg.error(HttpStatus.BAD_REQUEST, "key值有误,请确认您输入的key值正确!");
+      }
+      String paramJsonData = getParamJsonData(vo.getData());
+      ShipDataRequest req = JSONObject.parseObject(paramJsonData, ShipDataRequest.class);
+      log.info("Request参数值为:{}",req);
+      // 判断只能查当前在浦东范围内有AIS信号的船
+//      if(!commonService.checkInportByShipId(req.getShipId())){
+//        throw new EnumException("该船舶不在辖区内");
+//      }
+      List<BoatContactVo> voList = commonService.selectBoatContactByMmsi(req);
+      ResultRes resultRes = ResultRes.encapsulationResult(req.getPageIndex(),
+          req.getPageSize(),
+          CommonTools.getTotal(voList), voList);
+      String jsonString = JSONObject.toJSONString(resultRes);
+      String encodedData = resultEncode(jsonString);
+      return ReturnMsg.success("获取成功", encodedData);
+    }catch (Exception e){
+      PrintLogUtils.printErrorLogInfo(e,"getBoatContactByMmsi服务异常:");
+      return ReturnMsg.error(HttpStatus.BAD_REQUEST, "服务异常");
+    }
+
+  }
+
 
   @PostMapping("/getRangeCount")
   public ReturnMsg getRangeCount(@RequestBody @Validated ObjectBodyVo vo) {

+ 2 - 0
ghjg-item-datashare-server/src/main/java/com/shanghaichengdi/ghjgitem/mapper/CommonMapper.java

@@ -30,6 +30,8 @@ public interface CommonMapper {
 
   List<ShipDataVo> selectBoatInfoList(ShipDataRequest param);
 
+  List<ShipDataVo> selectBoatContactInfoByMmsi(ShipDataRequest param);
+
   List<BoatReportInfoVo> selectBoatReportInfoList(@Param("reportId") String reportId,
       @Param("region") String area, @Param("district") String district,
       @Param("shipId") String shipId, @Param("startTime") String startTime,

+ 2 - 0
ghjg-item-datashare-server/src/main/java/com/shanghaichengdi/ghjgitem/service/CommonService.java

@@ -26,6 +26,8 @@ public interface CommonService {
 
   List<BoatReportInfoVo> selectBoatReportInfoList(ReportInfoRequest param) throws ParseException;
 
+  List<BoatContactVo> selectBoatContactByMmsi(ShipDataRequest param) throws  Exception;
+
   List<ShipDataVo> obscureSelectBoatInfoList(ShipDataRequest req);
 
   CountVo getRangeCount(ShipRangeReq req);

+ 51 - 2
ghjg-item-datashare-server/src/main/java/com/shanghaichengdi/ghjgitem/service/impl/CommonServiceImpl.java

@@ -144,8 +144,8 @@ public class CommonServiceImpl implements CommonService {
     @Override
     public List<BoatReportInfoVo> selectBoatReportInfoList(ReportInfoRequest param)
             throws ParseException {
-        String startTime = param.getDateTo() + " 00:00:00";
-        String endTime = param.getDateFrom() + " 23:59:59";
+        String startTime = param.getDateFrom() + " 00:00:00";
+        String endTime = param.getDateTo() + " 23:59:59";
 //        String partition = "SHIP_REPORT_" + DateUtils.dateToString(
 //                DateUtils.stringToDate(param.getDateFrom(), DateUtils.DATE_FORMAT_10),
 //                DateUtils.DATE_FORMAT_11);
@@ -174,6 +174,55 @@ public class CommonServiceImpl implements CommonService {
                 param.getReportNo());
     }
 
+    @Override
+    public List<BoatContactVo> selectBoatContactByMmsi(ShipDataRequest param) throws Exception{
+        String[] mmsis = param.getMmsi().split(",");
+        if (mmsis != null && mmsis.length > 1){
+            if(mmsis.length > 500){
+                throw new EnumException("mmsi批量查询不得超过500条");
+            }
+            List<String> mmsiList = Arrays.asList(mmsis);
+            for(int i=0; i<mmsiList.size();i++){
+                mmsiList.set(i, "'" + mmsiList.get(i) + "'");
+            }
+            param.setMmsiList(mmsiList);
+            param.setMmsi("");
+        }
+
+        PageHelper.startPage(param.getPageIndex(), param.getPageSize());
+        List<ShipDataVo> shipDataVoList = mapper.selectBoatContactInfoByMmsi(param);
+        log.info("匹配到船舶基础信息:{}",shipDataVoList.toString());
+
+        List<BoatContactVo> baotContactList =new ArrayList<>();
+        for(ShipDataVo shipDataVo : shipDataVoList){
+            BoatContactVo boatContactVo = new BoatContactVo();
+            ReportInfoRequest reportReq = new ReportInfoRequest();
+            reportReq.setShipId(shipDataVo.getShipId());
+            reportReq.setPageIndex(1);
+            reportReq.setPageSize(1);
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(new Date());
+            calendar.set(Calendar.HOUR_OF_DAY, -48);
+            reportReq.setDateFrom(DateUtils.dateToString(calendar.getTime(), DateUtils.DATE_FORMAT_10));
+            reportReq.setDateTo(DateUtils.dateToString(new Date(), DateUtils.DATE_FORMAT_10));
+            List<BoatReportInfoVo> reportVoList = selectBoatReportInfoList(reportReq);
+
+            boatContactVo.setMmsi(shipDataVo.getMmsi());
+            boatContactVo.setShipId(shipDataVo.getShipId());
+            if(!reportVoList.isEmpty()){
+                boatContactVo.setContact(reportVoList.get(0).getBidName());
+                boatContactVo.setPhone(reportVoList.get(0).getMobilePhone());
+            }else{
+                boatContactVo.setContact(shipDataVo.getOwnerLegalPerson());
+                boatContactVo.setPhone(shipDataVo.getOwnerContactPhone());
+            }
+
+            baotContactList.add(boatContactVo);
+        }
+
+        return baotContactList;
+    }
+
     @Override
     public List<ShipDataVo> obscureSelectBoatInfoList(ShipDataRequest param) {
         param.setPageIndex(1);

+ 29 - 0
ghjg-item-datashare-server/src/main/java/com/shanghaichengdi/ghjgitem/vo/BoatContactVo.java

@@ -0,0 +1,29 @@
+package com.shanghaichengdi.ghjgitem.vo;
+
+import lombok.Data;
+
+@Data
+public class BoatContactVo {
+
+  /**
+   * 船主mmsi
+   */
+  String mmsi;
+
+  /**
+   * 船舶识别号
+   */
+  String shipId;
+
+
+  /**
+   * 联系人
+   */
+  String contact;
+
+  /**
+   * 联系方式
+   */
+  String phone;
+
+}

+ 14 - 0
ghjg-item-datashare-server/src/main/resources/mapper/CommonMapper.xml

@@ -177,6 +177,19 @@
     </where>
   </select>
 
+    <select id="selectBoatContactInfoByMmsi" resultType="com.shanghaichengdi.ghjgitem.vo.ShipDataVo">
+        select
+        T.SHIP_ID shipId,
+        T.MMSI mmsi,
+        T.OWNER_LEGAL_PERSON ownerLegalPerson,
+        T.OWNER_CONTACT_PHONE ownerContactPhone
+        from GHJG_BASICS.MVW_BOAT_INFO T
+        where T.MMSI in
+            <foreach collection="mmsiList" index="index" item="item" open="(" close=")" separator=",">
+                ${item}
+            </foreach>
+    </select>
+
   <select id="obscureSelectBoatInfoList" resultType="com.shanghaichengdi.ghjgitem.vo.ShipDataVo">
     select *
     from (select T.SHIP_NAME_CN                                                        shipNameCn,
@@ -371,6 +384,7 @@
       from GHJG_BASICS.MVW_BOAT_INFO t
       where SHIP_ID = #{shipId}
   </select>
+
     <select id="selectCargoDeclareInfoByShipId"
             resultType="com.shanghaichengdi.ghjgitem.vo.CargoInfoForShipLockVo">
         select * from (