123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <?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.tld.mapper.ContainerMapper">
- <sql id="field">
- id,department,type,container_name,num,create_time
- </sql>
- <!-- 查询容器 -->
- <select id="getContainer" resultType="com.tld.model.Container">
- select
- a.id,
- b.name as department,
- a.department as departmentId,
- a.type,
- a.container_name,
- a.num,
- a.code,
- a.create_time,
- a.modify_time as modifyTime,
- c.user_name as modifyUser
- from tld_container a
- left join tld_department b on a.department = b.code
- left join tld_user c on a.modify_user = c.id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="department != null and department != ''">
- and a.department = #{department}
- </if>
- <if test="id != null and id != ''">
- and a.id = #{id}
- </if>
- <if test="type != null and type != ''">
- and a.type = #{type}
- </if>
- <if test="containerName != null and containerName != ''">
- and a.container_name like CONCAT(CONCAT('%', #{containerName}), '%')
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 新增容器内容 -->
- <insert id="addContainer">
- insert into tld_container(department,type,container_name,num,code,create_time,modify_user,modify_time)
- values(#{department},#{type},#{containerName},#{num},#{code},NOW(),#{modifyUser},NOW())
- </insert>
- <!-- 修改容器内容 -->
- <update id="updateContainer">
- update tld_container
- <set>
- <trim suffixOverrides=",">
- <if test="department != null">
- department = #{department},
- </if>
- <if test="type != null">
- type = #{type},
- </if>
- <if test="containerName != null">
- container_name = #{containerName},
- </if>
- <if test="num != null">
- num = #{num},
- </if>
- <if test="code != null">
- code = #{code},
- </if>
- modify_user = #{modifyUser} ,
- modify_time = NOW(),
- </trim>
- </set>
- where id = #{id}
- </update>
- <!-- 废弃 -->
- <delete id="delContainer">
- delete from tld_container where id = #{id}
- </delete>
- <!-- 查询导出内容 -->
- <select id="export" resultType="java.util.LinkedHashMap">
- select
- b.name as department,
- a.type,
- a.code as code,
- a.container_name,
- a.num,
- a.create_time
- from tld_container a
- left join tld_department b on a.department = b.code
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="department != null and department != ''">
- and a.department = #{department}
- </if>
- <if test="id != null and id != ''">
- and a.id = #{id}
- </if>
- <if test="type != null and type != ''">
- and a.type = #{type}
- </if>
- <if test="containerName != null and containerName != ''">
- and a.container_name = #{containerName}
- </if>
- </trim>
- order by a.id desc
- </select>
- <!-- 新增报废日志 -->
- <insert id="addScrap">
- insert into tld_scrap(operation_name,scrap_cause,scrap_time,scrap_num,container_name)
- values(#{operationName},#{scrapCause},DATE_FORMAT(NOW(), '%Y-%m-%d'),#{scrapNum},#{containerName})
- </insert>
- <!-- 查询报废日志 -->
- <select id="getScrap" resultType="com.tld.model.Scrap">
- select
- a.id,
- b.user_name as operationName,
- a.scrap_cause,
- a.scrap_time,
- a.scrap_num,
- c.container_name as containerName
- from tld_scrap a
- left join tld_user b on a.operation_name = b.id
- left join tld_container c on a.container_name = c.id
- <where>
- <if test="startTime != null and startTime != ''">
- and a.scrap_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.scrap_time <![CDATA[<=]]> #{endTime}
- </if>
- <if test="containerName != null and containerName != ''">
- and a.container_name = #{containerName}
- </if>
- </where>
- </select>
- <!-- 导出报废日志 -->
- <select id="exportScrap" resultType="java.util.LinkedHashMap">
- select
- b.user_name as operationName,
- a.scrap_cause,
- a.scrap_time,
- a.scrap_num,
- c.container_name as containerName
- from tld_scrap a
- left join tld_user b on a.operation_name = b.id
- left join tld_container c on a.container_name = c.id
- <where>
- <if test="startTime != null and startTime != ''">
- and a.scrap_time <![CDATA[>=]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and a.scrap_time <![CDATA[<=]]> #{endTime}
- </if>
- <if test="containerName != null and containerName != ''">
- and a.container_name = #{containerName}
- </if>
- </where>
- </select>
- </mapper>
|