StaMaterialDao.xml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.liang.dao.StaMaterialDao">
  4. <resultMap type="com.liang.entity.StaMaterial" id="StaMaterialMap">
  5. <result property="id" column="ID" jdbcType="INTEGER"/>
  6. <result property="zb" column="ZB" jdbcType="INTEGER"/>
  7. <result property="fysq" column="FYSQ" jdbcType="NUMERIC"/>
  8. <result property="clmc" column="CLMC" jdbcType="VARCHAR"/>
  9. <result property="wlbm" column="WLBM" jdbcType="VARCHAR"/>
  10. <result property="cgdj" column="CGDJ" jdbcType="NUMERIC"/>
  11. <result property="bhsje" column="BHSJE" jdbcType="NUMERIC"/>
  12. <result property="hsje" column="HSJE" jdbcType="NUMERIC"/>
  13. <result property="bz" column="BZ" jdbcType="VARCHAR"/>
  14. </resultMap>
  15. <!--查询单个-->
  16. <select id="queryById" resultMap="StaMaterialMap">
  17. select
  18. ID, ZB, FYSQ, CLMC, WLBM, CGDJ, BHSJE, HSJE, BZ
  19. from sta_Material
  20. where ID = #{id}
  21. </select>
  22. <!--查询指定行数据-->
  23. <select id="queryAllByLimit" resultMap="StaMaterialMap">
  24. select
  25. ID, ZB, FYSQ, CLMC, WLBM, CGDJ, BHSJE, HSJE, BZ
  26. from sta_Material
  27. <where>
  28. <if test="id != null">
  29. and ID = #{id}
  30. </if>
  31. <if test="zb != null">
  32. and ZB = #{zb}
  33. </if>
  34. <if test="fysq != null">
  35. and FYSQ = #{fysq}
  36. </if>
  37. <if test="clmc != null and clmc != ''">
  38. and CLMC = #{clmc}
  39. </if>
  40. <if test="wlbm != null and wlbm != ''">
  41. and WLBM = #{wlbm}
  42. </if>
  43. <if test="cgdj != null">
  44. and CGDJ = #{cgdj}
  45. </if>
  46. <if test="bhsje != null">
  47. and BHSJE = #{bhsje}
  48. </if>
  49. <if test="hsje != null">
  50. and HSJE = #{hsje}
  51. </if>
  52. <if test="bz != null and bz != ''">
  53. and BZ = #{bz}
  54. </if>
  55. </where>
  56. limit #{pageable.offset}, #{pageable.pageSize}
  57. </select>
  58. <!--统计总行数-->
  59. <select id="count" resultType="java.lang.Long">
  60. select count(1)
  61. from sta_Material
  62. <where>
  63. <if test="id != null">
  64. and ID = #{id}
  65. </if>
  66. <if test="zb != null">
  67. and ZB = #{zb}
  68. </if>
  69. <if test="fysq != null">
  70. and FYSQ = #{fysq}
  71. </if>
  72. <if test="clmc != null and clmc != ''">
  73. and CLMC = #{clmc}
  74. </if>
  75. <if test="wlbm != null and wlbm != ''">
  76. and WLBM = #{wlbm}
  77. </if>
  78. <if test="cgdj != null">
  79. and CGDJ = #{cgdj}
  80. </if>
  81. <if test="bhsje != null">
  82. and BHSJE = #{bhsje}
  83. </if>
  84. <if test="hsje != null">
  85. and HSJE = #{hsje}
  86. </if>
  87. <if test="bz != null and bz != ''">
  88. and BZ = #{bz}
  89. </if>
  90. </where>
  91. </select>
  92. <!--新增所有列-->
  93. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  94. insert into sta_Material(ZB, FYSQ, CLMC, WLBM, CGDJ, BHSJE, HSJE, BZ)
  95. values (#{zb}, #{fysq}, #{clmc}, #{wlbm}, #{cgdj}, #{bhsje}, #{hsje}, #{bz})
  96. </insert>
  97. <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
  98. insert into sta_Material(ZB, FYSQ, CLMC, WLBM, CGDJ, BHSJE, HSJE, BZ)
  99. values
  100. <foreach collection="entities" item="entity" separator=",">
  101. (#{entity.zb}, #{entity.fysq}, #{entity.clmc}, #{entity.wlbm}, #{entity.cgdj}, #{entity.bhsje}, #{entity.hsje}, #{entity.bz})
  102. </foreach>
  103. </insert>
  104. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  105. insert into sta_Material(ZB, FYSQ, CLMC, WLBM, CGDJ, BHSJE, HSJE, BZ)
  106. values
  107. <foreach collection="entities" item="entity" separator=",">
  108. (#{entity.zb}, #{entity.fysq}, #{entity.clmc}, #{entity.wlbm}, #{entity.cgdj}, #{entity.bhsje}, #{entity.hsje}, #{entity.bz})
  109. </foreach>
  110. on duplicate key update
  111. ZB = values(ZB),
  112. FYSQ = values(FYSQ),
  113. CLMC = values(CLMC),
  114. WLBM = values(WLBM),
  115. CGDJ = values(CGDJ),
  116. BHSJE = values(BHSJE),
  117. HSJE = values(HSJE),
  118. BZ = values(BZ)
  119. </insert>
  120. <!--通过主键修改数据-->
  121. <update id="update">
  122. update sta_Material
  123. <set>
  124. <if test="zb != null">
  125. ZB = #{zb},
  126. </if>
  127. <if test="fysq != null">
  128. FYSQ = #{fysq},
  129. </if>
  130. <if test="clmc != null and clmc != ''">
  131. CLMC = #{clmc},
  132. </if>
  133. <if test="wlbm != null and wlbm != ''">
  134. WLBM = #{wlbm},
  135. </if>
  136. <if test="cgdj != null">
  137. CGDJ = #{cgdj},
  138. </if>
  139. <if test="bhsje != null">
  140. BHSJE = #{bhsje},
  141. </if>
  142. <if test="hsje != null">
  143. HSJE = #{hsje},
  144. </if>
  145. <if test="bz != null and bz != ''">
  146. BZ = #{bz},
  147. </if>
  148. </set>
  149. where ID = #{id}
  150. </update>
  151. <!--通过主键删除-->
  152. <delete id="deleteById">
  153. delete from sta_Material where ID = #{id}
  154. </delete>
  155. <!--获取材料费列表-->
  156. <select id="getList" resultMap="StaMaterialMap">
  157. select *
  158. from sta_Material
  159. where ZB = #{zb}
  160. </select>
  161. <!--通过主表删除-->
  162. <delete id="deleteByZb">
  163. delete from sta_Material where ZB = #{zb}
  164. </delete>
  165. <!--批量删除-->
  166. <delete id="batchDeleteByZb" parameterType="java.util.ArrayList">
  167. delete from sta_Material
  168. where ZB in
  169. <foreach item="item" index="index" collection="zbList" open = "(" separator = "," close = ")">
  170. #{item}
  171. </foreach>
  172. </delete>
  173. <!--统计报表(材料费)查询 -->
  174. <select id="searchMaterialCost" resultType="Map">
  175. SELECT sta_Material.ID,
  176. sys_dept_info.dept_name AS BM,
  177. prj_Project.BM AS XMBH,
  178. sta_BudgetApproval.XMMC,
  179. base_ProjectType.XMLXMC,
  180. sta_Material.FYSQ,
  181. sta_Material.CLMC,
  182. sta_Material.WLBM,
  183. sta_Material.CGDJ,
  184. sta_Material.BHSJE,
  185. sta_Material.HSJE,
  186. CASE
  187. WHEN sta_BudgetApproval.SFBYJ = 0 THEN '否'
  188. WHEN sta_BudgetApproval.SFBYJ = 1 THEN '是'
  189. ELSE CAST(sta_BudgetApproval.SFBYJ AS varchar(11))
  190. END AS SFBYJ,
  191. sta_Material.BZ,
  192. CAST(sta_BudgetApproval.SQSJ AS date) AS SQSJ
  193. FROM sta_Material,
  194. sta_BudgetApproval,
  195. prj_Project,
  196. base_ProjectType,
  197. sys_dept_info
  198. WHERE sta_Material.ZB = sta_BudgetApproval.ID
  199. AND sta_BudgetApproval.XMID = prj_Project.ID
  200. AND sta_BudgetApproval.SSBM = sys_dept_info.dept_id
  201. AND sta_BudgetApproval.XMLX = base_ProjectType.XMLX
  202. <if test="MC != null and MC != ''">
  203. AND sta_BudgetApproval.XMMC LIKE '%${MC}%'
  204. </if>
  205. <if test="CLMC != null and CLMC != ''">
  206. AND sta_Material.CLMC LIKE '%${CLMC}%'
  207. </if>
  208. <if test="WLBM != null and WLBM != ''">
  209. AND sta_Material.WLBM LIKE '%${WLBM}%'
  210. </if>
  211. <if test="BZ != null and BZ != ''">
  212. AND sta_Material.BZ LIKE '%${BZ}%'
  213. </if>
  214. <if test="QSRQ != null and QSRQ != ''">
  215. AND sta_BudgetApproval.SQSJ <![CDATA[>= ]]> #{QSRQ}
  216. </if>
  217. <if test="JZRQ != null and JZRQ != ''">
  218. AND sta_BudgetApproval.SQSJ <![CDATA[<= ]]> #{JZRQ}
  219. </if>
  220. </select>
  221. </mapper>