StaBudgetapprovalDao.xml 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  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. <if test="userId != null and userId != ''">
  513. and (b.SQR = #{userId} or #{userId} in (select SHR from prj_ApproveRecord where XMID = b.ID))
  514. </if>
  515. <if test="sqmc != null and sqmc != ''">
  516. and b.SQMC like '%'+#{sqmc}+'%'
  517. </if>
  518. <if test="erpbh != null and erpbh != ''">
  519. and b.ERPBH like '%'+#{erpbh}+'%'
  520. </if>
  521. <if test="bh != null and bh != ''">
  522. and b.BH like '%'+#{bh}+'%'
  523. </if>
  524. <if test="xmlx != null and xmlx != ''">
  525. and b.XMLX = #{xmlx}
  526. </if>
  527. <if test="dkyfzr != null and dkyfzr != ''">
  528. and p.DKYFZR like '%'+#{dkyfzr}+'%'
  529. </if>
  530. <if test="ssbmmc != null and ssbmmc != ''">
  531. and d.dept_name like '%'+#{ssbm}+'%'
  532. </if>
  533. <if test="nf != null and nf != ''">
  534. and b.NF = #{nf}
  535. </if>
  536. <choose>
  537. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  538. order by ${sortName} ${sortOrder}
  539. </when>
  540. </choose>
  541. ORDER BY
  542. CASE
  543. WHEN r.SPZT = '部门主任审批' THEN 0
  544. WHEN r.SPZT = '科技项目管理专责审批' THEN 1
  545. WHEN r.SPZT = '科技部部门主任审批' THEN 2
  546. WHEN r.SPZT = '主管院领导审批' THEN 3
  547. WHEN r.SPZT = '院长审批' THEN 4
  548. WHEN r.SPZT = '科技项目管理专责确认' THEN 5
  549. WHEN r.SPZT = '未提交' THEN 996
  550. WHEN r.SPZT = '未提交(返回)' THEN 997
  551. WHEN r.SPZT = '审批结束' THEN 998
  552. WHEN r.SPZT = '作废' THEN 999
  553. END
  554. ASC,
  555. CJSJ DESC
  556. </select>
  557. <!--获取全部费用申请(审批完成)-->
  558. <select id="getAllApplyList" resultMap="StaBudgetapprovalMap" parameterType="map">
  559. select b.*, t.XMLXMC, d.dept_name as SSBMMC, g.FYMC as FYLBMC, r.XM as XMFZRXM,
  560. case when b.SFBYJ = 1 then '是' else '否' end as SFBYJMC, case when b.SFBZ = 1 then '是' else '否' end as SFBZMC,
  561. (SELECT STUFF((SELECT ','+XM from (select xm from base_Person
  562. where id in (select dkyfzrid from
  563. (select DISTINCT zwmc,SUBSTRING(dkyfzr, number,CHARINDEX(',',dkyfzr+',',number)-number) as dkyfzrid
  564. from prj_Project WITH(nolock) ,master..spt_values with(nolock) where number >= 1 and len(DKYFZR) > number
  565. and SUBSTRING(','+DKYFZR,number,1)=',' and ID = b.XMID) t)) B for xml path('')),1,1,'')) as DKYFZRXM
  566. from sta_BudgetApproval b
  567. left join base_ProjectType t on t.XMLX = b.XMLX
  568. left join prj_Project p on p.ID = b.XMID
  569. left join sys_dept_info d on d.dept_id = b.SSBM
  570. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  571. left join base_Person r on r.ID = b.XMFZR
  572. where 1 = 1
  573. <if test="bh != null and bh != ''">
  574. and b.BH like '%'+#{bh}+'%'
  575. </if>
  576. <if test="erpbh != null and erpbh != ''">
  577. and b.ERPBH like '%'+#{erpbh}+'%'
  578. </if>
  579. <if test="xmlx != null and xmlx != ''">
  580. and b.XMLX = #{xmlx}
  581. </if>
  582. <if test="sfbyj != null and sfbyj != ''">
  583. and b.SFBYJ = #{sfbyj}
  584. </if>
  585. <if test="xmmc != null and xmmc != ''">
  586. and b.XMMC like '%'+#{xmmc}+'%'
  587. </if>
  588. <if test="fylb != null and fylb != ''">
  589. and g.FYMC like '%'+#{fylb}+'%'
  590. </if>
  591. <if test="sqr != null and sqr != ''">
  592. and b.sqrxm like '%'+#{sqr}+'%'
  593. </if>
  594. <if test="ssbmmc != null and ssbmmc != ''">
  595. and d.dept_name like '%'+#{ssbm}+'%'
  596. </if>
  597. <if test="nf != null and nf != ''">
  598. and b.NF = #{nf}
  599. </if>
  600. <if test="spzt != null and spzt != ''">
  601. and b.SPZT = #{spzt}
  602. </if>
  603. <if test="sfbz != null and sfbz != ''">
  604. and b.SFBZ = #{sfbz}
  605. </if>
  606. <if test="dkyfzr != null and dkyfzr != ''">
  607. and p.DKYFZR like '%'+#{dkyfzr}+'%'
  608. </if>
  609. <if test="sqsj1 != null and sqsj1 != ''">
  610. and b.SQSJ >= #{sqsj1}
  611. </if>
  612. <if test="sqsj2 != null and sqsj2 != ''">
  613. and DATEADD(day, 1, #{sqsj2}) >= b.SQSJ
  614. </if>
  615. <choose>
  616. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  617. order by ${sortName} ${sortOrder}
  618. </when>
  619. </choose>
  620. ORDER BY
  621. CASE
  622. WHEN b.SPZT = '部门主任审批' THEN 0
  623. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  624. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  625. WHEN b.SPZT = '主管院领导审批' THEN 3
  626. WHEN b.SPZT = '院长审批' THEN 4
  627. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  628. WHEN b.SPZT = '未提交' THEN 996
  629. WHEN b.SPZT = '未提交(返回)' THEN 997
  630. WHEN b.SPZT = '审批结束' THEN 998
  631. WHEN b.SPZT = '作废' THEN 999
  632. END
  633. ASC,
  634. b.SQSJ DESC
  635. </select>
  636. <!--获取审批中的费用申请-->
  637. <select id="getApprovingList" resultMap="StaBudgetapprovalMap" parameterType="map">
  638. select b.*, t.XMLXMC, d.dept_name as SSBMMC, g.FYMC as FYLBMC, r.XM as XMFZRXM,
  639. case when b.SFBYJ = 1 then '是' else '否' end as SFBYJMC, case when b.SFBZ = 1 then '是' else '否' end as SFBZMC,
  640. (SELECT STUFF((SELECT ','+XM from (select xm from base_Person
  641. where id in (select dkyfzrid from
  642. (select DISTINCT zwmc,SUBSTRING(dkyfzr, number,CHARINDEX(',',dkyfzr+',',number)-number) as dkyfzrid
  643. from prj_Project WITH(nolock) ,master..spt_values with(nolock) where number >= 1 and len(DKYFZR) > number
  644. and SUBSTRING(','+DKYFZR,number,1)=',' and ID = b.XMID) t)) B for xml path('')),1,1,'')) as DKYFZRXM
  645. from sta_BudgetApproval b
  646. left join base_ProjectType t on t.XMLX = b.XMLX
  647. left join prj_Project p on p.ID = b.XMID
  648. left join sys_dept_info d on d.dept_id = b.SSBM
  649. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  650. left join base_Person r on r.ID = b.XMFZR
  651. where b.SPZT != '未提交' and b.SPZT != '审批结束' and b.SPZT != '作废' and b.SFBYJ = 0
  652. <if test="spzt != null and spzt != ''">
  653. and b.SPZT = #{spzt}
  654. </if>
  655. <if test="bh != null and bh != ''">
  656. and b.BH like '%'+#{bh}+'%'
  657. </if>
  658. <if test="nf != null and nf != ''">
  659. and b.NF = #{nf}
  660. </if>
  661. <if test="sfbyj != null and sfbyj != ''">
  662. and b.SFBYJ = #{sfbyj}
  663. </if>
  664. <if test="xmmc != null and xmmc != ''">
  665. and b.XMMC like '%'+#{xmmc}+'%'
  666. </if>
  667. <if test="erpbh != null and erpbh != ''">
  668. and b.ERPBH like '%'+#{erpbh}+'%'
  669. </if>
  670. <if test="xmlx != null and xmlx != ''">
  671. and b.XMLX = #{xmlx}
  672. </if>
  673. <if test="ssbmmc != null and ssbmmc != ''">
  674. and d.dept_name like '%'+#{ssbm}+'%'
  675. </if>
  676. <choose>
  677. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  678. order by ${sortName} ${sortOrder}
  679. </when>
  680. </choose>
  681. ORDER BY
  682. CASE
  683. WHEN b.SPZT = '部门主任审批' THEN 0
  684. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  685. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  686. WHEN b.SPZT = '主管院领导审批' THEN 3
  687. WHEN b.SPZT = '院长审批' THEN 4
  688. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  689. END
  690. ASC,
  691. b.SQSJ DESC
  692. </select>
  693. <!--批量删除费用申请-->
  694. <delete id="batchDelete" parameterType="java.util.ArrayList">
  695. delete from sta_BudgetApproval
  696. where ID in
  697. <foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
  698. #{item}
  699. </foreach>
  700. </delete>
  701. <!--撤销审核状态费用申请-->
  702. <update id="tjrevokeApprove">
  703. update sta_BudgetApproval
  704. set SPZT = '未提交'
  705. where ID = #{id}
  706. </update>
  707. <!--通过主键修改审批状态-->
  708. <update id="updateSpzt">
  709. update sta_BudgetApproval
  710. set SPZT = #{spzt},
  711. BH=#{bh}
  712. where ID = #{id}
  713. </update>
  714. <!--获取费用申请信息-->
  715. <select id="getFysqById" resultMap="StaBudgetapprovalMap">
  716. select b.*,
  717. t.XMLXMC,
  718. d.dept_name as SSBMMC,
  719. g.FYMC as FYLBMC,
  720. r.XM as XMFZRXM,
  721. (select MC from base_ProjectBudget g1 where g1.BM = g.FJ) as FJMC,
  722. case when b.SFBYJ = 1 then '是' else '否' end as SFBYJMC,
  723. case when b.SFBZ = 1 then '是' else '否' end as SFBZMC,
  724. (SELECT STUFF((SELECT ',' + XM
  725. from (select xm
  726. from base_Person
  727. where id in (select dkyfzrid
  728. from (select DISTINCT zwmc,
  729. SUBSTRING(dkyfzr, number,
  730. CHARINDEX(',', dkyfzr + ',', number) -
  731. number) as dkyfzrid
  732. from prj_Project WITH(nolock) ,master..spt_values
  733. with (nolock)
  734. where number >= 1
  735. and len(DKYFZR)
  736. > number
  737. and SUBSTRING (','+DKYFZR
  738. , number
  739. , 1)=','
  740. and ID = b.XMID) t)) B for xml path ('')),1,1,'')) as DKYFZRXM
  741. from sta_BudgetApproval b
  742. left join base_ProjectType t on t.XMLX = b.XMLX
  743. left join prj_Project p on p.ID = b.XMID
  744. left join sys_dept_info d on d.dept_id = b.SSBM
  745. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  746. left join base_Person r on r.ID = b.XMFZR
  747. where b.ID = #{id}
  748. </select>
  749. <!--获取费用管理列表-->
  750. <select id="getFyglList" resultMap="StaBudgetapprovalMap" parameterType="map">
  751. select b.*, t.XMLXMC, d.dept_name as SSBMMC, r.XM as XMFZRXM
  752. from sta_BudgetApproval b
  753. left join base_ProjectType t on t.XMLX = b.XMLX
  754. left join prj_Project p on p.ID = b.XMID
  755. left join sys_dept_info d on d.dept_id = b.SSBM
  756. left join base_Person r on r.ID = b.XMFZR
  757. where 1 = 1
  758. <if test="xmmc != null and xmmc != ''">
  759. and b.XMMC like '%'+#{xmmc}+'%'
  760. </if>
  761. <if test="erpbh != null and erpbh != ''">
  762. and b.ERPBH like '%'+#{erpbh}+'%'
  763. </if>
  764. <if test="xmlx != null and xmlx != ''">
  765. and b.XMLX = #{xmlx}
  766. </if>
  767. <if test="xmfzrxm != null and xmfzrxm != ''">
  768. and r.XM like '%'+#{xmfzrxm}+'%'
  769. </if>
  770. <if test="ssbmmc != null and ssbmmc != ''">
  771. and d.dept_name like '%'+#{ssbm}+'%'
  772. </if>
  773. <choose>
  774. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  775. order by ${sortName} ${sortOrder}
  776. </when>
  777. </choose>
  778. </select>
  779. <!--更新报账数据-->
  780. <update id="updateReimburse">
  781. update sta_BudgetApproval
  782. set SFBZ = 1,
  783. BXPZ = #{bxpz},
  784. BZJE = #{bzje},
  785. BHSJE = #{bhsje},
  786. SF = #{sf}
  787. where ID = #{id}
  788. </update>
  789. <!--批量修改报账信息-->
  790. <update id="clearReimburse">
  791. update sta_BudgetApproval
  792. set SFBZ = 0,
  793. BXPZ = null,
  794. BZJE = null,
  795. BHSJE = null,
  796. SF = null
  797. where ID in
  798. <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
  799. #{item}
  800. </foreach>
  801. </update>
  802. <!--批量作废费用申请-->
  803. <delete id="batchNullify" parameterType="java.util.ArrayList">
  804. update sta_BudgetApproval
  805. set SPZT = '作废'
  806. where ID in
  807. <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
  808. #{item}
  809. </foreach>
  810. </delete>
  811. <!--项目总体费用信息-->
  812. <select id="getXmFyInfo" resultMap="StaBudgetapprovalMap">
  813. 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,
  814. SUM(b.BZJE) as BZJE,
  815. (select YSJE from prj_AnnualBudgetDetail where NYS = b.NYS and FJ = '') as YSJE
  816. from sta_BudgetApproval b
  817. where b.NYS = #{nys} and b.SPZT != '作废' and b.SFBYJ =0
  818. GROUP BY b.NYS
  819. </select>
  820. <!--项目分项费用信息-->
  821. <select id="getKmFyInfo" resultMap="StaBudgetapprovalMap" parameterType="map">
  822. select b.NYS, b.FYLB,
  823. ISNULL((select SUM(SQJE) from sta_BudgetApproval where NYS = #{nys1} and FYLB = #{fylb1} and SPZT != '作废' and SFBYJ =0),0) as SQJE,
  824. (select
  825. SUM(sr.bzje)
  826. from
  827. sta_Reimbursement sr
  828. left join sta_BudgetApproval sb on sr.fysq = sb.id
  829. where
  830. sb.NYS = #{nys1}
  831. and sb.FYLB = #{fylb1}
  832. and sb.SPZT != '作废'
  833. and sb.SFBYJ = 0
  834. and sr.spzt = '审批结束') as BZJE,
  835. (select YSJE from prj_AnnualBudgetDetail where NYS = b.NYS and ID = b.FYLB) as YSJE,
  836. (SELECT
  837. sum(ISNULL(sr.BZJE ,sb.SQJE))
  838. from
  839. sta_BudgetApproval sb
  840. left join sta_Reimbursement sr on sr.fysq = sb.id and sr.SPZT = '审批结束'
  841. where sb.NYS = #{nys1} and sb.fylb = #{fylb1}
  842. ) xmndjfysq
  843. from sta_BudgetApproval b
  844. where b.NYS = #{nys} and b.FYLB = #{fylb} and b.SPZT != '作废' and b.SFBYJ =0
  845. GROUP BY b.NYS, b.FYLB
  846. </select>
  847. <!--未关联项目备用金 -->
  848. <select id="unassociated" resultMap="StaBudgetapprovalMap" parameterType="map">
  849. SELECT * FROM sta_BudgetApproval WHERE SFBYJ = 1 AND XMMC IS NULL AND SPZT='审批结束'
  850. </select>
  851. <!--项目备用金信息-->
  852. <select id="getByjInfo" resultMap="StaBudgetapprovalMap">
  853. 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,
  854. SUM(b.BZJE) as BZJE,
  855. (select YSJE from prj_AnnualBudgetDetail where NYS = b.NYS and FJ = '') as YSJE
  856. from sta_BudgetApproval b
  857. where b.NYS = #{nys} and b.SPZT != '作废' and b.SFBYJ =1
  858. GROUP BY b.NYS
  859. </select>
  860. <select id="getBhById" resultType="java.lang.String">
  861. SELECT BH FROM sta_BudgetApproval where ID = #{id}
  862. </select>
  863. </mapper>