Files
spdm-backend/project/src/main/resources/mapper/SimulationNodeMapper.xml
2025-10-17 16:44:46 +08:00

541 lines
21 KiB
XML

<?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.sdm.project.dao.SimulationNodeMapper">
<insert id="addNodeBatch" useGeneratedKeys="true" keyProperty="id">
insert into simulation_node
(uuid,nodeName,nodeCode,englishName,nodeType,nodeSubType,nodeStatus,parentId,folderId,nodeLevel,beginTime,endTime,finishTime,progress,
achieveStatus,nodeVersion,tenantId,description,detailImgUrl,creator,create_time,tag1,tag2,tag3,tag4,tag5,tag6,tag7,tag8,tag9,tag10)
values
<foreach collection='addNodeList' item='addNode' index='index' separator=','>
(#{addNode.uuid},#{addNode.nodeName},#{addNode.nodeCode},'',#{addNode.nodeType},#{addNode.nodeSubType},'0',#{addNode.pid},
'',1,#{addNode.beginTime},#{addNode.endTime},'',#{addNode.progressStatus},#{addNode.achieveStatus},'1',#{addNode.tenantId},#{addNode.description},
#{addNode.detailImgUrl},#{addNode.creator},#{addNode.createTime},#{addNode.Tag1},#{addNode.Tag2},
#{addNode.Tag3},#{addNode.Tag4},#{addNode.Tag5},#{addNode.Tag6},#{addNode.Tag7},#{addNode.Tag8},#{addNode.Tag9},#{addNode.Tag10})
</foreach>
</insert>
<insert id="addNodeMemberBatch">
insert into simulation_node_member (nodeId,identity,name,user_id,creator,create_time) values
<foreach collection='addNodeMemberList' item='addNodeMember' index='index' separator=','>
(#{addNodeMember.nodeId},#{addNodeMember.identity},#{addNodeMember.name},#{addNodeMember.userId},#{addNodeMember.creator},#{addNodeMember.createTime})
</foreach>
</insert>
<insert id="addNodeExtraBatch">
insert into simulation_node_extra
(nodeId,propertyName,propertyValue,valueType,propertyClass,creator,create_time) values
<foreach collection='addNodeExtraList' item='addNodeExtra' index='index' separator=','>
(#{addNodeExtra.nodeId},#{addNodeExtra.propertyName},#{addNodeExtra.propertyValue},#{addNodeExtra.valueType},#{addNodeExtra.propertyClass},#{addNodeExtra.creator},#{addNodeExtra.createTime})
</foreach>
</insert>
<update id="editNode">
update simulation_node
<trim prefix="set" suffixOverrides=",">
<if test="editNode.nodeName != null and editNode.nodeName != ''">
nodeName = #{editNode.nodeName},
</if>
<if test="editNode.nodeCode != null and editNode.nodeCode != ''">
nodeCode = #{editNode.nodeCode},
</if>
<if test="editNode.nodeSubType != null and editNode.nodeSubType != ''">
nodeSubType = #{editNode.nodeSubType},
</if>
<if test="editNode.beginTime != null and editNode.beginTime != ''">
beginTime = #{editNode.beginTime},
</if>
<if test="editNode.endTime != null and editNode.endTime != ''">
endTime = #{editNode.endTime},
</if>
<if test="editNode.description != null and editNode.description != ''">
description = #{editNode.description},
</if>
<if test="editNode.detailImgUrl != null and editNode.detailImgUrl != ''">
detailImgUrl = #{editNode.detailImgUrl}
</if>
<if test="editNode.exeStatus != null and editNode.exeStatus != ''">
exe_status = #{editNode.exeStatus}
</if>
<if test="editNode.updater != null and editNode.updater != ''">
updater = #{editNode.updater},
</if>
<if test="editNode.updateTime != null and editNode.updateTime != ''">
update_time = #{editNode.updateTime},
</if>
</trim>
where uuid = #{editNode.uuid}
</update>
<update id="editNodeMember">
update simulation_node_member
<trim prefix="set" suffixOverrides=",">
<if test="editNodeMember.identity != null and editNodeMember.identity != ''">
identity = #{editNodeMember.identity},
</if>
<if test="editNodeMember.name != null and editNodeMember.name != ''">
name = #{editNodeMember.name},
</if>
<if test="editNodeMember.updater != null and editNodeMember.updater != ''">
updater = #{editNodeMember.updater},
</if>
<if test="editNodeMember.updateTime != null and editNodeMember.updateTime != ''">
update_time = #{editNodeMember.updateTime},
</if>
</trim>
where id = #{editNodeMember.id}
</update>
<update id="editNodeExtra">
update simulation_node_extra
<trim prefix="set" suffixOverrides=",">
<if test="nodeExtra.propertyName != null and nodeExtra.propertyName != ''">
propertyName = #{nodeExtra.propertyName},
</if>
<if test="nodeExtra.propertyValue != null and nodeExtra.propertyValue != ''">
propertyValue = #{nodeExtra.propertyValue},
</if>
<if test="nodeExtra.valueType != null and nodeExtra.valueType != ''">
valueType = #{nodeExtra.valueType},
</if>
<if test="nodeExtra.propertyClass != null and nodeExtra.propertyClass != ''">
propertyClass = #{nodeExtra.propertyClass},
</if>
<if test="nodeExtra.updater != null and nodeExtra.updater != ''">
updater = #{nodeExtra.updater},
</if>
<if test="nodeExtra.updateTime != null and nodeExtra.updateTime != ''">
update_time = #{nodeExtra.updateTime},
</if>
</trim>
where id = #{nodeExtra.id}
</update>
<delete id="deleteNodeBatch">
delete from simulation_node
where uuid in (
<foreach collection='deleteNodeIdList' item='nodeId' index='index' separator=','>
#{nodeId}
</foreach>
)
</delete>
<delete id="deleteNodeMemberBatch">
delete from simulation_node_member
where nodeId in (
<foreach collection='deleteNodeIdList' item='nodeId' index='index' separator=','>
#{nodeId}
</foreach>
)
</delete>
<delete id="deleteNodeExtraBatch">
delete from simulation_node_extra
where nodeId in (
<foreach collection='deleteNodeIdList' item='nodeId' index='index' separator=','>
#{nodeId}
</foreach>
)
</delete>
<delete id="deleteTaskBatch">
delete from simulation_task
where node_id in (
<foreach collection='deleteNodeIdList' item='nodeId' index='index' separator=','>
#{nodeId}
</foreach>
)
</delete>
<delete id="deleteTaskExtraBatch">
delete from simulation_task_extra
where task_id in (
<foreach collection='taskIdList' item='taskId' index='index' separator=','>
#{taskId}
</foreach>
)
</delete>
<delete id="deleteTaskMemberBatch">
delete from simulation_task_member
where task_id in (
<foreach collection='taskIdList' item='taskId' index='index' separator=','>
#{taskId}
</foreach>
)
</delete>
<delete id="deletePerformanceBatch">
delete from simulation_performance
where id in (
<foreach collection='performanceIdList' item='performanceId' index='index' separator=','>
#{performanceId}
</foreach>
)
</delete>
<delete id="deletePerformanceExtraBatch">
delete from simulation_performance_extra
where performanceId in (
<foreach collection='performanceIdList' item='performanceId' index='index' separator=','>
#{performanceId}
</foreach>
)
</delete>
<select id="getNodeList" resultType="com.sdm.project.model.vo.SpdmNodeVo">
select * from simulation_node sn
where sn.tenantId = #{tenantId}
<if test="nodeType != null and nodeType != ''">
and sn.nodeType = #{nodeType}
</if>
<if test="nodeSubType != null and nodeSubType != ''">
and sn.nodeSubType = #{nodeSubType}
</if>
<if test="progressStatus != null">
and sn.progress = #{progressStatus}
</if>
<if test="nodeCode != null and nodeCode != ''">
and sn.nodeCode like CONCAT('%',#{nodeCode},'%')
</if>
<if test="manager != null and manager != ''">
and snm.name like CONCAT('%',#{manager},'%')
</if>
<if test="nodeName != null and nodeName != ''">
and sn.nodeName like CONCAT('%',#{nodeName},'%')
</if>
limit #{pos},#{limit}
</select>
<select id="getNodeListCount" resultType="java.lang.Integer">
select count(1) from simulation_node sn
where sn.tenantId = #{tenantId}
<if test="nodeType != null and nodeType != ''">
and sn.nodeType = #{nodeType}
</if>
<if test="nodeSubType != null and nodeSubType != ''">
and sn.nodeSubType = #{nodeSubType}
</if>
<if test="progressStatus != null">
and sn.progress = #{progressStatus}
</if>
<if test="nodeCode != null and nodeCode != ''">
and sn.nodeCode like CONCAT('%',#{nodeCode},'%')
</if>
<if test="manager != null and manager != ''">
and snm.name like CONCAT('%',#{manager},'%')
</if>
<if test="nodeName != null and nodeName != ''">
and sn.nodeName like CONCAT('%',#{nodeName},'%')
</if>
</select>
<select id="getNodeExtraListByNodeIdList" resultType="com.sdm.project.model.vo.SpdmNodeExtraVo">
SELECT
*
FROM
simulation_node_extra
WHERE
nodeId in (
<foreach collection='nodeIdList' item='nodeId' index='index' separator=','>
#{nodeId}
</foreach>
)
</select>
<select id="getNodeDetail" resultType="com.sdm.project.model.vo.SpdmNodeDetailVo">
select *,
GROUP_CONCAT(snm.name ORDER BY snm.name SEPARATOR ',') AS managers
from simulation_node sn
LEFT JOIN simulation_node_member snm ON sn.uuid = snm.nodeId
where sn.uuid = #{projectNodeId}
and sn.tenantId = #{tenantId}
GROUP BY sn.uuid limit 0,1
</select>
<select id="allList" resultType="com.sdm.project.model.po.ProjectNodePo">
select * from simulation_node
where uuid in (
<foreach collection='nodeIdList' item='nodeId' index='index' separator=','>
#{nodeId}
</foreach>
)
</select>
<select id="getTaskListByNodeIdList" resultType="com.sdm.project.model.po.TaskNodePo">
select * from simulation_task where node_id in (
<foreach collection='deleteNodeIdList' item='nodeId' index='index' separator=','>
#{nodeId}
</foreach>
)
</select>
<select id="getPerformanceListByNodeIdList" resultType="com.sdm.project.model.po.PerformanceNodePo">
select * from simulation_performance where taskId in (
<foreach collection='taskIdList' item='taskId' index='index' separator=','>
#{taskId}
</foreach>
)
</select>
<select id="getNodeMemberListByNodeIdList" resultType="com.sdm.project.model.vo.SpdmNodeMemberVo">
select * from simulation_node_member
where nodeId in (
<foreach collection='nodeIdList' item='nodeId' index='index' separator=','>
#{nodeId}
</foreach>
)
</select>
<select id="getNodeById" resultType="com.sdm.project.model.vo.SpdmNodeVo">
select *
from simulation_node
where uuid = #{projectNodeId} limit 1
</select>
<select id="getNodeListByNodeIdList" resultType="com.sdm.project.model.vo.SpdmNodeVo">
select * from simulation_node
where parentId in (
<foreach collection='nodeIdList' item='nodeId' index='index' separator=','>
#{nodeId}
</foreach>
)
</select>
<select id="getTaskMemberListByNodeIdList" resultType="com.sdm.project.model.po.TaskNodeMemberPo">
select * from simulation_task_member
where task_id in (
<foreach collection='nodeIdList' item='nodeId' index='index' separator=','>
#{nodeId}
</foreach>
)
</select>
<select id="getNodeListByIds" resultType="com.sdm.project.model.vo.SpdmNodeVo">
select * from simulation_node
where uuid in (
<foreach collection='nodeIdList' item='nodeId' index='index' separator=','>
#{nodeId}
</foreach>
)
</select>
<select id="getUserGroupProjectStatistics" resultType="com.sdm.project.model.vo.UserGroupProjectVo">
select
nm.nodeId,
nm.user_id as userId,
su.nickname,
sur.groupId
from simulation_node_member nm
LEFT JOIN sys_user su on nm.user_id = su.id
left join sys_user_group_relation sur on sur.userId = su.id
<where>
nm.user_id is not null and sur.groupId is not null
<if test="userGroupId != null">
and sur.groupId = #{userGroupId}
</if>
<if test="userId != null">
and nm.user_id = #{userId}
</if>
</where>
</select>
<select id="getUserGroupTaskCompleteStatistics"
parameterType="com.sdm.project.model.req.GetUserGroupTaskCompleteStatisticsReq"
resultType="com.sdm.project.model.vo.UserGroupTaskCompleteVo">
select task.exe_status as exeStatus,
task_member.user_id as userId,
su.nickname,
sur.groupId
from simulation_task task
left join simulation_task_member task_member on task.uuid = task_member.task_id
LEFT JOIN sys_user su on task_member.user_id = su.id
left join sys_user_group_relation sur on sur.userId = su.id
<where>
task_member.user_id is not null and sur.groupId is not null
<if test="req.userGroupId != null">
and sur.groupId = #{req.userGroupId}
</if>
<if test="req.userId != null">
and task_member.user_id = #{req.userId}
</if>
<if test="req.tag1 != null and req.tag1 !='' ">
and task.tag1 = #{req.tag1}
</if>
<if test="req.tag2 != null and req.tag2 !='' ">
and task.tag2 = #{req.tag2}
</if>
<if test="req.tag3 != null and req.tag3 !='' ">
and task.tag3 = #{req.tag3}
</if>
<if test="req.tag4 != null and req.tag4 !='' ">
and task.tag4 = #{req.tag4}
</if>
<if test="req.tag5 != null and req.tag5 !='' ">
and task.tag5 = #{req.tag5}
</if>
<if test="req.tag6 != null and req.tag6 !='' ">
and task.tag6 = #{req.tag6}
</if>
<if test="req.tag7 != null and req.tag7 !='' ">
and task.tag7 = #{req.tag7}
</if>
<if test="req.tag8 != null and req.tag8 !='' ">
and task.tag8 = #{req.tag8}
</if>
<if test="req.tag9 != null and req.tag9 !='' ">
and task.tag9 = #{req.tag9}
</if>
<if test="req.tag10 != null and req.tag10 !='' ">
and task.tag10 = #{req.tag10}
</if>
</where>
</select>
<select id="getUserGroupDifficultyStatistics"
parameterType="com.sdm.project.model.req.GetUserGroupTaskCompleteStatisticsReq"
resultType="com.sdm.project.model.vo.UserGroupDifficultyVo">
select
task.difficult,
task_member.user_id as userId,
su.nickname,
sur.groupId
from simulation_task task
left join simulation_task_member task_member on task.uuid = task_member.task_id
LEFT JOIN sys_user su on task_member.user_id = su.id
left join sys_user_group_relation sur on sur.userId = su.id
<where>
task_member.user_id is not null and sur.groupId is not null
<if test="req.userGroupId != null">
and sur.groupId = #{req.userGroupId}
</if>
<if test="req.userId != null">
and task_member.user_id = #{req.userId}
</if>
<if test="req.tag1 != null and req.tag1 !='' ">
and task.tag1 = #{req.tag1}
</if>
<if test="req.tag2 != null and req.tag2 !='' ">
and task.tag2 = #{req.tag2}
</if>
<if test="req.tag3 != null and req.tag3 !='' ">
and task.tag3 = #{req.tag3}
</if>
<if test="req.tag4 != null and req.tag4 !='' ">
and task.tag4 = #{req.tag4}
</if>
<if test="req.tag5 != null and req.tag5 !='' ">
and task.tag5 = #{req.tag5}
</if>
<if test="req.tag6 != null and req.tag6 !='' ">
and task.tag6 = #{req.tag6}
</if>
<if test="req.tag7 != null and req.tag7 !='' ">
and task.tag7 = #{req.tag7}
</if>
<if test="req.tag8 != null and req.tag8 !='' ">
and task.tag8 = #{req.tag8}
</if>
<if test="req.tag9 != null and req.tag9 !='' ">
and task.tag9 = #{req.tag9}
</if>
<if test="req.tag10 != null and req.tag10 !='' ">
and task.tag10 = #{req.tag10}
</if>
</where>
</select>
<select id="getCommonCompleteStatisticsFromTask"
parameterType="com.sdm.project.model.req.CommonGetCompleteStatisticsReq"
resultType="com.sdm.project.model.vo.CommonGetCompleteFromTaskVo">
select
task.${req.resultTagType} as tag,
node.nodeName,
task.exe_status as exeStatus
from simulation_task task
left join simulation_node node on task.${req.resultTagType} = node.uuid
<where>
1=1 and task.exe_status is not null
<if test="req.tag1 != null and req.tag1 !='' ">
and task.tag1 = #{req.tag1}
</if>
<if test="req.tag2 != null and req.tag2 !='' ">
and task.tag2 = #{req.tag2}
</if>
<if test="req.tag3 != null and req.tag3 !='' ">
and task.tag3 = #{req.tag3}
</if>
<if test="req.tag4 != null and req.tag4 !='' ">
and task.tag4 = #{req.tag4}
</if>
<if test="req.tag5 != null and req.tag5 !='' ">
and task.tag5 = #{req.tag5}
</if>
<if test="req.tag6 != null and req.tag6 !='' ">
and task.tag6 = #{req.tag6}
</if>
<if test="req.tag7 != null and req.tag7 !='' ">
and task.tag7 = #{req.tag7}
</if>
<if test="req.tag8 != null and req.tag8 !='' ">
and task.tag8 = #{req.tag8}
</if>
<if test="req.tag9 != null and req.tag9 !='' ">
and task.tag9 = #{req.tag9}
</if>
<if test="req.tag10 != null and req.tag10 !='' ">
and task.tag10 = #{req.tag10}
</if>
</where>
</select>
<select id="getCommonCompleteStatisticsFromPerformance"
parameterType="com.sdm.project.model.req.CommonGetCompleteStatisticsReq"
resultType="com.sdm.project.model.vo.CommonGetCompleteFromPerformanceVo">
select
task.${req.resultTagType} as tag,
node.nodeName,
performance.completeStatus
from simulation_performance performance
left join simulation_task task on performance.taskId = task.uuid
left join simulation_node node on task.${req.resultTagType} = node.uuid
<where>
performance.completeStatus is not null
<if test="req.tag1 != null and req.tag1 !='' ">
and task.tag1 = #{req.tag1}
</if>
<if test="req.tag2 != null and req.tag2 !='' ">
and task.tag2 = #{req.tag2}
</if>
<if test="req.tag3 != null and req.tag3 !='' ">
and task.tag3 = #{req.tag3}
</if>
<if test="req.tag4 != null and req.tag4 !='' ">
and task.tag4 = #{req.tag4}
</if>
<if test="req.tag5 != null and req.tag5 !='' ">
and task.tag5 = #{req.tag5}
</if>
<if test="req.tag6 != null and req.tag6 !='' ">
and task.tag6 = #{req.tag6}
</if>
<if test="req.tag7 != null and req.tag7 !='' ">
and task.tag7 = #{req.tag7}
</if>
<if test="req.tag8 != null and req.tag8 !='' ">
and task.tag8 = #{req.tag8}
</if>
<if test="req.tag9 != null and req.tag9 !='' ">
and task.tag9 = #{req.tag9}
</if>
<if test="req.tag10 != null and req.tag10 !='' ">
and task.tag10 = #{req.tag10}
</if>
</where>
</select>
</mapper>