ProjectMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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.mapper.ProjectMapper">
  4. <select id="calculate" resultType="com.zjugis.business.bean.response.ProjectCalculateResponse">
  5. SELECT COALESCE(SUM(COALESCE(PA.VIRTUAL_AMOUNT, 0)), 0) as output,
  6. COALESCE(SUM(COALESCE(PA.PROJECT_COST, 0)), 0) as cost
  7. FROM PROJECT P
  8. LEFT JOIN PROJECT_AMOUNT PA on PA.PROJECT_ID = P.ID
  9. LEFT JOIN (SELECT PROJECT_ID,MAX(ID) as ID FROM CONTRACT WHERE FLOW_STATUS = 90 AND ISVALID = 1 GROUP BY PROJECT_ID ) T1 ON T1.PROJECT_ID = P.ID
  10. <if test="params != null and params.userId != null and params.userId != ''">
  11. LEFT JOIN PROJECT_WORKER_RELATION PW ON PW.PROJECT_ID = P.ID
  12. </if>
  13. <where>
  14. P.ISVALID = 1 AND P.FLOW_STATUS IN (90,99)
  15. <if test="params != null and params.hyId != null">
  16. AND P.HY_ID = #{params.hyId}
  17. </if>
  18. <if test="params != null and params.xzqdm != null and params.xzqdm != ''">
  19. AND P.XZQDM = #{params.xzqdm}
  20. </if>
  21. <if test="params != null and params.projectTypeId != null and params.projectTypeId != ''">
  22. AND P.PROJECT_TYPE_ID = #{params.projectTypeId}
  23. </if>
  24. <if test="params != null and params.xmzt != null">
  25. AND P.XMZT = #{params.xmzt}
  26. </if>
  27. <if test="params != null and params.lxsjOn != null">
  28. AND P.LXSJ &gt;= #{params.lxsjOn}
  29. </if>
  30. <if test="params != null and params.lxsjOff != null">
  31. AND P.LXSJ &lt;= #{params.lxsjOff}
  32. </if>
  33. <if test="params != null and params.isSign == 1">
  34. AND T1.ID is not null
  35. </if>
  36. <if test="params != null and params.isSign == 0">
  37. AND T1.ID is null
  38. </if>
  39. <if test="params != null and params.xmmc != null and params.xmmc != ''">
  40. <bind name="xmmc" value="'%'+params.xmmc+'%'"/>
  41. AND P.XMMC LIKE #{xmmc}
  42. </if>
  43. <if test="params != null and params.xmbh != null and params.xmbh != ''">
  44. <bind name="xmbh" value="'%'+params.xmbh+'%'"/>
  45. AND P.XMBH LIKE #{xmbh}
  46. </if>
  47. <if test="params != null and params.userId != null and params.userId != ''">
  48. AND PW.WORKER_ID = #{params.userId}
  49. </if>
  50. <if test="params != null and params.deptId != null and params.deptId != ''">
  51. AND P.ZRBM_ID = #{params.deptId}
  52. </if>
  53. <if test="params != null and params.xmjlId != null and params.xmjlId != ''">
  54. AND P.XMJL_ID = #{params.xmjlId}
  55. </if>
  56. </where>
  57. </select>
  58. <select id="selectWithChildren" resultType="com.zjugis.business.bean.response.ProjectResponse">
  59. SELECT P.*,D.NAME as zrbm FROM PROJECT P
  60. LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = P.ZRBM_ID
  61. WHERE P.ISVALID = 1
  62. START WITH P.ID = (
  63. SELECT ID FROM PROJECT
  64. WHERE ISVALID = 1 and PID is NULL
  65. START WITH ID = #{id}
  66. CONNECT BY PRIOR PID = ID
  67. )
  68. CONNECT BY PRIOR P.ID = P.PID
  69. </select>
  70. <select id="page" resultType="com.zjugis.business.bean.entity.Project">
  71. SELECT P.*,D.NAME as zrbm,PA.CONTRACT_AMOUNT,PA.RECEIVABLE_AMOUNT,PA.CONTRACT_BALANCE,PA.PROJECT_COST,PA.VIRTUAL_AMOUNT
  72. <if test="params != null and params.isRelContract != null and params.isRelContract == 1">
  73. ,C.contractNumber as contractNumber
  74. </if>
  75. FROM PROJECT P
  76. LEFT JOIN PROJECT_AMOUNT PA ON PA.PROJECT_ID = P.ID
  77. LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = P.ZRBM_ID
  78. LEFT JOIN (SELECT PROJECT_ID,MAX(ID) as ID FROM CONTRACT WHERE FLOW_STATUS = 90 AND ISVALID = 1 GROUP BY PROJECT_ID ) T1 ON T1.PROJECT_ID = P.ID
  79. <if test="params != null and params.isRelContract != null and params.isRelContract == 1">
  80. LEFT JOIN (SELECT PID,count(1) as ccount FROM PROJECT WHERE FLOW_STATUS = 99 GROUP BY PID) CH ON CH.PID = P.ID
  81. LEFT JOIN (SELECT PROJECT_ID,max(CONTRACT_NUMBER) as contractNumber FROM CONTRACT where FLOW_STATUS in (90,99) GROUP BY PROJECT_ID) C ON C.PROJECT_ID = P.ID
  82. </if>
  83. <if test="params != null and params.userId != null and params.userId != ''">
  84. LEFT JOIN PROJECT_WORKER_RELATION PW ON PW.PROJECT_ID = P.ID
  85. </if>
  86. <if test="params != null and params.userId == null and params.userList != null and params.userList.size > 0">
  87. LEFT JOIN PROJECT_WORKER_RELATION PW ON PW.PROJECT_ID = P.ID
  88. </if>
  89. <if test="params != null and params.xmzt == 2">
  90. LEFT JOIN PROJECT_STATUS PS ON PS.PROJECT_ID = P.ID AND PS.TYPE = 'ys' AND PS.FLOW_STATUS = 90
  91. </if>
  92. <if test="params != null and params.xmzt == 3">
  93. LEFT JOIN PROJECT_STATUS PS ON PS.PROJECT_ID = P.ID AND PS.TYPE = 'jx' AND PS.FLOW_STATUS = 90
  94. </if>
  95. <where>
  96. P.ISVALID = 1 AND P.FLOW_STATUS IN (90,99)
  97. <if test="params != null and params.hyId != null">
  98. AND P.HY_ID = #{params.hyId}
  99. </if>
  100. <if test="params != null and params.xzqdm != null and params.xzqdm != ''">
  101. AND P.XZQDM = #{params.xzqdm}
  102. </if>
  103. <if test="params != null and params.projectTypeId != null and params.projectTypeId != ''">
  104. AND P.PROJECT_TYPE_ID = #{params.projectTypeId}
  105. </if>
  106. <if test="params != null and params.xmzt != null">
  107. AND P.XMZT = #{params.xmzt}
  108. </if>
  109. <if test="params != null and params.xmztList != null and params.xmztList.size > 0">
  110. AND P.XMZT in
  111. <foreach collection="params.xmztList" item="item" open="(" close=")" separator=",">
  112. #{item}
  113. </foreach>
  114. </if>
  115. <if test="params != null and params.lxsjOn != null">
  116. AND P.LXSJ &gt;= #{params.lxsjOn}
  117. </if>
  118. <if test="params != null and params.lxsjOff != null">
  119. AND P.LXSJ &lt;= #{params.lxsjOff}
  120. </if>
  121. <if test="params != null and params.isSign == 1">
  122. AND T1.ID is not null
  123. </if>
  124. <if test="params != null and params.isSign == 0">
  125. AND T1.ID is null
  126. </if>
  127. <if test="params != null and params.xmmc != null and params.xmmc != ''">
  128. <bind name="xmmc" value="'%'+params.xmmc+'%'"/>
  129. AND P.XMMC LIKE #{xmmc}
  130. </if>
  131. <if test="params != null and params.xmbh != null and params.xmbh != ''">
  132. <bind name="xmbh" value="'%'+params.xmbh+'%'"/>
  133. AND P.XMBH LIKE #{xmbh}
  134. </if>
  135. <if test="params != null and params.userId != null and params.userId != ''">
  136. AND PW.WORKER_ID = #{params.userId}
  137. </if>
  138. <if test="params != null and params.userList != null and params.userList.size > 0">
  139. AND PW.WORKER_ID in
  140. <foreach collection="params.userList" item="item" open="(" close=")" separator=",">
  141. #{item}
  142. </foreach>
  143. </if>
  144. <if test="params != null and params.deptId != null and params.deptId != ''">
  145. AND P.ZRBM_ID = #{params.deptId}
  146. </if>
  147. <if test="params != null and params.xmjlId != null and params.xmjlId != ''">
  148. AND P.XMJL_ID = #{params.xmjlId}
  149. </if>
  150. </where>
  151. ORDER BY
  152. <choose>
  153. <when test="params != null and (params.xmzt == 2 or params.xmzt == 3)">
  154. PS.FLOW_FINISHTIME
  155. </when>
  156. <when test="params != null and params.xmzt != 2 and params.xmzt != 3 and params.sortType == 2 ">
  157. YSSJ
  158. </when>
  159. <otherwise>
  160. LXSJ
  161. </otherwise>
  162. </choose>
  163. DESC
  164. </select>
  165. <select id="costSum" resultType="com.zjugis.business.bean.response.SumResponse">
  166. select
  167. nvl(sum(a.xmzcb), 0) as xmzcb,
  168. nvl(sum(ct.htje * a.czjd / 100), 0) as xmzcz,
  169. nvl(nvl(sum(ct.htje * a.czjd / 100), 0)- nvl(sum(a.xmzcb), 0),0) as xmlr
  170. from PROJECT p
  171. left join (select nvl(sum(c.htje), 0) as htje, cp.project_id
  172. from contract c
  173. left join contract_project cp
  174. on cp.contract_id = c.contract_id
  175. group by cp.project_id) ct
  176. on ct.project_id = p.project_id
  177. left join (select t.project_id as project_id,
  178. nvl(sum(t.payment_cost), 0) as xmzcb,
  179. max(t.output_progress) as czjd
  180. from PROJECT_COST t
  181. where to_char(t.rq, 'yyyy') = '{time}'
  182. group by t.project_id) a
  183. on a.project_id = p.project_id
  184. where p.isvalid = 1
  185. </select>
  186. <select id="selectChildrenOutputValue" resultType="java.math.BigDecimal">
  187. select nvl(sum(nvl(OUTPUT_VALUE,0)), 0) from PROJECT where PID = #{pid,jdbcType=VARCHAR} and ISVALID = 1
  188. </select>
  189. <select id="selectChildrenIds" resultType="java.lang.String">
  190. SELECT ID FROM PROJECT WHERE PID = #{projectId,jdbcType=VARCHAR} AND ISVALID = 1 and FLOW_STATUS = 99
  191. </select>
  192. <select id="countXmzt" resultType="com.zjugis.business.bean.response.ProjectXmztCountResponse">
  193. SELECT
  194. count(1) as total,
  195. SUM(CASE WHEN P.XMZT = 1 THEN 1 ELSE 0 END) as process,
  196. SUM(CASE WHEN P.XMZT = 2 THEN 1 ELSE 0 END) as finished,
  197. SUM(CASE WHEN P.XMZT = 3 THEN 1 ELSE 0 END) as terminated,
  198. SUM(CASE WHEN P.XMZT = 4 THEN 1 ELSE 0 END) as accepted
  199. FROM PROJECT P
  200. LEFT JOIN (SELECT PROJECT_ID,MAX(ID) as ID FROM CONTRACT WHERE FLOW_STATUS = 90 AND ISVALID = 1 GROUP BY PROJECT_ID ) T1 ON T1.PROJECT_ID = P.ID
  201. <if test="params != null and params.userId != null and params.userId != ''">
  202. LEFT JOIN PROJECT_WORKER_RELATION PW ON PW.PROJECT_ID = P.ID
  203. </if>
  204. <where>
  205. P.ISVALID = 1 AND P.FLOW_STATUS IN (90,99)
  206. <if test="params != null and params.hyId != null">
  207. AND P.HY_ID = #{params.hyId}
  208. </if>
  209. <if test="params != null and params.xzqdm != null and params.xzqdm != ''">
  210. AND P.XZQDM = #{params.xzqdm}
  211. </if>
  212. <if test="params != null and params.projectTypeId != null and params.projectTypeId != ''">
  213. AND P.PROJECT_TYPE_ID = #{params.projectTypeId}
  214. </if>
  215. <if test="params != null and params.xmzt != null">
  216. AND P.XMZT = #{params.xmzt}
  217. </if>
  218. <if test="params != null and params.lxsjOn != null">
  219. AND P.LXSJ &gt;= #{params.lxsjOn}
  220. </if>
  221. <if test="params != null and params.lxsjOff != null">
  222. AND P.LXSJ &lt;= #{params.lxsjOff}
  223. </if>
  224. <if test="params != null and params.isSign == 1">
  225. AND T1.ID is not null
  226. </if>
  227. <if test="params != null and params.isSign == 0">
  228. AND T1.ID is null
  229. </if>
  230. <if test="params != null and params.xmmc != null and params.xmmc != ''">
  231. <bind name="xmmc" value="'%'+params.xmmc+'%'"/>
  232. AND P.XMMC LIKE #{xmmc}
  233. </if>
  234. <if test="params != null and params.xmbh != null and params.xmbh != ''">
  235. <bind name="xmbh" value="'%'+params.xmbh+'%'"/>
  236. AND P.XMBH LIKE #{xmbh}
  237. </if>
  238. <if test="params != null and params.userId != null and params.userId != ''">
  239. AND PW.WORKER_ID = #{params.userId}
  240. </if>
  241. <if test="params != null and params.deptId != null and params.deptId != ''">
  242. AND P.ZRBM_ID = #{params.deptId}
  243. </if>
  244. </where>
  245. </select>
  246. <update id="updateChildXmzt">
  247. UPDATE PROJECT SET XMZT = #{xmzt,jdbcType=INTEGER} WHERE PID = #{projectId,jdbcType=VARCHAR} AND FLOW_STATUS = 99
  248. </update>
  249. <select id="selectCountInfo" resultType="com.zjugis.business.bean.dto.CountInfo">
  250. SELECT
  251. COALESCE(SUM(CASE WHEN T.LXSJ &gt;= #{start,jdbcType=DATE} THEN 1 ELSE 0 END),0) as xl,
  252. COALESCE(SUM(CASE WHEN T.LXSJ &lt;= #{end,jdbcType=DATE} AND XMZT = 1 THEN 1 ELSE 0 END),0) as jz,
  253. COALESCE(SUM(CASE WHEN T.XMZT != 3 AND T.IS_SIGN = 1 AND T1.ID IS NOT NULL THEN 1 ELSE 0 END),0) as haveContract,
  254. COALESCE(SUM(CASE WHEN T.XMZT != 3 AND T.IS_SIGN = 1 AND T1.ID IS NULL THEN 1 ELSE 0 END),0) as noContract,
  255. COALESCE(SUM(CASE WHEN T.XMZT = 4 THEN 1 ELSE 0 END),0) as accepted,
  256. COALESCE(SUM(CASE WHEN T.XMZT = 1 and T1.ID IS NOT NULL THEN 1 ELSE 0 END),0) as unaccepted
  257. FROM PROJECT T
  258. LEFT JOIN (SELECT PROJECT_ID,MAX(ID) as ID FROM CONTRACT WHERE FLOW_STATUS = 90 AND ISVALID = 1 GROUP BY PROJECT_ID ) T1 ON T1.PROJECT_ID = T.ID
  259. WHERE T.ISVALID = 1 AND T.FLOW_STATUS = 90
  260. <if test="params != null and params.deptIds != null and params.deptIds.size > 0">
  261. AND T.ZRBM_ID in
  262. <foreach collection="params.deptIds" item="item" open="(" close=")" separator=",">
  263. #{item}
  264. </foreach>
  265. </if>
  266. </select>
  267. <select id="selectAmountInfo" resultType="com.zjugis.business.bean.dto.AmountInfo">
  268. SELECT
  269. count(1) as total,
  270. COALESCE(SUM(CASE WHEN T1.CONTRACT_AMOUNT &lt; 1000000 THEN 1 ELSE 0 END),0) as lt100,
  271. COALESCE(SUM(CASE WHEN T1.CONTRACT_AMOUNT &gt;= 1000000 and T1.CONTRACT_AMOUNT &lt; 2000000 THEN 1 ELSE 0 END),0) as lt200,
  272. COALESCE(SUM(CASE WHEN T1.CONTRACT_AMOUNT &gt;= 2000000 and T1.CONTRACT_AMOUNT &lt; 3000000 THEN 1 ELSE 0 END),0) as lt300,
  273. COALESCE(SUM(CASE WHEN T1.CONTRACT_AMOUNT &gt;= 3000000 and T1.CONTRACT_AMOUNT &lt; 4000000 THEN 1 ELSE 0 END),0) as lt400,
  274. COALESCE(SUM(CASE WHEN T1.CONTRACT_AMOUNT &gt;= 4000000 THEN 1 ELSE 0 END),0) as gte400
  275. FROM PROJECT T
  276. LEFT JOIN CONTRACT T1 ON T1.PROJECT_ID = T.ID AND T1.FLOW_STATUS = 90 AND T1.ISVALID = 1
  277. WHERE T.ISVALID = 1 AND T.FLOW_STATUS = 90
  278. <if test="params != null and params.deptIds != null and params.deptIds.size > 0">
  279. AND T.ZRBM_ID in
  280. <foreach collection="params.deptIds" item="item" open="(" close=")" separator=",">
  281. #{item}
  282. </foreach>
  283. </if>
  284. </select>
  285. <select id="selectProcessInfo" resultType="com.zjugis.business.bean.dto.ProcessInfo">
  286. SELECT
  287. count(1) as total,
  288. COALESCE(SUM(CASE WHEN T1.process &gt; 75 THEN 1 ELSE 0 END),0) as gt75,
  289. COALESCE(SUM(CASE WHEN T1.process &gt; 50 and T1.process &lt;= 75 THEN 1 ELSE 0 END),0) as gt50,
  290. COALESCE(SUM(CASE WHEN T1.process &gt; 25 and T1.process &lt;= 50 THEN 1 ELSE 0 END),0) as gt25,
  291. COALESCE(SUM(CASE WHEN T1.process &gt; 10 and T1.process &lt;= 25 THEN 1 ELSE 0 END),0) as gt10,
  292. COALESCE(SUM(CASE WHEN T1.process &lt; 10 THEN 1 ELSE 0 END),0) as lte10
  293. FROM PROJECT T
  294. LEFT JOIN(
  295. SELECT MAX(TO_NUMBER(REPLACE(PROCESS, '%' ,''))) as process,PROJECT_ID FROM PROJECT_MILESTONE
  296. WHERE STATE = 1 AND ISVALID = 1
  297. GROUP BY PROJECT_ID
  298. ) T1 ON T1.PROJECT_ID = T.ID
  299. WHERE T.ISVALID = 1 AND T.FLOW_STATUS = 90
  300. <if test="params != null and params.deptIds != null and params.deptIds.size > 0">
  301. AND T.ZRBM_ID in
  302. <foreach collection="params.deptIds" item="item" open="(" close=")" separator=",">
  303. #{item}
  304. </foreach>
  305. </if>
  306. </select>
  307. <select id="selectAllIds" resultType="java.lang.String">
  308. SELECT ID FROM PROJECT
  309. WHERE ISVALID = 1 AND FLOW_STATUS IN (90,99) and XMZT IN (1,4)
  310. </select>
  311. <select id="contractExist" resultType="com.zjugis.business.bean.entity.Contract">
  312. SELECT ID,INSTANCE_ID,FLOW_STATUS,ISVALID FROM CONTRACT
  313. WHERE PROJECT_ID = #{projectId,jdbcType=VARCHAR}
  314. </select>
  315. <select id="getList" resultType="com.zjugis.business.bean.entity.Project">
  316. SELECT P.*,D.NAME as zrbm,PA.CONTRACT_AMOUNT,PA.RECEIVABLE_AMOUNT,PA.CONTRACT_BALANCE,PA.PROJECT_COST,PA.VIRTUAL_AMOUNT
  317. <if test="params != null and params.isRelContract != null and params.isRelContract == 1">
  318. ,C.contractNumber as contractNumber
  319. </if>
  320. FROM PROJECT P
  321. LEFT JOIN PROJECT_AMOUNT PA ON PA.PROJECT_ID = P.ID
  322. LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = P.ZRBM_ID
  323. <if test="params != null and params.isRelContract != null and params.isRelContract == 1">
  324. LEFT JOIN (SELECT PID,count(1) as ccount FROM PROJECT WHERE FLOW_STATUS = 99 GROUP BY PID) CH ON CH.PID = P.ID
  325. LEFT JOIN (SELECT PROJECT_ID,max(CONTRACT_NUMBER) as contractNumber FROM CONTRACT where FLOW_STATUS in (90,99) GROUP BY PROJECT_ID) C ON C.PROJECT_ID = P.ID
  326. </if>
  327. <if test="params != null and params.userId != null and params.userId != ''">
  328. LEFT JOIN PROJECT_WORKER_RELATION PW ON PW.PROJECT_ID = P.ID
  329. </if>
  330. <where>
  331. P.ISVALID = 1 AND P.FLOW_STATUS IN (90,99)
  332. <if test="params != null and params.hyId != null">
  333. AND P.HY_ID = #{params.hyId}
  334. </if>
  335. <if test="params != null and params.xzqdm != null and params.xzqdm != ''">
  336. AND P.XZQDM = #{params.xzqdm}
  337. </if>
  338. <if test="params != null and params.projectTypeId != null and params.projectTypeId != ''">
  339. AND P.PROJECT_TYPE_ID = #{params.projectTypeId}
  340. </if>
  341. <if test="params != null and params.xmzt != null">
  342. AND P.XMZT = #{params.xmzt}
  343. </if>
  344. <if test="params != null and params.lxsjOn != null">
  345. AND P.LXSJ &gt;= #{params.lxsjOn}
  346. </if>
  347. <if test="params != null and params.lxsjOff != null">
  348. AND P.LXSJ &lt;= #{params.lxsjOff}
  349. </if>
  350. <if test="params != null and params.isSign != null">
  351. AND P.IS_SIGN = #{params.isSign}
  352. </if>
  353. <if test="params != null and params.xmmc != null and params.xmmc != ''">
  354. <bind name="xmmc" value="'%'+params.xmmc+'%'"/>
  355. AND P.XMMC LIKE #{xmmc}
  356. </if>
  357. <if test="params != null and params.xmbh != null and params.xmbh != ''">
  358. <bind name="xmbh" value="'%'+params.xmbh+'%'"/>
  359. AND P.XMBH LIKE #{xmbh}
  360. </if>
  361. <if test="params != null and params.userId != null and params.userId != ''">
  362. AND PW.WORKER_ID = #{params.userId}
  363. </if>
  364. <if test="params != null and params.deptId != null and params.deptId != ''">
  365. AND P.ZRBM_ID = #{params.deptId}
  366. </if>
  367. <if test="params != null and params.xmjlId != null and params.xmjlId != ''">
  368. AND P.XMJL_ID = #{params.xmjlId}
  369. </if>
  370. </where>
  371. ORDER BY
  372. <choose>
  373. <when test="params != null and params.sortType == 2 ">
  374. YSSJ
  375. </when>
  376. <otherwise>
  377. LXSJ
  378. </otherwise>
  379. </choose>
  380. DESC
  381. </select>
  382. <select id="excelList" resultType="com.zjugis.business.bean.response.ProjectExcelResponse">
  383. SELECT P.*,D.NAME as zrbm,T1.contractName,T1.contractNumber,PA.CONTRACT_AMOUNT,PA.RETURN_AMOUNT,PA.RECEIVABLE_AMOUNT,PA.CONTRACT_BALANCE,PA.PROJECT_COST,PA.REIMBURSEMENT_COST,PA.TRAVEL_COST,PA.SUBCONTRACT_COST,PA.OUTSOURCE_COST,PA.PAYMENT_COST,P.PROJECT_STATUS_REASON
  384. FROM PROJECT P
  385. LEFT JOIN (SELECT PROJECT_ID,MAX(ID) as ID,
  386. REPLACE(WMSYS.WM_CONCAT(TO_CHAR(NAME)), ',', '/') as contractName,
  387. REPLACE(WMSYS.WM_CONCAT(TO_CHAR(CONTRACT_NUMBER)), ',', '/') as contractNumber
  388. FROM CONTRACT WHERE FLOW_STATUS = 90 AND ISVALID = 1 AND PROJECT_ID IS NOT NULL GROUP BY PROJECT_ID) T1 ON T1.PROJECT_ID = P.ID
  389. LEFT JOIN PROJECT_AMOUNT PA ON PA.PROJECT_ID = P.ID
  390. LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = P.ZRBM_ID
  391. <if test="params != null and params.userId != null and params.userId != ''">
  392. LEFT JOIN PROJECT_WORKER_RELATION PW ON PW.PROJECT_ID = P.ID
  393. </if>
  394. <if test="params != null and params.userId == null and params.userList != null and params.userList.size > 0">
  395. LEFT JOIN PROJECT_WORKER_RELATION PW ON PW.PROJECT_ID = P.ID
  396. </if>
  397. <where>
  398. P.ISVALID = 1 AND P.FLOW_STATUS IN (90,99)
  399. <if test="params != null and params.hyId != null">
  400. AND P.HY_ID = #{params.hyId}
  401. </if>
  402. <if test="params != null and params.xzqdm != null and params.xzqdm != ''">
  403. AND P.XZQDM = #{params.xzqdm}
  404. </if>
  405. <if test="params != null and params.projectTypeId != null and params.projectTypeId != ''">
  406. AND P.PROJECT_TYPE_ID = #{params.projectTypeId}
  407. </if>
  408. <if test="params != null and params.xmzt != null">
  409. AND P.XMZT = #{params.xmzt}
  410. </if>
  411. <if test="params != null and params.lxsjOn != null">
  412. AND P.LXSJ &gt;= #{params.lxsjOn}
  413. </if>
  414. <if test="params != null and params.lxsjOff != null">
  415. AND P.LXSJ &lt;= #{params.lxsjOff}
  416. </if>
  417. <if test="params != null and params.isSign == 1">
  418. AND T1.ID is not null
  419. </if>
  420. <if test="params != null and params.isSign == 0">
  421. AND T1.ID is null
  422. </if>
  423. <if test="params != null and params.xmmc != null and params.xmmc != ''">
  424. <bind name="xmmc" value="'%'+params.xmmc+'%'"/>
  425. AND P.XMMC LIKE #{xmmc}
  426. </if>
  427. <if test="params != null and params.xmbh != null and params.xmbh != ''">
  428. <bind name="xmbh" value="'%'+params.xmbh+'%'"/>
  429. AND P.XMBH LIKE #{xmbh}
  430. </if>
  431. <if test="params != null and params.userId != null and params.userId != ''">
  432. AND PW.WORKER_ID = #{params.userId}
  433. </if>
  434. <if test="params != null and params.userList != null and params.userList.size > 0">
  435. AND PW.WORKER_ID in
  436. <foreach collection="params.userList" item="item" open="(" close=")" separator=",">
  437. #{item}
  438. </foreach>
  439. </if>
  440. <if test="params != null and params.deptId != null and params.deptId != ''">
  441. AND P.ZRBM_ID = #{params.deptId}
  442. </if>
  443. <if test="params != null and params.xmjlId != null and params.xmjlId != ''">
  444. AND P.XMJL_ID = #{params.xmjlId}
  445. </if>
  446. </where>
  447. ORDER BY
  448. <choose>
  449. <when test="params != null and params.sortType == 2 ">
  450. YSSJ
  451. </when>
  452. <otherwise>
  453. LXSJ
  454. </otherwise>
  455. </choose>
  456. DESC
  457. </select>
  458. </mapper>