<?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="cn.gistack.sm.sjztmd.mapper.AttResManagePersonMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="baseResultMap" type="cn.gistack.sm.sjztmd.entity.AttResManagePerson">
|
<id column="guid" property="guid"/>
|
<result column="user_name" property="userName"/>
|
<result column="type" property="type"/>
|
<result column="user_phone" property="userPhone"/>
|
<result column="user_unit" property="userUnit"/>
|
<result column="postion" property="position"/>
|
<result column="res_guid" property="resGuid"/>
|
</resultMap>
|
|
<!-- <select id="attResManagePersonListByResId" resultMap="baseResultMap">-->
|
<select id="attResManagePersonListByResId" resultMap="baseResultMap">
|
select DISTINCT
|
"guid","user_name","type","user_phone","user_unit","position","res_guid","user_guid"
|
from "att_res_manage_person" where "type" = 5 AND "res_guid" IN
|
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</select>
|
|
<select id="getPatrolResponsiblePersonAll" resultType="cn.gistack.sm.sjztmd.entity.PatrolResponsiblePerson">
|
select DISTINCT a."res_guid", c."name", b.id as user_id
|
from "SJZT_MD"."att_res_manage_person" a,
|
"BLADE_USER" b,
|
"SJZT_MD"."att_res_base" c
|
WHERE a."user_phone" = b.PHONE
|
and a."res_guid" = c."guid"
|
and a."type" = 5
|
</select>
|
|
<update id="updateResManagePersonByGuid">
|
update "att_res_manage_person"
|
SET
|
<if test="attResManagePerson.userName !=null and attResManagePerson.userName != '' ">
|
"user_name" = #{attResManagePerson.userName},
|
</if>
|
<if test="attResManagePerson.userPhone !=null and attResManagePerson.userPhone != '' ">
|
"user_phone" = #{attResManagePerson.userPhone},
|
</if>
|
<if test="attResManagePerson.userUnit !=null and attResManagePerson.userUnit != '' ">
|
"user_unit" = #{attResManagePerson.userUnit},
|
</if>
|
<if test="attResManagePerson.position !=null and attResManagePerson.position != '' ">
|
"position" = #{attResManagePerson.position},
|
</if>
|
<if test="attResManagePerson.resGuid !=null and attResManagePerson.resGuid != '' ">
|
"res_guid" = #{attResManagePerson.resGuid},
|
</if>
|
<if test="attResManagePerson.type !=null and attResManagePerson.type != '' ">
|
"type" = #{attResManagePerson.type},
|
</if>
|
<if test="attResManagePerson.sysResource !=null and attResManagePerson.sysResource != '' ">
|
"sys_resource" = #{attResManagePerson.sysResource},
|
</if>
|
"update_time" = #{attResManagePerson.updateTime}
|
where "guid" = #{attResManagePerson.guid}
|
</update>
|
|
<insert id="insertResManagePersion">
|
insert into "att_res_manage_person"("guid", "user_name", "type", "user_phone", "user_unit", "position",
|
"res_guid", "sys_resource")
|
values (rawtohex(sys_guid()),
|
#{attResManagePerson.userName},
|
#{attResManagePerson.type},
|
#{attResManagePerson.userPhone},
|
#{attResManagePerson.userUnit},
|
#{attResManagePerson.position},
|
#{attResManagePerson.resGuid},
|
#{attResManagePerson.sysResource})
|
</insert>
|
|
<!--根据水库编号及责任人类型查询相关责任人信息-->
|
<select id="getPersonListByResGuid" resultType="cn.gistack.sm.sjztmd.vo.PersonVO">
|
select "user_name" as name,"user_phone" as phone,"type" as type
|
from "SJZT_MD"."att_res_manage_person"
|
where "res_guid" = #{res_cd}
|
<choose>
|
<when test="list!=null and list.size()>0">
|
and "type" in
|
<foreach collection="list" item="type" separator="," open="(" close=")">
|
#{type}
|
</foreach>
|
</when>
|
<otherwise>
|
and "type" in ('')
|
</otherwise>
|
</choose>
|
</select>
|
|
<select id="getPersonByUserNotExists" resultType="cn.gistack.sm.sjztmd.vo.UserPersonVO">
|
select distinct a.*,
|
to_char((select wm_concat(
|
distinct CASE tmp."type" WHEN '1' THEN '1648252341572902914' WHEN '2' THEN '1648252441107931137' WHEN '3' THEN '1648252563300589570' WHEN '4' THEN '1648252509110181890' WHEN '5' THEN '1642713427301355522' ELSE '' END
|
)
|
from "SJZT_MD"."att_res_manage_person" tmp
|
where tmp."user_phone" = a."user_phone")) as role_id
|
from (select *
|
from (select distinct a."user_name", a."user_phone", concat(b."ad_guid", '000000') as "ad_code"
|
from "SJZT_MD"."att_res_manage_person" a
|
left join "SJZT_MD"."att_res_base" b on a."res_guid" = b."guid"
|
where "user_phone" is not null
|
and "user_name" not like '%、'
|
and length(a."user_phone") = 11
|
order by "user_phone") a
|
where not exists(select * from "YWXT"."BLADE_USER" where a."user_phone" = "PHONE")) a
|
</select>
|
|
<select id="getPersonByUser" resultType="cn.gistack.sm.sjztmd.vo.UserPersonVO">
|
select distinct a."user_name",
|
a."user_phone",
|
a."ad_code",
|
to_char((select wm_concat(
|
distinct CASE tmp."type" WHEN '1' THEN '1648252341572902914' WHEN '2' THEN '1648252441107931137' WHEN '3' THEN '1648252563300589570' WHEN '4' THEN '1648252509110181890' WHEN '5' THEN '1642713427301355522' ELSE '' END
|
)
|
from "SJZT_MD"."att_res_manage_person" tmp
|
where tmp."user_phone" = a."user_phone")) as role_id
|
from (select *
|
from (select distinct a."user_name", a."user_phone", concat(b."ad_guid", '000000') as "ad_code"
|
from "SJZT_MD"."att_res_manage_person" a
|
left join "SJZT_MD"."att_res_base" b on a."res_guid" = b."guid"
|
where "user_phone" is not null
|
and "user_name" not like '%、'
|
and length(a."user_phone") = 11
|
order by "user_phone") a) a
|
</select>
|
|
<update id="updateUserByPerson">
|
|
UPDATE YWXT.BLADE_USER a, (
|
select distinct a."user_name",
|
a."user_phone",
|
a."ad_code",
|
to_char((select wm_concat(
|
distinct CASE tmp."type" WHEN '1' THEN '1648252341572902914' WHEN '2' THEN '1648252441107931137' WHEN '3' THEN '1648252563300589570' WHEN '4' THEN '1648252509110181890' WHEN '5' THEN '1642713427301355522' ELSE '' END
|
)
|
from "SJZT_MD"."att_res_manage_person" tmp
|
where tmp."user_phone" = a."user_phone")) as role_id
|
from (select *
|
from (select distinct a."user_name", a."user_phone", concat(b."ad_guid", '000000') as "ad_code"
|
from "SJZT_MD"."att_res_manage_person" a
|
left join "SJZT_MD"."att_res_base" b on a."res_guid" = b."guid"
|
where "user_phone" is not null
|
and "user_name" not like '%、'
|
and length(a."user_phone") = 11
|
order by "user_phone") a) a
|
) b
|
set
|
a.role_id = b.role_id
|
where a.phone = b."user_phone" and a.role_id <> b.role_id
|
</update>
|
|
<!--通过水库代码获取巡查责任人及技术责任人手机号-->
|
<select id="getPersonListByWaterCodeList" resultType="java.lang.String">
|
SELECT b."user_phone" FROM SJZT_MD."att_res_base" a
|
LEFT JOIN SJZT_MD."att_res_manage_person" b ON a."guid" = b."res_guid"
|
where 1=1
|
and (b."type" = 4 or b."type" = 5)
|
<choose>
|
<when test="list!=null and list.size()>0">
|
and "sk_code" in
|
<foreach collection="list" item="id" open="(" close=")" separator=",">
|
#{id}
|
</foreach>
|
</when>
|
<otherwise>
|
and "sk_code" in ('')
|
</otherwise>
|
</choose>
|
group by b."user_phone"
|
</select>
|
|
<!--根据水库编号查询市县水利部人员姓名及联系方式-->
|
<select id="getCityCountyPersonListByResGuid" resultType="cn.gistack.sm.sjztmd.vo.PersonVO">
|
select real_name as name,phone,#{type} as type from YWXT.blade_user bu
|
left join YWXT.blade_dept bd on locate(bd.id,bu.dept_id)>0 and bd.is_deleted = 0
|
left join YWXT.blade_role br on locate(br.id,bu.role_id)>0 and br.is_deleted = 0
|
where bu.is_deleted = 0
|
and br.role_alias = #{roleAlias}
|
and bd.ad_code = #{adCode}
|
</select>
|
|
</mapper>
|