ProjectMapper.xml 18 KB

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