2024-09-13 18:06:19 +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.base.mapper.TbProjectMapper">
|
|
|
|
|
<delete id="deleteById">
|
|
|
|
|
update tb_project set del_flag = '1' where id = #{id}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<select id="queryByPage" resultType="com.bonus.base.vo.TbProjectVo">
|
|
|
|
|
select
|
|
|
|
|
tb.id as id, tb.pro_name as proName, tb.depart_id as departId, tpd.depart_name as departName, tb.rel_id as
|
|
|
|
|
relId, sda.dict_label as relName, tb.pro_type as proType,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN tb.pro_type = 1 THEN '变电工程'
|
|
|
|
|
WHEN tb.pro_type = 2 THEN '线路工程'
|
|
|
|
|
ELSE '电缆工程'
|
|
|
|
|
END AS proTypeName,
|
|
|
|
|
tb.pro_status AS proStatus,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN tb.pro_status = 0 THEN '施工'
|
|
|
|
|
ELSE '暂停'
|
|
|
|
|
END AS proStatusName,
|
|
|
|
|
tb.area_id as areaId, ta.area_name as areaName,
|
|
|
|
|
tb.lon as lon, tb.lat as lat, tb.del_flag as delFlag, count(tpp.pro_id) as powerTotal
|
|
|
|
|
from tb_project tb
|
|
|
|
|
left join tb_pro_depart tpd on tb.depart_id = tpd.id
|
|
|
|
|
left join tb_area ta on tb.area_id = ta.id
|
|
|
|
|
left join sys_dict_data sda on tb.rel_id = sda.dict_code
|
|
|
|
|
left join tb_pro_power tpp on tpp.pro_id = tb.id and tpp.del_flag = '0'
|
|
|
|
|
where tb.del_flag = '0'
|
|
|
|
|
<if test="id != null">
|
|
|
|
|
and tb.id = #{id}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proName != null and proName != ''">
|
|
|
|
|
and tb.pro_name like concat('%',#{proName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="relId != null and relId != '' ">
|
|
|
|
|
and tb.rel_id = #{relId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="areaId != null and areaId != ''">
|
|
|
|
|
and tb.area_id = #{areaId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proType != null and proType != ''">
|
|
|
|
|
and tb.pro_type = #{proType}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="departName != null and departName != ''">
|
|
|
|
|
and tpd.depart_name like concat('%',#{departName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY tb.id
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="queryById" resultType="com.bonus.base.vo.TbProjectVo">
|
|
|
|
|
select tb.id as id,
|
|
|
|
|
tb.pro_name as proName,
|
|
|
|
|
tb.depart_id as departId,
|
|
|
|
|
tpd.depart_name as departName,
|
|
|
|
|
tb.rel_id as relId,
|
|
|
|
|
sda.dict_label as relName,
|
|
|
|
|
tb.pro_type as proType,
|
|
|
|
|
tb.pro_status as proStatus,
|
|
|
|
|
tb.area_id as areaId,
|
|
|
|
|
ta.area_name as areaName,
|
|
|
|
|
tb.lon as lon,
|
|
|
|
|
tb.lat as lat,
|
|
|
|
|
tb.del_flag as delFlag,
|
|
|
|
|
count(tpp.pro_id) as powerTotal
|
|
|
|
|
from tb_project tb
|
|
|
|
|
left join tb_pro_depart tpd on tb.depart_id = tpd.id
|
|
|
|
|
left join tb_area ta on tb.area_id = ta.id
|
|
|
|
|
left join sys_dict_data sda on tb.rel_id = sda.dict_code
|
|
|
|
|
left join tb_pro_power tpp on tpp.pro_id = tb.id and tpp.del_flag = '0'
|
|
|
|
|
where tb.del_flag = '0'
|
|
|
|
|
and tb.id = #{id}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectByName" resultType="com.bonus.base.vo.TbProjectVo">
|
|
|
|
|
select tb.id as id,
|
|
|
|
|
tb.pro_name as proName,
|
|
|
|
|
tb.depart_id as departId,
|
|
|
|
|
tpd.depart_name as departName,
|
|
|
|
|
tb.rel_id as relId,
|
|
|
|
|
sda.dict_label as relName,
|
|
|
|
|
tb.pro_type as proType,
|
|
|
|
|
tb.pro_status as proStatus,
|
|
|
|
|
tb.area_id as areaId,
|
|
|
|
|
ta.area_name as areaName,
|
|
|
|
|
tb.lon as lon,
|
|
|
|
|
tb.lat as lat,
|
|
|
|
|
tb.del_flag as delFlag
|
|
|
|
|
from tb_project tb
|
|
|
|
|
left join tb_pro_depart tpd on tb.depart_id = tpd.id
|
|
|
|
|
left join tb_area ta on tb.area_id = ta.id
|
|
|
|
|
left join sys_dict_data sda on tb.rel_id = sda.dict_code
|
|
|
|
|
where tb.del_flag = '0'
|
|
|
|
|
<if test="proName != null and proName != ''">
|
|
|
|
|
and tb.pro_name = #{proName}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<insert id="insert">
|
|
|
|
|
INSERT INTO tb_project
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="proName != null and proName != ''">pro_name,</if>
|
|
|
|
|
<if test="departId != null">depart_id,</if>
|
|
|
|
|
<if test="relId != null">rel_id,</if>
|
|
|
|
|
<if test="proType != null">pro_type,</if>
|
|
|
|
|
<if test="proStatus != null">pro_status,</if>
|
|
|
|
|
<if test="areaId != null">area_id,</if>
|
|
|
|
|
<if test="lon != null">lon,</if>
|
|
|
|
|
<if test="lat != null">lat,</if>
|
|
|
|
|
create_time,
|
|
|
|
|
<if test="createUser != null">create_user,</if>
|
2024-09-26 15:52:11 +08:00
|
|
|
<if test="proCode != null and proCode != ''">pro_code,</if>
|
2024-09-13 18:06:19 +08:00
|
|
|
del_flag
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="proName != null and proName != ''">#{proName},</if>
|
|
|
|
|
<if test="departId != null">#{departId},</if>
|
|
|
|
|
<if test="relId != null">#{relId},</if>
|
|
|
|
|
<if test="proType != null">#{proType},</if>
|
|
|
|
|
<if test="proStatus != null">#{proStatus},</if>
|
|
|
|
|
<if test="areaId != null">#{areaId},</if>
|
|
|
|
|
<if test="lon != null">#{lon},</if>
|
|
|
|
|
<if test="lat != null">#{lat},</if>
|
|
|
|
|
NOW(),
|
|
|
|
|
<if test="createUser != null">#{createUser},</if>
|
2024-09-26 15:52:11 +08:00
|
|
|
<if test="proCode != null and proCode != ''">#{proCode},</if>
|
2024-09-13 18:06:19 +08:00
|
|
|
0
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<!--通过主键修改数据-->
|
|
|
|
|
<update id="update">
|
|
|
|
|
update tb_project
|
|
|
|
|
<set>
|
|
|
|
|
<if test="proName != null and proName != ''">
|
|
|
|
|
pro_name = #{proName},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="departId != null">
|
|
|
|
|
depart_id = #{departId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="relId != null and relId != ''">
|
|
|
|
|
rel_id = #{relId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proType != null and proType != ''">
|
|
|
|
|
pro_type = #{proType},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proStatus != null and proStatus != ''">
|
|
|
|
|
pro_status = #{proStatus},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="areaId != null and areaId != ''">
|
|
|
|
|
area_id = #{areaId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="lon != null and lon != ''">
|
|
|
|
|
lon = #{lon},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="lat != null and lat != ''">
|
|
|
|
|
lat = #{lat},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="delFlag != null">
|
|
|
|
|
del_flag = #{delFlag},
|
|
|
|
|
</if>
|
|
|
|
|
update_time = NOW(),
|
|
|
|
|
<if test="updateUser != null">
|
|
|
|
|
update_user = #{updateUser},
|
|
|
|
|
</if>
|
2024-09-26 15:52:11 +08:00
|
|
|
<if test="updateUser != null">
|
|
|
|
|
pro_code = #{proCode},
|
|
|
|
|
</if>
|
2024-09-13 18:06:19 +08:00
|
|
|
</set>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
2024-09-18 18:19:12 +08:00
|
|
|
<select id="getProjectView" resultType="com.bonus.screen.vo.ProjectViewVo">
|
|
|
|
|
select count(1) as projectTotal,
|
|
|
|
|
count(case when tb.pro_type = #{powerCode} then 1 end) as projectPowerTotal,
|
|
|
|
|
count(case when tb.pro_type = #{lineCode} then 1 end) as projectLineTotal
|
|
|
|
|
from tb_project tb
|
|
|
|
|
where tb.del_flag = '0'
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getProjectListGroupArea" resultType="com.bonus.screen.vo.ProjectAreaGroupVo">
|
|
|
|
|
SELECT
|
|
|
|
|
a.id AS areaId,
|
|
|
|
|
a.area_name as areaName,
|
|
|
|
|
p.id AS projectId,
|
|
|
|
|
p.pro_name AS projectName
|
|
|
|
|
FROM
|
|
|
|
|
tb_area a
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
tb_project p ON a.id = p.area_id;
|
|
|
|
|
</select>
|
2024-09-20 10:51:00 +08:00
|
|
|
|
|
|
|
|
<select id="getProjectListGroupAreaByTypeCode" resultType="com.bonus.screen.vo.ProjectAreaGroupVo">
|
|
|
|
|
SELECT
|
|
|
|
|
a.id AS areaId,
|
|
|
|
|
a.area_name as areaName,
|
|
|
|
|
p.id AS projectId,
|
|
|
|
|
p.pro_name AS projectName,
|
|
|
|
|
p.lon,p.lat
|
|
|
|
|
FROM
|
|
|
|
|
tb_project p
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
tb_area a ON a.id = p.area_id
|
|
|
|
|
<where>
|
|
|
|
|
p.del_flag = 0
|
|
|
|
|
<if test="projectTypeCode != null">
|
|
|
|
|
and p.pro_type = #{projectTypeCode}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="areaId != null">
|
|
|
|
|
and p.area_id = #{areaId}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
2024-09-23 17:09:36 +08:00
|
|
|
<select id="getProPowerListByProId" resultType="com.bonus.base.domain.TbProPower">
|
|
|
|
|
select id as id,
|
|
|
|
|
pro_id as proId,
|
|
|
|
|
gt_name as gtName,
|
|
|
|
|
lon as lon,
|
|
|
|
|
lat as lat
|
|
|
|
|
from tb_pro_power
|
|
|
|
|
where pro_id = #{proId}
|
|
|
|
|
and del_flag = 0
|
|
|
|
|
</select>
|
2024-09-13 18:06:19 +08:00
|
|
|
</mapper>
|
|
|
|
|
|