StaBudgetapprovalDao.xml 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  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.StaBudgetapprovalDao">
  4. <resultMap type="com.liang.entity.StaBudgetapproval" id="StaBudgetapprovalMap">
  5. <result property="id" column="ID" jdbcType="INTEGER"/>
  6. <result property="xmmc" column="XMMC" jdbcType="VARCHAR"/>
  7. <result property="xmid" column="XMID" jdbcType="INTEGER"/>
  8. <result property="bh" column="BH" jdbcType="VARCHAR"/>
  9. <result property="sqsm" column="SQSM" jdbcType="VARCHAR"/>
  10. <result property="sqje" column="SQJE" jdbcType="NUMERIC"/>
  11. <result property="fylb" column="FYLB" jdbcType="INTEGER"/>
  12. <result property="bbm" column="BBM" jdbcType="VARCHAR"/>
  13. <result property="fj" column="FJ" jdbcType="VARCHAR"/>
  14. <result property="shzt" column="SHZT" jdbcType="VARCHAR"/>
  15. <result property="nf" column="NF" jdbcType="VARCHAR"/>
  16. <result property="sqr" column="SQR" jdbcType="INTEGER"/>
  17. <result property="sqrxm" column="SQRXM" jdbcType="VARCHAR"/>
  18. <result property="sqsj" column="SQSJ" jdbcType="TIMESTAMP"/>
  19. <result property="sqmc" column="SQMC" jdbcType="VARCHAR"/>
  20. <result property="spzt" column="SPZT" jdbcType="VARCHAR"/>
  21. <result property="kyfyxx" column="KYFYXX" jdbcType="VARCHAR"/>
  22. <result property="bzje" column="BZJE" jdbcType="NUMERIC"/>
  23. <result property="bxpz" column="BXPZ" jdbcType="VARCHAR"/>
  24. <result property="bzje2" column="BZJE2" jdbcType="NUMERIC"/>
  25. <result property="sfbyj" column="SFBYJ" jdbcType="VARCHAR"/>
  26. <result property="kybg" column="KYBG" jdbcType="VARCHAR"/>
  27. <result property="erpbh" column="ERPBH" jdbcType="VARCHAR"/>
  28. <result property="xmlx" column="XMLX" jdbcType="VARCHAR"/>
  29. <result property="xmfzr" column="XMFZR" jdbcType="INTEGER"/>
  30. <result property="ssbm" column="SSBM" jdbcType="INTEGER"/>
  31. <result property="sfbz" column="SFBZ" jdbcType="VARCHAR"/>
  32. <result property="smwj" column="SMWJ" jdbcType="VARCHAR"/>
  33. <result property="bhsje" column="BHSJE" jdbcType="NUMERIC"/>
  34. <result property="sf" column="SF" jdbcType="NUMERIC"/>
  35. <result property="nys" column="NYS" jdbcType="INTEGER"/>
  36. <result property="bz" column="BZ" jdbcType="VARCHAR"/>
  37. </resultMap>
  38. <!--查询单个-->
  39. <select id="queryById" resultMap="StaBudgetapprovalMap">
  40. select b.*, d.YSJE
  41. from sta_BudgetApproval b
  42. left join prj_AnnualBudgetDetail d on d.NYS = b.NYS and d.ID = b.FYLB
  43. where b.ID = #{id}
  44. </select>
  45. <select id="queryByBH" resultMap="StaBudgetapprovalMap">
  46. select *
  47. from sta_BudgetApproval
  48. where BH like #{bh}+'%' order by ID desc
  49. </select>
  50. <!--查询指定行数据-->
  51. <select id="queryAllByLimit" resultMap="StaBudgetapprovalMap">
  52. select *
  53. from s
  54. <where>
  55. <if test="id != null">
  56. and ID = #{id}
  57. </if>
  58. <if test="xmmc != null and xmmc != ''">
  59. and XMMC = #{xmmc}
  60. </if>
  61. <if test="xmid != null">
  62. and XMID = #{xmid}
  63. </if>
  64. <if test="bh != null and bh != ''">
  65. and BH = #{bh}
  66. </if>
  67. <if test="sqsm != null and sqsm != ''">
  68. and SQSM = #{sqsm}
  69. </if>
  70. <if test="sqje != null">
  71. and SQJE = #{sqje}
  72. </if>
  73. <if test="fylb != null">
  74. and FYLB = #{fylb}
  75. </if>
  76. <if test="bbm != null and bbm != ''">
  77. and BBM = #{bbm}
  78. </if>
  79. <if test="fj != null and fj != ''">
  80. and FJ = #{fj}
  81. </if>
  82. <if test="shzt != null and shzt != ''">
  83. and SHZT = #{shzt}
  84. </if>
  85. <if test="nf != null and nf != ''">
  86. and NF = #{nf}
  87. </if>
  88. <if test="sqr != null">
  89. and SQR = #{sqr}
  90. </if>
  91. <if test="sqrxm != null and sqrxm != ''">
  92. and SQRXM = #{sqrxm}
  93. </if>
  94. <if test="sqsj != null">
  95. and SQSJ = #{sqsj}
  96. </if>
  97. <if test="sqmc != null and sqmc != ''">
  98. and SQMC = #{sqmc}
  99. </if>
  100. <if test="spzt != null and spzt != ''">
  101. and SPZT = #{spzt}
  102. </if>
  103. <if test="kyfyxx != null and kyfyxx != ''">
  104. and KYFYXX = #{kyfyxx}
  105. </if>
  106. <if test="bzje != null">
  107. and BZJE = #{bzje}
  108. </if>
  109. <if test="bxpz != null and bxpz != ''">
  110. and BXPZ = #{bxpz}
  111. </if>
  112. <if test="bzje2 != null">
  113. and BZJE2 = #{bzje2}
  114. </if>
  115. <if test="sfbyj != null and sfbyj != ''">
  116. and SFBYJ = #{sfbyj}
  117. </if>
  118. <if test="kybg != null and kybg != ''">
  119. and KYBG = #{kybg}
  120. </if>
  121. <if test="erpbh != null and erpbh != ''">
  122. and ERPBH = #{erpbh}
  123. </if>
  124. <if test="xmlx != null and xmlx != ''">
  125. and XMLX = #{xmlx}
  126. </if>
  127. <if test="xmfzr != null">
  128. and XMFZR = #{xmfzr}
  129. </if>
  130. <if test="ssbm != null">
  131. and SSBM = #{ssbm}
  132. </if>
  133. <if test="sfbz != null and sfbz != ''">
  134. and SFBZ = #{sfbz}
  135. </if>
  136. <if test="smwj != null and smwj != ''">
  137. and SMWJ = #{smwj}
  138. </if>
  139. <if test="bhsje != null">
  140. and BHSJE = #{bhsje}
  141. </if>
  142. <if test="sf != null">
  143. and SF = #{sf}
  144. </if>
  145. <if test="nys != null">
  146. and NYS = #{nys}
  147. </if>
  148. </where>
  149. limit #{pageable.offset}, #{pageable.pageSize}
  150. </select>
  151. <!--统计总行数-->
  152. <select id="count" resultType="java.lang.Long">
  153. select count(1)
  154. from sta_BudgetApproval
  155. <where>
  156. <if test="id != null">
  157. and ID = #{id}
  158. </if>
  159. <if test="xmmc != null and xmmc != ''">
  160. and XMMC = #{xmmc}
  161. </if>
  162. <if test="xmid != null">
  163. and XMID = #{xmid}
  164. </if>
  165. <if test="bh != null and bh != ''">
  166. and BH = #{bh}
  167. </if>
  168. <if test="sqsm != null and sqsm != ''">
  169. and SQSM = #{sqsm}
  170. </if>
  171. <if test="sqje != null">
  172. and SQJE = #{sqje}
  173. </if>
  174. <if test="fylb != null">
  175. and FYLB = #{fylb}
  176. </if>
  177. <if test="bbm != null and bbm != ''">
  178. and BBM = #{bbm}
  179. </if>
  180. <if test="fj != null and fj != ''">
  181. and FJ = #{fj}
  182. </if>
  183. <if test="shzt != null and shzt != ''">
  184. and SHZT = #{shzt}
  185. </if>
  186. <if test="nf != null and nf != ''">
  187. and NF = #{nf}
  188. </if>
  189. <if test="sqr != null">
  190. and SQR = #{sqr}
  191. </if>
  192. <if test="sqrxm != null and sqrxm != ''">
  193. and SQRXM = #{sqrxm}
  194. </if>
  195. <if test="sqsj != null">
  196. and SQSJ = #{sqsj}
  197. </if>
  198. <if test="sqmc != null and sqmc != ''">
  199. and SQMC = #{sqmc}
  200. </if>
  201. <if test="spzt != null and spzt != ''">
  202. and SPZT = #{spzt}
  203. </if>
  204. <if test="kyfyxx != null and kyfyxx != ''">
  205. and KYFYXX = #{kyfyxx}
  206. </if>
  207. <if test="bzje != null">
  208. and BZJE = #{bzje}
  209. </if>
  210. <if test="bxpz != null and bxpz != ''">
  211. and BXPZ = #{bxpz}
  212. </if>
  213. <if test="bzje2 != null">
  214. and BZJE2 = #{bzje2}
  215. </if>
  216. <if test="sfbyj != null and sfbyj != ''">
  217. and SFBYJ = #{sfbyj}
  218. </if>
  219. <if test="kybg != null and kybg != ''">
  220. and KYBG = #{kybg}
  221. </if>
  222. <if test="erpbh != null and erpbh != ''">
  223. and ERPBH = #{erpbh}
  224. </if>
  225. <if test="xmlx != null and xmlx != ''">
  226. and XMLX = #{xmlx}
  227. </if>
  228. <if test="xmfzr != null">
  229. and XMFZR = #{xmfzr}
  230. </if>
  231. <if test="ssbm != null">
  232. and SSBM = #{ssbm}
  233. </if>
  234. <if test="sfbz != null and sfbz != ''">
  235. and SFBZ = #{sfbz}
  236. </if>
  237. <if test="smwj != null and smwj != ''">
  238. and SMWJ = #{smwj}
  239. </if>
  240. <if test="bhsje != null">
  241. and BHSJE = #{bhsje}
  242. </if>
  243. <if test="sf != null">
  244. and SF = #{sf}
  245. </if>
  246. <if test="nys != null">
  247. and NYS = #{nys}
  248. </if>
  249. </where>
  250. </select>
  251. <!--新增-->
  252. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  253. insert into sta_BudgetApproval(SQMC, XMMC, XMID, BH, NF, FYLB, SQJE, SQSM, FJ, SQRXM, SQR, SQSJ, ERPBH, KYBG, XMLX, XMFZR, SSBM, SFBYJ, SFBZ, SPZT, NYS, BZ)
  254. values (#{sqmc}, #{xmmc}, #{xmid}, #{bh}, #{nf}, #{fylb}, #{sqje}, #{sqsm}, #{fj}, #{sqrxm}, #{sqr}, GETDATE(), #{erpbh}, #{kybg}, #{xmlx}, #{xmfzr}, #{ssbm}, 0, 0, '未提交', #{nys}, #{bz})
  255. </insert>
  256. <insert id="insertImprest" keyProperty="id" useGeneratedKeys="true">
  257. insert into sta_BudgetApproval(SQMC, BH,SQSM , NF, SQJE, SQRXM, SQR, SQSJ, SFBYJ, SFBZ, SPZT)
  258. values (#{sqmc}, #{bh}, #{sqsm},#{nf}, #{sqje}, #{sqrxm}, #{sqr}, #{sqsj}, 1, 0, '未提交')
  259. </insert>
  260. <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
  261. insert into sta_BudgetApproval(XMMC, XMID, BH, SQSM, SQJE, FYLB, BBM, FJ, SHZT, NF, SQR, SQRXM, SQSJ, SQMC, SPZT, KYFYXX, BZJE, BXPZ, BZJE2, SFBYJ, KYBG, ERPBH, XMLX, XMFZR, SSBM, SFBZ, SMWJ, BHSJE, SF, NYS, BZ)
  262. values
  263. <foreach collection="entities" item="entity" separator=",">
  264. (#{entity.xmmc}, #{entity.xmid}, #{entity.bh}, #{entity.sqsm}, #{entity.sqje}, #{entity.fylb}, #{entity.bbm}, #{entity.fj}, #{entity.shzt}, #{entity.nf}, #{entity.sqrxm}, #{entity.sqr}, #{entity.sqsj}, #{entity.sqmc},
  265. #{entity.spzt}, #{entity.kyfyxx}, #{entity.bzje}, #{entity.bxpz}, #{entity.bzje2}, #{entity.sfbyj}, #{entity.kybg}, #{entity.erpbh}, #{entity.xmlx}, #{entity.xmfzr}, #{entity.ssbm}, #{entity.sfbz}, #{entity.smwj},
  266. #{entity.bhsje}, #{entity.sf}, #{entity.nys}, #{entity.bz})
  267. </foreach>
  268. </insert>
  269. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  270. insert into sta_BudgetApproval(XMMC, XMID, BH, SQSM, SQJE, FYLB, BBM, FJ, SHZT, NF, SQR, SQRXM, SQSJ, SQMC, SPZT, KYFYXX, BZJE, BXPZ, BZJE2, SFBYJ, KYBG, ERPBH, XMLX, XMFZR, SSBM, SFBZ, SMWJ, BHSJE, SF, NYS, BZ)
  271. values
  272. <foreach collection="entities" item="entity" separator=",">
  273. (#{entity.xmmc}, #{entity.xmid}, #{entity.bh}, #{entity.sqsm}, #{entity.sqje}, #{entity.fylb}, #{entity.bbm}, #{entity.fj}, #{entity.shzt}, #{entity.nf}, #{entity.sqrxm}, #{entity.sqr}, #{entity.sqsj}, #{entity.sqmc},
  274. #{entity.spzt}, #{entity.kyfyxx}, #{entity.bzje}, #{entity.bxpz}, #{entity.bzje2}, #{entity.sfbyj}, #{entity.kybg}, #{entity.erpbh}, #{entity.xmlx}, #{entity.xmfzr}, #{entity.ssbm}, #{entity.sfbz}, #{entity.smwj},
  275. #{entity.bhsje}, #{entity.sf}, ##{entity.nys}, #{entity.bz})
  276. </foreach>
  277. on duplicate key update
  278. XMMC = values(XMMC),
  279. XMID = values(XMID),
  280. BH = values(BH),
  281. SQSM = values(SQSM),
  282. SQJE = values(SQJE),
  283. FYLB = values(FYLB),
  284. BBM = values(BBM),
  285. FJ = values(FJ),
  286. SHZT = values(SHZT),
  287. NF = values(NF),
  288. SQR = values(SQR),
  289. SQRXM = values(SQRXM),
  290. SQSJ = values(SQSJ),
  291. SQMC = values(SQMC),
  292. SPZT = values(SPZT),
  293. KYFYXX = values(KYFYXX),
  294. BZJE = values(BZJE),
  295. BXPZ = values(BXPZ),
  296. BZJE2 = values(BZJE2),
  297. SFBYJ = values(SFBYJ),
  298. KYBG = values(KYBG),
  299. ERPBH = values(ERPBH),
  300. XMLX = values(XMLX),
  301. XMFZR = values(XMFZR),
  302. SSBM = values(SSBM),
  303. SFBZ = values(SFBZ),
  304. SMWJ = values(SMWJ),
  305. BHSJE = values(BHSJE),
  306. SF = values(SF),
  307. NYS = values(NYS),
  308. BZ = values(BZ)
  309. </insert>
  310. <!--通过主键修改基础数据-->
  311. <update id="update">
  312. update sta_BudgetApproval
  313. set SQJE = #{sqje},
  314. FJ = #{fj},
  315. BZ = #{bz},
  316. SQMC = #{sqmc},
  317. SQSM = #{sqsm}
  318. where ID = #{id}
  319. </update>
  320. <!-- 修改方法-->
  321. <!--通过主键修改基础数据-->
  322. <update id="updateImprest">
  323. update sta_BudgetApproval
  324. set SQJE = #{sqje},
  325. SQSJ = #{sqsj},
  326. SQMC = #{sqmc},
  327. SQSM = #{sqsm}
  328. where ID = #{id}
  329. </update>
  330. <!-- 修改方法-->
  331. <!--备用金关联项目-->
  332. <update id="ImprestConnect">
  333. update sta_BudgetApproval
  334. set XMMC = #{xmmc},
  335. XMID = #{xmid},
  336. FYLB = #{fylb},
  337. FJ = #{fj},
  338. ERPBH = #{erpbh},
  339. XMLX = #{xmlx},
  340. XMFZR = #{xmfzr},
  341. SSBM = #{ssbm},
  342. NYS = #{nys},
  343. BZ = #{bz}
  344. where ID = #{id}
  345. </update>
  346. <!--通过主键修改其它数据-->
  347. <update id="updateOthers">
  348. update sta_BudgetApproval
  349. set ERPBH = #{erpbh},
  350. XMLX = #{xmlx},
  351. XMFZR = #{xmfzr},
  352. SSBM = #{ssbm}
  353. where ID = #{id}
  354. </update>
  355. <!--通过主键删除-->
  356. <delete id="deleteById">
  357. delete from sta_BudgetApproval where ID = #{id}
  358. </delete>
  359. <!--获取费用申请列表-->
  360. <select id="getFysqList" resultMap="StaBudgetapprovalMap" parameterType="map">
  361. select b.*, t.XMLXMC, d.dept_name as SSBMMC, g.FYMC as FYLBMC, r.XM as XMFZRXM,
  362. (SELECT STUFF((SELECT ','+XM from (select xm from base_Person
  363. where id in (select dkyfzrid from
  364. (select DISTINCT zwmc,SUBSTRING(dkyfzr, number,CHARINDEX(',',dkyfzr+',',number)-number) as dkyfzrid
  365. from prj_Project WITH(nolock) ,master..spt_values with(nolock) where number >= 1 and len(DKYFZR) > number
  366. and SUBSTRING(','+DKYFZR,number,1)=',' and ID = b.XMID) t)) B for xml path('')),1,1,'')) as DKYFZRXM
  367. from sta_BudgetApproval b
  368. left join base_ProjectType t on t.XMLX = b.XMLX
  369. left join prj_Project p on p.ID = b.XMID
  370. left join sys_dept_info d on d.dept_id = b.SSBM
  371. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  372. left join base_Person r on r.ID = b.XMFZR
  373. where b.SFBYJ = 0
  374. -- and b.SPZT != '审批结束'
  375. <if test="userId != null and userId != ''">
  376. and (b.SQR = #{userId} or #{userId} in (select SHR from prj_ApproveRecord where XMID = b.ID))
  377. </if>
  378. <if test="sqmc != null and sqmc != ''">
  379. and b.SQMC like '%'+#{sqmc}+'%'
  380. </if>
  381. <if test="spzt != null and spzt != ''">
  382. and b.SPZT = #{spzt}
  383. </if>
  384. <if test="bh != null and bh != ''">
  385. and b.BH like '%'+#{bh}+'%'
  386. </if>
  387. <if test="dkyfzr != null and dkyfzr != ''">
  388. and p.DKYFZR like '%'+#{dkyfzr}+'%'
  389. </if>
  390. <if test="ssbmmc != null and ssbmmc != ''">
  391. and d.dept_name like '%'+#{ssbmmc}+'%'
  392. </if>
  393. <if test="erpbh != null and erpbh != ''">
  394. and b.ERPBH like '%'+#{erpbh}+'%'
  395. </if>
  396. <if test="xmlx != null and xmlx != ''">
  397. and b.XMLX = #{xmlx}
  398. </if>
  399. <if test="nf != null and nf != ''">
  400. and b.NF = #{nf}
  401. </if>
  402. <choose>
  403. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  404. order by ${sortName} ${sortOrder}
  405. </when>
  406. </choose>
  407. ORDER BY
  408. CASE
  409. WHEN b.SPZT = '部门主任审批' THEN 0
  410. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  411. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  412. WHEN b.SPZT = '主管院领导审批' THEN 3
  413. WHEN b.SPZT = '院长审批' THEN 4
  414. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  415. WHEN b.SPZT = '未提交' THEN 996
  416. WHEN b.SPZT = '未提交(返回)' THEN 997
  417. WHEN b.SPZT = '审批结束' THEN 998
  418. WHEN b.SPZT = '作废' THEN 999
  419. END
  420. ASC,
  421. SQSJ DESC
  422. </select>
  423. <!--获取备用金申请列表-->
  424. <select id="getByjsqList" resultMap="StaBudgetapprovalMap" parameterType="map">
  425. select b.*, g.FYMC as FYLBMC
  426. from sta_BudgetApproval b
  427. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  428. where b.SFBYJ = 1
  429. <if test="userId != null and userId != ''">
  430. and (b.SQR = #{userId} or #{userId} in (select SHR from prj_ApproveRecord where XMID = b.ID))
  431. </if>
  432. <if test="spzt != null and spzt != ''">
  433. and b.SPZT = #{spzt}
  434. </if>
  435. <if test="erpbh != null and erpbh != ''">
  436. and b.ERPBH like '%'+#{erpbh}+'%'
  437. </if>
  438. <if test="xmmc != null and xmmc != ''">
  439. and b.XMMC like '%'+#{xmmc}+'%'
  440. </if>
  441. <if test="bh != null and bh != ''">
  442. and b.BH like '%'+#{bh}+'%'
  443. </if>
  444. <if test="nf != null and nf != ''">
  445. and b.NF = #{nf}
  446. </if>
  447. <choose>
  448. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  449. order by ${sortName} ${sortOrder}
  450. </when>
  451. </choose>
  452. ORDER BY
  453. CASE
  454. WHEN b.SPZT = '部门主任审批' THEN 0
  455. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  456. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  457. WHEN b.SPZT = '主管院领导审批' THEN 3
  458. WHEN b.SPZT = '院长审批' THEN 4
  459. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  460. WHEN b.SPZT = '未提交' THEN 996
  461. WHEN b.SPZT = '未提交(返回)' THEN 997
  462. WHEN b.SPZT = '审批结束' THEN 998
  463. WHEN b.SPZT = '作废' THEN 999
  464. END ASC,
  465. SQSJ DESC
  466. </select>
  467. <!--获取年份-->
  468. <select id="getYearList" resultMap="StaBudgetapprovalMap">
  469. select distinct NF
  470. from sta_BudgetApproval
  471. where NF is not NULL
  472. </select>
  473. <!--获取已报账费用申请列表-->
  474. <select id="getYbzFysqList" resultMap="StaBudgetapprovalMap" parameterType="map">
  475. select b.*, t.XMLXMC, d.dept_name as SSBMMC, g.FYMC as FYLBMC,
  476. (SELECT STUFF((SELECT ','+XM from (select xm from base_Person
  477. where id in (select dkyfzrid from
  478. (select DISTINCT zwmc,SUBSTRING(dkyfzr, number,CHARINDEX(',',dkyfzr+',',number)-number) as dkyfzrid
  479. from prj_Project WITH(nolock) ,master..spt_values with(nolock) where number >= 1 and len(DKYFZR) > number
  480. and SUBSTRING(','+DKYFZR,number,1)=',' and ID = b.XMID) t)) B for xml path('')),1,1,'')) as DKYFZRXM
  481. from sta_BudgetApproval b
  482. left join base_ProjectType t on t.XMLX = b.XMLX
  483. left join prj_Project p on p.ID = b.XMID
  484. left join sys_dept_info d on d.dept_id = b.SSBM
  485. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  486. left join sta_Reimbursement r on r.FYSQ = b.ID
  487. where b.SFBZ = 1
  488. <if test="userId != null and userId != ''">
  489. and (b.SQR = #{userId} or #{userId} in (select SHR from prj_ApproveRecord where XMID = b.ID))
  490. </if>
  491. <if test="sqmc != null and sqmc != ''">
  492. and b.SQMC like '%'+#{sqmc}+'%'
  493. </if>
  494. <if test="erpbh != null and erpbh != ''">
  495. and b.ERPBH like '%'+#{erpbh}+'%'
  496. </if>
  497. <if test="bh != null and bh != ''">
  498. and b.BH like '%'+#{bh}+'%'
  499. </if>
  500. <if test="xmlx != null and xmlx != ''">
  501. and b.XMLX = #{xmlx}
  502. </if>
  503. <if test="dkyfzr != null and dkyfzr != ''">
  504. and p.DKYFZR like '%'+#{dkyfzr}+'%'
  505. </if>
  506. <if test="ssbmmc != null and ssbmmc != ''">
  507. and d.dept_name like '%'+#{ssbm}+'%'
  508. </if>
  509. <if test="nf != null and nf != ''">
  510. and b.NF = #{nf}
  511. </if>
  512. <choose>
  513. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  514. order by ${sortName} ${sortOrder}
  515. </when>
  516. </choose>
  517. ORDER BY
  518. CASE
  519. WHEN r.SPZT = '部门主任审批' THEN 0
  520. WHEN r.SPZT = '科技项目管理专责审批' THEN 1
  521. WHEN r.SPZT = '科技部部门主任审批' THEN 2
  522. WHEN r.SPZT = '主管院领导审批' THEN 3
  523. WHEN r.SPZT = '院长审批' THEN 4
  524. WHEN r.SPZT = '科技项目管理专责确认' THEN 5
  525. WHEN r.SPZT = '未提交' THEN 996
  526. WHEN r.SPZT = '未提交(返回)' THEN 997
  527. WHEN r.SPZT = '审批结束' THEN 998
  528. WHEN r.SPZT = '作废' THEN 999
  529. END
  530. ASC,
  531. CJSJ DESC
  532. </select>
  533. <!--获取全部费用申请(审批完成)-->
  534. <select id="getAllApplyList" resultMap="StaBudgetapprovalMap" parameterType="map">
  535. select b.*, t.XMLXMC, d.dept_name as SSBMMC, g.FYMC as FYLBMC, r.XM as XMFZRXM,
  536. case when b.SFBYJ = 1 then '是' else '否' end as SFBYJMC, case when b.SFBZ = 1 then '是' else '否' end as SFBZMC,
  537. (SELECT STUFF((SELECT ','+XM from (select xm from base_Person
  538. where id in (select dkyfzrid from
  539. (select DISTINCT zwmc,SUBSTRING(dkyfzr, number,CHARINDEX(',',dkyfzr+',',number)-number) as dkyfzrid
  540. from prj_Project WITH(nolock) ,master..spt_values with(nolock) where number >= 1 and len(DKYFZR) > number
  541. and SUBSTRING(','+DKYFZR,number,1)=',' and ID = b.XMID) t)) B for xml path('')),1,1,'')) as DKYFZRXM
  542. from sta_BudgetApproval b
  543. left join base_ProjectType t on t.XMLX = b.XMLX
  544. left join prj_Project p on p.ID = b.XMID
  545. left join sys_dept_info d on d.dept_id = b.SSBM
  546. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  547. left join base_Person r on r.ID = b.XMFZR
  548. where 1 = 1
  549. <if test="bh != null and bh != ''">
  550. and b.BH like '%'+#{bh}+'%'
  551. </if>
  552. <if test="erpbh != null and erpbh != ''">
  553. and b.ERPBH like '%'+#{erpbh}+'%'
  554. </if>
  555. <if test="xmlx != null and xmlx != ''">
  556. and b.XMLX = #{xmlx}
  557. </if>
  558. <if test="sfbyj != null and sfbyj != ''">
  559. and b.SFBYJ = #{sfbyj}
  560. </if>
  561. <if test="xmmc != null and xmmc != ''">
  562. and b.XMMC like '%'+#{xmmc}+'%'
  563. </if>
  564. <if test="ssbmmc != null and ssbmmc != ''">
  565. and d.dept_name like '%'+#{ssbm}+'%'
  566. </if>
  567. <if test="nf != null and nf != ''">
  568. and b.NF = #{nf}
  569. </if>
  570. <if test="spzt != null and spzt != ''">
  571. and b.SPZT = #{spzt}
  572. </if>
  573. <if test="sfbz != null and sfbz != ''">
  574. and b.SFBZ = #{sfbz}
  575. </if>
  576. <if test="dkyfzr != null and dkyfzr != ''">
  577. and p.DKYFZR like '%'+#{dkyfzr}+'%'
  578. </if>
  579. <if test="sqsj1 != null and sqsj1 != ''">
  580. and b.SQSJ >= #{sqsj1}
  581. </if>
  582. <if test="sqsj2 != null and sqsj2 != ''">
  583. and DATEADD(day, 1, #{sqsj2}) >= b.SQSJ
  584. </if>
  585. <choose>
  586. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  587. order by ${sortName} ${sortOrder}
  588. </when>
  589. </choose>
  590. ORDER BY
  591. CASE
  592. WHEN b.SPZT = '部门主任审批' THEN 0
  593. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  594. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  595. WHEN b.SPZT = '主管院领导审批' THEN 3
  596. WHEN b.SPZT = '院长审批' THEN 4
  597. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  598. WHEN b.SPZT = '未提交' THEN 996
  599. WHEN b.SPZT = '未提交(返回)' THEN 997
  600. WHEN b.SPZT = '审批结束' THEN 998
  601. WHEN b.SPZT = '作废' THEN 999
  602. END
  603. ASC
  604. </select>
  605. <!--获取审批中的费用申请-->
  606. <select id="getApprovingList" resultMap="StaBudgetapprovalMap" parameterType="map">
  607. select b.*, t.XMLXMC, d.dept_name as SSBMMC, g.FYMC as FYLBMC, r.XM as XMFZRXM,
  608. case when b.SFBYJ = 1 then '是' else '否' end as SFBYJMC, case when b.SFBZ = 1 then '是' else '否' end as SFBZMC,
  609. (SELECT STUFF((SELECT ','+XM from (select xm from base_Person
  610. where id in (select dkyfzrid from
  611. (select DISTINCT zwmc,SUBSTRING(dkyfzr, number,CHARINDEX(',',dkyfzr+',',number)-number) as dkyfzrid
  612. from prj_Project WITH(nolock) ,master..spt_values with(nolock) where number >= 1 and len(DKYFZR) > number
  613. and SUBSTRING(','+DKYFZR,number,1)=',' and ID = b.XMID) t)) B for xml path('')),1,1,'')) as DKYFZRXM
  614. from sta_BudgetApproval b
  615. left join base_ProjectType t on t.XMLX = b.XMLX
  616. left join prj_Project p on p.ID = b.XMID
  617. left join sys_dept_info d on d.dept_id = b.SSBM
  618. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  619. left join base_Person r on r.ID = b.XMFZR
  620. where b.SPZT != '未提交' and b.SPZT != '审批结束' and b.SPZT != '作废' and b.SFBYJ = 0
  621. <if test="spzt != null and spzt != ''">
  622. and b.SPZT = #{spzt}
  623. </if>
  624. <if test="bh != null and bh != ''">
  625. and b.BH like '%'+#{bh}+'%'
  626. </if>
  627. <if test="nf != null and nf != ''">
  628. and b.NF = #{nf}
  629. </if>
  630. <if test="sfbyj != null and sfbyj != ''">
  631. and b.SFBYJ = #{sfbyj}
  632. </if>
  633. <if test="xmmc != null and xmmc != ''">
  634. and b.XMMC like '%'+#{xmmc}+'%'
  635. </if>
  636. <if test="erpbh != null and erpbh != ''">
  637. and b.ERPBH like '%'+#{erpbh}+'%'
  638. </if>
  639. <if test="xmlx != null and xmlx != ''">
  640. and b.XMLX = #{xmlx}
  641. </if>
  642. <if test="ssbmmc != null and ssbmmc != ''">
  643. and d.dept_name like '%'+#{ssbm}+'%'
  644. </if>
  645. <choose>
  646. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  647. order by ${sortName} ${sortOrder}
  648. </when>
  649. </choose>
  650. ORDER BY
  651. CASE
  652. WHEN b.SPZT = '部门主任审批' THEN 0
  653. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  654. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  655. WHEN b.SPZT = '主管院领导审批' THEN 3
  656. WHEN b.SPZT = '院长审批' THEN 4
  657. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  658. END
  659. ASC
  660. </select>
  661. <!--批量删除费用申请-->
  662. <delete id="batchDelete" parameterType="java.util.ArrayList">
  663. delete from sta_BudgetApproval
  664. where ID in
  665. <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
  666. #{item}
  667. </foreach>
  668. </delete>
  669. <!--撤销审核状态费用申请-->
  670. <update id="tjrevokeApprove">
  671. update sta_BudgetApproval
  672. set SPZT = '未提交'
  673. where ID = #{id}
  674. </update>
  675. <!--通过主键修改审批状态-->
  676. <update id="updateSpzt">
  677. update sta_BudgetApproval
  678. set SPZT = #{spzt}, BH=#{bh}
  679. where ID = #{id}
  680. </update>
  681. <!--获取费用申请信息-->
  682. <select id="getFysqById" resultMap="StaBudgetapprovalMap">
  683. select b.*, t.XMLXMC, d.dept_name as SSBMMC, g.FYMC as FYLBMC, r.XM as XMFZRXM,
  684. (select MC from base_ProjectBudget g1 where g1.BM = g.FJ) as FJMC,
  685. case when b.SFBYJ = 1 then '是' else '否' end as SFBYJMC, case when b.SFBZ = 1 then '是' else '否' end as SFBZMC,
  686. (SELECT STUFF((SELECT ','+XM from (select xm from base_Person
  687. where id in (select dkyfzrid from
  688. (select DISTINCT zwmc,SUBSTRING(dkyfzr, number,CHARINDEX(',',dkyfzr+',',number)-number) as dkyfzrid
  689. from prj_Project WITH(nolock) ,master..spt_values with(nolock) where number >= 1 and len(DKYFZR) > number
  690. and SUBSTRING(','+DKYFZR,number,1)=',' and ID = b.XMID) t)) B for xml path('')),1,1,'')) as DKYFZRXM
  691. from sta_BudgetApproval b
  692. left join base_ProjectType t on t.XMLX = b.XMLX
  693. left join prj_Project p on p.ID = b.XMID
  694. left join sys_dept_info d on d.dept_id = b.SSBM
  695. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  696. left join base_Person r on r.ID = b.XMFZR
  697. where b.ID = #{id}
  698. </select>
  699. <!--获取费用管理列表-->
  700. <select id="getFyglList" resultMap="StaBudgetapprovalMap" parameterType="map">
  701. select b.*, t.XMLXMC, d.dept_name as SSBMMC, r.XM as XMFZRXM
  702. from sta_BudgetApproval b
  703. left join base_ProjectType t on t.XMLX = b.XMLX
  704. left join prj_Project p on p.ID = b.XMID
  705. left join sys_dept_info d on d.dept_id = b.SSBM
  706. left join base_Person r on r.ID = b.XMFZR
  707. where 1 = 1
  708. <if test="xmmc != null and xmmc != ''">
  709. and b.XMMC like '%'+#{xmmc}+'%'
  710. </if>
  711. <if test="erpbh != null and erpbh != ''">
  712. and b.ERPBH like '%'+#{erpbh}+'%'
  713. </if>
  714. <if test="xmlx != null and xmlx != ''">
  715. and b.XMLX = #{xmlx}
  716. </if>
  717. <if test="xmfzrxm != null and xmfzrxm != ''">
  718. and r.XM like '%'+#{xmfzrxm}+'%'
  719. </if>
  720. <if test="ssbmmc != null and ssbmmc != ''">
  721. and d.dept_name like '%'+#{ssbm}+'%'
  722. </if>
  723. <choose>
  724. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  725. order by ${sortName} ${sortOrder}
  726. </when>
  727. </choose>
  728. </select>
  729. <!--更新报账数据-->
  730. <update id="updateReimburse">
  731. update sta_BudgetApproval
  732. set SFBZ = 1,
  733. BXPZ = #{bxpz},
  734. BZJE = #{bzje},
  735. BHSJE = #{bhsje},
  736. SF = #{sf}
  737. where ID = #{id}
  738. </update>
  739. <!--批量修改报账信息-->
  740. <update id="clearReimburse">
  741. update sta_BudgetApproval
  742. set SFBZ = 0,
  743. BXPZ = null,
  744. BZJE = null,
  745. BHSJE = null,
  746. SF = null
  747. where ID in
  748. <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
  749. #{item}
  750. </foreach>
  751. </update>
  752. <!--批量作废费用申请-->
  753. <delete id="batchNullify" parameterType="java.util.ArrayList">
  754. update sta_BudgetApproval
  755. set SPZT = '作废'
  756. where ID in
  757. <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
  758. #{item}
  759. </foreach>
  760. </delete>
  761. <!--项目总体费用信息-->
  762. <select id="getXmFyInfo" resultMap="StaBudgetapprovalMap">
  763. select b.NYS, (ISNULL(SUM(b.BZJE),0)+ISNULL((select SUM(SQJE) from sta_BudgetApproval where BZJE is NULL and NYS = #{nys1} and SPZT != '作废' and SFBYJ =0),0)) as SQJE,
  764. SUM(b.BZJE) as BZJE,
  765. (select YSJE from prj_AnnualBudgetDetail where NYS = b.NYS and FJ = '') as YSJE
  766. from sta_BudgetApproval b
  767. where b.NYS = #{nys} and b.SPZT != '作废' and b.SFBYJ =0
  768. GROUP BY b.NYS
  769. </select>
  770. <!--项目分项费用信息-->
  771. <select id="getKmFyInfo" resultMap="StaBudgetapprovalMap" parameterType="map">
  772. select b.NYS, b.FYLB, (ISNULL(SUM(b.BZJE),0)+ISNULL((select SUM(SQJE) from sta_BudgetApproval where BZJE is NULL and NYS = #{nys1} and FYLB = #{fylb1} and SPZT != '作废' and SFBYJ =0),0)) as SQJE,
  773. SUM(b.BZJE) as BZJE,
  774. (select YSJE from prj_AnnualBudgetDetail where NYS = b.NYS and ID = b.FYLB) as YSJE
  775. from sta_BudgetApproval b
  776. where b.NYS = #{nys} and b.FYLB = #{fylb} and b.SPZT != '作废' and b.SFBYJ =0
  777. GROUP BY b.NYS, b.FYLB
  778. </select>
  779. <!--未关联项目备用金 -->
  780. <select id="unassociated" resultMap="StaBudgetapprovalMap" parameterType="map">
  781. SELECT * FROM sta_BudgetApproval WHERE SFBYJ = 1 AND XMMC IS NULL AND SPZT='审批结束'
  782. </select>
  783. <!--项目备用金信息-->
  784. <select id="getByjInfo" resultMap="StaBudgetapprovalMap">
  785. select b.NYS, (ISNULL(SUM(b.BZJE),0)+ISNULL((select SUM(SQJE) from sta_BudgetApproval where BZJE is NULL and NYS = #{nys1} and SPZT != '作废' and SFBYJ =1),0)) as SQJE,
  786. SUM(b.BZJE) as BZJE,
  787. (select YSJE from prj_AnnualBudgetDetail where NYS = b.NYS and FJ = '') as YSJE
  788. from sta_BudgetApproval b
  789. where b.NYS = #{nys} and b.SPZT != '作废' and b.SFBYJ =1
  790. GROUP BY b.NYS
  791. </select>
  792. </mapper>