UseMoneyMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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.zjugis.business.flow.usemoney.dao.UseMoneyDao">
  4. <select id="getUseMoneyEarnestPage"
  5. resultType="com.zjugis.business.flow.usemoney.controller.vo.UseMoneyEarnestRespVO">
  6. SELECT
  7. T2.ID,
  8. T2.instance_id,
  9. T2.PROJECT_ID,
  10. T2.APPLY_TIME,
  11. to_char(T2.COLLECTION_COMPANY) as COLLECTION_COMPANY,
  12. T2.USER_NICKNAME,
  13. T2.DEPT_NAME,
  14. T2.PAYMENT_COMPANY_ID,
  15. T1.AMOUNT,
  16. to_char(T1.REMARK) REMARK,
  17. T1.WRITE_OFF_AMOUNT,
  18. T1.I_WRITE_OFF,
  19. T1.WRITE_OFF_TIME,
  20. T1.COST_TYPE,
  21. T1.ID as detailId,
  22. case when T2.PROJECT_ID is not null then T3.XMMC else T4.XMMC end as XMMC,
  23. 'usemonvy' as type
  24. FROM
  25. WF_USE_MONEY_DETAIL T1
  26. LEFT JOIN WF_USE_MONEY T2 ON T1.USE_MONEY_ID = T2.ID
  27. LEFT JOIN PROJECT T3 ON T2.PROJECT_ID=T3.ID
  28. LEFT JOIN project T4 ON T1.PROJECT_ID=T4.ID
  29. <where>
  30. T1.COST_TYPE LIKE '14%' and (T2.FLOW_STATUS=90)
  31. <if test="params != null and params.collectionCompany != null and params.collectionCompany != ''">
  32. <bind name="collectionCompany" value="'%'+params.collectionCompany+'%'"/>
  33. AND T2.COLLECTION_COMPANY like #{collectionCompany}
  34. </if>
  35. <if test="params != null and params.REMARK != null and params.REMARK != ''">
  36. <bind name="REMARK" value="'%'+params.REMARK+'%'"/>
  37. AND T1.REMARK like #{REMARK}
  38. </if>
  39. <!-- <if test="params != null and params.costType != null and params.costType != ''">-->
  40. <!-- AND T1.COST_TYPE in (#{params.costType})-->
  41. <!-- </if>-->
  42. <if test="params != null and params.costTypeList != null and params.costTypeList.size > 0">
  43. AND T1.COST_TYPE in
  44. <foreach collection="params.costTypeList" item="item" open="(" close=")" separator=",">
  45. #{item}
  46. </foreach>
  47. </if>
  48. <if test="params != null and params.useMoneyNo != null and params.useMoneyNo != ''">
  49. AND T2.USE_MONEY_NO = #{params.useMoneyNo}
  50. </if>
  51. <if test="params != null and params.totalAmount != null and params.totalAmount != ''">
  52. AND T2.TOTAL_AMOUNT = #{params.totalAmount}
  53. </if>
  54. <if test="params != null and params.status != null and params.status != ''">
  55. AND T1.I_WRITE_OFF = #{params.status}
  56. </if>
  57. <if test="params != null and params.userId != null and params.userId != ''">
  58. AND T2.USER_ID = #{params.userId}
  59. </if>
  60. <if test="params != null and params.applyOn != null ">
  61. AND T2.APPLY_TIME &gt;= #{params.applyOn}
  62. </if>
  63. <if test="params != null and params.applyOff != null ">
  64. AND T2.APPLY_TIME &lt;= #{params.applyOff}
  65. </if>
  66. <if test="params != null and params.writeOn != null ">
  67. AND T1.WRITE_OFF_TIME &gt;= #{params.writeOn}
  68. </if>
  69. <if test="params != null and params.writeOff != null ">
  70. AND T1.WRITE_OFF_TIME &lt;= #{params.writeOff}
  71. </if>
  72. <if test="params != null and params.DeptList != null and params.DeptList.size > 0">
  73. AND T3.ZRBM_ID in
  74. <foreach collection="params.DeptList" item="item" open="(" close=")" separator=",">
  75. #{item}
  76. </foreach>
  77. </if>
  78. <if test="params != null and params.UserDeptList != null and params.UserDeptList.size > 0">
  79. AND T2.DEPT_ID in
  80. <foreach collection="params.UserDeptList" item="item" open="(" close=")" separator=",">
  81. #{item}
  82. </foreach>
  83. </if>
  84. </where>
  85. union
  86. SELECT
  87. T2.ID,
  88. T2.instance_id,
  89. T2.PROJECT_ID,
  90. T2.APPLY_TIME,
  91. '' as COLLECTION_COMPANY,
  92. T2.USER_NICKNAME,
  93. T2.DEPT_NAME,
  94. T2.PAYMENT_COMPANY_ID,
  95. T1.AMOUNT,
  96. to_char(T1.BZ1) AS REMARK,
  97. T1.WRITE_OFF_AMOUNT,
  98. T1.I_WRITE_OFF,
  99. T1.WRITE_OFF_TIME,
  100. T1.COST_TYPE,
  101. T1.ID as detailId,
  102. T3.XMMC,
  103. 'cost' as type
  104. FROM
  105. WF_COMMON_COST_DETAIL T1
  106. LEFT JOIN WF_COMMON_COST T2 ON T1.COMMON_COST_ID = T2.ID
  107. LEFT JOIN PROJECT T3 ON T1.PROJECT_ID=T3.ID
  108. <where>
  109. T1.COST_TYPE LIKE '14%' and (T2.FLOW_STATUS=90 or T2.FLOW_STATUS=89) AND T2.ISVALID = 1 and T1.ISVALID = 1
  110. <if test="params != null and params.collectionCompany != null and params.collectionCompany != ''">
  111. <bind name="collectionCompany" value="'%'+params.collectionCompany+'%'"/>
  112. AND T2.ID IS NULL
  113. </if>
  114. <if test="params != null and params.REMARK != null and params.REMARK != ''">
  115. <bind name="REMARK" value="'%'+params.REMARK+'%'"/>
  116. AND T1.BZ1 like #{REMARK}
  117. </if>
  118. <!-- <if test="params != null and params.costType != null and params.costType != ''">-->
  119. <!-- AND T1.COST_TYPE in (#{params.costType})-->
  120. <!-- </if>-->
  121. <if test="params != null and params.costTypeList != null and params.costTypeList.size > 0">
  122. AND T1.COST_TYPE in
  123. <foreach collection="params.costTypeList" item="item" open="(" close=")" separator=",">
  124. #{item}
  125. </foreach>
  126. </if>
  127. <if test="params != null and params.useMoneyNo != null and params.useMoneyNo != ''">
  128. AND T2.COMMON_COST_NO = #{params.useMoneyNo}
  129. </if>
  130. <if test="params != null and params.totalAmount != null and params.totalAmount != ''">
  131. AND T1.AMOUNT = #{params.totalAmount}
  132. </if>
  133. <if test="params != null and params.status != null and params.status != ''">
  134. AND T1.I_WRITE_OFF = #{params.status}
  135. </if>
  136. <if test="params != null and params.userId != null and params.userId != ''">
  137. AND T2.USER_ID = #{params.userId}
  138. </if>
  139. <if test="params != null and params.applyOn != null ">
  140. AND T2.APPLY_TIME &gt;= #{params.applyOn}
  141. </if>
  142. <if test="params != null and params.applyOff != null">
  143. AND T2.APPLY_TIME &lt;= #{params.applyOff}
  144. </if>
  145. <if test="params != null and params.writeOn != null ">
  146. AND T1.WRITE_OFF_TIME &gt;= #{params.writeOn}
  147. </if>
  148. <if test="params != null and params.writeOff != null ">
  149. AND T1.WRITE_OFF_TIME &lt;= #{params.writeOff}
  150. </if>
  151. <if test="params != null and params.DeptList != null and params.DeptList.size > 0">
  152. AND T3.ZRBM_ID in
  153. <foreach collection="params.DeptList" item="item" open="(" close=")" separator=",">
  154. #{item}
  155. </foreach>
  156. </if>
  157. <if test="params != null and params.UserDeptList != null and params.UserDeptList.size > 0">
  158. AND T2.DEPT_ID in
  159. <foreach collection="params.UserDeptList" item="item" open="(" close=")" separator=",">
  160. #{item}
  161. </foreach>
  162. </if>
  163. </where>
  164. order by APPLY_TIME DESC NULLS LAST
  165. </select>
  166. <select id="getUseMoneyEarnestDeptPage"
  167. resultType="com.zjugis.business.flow.usemoney.controller.vo.UseMoneyEarnestRespVO">
  168. SELECT
  169. T2.ID,
  170. T2.INSTANCE_ID,
  171. T2.PROJECT_ID,
  172. T2.APPLY_TIME,
  173. to_char(T2.COLLECTION_COMPANY) as COLLECTION_COMPANY,
  174. T2.USER_NICKNAME,
  175. T2.PAYMENT_COMPANY_ID,
  176. T1.AMOUNT,
  177. to_char(T1.REMARK) as REMARK,
  178. T1.WRITE_OFF_AMOUNT,
  179. T1.I_WRITE_OFF,
  180. T1.WRITE_OFF_TIME,
  181. T1.COST_TYPE,
  182. case when T2.PROJECT_ID is not null then T3.XMMC else T4.XMMC end as XMMC
  183. FROM
  184. WF_USE_MONEY_DETAIL T1
  185. LEFT JOIN WF_USE_MONEY T2 ON T1.USE_MONEY_ID = T2.ID
  186. LEFT JOIN project T3 ON T2.PROJECT_ID=T3.ID
  187. LEFT JOIN project T4 ON T1.PROJECT_ID=T4.ID
  188. <where>
  189. T1.COST_TYPE LIKE '14%' and (T2.FLOW_STATUS=90 )
  190. <if test="projectIds != null and projectIds.size > 0">
  191. AND (T2.PROJECT_ID IN
  192. <foreach collection="projectIds" index="index" item="item" open="(" separator="," close=")">
  193. #{item,jdbcType=VARCHAR}
  194. </foreach>
  195. or T1.PROJECT_ID IN
  196. <foreach collection="projectIds" index="index" item="item" open="(" separator="," close=")">
  197. #{item,jdbcType=VARCHAR}
  198. </foreach>
  199. <if test="params.UserDeptList != null and params.UserDeptList.size > 0">
  200. or (T2.DEPT_ID IN
  201. <foreach collection="params.UserDeptList" index="index" item="item1" open="(" separator="," close=")">
  202. #{item1,jdbcType=VARCHAR}
  203. </foreach>
  204. )
  205. </if>
  206. )
  207. </if>
  208. <if test="params != null and params.collectionCompany != null and params.collectionCompany != ''">
  209. <bind name="collectionCompany" value="'%'+params.collectionCompany+'%'"/>
  210. AND T2.COLLECTION_COMPANY like #{collectionCompany}
  211. </if>
  212. <if test="params != null and params.REMARK != null and params.REMARK != ''">
  213. <bind name="REMARK" value="'%'+params.REMARK+'%'"/>
  214. AND T1.REMARK like #{REMARK}
  215. </if>
  216. <!-- <if test="params != null and params.costType != null and params.costType != ''">-->
  217. <!-- AND T1.COST_TYPE in (#{params.costType})-->
  218. <!-- </if>-->
  219. <if test="params != null and params.costTypeList != null and params.costTypeList.size > 0">
  220. AND T1.COST_TYPE in
  221. <foreach collection="params.costTypeList" item="item" open="(" close=")" separator=",">
  222. #{item}
  223. </foreach>
  224. </if>
  225. <if test="params != null and params.totalAmount != null and params.totalAmount != ''">
  226. AND T2.TOTAL_AMOUNT = #{params.totalAmount}
  227. </if>
  228. <if test="params != null and params.status != null and params.status != ''">
  229. AND T1.I_WRITE_OFF = #{params.status}
  230. </if>
  231. <if test="params != null and params.userId != null and params.userId != ''">
  232. AND T2.USER_ID = #{params.userId}
  233. </if>
  234. <if test="params != null and params.applyOn != null ">
  235. AND T2.APPLY_TIME &gt;= #{params.applyOn}
  236. </if>
  237. <if test="params != null and params.applyOff != null ">
  238. AND T2.APPLY_TIME &lt;= #{params.applyOff}
  239. </if>
  240. <if test="params != null and params.writeOn != null ">
  241. AND T1.WRITE_OFF_TIME &gt;= #{params.writeOn}
  242. </if>
  243. <if test="params != null and params.writeOff != null ">
  244. AND T1.WRITE_OFF_TIME &lt;= #{params.writeOff}
  245. </if>
  246. <if test="params != null and params.DeptList != null and params.DeptList.size > 0">
  247. AND T3.ZRBM_ID in
  248. <foreach collection="params.DeptList" item="item" open="(" close=")" separator=",">
  249. #{item}
  250. </foreach>
  251. </if>
  252. </where>
  253. union
  254. SELECT
  255. T2.ID,
  256. T2.instance_id,
  257. T2.PROJECT_ID,
  258. T2.APPLY_TIME,
  259. '' as COLLECTION_COMPANY,
  260. T2.USER_NICKNAME,
  261. T2.PAYMENT_COMPANY_ID,
  262. T1.AMOUNT,
  263. to_char(T1.BZ1) AS REMARK,
  264. T1.WRITE_OFF_AMOUNT,
  265. T1.I_WRITE_OFF,
  266. T1.WRITE_OFF_TIME,
  267. T1.COST_TYPE,
  268. T3.XMMC
  269. FROM
  270. WF_COMMON_COST_DETAIL T1
  271. LEFT JOIN WF_COMMON_COST T2 ON T1.COMMON_COST_ID = T2.ID
  272. LEFT JOIN PROJECT T3 ON T2.PROJECT_ID=T3.ID
  273. <where>
  274. T1.COST_TYPE LIKE '14%' and (T2.FLOW_STATUS=90 or T2.FLOW_STATUS=89)
  275. <if test="projectIds != null and projectIds.size > 0">
  276. AND (T1.PROJECT_ID IN
  277. <foreach collection="projectIds" index="index" item="item" open="(" separator="," close=")">
  278. #{item,jdbcType=VARCHAR}
  279. </foreach>
  280. <if test="params.UserDeptList != null and params.UserDeptList.size > 0">
  281. or (T2.DEPT_ID IN
  282. <foreach collection="params.UserDeptList" index="index" item="item1" open="(" separator="," close=")">
  283. #{item1,jdbcType=VARCHAR}
  284. </foreach>
  285. )
  286. </if>
  287. )
  288. </if>
  289. <if test="params != null and params.collectionCompany != null and params.collectionCompany != ''">
  290. <bind name="collectionCompany" value="'%'+params.collectionCompany+'%'"/>
  291. AND T2.ID IS NULL
  292. </if>
  293. <if test="params != null and params.REMARK != null and params.REMARK != ''">
  294. <bind name="REMARK" value="'%'+params.REMARK+'%'"/>
  295. AND T1.BZ1 like #{REMARK}
  296. </if>
  297. <!-- <if test="params != null and params.costType != null and params.costType != ''">-->
  298. <!-- AND T1.COST_TYPE in (#{params.costType})-->
  299. <!-- </if>-->
  300. <if test="params != null and params.costTypeList != null and params.costTypeList.size > 0">
  301. AND T1.COST_TYPE in
  302. <foreach collection="params.costTypeList" item="item" open="(" close=")" separator=",">
  303. #{item}
  304. </foreach>
  305. </if>
  306. <!-- <if test="params != null and params.useMoneyNo != null and params.useMoneyNo != ''">-->
  307. <!-- AND T2.COMMON_COST_NO = #{params.useMoneyNo}-->
  308. <!-- </if>-->
  309. <if test="params != null and params.totalAmount != null and params.totalAmount != ''">
  310. AND T1.AMOUNT = #{params.totalAmount}
  311. </if>
  312. <if test="params != null and params.status != null and params.status != ''">
  313. AND T1.I_WRITE_OFF = #{params.status}
  314. </if>
  315. <if test="params != null and params.userId != null and params.userId != ''">
  316. AND T2.USER_ID = #{params.userId}
  317. </if>
  318. <if test="params != null and params.applyOn != null ">
  319. AND T2.APPLY_TIME &gt;= #{params.applyOn}
  320. </if>
  321. <if test="params != null and params.applyOff != null ">
  322. AND T2.APPLY_TIME &lt;= #{params.applyOff}
  323. </if>
  324. <if test="params != null and params.writeOn != null ">
  325. AND T1.WRITE_OFF_TIME &gt;= #{params.writeOn}
  326. </if>
  327. <if test="params != null and params.writeOff != null ">
  328. AND T1.WRITE_OFF_TIME &lt;= #{params.writeOff}
  329. </if>
  330. <if test="params != null and params.DeptList != null and params.DeptList.size > 0">
  331. AND T3.ZRBM_ID in
  332. <foreach collection="params.DeptList" item="item" open="(" close=")" separator=",">
  333. #{item}
  334. </foreach>
  335. </if>
  336. </where>
  337. ORDER BY APPLY_TIME DESC NULLS LAST
  338. </select>
  339. <select id="getCount" resultType="java.lang.Integer">
  340. select sum(num) from (
  341. SELECT count(*) as num
  342. from
  343. WF_USE_MONEY_DETAIL T1
  344. LEFT JOIN WF_USE_MONEY T2 ON T1.USE_MONEY_ID = T2.ID
  345. <where>
  346. T1.ISVALID = 1 and T2.FLOW_STATUS=90 and I_WRITE_OFF=0 AND T2.ISVALID = 1 and T1.COST_TYPE LIKE '14%'
  347. <if test="params != null and params.userId != null and params.userId != ''">
  348. AND USER_ID = #{params.userId}
  349. </if>
  350. </where>
  351. union all
  352. SELECT count(*) as num
  353. from
  354. WF_COMMON_COST_DETAIL T1
  355. LEFT JOIN WF_COMMON_COST T2 ON T1.COMMON_COST_ID = T2.ID
  356. <where>
  357. T1.ISVALID = 1 and (T2.FLOW_STATUS=90 or T2.FLOW_STATUS=89) and I_WRITE_OFF=0 AND T2.ISVALID = 1 and T1.COST_TYPE LIKE '14%'
  358. <if test="params != null and params.userId != null and params.userId != ''">
  359. AND USER_ID = #{params.userId}
  360. </if>
  361. </where>
  362. ) e
  363. </select>
  364. <select id="getUseMoneyOverviewHx" resultType="com.zjugis.business.flow.usemoney.controller.vo.UseMoneyOverviewVO">
  365. select
  366. NVL( sum( totalAmount ), 0 ) AS totalAmount,
  367. NVL( sum( totalUseAmount ), 0 ) AS totalUseAmount,
  368. NVL( sum( totalAmount ) - sum( totalUseAmount ), 0 ) AS totalApplyAmount
  369. from (
  370. SELECT
  371. NVL(sum(AMOUNT),0) as totalAmount,
  372. NVL(sum(WRITE_OFF_AMOUNT),0) as totalUseAmount,
  373. NVL(sum(AMOUNT)-sum(WRITE_OFF_AMOUNT),0) as totalApplyAmount
  374. from
  375. WF_USE_MONEY_DETAIL T1
  376. LEFT JOIN WF_USE_MONEY T2 ON T1.USE_MONEY_ID = T2.ID
  377. LEFT JOIN project T3 ON T2.PROJECT_ID=T3.ID
  378. <where>
  379. T1.ISVALID = 1 and (T2.FLOW_STATUS=90 ) AND T2.ISVALID = 1 and T1.COST_TYPE LIKE '14%'
  380. <if test="params != null and params.collectionCompany != null and params.collectionCompany != ''">
  381. <bind name="collectionCompany" value="'%'+params.collectionCompany+'%'"/>
  382. AND T2.COLLECTION_COMPANY like #{collectionCompany}
  383. </if>
  384. <if test="params != null and params.REMARK != null and params.REMARK != ''">
  385. <bind name="REMARK" value="'%'+params.REMARK+'%'"/>
  386. AND T1.REMARK like #{REMARK}
  387. </if>
  388. <!-- <if test="params != null and params.costType != null and params.costType != ''">-->
  389. <!-- AND T1.COST_TYPE in (#{params.costType})-->
  390. <!-- </if>-->
  391. <if test="params != null and params.costTypeList != null and params.costTypeList.size > 0">
  392. AND T1.COST_TYPE in
  393. <foreach collection="params.costTypeList" item="item" open="(" close=")" separator=",">
  394. #{item}
  395. </foreach>
  396. </if>
  397. <if test="params != null and params.useMoneyNo != null and params.useMoneyNo != ''">
  398. AND T2.USE_MONEY_NO = #{params.useMoneyNo}
  399. </if>
  400. <if test="params != null and params.totalAmount != null and params.totalAmount != ''">
  401. AND T2.TOTAL_AMOUNT = #{params.totalAmount}
  402. </if>
  403. <if test="params != null and params.status != null and params.status != ''">
  404. AND T1.I_WRITE_OFF = #{params.status}
  405. </if>
  406. <if test="params != null and params.userId != null and params.userId != ''">
  407. AND T2.USER_ID = #{params.userId}
  408. </if>
  409. <if test="params != null and params.applyOn != null ">
  410. AND T2.APPLY_TIME &gt;= #{params.applyOn}
  411. </if>
  412. <if test="params != null and params.applyOff != null ">
  413. AND T2.APPLY_TIME &lt;= #{params.applyOff}
  414. </if>
  415. <if test="params != null and params.writeOn != null ">
  416. AND T1.WRITE_OFF_TIME &gt;= #{params.writeOn}
  417. </if>
  418. <if test="params != null and params.writeOff != null ">
  419. AND T1.WRITE_OFF_TIME &lt;= #{params.writeOff}
  420. </if>
  421. <if test="params != null and params.DeptList != null and params.DeptList.size > 0">
  422. AND T3.ZRBM_ID in
  423. <foreach collection="params.DeptList" item="item" open="(" close=")" separator=",">
  424. #{item}
  425. </foreach>
  426. </if>
  427. <if test="params.project != null and params.project.size > 0">
  428. AND (T2.PROJECT_ID IN
  429. <foreach collection="params.project" index="index" item="item" open="(" separator="," close=")">
  430. #{item,jdbcType=VARCHAR}
  431. </foreach>
  432. or T1.PROJECT_ID IN
  433. <foreach collection="params.project" index="index" item="item" open="(" separator="," close=")">
  434. #{item,jdbcType=VARCHAR}
  435. </foreach>
  436. <if test="params.UserDeptList != null and params.UserDeptList.size > 0">
  437. or (T2.DEPT_ID IN
  438. <foreach collection="params.UserDeptList" index="index" item="item1" open="(" separator="," close=")">
  439. #{item1,jdbcType=VARCHAR}
  440. </foreach>
  441. )
  442. </if>
  443. )
  444. </if>
  445. </where>
  446. union all
  447. SELECT
  448. NVL(sum(AMOUNT),0) as totalAmount,
  449. NVL(sum(WRITE_OFF_AMOUNT),0) as totalUseAmount,
  450. NVL(sum(AMOUNT)-sum(WRITE_OFF_AMOUNT),0) as totalApplyAmount
  451. from
  452. WF_COMMON_COST_DETAIL T1
  453. LEFT JOIN WF_COMMON_COST T2 ON T1.COMMON_COST_ID = T2.ID
  454. LEFT JOIN project T3 ON T2.PROJECT_ID=T3.ID
  455. <where>
  456. T1.ISVALID = 1 and (T2.FLOW_STATUS=90 or T2.FLOW_STATUS=89) AND T2.ISVALID = 1 and T1.COST_TYPE LIKE '14%'
  457. <if test="params != null and params.collectionCompany != null and params.collectionCompany != ''">
  458. <bind name="collectionCompany" value="'%'+params.collectionCompany+'%'"/>
  459. AND T2.ID IS NULL
  460. </if>
  461. <if test="params != null and params.REMARK != null and params.REMARK != ''">
  462. <bind name="REMARK" value="'%'+params.REMARK+'%'"/>
  463. AND T1.BZ1 like #{REMARK}
  464. </if>
  465. <!-- <if test="params != null and params.costType != null and params.costType != ''">-->
  466. <!-- AND T1.COST_TYPE in (#{params.costType})-->
  467. <!-- </if>-->
  468. <if test="params != null and params.costTypeList != null and params.costTypeList.size > 0">
  469. AND T1.COST_TYPE in
  470. <foreach collection="params.costTypeList" item="item" open="(" close=")" separator=",">
  471. #{item}
  472. </foreach>
  473. </if>
  474. <if test="params != null and params.useMoneyNo != null and params.useMoneyNo != ''">
  475. AND T2.COMMON_COST_NO = #{params.useMoneyNo}
  476. </if>
  477. <if test="params != null and params.totalAmount != null and params.totalAmount != ''">
  478. AND T2.TOTAL_AMOUNT = #{params.totalAmount}
  479. </if>
  480. <if test="params != null and params.status != null and params.status != ''">
  481. AND T1.I_WRITE_OFF = #{params.status}
  482. </if>
  483. <if test="params != null and params.userId != null and params.userId != ''">
  484. AND T2.USER_ID = #{params.userId}
  485. </if>
  486. <if test="params != null and params.applyOn != null ">
  487. AND T2.APPLY_TIME &gt;= #{params.applyOn}
  488. </if>
  489. <if test="params != null and params.applyOff != null ">
  490. AND T2.APPLY_TIME &lt;= #{params.applyOff}
  491. </if>
  492. <if test="params != null and params.writeOn != null">
  493. AND T1.WRITE_OFF_TIME &gt;= #{params.writeOn}
  494. </if>
  495. <if test="params != null and params.writeOff != null ">
  496. AND T1.WRITE_OFF_TIME &lt;= #{params.writeOff}
  497. </if>
  498. <if test="params != null and params.DeptList != null and params.DeptList.size > 0">
  499. AND T3.ZRBM_ID in
  500. <foreach collection="params.DeptList" item="item" open="(" close=")" separator=",">
  501. #{item}
  502. </foreach>
  503. </if>
  504. <if test="params.project != null and params.project.size > 0">
  505. AND (T1.PROJECT_ID IN
  506. <foreach collection="params.project" index="index" item="item" open="(" separator="," close=")">
  507. #{item,jdbcType=VARCHAR}
  508. </foreach>
  509. <if test="params.UserDeptList != null and params.UserDeptList.size > 0">
  510. or (T2.DEPT_ID IN
  511. <foreach collection="params.UserDeptList" index="index" item="item1" open="(" separator="," close=")">
  512. #{item1,jdbcType=VARCHAR}
  513. </foreach>
  514. )
  515. </if>
  516. )
  517. </if>
  518. </where>) e
  519. </select>
  520. <!-- <select id="getUseMoneyPage" resultType="com.zjugis.business.flow.usemoney.controller.vo.UseMoneyRespVO">-->
  521. <!-- SELECT-->
  522. <!-- T.*-->
  523. <!-- FROM-->
  524. <!-- WF_USE_MONEY T-->
  525. <!-- <where>-->
  526. <!-- <if test="params != null and params.userId != null">-->
  527. <!-- AND T.USER_ID = #{params.userId}-->
  528. <!-- </if>-->
  529. <!-- <if test="params != null and params.costType != null">-->
  530. <!-- AND T.DEPT_ID = #{params.costType}-->
  531. <!-- </if>-->
  532. <!-- <if test="params != null and params.costType != null">-->
  533. <!-- AND T.USE_MONEY_NO = #{params.costType}-->
  534. <!-- </if>-->
  535. <!-- <if test="params != null and params.costType != null">-->
  536. <!-- AND T.COST_TYPE = #{params.costType}-->
  537. <!-- </if>-->
  538. <!-- <if test="params != null and params.params.flowStatus != null">-->
  539. <!-- AND T.FLOW_STATUS = #{params.flowStatus}-->
  540. <!-- </if>-->
  541. <!-- <if test="params != null and params.costType != null">-->
  542. <!-- AND T.TOTAL_AMOUNT = #{params.costType}-->
  543. <!-- </if>-->
  544. <!-- <if test="params != null and params.applyOn != null">-->
  545. <!-- AND T.APPLY_DATE &gt;= #{params.applyOn}-->
  546. <!-- </if>-->
  547. <!-- <if test="params != null and params.applyOff != null">-->
  548. <!-- AND T.APPLY_DATE &lt;= #{params.applyOff}-->
  549. <!-- </if>-->
  550. <!-- </where>-->
  551. <!-- ORDER BY T.APPLY_TIME DESC NULLS LAST-->
  552. <!-- </select>-->
  553. <select id="getAllIdByProject" resultType="java.lang.String">
  554. SELECT T1.id
  555. from
  556. WF_USE_MONEY T1
  557. LEFT JOIN WF_USE_MONEY_DETAIL T2 ON T2.USE_MONEY_ID = T1.ID
  558. <where>
  559. T1.ISVALID = 1 and (T1.FLOW_STATUS=90 or T1.FLOW_STATUS=89) AND T2.ISVALID = 1
  560. and (t1.PROJECT_ID=#{project} or t2.PROJECT_ID=#{project})
  561. </where>
  562. </select>
  563. <select id="getDataByProject" resultType="com.zjugis.business.flow.usemoney.controller.vo.UseMoneyTypeRespVO">
  564. SELECT
  565. sum(case when t1.COST_TYPE ='0101' or t1.COST_TYPE ='0102' then t1.AMOUNT else 0 end ) as subAmount,
  566. sum(case when t1.COST_TYPE ='03' then t1.AMOUNT else 0 end ) as outAmount,
  567. sum(case when t1.COST_TYPE !='03' and t1.COST_TYPE !='0101' and t1.COST_TYPE !='0102' then t1.AMOUNT else 0 end ) as otherAmount
  568. from
  569. WF_USE_MONEY_DETAIL T1
  570. LEFT JOIN WF_USE_MONEY T2 ON T1.USE_MONEY_ID = T2.ID
  571. <where>
  572. T1.ISVALID = 1 and (T2.FLOW_STATUS=90 or T2.FLOW_STATUS=89) AND T2.ISVALID = 1
  573. and (t1.PROJECT_ID=#{project} or t2.PROJECT_ID=#{project})
  574. </where>
  575. </select>
  576. <select id="getDataByDeptId" resultType="com.zjugis.business.flow.usemoney.controller.vo.UseMoneyDeptRespVO">
  577. SELECT
  578. sum(t1.AMOUNT ) as amount
  579. from
  580. WF_USE_MONEY_DETAIL T1
  581. LEFT JOIN WF_USE_MONEY T2 ON T1.USE_MONEY_ID = T2.ID
  582. LEFT JOIN project T3 ON T2.PROJECT_ID=T3.ID
  583. LEFT JOIN project T4 ON T1.PROJECT_ID=T4.ID
  584. <where>
  585. T1.ISVALID = 1 and (T2.FLOW_STATUS=90 or T2.FLOW_STATUS=89) AND T2.ISVALID = 1
  586. and EXTRACT(YEAR FROM T2.FLOW_FINISHTIME) = EXTRACT(YEAR FROM SYSDATE)
  587. <if test=" deptId != null and deptId.size > 0">
  588. AND (T3.ZRBM_ID in
  589. <foreach collection="deptId" item="item" open="(" close=")" separator=",">
  590. #{item}
  591. </foreach>
  592. or
  593. T4.ZRBM_ID in
  594. <foreach collection="deptId" item="item" open="(" close=")" separator=",">
  595. #{item}
  596. </foreach>
  597. )
  598. </if>
  599. </where>
  600. </select>
  601. </mapper>