<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE sqlMap   
    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"   
    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="com.hst.tmService.dao.BusSsglWjzAppMapper">
	 <!--插入主表数据-->
	<insert id="insertNsfwWsgpSqzb"  parameterClass="com.hst.common.bo.NsfwWsgpSqzb">
		INSERT INTO NSFW_WSGP_SQZB
		  (WS_DJHZ_XH,
		   wsgp_sqlx_dm,
		   wsgp_sqlb_dm,
		   nsrsbh,
		   nsrdzdah,
		   sqrq,
		   sqsj,
		   gpyxm,
		   gpysfzm,
		   appsq_xh,
		   kddh,
		   wsgp_sqdbh,
		   swjg_dm,
		   bsdt_djxh,
		   sljg,
		   byfsyy,
		   spqrbz,
		   spr,
		   sprq,
		   lgb_dybz,
		   kdd_qsbz)
		VALUES
		  (#wsDjhzXh:VARCHAR#,
		   #wsgpSqlxDm:VARCHAR#,
		   #wsgpSqlbDm:NUMBER#,
		   #nsrsbh:VARCHAR#,
		   #nsrdzdah:VARCHAR#,
		   to_date(#sqrq#, 'yyyy-MM-dd'),
		  sysdate,
		     #gpyxm:VARCHAR#,
		   #gpysfzm:VARCHAR#,
		   #appsqXh:VARCHAR#,
		   #kddh:VARCHAR#,
		   #wsgpSqdbh:VARCHAR#,
		   #swjgDm:VARCHAR#,
		   #bsdtDjxh:VARCHAR#,
		   #sljg:VARCHAR#, 
		   #byfsyy:VARCHAR#,
		   #spqrbz:VARCHAR#,
		   #spr:VARCHAR#,
		   to_date(#sprq:DATE#, 'yyyy-MM-dd'),
		   #lgbDybz:VARCHAR#,
		   #kddQsbz:VARCHAR#)
	</insert>

	<!--根据主键更新主表-->
    <update id="updateNsfwWsgpSqzbByKey" parameterClass="com.hst.common.bo.NsfwWsgpSqzb">
      update NSFW_WSGP_SQZB
		  set WS_DJHZ_XH   = #wsDjhzXh#,
		      wsgp_sqlx_dm = #wsgpSqlxDm#,
		      wsgp_sqlb_dm = #wsgpSqlbDm#,
		      nsrsbh       = #nsrsbh#,
		      nsrdzdah     = #nsrdzdah#,
		      sqrq         = to_date(#sqrq:DATE#, 'yyyy-MM-dd'),
		      sqsj         = sysdate,
		      gpyxm        = #gpyxm#,
		      gpysfzm      = #gpysfzm#,
		      appsq_xh     = #appsqXh#,
		      kddh         = #kddh#,
		      wsgp_sqdbh   = #wsgpSqdbh#,
		      swjg_dm      = #swjgDm#,
		      bsdt_djxh    = #bsdtDjxh#,
		      sljg         = #sljg#,
		      byfsyy       = #byfsyy#,
		      spqrbz       = #spqrbz#,
		      spr          = #spr#,
		      sprq         = to_date(#sprq:DATE#, 'yyyy-MM-dd'),
		      lgb_dybz          = #lgbDybz#,
		      kdd_qsbz          = #kddQsbz#
		where WS_DJHZ_XH = #wsDjhzXh#
    </update>
    
    <!--插入子表数据-->
    <insert id="insertNsfwWsgpFplgsq"  parameterClass="com.hst.common.bo.NsfwWsgpFplgsq">
		INSERT INTO NSFW_WSGP_FPLGSQ
		(WS_DJHZ_XH,FPZL_DM,LGSL,DW)
		values
		(#wsDjhzXh:VARCHAR#,#fpzlDm:VARCHAR#,#lgsl:VARCHAR#,#dw:VARCHAR#)
	</insert>
	
	<!--根据主键删除子表数据-->
	<delete id="deleteNsfwWsgpFplgsqByKey" parameterClass="java.util.Map">
		delete from NSFW_WSGP_FPLGSQ where WS_DJHZ_XH=#wsDjhzXh#
	</delete>
	
	    <!--插入子表数据-->
    <insert id="insertNsfwWsgpFpyjsq"  parameterClass="com.hst.common.bo.NsfwWsgpFpyjsq">
	INSERT INTO NSFW_WSGP_FPYJSQ
  (WS_DJHZ_XH, FPZL_DM, FP_DM, FPQH,FPZH,KPRQ_Q,KPRQ_Z,
  	KPJE,SE,FP_YJJG_DM,SFSCDZXX,YJBZ,YJ_CZRY_DM,CZRQ,YJZT,ERR_MESS)
	values
  (#wsDjhzXh:VARHCAR#, #fpzlDm:VARCHAR#, #fpDm:VARCHAR#, #fpqh:VARCHAR#,#fpzh:VARCHAR#,to_date(#kprqQ:DATE#, 'yyyyMMdd'),to_date(#kprqZ:DATE#, 'yyyyMMdd'),
   #kpje:VARCHAR#,#se:VARCHAR#,#fpYjjgDm:VARCHAR#,#sfscdzxx:VARCHAR#,#yjbz:VARCHAR#,#yjCzryDm:VARCHAR#,#czrq:VARCHAR#,#yjzt:VARCHAR#,#errMess:VARCHAR#)

	</insert>
	
	<!--根据主键删除子表数据-->
	<delete id="deleteNsfwWsgpFpyjsqByKey" parameterClass="java.util.Map">
		delete from NSFW_WSGP_FPYJSQ where WS_DJHZ_XH=#wsDjhzXh#
	</delete>
    <!--插入数据-->
	<insert id="insertSssxSlsqSqrYjxx"  parameterClass="com.hst.common.bo.SssxSlsqSqrYjxx">
		<selectKey keyProperty="djxxXh" resultClass="String" type="pre"> 
			select SEQ_SSSX_DJXXXH.nextval as djxxXh from dual 
		</selectKey> 
		insert into SSSX_SLSQ_SQR_YJXX(DJXX_XH,NSRBSH,DZ,YB,SJR,
		SJHM,GDDH,YXBZ,CJRQ)
		values(#djxxXh:NUMERIC#,#nsrbsh:VARCHAR#,#dz:VARCHAR#,#yb:VARCHAR#,#sjr:VARCHAR#,
		#sjhm:VARCHAR#,#gddh:VARCHAR#,#yxbz:VARCHAR#,to_date(#cjrq:DATE#,'yyyy-MM-dd'))
	</insert>
	<!--根据主键更新该表中其它所有字段-->
    <update id="updateSssxSlsqSqrYjxxByKey" parameterClass="com.hst.common.bo.SssxSlsqSqrYjxx">
        update SSSX_SLSQ_SQR_YJXX set DJXX_XH=#djxxXh#,NSRBSH=#nsrbsh#,DZ=#dz#,YB=#yb#,SJR=#sjr#,
		SJHM=#sjhm#,GDDH=#gddh#,YXBZ=#yxbz#,CJRQ=to_date(#cjrq#, 'YYYY-MM-DD') where DJXX_XH=#djxxXh#
    </update>
     <select id="selectSssxSlsqSqrYjxxBySjr" parameterClass="java.util.Map"
		resultClass="com.hst.common.bo.SssxSlsqSqrYjxx">
		select a.DJXX_XH as djxxXh,a.NSRBSH as nsrbsh,a.DZ as dz,a.YB as yb,a.SJR as sjr,
		a.SJHM as sjhm,a.GDDH as gddh,a.YXBZ as yxbz,a.CJRQ as cjrq from SSSX_SLSQ_SQR_YJXX a  
		where  a.nsrbsh=#nsrbsh#
		<isNotEmpty prepend="and" property="sjr">
			sjr=#sjr#
		</isNotEmpty>
		<isNotEmpty prepend="and" property="dz">
			dz=#dz#
		</isNotEmpty>
		<isNotEmpty prepend="and" property="sjhm">
			sjhm=#sjhm#
		</isNotEmpty>
		<isNotEmpty prepend="and" property="gddh">
			gddh=#gddh#
		</isNotEmpty>
    </select>
	  <select id="selectFpyjCheckWhDzList" parameterClass="java.util.Map" resultClass="java.lang.String">
    	select T.DZ 
  from nsfw_wsgp_nsr_yjdz t
 where T.NSRDZDAH =
       (SELECT A.NSRDZDAH FROM CTAIS2.DJ_NSRXX A WHERE NSRSBH = #nsrsbh#)
   and t.yxbz = 'Y'
    </select>
    
    
</sqlMap>