water-design-const-service/water-design-const/src/main/resources/mapper/ModelMapper.xml

162 lines
5.6 KiB
XML
Raw Normal View History

2025-07-11 13:29:48 +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.waterdesign.mapper.ModelMapper">
2025-07-22 09:21:28 +08:00
<insert id="addModel" >
2025-07-11 13:29:48 +08:00
insert into tb_model(
2025-07-22 09:21:28 +08:00
<if test="projectId != null ">project_id,</if>
2025-07-11 13:29:48 +08:00
<if test="modelName != null and modelName != ''">model_name,</if>
<if test="modelUrl != null and modelUrl != ''">model_url,</if>
<if test="fileName != null and fileName != ''">file_name,</if>
<if test="version != null and version != ''">version,</if>
<if test="designer != null and designer != ''">designer,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="modelType != null and modelType != ''">model_type,</if>
<if test="modelIds != null and modelIds != ''">model_ids,</if>
<if test="createBy != null and createBy != ''">create_user,</if>
create_time
)values(
2025-07-22 09:21:28 +08:00
<if test="projectId != null ">#{projectId},</if>
2025-07-11 13:29:48 +08:00
<if test="modelName != null and modelName != ''">#{modelName},</if>
<if test="modelUrl != null and modelUrl != ''">#{modelUrl},</if>
<if test="fileName != null and fileName != ''">#{fileName},</if>
<if test="version != null and version != ''">#{version},</if>
<if test="designer != null and designer != ''">#{designer},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="modelType != null and modelType != ''">#{modelType},</if>
<if test="modelIds != null and modelIds != ''">#{modelIds},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
2025-07-17 10:52:41 +08:00
<insert id="insert" parameterType="PeojectNodes">
2025-07-15 13:05:18 +08:00
INSERT INTO project_node
<trim prefix="(" suffix=")" suffixOverrides=",">
2025-07-17 10:52:41 +08:00
id,
<if test="projectId != null and projectId != ''">project_id,</if>
<if test="parentId != null and parentId != ''">parent_id,</if>
2025-07-15 13:05:18 +08:00
<if test="proName != null and proName != ''">node_name,</if>
<if test="level != null and level != ''">level,</if>
<if test="nodeCount != null and nodeCount != ''">node_count,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
2025-07-17 10:52:41 +08:00
#{id},
<if test="projectId != null and projectId != ''">#{projectId},</if>
<if test="parentId != null and parentId != ''">#{parentId},</if>
2025-07-15 13:05:18 +08:00
<if test="proName != null and proName != ''">#{proName},</if>
<if test="level != null and level != ''">#{level},</if>
<if test="nodeCount != null and nodeCount != ''">#{nodeCount},</if>
</trim>
</insert>
2025-07-17 10:52:41 +08:00
2025-07-15 13:05:18 +08:00
<update id="deleteById">
2025-07-17 10:52:41 +08:00
update project_node set del_flag = 1
2025-07-15 13:05:18 +08:00
where id = #{id}
</update>
<update id="update">
update project_node
<set>
<if test="projectId != null and projectId != 0">project_id = #{projectId},</if>
<if test="proName != null and proName != ''">node_name = #{proName},</if>
<if test="level != null and level != ''">level = #{level},</if>
<if test="nodeCount != null and nodeCount != ''">node_count = #{nodeCount},</if>
</set>
</update>
<resultMap type="ProjectVo" id="SysProjectVoResult">
2025-07-17 10:52:41 +08:00
<id property="projectId" column="project_id" />
2025-07-15 13:05:18 +08:00
<result property="id" column="id" />
2025-07-17 10:52:41 +08:00
<result property="proName" column="pro_name"/>
2025-07-22 09:21:28 +08:00
<result property="proName" column="pro_name"/>
2025-07-17 10:52:41 +08:00
<result property="proType" column="pro_type"/>
<result property="unitName" column="unit_name"/>
<result property="userName" column="user_name"/>
<result property="proLocation" column="pro_location"/>
<result property="level" column="config_id"/>
<result property="levelName" column="config_name"/>
<result property="parentId" column="parent_id"/>
<result property="nodelevel" column="node_level"/>
<result property="nodeCountDetail" column="node_count_detail"/>
2025-07-22 09:21:28 +08:00
<result property="nodeCount" column="node_count"/>
2025-07-17 10:52:41 +08:00
<result property="nodeName" column="node_name"/>
<result property="nodeId" column="node_id"/>
<result property="modelUrl" column="model_url"/>
2025-07-15 13:05:18 +08:00
<!-- 子表节点信息 -->
2025-07-17 10:52:41 +08:00
<!-- <collection property="nodes" ofType="PeojectNodes"
select="selectNodesByConfigId" column="id"/>-->
2025-07-15 13:05:18 +08:00
</resultMap>
<select id="selectNodesByConfigId" resultType="PeojectNodes">
SELECT
id,
node_name AS proName,
level,
project_id as projectId,
2025-07-17 10:52:41 +08:00
parent_id as parentId,
2025-07-15 13:05:18 +08:00
node_count as nodeCount
FROM
project_node
WHERE
project_id = #{id} and del_flag = 0
</select>
<select id="list" resultMap="SysProjectVoResult">
SELECT
2025-07-17 10:52:41 +08:00
n.id AS id,
n.parent_id,
p.id AS project_id,
2025-07-15 13:05:18 +08:00
p.pro_name,
2025-07-17 10:52:41 +08:00
p.level,
2025-07-22 09:21:28 +08:00
c.config_name,
2025-07-15 13:05:18 +08:00
(
SELECT COUNT(*)
FROM sys_level_node n
WHERE n.config_id = c.config_id
2025-07-17 10:52:41 +08:00
) AS node_count,
n.id as node_id,
n.node_name,
n.level AS node_level,
n.node_count AS node_count_detail,
m.model_url
2025-07-15 13:05:18 +08:00
FROM tb_project p
LEFT JOIN sys_level_config c ON p.level = c.config_id
2025-07-17 10:52:41 +08:00
LEFT JOIN project_node n ON p.id = n.project_id AND n.del_flag = '0'
LEFT JOIN (
SELECT t1.*
FROM tb_model t1
INNER JOIN (
SELECT project_id, MAX(id) AS max_id
FROM tb_model
GROUP BY project_id
) t2 ON t1.project_id = t2.project_id AND t1.id = t2.max_id
2025-07-22 09:21:28 +08:00
) m ON m.project_id = n.id
2025-07-17 10:52:41 +08:00
2025-07-15 13:05:18 +08:00
WHERE p.del_flag = '0'
2025-07-29 18:19:01 +08:00
<if test="projectId != null and projectId != ''">
AND p.id = #{projectId}
2025-07-25 17:52:29 +08:00
</if>
2025-07-22 09:21:28 +08:00
</select>
<select id="openView" resultType="com.bonus.waterdesign.domain.CadData">
SELECT
id,
layer_name AS layerName,
entity_type AS entityType,
color,
lineweight,
thickness,
transparency,
start_point AS startPoint,
end_point AS endPoint,
center_point AS centerPoint,
radius,
points,
geometry
FROM
cad_data
WHERE
project_id = #{id}
2025-07-11 13:29:48 +08:00
</select>
</mapper>