ept_storage_settleMapper.xml 5.1 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.EptStorageSettleDao">
    
	<sql id="EptStorageSettleEntityColumns">
		a1.ID AS "id"
		,a1.STORAGE_TYPE AS "storageType"
		,a1.STORAGE_ID AS "storageId"
		,a1.SETTLE_ID AS "settleId"
		,a1.NUM_VAL AS "numVal"
		,a1.IS_DELETE AS "isDelete"
		,a1.CREATE_ID AS "createId"
		,a1.CREATE_DATE AS "createDate"
		,a1.UPDATE_ID AS "updateId"
		,a1.UPDATE_DATE AS "updateDate"
	</sql>
	
	<sql id="EptStorageSettleEntityListColumns">
		a1.ID AS "id"
		,a1.STORAGE_TYPE AS "storageType"
		,a1.STORAGE_ID AS "storageId"
		,a1.SETTLE_ID AS "settleId"
		,a1.NUM_VAL AS "numVal"
	</sql>
	
	
	
		<!--查询表中所有资料(所有字段) -->
		<select id="listAll"  
		parameterType="HashMap" 
		resultType="com.eport.rest.entity.EptStorageSettleEntity"
		>
		select  
			<include refid="EptStorageSettleEntityColumns"/>
			,(select TYPE_NAME from ept_settle_type  c1 where c1.ID = a1.SETTLE_ID) as settleName
		FROM ept_storage_settle  a1
		WHERE 1=1
		 and IS_DELETE = 0
		</select>
		
	
		<!--分页查询资料(所有字段) -->
		<select id="pageAll"  
		parameterType="HashMap" 
		resultType="com.eport.rest.entity.EptStorageSettleEntity"
		>
		select  
			<include refid="EptStorageSettleEntityColumns"/>
			,(select TYPE_NAME from ept_settle_type  c1 where c1.ID = a1.SETTLE_ID) as settleName
		FROM ept_storage_settle  a1
		WHERE 1=1
		 and IS_DELETE = 0
		</select>
		
	
		<!--查询表中所有资料(仅列表显示字段) -->
		<select id="list"  
		parameterType="HashMap" 
		resultType="com.eport.rest.entity.EptStorageSettleEntity"
		>
		select  
			<include refid="EptStorageSettleEntityListColumns"/>
			,(select TYPE_NAME from ept_settle_type  c1 where c1.ID = a1.SETTLE_ID) as settleName
		FROM ept_storage_settle  a1
		WHERE 1=1
		 and IS_DELETE = 0
		</select>
		
	
		<!--分页查询资料(仅列表显示字段) -->
		<select id="page"  
		parameterType="HashMap" 
		resultType="com.eport.rest.entity.EptStorageSettleEntity"
		>
		select  
			<include refid="EptStorageSettleEntityListColumns"/>
			,(select TYPE_NAME from ept_settle_type  c1 where c1.ID = a1.SETTLE_ID) as settleName
		FROM ept_storage_settle  a1
		WHERE 1=1
		 and IS_DELETE = 0
		</select>
		
	
		<!--根据主键查询数据 -->
		<select id="findByPK"  
		parameterType="Integer" 
		resultType="com.eport.rest.entity.EptStorageSettleEntity"
		>
		select  
		<include refid="EptStorageSettleEntityColumns"/>
			,(select TYPE_NAME from ept_settle_type  c1 where c1.ID = a1.SETTLE_ID) as settleName
		FROM ept_storage_settle  a1
		WHERE a1.ID=#{par}
		 and IS_DELETE = 0
		</select>
		
	
		<!--新增数据 -->
		<insert id="insert"  
		parameterType="com.eport.rest.entity.EptStorageSettleEntity" 
		>
		<selectKey resultType="Integer" order="AFTER" keyProperty="id">
		<if test="id != null ">
		select #{id} from dual
		</if>
		<if test="id == null ">
		SELECT LAST_INSERT_ID() AS id
		</if>
		 </selectKey>
		insert  
		  INTO ept_storage_settle (
		STORAGE_TYPE
		,STORAGE_ID
		,SETTLE_ID
		,NUM_VAL
		,IS_DELETE
		,CREATE_ID
		,CREATE_DATE
		,UPDATE_ID
		,UPDATE_DATE
		<if test="id != null ">
		,ID
		</if>
		  ) VALUES (
		#{storageType,jdbcType=VARCHAR}
		,#{storageId,jdbcType=INTEGER}
		,#{settleId,jdbcType=INTEGER}
		,#{numVal,jdbcType=FLOAT}
		,#{isDelete,jdbcType=INTEGER}
		,#{createId,jdbcType=INTEGER}
		,#{createDate,jdbcType=DATE}
		,#{updateId,jdbcType=INTEGER}
		,#{updateDate,jdbcType=DATE}
		<if test="id != null ">
		,#{id,jdbcType=INTEGER}
		</if>
		  )
		</insert>
		
	
		<!--更新数据 -->
		<update id="update"  
		parameterType="com.eport.rest.entity.EptStorageSettleEntity" 
		>
		update  
		ept_storage_settle
		<set>
		<if test="storageType != null ">
		STORAGE_TYPE = #{storageType},
		</if>
		<if test="storageId != null ">
		STORAGE_ID = #{storageId},
		</if>
		<if test="settleId != null ">
		SETTLE_ID = #{settleId},
		</if>
		<if test="numVal != null ">
		NUM_VAL = #{numVal},
		</if>
		<if test="isDelete != null ">
		IS_DELETE = #{isDelete},
		</if>
		<if test="updateId != null ">
		UPDATE_ID = #{updateId},
		</if>
		<if test="updateDate != null ">
		UPDATE_DATE = #{updateDate},
		</if>
		</set>
		WHERE ID = #{id}
		</update>
		
	
		<!--根据主键删除数据 -->
		<update id="delete"  
		parameterType="HashMap" 
		>
		update  
		ept_storage_settle set IS_DELETE = 1
		where ID in (${par})
		</update>
		
	
		<!--根据出入库单查询费用登记 -->
		<select id="findByStorage"  
		parameterType="HashMap" 
		resultType="HashMap"
		>
		SELECT
	a1. ID AS "id",
	a1.STORAGE_TYPE AS "storageType",
	a1.STORAGE_ID AS "storageId",
	a1.SETTLE_ID AS "settleId",
	a1.NUM_VAL AS "numVal",
	a1.IS_DELETE AS "isDelete",
	a1.CREATE_ID AS "createId",
	a1.CREATE_DATE AS "createDate",
	a1.UPDATE_ID AS "updateId",
	a1.UPDATE_DATE AS "updateDate",
	(
		SELECT
			TYPE_NAME
		FROM
			ept_settle_type c1
		WHERE
			c1. ID = a1.SETTLE_ID
	) AS "settleName"
FROM
	ept_storage_settle a1
WHERE
	a1.STORAGE_TYPE =#{type}
AND a1.STORAGE_ID = #{id}
AND IS_DELETE = 0
		</select>
		
	
</mapper>