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

193 lines
6.3 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.bonus.waterdesign.mapper.ModelMapper">
<insert id="addModel" >
insert into tb_model(
<if test="projectId != null ">project_id,</if>
<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(
<if test="projectId != null ">#{projectId},</if>
<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>
<insert id="insert" parameterType="PeojectNodes">
INSERT INTO project_node
<trim prefix="(" suffix=")" suffixOverrides=",">
id,
<if test="projectId != null and projectId != ''">project_id,</if>
<if test="parentId != null and parentId != ''">parent_id,</if>
<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>
create_time
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
#{id},
<if test="projectId != null and projectId != ''">#{projectId},</if>
<if test="parentId != null and parentId != ''">#{parentId},</if>
<if test="proName != null and proName != ''">#{proName},</if>
<if test="level != null and level != ''">#{level},</if>
<if test="nodeCount != null and nodeCount != ''">#{nodeCount},</if>
sysdate()
</trim>
</insert>
<update id="deleteById">
update project_node set del_flag = 1
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">
<id property="projectId" column="project_id" />
<result property="id" column="id" />
<result property="proName" column="pro_name"/>
<result property="proName" column="pro_name"/>
<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"/>
<result property="nodeCount" column="node_count"/>
<result property="nodeName" column="node_name"/>
<result property="nodeId" column="node_id"/>
<result property="modelUrl" column="model_url"/>
<!-- 子表节点信息 -->
<!-- <collection property="nodes" ofType="PeojectNodes"
select="selectNodesByConfigId" column="id"/>-->
</resultMap>
<select id="selectNodesByConfigId" resultType="PeojectNodes">
SELECT
id,
node_name AS proName,
level,
project_id as projectId,
parent_id as parentId,
node_count as nodeCount
FROM
project_node
WHERE
project_id = #{id} and del_flag = 0
</select>
<select id="list" resultMap="SysProjectVoResult">
SELECT
n.id AS id,
n.parent_id,
p.id AS project_id,
p.pro_name,
p.level,
p.lon,
p.lat,
c.config_name,
c.level 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
FROM project_node n
LEFT JOIN tb_project p ON p.id = n.project_id AND n.del_flag = '0'
LEFT JOIN sys_level_config c ON p.level = c.config_id
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
) m ON m.project_id = n.id
WHERE p.del_flag = '0'
<if test="projectId != null and projectId != ''">
AND p.id = #{projectId}
</if>
order by n.create_time
</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}
</select>
<select id="openAllView" 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,
project_id as nodeId
FROM cad_data
WHERE project_id IN
<foreach item="projectId" index="index" collection="ids" open="(" separator="," close=")">
#{projectId}
</foreach>
</select>
<select id="getNodes" resultType="java.lang.String">
SELECT
id
FROM
project_node
WHERE
project_id = #{projectId} and del_flag = 0 and node_count = level
</select>
</mapper>