StaBudgetapprovalDao.xml 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317
  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. <result property="mc" column="MC" jdbcType="VARCHAR"/>
  38. <result property="fymc" column="FYMC" jdbcType="VARCHAR"/>
  39. <result property="bzid" column="BZID" jdbcType="VARCHAR"/>
  40. <result property="xmzys" column="XMZYS" jdbcType="NUMERIC"/>
  41. <result property="zbzje" column="ZBZJE" jdbcType="NUMERIC"/>
  42. <result property="sfth" column="SFTH" jdbcType="INTEGER"/>
  43. <result property="sl" column="SL" jdbcType="VARCHAR"/>
  44. <result property="ssbmmc" column="SSBMMC" jdbcType="VARCHAR"/>
  45. </resultMap>
  46. <!--查询单个-->
  47. <select id="queryById" resultMap="StaBudgetapprovalMap">
  48. select b.*, d.YSJE,d.FYMC,c.dept_name as SSBMMC
  49. from sta_BudgetApproval b
  50. left join prj_AnnualBudgetDetail d on d.NYS = b.NYS and d.ID = b.FYLB
  51. left join sys_dept_info c on b.SSBM = c.dept_id
  52. where b.ID = #{id}
  53. </select>
  54. <select id="queryByBH" resultMap="StaBudgetapprovalMap">
  55. select *
  56. from sta_BudgetApproval
  57. where BH like #{bh} + '%'
  58. order by ID desc
  59. </select>
  60. <!--查询指定行数据-->
  61. <select id="queryAllByLimit" resultMap="StaBudgetapprovalMap">
  62. select *
  63. from s
  64. <where>
  65. <if test="id != null">
  66. and ID = #{id}
  67. </if>
  68. <if test="xmmc != null and xmmc != ''">
  69. and XMMC = #{xmmc}
  70. </if>
  71. <if test="xmid != null">
  72. and XMID = #{xmid}
  73. </if>
  74. <if test="bh != null and bh != ''">
  75. and BH = #{bh}
  76. </if>
  77. <if test="sqsm != null and sqsm != ''">
  78. and SQSM = #{sqsm}
  79. </if>
  80. <if test="sqje != null">
  81. and SQJE = #{sqje}
  82. </if>
  83. <if test="fylb != null">
  84. and FYLB = #{fylb}
  85. </if>
  86. <if test="bbm != null and bbm != ''">
  87. and BBM = #{bbm}
  88. </if>
  89. <if test="fj != null and fj != ''">
  90. and FJ = #{fj}
  91. </if>
  92. <if test="shzt != null and shzt != ''">
  93. and SHZT = #{shzt}
  94. </if>
  95. <if test="nf != null and nf != ''">
  96. and NF = #{nf}
  97. </if>
  98. <if test="sqr != null">
  99. and SQR = #{sqr}
  100. </if>
  101. <if test="sqrxm != null and sqrxm != ''">
  102. and SQRXM = #{sqrxm}
  103. </if>
  104. <if test="sqsj != null">
  105. and SQSJ = #{sqsj}
  106. </if>
  107. <if test="sqmc != null and sqmc != ''">
  108. and SQMC = #{sqmc}
  109. </if>
  110. <if test="spzt != null and spzt != ''">
  111. and SPZT = #{spzt}
  112. </if>
  113. <if test="kyfyxx != null and kyfyxx != ''">
  114. and KYFYXX = #{kyfyxx}
  115. </if>
  116. <if test="bzje != null">
  117. and BZJE = #{bzje}
  118. </if>
  119. <if test="bxpz != null and bxpz != ''">
  120. and BXPZ = #{bxpz}
  121. </if>
  122. <if test="bzje2 != null">
  123. and BZJE2 = #{bzje2}
  124. </if>
  125. <if test="sfbyj != null and sfbyj != ''">
  126. and SFBYJ = #{sfbyj}
  127. </if>
  128. <if test="kybg != null and kybg != ''">
  129. and KYBG = #{kybg}
  130. </if>
  131. <if test="erpbh != null and erpbh != ''">
  132. and ERPBH = #{erpbh}
  133. </if>
  134. <if test="xmlx != null and xmlx != ''">
  135. and XMLX = #{xmlx}
  136. </if>
  137. <if test="xmfzr != null">
  138. and XMFZR = #{xmfzr}
  139. </if>
  140. <if test="ssbm != null">
  141. and SSBM = #{ssbm}
  142. </if>
  143. <if test="sfbz != null and sfbz != ''">
  144. and SFBZ = #{sfbz}
  145. </if>
  146. <if test="smwj != null and smwj != ''">
  147. and SMWJ = #{smwj}
  148. </if>
  149. <if test="bhsje != null">
  150. and BHSJE = #{bhsje}
  151. </if>
  152. <if test="sf != null">
  153. and SF = #{sf}
  154. </if>
  155. <if test="nys != null">
  156. and NYS = #{nys}
  157. </if>
  158. </where>
  159. limit #{pageable.offset}, #{pageable.pageSize}
  160. </select>
  161. <!--统计总行数-->
  162. <select id="count" resultType="java.lang.Long">
  163. select count(1)
  164. from sta_BudgetApproval
  165. <where>
  166. <if test="id != null">
  167. and ID = #{id}
  168. </if>
  169. <if test="xmmc != null and xmmc != ''">
  170. and XMMC = #{xmmc}
  171. </if>
  172. <if test="xmid != null">
  173. and XMID = #{xmid}
  174. </if>
  175. <if test="bh != null and bh != ''">
  176. and BH = #{bh}
  177. </if>
  178. <if test="sqsm != null and sqsm != ''">
  179. and SQSM = #{sqsm}
  180. </if>
  181. <if test="sqje != null">
  182. and SQJE = #{sqje}
  183. </if>
  184. <if test="fylb != null">
  185. and FYLB = #{fylb}
  186. </if>
  187. <if test="bbm != null and bbm != ''">
  188. and BBM = #{bbm}
  189. </if>
  190. <if test="fj != null and fj != ''">
  191. and FJ = #{fj}
  192. </if>
  193. <if test="shzt != null and shzt != ''">
  194. and SHZT = #{shzt}
  195. </if>
  196. <if test="nf != null and nf != ''">
  197. and NF = #{nf}
  198. </if>
  199. <if test="sqr != null">
  200. and SQR = #{sqr}
  201. </if>
  202. <if test="sqrxm != null and sqrxm != ''">
  203. and SQRXM = #{sqrxm}
  204. </if>
  205. <if test="sqsj != null">
  206. and SQSJ = #{sqsj}
  207. </if>
  208. <if test="sqmc != null and sqmc != ''">
  209. and SQMC = #{sqmc}
  210. </if>
  211. <if test="spzt != null and spzt != ''">
  212. and SPZT = #{spzt}
  213. </if>
  214. <if test="kyfyxx != null and kyfyxx != ''">
  215. and KYFYXX = #{kyfyxx}
  216. </if>
  217. <if test="bzje != null">
  218. and BZJE = #{bzje}
  219. </if>
  220. <if test="bxpz != null and bxpz != ''">
  221. and BXPZ = #{bxpz}
  222. </if>
  223. <if test="bzje2 != null">
  224. and BZJE2 = #{bzje2}
  225. </if>
  226. <if test="sfbyj != null and sfbyj != ''">
  227. and SFBYJ = #{sfbyj}
  228. </if>
  229. <if test="kybg != null and kybg != ''">
  230. and KYBG = #{kybg}
  231. </if>
  232. <if test="erpbh != null and erpbh != ''">
  233. and ERPBH = #{erpbh}
  234. </if>
  235. <if test="xmlx != null and xmlx != ''">
  236. and XMLX = #{xmlx}
  237. </if>
  238. <if test="xmfzr != null">
  239. and XMFZR = #{xmfzr}
  240. </if>
  241. <if test="ssbm != null">
  242. and SSBM = #{ssbm}
  243. </if>
  244. <if test="sfbz != null and sfbz != ''">
  245. and SFBZ = #{sfbz}
  246. </if>
  247. <if test="smwj != null and smwj != ''">
  248. and SMWJ = #{smwj}
  249. </if>
  250. <if test="bhsje != null">
  251. and BHSJE = #{bhsje}
  252. </if>
  253. <if test="sf != null">
  254. and SF = #{sf}
  255. </if>
  256. <if test="nys != null">
  257. and NYS = #{nys}
  258. </if>
  259. </where>
  260. </select>
  261. <!--新增-->
  262. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  263. insert into sta_BudgetApproval(SQMC, XMMC, XMID, BH, NF, FYLB, SQJE, SQSM, FJ, SQRXM, SQR, SQSJ, ERPBH, KYBG,
  264. XMLX, XMFZR, SSBM, SFBYJ, SFBZ, SPZT, NYS, BZ,SFTH,ZBJE)
  265. values (#{sqmc}, #{xmmc}, #{xmid}, #{bh}, #{nf}, #{fylb}, #{sqje}, #{sqsm}, #{fj}, #{sqrxm}, #{sqr}, GETDATE(),
  266. #{erpbh}, #{kybg}, #{xmlx}, #{xmfzr}, #{ssbm}, 0, #{sfbz}, '未提交', #{nys}, #{bz},#{sfth},#{zbje})
  267. </insert>
  268. <insert id="insertImprest" keyProperty="id" useGeneratedKeys="true">
  269. insert into sta_BudgetApproval(SQMC, BH, SQSM, NF, SQJE, SQRXM, SQR, SQSJ, SFBYJ, SFBZ, SPZT,SFTH)
  270. values (#{sqmc}, #{bh}, #{sqsm}, #{nf}, #{sqje}, #{sqrxm}, #{sqr}, #{sqsj}, 1, 0, '未提交',0)
  271. </insert>
  272. <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
  273. insert into sta_BudgetApproval(XMMC, XMID, BH, SQSM, SQJE, FYLB, BBM, FJ, SHZT, NF, SQR, SQRXM, SQSJ, SQMC,
  274. SPZT, KYFYXX, BZJE, BXPZ, BZJE2, SFBYJ, KYBG, ERPBH, XMLX, XMFZR, SSBM, SFBZ, SMWJ, BHSJE, SF, NYS, BZ)
  275. values
  276. <foreach collection="entities" item="entity" separator=",">
  277. (#{entity.xmmc}, #{entity.xmid}, #{entity.bh}, #{entity.sqsm}, #{entity.sqje}, #{entity.fylb},
  278. #{entity.bbm}, #{entity.fj}, #{entity.shzt}, #{entity.nf}, #{entity.sqrxm}, #{entity.sqr}, #{entity.sqsj},
  279. #{entity.sqmc},
  280. #{entity.spzt}, #{entity.kyfyxx}, #{entity.bzje}, #{entity.bxpz}, #{entity.bzje2}, #{entity.sfbyj},
  281. #{entity.kybg}, #{entity.erpbh}, #{entity.xmlx}, #{entity.xmfzr}, #{entity.ssbm}, #{entity.sfbz},
  282. #{entity.smwj},
  283. #{entity.bhsje}, #{entity.sf}, #{entity.nys}, #{entity.bz})
  284. </foreach>
  285. </insert>
  286. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  287. insert into sta_BudgetApproval(XMMC, XMID, BH, SQSM, SQJE, FYLB, BBM, FJ, SHZT, NF, SQR, SQRXM, SQSJ, SQMC,
  288. SPZT, KYFYXX, BZJE, BXPZ, BZJE2, SFBYJ, KYBG, ERPBH, XMLX, XMFZR, SSBM, SFBZ, SMWJ, BHSJE, SF, NYS, BZ)
  289. values
  290. <foreach collection="entities" item="entity" separator=",">
  291. (#{entity.xmmc}, #{entity.xmid}, #{entity.bh}, #{entity.sqsm}, #{entity.sqje}, #{entity.fylb},
  292. #{entity.bbm}, #{entity.fj}, #{entity.shzt}, #{entity.nf}, #{entity.sqrxm}, #{entity.sqr}, #{entity.sqsj},
  293. #{entity.sqmc},
  294. #{entity.spzt}, #{entity.kyfyxx}, #{entity.bzje}, #{entity.bxpz}, #{entity.bzje2}, #{entity.sfbyj},
  295. #{entity.kybg}, #{entity.erpbh}, #{entity.xmlx}, #{entity.xmfzr}, #{entity.ssbm}, #{entity.sfbz},
  296. #{entity.smwj},
  297. #{entity.bhsje}, #{entity.sf}, ##{entity.nys}, #{entity.bz})
  298. </foreach>
  299. on duplicate key update
  300. XMMC = values(XMMC),
  301. XMID = values(XMID),
  302. BH = values(BH),
  303. SQSM = values(SQSM),
  304. SQJE = values(SQJE),
  305. FYLB = values(FYLB),
  306. BBM = values(BBM),
  307. FJ = values(FJ),
  308. SHZT = values(SHZT),
  309. NF = values(NF),
  310. SQR = values(SQR),
  311. SQRXM = values(SQRXM),
  312. SQSJ = values(SQSJ),
  313. SQMC = values(SQMC),
  314. SPZT = values(SPZT),
  315. KYFYXX = values(KYFYXX),
  316. BZJE = values(BZJE),
  317. BXPZ = values(BXPZ),
  318. BZJE2 = values(BZJE2),
  319. SFBYJ = values(SFBYJ),
  320. KYBG = values(KYBG),
  321. ERPBH = values(ERPBH),
  322. XMLX = values(XMLX),
  323. XMFZR = values(XMFZR),
  324. SSBM = values(SSBM),
  325. SFBZ = values(SFBZ),
  326. SMWJ = values(SMWJ),
  327. BHSJE = values(BHSJE),
  328. SF = values(SF),
  329. NYS = values(NYS),
  330. BZ = values(BZ)
  331. </insert>
  332. <!--通过主键修改基础数据-->
  333. <update id="update">
  334. update sta_BudgetApproval
  335. set SQJE = #{sqje}
  336. ,FJ = #{fj}
  337. ,BZ = #{bz}
  338. ,SQMC = #{sqmc}
  339. ,SQSM = #{sqsm}
  340. ,BZJE = #{bzje}
  341. ,BHSJE = #{bhsje}
  342. <if test="sfbz != null">
  343. ,SFBZ = #{sfbz}
  344. </if>
  345. ,SF = #{sf}
  346. where ID = #{id}
  347. </update>
  348. <update id="updatebmbg">
  349. update sta_BudgetApproval
  350. set SSBM = #{ssbm}
  351. where ID = #{id}
  352. </update>
  353. <!-- 修改方法-->
  354. <!--通过主键修改基础数据-->
  355. <update id="updateImprest">
  356. update sta_BudgetApproval
  357. set SQJE = #{sqje},
  358. SQSJ = #{sqsj},
  359. SQMC = #{sqmc},
  360. SQSM = #{sqsm}
  361. where ID = #{id}
  362. </update>
  363. <!-- 修改方法-->
  364. <!--备用金关联项目-->
  365. <update id="ImprestConnect">
  366. update sta_BudgetApproval
  367. set XMMC = #{xmmc},
  368. XMID = #{xmid},
  369. FYLB = #{fylb},
  370. FJ = #{fj},
  371. ERPBH = #{erpbh},
  372. XMLX = #{xmlx},
  373. XMFZR = #{xmfzr},
  374. SSBM = #{ssbm},
  375. NYS = #{nys},
  376. BZ = #{bz}
  377. where ID = #{id}
  378. </update>
  379. <!--通过主键修改其它数据-->
  380. <update id="updateOthers">
  381. update sta_BudgetApproval
  382. set ERPBH = #{erpbh},
  383. XMLX = #{xmlx},
  384. XMFZR = #{xmfzr},
  385. SSBM = #{ssbm}
  386. where ID = #{id}
  387. </update>
  388. <!--通过主键删除-->
  389. <delete id="deleteById">
  390. delete
  391. from sta_BudgetApproval
  392. where ID = #{id}
  393. </delete>
  394. <!--获取费用申请列表-->
  395. <select id="getFysqList" resultMap="StaBudgetapprovalMap" parameterType="map">
  396. SELECT
  397. b.*,
  398. t.XMLXMC,
  399. d.dept_name AS SSBMMC,
  400. g.FYMC AS FYLBMC,
  401. r.XM AS XMFZRXM,
  402. (
  403. SELECT
  404. STUFF(
  405. (
  406. SELECT
  407. ',' + XM
  408. FROM
  409. (
  410. SELECT
  411. xm
  412. FROM
  413. base_Person
  414. WHERE
  415. id IN (
  416. SELECT
  417. dkyfzrid
  418. FROM
  419. (
  420. SELECT DISTINCT
  421. zwmc,
  422. SUBSTRING ( dkyfzr, number, CHARINDEX( ',', dkyfzr + ',', number ) - number ) AS dkyfzrid
  423. FROM
  424. prj_Project WITH ( nolock ),
  425. master..spt_values WITH ( nolock )
  426. WHERE
  427. number >= 1
  428. AND len( DKYFZR ) > number
  429. AND SUBSTRING ( ',' + DKYFZR, number, 1 ) = ','
  430. AND ID = b.XMID
  431. ) t
  432. )
  433. ) B FOR xml path ( '' )
  434. ),
  435. 1,
  436. 1,
  437. ''
  438. )
  439. ) AS DKYFZRXM
  440. FROM
  441. sta_BudgetApproval b
  442. LEFT JOIN base_ProjectType t ON t.XMLX = b.XMLX
  443. LEFT JOIN prj_Project p ON p.ID = b.XMID
  444. LEFT JOIN sys_dept_info d ON d.dept_id = b.SSBM
  445. LEFT JOIN prj_AnnualBudgetDetail g ON g.ID = b.FYLB
  446. LEFT JOIN base_Person r ON r.ID = b.XMFZR
  447. LEFT JOIN sta_Reimbursement c ON c.FYSQ = b.ID
  448. WHERE
  449. 1=1
  450. <if test="bzid != null and bzid != ''">
  451. and b.SFBZ = #{bzid}
  452. </if>
  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="deptName!= null and deptName != ''">
  457. and(
  458. <if test="deptName !='电源技术中心'">
  459. d.dept_name = #{deptName}
  460. </if>
  461. <if test="deptName == '电源技术中心'">
  462. d.dept_name in (SELECT dept_name FROM sys_dept_info WHERE dept_name LIKE '%电源%')
  463. </if>
  464. )
  465. </if>
  466. <if test="sqmc != null and sqmc != ''">
  467. and b.SQMC like '%'+#{sqmc}+'%'
  468. </if>
  469. <if test="fylb != null and fylb != ''">
  470. and g.FYMC like '%'+#{fylb}+'%'
  471. </if>
  472. <if test="sqr != null and sqr != ''">
  473. and b.SQRXM like '%'+#{sqr}+'%'
  474. </if>
  475. <if test="sfbyj != null and sfbyj != ''">
  476. and b.SFBYJ = #{sfbyj}
  477. </if>
  478. <if test="spzt != null and spzt != ''">
  479. and b.SPZT = #{spzt}
  480. </if>
  481. <if test="bh != null and bh != ''">
  482. and b.BH like '%'+#{bh}+'%'
  483. </if>
  484. <if test="dkyfzr != null and dkyfzr != ''">
  485. and p.DKYFZR like '%'+#{dkyfzr}+'%'
  486. </if>
  487. <if test="ssbmmc != null and ssbmmc != ''">
  488. and d.dept_name like '%'+#{ssbmmc}+'%'
  489. </if>
  490. <if test="erpbh != null and erpbh != ''">
  491. and b.ERPBH like '%'+#{erpbh}+'%'
  492. </if>
  493. <if test="xmlx != null and xmlx != ''">
  494. and b.XMLX = #{xmlx}
  495. </if>
  496. <if test="nf != null and nf != ''">
  497. and b.NF = #{nf}
  498. </if>
  499. <if test="xmmc != null and xmmc != ''">
  500. and b.XMMC like '%'+#{xmmc}+'%'
  501. </if>
  502. <if test="id != null and id != ''">
  503. and b.ID = #{id}
  504. </if>
  505. <choose>
  506. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  507. order by ${sortName} ${sortOrder}
  508. </when>
  509. </choose>
  510. ORDER BY
  511. CASE
  512. WHEN b.SPZT = '部门主任审批' THEN 0
  513. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  514. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  515. WHEN b.SPZT = '主管院领导审批' THEN 3
  516. WHEN b.SPZT = '院长审批' THEN 4
  517. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  518. WHEN b.SPZT = '未提交' THEN 996
  519. WHEN b.SPZT = '未提交(返回)' THEN 997
  520. WHEN b.SPZT = '审批结束' THEN 998
  521. WHEN b.SPZT = '作废' THEN 999
  522. END
  523. ASC,
  524. SQSJ DESC
  525. </select>
  526. <!--获取备用金申请列表-->
  527. <select id="getByjsqList" resultMap="StaBudgetapprovalMap" parameterType="map">
  528. select b.*, g.FYMC as FYLBMC
  529. from sta_BudgetApproval b
  530. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  531. where b.SFBYJ = 1
  532. <if test="userId != null and userId != ''">
  533. and (b.SQR = #{userId} or #{userId} in (select SHR from prj_ApproveRecord where XMID = b.ID))
  534. </if>
  535. <if test="spzt != null and spzt != ''">
  536. and b.SPZT = #{spzt}
  537. </if>
  538. <if test="erpbh != null and erpbh != ''">
  539. and b.ERPBH like '%'+#{erpbh}+'%'
  540. </if>
  541. <if test="xmmc != null and xmmc != ''">
  542. and b.XMMC like '%'+#{xmmc}+'%'
  543. </if>
  544. <if test="bh != null and bh != ''">
  545. and b.BH like '%'+#{bh}+'%'
  546. </if>
  547. <if test="nf != null and nf != ''">
  548. and b.NF = #{nf}
  549. </if>
  550. <if test="sqmc != null and sqmc != ''">
  551. and b.sqmc like '%'+ #{sqmc}+'%'
  552. </if>
  553. <choose>
  554. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  555. order by ${sortName} ${sortOrder}
  556. </when>
  557. </choose>
  558. ORDER BY
  559. CASE
  560. WHEN b.SPZT = '部门主任审批' THEN 0
  561. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  562. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  563. WHEN b.SPZT = '主管院领导审批' THEN 3
  564. WHEN b.SPZT = '院长审批' THEN 4
  565. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  566. WHEN b.SPZT = '未提交' THEN 996
  567. WHEN b.SPZT = '未提交(返回)' THEN 997
  568. WHEN b.SPZT = '审批结束' THEN 998
  569. WHEN b.SPZT = '作废' THEN 999
  570. END ASC,
  571. SQSJ DESC
  572. </select>
  573. <!--获取年份-->
  574. <select id="getYearList" resultMap="StaBudgetapprovalMap">
  575. select distinct NF
  576. from sta_BudgetApproval
  577. where NF is not NULL
  578. ORDER BY NF DESC
  579. </select>
  580. <!--获取项目类型-->
  581. <select id="getXmlx" resultMap="StaBudgetapprovalMap">
  582. select
  583. b.FYMC
  584. from prj_AnnualBudgetDetail b
  585. where NYS = 355
  586. and BM not in (
  587. select distinct FJ
  588. from prj_AnnualBudgetDetail
  589. where FJ != '' AND NYS=355
  590. )
  591. </select>
  592. <!--获取已报账费用申请列表-->
  593. <select id="getYbzFysqList" resultMap="StaBudgetapprovalMap" parameterType="map">
  594. select b.*, t.XMLXMC, d.dept_name as SSBMMC, g.FYMC as FYLBMC,r.SL,r.SPZT as RSPZT,
  595. (SELECT STUFF((SELECT ','+XM from (select xm from base_Person
  596. where id in (select dkyfzrid from
  597. (select DISTINCT zwmc,SUBSTRING(dkyfzr, number,CHARINDEX(',',dkyfzr+',',number)-number) as dkyfzrid
  598. from prj_Project WITH(nolock) ,master..spt_values with(nolock) where number >= 1 and len(DKYFZR) > number
  599. and SUBSTRING(','+DKYFZR,number,1)=',' and ID = b.XMID) t)) B for xml path('')),1,1,'')) as DKYFZRXM
  600. from sta_BudgetApproval b
  601. left join base_ProjectType t on t.XMLX = b.XMLX
  602. left join prj_Project p on p.ID = b.XMID
  603. left join sys_dept_info d on d.dept_id = b.SSBM
  604. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  605. left join sta_Reimbursement r on r.FYSQ = b.ID
  606. where b.SFBZ = 1
  607. -- and r.spzt = '审批结束'
  608. <if test="userId != null and userId != ''">
  609. and (b.SQR = #{userId} or #{userId} in (select SHR from prj_ApproveRecord where XMID = b.ID))
  610. </if>
  611. <if test="sqmc != null and sqmc != ''">
  612. and b.SQMC like '%'+#{sqmc}+'%'
  613. </if>
  614. <if test="erpbh != null and erpbh != ''">
  615. and b.ERPBH like '%'+#{erpbh}+'%'
  616. </if>
  617. <if test="bh != null and bh != ''">
  618. and b.BH like '%'+#{bh}+'%'
  619. </if>
  620. <if test="xmlx != null and xmlx != ''">
  621. and b.XMLX = #{xmlx}
  622. </if>
  623. <if test="dkyfzr != null and dkyfzr != ''">
  624. and p.DKYFZR like '%'+#{dkyfzr}+'%'
  625. </if>
  626. <!-- <if test="ssbmmc != null and ssbmmc != ''">-->
  627. <!-- and d.dept_name like '%'+#{ssbmmc}+'%'-->
  628. <!-- </if>-->
  629. <if test="ssbmmc!= null and ssbmmc != ''">
  630. and(
  631. <if test="ssbmmc !='电源技术中心'">
  632. d.dept_name = #{ssbmmc}
  633. </if>
  634. <if test="ssbmmc == '电源技术中心'">
  635. d.dept_name in (SELECT dept_name FROM sys_dept_info WHERE dept_name LIKE '%电源%')
  636. </if>
  637. )
  638. </if>
  639. <if test="nf != null and nf != ''">
  640. and b.NF = #{nf}
  641. </if>
  642. <if test="sfbyj != null and sfbyj != ''">
  643. and b.SFBYJ = #{sfbyj}
  644. </if>
  645. <if test="xmmc != null and xmmc != ''">
  646. and b.XMMC like '%'+#{xmmc}+'%'
  647. </if>
  648. <choose>
  649. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  650. order by ${sortName} ${sortOrder}
  651. </when>
  652. </choose>
  653. ORDER BY
  654. CASE
  655. WHEN r.SPZT = '部门主任审批' THEN 0
  656. WHEN r.SPZT = '科技项目管理专责审批' THEN 1
  657. WHEN r.SPZT = '科技部部门主任审批' THEN 2
  658. WHEN r.SPZT = '主管院领导审批' THEN 3
  659. WHEN r.SPZT = '院长审批' THEN 4
  660. WHEN r.SPZT = '科技项目管理专责确认' THEN 5
  661. WHEN r.SPZT = '未提交' THEN 996
  662. WHEN r.SPZT = '未提交(返回)' THEN 997
  663. WHEN r.SPZT = '审批结束' THEN 998
  664. WHEN r.SPZT = '作废' THEN 999
  665. END
  666. ASC,
  667. CJSJ DESC
  668. </select>
  669. <!--获取全部费用申请(审批完成)-->
  670. <select id="getAllApplyList" resultMap="StaBudgetapprovalMap" parameterType="map">
  671. SELECT
  672. c.ID AS BZID,
  673. b.*,
  674. t.XMLXMC,
  675. d.dept_name AS SSBMMC,
  676. g.FYMC AS FYLBMC,
  677. r.XM AS XMFZRXM,
  678. CASE
  679. WHEN b.SFBYJ = 1 THEN
  680. '是' ELSE '否'
  681. END AS SFBYJMC,
  682. CASE
  683. WHEN b.SFBZ = 1 THEN
  684. '是' ELSE '否'
  685. END AS SFBZMC,
  686. (
  687. SELECT
  688. STUFF(
  689. (
  690. SELECT
  691. ',' + XM
  692. FROM
  693. (
  694. SELECT
  695. xm
  696. FROM
  697. base_Person
  698. WHERE
  699. id IN (
  700. SELECT
  701. dkyfzrid
  702. FROM
  703. (
  704. SELECT DISTINCT
  705. zwmc,
  706. SUBSTRING ( dkyfzr, number, CHARINDEX( ',', dkyfzr + ',', number ) - number ) AS dkyfzrid
  707. FROM
  708. prj_Project WITH ( nolock ),
  709. master..spt_values WITH ( nolock )
  710. WHERE
  711. number >= 1
  712. AND len( DKYFZR ) > number
  713. AND SUBSTRING ( ',' + DKYFZR, number, 1 ) = ','
  714. AND ID = b.XMID
  715. ) t
  716. )
  717. ) B FOR xml path ( '' )
  718. ),
  719. 1,
  720. 1,
  721. ''
  722. )
  723. ) AS DKYFZRXM
  724. FROM
  725. sta_BudgetApproval b
  726. LEFT JOIN base_ProjectType t ON t.XMLX = b.XMLX
  727. LEFT JOIN prj_Project p ON p.ID = b.XMID
  728. LEFT JOIN sys_dept_info d ON d.dept_id = b.SSBM
  729. LEFT JOIN prj_AnnualBudgetDetail g ON g.ID = b.FYLB
  730. LEFT JOIN base_Person r ON r.ID = b.XMFZR
  731. LEFT JOIN sta_Reimbursement c ON b.ID = c.FYSQ
  732. WHERE
  733. 1 = 1
  734. <if test="bh != null and bh != ''">
  735. and b.BH like '%'+#{bh}+'%'
  736. </if>
  737. <if test="erpbh != null and erpbh != ''">
  738. and b.ERPBH like '%'+#{erpbh}+'%'
  739. </if>
  740. <if test="xmlx != null and xmlx != ''">
  741. and b.XMLX = #{xmlx}
  742. </if>
  743. <if test="sfbyj != null and sfbyj != ''">
  744. and b.SFBYJ = #{sfbyj}
  745. </if>
  746. <if test="xmmc != null and xmmc != ''">
  747. and b.XMMC like '%'+#{xmmc}+'%'
  748. </if>
  749. <if test="fylb != null and fylb != ''">
  750. and g.FYMC like '%'+#{fylb}+'%'
  751. </if>
  752. <if test="sqr != null and sqr != ''">
  753. and b.sqrxm like '%'+#{sqr}+'%'
  754. </if>
  755. <if test="ssbmmc != null and ssbmmc != ''">
  756. and d.dept_name like '%'+#{ssbmmc}+'%'
  757. </if>
  758. <if test="nf != null and nf != ''">
  759. and b.NF = #{nf}
  760. </if>
  761. <if test="spzt != null and spzt != ''">
  762. and b.SPZT = #{spzt}
  763. </if>
  764. <if test="sfth != null and sfth != ''">
  765. and b.SFTH = #{sfth}
  766. </if>
  767. <if test="sfbz != null and sfbz != ''">
  768. and b.SFBZ = #{sfbz}
  769. </if>
  770. <if test="dkyfzr != null and dkyfzr != ''">
  771. and p.DKYFZR like '%'+#{dkyfzr}+'%'
  772. </if>
  773. <if test="sqsj1 != null and sqsj1 != ''">
  774. and b.SQSJ >= #{sqsj1}
  775. </if>
  776. <if test="sqsj2 != null and sqsj2 != ''">
  777. and DATEADD(day, 1, #{sqsj2}) >= b.SQSJ
  778. </if>
  779. <choose>
  780. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  781. order by ${sortName} ${sortOrder}
  782. </when>
  783. </choose>
  784. ORDER BY
  785. CASE
  786. WHEN b.SPZT = '部门主任审批' THEN 0
  787. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  788. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  789. WHEN b.SPZT = '主管院领导审批' THEN 3
  790. WHEN b.SPZT = '院长审批' THEN 4
  791. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  792. WHEN b.SPZT = '未提交' THEN 996
  793. WHEN b.SPZT = '未提交(返回)' THEN 997
  794. WHEN b.SPZT = '审批结束' THEN 998
  795. WHEN b.SPZT = '作废' THEN 999
  796. END
  797. ASC,
  798. b.SQSJ DESC
  799. </select>
  800. <!--获取审批中的费用申请-->
  801. <select id="getApprovingList" resultMap="StaBudgetapprovalMap" parameterType="map">
  802. select b.*, t.XMLXMC, d.dept_name as SSBMMC, g.FYMC as FYLBMC, r.XM as XMFZRXM,
  803. case when b.SFBYJ = 1 then '是' else '否' end as SFBYJMC, case when b.SFBZ = 1 then '是' else '否' end as SFBZMC,
  804. (SELECT STUFF((SELECT ','+XM from (select xm from base_Person
  805. where id in (select dkyfzrid from
  806. (select DISTINCT zwmc,SUBSTRING(dkyfzr, number,CHARINDEX(',',dkyfzr+',',number)-number) as dkyfzrid
  807. from prj_Project WITH(nolock) ,master..spt_values with(nolock) where number >= 1 and len(DKYFZR) > number
  808. and SUBSTRING(','+DKYFZR,number,1)=',' and ID = b.XMID) t)) B for xml path('')),1,1,'')) as DKYFZRXM
  809. from sta_BudgetApproval b
  810. left join base_ProjectType t on t.XMLX = b.XMLX
  811. left join prj_Project p on p.ID = b.XMID
  812. left join sys_dept_info d on d.dept_id = b.SSBM
  813. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  814. left join base_Person r on r.ID = b.XMFZR
  815. where b.SPZT != '未提交' and b.SPZT != '审批结束' and b.SPZT != '作废' and b.SFBYJ = 0
  816. <if test="spzt != null and spzt != ''">
  817. and b.SPZT = #{spzt}
  818. </if>
  819. <if test="bh != null and bh != ''">
  820. and b.BH like '%'+#{bh}+'%'
  821. </if>
  822. <if test="nf != null and nf != ''">
  823. and b.NF = #{nf}
  824. </if>
  825. <if test="sfbyj != null and sfbyj != ''">
  826. and b.SFBYJ = #{sfbyj}
  827. </if>
  828. <if test="xmmc != null and xmmc != ''">
  829. and b.XMMC like '%'+#{xmmc}+'%'
  830. </if>
  831. <if test="erpbh != null and erpbh != ''">
  832. and b.ERPBH like '%'+#{erpbh}+'%'
  833. </if>
  834. <if test="xmlx != null and xmlx != ''">
  835. and b.XMLX = #{xmlx}
  836. </if>
  837. <if test="ssbmmc != null and ssbmmc != ''">
  838. and d.dept_name like '%'+#{ssbmmc}+'%'
  839. </if>
  840. <choose>
  841. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  842. order by ${sortName} ${sortOrder}
  843. </when>
  844. </choose>
  845. ORDER BY
  846. CASE
  847. WHEN b.SPZT = '部门主任审批' THEN 0
  848. WHEN b.SPZT = '科技项目管理专责审批' THEN 1
  849. WHEN b.SPZT = '科技部部门主任审批' THEN 2
  850. WHEN b.SPZT = '主管院领导审批' THEN 3
  851. WHEN b.SPZT = '院长审批' THEN 4
  852. WHEN b.SPZT = '科技项目管理专责确认' THEN 5
  853. END
  854. ASC,
  855. b.SQSJ DESC
  856. </select>
  857. <!--批量删除费用申请-->
  858. <delete id="batchDelete" parameterType="java.util.ArrayList">
  859. delete from sta_BudgetApproval
  860. where ID in
  861. <foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
  862. #{item}
  863. </foreach>
  864. </delete>
  865. <!--撤销审核状态费用申请-->
  866. <update id="tjrevokeApprove">
  867. update sta_BudgetApproval
  868. set SPZT = '未提交'
  869. where ID = #{id}
  870. </update>
  871. <!--通过主键修改审批状态-->
  872. <update id="updateSpzt">
  873. update sta_BudgetApproval
  874. <set>
  875. SPZT = #{spzt},
  876. BH=#{bh},
  877. <if test="spzt == '未提交(返回)'">
  878. SFTH = 1,
  879. </if>
  880. <if test="spzt == '审批结束'">
  881. SFTH = 0,
  882. </if>
  883. </set>
  884. where ID = #{id}
  885. </update>
  886. <!--获取费用申请信息-->
  887. <select id="getFysqById" resultMap="StaBudgetapprovalMap">
  888. select b.*,
  889. t.XMLXMC,
  890. d.dept_name as SSBMMC,
  891. g.FYMC as FYLBMC,
  892. r.XM as XMFZRXM,
  893. (select MC from base_ProjectBudget g1 where g1.BM = g.FJ) as FJMC,
  894. case when b.SFBYJ = 1 then '是' else '否' end as SFBYJMC,
  895. case when b.SFBZ = 1 then '是' else '否' end as SFBZMC,
  896. (SELECT STUFF((SELECT ',' + XM
  897. from (select xm
  898. from base_Person
  899. where id in (select dkyfzrid
  900. from (select DISTINCT zwmc,
  901. SUBSTRING(dkyfzr, number,
  902. CHARINDEX(',', dkyfzr + ',', number) -
  903. number) as dkyfzrid
  904. from prj_Project WITH(nolock) ,master..spt_values
  905. with (nolock)
  906. where number >= 1
  907. and len(DKYFZR)
  908. > number
  909. and SUBSTRING (','+DKYFZR
  910. , number
  911. , 1)=','
  912. and ID = b.XMID) t)) B for xml path ('')),1,1,'')) as DKYFZRXM
  913. from sta_BudgetApproval b
  914. left join base_ProjectType t on t.XMLX = b.XMLX
  915. left join prj_Project p on p.ID = b.XMID
  916. left join sys_dept_info d on d.dept_id = b.SSBM
  917. left join prj_AnnualBudgetDetail g on g.ID = b.FYLB
  918. left join base_Person r on r.ID = b.XMFZR
  919. where b.ID = #{id}
  920. </select>
  921. <!--获取费用管理列表-->
  922. <select id="getFyglList" resultMap="StaBudgetapprovalMap" parameterType="map">
  923. select b.*, t.XMLXMC, d.dept_name as SSBMMC, r.XM as XMFZRXM
  924. from sta_BudgetApproval b
  925. left join base_ProjectType t on t.XMLX = b.XMLX
  926. left join prj_Project p on p.ID = b.XMID
  927. left join sys_dept_info d on d.dept_id = b.SSBM
  928. left join base_Person r on r.ID = b.XMFZR
  929. where 1 = 1
  930. <if test="xmmc != null and xmmc != ''">
  931. and b.XMMC like '%'+#{xmmc}+'%'
  932. </if>
  933. <if test="erpbh != null and erpbh != ''">
  934. and b.ERPBH like '%'+#{erpbh}+'%'
  935. </if>
  936. <if test="xmlx != null and xmlx != ''">
  937. and b.XMLX = #{xmlx}
  938. </if>
  939. <if test="xmfzrxm != null and xmfzrxm != ''">
  940. and r.XM like '%'+#{xmfzrxm}+'%'
  941. </if>
  942. <if test="ssbmmc != null and ssbmmc != ''">
  943. and d.dept_name like '%'+#{ssbm}+'%'
  944. </if>
  945. <choose>
  946. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  947. order by ${sortName} ${sortOrder}
  948. </when>
  949. </choose>
  950. </select>
  951. <!--更新报账数据-->
  952. <update id="updateReimburse">
  953. update sta_BudgetApproval
  954. set SFBZ = 1,
  955. BXPZ = #{bxpz},
  956. BZJE = #{bzje},
  957. BHSJE = #{bhsje},
  958. SF = #{sf}
  959. where ID = #{id}
  960. </update>
  961. <!--批量修改报账信息-->
  962. <update id="clearReimburse">
  963. update sta_BudgetApproval
  964. set SFBZ = 0,
  965. BXPZ = null,
  966. BZJE = null,
  967. BHSJE = null,
  968. SF = null
  969. where ID in
  970. <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
  971. #{item}
  972. </foreach>
  973. </update>
  974. <update id="updateBatchBh">
  975. <foreach collection="entities" item="entity" separator=";">
  976. update sta_BudgetApproval
  977. set
  978. BH=#{entity.bh}
  979. where
  980. id = #{entity.id}
  981. </foreach>
  982. </update>
  983. <update id="updateSfbz">
  984. update sta_BudgetApproval
  985. set
  986. SFBZ= 0
  987. where
  988. id = #{fysq}
  989. </update>
  990. <!--批量作废费用申请-->
  991. <delete id="batchNullify" parameterType="java.util.ArrayList">
  992. update sta_BudgetApproval
  993. set SPZT = '作废'
  994. where ID in
  995. <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
  996. #{item}
  997. </foreach>
  998. </delete>
  999. <!--项目总体费用信息-->
  1000. <select id="getXmFyInfo" resultMap="StaBudgetapprovalMap">
  1001. 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,
  1002. SUM(b.BZJE) as BZJE,
  1003. (select YSJE from prj_AnnualBudgetDetail where NYS = b.NYS and FJ = '') as YSJE
  1004. from sta_BudgetApproval b
  1005. where b.NYS = #{nys} and b.SPZT != '作废' and b.SFBYJ =0
  1006. GROUP BY b.NYS
  1007. </select>
  1008. <!--项目分项费用信息-->
  1009. <select id="getKmFyInfo" resultMap="StaBudgetapprovalMap" parameterType="map">
  1010. select b.NYS, b.FYLB,
  1011. ISNULL((select SUM(SQJE) from sta_BudgetApproval where NYS = #{nys} and FYLB = #{fylb} and SPZT != '作废' and SFBYJ = 0),0) as SQJE,
  1012. (select
  1013. SUM(sr.bzje)
  1014. from
  1015. sta_Reimbursement sr
  1016. left join sta_BudgetApproval sb on sr.fysq = sb.id
  1017. where
  1018. sb.NYS = #{nys}
  1019. and sb.FYLB = #{fylb}
  1020. and sb.SPZT != '作废'
  1021. and sb.SFBYJ = 0
  1022. and sr.spzt = '审批结束') as BZJE,
  1023. (select
  1024. SUM(COALESCE(sr.bzje, 0))
  1025. from
  1026. sta_Reimbursement sr
  1027. left join sta_BudgetApproval sb on sr.fysq = sb.id
  1028. where
  1029. sb.NYS = #{nys}
  1030. and sb.FYLB = #{fylb}
  1031. and sb.SPZT != '作废'
  1032. and sb.SFBYJ = 0
  1033. and sr.spzt != '审批结束'
  1034. and sr.spzt != '作废'
  1035. ) as BZZJE,
  1036. (select YSJE from prj_AnnualBudgetDetail where NYS = b.NYS and ID = b.FYLB) as YSJE,
  1037. (SELECT
  1038. sum(ISNULL(sr.BZJE ,sb.SQJE))
  1039. from
  1040. sta_BudgetApproval sb
  1041. left join sta_Reimbursement sr on sr.fysq = sb.id and sr.SPZT = '审批结束'
  1042. where
  1043. sb.NYS = #{nys}
  1044. and sb.fylb = #{fylb}
  1045. and sb.spzt != '作废'
  1046. and sb.SFBYJ = 0
  1047. ) xmndjfysq
  1048. from sta_BudgetApproval b
  1049. where b.NYS = #{nys} and b.FYLB = #{fylb} and b.SPZT != '作废' and b.SFBYJ =0
  1050. GROUP BY b.NYS, b.FYLB
  1051. </select>
  1052. <select id="getSqjes" resultMap="StaBudgetapprovalMap">
  1053. select
  1054. ISNULL(sum(SQJE),0) AS SQJE,
  1055. ISNULL(sum(BZJE),0) AS BZJE
  1056. FROM sta_BudgetApproval
  1057. where SPZT != '作废'
  1058. <if test="nys != null and nys != ''">
  1059. and NYS = #{nys}
  1060. </if>
  1061. </select>
  1062. <!--未关联项目备用金 -->
  1063. <select id="unassociated" resultMap="StaBudgetapprovalMap" parameterType="map">
  1064. SELECT * FROM sta_BudgetApproval
  1065. WHERE
  1066. SFBYJ = 1
  1067. AND XMMC IS NULL
  1068. AND SPZT='审批结束'
  1069. <if test="xmmc != null and xmmc != ''">
  1070. and XMMC like '%'+#{xmmc}+'%'
  1071. </if>
  1072. <if test="bh != null and bh != ''">
  1073. and BH like '%'+#{bh}+'%'
  1074. </if>
  1075. <if test="nf != null and nf != ''">
  1076. and NF = #{nf}
  1077. </if>
  1078. </select>
  1079. <!--项目备用金信息-->
  1080. <select id="getByjInfo" resultMap="StaBudgetapprovalMap">
  1081. 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,
  1082. SUM(b.BZJE) as BZJE,
  1083. (select YSJE from prj_AnnualBudgetDetail where NYS = b.NYS and FJ = '') as YSJE
  1084. from sta_BudgetApproval b
  1085. where b.NYS = #{nys} and b.SPZT != '作废' and b.SFBYJ =1
  1086. GROUP BY b.NYS
  1087. </select>
  1088. <select id="getBhById" resultType="java.lang.String">
  1089. SELECT BH FROM sta_BudgetApproval where ID = #{id}
  1090. </select>
  1091. <select id="listSPJS" resultType="com.liang.entity.StaBudgetapproval">
  1092. SELECT
  1093. *
  1094. from sta_BudgetApproval sba
  1095. where
  1096. sba.SPZT = '审批结束'
  1097. and sba.BH = ''
  1098. </select>
  1099. <select id="getBayID" resultMap="StaBudgetapprovalMap">
  1100. SELECT * FROM sta_BudgetApproval where ID = #{id}
  1101. </select>
  1102. <select id="getSqje" resultMap="StaBudgetapprovalMap" resultType="hashmap">
  1103. SELECT COALESCE(SUM(SQJE), 0.00) AS SQJE
  1104. FROM sta_BudgetApproval
  1105. WHERE
  1106. SFBYJ = 1
  1107. and SPZT != '作废'
  1108. <if test="nf != null and nf != ''">
  1109. and NF = #{nf}
  1110. </if>
  1111. <if test="erpbh != null and erpbh != ''">
  1112. and ERPBH = #{erpbh}
  1113. </if>
  1114. </select>
  1115. <select id="getId" resultMap="StaBudgetapprovalMap">
  1116. select * from sta_BudgetApproval
  1117. <where>
  1118. <if test="id != null and id != ''">
  1119. ID = #{id}
  1120. </if>
  1121. </where>
  1122. </select>
  1123. <select id="getZbzje" resultType="com.liang.entity.StaBudgetapproval">
  1124. SELECT
  1125. (SELECT XMZYS * 10000 FROM prj_AnnualBudgetDetail WHERE FJ = '' AND NYS = #{nys}) AS XMZYS,
  1126. (SELECT BYJ * 10000 FROM prj_AnnualBudgetDetail WHERE FJ = '' AND NYS = #{nys}) AS BYJ,
  1127. (SELECT XMZ * 10000 FROM prj_AnnualBudgetDetail WHERE ID = #{fylb} AND NYS = #{nys}) AS KMZYS,
  1128. (select
  1129. SUM(sr.bzje)
  1130. from
  1131. sta_Reimbursement sr
  1132. left join sta_BudgetApproval sb on sr.fysq = sb.id
  1133. where
  1134. sb.NYS = #{nys}
  1135. and sb.SPZT != '作废'
  1136. and sr.spzt != '作废') AS ZBZJE,
  1137. (select
  1138. SUM(sr.bzje)
  1139. from
  1140. sta_Reimbursement sr
  1141. left join sta_BudgetApproval sb on sr.fysq = sb.id
  1142. where
  1143. sb.NYS = #{nys}
  1144. and sb.SPZT != '作废'
  1145. and sb.SFBYJ = 1
  1146. and sr.spzt != '作废' ) AS BYJBZZE,
  1147. (select
  1148. SUM(sr.bzje)
  1149. from
  1150. sta_Reimbursement sr
  1151. left join sta_BudgetApproval sb on sr.fysq = sb.id
  1152. where
  1153. sb.NYS = #{nys}
  1154. and sb.FYLB = #{fylb}
  1155. and sb.SPZT != '作废'
  1156. and sb.SFBYJ = 0
  1157. and sr.spzt != '作废') as KMYBZJE
  1158. </select>
  1159. <!-- <select id="getxmndjfysq" resultMap="StaBudgetapprovalMap">
  1160. select ISNULL(SUM(BZJE), 0.00) AS SQJE FROM sta_BudgetApproval
  1161. where spzt = '审批结束'
  1162. and SFBYJ = 0
  1163. and SFBZ = 1
  1164. <if test="xmid != null and xmid != ''">
  1165. </if>
  1166. <if test="nf != null and nf != ''">
  1167. </if>
  1168. </select>-->
  1169. <!-- 获取费用小项的当年申请总金额 不包含备用金 -->
  1170. <select id="getSqfyze" resultMap="StaBudgetapprovalMap" resultType="hashmap">
  1171. select COALESCE(SUM(SQJE),0.00)AS SQJE
  1172. from sta_BudgetApproval a
  1173. LEFT JOIN prj_AnnualBudgetDetail b ON a.FYLB = b.ID
  1174. WHERE
  1175. a.SPZT != '作废'
  1176. AND a.SFBYJ = 0
  1177. <if test="nys != null and nys != ''">
  1178. AND a.NYS = #{nys}
  1179. </if>
  1180. <if test="fymc != null and fymc != ''">
  1181. AND b.FYMC = #{fymc}
  1182. </if>
  1183. </select>
  1184. <!-- 获取备用金小项 申请金额 -->
  1185. <select id="getByjze" resultMap="StaBudgetapprovalMap" resultType="hashmap">
  1186. select COALESCE(SUM(SQJE),0.00)AS SQJE,COALESCE(SUM (BZJE),0.00)AS BZJE
  1187. from sta_BudgetApproval a
  1188. LEFT JOIN prj_AnnualBudgetDetail b ON a.FYLB = b.ID
  1189. WHERE
  1190. a.SPZT != '作废'
  1191. AND a.SFBYJ = 1
  1192. <if test="nys != null and nys != ''">
  1193. AND a.NYS = #{nys}
  1194. </if>
  1195. <if test="fymc != null and fymc != ''">
  1196. AND b.FYMC = #{fymc}
  1197. </if>
  1198. </select>
  1199. <select id="getFyzz" resultType="com.liang.entity.StaBudgetapproval">
  1200. SELECT
  1201. COALESCE (
  1202. SUM(CASE
  1203. WHEN a.SFBZ = 0 THEN a.SQJE
  1204. ELSE a.BZJE
  1205. END ),0.00
  1206. ) AS xmndjfysq
  1207. FROM sta_BudgetApproval a
  1208. LEFT JOIN prj_AnnualBudgetDetail b ON a.FYLB = b.ID
  1209. WHERE
  1210. a.SFBYJ = 0
  1211. AND
  1212. a.SPZT != '作废'
  1213. <if test="nys != null and nys != ''">
  1214. AND
  1215. a.NYS = #{nys}
  1216. </if>
  1217. <if test="fymc != null and fymc != ''">
  1218. AND b.FYMC = #{fymc}
  1219. </if>
  1220. </select>
  1221. <select id="getByjzje" resultType="com.liang.entity.PrjAnnualbudgetdetail">
  1222. select * from
  1223. prj_AnnualBudgetDetail
  1224. where FYMC = '总计'
  1225. <if test="nys != null and nys != ''">
  1226. and NYS = #{nys}
  1227. </if>
  1228. </select>
  1229. <select id="getSqe" resultType="com.liang.entity.StaBudgetapproval">
  1230. SELECT COALESCE
  1231. ( SUM ( CASE WHEN a.SFBZ = 0 THEN a.SQJE ELSE a.BZJE END ), 0.00 ) AS SQJE
  1232. FROM
  1233. sta_BudgetApproval a
  1234. LEFT JOIN prj_AnnualBudgetDetail b ON a.FYLB = b.ID
  1235. WHERE
  1236. a.SPZT != '作废'
  1237. <if test="nys != null and nys !=''">
  1238. AND a.NYS = #{nys}
  1239. </if>
  1240. <if test="fymc != null and fymc != ''">
  1241. AND b.FYMC = #{fymc}
  1242. </if>
  1243. </select>
  1244. <select id="getFylb" resultType="com.liang.entity.StaBudgetapproval">
  1245. SELECT
  1246. a.ID,
  1247. a.NYS,
  1248. a.XMMC,
  1249. a.BZJE,
  1250. C.FYMC
  1251. FROM
  1252. sta_BudgetApproval a
  1253. LEFT JOIN
  1254. prj_AnnualBudget b ON b.ID = a.NYS AND b.SPZT = '审批结束'
  1255. LEFT JOIN
  1256. prj_AnnualBudgetDetail c ON c.ID = a.FYLB
  1257. WHERE
  1258. a.SPZT = '审批结束'
  1259. AND a.SFBZ = 1
  1260. <if test="nys != null and nys != ''">
  1261. AND a.NYS = #{nys}
  1262. </if>
  1263. <if test="fymc != null and fymc != ''">
  1264. AND c.FYMC LIKE '%'+#{fymc}+'%'
  1265. </if>
  1266. </select>
  1267. </mapper>