PrjBudgetDao.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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.PrjBudgetDao">
  4. <resultMap type="com.liang.entity.PrjBudget" id="PrjBudgetMap">
  5. <result property="id" column="ID" jdbcType="INTEGER"/>
  6. <result property="mc" column="MC" jdbcType="VARCHAR"/>
  7. <result property="ysje" column="YSJE" jdbcType="NUMERIC"/>
  8. <result property="xm" column="XM" jdbcType="INTEGER"/>
  9. <result property="sjje" column="SJJE" jdbcType="NUMERIC"/>
  10. <result property="fj" column="FJ" jdbcType="VARCHAR"/>
  11. <result property="nf" column="NF" jdbcType="INTEGER"/>
  12. <result property="px" column="PX" jdbcType="VARCHAR"/>
  13. <result property="bm" column="BM" jdbcType="VARCHAR"/>
  14. <result property="hjbm" column="HJBM" jdbcType="VARCHAR"/>
  15. <result property="dw1" column="DW1" jdbcType="NUMERIC"/>
  16. <result property="dw2" column="DW2" jdbcType="NUMERIC"/>
  17. <result property="dw3" column="DW3" jdbcType="NUMERIC"/>
  18. <result property="dw4" column="DW4" jdbcType="NUMERIC"/>
  19. <result property="dw5" column="DW5" jdbcType="NUMERIC"/>
  20. <result property="dw6" column="DW6" jdbcType="NUMERIC"/>
  21. <result property="dw7" column="DW7" jdbcType="NUMERIC"/>
  22. <result property="dw8" column="DW8" jdbcType="NUMERIC"/>
  23. <result property="dw9" column="DW9" jdbcType="NUMERIC"/>
  24. <result property="dw10" column="DW10" jdbcType="NUMERIC"/>
  25. <result property="sjys1" column="SJYS1" jdbcType="NUMERIC"/>
  26. <result property="sjys2" column="SJYS2" jdbcType="NUMERIC"/>
  27. <result property="sjys3" column="SJYS3" jdbcType="NUMERIC"/>
  28. <result property="sjys4" column="SJYS4" jdbcType="NUMERIC"/>
  29. <result property="sjys5" column="SJYS5" jdbcType="NUMERIC"/>
  30. <result property="sjys6" column="SJYS6" jdbcType="NUMERIC"/>
  31. <result property="sjys7" column="SJYS7" jdbcType="NUMERIC"/>
  32. <result property="sjys8" column="SJYS8" jdbcType="NUMERIC"/>
  33. <result property="sjys9" column="SJYS9" jdbcType="NUMERIC"/>
  34. <result property="sjys10" column="SJYS10" jdbcType="NUMERIC"/>
  35. <result property="bz" column="BZ" jdbcType="VARCHAR"/>
  36. </resultMap>
  37. <!--查询单个-->
  38. <select id="queryById" resultMap="PrjBudgetMap">
  39. select
  40. ID, MC, YSJE, XM, SJJE, FJ, NF, PX, BM, HJBM, DW1, DW2, DW3, DW4, DW5, DW6, DW7, DW8, DW9, DW10, SJYS1, SJYS2, SJYS3, SJYS4, SJYS5, SJYS6, SJYS7, SJYS8, SJYS9, SJYS10, BZ
  41. from prj_Budget
  42. where ID = #{id}
  43. </select>
  44. <!--查询指定行数据-->
  45. <select id="queryAllByLimit" resultMap="PrjBudgetMap">
  46. select
  47. ID, MC, YSJE, XM, SJJE, FJ, NF, PX, BM, HJBM, DW1, DW2, DW3, DW4, DW5, DW6, DW7, DW8, DW9, DW10, SJYS1, SJYS2, SJYS3, SJYS4, SJYS5, SJYS6, SJYS7, SJYS8, SJYS9, SJYS10, BZ
  48. from prj_Budget
  49. <where>
  50. <if test="id != null">
  51. and ID = #{id}
  52. </if>
  53. <if test="mc != null and mc != ''">
  54. and MC = #{mc}
  55. </if>
  56. <if test="ysje != null">
  57. and YSJE = #{ysje}
  58. </if>
  59. <if test="xm != null">
  60. and XM = #{xm}
  61. </if>
  62. <if test="sjje != null">
  63. and SJJE = #{sjje}
  64. </if>
  65. <if test="fj != null and fj != ''">
  66. and FJ = #{fj}
  67. </if>
  68. <if test="nf != null">
  69. and NF = #{nf}
  70. </if>
  71. <if test="px != null and px != ''">
  72. and PX = #{px}
  73. </if>
  74. <if test="bm != null and bm != ''">
  75. and BM = #{bm}
  76. </if>
  77. <if test="hjbm != null and hjbm != ''">
  78. and HJBM = #{hjbm}
  79. </if>
  80. <if test="dw1 != null">
  81. and DW1 = #{dw1}
  82. </if>
  83. <if test="dw2 != null">
  84. and DW2 = #{dw2}
  85. </if>
  86. <if test="dw3 != null">
  87. and DW3 = #{dw3}
  88. </if>
  89. <if test="dw4 != null">
  90. and DW4 = #{dw4}
  91. </if>
  92. <if test="dw5 != null">
  93. and DW5 = #{dw5}
  94. </if>
  95. <if test="dw6 != null">
  96. and DW6 = #{dw6}
  97. </if>
  98. <if test="dw7 != null">
  99. and DW7 = #{dw7}
  100. </if>
  101. <if test="dw8 != null">
  102. and DW8 = #{dw8}
  103. </if>
  104. <if test="dw9 != null">
  105. and DW9 = #{dw9}
  106. </if>
  107. <if test="dw10 != null">
  108. and DW10 = #{dw10}
  109. </if>
  110. <if test="sjys1 != null">
  111. and SJYS1 = #{sjys1}
  112. </if>
  113. <if test="sjys2 != null">
  114. and SJYS2 = #{sjys2}
  115. </if>
  116. <if test="sjys3 != null">
  117. and SJYS3 = #{sjys3}
  118. </if>
  119. <if test="sjys4 != null">
  120. and SJYS4 = #{sjys4}
  121. </if>
  122. <if test="sjys5 != null">
  123. and SJYS5 = #{sjys5}
  124. </if>
  125. <if test="sjys6 != null">
  126. and SJYS6 = #{sjys6}
  127. </if>
  128. <if test="sjys7 != null">
  129. and SJYS7 = #{sjys7}
  130. </if>
  131. <if test="sjys8 != null">
  132. and SJYS8 = #{sjys8}
  133. </if>
  134. <if test="sjys9 != null">
  135. and SJYS9 = #{sjys9}
  136. </if>
  137. <if test="sjys10 != null">
  138. and SJYS10 = #{sjys10}
  139. </if>
  140. <if test="bz != null and bz != ''">
  141. and BZ = #{bz}
  142. </if>
  143. </where>
  144. limit #{pageable.offset}, #{pageable.pageSize}
  145. </select>
  146. <!--统计总行数-->
  147. <select id="count" resultType="java.lang.Long">
  148. select count(1)
  149. from prj_Budget
  150. <where>
  151. <if test="id != null">
  152. and ID = #{id}
  153. </if>
  154. <if test="mc != null and mc != ''">
  155. and MC = #{mc}
  156. </if>
  157. <if test="ysje != null">
  158. and YSJE = #{ysje}
  159. </if>
  160. <if test="xm != null">
  161. and XM = #{xm}
  162. </if>
  163. <if test="sjje != null">
  164. and SJJE = #{sjje}
  165. </if>
  166. <if test="fj != null and fj != ''">
  167. and FJ = #{fj}
  168. </if>
  169. <if test="nf != null">
  170. and NF = #{nf}
  171. </if>
  172. <if test="px != null and px != ''">
  173. and PX = #{px}
  174. </if>
  175. <if test="bm != null and bm != ''">
  176. and BM = #{bm}
  177. </if>
  178. <if test="hjbm != null and hjbm != ''">
  179. and HJBM = #{hjbm}
  180. </if>
  181. <if test="dw1 != null">
  182. and DW1 = #{dw1}
  183. </if>
  184. <if test="dw2 != null">
  185. and DW2 = #{dw2}
  186. </if>
  187. <if test="dw3 != null">
  188. and DW3 = #{dw3}
  189. </if>
  190. <if test="dw4 != null">
  191. and DW4 = #{dw4}
  192. </if>
  193. <if test="dw5 != null">
  194. and DW5 = #{dw5}
  195. </if>
  196. <if test="dw6 != null">
  197. and DW6 = #{dw6}
  198. </if>
  199. <if test="dw7 != null">
  200. and DW7 = #{dw7}
  201. </if>
  202. <if test="dw8 != null">
  203. and DW8 = #{dw8}
  204. </if>
  205. <if test="dw9 != null">
  206. and DW9 = #{dw9}
  207. </if>
  208. <if test="dw10 != null">
  209. and DW10 = #{dw10}
  210. </if>
  211. <if test="sjys1 != null">
  212. and SJYS1 = #{sjys1}
  213. </if>
  214. <if test="sjys2 != null">
  215. and SJYS2 = #{sjys2}
  216. </if>
  217. <if test="sjys3 != null">
  218. and SJYS3 = #{sjys3}
  219. </if>
  220. <if test="sjys4 != null">
  221. and SJYS4 = #{sjys4}
  222. </if>
  223. <if test="sjys5 != null">
  224. and SJYS5 = #{sjys5}
  225. </if>
  226. <if test="sjys6 != null">
  227. and SJYS6 = #{sjys6}
  228. </if>
  229. <if test="sjys7 != null">
  230. and SJYS7 = #{sjys7}
  231. </if>
  232. <if test="sjys8 != null">
  233. and SJYS8 = #{sjys8}
  234. </if>
  235. <if test="sjys9 != null">
  236. and SJYS9 = #{sjys9}
  237. </if>
  238. <if test="sjys10 != null">
  239. and SJYS10 = #{sjys10}
  240. </if>
  241. <if test="bz != null and bz != ''">
  242. and BZ = #{bz}
  243. </if>
  244. </where>
  245. </select>
  246. <!--新增所有列-->
  247. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  248. insert into prj_Budget(MC, YSJE, XM, SJJE, FJ, NF, PX, BM, HJBM, DW1, DW2, DW3, DW4, DW5, DW6, DW7, DW8, DW9, DW10, SJYS1, SJYS2, SJYS3, SJYS4, SJYS5, SJYS6, SJYS7, SJYS8, SJYS9, SJYS10, BZ)
  249. values (#{mc}, #{ysje}, #{xm}, #{sjje}, #{fj}, #{nf}, #{px}, #{bm}, #{hjbm}, #{dw1}, #{dw2}, #{dw3}, #{dw4}, #{dw5}, #{dw6}, #{dw7}, #{dw8}, #{dw9}, #{dw10}, #{sjys1}, #{sjys2}, #{sjys3}, #{sjys4}, #{sjys5}, #{sjys6}, #{sjys7}, #{sjys8}, #{sjys9}, #{sjys10}, #{bz})
  250. </insert>
  251. <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
  252. insert into prj_Budget(MC, XM, FJ, PX, BM, HJBM, BZ)
  253. values
  254. <foreach collection="entities" item="entity" separator=",">
  255. (#{entity.mc}, #{entity.xm}, #{entity.fj}, #{entity.px}, #{entity.bm}, #{entity.hjbm}, #{entity.bz})
  256. </foreach>
  257. </insert>
  258. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  259. insert into prj_Budget(MC, YSJE, XM, SJJE, FJ, NF, PX, BM, HJBM, DW1, DW2, DW3, DW4, DW5, DW6, DW7, DW8, DW9, DW10, SJYS1, SJYS2, SJYS3, SJYS4, SJYS5, SJYS6, SJYS7, SJYS8, SJYS9, SJYS10, BZ)
  260. values
  261. <foreach collection="entities" item="entity" separator=",">
  262. (#{entity.mc}, #{entity.ysje}, #{entity.xm}, #{entity.sjje}, #{entity.fj}, #{entity.nf}, #{entity.px}, #{entity.bm}, #{entity.hjbm}, #{entity.dw1}, #{entity.dw2}, #{entity.dw3}, #{entity.dw4}, #{entity.dw5}, #{entity.dw6}, #{entity.dw7}, #{entity.dw8}, #{entity.dw9}, #{entity.dw10}, #{entity.sjys1}, #{entity.sjys2}, #{entity.sjys3}, #{entity.sjys4}, #{entity.sjys5}, #{entity.sjys6}, #{entity.sjys7}, #{entity.sjys8}, #{entity.sjys9}, #{entity.sjys10}, #{entity.bz})
  263. </foreach>
  264. on duplicate key update
  265. MC = values(MC),
  266. YSJE = values(YSJE),
  267. XM = values(XM),
  268. SJJE = values(SJJE),
  269. FJ = values(FJ),
  270. NF = values(NF),
  271. PX = values(PX),
  272. BM = values(BM),
  273. HJBM = values(HJBM),
  274. DW1 = values(DW1),
  275. DW2 = values(DW2),
  276. DW3 = values(DW3),
  277. DW4 = values(DW4),
  278. DW5 = values(DW5),
  279. DW6 = values(DW6),
  280. DW7 = values(DW7),
  281. DW8 = values(DW8),
  282. DW9 = values(DW9),
  283. DW10 = values(DW10),
  284. SJYS1 = values(SJYS1),
  285. SJYS2 = values(SJYS2),
  286. SJYS3 = values(SJYS3),
  287. SJYS4 = values(SJYS4),
  288. SJYS5 = values(SJYS5),
  289. SJYS6 = values(SJYS6),
  290. SJYS7 = values(SJYS7),
  291. SJYS8 = values(SJYS8),
  292. SJYS9 = values(SJYS9),
  293. SJYS10 = values(SJYS10),
  294. BZ = values(BZ)
  295. </insert>
  296. <!--通过主键修改数据-->
  297. <update id="update">
  298. update prj_Budget
  299. set YSJE = #{ysje},
  300. DW1 = #{dw1},
  301. DW2 = #{dw2},
  302. DW3 = #{dw3},
  303. DW4 = #{dw4},
  304. DW5 = #{dw5},
  305. DW6 = #{dw6},
  306. DW7 = #{dw7},
  307. DW8 = #{dw8},
  308. DW9 = #{dw9},
  309. DW10 = #{dw10}
  310. where ID = #{id}
  311. </update>
  312. <!--通过主键删除-->
  313. <delete id="deleteById">
  314. delete from prj_Budget where ID = #{id}
  315. </delete>
  316. <!--删除项目预算-->
  317. <delete id="deleteByXm">
  318. delete from prj_Budget where XM = #{xm}
  319. </delete>
  320. <!--批量删除项目预算-->
  321. <delete id="batchDeleteByXm">
  322. delete from prj_Budget
  323. where XM in
  324. <foreach item="item" index="index" collection="xmList" open = "(" separator = "," close = ")">
  325. #{item}
  326. </foreach>
  327. </delete>
  328. <!--获取项目预算-->
  329. <select id="getBudgetList" resultMap="PrjBudgetMap" parameterType="map">
  330. select b.*, p.ZWMC as XMMC
  331. from prj_Budget b
  332. left join prj_Project p on p.ID = b.XM
  333. where b.XM = #{xm}
  334. </select>
  335. <!--通过项目修改数据-->
  336. <update id="updateYsByXm">
  337. update prj_Budget
  338. <set>
  339. <if test="count == 0">
  340. DW1 = NULL, DW2 = NULL, DW3 = NULL, DW4 = NULL, DW5 = NULL, DW6 = NULL, DW7 = NULL, DW8 = NULL, DW9 = NULL, DW10 = NULL,
  341. </if>
  342. <if test="count == 1">
  343. DW2 = NULL, DW3 = NULL, DW4 = NULL, DW5 = NULL, DW6 = NULL, DW7 = NULL, DW8 = NULL, DW9 = NULL, DW10 = NULL,
  344. </if>
  345. <if test="count == 2">
  346. DW3 = NULL, DW4 = NULL, DW5 = NULL, DW6 = NULL, DW7 = NULL, DW8 = NULL, DW9 = NULL, DW10 = NULL,
  347. </if>
  348. <if test="count == 3">
  349. DW4 = NULL, DW5 = NULL, DW6 = NULL, DW7 = NULL, DW8 = NULL, DW9 = NULL, DW10 = NULL,
  350. </if>
  351. <if test="count == 4">
  352. DW5 = NULL, DW6 = NULL, DW7 = NULL, DW8 = NULL, DW9 = NULL, DW10 = NULL,
  353. </if>
  354. <if test="count == 5">
  355. DW6 = NULL, DW7 = NULL, DW8 = NULL, DW9 = NULL, DW10 = NULL,
  356. </if>
  357. <if test="count == 6">
  358. DW7 = NULL, DW8 = NULL, DW9 = NULL, DW10 = NULL,
  359. </if>
  360. <if test="count == 7">
  361. DW8 = NULL, DW9 = NULL, DW10 = NULL,
  362. </if>
  363. <if test="count == 8">
  364. DW9 = NULL, DW10 = NULL,
  365. </if>
  366. <if test="count == 9">
  367. DW10 = NULL,
  368. </if>
  369. </set>
  370. where XM = #{xm}
  371. </update>
  372. <update id="updateYSYE">
  373. update prj_Budget
  374. set YSJE = (case when DW1 IS NULL then 0 else DW1 end + case when DW2 IS NULL then 0 else DW2 end
  375. + case when DW3 IS NULL then 0 else DW3 end + case when DW4 IS NULL then 0 else DW4 end
  376. + case when DW5 IS NULL then 0 else DW5 end + case when DW6 IS NULL then 0 else DW6 end
  377. + case when DW7 IS NULL then 0 else DW7 end + case when DW8 IS NULL then 0 else DW8 end
  378. + case when DW9 IS NULL then 0 else DW9 end + case when DW10 IS NULL then 0 else DW10 end)
  379. where XM = #{xm}
  380. </update>
  381. <update id="emptyYSYE">
  382. update prj_Budget
  383. set YSJE = NULL
  384. where XM = #{xm} and YSJE = 0
  385. </update>
  386. </mapper>