Ver código fonte

合同添加查询子合同已经金额改为虚拟合同额

chenjun 8 meses atrás
pai
commit
37d16139f4

+ 4 - 0
zjugis-business/src/main/java/com/zjugis/business/mapper/ContractMapper.java

@@ -76,4 +76,8 @@ public interface ContractMapper extends BaseMapperX<Contract> {
     default List<Contract> selectByProjectIds(Set<String> ids){
         return selectList(new LambdaQueryWrapperX<Contract>().eq(Contract::getFlowStatus,90).in(Contract::getProjectId,ids));
     }
+
+    ProjectAmount calcDept(@Param("params") ContractDto contractDto);
+
+    Page<Contract> pageDept(Page<Contract> page, @Param("params")ContractDto contractDto);
 }

+ 2 - 2
zjugis-business/src/main/java/com/zjugis/business/service/impl/ContractServiceImpl.java

@@ -197,7 +197,7 @@ public class ContractServiceImpl implements ContractService{
             Set<String> deptIds = respDTO.getDeptIds();
             contractDto.setDeptIds(deptIds);
         }
-        ProjectAmount sum = contractMapper.calc(contractDto);
+        ProjectAmount sum = contractMapper.calcDept(contractDto);
         return sum;
     }
 
@@ -376,7 +376,7 @@ public class ContractServiceImpl implements ContractService{
             Set<String> deptIds = respDTO.getDeptIds();
             contractDto.setDeptIds(deptIds);
         }
-        return  contractMapper.page(page, contractDto);
+        return  contractMapper.pageDept(page, contractDto);
     }
 
     @Override

+ 192 - 14
zjugis-business/src/main/resources/mapper/oracle/ContractMapper.xml

@@ -536,7 +536,7 @@
     <select id="returnGroupBySegment" resultType="com.zjugis.business.bean.dto.ManageSegmentDto">
         select COALESCE(SUM(COALESCE(t2.RETURN_AMOUNT,0)),0) as returnAmount,D.SEGMENT
         FROM CONTRACT_RETURN_MONEY t2
-        RIGHT JOIN CONTRACT t1 on t2.CONTRACT_ID = t1.ID and t1.ISVALID = 1 and t1.FLOW_STATUS = 90
+        RIGHT JOIN CONTRACT t1 on t2.CONTRACT_ID = t1.ID and t1.ISVALID = 1 and (t1.FLOW_STATUS = 90 OR t1.FLOW_STATUS = 99)
         LEFT JOIN PROJECT pr ON pr.ID = t1.PROJECT_ID
         LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = pr.ZRBM_ID
         <where>
@@ -549,12 +549,12 @@
     </select>
 
     <select id="signGroupBySegment" resultType="com.zjugis.business.bean.dto.ManageSegmentDto">
-        SELECT NVL(SUM(c.CONTRACT_AMOUNT), 0) as signAmount,D.SEGMENT
+        SELECT NVL(SUM(c.VIRTUAL_AMOUNT), 0) as signAmount,D.SEGMENT
         FROM CONTRACT c
         RIGHT JOIN PROJECT pr ON pr.ID = c.PROJECT_ID
         LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = pr.ZRBM_ID
         <where>
-            c.ISVALID = 1 AND c.FLOW_STATUS = 90 and D.SEGMENT is not null
+            c.ISVALID = 1 AND (c.FLOW_STATUS = 90 or c.FLOW_STATUS = 99) and D.SEGMENT is not null
             <if test="year != null and year != ''">
                 AND TO_CHAR(c.CONTRACT_OFF,'YYYY') = #{year,jdbcType=VARCHAR}
             </if>
@@ -563,12 +563,12 @@
     </select>
 
     <select id="newGroupBySegment" resultType="com.zjugis.business.bean.dto.ManageSegmentDto">
-        SELECT NVL(SUM(C.CONTRACT_AMOUNT), 0) AS newAmount,D.SEGMENT
+        SELECT NVL(SUM(C.VIRTUAL_AMOUNT), 0) AS newAmount,D.SEGMENT
         FROM CONTRACT c
         RIGHT JOIN PROJECT pr ON pr.ID = c.PROJECT_ID
         LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = pr.ZRBM_ID
         <where>
-            c.ISVALID = 1 AND c.FLOW_STATUS = 90 and D.SEGMENT is not null
+            c.ISVALID = 1 AND (c.FLOW_STATUS = 90 or c.FLOW_STATUS = 99) and D.SEGMENT is not null
             <if test="year != null and year != ''">
                 AND TO_CHAR(c.CONTRACT_ON,'YYYY') = #{year,jdbcType=VARCHAR}
             </if>
@@ -579,7 +579,7 @@
     <select id="amountBySegment" resultType="com.zjugis.business.bean.dto.ManageSegmentDto">
         SELECT D.SEGMENT,
         COALESCE(SUM(COALESCE(PA.invoiceAmount - PA.returnAmount,0)),0) as receivableAmount,
-        COALESCE(SUM(COALESCE(c.CONTRACT_AMOUNT,0)),0) - COALESCE(SUM(COALESCE(PA.invoiceAmount,0)),0) as contractBalance
+        COALESCE(SUM(COALESCE(c.VIRTUAL_AMOUNT,0)),0) - COALESCE(SUM(COALESCE(PA.invoiceAmount,0)),0) as contractBalance
         FROM CONTRACT c
         LEFT JOIN (
         SELECT CONTRACT_ID,
@@ -590,7 +590,7 @@
         ) PA on PA.CONTRACT_ID = c.ID
         RIGHT JOIN PROJECT pr ON pr.ID = c.PROJECT_ID
         LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = pr.ZRBM_ID
-        where c.ISVALID = 1 AND c.FLOW_STATUS = 90 and D.SEGMENT is not null
+        where c.ISVALID = 1 AND (c.FLOW_STATUS = 90 or c.FLOW_STATUS = 99) and D.SEGMENT is not null
         group by D.SEGMENT
     </select>
 
@@ -598,7 +598,7 @@
         select D.ID as deptId,
         COALESCE(SUM(COALESCE(t2.RETURN_AMOUNT,0)),0) as returnAmount
         FROM CONTRACT_RETURN_MONEY t2
-        RIGHT JOIN CONTRACT t1 on t2.CONTRACT_ID = t1.ID and t1.ISVALID = 1 and t1.FLOW_STATUS = 90
+        RIGHT JOIN CONTRACT t1 on t2.CONTRACT_ID = t1.ID and t1.ISVALID = 1 and (t1.FLOW_STATUS = 90 OR t1.FLOW_STATUS = 99)
         LEFT JOIN PROJECT pr ON pr.ID = t1.PROJECT_ID
         LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = pr.ZRBM_ID
         <where>
@@ -612,12 +612,12 @@
 
     <select id="signGroupByDept" resultType="com.zjugis.business.bean.dto.ManageDeptDto">
         SELECT D.ID as deptId,
-        NVL(SUM(c.CONTRACT_AMOUNT), 0) as signAmount
+        NVL(SUM(c.VIRTUAL_AMOUNT), 0) as signAmount
         FROM CONTRACT c
         RIGHT JOIN PROJECT pr ON pr.ID = c.PROJECT_ID
         LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = pr.ZRBM_ID
         <where>
-            c.ISVALID = 1 AND c.FLOW_STATUS = 90 and D.ID is not null
+            c.ISVALID = 1 AND (c.FLOW_STATUS = 90 or c.FLOW_STATUS = 99) and D.ID is not null
             <if test="year != null and year != ''">
                 AND TO_CHAR(c.CONTRACT_OFF,'YYYY') = #{year,jdbcType=VARCHAR}
             </if>
@@ -627,12 +627,12 @@
 
     <select id="newGroupByDept" resultType="com.zjugis.business.bean.dto.ManageDeptDto">
         SELECT D.ID as deptId,
-        NVL(SUM(C.CONTRACT_AMOUNT), 0) AS newAmount
+        NVL(SUM(C.VIRTUAL_AMOUNT), 0) AS newAmount
         FROM CONTRACT c
         RIGHT JOIN PROJECT pr ON pr.ID = c.PROJECT_ID
         LEFT JOIN ZJUGIS_OA.SYSTEM_DEPT D ON D.ID = pr.ZRBM_ID
         <where>
-            c.ISVALID = 1 AND c.FLOW_STATUS = 90 and D.ID is not null
+            c.ISVALID = 1 AND (c.FLOW_STATUS = 90 or c.FLOW_STATUS = 99) and D.ID is not null
             <if test="year != null and year != ''">
                 AND TO_CHAR(c.CONTRACT_ON,'YYYY') = #{year,jdbcType=VARCHAR}
             </if>
@@ -643,7 +643,7 @@
     <select id="amountByDept" resultType="com.zjugis.business.bean.dto.ManageDeptDto">
         SELECT D.ID as deptId, MAX(D.NAME) as deptName,
                COALESCE(SUM(COALESCE(PA.invoiceAmount - PA.returnAmount,0)),0) as receivableAmount,
-               COALESCE(SUM(COALESCE(c.CONTRACT_AMOUNT,0)),0) - COALESCE(SUM(COALESCE(PA.invoiceAmount,0)),0) as contractBalance,
+               COALESCE(SUM(COALESCE(c.VIRTUAL_AMOUNT,0)),0) - COALESCE(SUM(COALESCE(PA.invoiceAmount,0)),0) as contractBalance,
                COALESCE(MAX(SU.mc),0)+(SELECT COUNT(*) FROM ZJUGIS_OA.SYSTEM_USERS WHERE DEPT_IDS like '%'||D.ID||'%' and DELETED = 0 AND STATUS = 0) as memberCount
         FROM CONTRACT c
                  LEFT JOIN (
@@ -660,7 +660,7 @@
               WHERE DELETED = 0 AND STATUS = 0 AND DEPT_ID IS NOT NULL
               GROUP BY DEPT_ID
             ) SU ON SU.DEPT_ID = D.ID
-        where c.ISVALID = 1 AND c.FLOW_STATUS = 90 and D.ID is not null
+        where c.ISVALID = 1 AND (c.FLOW_STATUS = 90 or c.FLOW_STATUS = 99) and D.ID is not null
         GROUP BY D.ID
     </select>
 
@@ -715,4 +715,182 @@
         select sum(VIRTUAL_AMOUNT) as amount from CONTRACT c
         where parent_id=#{parentId} and c.ISVALID = 1 AND c.FLOW_STATUS IN (90,99)
     </select>
+    <select id="calcDept" resultType="com.zjugis.business.bean.entity.ProjectAmount">
+        SELECT  COALESCE(SUM(COALESCE(c.VIRTUAL_AMOUNT,0)),0) as contractAmount,
+        COALESCE(SUM(COALESCE(PA.invoiceAmount,0)),0) as invoiceAmount,
+        COALESCE(SUM(COALESCE(PA.returnAmount,0)),0) as returnAmount,
+        COALESCE(SUM(COALESCE(PA.invoiceAmount - PA.returnAmount,0)),0) as receivableAmount,
+        COALESCE(SUM(COALESCE(c.VIRTUAL_AMOUNT,0)),0) - COALESCE(SUM(COALESCE(PA.invoiceAmount,0)),0) as contractBalance
+        FROM CONTRACT c
+        LEFT JOIN (
+        SELECT CONTRACT_ID,
+        COALESCE(SUM(COALESCE(INVOICE_AMOUNT,0)),0) as invoiceAmount,
+        COALESCE(SUM(COALESCE(RETURN_AMOUNT,0)),0) as returnAmount
+        FROM CONTRACT_INVOICE_RELATION WHERE ISVALID = 1
+        GROUP BY CONTRACT_ID
+        ) PA on PA.CONTRACT_ID = c.ID
+        <if test="params != null and params.deptIds != null and params.deptIds.size > 0">
+            RIGHT JOIN PROJECT pr ON pr.ID = c.PROJECT_ID
+        </if>
+        <where>
+            c.ISVALID = 1 AND (c.FLOW_STATUS = 90 or c.FLOW_STATUS = 99)
+            <if test="params != null and params.projectId != null and params.projectId != ''">
+                AND c.PROJECT_ID = #{params.projectId}
+            </if>
+            <if test="params != null and params.signWay != null">
+                AND c.SIGN_WAY = #{params.signWay}
+            </if>
+            <if test="params != null and params.mainType != null">
+                AND c.MAIN_TYPE = #{params.mainType}
+            </if>
+            <if test="params != null and params.secondType != null">
+                AND c.SECOND_TYPE = #{params.secondType}
+            </if>
+            <if test="params != null and params.clientId != null and params.clientId != ''">
+                AND c.CLIENT_ID = #{params.clientId}
+            </if>
+            <if test="params != null and params.assigneeId != null and params.assigneeId != ''">
+                AND c.ASSIGNEE_ID = #{params.assigneeId}
+            </if>
+            <if test="params != null and params.amountStatus != null">
+                AND c.AMOUNT_STATUS = #{params.amountStatus}
+            </if>
+            <if test="params != null and params.contractOnStart != null">
+                AND c.CONTRACT_ON &gt;= #{params.contractOnStart}
+            </if>
+            <if test="params != null and params.contractOnEnd != null">
+                AND c.CONTRACT_ON &lt;= #{params.contractOnEnd}
+            </if>
+            <if test="params != null and params.contractOffStart != null">
+                AND c.CONTRACT_OFF &gt;= #{params.contractOffStart}
+            </if>
+            <if test="params != null and params.contractOffEnd != null">
+                AND c.CONTRACT_OFF &lt;= #{params.contractOffEnd}
+            </if>
+            <if test="params != null and params.signTimeStart != null">
+                AND c.SIGN_TIME &gt;= #{params.signTimeStart}
+            </if>
+            <if test="params != null and params.signTimeEnd != null">
+                AND c.SIGN_TIME &lt;= #{params.signTimeEnd}
+            </if>
+            <if test="params != null and params.dueTimeStart != null">
+                AND c.DUE_TIME &gt;= #{params.dueTimeStart}
+            </if>
+            <if test="params != null and params.dueTimeEnd != null">
+                AND c.DUE_TIME &lt;= #{params.dueTimeEnd}
+            </if>
+            <if test="params != null and params.isSign != null">
+                AND c.IS_SIGN = #{params.isSign}
+            </if>
+            <if test="params != null and params.name != null and params.name != ''">
+                <bind name="name" value="'%'+params.name+'%'"/>
+                AND c."NAME" LIKE #{name}
+            </if>
+            <if test="params != null and params.contractNumber != null and params.contractNumber != ''">
+                <bind name="contractNumber" value="'%'+params.contractNumber+'%'"/>
+                AND c.CONTRACT_NUMBER LIKE #{contractNumber}
+            </if>
+            <if test="params != null and params.hasReceivableAmount == 1">
+                AND c.RECEIVABLE_AMOUNT &gt; 0
+            </if>
+            <if test="params != null and params.managerId != null  and params.managerId != ''">
+                AND c.AREA_MANAGER_ID = #{params.managerId}
+            </if>
+            <if test="params != null and params.deptIds != null and params.deptIds.size > 0">
+                AND pr.ZRBM_ID  in
+                <foreach collection="params.deptIds" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+
+    </select>
+    <select id="pageDept" resultType="com.zjugis.business.bean.entity.Contract">
+        SELECT c.*,COALESCE(PA.invoiceAmount,0) as invoiceAmount,
+        COALESCE(PA.returnAmount,0) as returnAmount,
+        (COALESCE(PA.invoiceAmount,0) - COALESCE(PA.returnAmount,0)) as receivableAmount,
+        (COALESCE(c.VIRTUAL_AMOUNT,0) - COALESCE(pa.invoiceAmount,0)) as contractBalance FROM CONTRACT c
+        LEFT JOIN (
+        SELECT CONTRACT_ID,
+        COALESCE(SUM(COALESCE(INVOICE_AMOUNT,0)),0) as invoiceAmount,
+        COALESCE(SUM(COALESCE(RETURN_AMOUNT,0)),0) as returnAmount
+        FROM CONTRACT_INVOICE_RELATION WHERE ISVALID = 1
+        GROUP BY CONTRACT_ID
+        ) PA on PA.CONTRACT_ID = c.ID
+        <if test="params != null and params.deptIds != null and params.deptIds.size > 0">
+            LEFT JOIN PROJECT pr ON pr.ID = c.PROJECT_ID
+        </if>
+        <where>
+            c.ISVALID = 1 AND (c.FLOW_STATUS = 90 or c.FLOW_STATUS = 99)
+            <if test="params != null and params.projectId != null and params.projectId != ''">
+                AND c.PROJECT_ID = #{params.projectId}
+            </if>
+            <if test="params != null and params.signWay != null">
+                AND c.SIGN_WAY = #{params.signWay}
+            </if>
+            <if test="params != null and params.mainType != null">
+                AND c.MAIN_TYPE = #{params.mainType}
+            </if>
+            <if test="params != null and params.secondType != null">
+                AND c.SECOND_TYPE = #{params.secondType}
+            </if>
+            <if test="params != null and params.clientId != null and params.clientId != ''">
+                AND c.CLIENT_ID = #{params.clientId}
+            </if>
+            <if test="params != null and params.assigneeId != null and params.assigneeId != ''">
+                AND c.ASSIGNEE_ID = #{params.assigneeId}
+            </if>
+            <if test="params != null and params.amountStatus != null">
+                AND c.AMOUNT_STATUS = #{params.amountStatus}
+            </if>
+            <if test="params != null and params.contractOnStart != null">
+                AND c.CONTRACT_ON &gt;= #{params.contractOnStart}
+            </if>
+            <if test="params != null and params.contractOnEnd != null">
+                AND c.CONTRACT_ON &lt;= #{params.contractOnEnd}
+            </if>
+            <if test="params != null and params.contractOffStart != null">
+                AND c.CONTRACT_OFF &gt;= #{params.contractOffStart}
+            </if>
+            <if test="params != null and params.contractOffEnd != null">
+                AND c.CONTRACT_OFF &lt;= #{params.contractOffEnd}
+            </if>
+            <if test="params != null and params.signTimeStart != null">
+                AND c.SIGN_TIME &gt;= #{params.signTimeStart}
+            </if>
+            <if test="params != null and params.signTimeEnd != null">
+                AND c.SIGN_TIME &lt;= #{params.signTimeEnd}
+            </if>
+            <if test="params != null and params.dueTimeStart != null">
+                AND c.DUE_TIME &gt;= #{params.dueTimeStart}
+            </if>
+            <if test="params != null and params.dueTimeEnd != null">
+                AND c.DUE_TIME &lt;= #{params.dueTimeEnd}
+            </if>
+            <if test="params != null and params.isSign != null">
+                AND c.IS_SIGN = #{params.isSign}
+            </if>
+            <if test="params != null and params.name != null and params.name != ''">
+                <bind name="name" value="'%'+params.name+'%'"/>
+                AND c."NAME" LIKE #{name}
+            </if>
+            <if test="params != null and params.contractNumber != null and params.contractNumber != ''">
+                <bind name="contractNumber" value="'%'+params.contractNumber+'%'"/>
+                AND c.CONTRACT_NUMBER LIKE #{contractNumber}
+            </if>
+            <if test="params != null and params.hasReceivableAmount == 1">
+                AND c.RECEIVABLE_AMOUNT &gt; 0
+            </if>
+            <if test="params != null and params.managerId != null  and params.managerId != ''">
+                AND c.AREA_MANAGER_ID = #{params.managerId}
+            </if>
+            <if test="params != null and params.deptIds != null and params.deptIds.size > 0">
+                AND pr.ZRBM_ID  in
+                <foreach collection="params.deptIds" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+        ORDER BY c.CONTRACT_ON DESC NULLS LAST,c.CREATE_TIME DESC NULLS LAST,c.ID
+    </select>
 </mapper>