xiangpei
2025-04-23 c1a9747777ea9aee817f306475c94031e5559cc4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?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.ycl.mapper.ProjectProcessMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" 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="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="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" />
        <result column="build_content" property="buildContent" />
    </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, build_content  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, TPE.build_content 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,TT.build_content,
            (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">
        SELECT
            TPP.project_id,
            TPP.process_def_id,
            TPP.id
        FROM
            t_project_process TPP
        WHERE
            TPP.id = #{id} AND TPP.deleted = 0
    </select>
 
 
    <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>
            AND PI.used_status = 2 AND PI.deleted = 0
            <if test="query.projectName != null and query.projectName != ''">
                AND PI.project_name like concat('%', #{query.projectName}, '%')
            </if>
            <if test="query.projectCode != null and query.projectCode != ''">
                AND PI.project_code like concat('%', #{query.projectCode}, '%')
            </if>
            ${query.params.dataScope}
        </where>
        ORDER BY PI.gmt_create ASC
    </select>
 
 
    <select id="getProjectInfo" parameterType="string" resultType="com.ycl.domain.entity.ProjectInfo">
        SELECT
               PI.id, PI.project_name
        FROM
             t_project_process PP
                 INNER JOIN t_project_info PI ON PP.project_id = PI.id AND PI.deleted = 0 AND PP.process_ins_id = #{processInsId}
    </select>
 
 
    <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 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>
 
    <resultMap id="flowableVarVOResultMap" type="com.ycl.domain.vo.FlowableVarVO">
        <id property="ID_" column="ID_"/>
        <result property="PROC_INST_ID_" column="PROC_INST_ID_"/>
        <result property="EXECUTION_ID_" column="EXECUTION_ID_"/>
        <result property="NAME_" column="NAME_"/>
        <result property="VAR_TYPE_" column="VAR_TYPE_"/>
        <result property="BYTEARRAY_ID_" column="BYTEARRAY_ID_"/>
        <result property="DOUBLE_" column="DOUBLE_"/>
        <result property="LONG_" column="LONG_"/>
        <result property="TEXT_" column="TEXT_"/>
        <result property="TEXT2_" column="TEXT2_"/>
        <result property="CREATE_TIME_" column="CREATE_TIME_"/>
        <result property="LAST_UPDATED_TIME_" column="LAST_UPDATED_TIME_"/>
    </resultMap>
 
    <select id="getHisByteId" resultMap="flowableVarVOResultMap">
        SELECT ID_, PROC_INST_ID_, EXECUTION_ID_, NAME_, VAR_TYPE_, BYTEARRAY_ID_ FROM act_hi_varinst WHERE PROC_INST_ID_ = #{processInsId} AND NAME_ = #{keyName}
    </select>
 
    <select id="getRuByteId" resultMap="flowableVarVOResultMap">
        SELECT ID_, PROC_INST_ID_, EXECUTION_ID_, NAME_, TYPE_ as VAR_TYPE_, BYTEARRAY_ID_ FROM act_ru_variable WHERE PROC_INST_ID_ = #{processInsId} AND NAME_ = #{keyName}
    </select>
 
 
    <insert id="insertHisFlowableVar" parameterType="com.ycl.domain.vo.FlowableVarVO">
        insert into act_hi_varinst(ID_,REV_, PROC_INST_ID_, EXECUTION_ID_, NAME_, VAR_TYPE_,BYTEARRAY_ID_,DOUBLE_,LONG_, TEXT_, CREATE_TIME_, LAST_UPDATED_TIME_)
        values (#{v.ID_}, 0,  #{v.PROC_INST_ID_}, #{v.EXECUTION_ID_}, #{v.NAME_}, #{v.VAR_TYPE_}, #{v.BYTEARRAY_ID_}, #{v.DOUBLE_}, #{v.LONG_}, #{v.TEXT_}, #{v.CREATE_TIME_}, #{v.LAST_UPDATED_TIME_})
    </insert>
 
    <insert id="insertRunFlowableVar" parameterType="com.ycl.domain.vo.FlowableVarVO">
        insert into act_ru_variable(ID_,REV_, PROC_INST_ID_, EXECUTION_ID_, NAME_, TYPE_,BYTEARRAY_ID_,DOUBLE_,LONG_, TEXT_)
        values (#{v.ID_}, 1,  #{v.PROC_INST_ID_}, #{v.EXECUTION_ID_}, #{v.NAME_}, #{v.VAR_TYPE_}, #{v.BYTEARRAY_ID_}, #{v.DOUBLE_}, #{v.LONG_}, #{v.TEXT_})
    </insert>
 
    <insert id="insertByteArray">
        insert into act_ge_bytearray(ID_, REV_, NAME_, BYTES_) values (#{id_}, #{rev_}, #{name_}, #{bytes_, jdbcType=BLOB})
    </insert>
 
    <delete id="deleteByteArray" parameterType="string">
        DELETE FROM act_ge_bytearray WHERE ID_ = #{id}
    </delete>
 
    <delete id="deleteRunFlowableVar" parameterType="string">
        DELETE FROM act_ru_variable WHERE ID_ = #{id}
    </delete>
 
    <delete id="deleteHisFlowableVar" parameterType="string">
        DELETE FROM act_hi_varinst WHERE ID_ = #{id}
    </delete>
 
</mapper>