smart_archives_service/bonus-admin/src/main/resources/mapper/TransferApplyMapper.xml

462 lines
13 KiB
XML
Raw Normal View History

2025-09-15 15:43:00 +08:00
<?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.bonus.web.mapper.TransferApplyMapper">
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO da_ky_transfer_apply
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="proId != null and proId != ''">
pro_id,
</if>
<if test="proName != null and proName != ''">
pro_name,
</if>
<if test="singleProName != null and singleProName != ''">
single_pro_name,
</if>
<if test="deptId != null and deptId != ''">
dept_id,
</if>
<if test="deptName != null and deptName != ''">
dept_name,
</if>
<if test="applyUser != null and applyUser != ''">
apply_user,
</if>
<if test="applyTime != null">
apply_time,
</if>
<if test="auditStatus != null and auditStatus != ''">
audit_status,
</if>
<if test="auditOpinion != null and auditOpinion != ''">
audit_opinion,
</if>
<if test="transferStatus != null and transferStatus != ''">
transfer_status,
</if>
<if test="transferTime != null and transferTime != ''">
transfer_time,
</if>
<if test="createUserId != null">
create_user_id,
</if>
<if test="createUserName != null and createUserName != ''">
create_user_name,
</if>
<if test="updateUserName != null and updateUserName != ''">
update_user_name,
</if>
<if test="updateUserId != null">
update_user_id,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="proId != null and proId != ''">
#{proId},
</if>
<if test="proName != null and proName != ''">
#{proName},
</if>
<if test="singleProName != null and singleProName != ''">
#{singleProName},
</if>
<if test="deptId != null and deptId != ''">
#{deptId},
</if>
<if test="deptName != null and deptName != ''">
#{deptName},
</if>
<if test="applyUser != null and applyUser != ''">
#{applyUser},
</if>
<if test="applyTime != null">
#{applyTime},
</if>
<if test="auditStatus != null and auditStatus != ''">
#{auditStatus},
</if>
<if test="auditOpinion != null and auditOpinion != ''">
#{auditOpinion},
</if>
<if test="transferStatus != null and transferStatus != ''">
#{transferStatus},
</if>
<if test="transferTime != null and transferTime != ''">
#{transferTime},
</if>
<if test="createUserId != null">
#{createUserId},
</if>
<if test="createUserName != null and createUserName != ''">
#{createUserName},
</if>
<if test="updateUserName != null and updateUserName != ''">
#{updateUserName},
</if>
<if test="updateUserId != null">
#{updateUserId},
</if>
</trim>
</insert>
<insert id="insertTransferFile">
INSERT INTO da_ky_transfer_file
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="transferApplyId != null">
transfer_apply_id,
</if>
<if test="proFilesContentsId != null and proFilesContentsId != ''">
pro_files_contents_id,
</if>
<if test="proId != null and proId != ''">
pro_id,
</if>
<if test="fileSourceId != null">
file_source_id,
</if>
<if test="fileName != null and fileName != ''">
file_name,
</if>
<if test="filePath != null and filePath != ''">
file_path,
</if>
<if test="transferStatus != null and transferStatus != ''">
transfer_status,
</if>
<if test="transferTime != null">
transfer_time,
</if>
<if test="receiveStatus != null and receiveStatus != ''">
receive_status,
</if>
<if test="receiveTime != null">
receive_time,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id},
</if>
<if test="transferApplyId != null">
#{transferApplyId},
</if>
<if test="proFilesContentsId != null and proFilesContentsId != ''">
#{proFilesContentsId},
</if>
<if test="proId != null and proId != ''">
#{proId},
</if>
<if test="fileSourceId != null">
#{fileSourceId},
</if>
<if test="fileName != null and fileName != ''">
#{fileName},
</if>
<if test="filePath != null and filePath != ''">
#{filePath},
</if>
<if test="transferStatus != null and transferStatus != ''">
#{transferStatus},
</if>
<if test="transferTime != null">
#{transferTime},
</if>
<if test="receiveStatus != null and receiveStatus != ''">
#{receiveStatus},
</if>
<if test="receiveTime != null">
#{receiveTime},
</if>
</trim>
</insert>
2025-09-16 17:30:53 +08:00
<insert id="addTransferAuditRecord">
INSERT INTO da_ky_transfer_audit_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
transfer_apply_id,
</if>
<if test="auditStatus != null and auditStatus != ''">
audit_status,
</if>
<if test="auditOpinion != null and auditOpinion != ''">
audit_option,
</if>
<if test="auditUser != null">
audit_user_id,
</if>
<if test="auditUserName != null and auditUserName != ''">
audit_user_name,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id},
</if>
<if test="auditStatus != null and auditStatus != ''">
#{auditStatus},
</if>
<if test="auditOpinion != null and auditOpinion != ''">
#{auditOpinion},
</if>
<if test="auditUser != null">
#{auditUser},
</if>
<if test="auditUserName != null and auditUserName != ''">
#{auditUserName},
</if>
</trim>
</insert>
2025-09-15 15:43:00 +08:00
<update id="edit">
UPDATE da_ky_transfer_apply
<set>
<if test="proId != null and proId != ''">
pro_id = #{proId},
</if>
<if test="proName != null and proName != ''">
pro_name = #{proName},
</if>
<if test="singleProName != null and singleProName != ''">
single_pro_name = #{singleProName},
</if>
<if test="deptId != null and deptId != ''">
dept_id = #{deptId},
</if>
<if test="deptName != null and deptName != ''">
dept_name = #{deptName},
</if>
<if test="applyUser != null and applyUser != ''">
apply_user = #{applyUser},
</if>
<if test="applyTime != null">
apply_time = #{applyTime},
</if>
<if test="auditStatus != null and auditStatus != ''">
audit_status = #{auditStatus},
</if>
<if test="auditOpinion != null and auditOpinion != ''">
audit_opinion = #{auditOpinion},
</if>
<if test="transferStatus != null and transferStatus != ''">
transfer_status = #{transferStatus},
</if>
<if test="transferTime != null and transferTime != ''">
transfer_time = #{transferTime},
</if>
<if test="updateUserName != null and updateUserName != ''">
update_user_name = #{updateUserName},
</if>
<if test="updateUserId != null">
update_user_id = #{updateUserId},
</if>
<if test="delFlag != null and delFlag != ''">
del_flag = #{delFlag},
</if>
</set>
WHERE id = #{id}
</update>
2025-09-16 17:30:53 +08:00
<update id="audit">
UPDATE da_ky_transfer_apply
<set>
<if test="auditStatus != null and auditStatus != ''">
audit_status = #{auditStatus},
</if>
<if test="auditOpinion != null and auditOpinion != ''">
audit_opinion = #{auditOpinion},
</if>
</set>
WHERE id = #{id}
</update>
2025-09-15 15:43:00 +08:00
<delete id="delTransferFiles">
DELETE FROM da_ky_transfer_file
WHERE transfer_apply_id = #{id}
</delete>
<delete id="del">
DELETE FROM da_ky_transfer_apply
WHERE id = #{id}
</delete>
<select id="list" resultType="com.bonus.web.domain.TransferApplyDto">
SELECT
2025-09-19 11:10:21 +08:00
dkta.id,
dkta.pro_id AS proId,
dkta.pro_name AS proName,
dkta.single_pro_name AS singleProName,
dkta.dept_id AS deptId,
dkta.dept_name AS deptName,
dkta.apply_user AS applyUser,
dkta.apply_time AS applyTime,
dkta.audit_status AS auditStatus,
dkta.audit_opinion AS auditOpinion,
dkta.transfer_status AS transferStatus,
dkta.transfer_time AS transferTime,
dkta.create_time AS createTime,
dkta.update_time AS updateTime,
dkta.create_user_id AS createUserId,
dkta.create_user_name AS createUserName,
dkta.update_user_name AS updateUserName,
dkta.update_user_id AS updateUserId,
dkta.del_flag AS delFlag
FROM da_ky_transfer_apply dkta
left join da_ky_project dkp on dkta.pro_id = dkp.id
where dkta.del_flag = '1'
2025-09-15 15:43:00 +08:00
<if test="proId != null and proId != ''">
2025-09-19 11:10:21 +08:00
and dkta.pro_id = #{proId}
</if>
<if test="proName != null and proName != ''">
and dkta.pro_name like concat('%',#{proName},'%')
</if>
<if test="singleProName != null and singleProName != ''">
and dkta.single_pro_name like concat('%',#{singleProName},'%')
</if>
<if test="transfertTime != null and transfertTime != ''">
and DATE(dkta.transfer_time) = #{transfertTime}
</if>
<if test="deptId != null and deptId != ''">
and dkta.dept_id = #{deptId}
2025-09-15 15:43:00 +08:00
</if>
2025-09-19 11:10:21 +08:00
<if test="proType != null and proType != ''">
and dkp.pro_type = #{proType}
</if>
<if test="voltageLevel != null and voltageLevel != ''">
and dkp.voltage_level = #{voltageLevel}
</if>
<if test="auditStatus != null and auditStatus != ''">
and dkta.audit_status = #{auditStatus}
</if>
ORDER BY dkta.create_time DESC
2025-09-15 15:43:00 +08:00
</select>
<select id="getTransferApply" resultType="com.bonus.web.domain.TransferApplyDto">
SELECT
dept_name AS deptName,
pro_name AS proName,
apply_user AS applyUser,
apply_time AS applyTime,
audit_user AS auditUser,
audit_time AS auditTime,
audit_opinion AS auditOpinion,
case audit_status when '0' then '待审批'
when '1' then '审批通过'
when '2' then '审批驳回'
else '' end AS auditStatus
FROM da_ky_transfer_apply
where del_flag = '1' and id = #{id}
</select>
2025-09-18 17:12:08 +08:00
<select id="getProSelect" resultType="com.bonus.web.domain.SelectDto">
SELECT
id,
2025-09-19 13:57:10 +08:00
single_pro_name AS name
2025-09-18 17:12:08 +08:00
FROM
da_ky_project
WHERE
del_flag = '1' and file_status = '1'
</select>
2025-09-15 15:43:00 +08:00
<select id="getTransferFile" resultType="com.bonus.web.domain.TransferFileDto">
SELECT
dkp.pro_name AS proName,
dkp.single_pro_name AS singleProName,
dktf.file_name AS fileName
FROM da_ky_transfer_file dktf
left join da_ky_project dkp on dkp.id = dktf.pro_id
where dktf.transfer_apply_id = #{id}
</select>
2025-09-18 17:12:08 +08:00
<select id="getDeptSelect" resultType="com.bonus.common.core.domain.entity.SysDept">
2025-09-18 17:27:49 +08:00
SELECT dept_id AS deptId,
parent_id AS parentId,
ancestors,
dept_name AS deptName,
order_num AS orderNum,
leader,
phone,
email,
status,
del_flag AS delFlag
FROM da_ky_sys_dept
WHERE del_flag = '0'
and status = '0'
</select>
2025-09-19 11:10:21 +08:00
<select id="getTransferApplyFilesContents" resultType="java.lang.String">
WITH RECURSIVE sub_tree AS (
SELECT
id,
pro_id,
level
FROM da_ky_pro_files_contents
WHERE id = #{id}
2025-09-19 13:57:10 +08:00
AND pro_id = #{proId}
2025-09-19 11:10:21 +08:00
UNION ALL
SELECT
c.id,
c.pro_id,
c.level
FROM da_ky_pro_files_contents c
INNER JOIN sub_tree st ON c.parent_id = st.id
WHERE c.level &lt;= 4
2025-09-19 13:57:10 +08:00
AND c.pro_id = #{proId}
2025-09-19 11:10:21 +08:00
)
SELECT DISTINCT id
FROM sub_tree
WHERE level = 4
ORDER BY id
</select>
<select id="getTransferApplyFiles" resultType="com.bonus.web.domain.DaKyProFilesContentsDto">
2025-09-19 14:24:28 +08:00
SELECT distinct
2025-09-19 11:10:21 +08:00
dkpfc.id AS id,
dkpfc.pro_id AS proId,
dkpfc.content_name AS contentName,
dkpfc.parent_id AS parentId,
dkpfc.LEVEL AS LEVEL,
dkpfc.sort AS sort,
dkpfc.mark_code AS markCode,
dkpfc.term AS term,
2025-09-19 11:30:40 +08:00
concat(dkpfc3.content_name,'/',dkpfc2.content_name) AS parParentName,
2025-09-19 11:31:02 +08:00
dkpfc1.content_name AS parentName,
2025-09-19 11:10:21 +08:00
dkpfc.unit_name AS unitName,
CASE
WHEN dkpfc.data_source = '1' THEN
'本系统上传'
WHEN dkpfc.data_source = '2' THEN
'智慧现场' ELSE ''
END AS dataSource,
dkpfc.is_unique AS isUnique,
dkpfc.integrity_status AS integrityStatus,
dkfs.id AS fileId,
dkfs.file_name AS fileName,
2025-09-19 13:20:12 +08:00
dkfs.file_path AS filePath,
2025-09-19 11:10:21 +08:00
dkfs.create_time AS createTime,
dkfs.source_file_name AS sourceFileName,
dkfs.create_user_name AS createUserName
FROM
da_ky_pro_files_contents dkpfc
2025-09-19 11:30:40 +08:00
left join da_ky_pro_files_contents dkpfc1 on dkpfc.parent_id = dkpfc1.id
left join da_ky_pro_files_contents dkpfc2 on dkpfc1.parent_id = dkpfc2.id
left join da_ky_pro_files_contents dkpfc3 on dkpfc2.parent_id = dkpfc3.id
2025-09-19 11:10:21 +08:00
LEFT JOIN da_ky_sys_file_source dkfs ON dkpfc.id = dkfs.business_id
LEFT JOIN da_ky_transfer_file fs ON dkfs.id = fs.file_source_id
WHERE
dkpfc.del_flag = '1'
AND dkpfc.parent_id = #{parentId}
AND dkpfc.pro_id = #{proId}
AND dkpfc.LEVEL = 5
AND NOT EXISTS ( SELECT 1 FROM da_ky_transfer_file tf WHERE tf.file_source_id = dkfs.id )
</select>
2025-09-19 13:20:12 +08:00
<select id="getTransferRecordFiles" resultType="com.bonus.web.domain.TransferFileDto">
</select>
2025-09-19 14:24:28 +08:00
<select id="getProNameById" resultType="java.lang.String">
SELECT
pro_name AS proName
FROM
da_ky_project
WHERE
id = #{id}
</select>
2025-09-15 15:43:00 +08:00
</mapper>