From 203acef84d19ffc01bc8d5dd8ef85f90ba400f5c Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期日, 09 三月 2025 11:49:58 +0800
Subject: [PATCH] 容缺查询

---
 business/src/main/resources/mapper/ProjectProcessMapper.xml |  103 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 96 insertions(+), 7 deletions(-)

diff --git a/business/src/main/resources/mapper/ProjectProcessMapper.xml b/business/src/main/resources/mapper/ProjectProcessMapper.xml
index 80450e4..5008916 100644
--- a/business/src/main/resources/mapper/ProjectProcessMapper.xml
+++ b/business/src/main/resources/mapper/ProjectProcessMapper.xml
@@ -9,17 +9,14 @@
         <result column="project_code" property="projectCode" />
         <result column="content" property="content" />
         <result column="project_type" property="projectType" />
+        <result column="investmentAmount" property="investmentAmount" />
         <result column="project_status" property="projectStatus" />
         <result column="fund_type" property="fundType" />
         <result column="invest_type" property="investType" />
         <result column="project_phase" property="projectPhase" />
         <result column="tag" property="tag" />
-<!--        <result column="competent_department" property="competentDepartment" />-->
-<!--        <result column="management_centralization" property="managementCentralization" />-->
         <result column="project_approval_type" property="projectApprovalType" />
         <result column="importance_type" property="importanceType" />
-<!--        <result column="year" property="year" />-->
-<!--        <result column="year_invest_amount" property="yearInvestAmount" />-->
         <result column="create_project_time" property="createProjectTime" />
         <result column="plan_start_time" property="planStartTime" />
         <result column="plan_complete_time" property="planCompleteTime" />
@@ -34,10 +31,96 @@
         <result column="create_by" property="createBy" />
         <result column="process_def_id" property="processDefId" />
         <result column="process_ins_id" property="processInsId" />
-<!--        <association property="id" column=""-->
     </resultMap>
 
+    <resultMap id="PageResultMap" type="com.ycl.domain.vo.ProjectProcessVO">
+        <id column="id" property="id"/>
+        <result column="project_name" property="projectName" />
+        <result column="project_code" property="projectCode" />
+        <result column="content" property="content" />
+        <result column="project_type" property="projectType" />
+        <result column="investmentAmount" property="investmentAmount" />
+        <result column="project_status" property="projectStatus" />
+        <result column="fund_type" property="fundType" />
+        <result column="invest_type" property="investType" />
+        <result column="project_phase" property="projectPhase" />
+        <result column="tag" property="tag" />
+        <result column="project_approval_type" property="projectApprovalType" />
+        <result column="importance_type" property="importanceType" />
+        <result column="create_project_time" property="createProjectTime" />
+        <result column="plan_start_time" property="planStartTime" />
+        <result column="plan_complete_time" property="planCompleteTime" />
+        <result column="project_address" property="projectAddress" />
+        <result column="longitude" property="longitude" />
+        <result column="latitude" property="latitude" />
+        <result column="project_owner_unit" property="projectOwnerUnit" />
+        <result column="project_owner_unit_name" property="projectOwnerUnitName" />
+        <result column="project_contact_person" property="projectContactPerson" />
+        <result column="competent_department" property="competentDepartment" />
+        <result column="competent_department_name" property="competentDepartmentName" />
+        <result column="contact" property="contact" />
+        <result column="update_by" property="updateBy" />
+        <result column="create_by" property="createBy" />
+        <result column="process_def_id" property="processDefId" />
+        <result column="process_ins_id" property="processInsId" />
+    </resultMap>
 
+    <resultMap id="EngineeringMap" type="com.ycl.domain.vo.ProjectEngineeringVO">
+        <id column="id" property="id"/>
+        <result column="project_name" property="projectName" />
+        <result column="project_type" property="projectType" />
+        <result column="investment_amount" property="investmentAmount" />
+        <result column="status" property="status" />
+        <result column="unit" property="projectOwnerUnit" />
+        <result column="department" property="competentDepartment" />
+        <result column="year" property="year" />
+        <result column="parent_id" property="parent" />
+        <result column="project_owner_unit_name" property="projectOwnerUnitName" />
+        <result column="competent_department_name" property="competentDepartmentName" />
+        <result column="process_ins_id" property="processInsId" />
+        <result column="process_def_id" property="processDefId" />
+    </resultMap>
+
+    <select id="getProjectEngineeringList" parameterType="string" resultMap="EngineeringMap">
+        SELECT  TPE.project_info_id,
+                TPE.project_name,
+                TPE.project_type,
+                TPE.investment_amount,
+                TPE.status,
+                TPE.id,
+                TPE.unit,
+                TPE.department,
+                TPE.parent_id,
+                TPE.year,
+                (SELECT  SD.dept_name FROM sys_dept SD WHERE SD.dept_id = TPE.unit) AS unit_name,
+                (SELECT  SD.dept_name FROM sys_dept SD WHERE SD.dept_id = TPE.department) AS department_name
+        FROM t_project_engineering TPE
+                 INNER JOIN t_project_info TPI ON TPI.id = TPE.project_info_id AND TPI.deleted = 0
+        WHERE
+              TPE.parent_id = #{id} and TPE.deleted = 0
+        ORDER BY
+                 TPE.gmt_create
+    </select>
+
+    <select id="getEngineeringList" parameterType="long" resultMap="EngineeringMap">
+        WITH RECURSIVE temp_table AS (
+            SELECT
+                id, project_info_id, project_name, project_type, investment_amount, status, unit, department, parent_id, year, gmt_create  FROM t_project_engineering WHERE project_info_id = #{projectId} AND parent_id = '0' AND deleted = 0
+            UNION ALL
+            SELECT
+                TPE.id, TPE.project_info_id, TPE.project_name, TPE.project_type, TPE.investment_amount, TPE.status, TPE.unit, TPE.department, TPE.parent_id, TPE.year, TPE.gmt_create FROM t_project_engineering TPE INNER JOIN temp_table tb ON TPE.parent_id = tb.id AND TPE.deleted = 0
+        )
+        SELECT
+            TT.id, TT.project_info_id, TT.project_name, TT.project_type, TT.investment_amount, TT.status, TT.unit, TT.department, TT.parent_id, TT.year, TT.gmt_create,
+            (SELECT  SD.dept_name FROM sys_dept SD WHERE SD.dept_id = TT.unit) AS project_owner_unit_name,
+            (SELECT  SD.dept_name FROM sys_dept SD WHERE SD.dept_id = TT.department) AS competent_department_name,
+            TPP.process_ins_id, TPP.process_def_id
+        FROM
+            temp_table TT
+                LEFT JOIN t_project_process TPP ON TPP.project_id = TT.id AND TPP.deleted = 0 AND TPP.project_type = 'ENGINEERING'
+        ORDER BY
+            TT.gmt_create DESC
+    </select>
 
 
     <select id="getById" resultMap="BaseResultMap">
@@ -52,14 +135,18 @@
     </select>
 
 
-    <select id="getPage" resultMap="BaseResultMap">
+    <select id="getPage" resultMap="PageResultMap">
         SELECT
             PI.*,
             TPP.process_def_id,
             TPP.process_ins_id,
+            TPIF.total_investment as investmentAmount,
+            (SELECT  SD.dept_name FROM sys_dept SD WHERE SD.dept_id = PI.project_owner_unit) AS project_owner_unit_name,
+            (SELECT  SD.dept_name FROM sys_dept SD WHERE SD.dept_id = PI.competent_department) AS competent_department_name,
             d.dept_name as project_owner_unit_name
         FROM
             t_project_info PI
+                LEFT JOIN t_project_investment_funding TPIF ON TPIF.project_id = PI.id AND TPIF.deleted = 0
                 LEFT JOIN t_project_process TPP ON TPP.project_id = PI.id AND TPP.deleted = 0
                 LEFT JOIN sys_dept d ON d.dept_id = PI.project_owner_unit
         <where>
@@ -86,7 +173,9 @@
 
 
     <select id="getNormalInsIds" resultType="string">
-        SELECT TPP.process_ins_id FROM t_project_info TPI INNER JOIN t_project_process TPP ON TPI.id = TPP.project_id AND TPI.deleted = 0
+        SELECT TPP.process_ins_id FROM t_project_info TPI INNER JOIN t_project_process TPP ON TPI.id = TPP.project_id AND TPI.deleted = 0 AND TPP.project_type = 'PROJECT'
+        UNION ALL
+        SELECT TPP.process_ins_id FROM t_project_engineering TPE INNER JOIN t_project_process TPP ON TPE.id = TPP.project_id AND TPE.deleted = 0 AND TPP.project_type = 'ENGINEERING'
     </select>
 
 </mapper>

--
Gitblit v1.8.0