<?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.xt.hb.data.aq.aqmap.AqcxMapper">
	<!-- 根据码头ID查询码头详细信息 -->
	<select id="selectGqxxByGisId" resultType="map" parameterType="java.lang.String">
		select A.ID,A.GQMC NAME,B.NAME GKMC,A.GQMJ,A.LYMJ,A.SYMJ,A.BZ
		REMARK,A.GISID
		from t_yjpt_gq A,(SELECT ID,MC NAME FROM
		T_YJPT_GGDM
		WHERE GROUPCODE = 'SZD' AND
		RECORD_STATUS=1) B
		WHERE A.SZD=B.ID AND
		A.RECORD_STATUS=1 AND
		A.GISID=#{id,jdbcType=VARCHAR}
	</select>
	<!-- 根据经营ID查询经营人基础信息 -->
	<select id="selectJyrjcxxByGisId" resultType="map"
		parameterType="java.lang.String">
		SELECT J.ID,J.GKJYR NAME,B.NAME
		GKMC,J.AQFZRLXDH,J.GKJYXKZH,G.GQMC,J.ZYHZ,
		CASE WHEN
		J.GKWXHWZYFZBH IS
		NOT NULL OR ''!=J.GKWXHWZYFZBH THEN '是' ELSE
		'否' END
		SFWHQY,J.GISID
		FROM
		T_YJPT_JYRJCXX J JOIN T_YJPT_GQ G ON J.SZGQ=G.ID,(SELECT ID,MC NAME
		FROM
		T_YJPT_GGDM
		WHERE GROUPCODE = 'SZD'  AND
		RECORD_STATUS=1) B
		WHERE J.SZD=B.ID
		AND J.RECORD_STATUS=1
		AND J.GISID
		= #{id,jdbcType=VARCHAR}
	</select>
	<!-- 根据码头ID查询码头详细信息 -->
	<select id="selectMtxxByGisId" resultType="map" parameterType="java.lang.String">
		SELECT
		M.ID,B.NAME GKMC,G.GQMC,M.MTMC
		NAME,M.NHWTGNL,M.SJHWTTL,M.MTSJQYSS,M.GISID,M.ZYHL,M.MTYT,M.JYR,J.GKJYR
		jyrmc
		FROM T_YJPT_GQ_MT M JOIN T_YJPT_GQ G ON M.GQ=G.ID LEFT JOIN
		T_YJPT_JYRJCXX J ON M.JYR=J.ID AND
		J.RECORD_STATUS=1,(SELECT ID,MC NAME
		FROM T_YJPT_GGDM WHERE GROUPCODE = 'SZD'  AND RECORD_STATUS=1) B
		WHERE
		M.RECORD_STATUS=1 AND M.SZD=B.ID AND
		M.GISID=#{id,jdbcType=VARCHAR}
	</select>
	<!-- 根据泊位ID查询泊位详细信息 -->
	<select id="selectBwxxByGisId" resultType="map" parameterType="java.lang.String">
		SELECT B.ID,B.GISID,B.BWMC NAME,J.GKJYR JYRMC,G.GQMC,GK.NAME
		GKMC,B.ZWBWYT BWYT,B.BWCD,B.SJKPNL*10000 SJKBNL,B.NHWTGML,CASE
		WHEN
		B.WXPBW='N' THEN '否' ELSE '是' END WXPBW,
		B.QYSJSS,CASE WHEN
		B.FWLX=10000613 THEN '公用' WHEN B.FWLX=10000614 THEN '私用' ELSE ''
		END
		FWLX
		FROM T_YJPT_JYRXX_BW B LEFT JOIN T_YJPT_JYRJCXX J
		ON
		J.ID=B.QYMC AND
		J.RECORD_STATUS=1 LEFT JOIN T_YJPT_GQ G ON
		B.SZGQ=G.ID,(SELECT ID,MC
		NAME
		FROM T_YJPT_GGDM WHERE GROUPCODE = 'SZD'  AND RECORD_STATUS=1) GK
		WHERE
		B.SZD=GK.ID AND
		B.RECORD_STATUS=1 AND
		B.GISID=#{id,jdbcType=VARCHAR}
	</select>
	<!-- 根据经营人ID检索码头名称列表 -->
	<select id="selectMtByJyrid" resultType="string" parameterType="java.lang.Long">
		SELECT M.GKMTMC MT FROM T_YJPT_MT M
		WHERE M.GKJYR =
		#{id,jdbcType=BIGINT} AND M.RECORD_STATUS=1
	</select>
	<!-- 湖北省所在地检索 -->
	<resultMap id="ThreeColumnMap" type="com.xt.hb.data.aq.model.ThreeColumn">
		<id column="ID" property="column1" jdbcType="NUMERIC" />
		<result column="NAME" property="column2" jdbcType="VARCHAR" />
		<result column="COLUMN3" property="column3" jdbcType="VARCHAR" />
	</resultMap>
	<select id="selectHbszd" resultMap="ThreeColumnMap">
		SELECT ID,MC NAME,GISID
		COLUMN3 FROM
		T_YJPT_GGDM
		WHERE GROUPCODE = 'SZD'  AND RECORD_STATUS=1
	</select>
	<select id="selectHbszdByFID" resultMap="ThreeColumnMap" parameterType="java.lang.String">
		SELECT ID,MC NAME,GISID
		COLUMN3 FROM
		T_YJPT_GGDM
		WHERE GROUPCODE = 'SZD'  AND RECORD_STATUS=1
	  <choose>
	  <when test="fid != null">
	 	and FID=#{fid,jdbcType=BIGINT}
	  </when>
	  <otherwise>
	  and FID IS NULL
	  </otherwise>
	  </choose>
	</select>
	<!-- 根据所在地ID查询港区 -->
	<select id="selectGqByCity" resultMap="ThreeColumnMap"
		parameterType="java.lang.String">
		SELECT ID,GQMC NAME, GISID COLUMN3 FROM T_YJPT_GQ
		WHERE
		RECORD_STATUS=1
		AND SZD like #{id,jdbcType=BIGINT}
	</select>
	<!-- 根据所在地ID查询港区 -->
	<select id="selectJyrmcByGq" resultMap="ThreeColumnMap"
		parameterType="java.lang.Long">
		SELECT ID,GKJYR NAME,GISID COLUMN3 FROM T_YJPT_JYRJCXX
		WHERE
		RECORD_STATUS=1 AND SZGQ=#{id,jdbcType=BIGINT}
	</select>
	<select id="selectWhJyrmcByGq" resultMap="ThreeColumnMap"
		parameterType="java.lang.Long">
		SELECT ID,GKJYR NAME,GISID COLUMN3 FROM T_YJPT_JYRJCXX
		WHERE
		RECORD_STATUS=1 AND SZGQ=#{id,jdbcType=BIGINT}
		AND SFWHQY != 'N'
	</select>
	<insert id="insertCbgg" parameterType="com.xt.hb.data.cbyj.model.Cbgg">
		INSERT INTO T_YJPT_GG
		(ID,TITLE,ADD_USER,ADD_DATE,RECORD_STATUS,RECORD_CODE,BYZD1,BYZD2,BYZD3,QYKJ,PKJ,SZD,SKJ,SFCBYJ)
		values (SEQ_T_YJPT_GG.NextVal, #{title,jdbcType=VARCHAR}, 1,
		#{yjsj,jdbcType=OTHER},
		1,0,'N','N',#{cm,jdbcType=VARCHAR},'N','2',#{szd,jdbcType=VARCHAR},#{szd,jdbcType=VARCHAR},'Y')
	</insert>
	<!-- 取水口 -->
	<resultMap id="QskResultMap" type="com.xt.hb.data.aq.model.Qsk">
		<id column="ID" property="id" jdbcType="VARCHAR" />
		<result column="TBDW" property="tbdw" jdbcType="VARCHAR" />
		<result column="TBSJ" property="tbsj" jdbcType="TIMESTAMP" />
		<result column="QSKMC" property="qskmc" jdbcType="VARCHAR" />
		<result column="DLWZZB" property="dlwzzb" jdbcType="VARCHAR" />
		<result column="LXDH" property="lxdh" jdbcType="VARCHAR" />
		<result column="GLDW" property="gldw" jdbcType="VARCHAR" />
		<result column="PJQSL" property="pjqsl" jdbcType="DECIMAL" />
		<result column="YT" property="yt" jdbcType="VARCHAR" />
		<result column="SZYQ" property="szyq" jdbcType="VARCHAR" />
		<result column="GYRK" property="gyrk" jdbcType="DECIMAL" />
		<result column="TBR" property="tbr" jdbcType="VARCHAR" />
		<result column="ADD_USER" property="addUser" jdbcType="VARCHAR" />
		<result column="ADD_DATE" property="addDate" jdbcType="TIMESTAMP" />
		<result column="UPDATE_USER" property="updateUser" jdbcType="VARCHAR" />
		<result column="UPDATE_DATE" property="updateDate" jdbcType="TIMESTAMP" />
		<result column="RECORD_STATUS" property="recordStatus"
			jdbcType="DECIMAL" />
		<result column="SFTB" property="sftb" jdbcType="CHAR" />
		<result column="TBZT" property="tbzt" jdbcType="CHAR" />
		<result column="TBDYID" property="tbdyid" jdbcType="DECIMAL" />
		<result column="QYLB" property="qylb" jdbcType="CHAR" />
		<result column="SZD" property="szd" jdbcType="DECIMAL" />
		<result column="SSQY" property="ssqy" jdbcType="DECIMAL" />
		<result column="GQ" property="gq" jdbcType="DECIMAL" />
		<result column="RECORD_CODE" property="recordCode" jdbcType="VARCHAR" />
		<result column="BYZD1" property="byzd1" jdbcType="VARCHAR" />
		<result column="BYZD2" property="byzd2" jdbcType="VARCHAR" />
		<result column="BYZD3" property="byzd3" jdbcType="VARCHAR" />
		<result column="BYZD4" property="byzd4" jdbcType="VARCHAR" />
		<result column="BYZD5" property="byzd5" jdbcType="VARCHAR" />
		<result column="MAPID" property="mapid" jdbcType="DECIMAL" />
		<result column="GISID" property="gisid" jdbcType="VARCHAR" />
	</resultMap>
	<select id="selectQskByGisId" resultMap="QskResultMap"
		parameterType="java.lang.String">
		select ID, TBDW, TBSJ, QSKMC, DLWZZB, LXDH, GLDW, PJQSL, YT, SZYQ, GYRK,
		TBR, ADD_USER,
		ADD_DATE, UPDATE_USER, UPDATE_DATE, RECORD_STATUS, SFTB, TBZT, TBDYID, QYLB,
		SZD,
		SSQY, GQ, RECORD_CODE, BYZD1, BYZD2, BYZD3, BYZD4, BYZD5, MAPID, GISID
		from T_YJPT_QSK
		WHERE RECORD_STATUS=1 AND
		GISID=#{id,jdbcType=VARCHAR}
	</select>
	<!-- 危货作业申请 -->
	<resultMap id="WhzysqResultMap" type="com.xt.hb.data.aq.model.Whzysq">
		<id column="ID" property="id" jdbcType="VARCHAR" />
		<result column="BH" property="bh" jdbcType="VARCHAR" />
		<result column="WXHWMCBH" property="wxwpmc" jdbcType="VARCHAR" />
		<result column="ZYSJQ" property="zysjq" jdbcType="TIMESTAMP" />
		<result column="ZYSL" property="zysl" jdbcType="VARCHAR" />
		<result column="KGSJ" property="kgsj" jdbcType="TIMESTAMP" />
		<result column="BGSJ" property="bgsj" jdbcType="TIMESTAMP" />
	</resultMap>
	<select id="selectWhzysqByBwid" resultMap="WhzysqResultMap"
		parameterType="java.lang.String">
		SELECT T.ID,T.WXHWMCBH AS WXWPMC,t.bh,T.ZYSL,T.ZYSJQ,T.kgsj,t.bgsj FROM
		T_YJPT_WXHWGKZYSBD T
		LEFT JOIN T_YJPT_GKWXHWZYFZBL_FZ F ON F.ID=T.ZYDDQYBH
		WHERE T.ZYDD='10000501' AND T.RECORD_STATUS=2 AND
		F.QYNBBH=#{id,jdbcType=VARCHAR} order by T.BGSJ desc nulls last
	</select>
	<resultMap id="UserResultMap" type="com.xt.hb.data.aq.model.AQUser">
		<id column="ID" jdbcType="DECIMAL" property="id" />
		<result column="CODE" jdbcType="VARCHAR" property="code" />
		<result column="NAME" jdbcType="VARCHAR" property="name" />
		<result column="PASSWORD" jdbcType="VARCHAR" property="password" />
		<result column="ADD_USER" jdbcType="VARCHAR" property="addUser" />
		<result column="ADD_DATE" jdbcType="TIMESTAMP" property="addDate" />
		<result column="UPDATE_USER" jdbcType="VARCHAR" property="updateUser" />
		<result column="UPDATE_DATE" jdbcType="TIMESTAMP" property="updateDate" />
		<result column="RECORD_STATUS" jdbcType="DECIMAL" property="recordStatus" />
		<result column="JYRRYXXID" jdbcType="DECIMAL" property="jyrryxxid" />
		<result column="SFTB" jdbcType="CHAR" property="sftb" />
		<result column="TBZT" jdbcType="CHAR" property="tbzt" />
		<result column="TBDYID" jdbcType="DECIMAL" property="tbdyid" />
		<result column="QYLB" jdbcType="CHAR" property="qylb" />
		<result column="SSQY" jdbcType="DECIMAL" property="ssqy" />
		<result column="SZCSID" jdbcType="DECIMAL" property="szcsid" />
		<result column="SZDSMZ" jdbcType="VARCHAR" property="szdsmz" />
		<result column="SSJGID" jdbcType="DECIMAL" property="ssjgid" />
		<result column="SSJGMZ" jdbcType="VARCHAR" property="ssjgmz" />
		<result column="SFAQFZR" jdbcType="CHAR" property="sfaqfzr" />
		<result column="SFYXDL" jdbcType="CHAR" property="sfyxdl" />
		<result column="LXDH" jdbcType="VARCHAR" property="lxdh" />
		<result column="CZ" jdbcType="VARCHAR" property="cz" />
		<result column="YX" jdbcType="VARCHAR" property="yx" />
		<result column="BGDZ" jdbcType="VARCHAR" property="bgdz" />
		<result column="RECORD_CODE" jdbcType="VARCHAR" property="recordCode" />
		<result column="BYZD1" jdbcType="VARCHAR" property="byzd1" />
		<result column="BYZD2" jdbcType="VARCHAR" property="byzd2" />
		<result column="BYZD3" jdbcType="VARCHAR" property="byzd3" />
		<result column="BYZD4" jdbcType="VARCHAR" property="byzd4" />
		<result column="BYZD5" jdbcType="VARCHAR" property="byzd5" />
		<result column="SFJYR" jdbcType="CHAR" property="sfjyr" />
		<result column="SFCD" jdbcType="CHAR" property="sfcd" />
		<result column="SFJCRY" jdbcType="CHAR" property="sfjcry" />
		<result column="BIRTH" jdbcType="TIMESTAMP" property="birth" />
		<result column="SEX" jdbcType="VARCHAR" property="sex" />
		<result column="POLITICAL_LANDSCAPE" jdbcType="VARCHAR"
			property="politicalLandscape" />
		<result column="EDUCATION" jdbcType="VARCHAR" property="education" />
		<result column="ORGANIZATION" jdbcType="VARCHAR" property="organization" />
		<result column="UPDATE_TYPE" jdbcType="VARCHAR" property="updateType" />
		<result column="POSITION" jdbcType="VARCHAR" property="position" />
		<result column="SFYXZYSQ" jdbcType="CHAR" property="sfyxzysq" />
		<result column="SFYXCKDT" jdbcType="CHAR" property="sfyxckdt" />
		<result column="AQPJJGID" jdbcType="DECIMAL" property="aqpjjgid" />
		<result column="JSDWID" jdbcType="DECIMAL" property="jsdwid" />
		<result column="SZD" jdbcType="DECIMAL" property="szd" />
	</resultMap>
	<select id="selectUserByName" parameterType="java.lang.String"
		resultMap="UserResultMap">
		select ID, CODE, NAME, PASSWORD, ADD_USER, ADD_DATE, UPDATE_USER,
		UPDATE_DATE, RECORD_STATUS,
		JYRRYXXID, SFTB, TBZT, TBDYID, QYLB, SSQY, SZCSID, SZDSMZ, SSJGID, SSJGMZ,
		SFAQFZR,
		SFYXDL, LXDH, CZ, YX, BGDZ, RECORD_CODE, BYZD1, BYZD2, BYZD3, BYZD4, BYZD5,
		SFJYR,
		SFCD, SFJCRY, BIRTH, SEX, POLITICAL_LANDSCAPE, EDUCATION, ORGANIZATION,
		UPDATE_TYPE,
		POSITION, SFYXZYSQ, SFYXCKDT, AQPJJGID, JSDWID, SZD
		from T_YJPT_USER
		where CODE = #{code,jdbcType=VARCHAR} AND RECORD_STATUS='1'
	</select>
</mapper>