PrjBudgetDao.xml 16 KB

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