123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.zjugis.business.mapper.ProjectMapper">
- <select id="calculate" resultType="com.zjugis.business.bean.response.ProjectCalculateResponse">
- SELECT COALESCE(SUM(COALESCE(PA.VIRTUAL_AMOUNT, 0)), 0) as output,
- COALESCE(SUM(COALESCE(PA.PROJECT_COST, 0)), 0) as cost
- FROM PROJECT P
- LEFT JOIN PROJECT_AMOUNT PA on PA.PROJECT_ID = P.ID
- <if test="params != null and params.userId != null and params.userId != ''">
- LEFT JOIN PROJECT_WORKER_RELATION PW ON PW.PROJECT_ID = P.ID
- </if>
- <where>
- P.ISVALID = 1 AND P.FLOW_STATUS IN (90,99)
- <if test="params != null and params.hyId != null">
- AND P.HY_ID = #{params.hyId}
- </if>
- <if test="params != null and params.xzqdm != null and params.xzqdm != ''">
- AND P.XZQDM = #{params.xzqdm}
- </if>
- <if test="params != null and params.projectTypeId != null and params.projectTypeId != ''">
- AND P.PROJECT_TYPE_ID = #{params.projectTypeId}
- </if>
- <if test="params != null and params.xmzt != null">
- AND P.XMZT = #{params.xmzt}
- </if>
- <if test="params != null and params.lxsjOn != null">
- AND P.LXSJ >= #{params.lxsjOn}
- </if>
- <if test="params != null and params.lxsjOff != null">
- AND P.LXSJ <= #{params.lxsjOff}
- </if>
- <if test="params != null and params.isSign != null">
- AND P.IS_SIGN = #{params.isSign}
- </if>
- <if test="params != null and params.xmmc != null and params.xmmc != ''">
- <bind name="xmmc" value="'%'+params.xmmc+'%'"/>
- AND P.XMMC LIKE #{xmmc}
- </if>
- <if test="params != null and params.xmbh != null and params.xmbh != ''">
- <bind name="xmbh" value="'%'+params.xmbh+'%'"/>
- AND P.XMBH LIKE #{xmbh}
- </if>
- <if test="params != null and params.userId != null and params.userId != ''">
- AND PW.WORKER_ID = #{params.userId}
- </if>
- <if test="params != null and params.deptId != null and params.deptId != ''">
- AND P.ZRBM_ID = #{params.deptId}
- </if>
- <if test="params != null and params.xmjlId != null and params.xmjlId != ''">
- AND P.XMJL_ID = #{params.xmjlId}
- </if>
- </where>
- </select>
- <select id="selectWithChildren" resultType="com.zjugis.business.bean.response.ProjectResponse">
- SELECT P.*,D.NAME as zrbm FROM PROJECT P
- LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = P.ZRBM_ID
- WHERE P.ISVALID = 1
- START WITH P.ID = (
- SELECT ID FROM PROJECT
- WHERE ISVALID = 1 and PID is NULL
- START WITH ID = #{id}
- CONNECT BY PRIOR PID = ID
- )
- CONNECT BY PRIOR P.ID = P.PID
- </select>
- <select id="page" resultType="com.zjugis.business.bean.entity.Project">
- SELECT P.*,D.NAME as zrbm,PA.CONTRACT_AMOUNT,PA.RECEIVABLE_AMOUNT,PA.CONTRACT_BALANCE,PA.PROJECT_COST,PA.VIRTUAL_AMOUNT
- <if test="params != null and params.isRelContract != null and params.isRelContract == 1">
- ,C.contractNumber as contractNumber
- </if>
- FROM PROJECT P
- LEFT JOIN PROJECT_AMOUNT PA ON PA.PROJECT_ID = P.ID
- LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = P.ZRBM_ID
- <if test="params != null and params.isRelContract != null and params.isRelContract == 1">
- LEFT JOIN (SELECT PID,count(1) as ccount FROM PROJECT WHERE FLOW_STATUS = 99 GROUP BY PID) CH ON CH.PID = P.ID
- 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
- </if>
- <if test="params != null and params.userId != null and params.userId != ''">
- LEFT JOIN PROJECT_WORKER_RELATION PW ON PW.PROJECT_ID = P.ID
- </if>
- <if test="params != null and params.userId == null and params.userList != null and params.userList.size > 0">
- LEFT JOIN PROJECT_WORKER_RELATION PW ON PW.PROJECT_ID = P.ID
- </if>
- <where>
- P.ISVALID = 1 AND P.FLOW_STATUS IN (90,99)
- <if test="params != null and params.hyId != null">
- AND P.HY_ID = #{params.hyId}
- </if>
- <if test="params != null and params.xzqdm != null and params.xzqdm != ''">
- AND P.XZQDM = #{params.xzqdm}
- </if>
- <if test="params != null and params.projectTypeId != null and params.projectTypeId != ''">
- AND P.PROJECT_TYPE_ID = #{params.projectTypeId}
- </if>
- <if test="params != null and params.xmzt != null">
- AND P.XMZT = #{params.xmzt}
- </if>
- <if test="params != null and params.lxsjOn != null">
- AND P.LXSJ >= #{params.lxsjOn}
- </if>
- <if test="params != null and params.lxsjOff != null">
- AND P.LXSJ <= #{params.lxsjOff}
- </if>
- <if test="params != null and params.isSign != null">
- AND P.IS_SIGN = #{params.isSign}
- </if>
- <if test="params != null and params.xmmc != null and params.xmmc != ''">
- <bind name="xmmc" value="'%'+params.xmmc+'%'"/>
- AND P.XMMC LIKE #{xmmc}
- </if>
- <if test="params != null and params.xmbh != null and params.xmbh != ''">
- <bind name="xmbh" value="'%'+params.xmbh+'%'"/>
- AND P.XMBH LIKE #{xmbh}
- </if>
- <if test="params != null and params.userId != null and params.userId != ''">
- AND PW.WORKER_ID = #{params.userId}
- </if>
- <if test="params != null and params.userList != null and params.userList.size > 0">
- AND PW.WORKER_ID in
- <foreach collection="params.userList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="params != null and params.deptId != null and params.deptId != ''">
- AND P.ZRBM_ID = #{params.deptId}
- </if>
- <if test="params != null and params.xmjlId != null and params.xmjlId != ''">
- AND P.XMJL_ID = #{params.xmjlId}
- </if>
- </where>
- ORDER BY
- <choose>
- <when test="params != null and params.sortType == 2 ">
- YSSJ
- </when>
- <otherwise>
- LXSJ
- </otherwise>
- </choose>
- DESC
- </select>
- <select id="costSum" resultType="com.zjugis.business.bean.response.SumResponse">
- select
- nvl(sum(a.xmzcb), 0) as xmzcb,
- nvl(sum(ct.htje * a.czjd / 100), 0) as xmzcz,
- nvl(nvl(sum(ct.htje * a.czjd / 100), 0)- nvl(sum(a.xmzcb), 0),0) as xmlr
- from PROJECT p
- left join (select nvl(sum(c.htje), 0) as htje, cp.project_id
- from contract c
- left join contract_project cp
- on cp.contract_id = c.contract_id
- group by cp.project_id) ct
- on ct.project_id = p.project_id
- left join (select t.project_id as project_id,
- nvl(sum(t.payment_cost), 0) as xmzcb,
- max(t.output_progress) as czjd
- from PROJECT_COST t
- where to_char(t.rq, 'yyyy') = '{time}'
- group by t.project_id) a
- on a.project_id = p.project_id
- where p.isvalid = 1
- </select>
- <select id="selectChildrenOutputValue" resultType="java.math.BigDecimal">
- select nvl(sum(nvl(OUTPUT_VALUE,0)), 0) from PROJECT where PID = #{pid,jdbcType=VARCHAR} and ISVALID = 1
- </select>
- <select id="selectChildrenIds" resultType="java.lang.String">
- SELECT ID FROM PROJECT WHERE PID = #{projectId,jdbcType=VARCHAR} AND ISVALID = 1 and FLOW_STATUS = 99
- </select>
- <select id="countXmzt" resultType="com.zjugis.business.bean.response.ProjectXmztCountResponse">
- SELECT
- count(1) as total,
- SUM(CASE WHEN P.XMZT = 1 THEN 1 ELSE 0 END) as process,
- SUM(CASE WHEN P.XMZT = 2 THEN 1 ELSE 0 END) as finished,
- SUM(CASE WHEN P.XMZT = 3 THEN 1 ELSE 0 END) as terminated,
- SUM(CASE WHEN P.XMZT = 4 THEN 1 ELSE 0 END) as accepted
- FROM PROJECT P
- <if test="params != null and params.userId != null and params.userId != ''">
- LEFT JOIN PROJECT_WORKER_RELATION PW ON PW.PROJECT_ID = P.ID
- </if>
- <where>
- P.ISVALID = 1 AND P.FLOW_STATUS IN (90,99)
- <if test="params != null and params.hyId != null">
- AND P.HY_ID = #{params.hyId}
- </if>
- <if test="params != null and params.xzqdm != null and params.xzqdm != ''">
- AND P.XZQDM = #{params.xzqdm}
- </if>
- <if test="params != null and params.projectTypeId != null and params.projectTypeId != ''">
- AND P.PROJECT_TYPE_ID = #{params.projectTypeId}
- </if>
- <if test="params != null and params.xmzt != null">
- AND P.XMZT = #{params.xmzt}
- </if>
- <if test="params != null and params.lxsjOn != null">
- AND P.LXSJ >= #{params.lxsjOn}
- </if>
- <if test="params != null and params.lxsjOff != null">
- AND P.LXSJ <= #{params.lxsjOff}
- </if>
- <if test="params != null and params.isSign != null">
- AND P.IS_SIGN = #{params.isSign}
- </if>
- <if test="params != null and params.xmmc != null and params.xmmc != ''">
- <bind name="xmmc" value="'%'+params.xmmc+'%'"/>
- AND P.XMMC LIKE #{xmmc}
- </if>
- <if test="params != null and params.xmbh != null and params.xmbh != ''">
- <bind name="xmbh" value="'%'+params.xmbh+'%'"/>
- AND P.XMBH LIKE #{xmbh}
- </if>
- <if test="params != null and params.userId != null and params.userId != ''">
- AND PW.WORKER_ID = #{params.userId}
- </if>
- <if test="params != null and params.deptId != null and params.deptId != ''">
- AND P.ZRBM_ID = #{params.deptId}
- </if>
- </where>
- </select>
- <update id="updateChildXmzt">
- UPDATE PROJECT SET XMZT = #{xmzt,jdbcType=INTEGER} WHERE PID = #{projectId,jdbcType=VARCHAR} AND FLOW_STATUS = 99
- </update>
- <select id="selectCountInfo" resultType="com.zjugis.business.bean.dto.CountInfo">
- SELECT
- COALESCE(SUM(CASE WHEN T.LXSJ >= #{start,jdbcType=DATE} THEN 1 ELSE 0 END),0) as xl,
- COALESCE(SUM(CASE WHEN T.LXSJ <= #{end,jdbcType=DATE} AND XMZT = 1 THEN 1 ELSE 0 END),0) as jz,
- COALESCE(SUM(CASE WHEN T1.ID IS NULL THEN 1 ELSE 0 END),0) as haveContract,
- COALESCE(SUM(CASE WHEN T1.ID IS NOT NULL THEN 1 ELSE 0 END),0) as noContract,
- COALESCE(SUM(CASE WHEN T.XMZT = 4 THEN 1 ELSE 0 END),0) as accepted,
- COALESCE(SUM(CASE WHEN T.XMZT = 1 THEN 1 ELSE 0 END),0) as unaccepted
- FROM PROJECT T
- LEFT JOIN CONTRACT T1 ON T1.PROJECT_ID = T.ID AND T1.FLOW_STATUS = 90 AND T1.ISVALID = 1
- WHERE T.ISVALID = 1 AND T.FLOW_STATUS = 90
- <if test="params != null and params.deptIds != null and params.deptIds.size > 0">
- AND T.ZRBM_ID in
- <foreach collection="params.deptIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="selectAmountInfo" resultType="com.zjugis.business.bean.dto.AmountInfo">
- SELECT
- count(1) as total,
- COALESCE(SUM(CASE WHEN T1.CONTRACT_AMOUNT < 1000000 THEN 1 ELSE 0 END),0) as lt100,
- COALESCE(SUM(CASE WHEN T1.CONTRACT_AMOUNT >= 1000000 and T1.CONTRACT_AMOUNT < 2000000 THEN 1 ELSE 0 END),0) as lt200,
- COALESCE(SUM(CASE WHEN T1.CONTRACT_AMOUNT >= 2000000 and T1.CONTRACT_AMOUNT < 3000000 THEN 1 ELSE 0 END),0) as lt300,
- COALESCE(SUM(CASE WHEN T1.CONTRACT_AMOUNT >= 3000000 and T1.CONTRACT_AMOUNT < 4000000 THEN 1 ELSE 0 END),0) as lt400,
- COALESCE(SUM(CASE WHEN T1.CONTRACT_AMOUNT >= 4000000 THEN 1 ELSE 0 END),0) as gte400
- FROM PROJECT T
- LEFT JOIN CONTRACT T1 ON T1.PROJECT_ID = T.ID AND T1.FLOW_STATUS = 90 AND T1.ISVALID = 1
- WHERE T.ISVALID = 1 AND T.FLOW_STATUS = 90
- <if test="params != null and params.deptIds != null and params.deptIds.size > 0">
- AND T.ZRBM_ID in
- <foreach collection="params.deptIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="selectProcessInfo" resultType="com.zjugis.business.bean.dto.ProcessInfo">
- SELECT
- count(1) as total,
- COALESCE(SUM(CASE WHEN T1.process > 75 THEN 1 ELSE 0 END),0) as gt75,
- COALESCE(SUM(CASE WHEN T1.process > 50 and T1.process <= 75 THEN 1 ELSE 0 END),0) as gt50,
- COALESCE(SUM(CASE WHEN T1.process > 25 and T1.process <= 50 THEN 1 ELSE 0 END),0) as gt25,
- COALESCE(SUM(CASE WHEN T1.process > 10 and T1.process <= 25 THEN 1 ELSE 0 END),0) as gt10,
- COALESCE(SUM(CASE WHEN T1.process < 10 THEN 1 ELSE 0 END),0) as lte10
- FROM PROJECT T
- LEFT JOIN(
- SELECT MAX(TO_NUMBER(REPLACE(PROCESS, '%' ,''))) as process,PROJECT_ID FROM PROJECT_MILESTONE
- WHERE STATE = 1 AND ISVALID = 1
- GROUP BY PROJECT_ID
- ) T1 ON T1.PROJECT_ID = T.ID
- WHERE T.ISVALID = 1 AND T.FLOW_STATUS = 90
- <if test="params != null and params.deptIds != null and params.deptIds.size > 0">
- AND T.ZRBM_ID in
- <foreach collection="params.deptIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="selectAllIds" resultType="java.lang.String">
- SELECT ID FROM PROJECT
- WHERE ISVALID = 1 AND FLOW_STATUS IN (90,99) and XMZT IN (1,4)
- </select>
- <select id="contractExist" resultType="com.zjugis.business.bean.entity.Contract">
- SELECT ID,INSTANCE_ID,FLOW_STATUS,ISVALID FROM CONTRACT
- WHERE PROJECT_ID = #{projectId,jdbcType=VARCHAR}
- </select>
- <select id="getList" resultType="com.zjugis.business.bean.entity.Project">
- SELECT P.*,D.NAME as zrbm,PA.CONTRACT_AMOUNT,PA.RECEIVABLE_AMOUNT,PA.CONTRACT_BALANCE,PA.PROJECT_COST,PA.VIRTUAL_AMOUNT
- <if test="params != null and params.isRelContract != null and params.isRelContract == 1">
- ,C.contractNumber as contractNumber
- </if>
- FROM PROJECT P
- LEFT JOIN PROJECT_AMOUNT PA ON PA.PROJECT_ID = P.ID
- LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = P.ZRBM_ID
- <if test="params != null and params.isRelContract != null and params.isRelContract == 1">
- LEFT JOIN (SELECT PID,count(1) as ccount FROM PROJECT WHERE FLOW_STATUS = 99 GROUP BY PID) CH ON CH.PID = P.ID
- 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
- </if>
- <if test="params != null and params.userId != null and params.userId != ''">
- LEFT JOIN PROJECT_WORKER_RELATION PW ON PW.PROJECT_ID = P.ID
- </if>
- <where>
- P.ISVALID = 1 AND P.FLOW_STATUS IN (90,99)
- <if test="params != null and params.hyId != null">
- AND P.HY_ID = #{params.hyId}
- </if>
- <if test="params != null and params.xzqdm != null and params.xzqdm != ''">
- AND P.XZQDM = #{params.xzqdm}
- </if>
- <if test="params != null and params.projectTypeId != null and params.projectTypeId != ''">
- AND P.PROJECT_TYPE_ID = #{params.projectTypeId}
- </if>
- <if test="params != null and params.xmzt != null">
- AND P.XMZT = #{params.xmzt}
- </if>
- <if test="params != null and params.lxsjOn != null">
- AND P.LXSJ >= #{params.lxsjOn}
- </if>
- <if test="params != null and params.lxsjOff != null">
- AND P.LXSJ <= #{params.lxsjOff}
- </if>
- <if test="params != null and params.isSign != null">
- AND P.IS_SIGN = #{params.isSign}
- </if>
- <if test="params != null and params.xmmc != null and params.xmmc != ''">
- <bind name="xmmc" value="'%'+params.xmmc+'%'"/>
- AND P.XMMC LIKE #{xmmc}
- </if>
- <if test="params != null and params.xmbh != null and params.xmbh != ''">
- <bind name="xmbh" value="'%'+params.xmbh+'%'"/>
- AND P.XMBH LIKE #{xmbh}
- </if>
- <if test="params != null and params.userId != null and params.userId != ''">
- AND PW.WORKER_ID = #{params.userId}
- </if>
- <if test="params != null and params.deptId != null and params.deptId != ''">
- AND P.ZRBM_ID = #{params.deptId}
- </if>
- <if test="params != null and params.xmjlId != null and params.xmjlId != ''">
- AND P.XMJL_ID = #{params.xmjlId}
- </if>
- </where>
- ORDER BY
- <choose>
- <when test="params != null and params.sortType == 2 ">
- YSSJ
- </when>
- <otherwise>
- LXSJ
- </otherwise>
- </choose>
- DESC
- </select>
- </mapper>
|