complexMapper.xml 7.5 KB
<?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.eport.rest.dao.ComplexDao">
    
	<sql id="ComplexEntityColumns">
		a1.CODE_T AS "codeT"
		,a1.CODE_S AS "codeS"
		,a1.G_NAME AS "gName"
		,a1.LOW_RATE AS "lowRate"
		,a1.HIGH_RATE AS "highRate"
		,a1.OUT_RATE AS "outRate"
		,a1.REG_MARK AS "regMark"
		,a1.REG_RATE AS "regRate"
		,a1.TAX_TYPE AS "taxType"
		,a1.TAX_RATE AS "taxRate"
		,a1.COMM_RATE AS "commRate"
		,a1.TAIWAN_RATE AS "taiwanRate"
		,a1.OTHER_TYPE AS "otherType"
		,a1.OTHER_RATE AS "otherRate"
		,a1.UNIT_1 AS "unit1"
		,a1.UNIT_2 AS "unit2"
		,a1.ILOW_PRICE AS "ilowPrice"
		,a1.IHIGH_PRICE AS "ihighPrice"
		,a1.ELOW_PRICE AS "elowPrice"
		,a1.EHIGH_PRICE AS "ehighPrice"
		,a1.MAX_IN AS "maxIn"
		,a1.MAX_OUT AS "maxOut"
		,a1.CONTROL_MA AS "controlMa"
		,a1.CHK_PRICE AS "chkPrice"
		,a1.TARIFF_MARK AS "tariffMark"
		,a1.NOTE_S AS "noteS"
		,a1.PK_SEQ AS "pkSeq"
	</sql>
	
	<sql id="ComplexEntityListColumns">
		a1.PK_SEQ AS "pkSeq"
	</sql>
	
	
	
		<!--查询表中所有资料(所有字段) -->
		<select id="listAll"  
		parameterType="HashMap" 
		resultType="com.eport.rest.entity.ComplexEntity"
		>
		select  
			<include refid="ComplexEntityColumns"/>
			,(select UNIT_NAME from unit  c1 where c1.UNIT_CODE = a1.UNIT_1) as unit1Name
			,(select UNIT_NAME from unit  c1 where c1.UNIT_CODE = a1.UNIT_2) as unit2Name
		FROM complex  a1
		WHERE 1=1
		</select>
		
	
		<!--分页查询资料(所有字段) -->
		<select id="pageAll"  
		parameterType="HashMap" 
		resultType="com.eport.rest.entity.ComplexEntity"
		>
		select  
			<include refid="ComplexEntityColumns"/>
			,(select UNIT_NAME from unit  c1 where c1.UNIT_CODE = a1.UNIT_1) as unit1Name
			,(select UNIT_NAME from unit  c1 where c1.UNIT_CODE = a1.UNIT_2) as unit2Name
		FROM complex  a1
		WHERE 1=1
		</select>
		
	
		<!--查询表中所有资料(仅列表显示字段) -->
		<select id="list"  
		parameterType="HashMap" 
		resultType="com.eport.rest.entity.ComplexEntity"
		>
		select  
			<include refid="ComplexEntityListColumns"/>
		FROM complex  a1
		WHERE 1=1
		</select>
		
	
		<!--分页查询资料(仅列表显示字段) -->
		<select id="page"  
		parameterType="HashMap" 
		resultType="com.eport.rest.entity.ComplexEntity"
		>
		select  
			<include refid="ComplexEntityListColumns"/>
		FROM complex  a1
		WHERE 1=1
		</select>
		
	
		<!--根据主键查询数据 -->
		<select id="findByPK"  
		parameterType="Integer" 
		resultType="com.eport.rest.entity.ComplexEntity"
		>
		select  
		<include refid="ComplexEntityColumns"/>
			,(select UNIT_NAME from unit  c1 where c1.UNIT_CODE = a1.UNIT_1) as unit1Name
			,(select UNIT_NAME from unit  c1 where c1.UNIT_CODE = a1.UNIT_2) as unit2Name
		FROM complex  a1
		WHERE a1.PK_SEQ=#{par}
		</select>
		
	
		<!--新增数据 -->
		<insert id="insert"  
		parameterType="com.eport.rest.entity.ComplexEntity" 
		>
		<selectKey resultType="Integer" order="AFTER" keyProperty="pkSeq">
		<if test="pkSeq != null ">
		select #{pkSeq} from dual
		</if>
		<if test="pkSeq == null ">
		SELECT LAST_INSERT_ID() AS pkSeq
		</if>
		 </selectKey>
		insert  
		  INTO complex (
		CODE_T
		,CODE_S
		,G_NAME
		,LOW_RATE
		,HIGH_RATE
		,OUT_RATE
		,REG_MARK
		,REG_RATE
		,TAX_TYPE
		,TAX_RATE
		,COMM_RATE
		,TAIWAN_RATE
		,OTHER_TYPE
		,OTHER_RATE
		,UNIT_1
		,UNIT_2
		,ILOW_PRICE
		,IHIGH_PRICE
		,ELOW_PRICE
		,EHIGH_PRICE
		,MAX_IN
		,MAX_OUT
		,CONTROL_MA
		,CHK_PRICE
		,TARIFF_MARK
		,NOTE_S
		<if test="pkSeq != null ">
		,PK_SEQ
		</if>
		  ) VALUES (
		#{codeT,jdbcType=VARCHAR}
		,#{codeS,jdbcType=VARCHAR}
		,#{gName,jdbcType=VARCHAR}
		,#{lowRate,jdbcType=VARCHAR}
		,#{highRate,jdbcType=VARCHAR}
		,#{outRate,jdbcType=VARCHAR}
		,#{regMark,jdbcType=VARCHAR}
		,#{regRate,jdbcType=VARCHAR}
		,#{taxType,jdbcType=VARCHAR}
		,#{taxRate,jdbcType=VARCHAR}
		,#{commRate,jdbcType=VARCHAR}
		,#{taiwanRate,jdbcType=VARCHAR}
		,#{otherType,jdbcType=VARCHAR}
		,#{otherRate,jdbcType=VARCHAR}
		,#{unit1,jdbcType=VARCHAR}
		,#{unit2,jdbcType=VARCHAR}
		,#{ilowPrice,jdbcType=VARCHAR}
		,#{ihighPrice,jdbcType=VARCHAR}
		,#{elowPrice,jdbcType=VARCHAR}
		,#{ehighPrice,jdbcType=VARCHAR}
		,#{maxIn,jdbcType=VARCHAR}
		,#{maxOut,jdbcType=VARCHAR}
		,#{controlMa,jdbcType=VARCHAR}
		,#{chkPrice,jdbcType=VARCHAR}
		,#{tariffMark,jdbcType=VARCHAR}
		,#{noteS,jdbcType=VARCHAR}
		<if test="pkSeq != null ">
		,#{pkSeq,jdbcType=decimal}
		</if>
		  )
		</insert>
		
	
		<!--更新数据 -->
		<update id="update"  
		parameterType="com.eport.rest.entity.ComplexEntity" 
		>
		update  
		complex
		<set>
		<if test="codeT != null ">
		CODE_T = #{codeT},
		</if>
		<if test="codeS != null ">
		CODE_S = #{codeS},
		</if>
		<if test="gName != null ">
		G_NAME = #{gName},
		</if>
		<if test="lowRate != null ">
		LOW_RATE = #{lowRate},
		</if>
		<if test="highRate != null ">
		HIGH_RATE = #{highRate},
		</if>
		<if test="outRate != null ">
		OUT_RATE = #{outRate},
		</if>
		<if test="regMark != null ">
		REG_MARK = #{regMark},
		</if>
		<if test="regRate != null ">
		REG_RATE = #{regRate},
		</if>
		<if test="taxType != null ">
		TAX_TYPE = #{taxType},
		</if>
		<if test="taxRate != null ">
		TAX_RATE = #{taxRate},
		</if>
		<if test="commRate != null ">
		COMM_RATE = #{commRate},
		</if>
		<if test="taiwanRate != null ">
		TAIWAN_RATE = #{taiwanRate},
		</if>
		<if test="otherType != null ">
		OTHER_TYPE = #{otherType},
		</if>
		<if test="otherRate != null ">
		OTHER_RATE = #{otherRate},
		</if>
		<if test="unit1 != null ">
		UNIT_1 = #{unit1},
		</if>
		<if test="unit2 != null ">
		UNIT_2 = #{unit2},
		</if>
		<if test="ilowPrice != null ">
		ILOW_PRICE = #{ilowPrice},
		</if>
		<if test="ihighPrice != null ">
		IHIGH_PRICE = #{ihighPrice},
		</if>
		<if test="elowPrice != null ">
		ELOW_PRICE = #{elowPrice},
		</if>
		<if test="ehighPrice != null ">
		EHIGH_PRICE = #{ehighPrice},
		</if>
		<if test="maxIn != null ">
		MAX_IN = #{maxIn},
		</if>
		<if test="maxOut != null ">
		MAX_OUT = #{maxOut},
		</if>
		<if test="controlMa != null ">
		CONTROL_MA = #{controlMa},
		</if>
		<if test="chkPrice != null ">
		CHK_PRICE = #{chkPrice},
		</if>
		<if test="tariffMark != null ">
		TARIFF_MARK = #{tariffMark},
		</if>
		<if test="noteS != null ">
		NOTE_S = #{noteS},
		</if>
		</set>
		WHERE PK_SEQ = #{pkSeq}
		</update>
		
	
		<!--根据主键删除数据 -->
		<delete id="delete"  
		parameterType="HashMap" 
		>
		delete  
		from complex 
		 WHERE PK_SEQ in (${par})
		</delete>
		
	
		<!--根据商品编码查询数据 -->
		<select id="findByCodeTS"  
		parameterType="HashMap" 
		resultType="HashMap"
		>
		SELECT
	a1.CODE_T AS "codeT",
	a1.CODE_S AS "codeS",
	a1.G_NAME AS "gName",
	a1.LOW_RATE AS "lowRate",
	a1.HIGH_RATE AS "highRate",
	a1.OUT_RATE AS "outRate",
	a1.REG_MARK AS "regMark",
	a1.REG_RATE AS "regRate",
	a1.TAX_TYPE AS "taxType",
	a1.TAX_RATE AS "taxRate",
	a1.COMM_RATE AS "commRate",
	a1.TAIWAN_RATE AS "taiwanRate",
	a1.OTHER_TYPE AS "otherType",
	a1.OTHER_RATE AS "otherRate",
	a1.UNIT_1 AS "unit1",
	a1.UNIT_2 AS "unit2",
	a1.ILOW_PRICE AS "ilowPrice",
	a1.IHIGH_PRICE AS "ihighPrice",
	a1.ELOW_PRICE AS "elowPrice",
	a1.EHIGH_PRICE AS "ehighPrice",
	a1.MAX_IN AS "maxIn",
	a1.MAX_OUT AS "maxOut",
	a1.CONTROL_MA AS "controlMa",
	a1.CHK_PRICE AS "chkPrice",
	a1.TARIFF_MARK AS "tariffMark",
	a1.NOTE_S AS "noteS",
	a1.PK_SEQ AS "pkSeq",
	(
		SELECT
			UNIT_NAME
		FROM
			unit c1
		WHERE
			c1.UNIT_CODE = a1.UNIT_1
	) AS "unit1Name",
	(
		SELECT
			UNIT_NAME
		FROM
			unit c1
		WHERE
			c1.UNIT_CODE = a1.UNIT_2
	) AS "unit2Name"
FROM
	complex a1
WHERE
	CONCAT(a1.CODE_T,a1.CODE_S) =#{code}
		</select>
		
	
</mapper>