StaBudgetapprovalDao.xml 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  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. <if test="bzje != null and bzje != ''">
  332. ,BZJE = #{bzje}
  333. </if>
  334. where ID = #{id}
  335. </update>
  336. <!-- 修改方法-->
  337. <!--通过主键修改基础数据-->
  338. <update id="updateImprest">
  339. update sta_BudgetApproval
  340. set SQJE = #{sqje},
  341. SQSJ = #{sqsj},
  342. SQMC = #{sqmc},
  343. SQSM = #{sqsm}
  344. where ID = #{id}
  345. </update>
  346. <!-- 修改方法-->
  347. <!--备用金关联项目-->
  348. <update id="ImprestConnect">
  349. update sta_BudgetApproval
  350. set XMMC = #{xmmc},
  351. XMID = #{xmid},
  352. FYLB = #{fylb},
  353. FJ = #{fj},
  354. ERPBH = #{erpbh},
  355. XMLX = #{xmlx},
  356. XMFZR = #{xmfzr},
  357. SSBM = #{ssbm},
  358. NYS = #{nys},
  359. BZ = #{bz}
  360. where ID = #{id}
  361. </update>
  362. <!--通过主键修改其它数据-->
  363. <update id="updateOthers">
  364. update sta_BudgetApproval
  365. set ERPBH = #{erpbh},
  366. XMLX = #{xmlx},
  367. XMFZR = #{xmfzr},
  368. SSBM = #{ssbm}
  369. where ID = #{id}
  370. </update>
  371. <!--通过主键删除-->
  372. <delete id="deleteById">
  373. delete
  374. from sta_BudgetApproval
  375. where ID = #{id}
  376. </delete>
  377. <!--获取费用申请列表-->
  378. <select id="getFysqList" resultMap="StaBudgetapprovalMap" parameterType="map">
  379. select b.*, t.XMLXMC, d.dept_name as SSBMMC, g.FYMC as FYLBMC, r.XM as XMFZRXM,
  380. (SELECT STUFF((SELECT ','+XM from (select xm from base_Person
  381. where id in (select dkyfzrid from
  382. (select DISTINCT zwmc,SUBSTRING(dkyfzr, number,CHARINDEX(',',dkyfzr+',',number)-number) as dkyfzrid
  383. from prj_Project WITH(nolock) ,master..spt_values with(nolock) where number >= 1 and len(DKYFZR) > number
  384. and SUBSTRING(','+DKYFZR,number,1)=',' and ID = b.XMID) t)) B for xml path('')),1,1,'')) as DKYFZRXM
  385. from sta_BudgetApproval b
  386. left join base_ProjectType t on t.XMLX = b.XMLX
  387. left join prj_Project p on p.ID = b.XMID
  388. left join sys_dept_info d on d.dept_id = b.SSBM
  389. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  390. left join base_Person r on r.ID = b.XMFZR
  391. where b.SFBYJ = 0
  392. -- and b.SPZT != '审批结束'
  393. <if test="userId != null and userId != ''">
  394. and (b.SQR = #{userId} or #{userId} in (select SHR from prj_ApproveRecord where XMID = b.ID))
  395. </if>
  396. <if test="sqmc != null and sqmc != ''">
  397. and b.SQMC like '%'+#{sqmc}+'%'
  398. </if>
  399. <if test="fylb != null and fylb != ''">
  400. and g.FYMC like '%'+#{fylb}+'%'
  401. </if>
  402. <if test="sqr != null and sqr != ''">
  403. and b.SQRXM like '%'+#{sqr}+'%'
  404. </if>
  405. <if test="spzt != null and spzt != ''">
  406. and b.SPZT = #{spzt}
  407. </if>
  408. <if test="bh != null and bh != ''">
  409. and b.BH like '%'+#{bh}+'%'
  410. </if>
  411. <if test="dkyfzr != null and dkyfzr != ''">
  412. and p.DKYFZR like '%'+#{dkyfzr}+'%'
  413. </if>
  414. <if test="ssbmmc != null and ssbmmc != ''">
  415. and d.dept_name like '%'+#{ssbmmc}+'%'
  416. </if>
  417. <if test="erpbh != null and erpbh != ''">
  418. and b.ERPBH like '%'+#{erpbh}+'%'
  419. </if>
  420. <if test="xmlx != null and xmlx != ''">
  421. and b.XMLX = #{xmlx}
  422. </if>
  423. <if test="nf != null and nf != ''">
  424. and b.NF = #{nf}
  425. </if>
  426. <choose>
  427. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  428. order by ${sortName} ${sortOrder}
  429. </when>
  430. </choose>
  431. ORDER BY
  432. CASE
  433. WHEN b.SPZT = '部门主任审批' THEN 0
  434. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  435. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  436. WHEN b.SPZT = '主管院领导审批' THEN 3
  437. WHEN b.SPZT = '院长审批' THEN 4
  438. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  439. WHEN b.SPZT = '未提交' THEN 996
  440. WHEN b.SPZT = '未提交(返回)' THEN 997
  441. WHEN b.SPZT = '审批结束' THEN 998
  442. WHEN b.SPZT = '作废' THEN 999
  443. END
  444. ASC,
  445. SQSJ DESC
  446. </select>
  447. <!--获取备用金申请列表-->
  448. <select id="getByjsqList" resultMap="StaBudgetapprovalMap" parameterType="map">
  449. select b.*, g.FYMC as FYLBMC
  450. from sta_BudgetApproval b
  451. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  452. where b.SFBYJ = 1
  453. <if test="userId != null and userId != ''">
  454. and (b.SQR = #{userId} or #{userId} in (select SHR from prj_ApproveRecord where XMID = b.ID))
  455. </if>
  456. <if test="spzt != null and spzt != ''">
  457. and b.SPZT = #{spzt}
  458. </if>
  459. <if test="erpbh != null and erpbh != ''">
  460. and b.ERPBH like '%'+#{erpbh}+'%'
  461. </if>
  462. <if test="xmmc != null and xmmc != ''">
  463. and b.XMMC like '%'+#{xmmc}+'%'
  464. </if>
  465. <if test="bh != null and bh != ''">
  466. and b.BH like '%'+#{bh}+'%'
  467. </if>
  468. <if test="nf != null and nf != ''">
  469. and b.NF = #{nf}
  470. </if>
  471. <if test="sqmc != null and sqmc != ''">
  472. and b.sqmc = #{sqmc}
  473. </if>
  474. <choose>
  475. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  476. order by ${sortName} ${sortOrder}
  477. </when>
  478. </choose>
  479. ORDER BY
  480. CASE
  481. WHEN b.SPZT = '部门主任审批' THEN 0
  482. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  483. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  484. WHEN b.SPZT = '主管院领导审批' THEN 3
  485. WHEN b.SPZT = '院长审批' THEN 4
  486. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  487. WHEN b.SPZT = '未提交' THEN 996
  488. WHEN b.SPZT = '未提交(返回)' THEN 997
  489. WHEN b.SPZT = '审批结束' THEN 998
  490. WHEN b.SPZT = '作废' THEN 999
  491. END ASC,
  492. SQSJ DESC
  493. </select>
  494. <!--获取年份-->
  495. <select id="getYearList" resultMap="StaBudgetapprovalMap">
  496. select distinct NF
  497. from sta_BudgetApproval
  498. where NF is not NULL
  499. </select>
  500. <!--获取已报账费用申请列表-->
  501. <select id="getYbzFysqList" resultMap="StaBudgetapprovalMap" parameterType="map">
  502. select b.*, t.XMLXMC, d.dept_name as SSBMMC, g.FYMC as FYLBMC,
  503. (SELECT STUFF((SELECT ','+XM from (select xm from base_Person
  504. where id in (select dkyfzrid from
  505. (select DISTINCT zwmc,SUBSTRING(dkyfzr, number,CHARINDEX(',',dkyfzr+',',number)-number) as dkyfzrid
  506. from prj_Project WITH(nolock) ,master..spt_values with(nolock) where number >= 1 and len(DKYFZR) > number
  507. and SUBSTRING(','+DKYFZR,number,1)=',' and ID = b.XMID) t)) B for xml path('')),1,1,'')) as DKYFZRXM
  508. from sta_BudgetApproval b
  509. left join base_ProjectType t on t.XMLX = b.XMLX
  510. left join prj_Project p on p.ID = b.XMID
  511. left join sys_dept_info d on d.dept_id = b.SSBM
  512. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  513. left join sta_Reimbursement r on r.FYSQ = b.ID
  514. where b.SFBZ = 1
  515. and r.spzt = '审批结束'
  516. <if test="userId != null and userId != ''">
  517. and (b.SQR = #{userId} or #{userId} in (select SHR from prj_ApproveRecord where XMID = b.ID))
  518. </if>
  519. <if test="sqmc != null and sqmc != ''">
  520. and b.SQMC like '%'+#{sqmc}+'%'
  521. </if>
  522. <if test="erpbh != null and erpbh != ''">
  523. and b.ERPBH like '%'+#{erpbh}+'%'
  524. </if>
  525. <if test="bh != null and bh != ''">
  526. and b.BH like '%'+#{bh}+'%'
  527. </if>
  528. <if test="xmlx != null and xmlx != ''">
  529. and b.XMLX = #{xmlx}
  530. </if>
  531. <if test="dkyfzr != null and dkyfzr != ''">
  532. and p.DKYFZR like '%'+#{dkyfzr}+'%'
  533. </if>
  534. <if test="ssbmmc != null and ssbmmc != ''">
  535. and d.dept_name like '%'+#{ssbm}+'%'
  536. </if>
  537. <if test="nf != null and nf != ''">
  538. and b.NF = #{nf}
  539. </if>
  540. <choose>
  541. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  542. order by ${sortName} ${sortOrder}
  543. </when>
  544. </choose>
  545. ORDER BY
  546. CASE
  547. WHEN r.SPZT = '部门主任审批' THEN 0
  548. WHEN r.SPZT = '科技项目管理专责审批' THEN 1
  549. WHEN r.SPZT = '科技部部门主任审批' THEN 2
  550. WHEN r.SPZT = '主管院领导审批' THEN 3
  551. WHEN r.SPZT = '院长审批' THEN 4
  552. WHEN r.SPZT = '科技项目管理专责确认' THEN 5
  553. WHEN r.SPZT = '未提交' THEN 996
  554. WHEN r.SPZT = '未提交(返回)' THEN 997
  555. WHEN r.SPZT = '审批结束' THEN 998
  556. WHEN r.SPZT = '作废' THEN 999
  557. END
  558. ASC,
  559. CJSJ DESC
  560. </select>
  561. <!--获取全部费用申请(审批完成)-->
  562. <select id="getAllApplyList" resultMap="StaBudgetapprovalMap" parameterType="map">
  563. select b.*, t.XMLXMC, d.dept_name as SSBMMC, g.FYMC as FYLBMC, r.XM as XMFZRXM,
  564. case when b.SFBYJ = 1 then '是' else '否' end as SFBYJMC, case when b.SFBZ = 1 then '是' else '否' end as SFBZMC,
  565. (SELECT STUFF((SELECT ','+XM from (select xm from base_Person
  566. where id in (select dkyfzrid from
  567. (select DISTINCT zwmc,SUBSTRING(dkyfzr, number,CHARINDEX(',',dkyfzr+',',number)-number) as dkyfzrid
  568. from prj_Project WITH(nolock) ,master..spt_values with(nolock) where number >= 1 and len(DKYFZR) > number
  569. and SUBSTRING(','+DKYFZR,number,1)=',' and ID = b.XMID) t)) B for xml path('')),1,1,'')) as DKYFZRXM
  570. from sta_BudgetApproval b
  571. left join base_ProjectType t on t.XMLX = b.XMLX
  572. left join prj_Project p on p.ID = b.XMID
  573. left join sys_dept_info d on d.dept_id = b.SSBM
  574. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  575. left join base_Person r on r.ID = b.XMFZR
  576. where 1 = 1
  577. <if test="bh != null and bh != ''">
  578. and b.BH like '%'+#{bh}+'%'
  579. </if>
  580. <if test="erpbh != null and erpbh != ''">
  581. and b.ERPBH like '%'+#{erpbh}+'%'
  582. </if>
  583. <if test="xmlx != null and xmlx != ''">
  584. and b.XMLX = #{xmlx}
  585. </if>
  586. <if test="sfbyj != null and sfbyj != ''">
  587. and b.SFBYJ = #{sfbyj}
  588. </if>
  589. <if test="xmmc != null and xmmc != ''">
  590. and b.XMMC like '%'+#{xmmc}+'%'
  591. </if>
  592. <if test="fylb != null and fylb != ''">
  593. and g.FYMC like '%'+#{fylb}+'%'
  594. </if>
  595. <if test="sqr != null and sqr != ''">
  596. and b.sqrxm like '%'+#{sqr}+'%'
  597. </if>
  598. <if test="ssbmmc != null and ssbmmc != ''">
  599. and d.dept_name like '%'+#{ssbmmc}+'%'
  600. </if>
  601. <if test="nf != null and nf != ''">
  602. and b.NF = #{nf}
  603. </if>
  604. <if test="spzt != null and spzt != ''">
  605. and b.SPZT = #{spzt}
  606. </if>
  607. <if test="sfbz != null and sfbz != ''">
  608. and b.SFBZ = #{sfbz}
  609. </if>
  610. <if test="dkyfzr != null and dkyfzr != ''">
  611. and p.DKYFZR like '%'+#{dkyfzr}+'%'
  612. </if>
  613. <if test="sqsj1 != null and sqsj1 != ''">
  614. and b.SQSJ >= #{sqsj1}
  615. </if>
  616. <if test="sqsj2 != null and sqsj2 != ''">
  617. and DATEADD(day, 1, #{sqsj2}) >= b.SQSJ
  618. </if>
  619. <choose>
  620. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  621. order by ${sortName} ${sortOrder}
  622. </when>
  623. </choose>
  624. ORDER BY
  625. CASE
  626. WHEN b.SPZT = '部门主任审批' THEN 0
  627. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  628. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  629. WHEN b.SPZT = '主管院领导审批' THEN 3
  630. WHEN b.SPZT = '院长审批' THEN 4
  631. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  632. WHEN b.SPZT = '未提交' THEN 996
  633. WHEN b.SPZT = '未提交(返回)' THEN 997
  634. WHEN b.SPZT = '审批结束' THEN 998
  635. WHEN b.SPZT = '作废' THEN 999
  636. END
  637. ASC,
  638. b.SQSJ DESC
  639. </select>
  640. <!--获取审批中的费用申请-->
  641. <select id="getApprovingList" resultMap="StaBudgetapprovalMap" parameterType="map">
  642. select b.*, t.XMLXMC, d.dept_name as SSBMMC, g.FYMC as FYLBMC, r.XM as XMFZRXM,
  643. case when b.SFBYJ = 1 then '是' else '否' end as SFBYJMC, case when b.SFBZ = 1 then '是' else '否' end as SFBZMC,
  644. (SELECT STUFF((SELECT ','+XM from (select xm from base_Person
  645. where id in (select dkyfzrid from
  646. (select DISTINCT zwmc,SUBSTRING(dkyfzr, number,CHARINDEX(',',dkyfzr+',',number)-number) as dkyfzrid
  647. from prj_Project WITH(nolock) ,master..spt_values with(nolock) where number >= 1 and len(DKYFZR) > number
  648. and SUBSTRING(','+DKYFZR,number,1)=',' and ID = b.XMID) t)) B for xml path('')),1,1,'')) as DKYFZRXM
  649. from sta_BudgetApproval b
  650. left join base_ProjectType t on t.XMLX = b.XMLX
  651. left join prj_Project p on p.ID = b.XMID
  652. left join sys_dept_info d on d.dept_id = b.SSBM
  653. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  654. left join base_Person r on r.ID = b.XMFZR
  655. where b.SPZT != '未提交' and b.SPZT != '审批结束' and b.SPZT != '作废' and b.SFBYJ = 0
  656. <if test="spzt != null and spzt != ''">
  657. and b.SPZT = #{spzt}
  658. </if>
  659. <if test="bh != null and bh != ''">
  660. and b.BH like '%'+#{bh}+'%'
  661. </if>
  662. <if test="nf != null and nf != ''">
  663. and b.NF = #{nf}
  664. </if>
  665. <if test="sfbyj != null and sfbyj != ''">
  666. and b.SFBYJ = #{sfbyj}
  667. </if>
  668. <if test="xmmc != null and xmmc != ''">
  669. and b.XMMC like '%'+#{xmmc}+'%'
  670. </if>
  671. <if test="erpbh != null and erpbh != ''">
  672. and b.ERPBH like '%'+#{erpbh}+'%'
  673. </if>
  674. <if test="xmlx != null and xmlx != ''">
  675. and b.XMLX = #{xmlx}
  676. </if>
  677. <if test="ssbmmc != null and ssbmmc != ''">
  678. and d.dept_name like '%'+#{ssbm}+'%'
  679. </if>
  680. <choose>
  681. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  682. order by ${sortName} ${sortOrder}
  683. </when>
  684. </choose>
  685. ORDER BY
  686. CASE
  687. WHEN b.SPZT = '部门主任审批' THEN 0
  688. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  689. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  690. WHEN b.SPZT = '主管院领导审批' THEN 3
  691. WHEN b.SPZT = '院长审批' THEN 4
  692. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  693. END
  694. ASC,
  695. b.SQSJ DESC
  696. </select>
  697. <!--批量删除费用申请-->
  698. <delete id="batchDelete" parameterType="java.util.ArrayList">
  699. delete from sta_BudgetApproval
  700. where ID in
  701. <foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
  702. #{item}
  703. </foreach>
  704. </delete>
  705. <!--撤销审核状态费用申请-->
  706. <update id="tjrevokeApprove">
  707. update sta_BudgetApproval
  708. set SPZT = '未提交'
  709. where ID = #{id}
  710. </update>
  711. <!--通过主键修改审批状态-->
  712. <update id="updateSpzt">
  713. update sta_BudgetApproval
  714. set SPZT = #{spzt},
  715. BH=#{bh}
  716. where ID = #{id}
  717. </update>
  718. <!--获取费用申请信息-->
  719. <select id="getFysqById" resultMap="StaBudgetapprovalMap">
  720. select b.*,
  721. t.XMLXMC,
  722. d.dept_name as SSBMMC,
  723. g.FYMC as FYLBMC,
  724. r.XM as XMFZRXM,
  725. (select MC from base_ProjectBudget g1 where g1.BM = g.FJ) as FJMC,
  726. case when b.SFBYJ = 1 then '是' else '否' end as SFBYJMC,
  727. case when b.SFBZ = 1 then '是' else '否' end as SFBZMC,
  728. (SELECT STUFF((SELECT ',' + XM
  729. from (select xm
  730. from base_Person
  731. where id in (select dkyfzrid
  732. from (select DISTINCT zwmc,
  733. SUBSTRING(dkyfzr, number,
  734. CHARINDEX(',', dkyfzr + ',', number) -
  735. number) as dkyfzrid
  736. from prj_Project WITH(nolock) ,master..spt_values
  737. with (nolock)
  738. where number >= 1
  739. and len(DKYFZR)
  740. > number
  741. and SUBSTRING (','+DKYFZR
  742. , number
  743. , 1)=','
  744. and ID = b.XMID) t)) B for xml path ('')),1,1,'')) as DKYFZRXM
  745. from sta_BudgetApproval b
  746. left join base_ProjectType t on t.XMLX = b.XMLX
  747. left join prj_Project p on p.ID = b.XMID
  748. left join sys_dept_info d on d.dept_id = b.SSBM
  749. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  750. left join base_Person r on r.ID = b.XMFZR
  751. where b.ID = #{id}
  752. </select>
  753. <!--获取费用管理列表-->
  754. <select id="getFyglList" resultMap="StaBudgetapprovalMap" parameterType="map">
  755. select b.*, t.XMLXMC, d.dept_name as SSBMMC, r.XM as XMFZRXM
  756. from sta_BudgetApproval b
  757. left join base_ProjectType t on t.XMLX = b.XMLX
  758. left join prj_Project p on p.ID = b.XMID
  759. left join sys_dept_info d on d.dept_id = b.SSBM
  760. left join base_Person r on r.ID = b.XMFZR
  761. where 1 = 1
  762. <if test="xmmc != null and xmmc != ''">
  763. and b.XMMC like '%'+#{xmmc}+'%'
  764. </if>
  765. <if test="erpbh != null and erpbh != ''">
  766. and b.ERPBH like '%'+#{erpbh}+'%'
  767. </if>
  768. <if test="xmlx != null and xmlx != ''">
  769. and b.XMLX = #{xmlx}
  770. </if>
  771. <if test="xmfzrxm != null and xmfzrxm != ''">
  772. and r.XM like '%'+#{xmfzrxm}+'%'
  773. </if>
  774. <if test="ssbmmc != null and ssbmmc != ''">
  775. and d.dept_name like '%'+#{ssbm}+'%'
  776. </if>
  777. <choose>
  778. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  779. order by ${sortName} ${sortOrder}
  780. </when>
  781. </choose>
  782. </select>
  783. <!--更新报账数据-->
  784. <update id="updateReimburse">
  785. update sta_BudgetApproval
  786. set SFBZ = 1,
  787. BXPZ = #{bxpz},
  788. BZJE = #{bzje},
  789. BHSJE = #{bhsje},
  790. SF = #{sf}
  791. where ID = #{id}
  792. </update>
  793. <!--批量修改报账信息-->
  794. <update id="clearReimburse">
  795. update sta_BudgetApproval
  796. set SFBZ = 0,
  797. BXPZ = null,
  798. BZJE = null,
  799. BHSJE = null,
  800. SF = null
  801. where ID in
  802. <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
  803. #{item}
  804. </foreach>
  805. </update>
  806. <!--批量作废费用申请-->
  807. <delete id="batchNullify" parameterType="java.util.ArrayList">
  808. update sta_BudgetApproval
  809. set SPZT = '作废'
  810. where ID in
  811. <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
  812. #{item}
  813. </foreach>
  814. </delete>
  815. <!--项目总体费用信息-->
  816. <select id="getXmFyInfo" resultMap="StaBudgetapprovalMap">
  817. 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,
  818. SUM(b.BZJE) as BZJE,
  819. (select YSJE from prj_AnnualBudgetDetail where NYS = b.NYS and FJ = '') as YSJE
  820. from sta_BudgetApproval b
  821. where b.NYS = #{nys} and b.SPZT != '作废' and b.SFBYJ =0
  822. GROUP BY b.NYS
  823. </select>
  824. <!--项目分项费用信息-->
  825. <select id="getKmFyInfo" resultMap="StaBudgetapprovalMap" parameterType="map">
  826. select b.NYS, b.FYLB,
  827. ISNULL((select SUM(SQJE) from sta_BudgetApproval where NYS = #{nys1} and FYLB = #{fylb1} and SPZT != '作废'),0) as SQJE,
  828. (select
  829. SUM(sr.bzje)
  830. from
  831. sta_Reimbursement sr
  832. left join sta_BudgetApproval sb on sr.fysq = sb.id
  833. where
  834. sb.NYS = #{nys1}
  835. and sb.FYLB = #{fylb1}
  836. and sb.SPZT != '作废'
  837. and sb.SFBYJ = 0
  838. and sr.spzt = '审批结束') as BZJE,
  839. (select YSJE from prj_AnnualBudgetDetail where NYS = b.NYS and ID = b.FYLB) as YSJE,
  840. (SELECT
  841. sum(ISNULL(sr.BZJE ,sb.SQJE))
  842. from
  843. sta_BudgetApproval sb
  844. left join sta_Reimbursement sr on sr.fysq = sb.id and sr.SPZT = '审批结束'
  845. where
  846. sb.NYS = #{nys1}
  847. and sb.fylb = #{fylb1}
  848. and sb.spzt != '作废'
  849. ) xmndjfysq
  850. from sta_BudgetApproval b
  851. where b.NYS = #{nys} and b.FYLB = #{fylb} and b.SPZT != '作废' and b.SFBYJ =0
  852. GROUP BY b.NYS, b.FYLB
  853. </select>
  854. <!--未关联项目备用金 -->
  855. <select id="unassociated" resultMap="StaBudgetapprovalMap" parameterType="map">
  856. SELECT * FROM sta_BudgetApproval
  857. WHERE
  858. SFBYJ = 1
  859. AND XMMC IS NULL
  860. AND SPZT='审批结束'
  861. <if test="xmmc != null and xmmc != ''">
  862. and XMMC like '%'+#{xmmc}+'%'
  863. </if>
  864. <if test="bh != null and bh != ''">
  865. and BH like '%'+#{bh}+'%'
  866. </if>
  867. <if test="nf != null and nf != ''">
  868. and NF = #{nf}
  869. </if>
  870. </select>
  871. <!--项目备用金信息-->
  872. <select id="getByjInfo" resultMap="StaBudgetapprovalMap">
  873. 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,
  874. SUM(b.BZJE) as BZJE,
  875. (select YSJE from prj_AnnualBudgetDetail where NYS = b.NYS and FJ = '') as YSJE
  876. from sta_BudgetApproval b
  877. where b.NYS = #{nys} and b.SPZT != '作废' and b.SFBYJ =1
  878. GROUP BY b.NYS
  879. </select>
  880. <select id="getBhById" resultType="java.lang.String">
  881. SELECT BH FROM sta_BudgetApproval where ID = #{id}
  882. </select>
  883. <select id="getBayID" resultMap="StaBudgetapprovalMap">
  884. SELECT * FROM sta_BudgetApproval where ID = #{id}
  885. </select>
  886. </mapper>