StaBudgetapprovalDao.xml 36 KB

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