ah_jjzhgd_service/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/TbAreaMapper.xml

114 lines
5.4 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.securitycontrol.background.mapper.TbAreaMapper">
<resultMap id="AreaMap" type="com.securitycontrol.entity.background.vo.AreaVo">
<id property="areaId" column="area_id"/>
<result property="areaName" column="area_name"/>
<result property="bidCode" column="bid_code"/>
<result property="remarks" column="remarks"/>
<result property="areaCode" column="area_code"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="gtId" column="gt_id"/>
<result property="gtName" column="gt_name"/>
<result property="proName" column="pro_name"/>
<result property="areaType" column="area_type"/>
</resultMap>
<insert id="insertData">
insert into tb_area(area_id,area_name,bid_code,remarks,
area_code,create_time, gt_id,del_flag,area_type)value (
#{areaId},#{areaName},#{bidCode},#{remarks},#{areaCode},now(),#{gtId},0,#{areaType})
</insert>
<insert id="addGtData">
insert into t_pro_gt (gt_id,gt_name,gt_code,bid_code,lat,lon,del_flag,create_time)value (
#{gtId},#{gtName},#{gtCode},#{bidCode},#{lat},#{lon},0,now()
)
</insert>
<insert id="addSwFile" keyProperty="id" useGeneratedKeys="true">
insert into tb_sw_source (bid_code,gt_id,del_flag) value (#{bidCode},#{gtId},0)
</insert>
<update id="updateData">
update tb_area set area_name=#{areaName},bid_code=#{bidCode},remarks=#{remarks},gt_id=#{gtId},
area_code=#{areaCode},update_time=now(),area_type=#{areaType}
where area_id=#{areaId}
</update>
<update id="deleteArea">
update tb_area set del_flag=1 where area_id=#{areaId}
</update>
<update id="updateGtData">
update t_pro_gt set gt_name=#{gtName},gt_code=#{gtCode},lat=#{lat},lon=#{lon},update_time=now()
where gt_id=#{gtId}
</update>
<update id="deleteGt">
update t_pro_gt set del_flag=1 where gt_id=#{gtId}
</update>
<delete id="deleteData">
delete from tb_sw_source where id=#{id}
</delete>
<select id="getAreaList" resultMap="AreaMap">
select area_id,area_name,pro.bid_code, remarks,area_code,pro.pro_name,
area.create_time,area.update_time, area.gt_id,gt.gt_name,area.area_type
from tb_area area
left join tb_project pro on pro.bid_code=area.bid_code and pro.del_flag=0
LEFT JOIN t_pro_gt gt on area.gt_id=gt.gt_id and gt.del_flag=0
where area.del_flag=0
<if test="keyWord!=null and keyWord!=''">
AND INSTR(area_name,#{keyWord}) > 0
</if>
</select>
<select id="getProjectTypeByBidCode" resultType="java.lang.String">
select pro_type
from tb_project pro
where pro.del_flag=0 AND pro.bid_code=#{bidCode}
</select>
<select id="getGtList" resultType="com.securitycontrol.entity.background.vo.GtVo">
select
gt.gt_id gtId,gt.gt_name gtName,gt. gt_code gtCode,
gt.bid_code bidCode, lat,lon,pro.pro_name proName,
gt.now_gx nowGx, gt.create_time createTime,gt.update_time updateTime,tgg.gx_name gxName
from t_pro_gt gt
left join tb_gt_gx tgg on gt.now_gx=tgg.gx_id
left join tb_project pro on pro.bid_code=gt.bid_code and pro.del_flag=0
WHERE gt.del_flag=0 and gt.bid_code=#{bidCode}
<if test="keyWord!=null and keyWord!=''">
AND (
INSTR(gt.gt_name,#{keyWord}) > 0 or
INSTR(gt.gt_code,#{keyWord}) > 0
)
</if>
</select>
<select id="getGtById" resultType="com.securitycontrol.entity.background.vo.GtVo">
select
gt.gt_id gtId,gt.gt_name gtName,gt. gt_code gtCode,
gt.bid_code bidCode, lat,lon,
gt.now_gx nowGx, gt.create_time createTime,gt.update_time updateTime
from t_pro_gt gt
WHERE gt.gt_id=#{gtId}
</select>
<select id="getAreaById" resultMap="AreaMap">
select area_id,area_name,remarks,area_code,bid_code,gt_id,
area.create_time,area.update_time,area.area_type
from tb_area area
where area.area_id=#{areaId}
</select>
<select id="getSwList" resultType="com.securitycontrol.entity.background.vo.AreaVo">
select sw.id,ANY_VALUE(pro.pro_name) proName,ANY_VALUE(gt.gt_name) gtName,count(rf.id) fileNum
FROM tb_sw_source sw
left join tb_resource_file rf on rf.source_id=sw.id and rf.source_type='三维文件' and rf.del_flag=0
left join tb_project pro on pro.bid_code=sw.bid_code and pro.del_flag=0
left join t_pro_gt gt on gt.gt_id=sw.gt_id and gt.del_flag=0
where sw.del_flag=0
GROUP BY sw.id
</select>
<select id="getSwData" resultType="java.lang.Integer">
select COUNT(1)
from tb_sw_source sw
where sw.del_flag=0
and sw.gt_id=#{gtId}
</select>
</mapper>