ContainerMapper.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.tld.mapper.ContainerMapper">
  5. <sql id="field">
  6. id,department,type,container_name,num,create_time
  7. </sql>
  8. <!-- 查询容器 -->
  9. <select id="getContainer" resultType="com.tld.model.Container">
  10. select
  11. a.id,
  12. b.name as department,
  13. a.department as departmentId,
  14. a.type,
  15. a.container_name,
  16. a.num,
  17. a.code,
  18. a.create_time,
  19. a.modify_time as modifyTime,
  20. c.user_name as modifyUser
  21. from tld_container a
  22. left join tld_department b on a.department = b.code
  23. left join tld_user c on a.modify_user = c.id
  24. <trim prefix="WHERE" prefixOverrides="and |or">
  25. <if test="department != null and department != ''">
  26. and a.department = #{department}
  27. </if>
  28. <if test="id != null and id != ''">
  29. and a.id = #{id}
  30. </if>
  31. <if test="type != null and type != ''">
  32. and a.type = #{type}
  33. </if>
  34. <if test="containerName != null and containerName != ''">
  35. and a.container_name like CONCAT(CONCAT('%', #{containerName}), '%')
  36. </if>
  37. </trim>
  38. order by a.id desc
  39. </select>
  40. <!-- 新增容器内容 -->
  41. <insert id="addContainer">
  42. insert into tld_container(department,type,container_name,num,code,create_time,modify_user,modify_time)
  43. values(#{department},#{type},#{containerName},#{num},#{code},NOW(),#{modifyUser},NOW())
  44. </insert>
  45. <!-- 修改容器内容 -->
  46. <update id="updateContainer">
  47. update tld_container
  48. <set>
  49. <trim suffixOverrides=",">
  50. <if test="department != null">
  51. department = #{department},
  52. </if>
  53. <if test="type != null">
  54. type = #{type},
  55. </if>
  56. <if test="containerName != null">
  57. container_name = #{containerName},
  58. </if>
  59. <if test="num != null">
  60. num = #{num},
  61. </if>
  62. <if test="code != null">
  63. code = #{code},
  64. </if>
  65. modify_user = #{modifyUser} ,
  66. modify_time = NOW(),
  67. </trim>
  68. </set>
  69. where id = #{id}
  70. </update>
  71. <!-- 废弃 -->
  72. <delete id="delContainer">
  73. delete from tld_container where id = #{id}
  74. </delete>
  75. <!-- 查询导出内容 -->
  76. <select id="export" resultType="java.util.LinkedHashMap">
  77. select
  78. b.name as department,
  79. a.type,
  80. a.code as code,
  81. a.container_name,
  82. a.num,
  83. a.create_time
  84. from tld_container a
  85. left join tld_department b on a.department = b.code
  86. <trim prefix="WHERE" prefixOverrides="and |or">
  87. <if test="department != null and department != ''">
  88. and a.department = #{department}
  89. </if>
  90. <if test="id != null and id != ''">
  91. and a.id = #{id}
  92. </if>
  93. <if test="type != null and type != ''">
  94. and a.type = #{type}
  95. </if>
  96. <if test="containerName != null and containerName != ''">
  97. and a.container_name = #{containerName}
  98. </if>
  99. </trim>
  100. order by a.id desc
  101. </select>
  102. <!-- 新增报废日志 -->
  103. <insert id="addScrap">
  104. insert into tld_scrap(operation_name,scrap_cause,scrap_time,scrap_num,container_name)
  105. values(#{operationName},#{scrapCause},DATE_FORMAT(NOW(), '%Y-%m-%d'),#{scrapNum},#{containerName})
  106. </insert>
  107. <!-- 查询报废日志 -->
  108. <select id="getScrap" resultType="com.tld.model.Scrap">
  109. select
  110. a.id,
  111. b.user_name as operationName,
  112. a.scrap_cause,
  113. a.scrap_time,
  114. a.scrap_num,
  115. c.container_name as containerName
  116. from tld_scrap a
  117. left join tld_user b on a.operation_name = b.id
  118. left join tld_container c on a.container_name = c.id
  119. <where>
  120. <if test="startTime != null and startTime != ''">
  121. and a.scrap_time <![CDATA[>=]]> #{startTime}
  122. </if>
  123. <if test="endTime != null and endTime != ''">
  124. and a.scrap_time <![CDATA[<=]]> #{endTime}
  125. </if>
  126. <if test="containerName != null and containerName != ''">
  127. and a.container_name = #{containerName}
  128. </if>
  129. </where>
  130. </select>
  131. <!-- 导出报废日志 -->
  132. <select id="exportScrap" resultType="java.util.LinkedHashMap">
  133. select
  134. b.user_name as operationName,
  135. a.scrap_cause,
  136. a.scrap_time,
  137. a.scrap_num,
  138. c.container_name as containerName
  139. from tld_scrap a
  140. left join tld_user b on a.operation_name = b.id
  141. left join tld_container c on a.container_name = c.id
  142. <where>
  143. <if test="startTime != null and startTime != ''">
  144. and a.scrap_time <![CDATA[>=]]> #{startTime}
  145. </if>
  146. <if test="endTime != null and endTime != ''">
  147. and a.scrap_time <![CDATA[<=]]> #{endTime}
  148. </if>
  149. <if test="containerName != null and containerName != ''">
  150. and a.container_name = #{containerName}
  151. </if>
  152. </where>
  153. </select>
  154. </mapper>