<?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.HyDangerPreDeclareNhMapper">

  <resultMap id="BaseResultMap" type="com.shanghaichengdi.ghjgitem.domain.HyDangerPreDeclareNh">
    <result property="id" column="ID" jdbcType="VARCHAR"/>
    <result property="maker" column="MAKER" jdbcType="VARCHAR"/>
    <result property="makeDate" column="MAKE_DATE" jdbcType="TIMESTAMP"/>
    <result property="makeProject" column="MAKE_PROJECT" jdbcType="VARCHAR"/>
    <result property="connects" column="CONNECTS" jdbcType="VARCHAR"/>
    <result property="connectNo" column="CONNECT_NO" jdbcType="VARCHAR"/>
    <result property="explanations" column="EXPLANATIONS" jdbcType="VARCHAR"/>
    <result property="declareCode" column="DECLARE_CODE" jdbcType="VARCHAR"/>
    <result property="unitCode" column="UNIT_CODE" jdbcType="VARCHAR"/>
    <result property="consigner" column="CONSIGNER" jdbcType="VARCHAR"/>
    <result property="shipName" column="SHIP_NAME" jdbcType="VARCHAR"/>
    <result property="voyageNumberCode" column="VOYAGE_NUMBER_CODE" jdbcType="VARCHAR"/>
    <result property="address" column="ADDRESS" jdbcType="VARCHAR"/>
    <result property="fromPortCode" column="FROM_PORT_CODE" jdbcType="VARCHAR"/>
    <result property="toPortCode" column="TO_PORT_CODE" jdbcType="VARCHAR"/>
    <result property="preStartDate" column="PRE_START_DATE" jdbcType="TIMESTAMP"/>
    <result property="preEndDate" column="PRE_END_DATE" jdbcType="TIMESTAMP"/>
    <result property="packCode" column="PACK_CODE" jdbcType="VARCHAR"/>
    <result property="handleMode" column="HANDLE_MODE" jdbcType="VARCHAR"/>
    <result property="addInfo" column="ADD_INFO" jdbcType="VARCHAR"/>
    <result property="emergencyCode" column="EMERGENCY_CODE" jdbcType="VARCHAR"/>
    <result property="declareUnit" column="DECLARE_UNIT" jdbcType="VARCHAR"/>
    <result property="declareDate" column="DECLARE_DATE" jdbcType="TIMESTAMP"/>
    <result property="emergencyLinkTelNo" column="EMERGENCY_LINK_TEL_NO" jdbcType="VARCHAR"/>
    <result property="checkUnitCode" column="CHECK_UNIT_CODE" jdbcType="VARCHAR"/>
    <result property="checker" column="CHECKER" jdbcType="VARCHAR"/>
    <result property="checkerFlag" column="CHECKER_FLAG" jdbcType="VARCHAR"/>
    <result property="checkDate" column="CHECK_DATE" jdbcType="TIMESTAMP"/>
    <result property="revoker" column="REVOKER" jdbcType="VARCHAR"/>
    <result property="revokerDate" column="REVOKER_DATE" jdbcType="TIMESTAMP"/>
    <result property="declarer" column="DECLARER" jdbcType="VARCHAR"/>
    <result property="transportType" column="TRANSPORT_TYPE" jdbcType="VARCHAR"/>
    <result property="transportDesc" column="TRANSPORT_DESC" jdbcType="VARCHAR"/>
    <result property="state" column="STATE" jdbcType="VARCHAR"/>
    <result property="addoperation" column="ADDOPERATION" jdbcType="VARCHAR"/>
    <result property="addtime" column="ADDTIME" jdbcType="TIMESTAMP"/>
    <result property="updateoperation" column="UPDATEOPERATION" jdbcType="VARCHAR"/>
    <result property="updatetime" column="UPDATETIME" jdbcType="TIMESTAMP"/>
    <result property="isremove" column="ISREMOVE" jdbcType="VARCHAR"/>
    <result property="declareType" column="DECLARE_TYPE" jdbcType="VARCHAR"/>
    <result property="approvalNumber" column="APPROVAL_NUMBER" jdbcType="VARCHAR"/>
    <result property="prerecordNo" column="PRERECORD_NO" jdbcType="VARCHAR"/>
    <result property="unlocker" column="UNLOCKER" jdbcType="VARCHAR"/>
    <result property="unlockTime" column="UNLOCK_TIME" jdbcType="TIMESTAMP"/>
    <result property="pid" column="PID" jdbcType="VARCHAR"/>
    <result property="version" column="VERSION" jdbcType="DECIMAL"/>
    <result property="itemId" column="ITEM_ID" jdbcType="VARCHAR"/>
    <result property="checkOption" column="CHECK_OPTION" jdbcType="VARCHAR"/>
    <result property="isSpotCheck" column="IS_SPOT_CHECK" jdbcType="DECIMAL"/>
    <result property="declareTotalTon" column="DECLARE_TOTAL_TON" jdbcType="VARCHAR"/>
    <result property="declareTotalTeu" column="DECLARE_TOTAL_TEU" jdbcType="VARCHAR"/>
    <result property="declareTotalPiece" column="DECLARE_TOTAL_PIECE" jdbcType="VARCHAR"/>
    <result property="isMustCheck" column="IS_MUST_CHECK" jdbcType="DECIMAL"/>
    <result property="declareTonActual" column="DECLARE_TON_ACTUAL" jdbcType="DECIMAL"/>
    <result property="declareTeuActual" column="DECLARE_TEU_ACTUAL" jdbcType="DECIMAL"/>
    <result property="declarePieceActual" column="DECLARE_PIECE_ACTUAL" jdbcType="DECIMAL"/>
    <result property="cancelReason" column="CANCEL_REASON" jdbcType="VARCHAR"/>
    <result property="makerId" column="MAKER_ID" jdbcType="VARCHAR"/>
    <result property="declareUnitCode" column="DECLARE_UNIT_CODE" jdbcType="VARCHAR"/>
    <result property="implementTime" column="IMPLEMENT_TIME" jdbcType="TIMESTAMP"/>
    <result property="finishedTime" column="FINISHED_TIME" jdbcType="TIMESTAMP"/>
    <result property="shipTon" column="SHIP_TON" jdbcType="VARCHAR"/>
    <result property="areaCode" column="AREA_CODE" jdbcType="VARCHAR"/>
    <result property="departurearrivalport" column="DEPARTUREARRIVALPORT" jdbcType="VARCHAR"/>
  </resultMap>

  <sql id="Base_Column_List">
    ID,MAKER,MAKE_DATE,
        MAKE_PROJECT,CONNECTS,CONNECT_NO,
        EXPLANATIONS,DECLARE_CODE,UNIT_CODE,
        CONSIGNER,SHIP_NAME,VOYAGE_NUMBER_CODE,
        ADDRESS,FROM_PORT_CODE,TO_PORT_CODE,
        PRE_START_DATE,PRE_END_DATE,PACK_CODE,
        HANDLE_MODE,ADD_INFO,EMERGENCY_CODE,
        DECLARE_UNIT,DECLARE_DATE,EMERGENCY_LINK_TEL_NO,
        CHECK_UNIT_CODE,CHECKER,CHECKER_FLAG,
        CHECK_DATE,REVOKER,REVOKER_DATE,
        DECLARER,TRANSPORT_TYPE,TRANSPORT_DESC,
        STATE,ADDOPERATION,ADDTIME,
        UPDATEOPERATION,UPDATETIME,ISREMOVE,
        DECLARE_TYPE,APPROVAL_NUMBER,PRERECORD_NO,
        UNLOCKER,UNLOCK_TIME,PID,
        VERSION,ITEM_ID,CHECK_OPTION,
        IS_SPOT_CHECK,DECLARE_TOTAL_TON,DECLARE_TOTAL_TEU,
        DECLARE_TOTAL_PIECE,IS_MUST_CHECK,DECLARE_TON_ACTUAL,
        DECLARE_TEU_ACTUAL,DECLARE_PIECE_ACTUAL,CANCEL_REASON,
        MAKER_ID,DECLARE_UNIT_CODE,IMPLEMENT_TIME,
        FINISHED_TIME,SHIP_TON,AREA_CODE,
        DEPARTUREARRIVALPORT
  </sql>

  <select id="selectDeclareGoodsList"
    resultType="com.shanghaichengdi.ghjgitem.vo.HyDangerPreDeclareNhVo">
    select distinct t.id                      id1,
                    t.maker                   maker,
                    t.make_date               makeDate,
                    t.make_project            makeProject,
                    t.connects                connects,
                    t.connect_no              connectNo,
                    t.explanations            explanations,
                    t.declare_code            declareCode,
                    t.unit_code               unitCode,
                    t.consigner               consigner,
                    t.ship_name               shipName,
                    t.voyage_number_code      voyageNumberCode,
                    t.address                 address,
                    t.from_port_code          fromPortCode,
                    t.to_port_code            toPortCode,
                    t.pre_start_date          preStartDate,
                    t.pre_end_date            preEndDate,
                    t.pack_code               packCode,
                    t.handle_mode             handleMode,
                    t.declare_unit            declareUnit,
                    t.declare_date            declareDate,
                    t.emergency_link_tel_no   emergencyLinkTelNo,
                    t.check_unit_code         checkUnitCode,
                    t.checker                 checker,
                    t.checker_flag            checkerFlag,
                    t.check_date              checkDate,
                    t.revoker                 revoker,
                    t.revoker_date            revokerDate,
                    t.declarer                declarer,
                    t.transport_type          transportType,
                    t.transport_desc          transportDesc,
                    t.state                   state,
                    t.isremove                isRemove1,
                    t.declare_type            declareType,
                    t.item_id                 itemId,
                    t.check_option            checkOption,
                    t.is_spot_check           isSpotCheck,
                    t.declare_total_ton       declareTotalTon,
                    t.declare_total_teu       declareTotalTeu,
                    t.declare_total_piece     declareTotalPiece,
                    t.is_must_check           isMustCheck,
                    t.declare_ton_actual      declareTonActual,
                    t.declare_teu_actual      declareTeuActual,
                    t.declare_piece_actual    declarePieceActual,
                    t.cancel_reason           cancelReason,
                    t.declare_unit_code       declareUnitCode,
                    t.implement_time          implementTime,
                    t.finished_time           finishedTime,
                    t.ship_ton                shipTon,
                    t.area_code               areaCode,
                    t.departurearrivalport    departurearrivalport,
                    t1.id                     id2,
                    t1.declare_id             declareId,
                    t1.cargo_code             cargoCode,
                    t3.kind_name              cargoName,
                    t1.declare_ton            declareTon,
                    t1.declare_teu            declareTeu,
                    t1.declare_piece          declarePiece,
                    t1.package_type           packageType,
                    t1.danger_type            dangerType,
                    t1.isremove               isRemove2,
                    t1.transport_name         transportName,
                    t1.measures_number        measuresNumber,
                    t1.order_number           orderNumber,
                    t1.is_ref_poison_goods    isRefPoisonGoods,
                    t1.container_no           containerNo,
                    t1.bill_no                billNo,
                    t1.full_box               fullBox,
                    t1.cnt_type               cntType,
                    t1.cnt_size               cntSize,
                    t2.licensenumber          licensenumber,
                    t2.operator_way           operatorWay,
                    t2.unit_measure           unitMeasure,
                    t2.dange_groupname        dangerGroupName,
                    t2.dange_name             dangerName,
                    t2.year_limitamount       yearLimitAmount,
                    t2.trans_way              transWay,
                    t2.trans_shape            transShape,
                    t2.operator_location_naem operatorLocationName,
                    t2.dange_code             dangerCode,
                    t2.bowei                  bowei
    from ghjg_port_manage.hy_danger_pre_declare_nh t
           left join ghjg_port_manage.hy_danger_pre_declare_cargo_nh t1 on t.id = t1.declare_id
           left join ghjg_basics.hy_wharf_ruleconfig_nh t2 on t.unit_code = t2.operator_location
           left join ghjg_port_manage.hy_danger_goods_nh_dict t3 on t1.cargo_code = t3.kind_code
    where t.AREA_CODE = '310115'
  </select>


  <select id="selectOutRecordRecent" resultType="com.shanghaichengdi.ghjgitem.vo.PollutantAcceptVo">
    select * from (select acc.SHIP_NAME boat,acc.FIRST_DTM time,acc.SEWAGE_TYPE
    POLLUTANTTYPE,acc.RECEIVE_NUM || ' ' || UNIT POLLUTANTCOUNT,
    row_number() over(partition by SHIP_NAME,SEWAGE_TYPE order by FIRST_DTM desc) num
    from GHJG_BUSSINESS.BOAT_WATER_POLLUTANT_ACCEPT_F acc
    where acc.SHIP_NAME = #{boatName}
    order by acc.FIRST_DTM desc) where num = 1
  </select>
</mapper>
