<?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.javaweb.geo.mapper.TubLogMapper">
|
|
<resultMap type="TubLog" id="TubLogResult">
|
<result property="id" column="id" />
|
<result property="code" column="code" />
|
<result property="projectId" column="project_id" />
|
<result property="tubName" column="tub_name" />
|
<result property="type" column="type" />
|
<result property="outboundDate" column="outbound_date" />
|
<result property="inboundDate" column="inbound_date" />
|
<result property="optUser" column="opt_user" />
|
<result property="applyUser" column="apply_user" />
|
<result property="number" column="number" />
|
<result property="unit" column="unit" />
|
<result property="createDate" column="create_date" />
|
<result property="remark" column="remark" />
|
<result property="outboundNumber" column="outbound_number" />
|
<result property="inboundNumber" column="inbound_number" />
|
</resultMap>
|
|
<sql id="selectTubLogVo">
|
select id, code, project_id, tub_name, type, outbound_date, inbound_date, opt_user, apply_user, number, unit, create_date, remark from js_tub_log
|
</sql>
|
|
<select id="selectTubLogList" parameterType="TubLog" resultMap="TubLogResult">
|
<include refid="selectTubLogVo"/>
|
<where>
|
<if test="code != null and code != ''"> and code = #{code}</if>
|
<if test="projectId != null and projectId != ''"> and project_id = #{projectId}</if>
|
<if test="tubName != null and tubName != ''"> and tub_name like concat('%', #{tubName}, '%')</if>
|
<if test="type != null and type != ''"> and type = #{type}</if>
|
<if test="outboundDate != null "> and outbound_date = #{outboundDate}</if>
|
<if test="inboundDate != null "> and inbound_date = #{inboundDate}</if>
|
<if test="optUser != null and optUser != ''"> and opt_user = #{optUser}</if>
|
<if test="applyUser != null and applyUser != ''"> and apply_user = #{applyUser}</if>
|
<if test="number != null "> and number = #{number}</if>
|
<if test="unit != null and unit != ''"> and unit = #{unit}</if>
|
<if test="createDate != null "> and create_date = #{createDate}</if>
|
</where>
|
</select>
|
|
<select id="selectTubLogById" parameterType="Integer" resultMap="TubLogResult">
|
<include refid="selectTubLogVo"/>
|
where id = #{id}
|
</select>
|
|
<select id="selectMaxTubLogId" resultType="java.lang.Integer">
|
SELECT MAX(id) FROM js_tub_log where project_id = #{projectId}
|
</select>
|
|
<select id="countTubLogDate" resultMap="TubLogResult">
|
SELECT
|
a.tub_name,
|
b.inbound_number,
|
a.outbound_number,
|
a.unit
|
FROM
|
( SELECT tub_name, SUM( number ) AS outbound_number, unit FROM js_tub_log WHERE outbound_date IS NOT NULL GROUP BY tub_name ) a
|
LEFT JOIN ( SELECT tub_name, SUM( number ) AS inbound_number, unit FROM js_tub_log WHERE inbound_date IS NOT NULL GROUP BY tub_name ) b ON a.tub_name = b.tub_name
|
</select>
|
|
<insert id="insertTubLog" parameterType="TubLog" useGeneratedKeys="true" keyProperty="id">
|
insert into js_tub_log
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="code != null and code != ''">code,</if>
|
<if test="projectId != null and projectId != ''">project_id,</if>
|
<if test="tubName != null and tubName != ''">tub_name,</if>
|
<if test="type != null and type != ''">type,</if>
|
<if test="outboundDate != null ">outbound_date,</if>
|
<if test="inboundDate != null ">inbound_date,</if>
|
<if test="optUser != null and optUser != ''">opt_user,</if>
|
<if test="applyUser != null and applyUser != ''">apply_user,</if>
|
<if test="number != null ">number,</if>
|
<if test="unit != null and unit != ''">unit,</if>
|
<if test="createDate != null ">create_date,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="code != null and code != ''">#{code},</if>
|
<if test="projectId != null and projectId != ''">#{projectId},</if>
|
<if test="tubName != null and tubName != ''">#{tubName},</if>
|
<if test="type != null and type != ''">#{type},</if>
|
<if test="outboundDate != null ">#{outboundDate},</if>
|
<if test="inboundDate != null ">#{inboundDate},</if>
|
<if test="optUser != null and optUser != ''">#{optUser},</if>
|
<if test="applyUser != null and applyUser != ''">#{applyUser},</if>
|
<if test="number != null ">#{number},</if>
|
<if test="unit != null and unit != ''">#{unit},</if>
|
<if test="createDate != null ">#{createDate},</if>
|
<if test="remark != null and remark != ''">#{remark},</if>
|
</trim>
|
</insert>
|
|
<update id="updateTubLog" parameterType="TubLog">
|
update js_tub_log
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="code != null and code != ''">code = #{code},</if>
|
<if test="projectId != null and projectId != ''">project_id = #{projectId},</if>
|
<if test="tubName != null and tubName != ''">tub_name = #{tubName},</if>
|
<if test="type != null and type != ''">type = #{type},</if>
|
<if test="outboundDate != null ">outbound_date = #{outboundDate},</if>
|
<if test="inboundDate != null ">inbound_date = #{inboundDate},</if>
|
<if test="optUser != null and optUser != ''">opt_user = #{optUser},</if>
|
<if test="applyUser != null and applyUser != ''">apply_user = #{applyUser},</if>
|
<if test="number != null ">number = #{number},</if>
|
<if test="unit != null and unit != ''">unit = #{unit},</if>
|
<if test="createDate != null ">create_date = #{createDate},</if>
|
<if test="remark != null and remark != ''">remark = #{remark},</if>
|
</trim>
|
where id = #{id}
|
</update>
|
|
<delete id="deleteTubLogById" parameterType="Integer">
|
delete from js_tub_log where id = #{id}
|
</delete>
|
|
<delete id="deleteTubLogByIds" parameterType="String">
|
delete from js_tub_log where id in
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
|
</mapper>
|