ganzi-api/inventory-dao/src/main/resources/mapper/SysOrgMapper.xml

723 lines
27 KiB
XML
Raw Normal View History

2022-09-16 15:07:17 +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.rzyc.mapper.SysOrgMapper">
<resultMap id="BaseResultMap" type="com.rzyc.model.SysOrg">
<id column="OrgCode" jdbcType="VARCHAR" property="orgcode" />
<result column="OrgName" jdbcType="VARCHAR" property="orgname" />
<result column="OrgLevel" jdbcType="INTEGER" property="orglevel" />
<result column="SuperiorOrgCode" jdbcType="VARCHAR" property="superiororgcode" />
<result column="charger" jdbcType="VARCHAR" property="charger" />
<result column="CreatedBy" jdbcType="VARCHAR" property="createdby" />
<result column="totalEnt" jdbcType="VARCHAR" property="totalEnt" />
<result column="checkEnt" jdbcType="VARCHAR" property="checkEnt" />
<result column="CreatedOn" jdbcType="TIMESTAMP" property="createdon" />
<result column="ModifiedBy" jdbcType="VARCHAR" property="modifiedby" />
<result column="ModifiedOn" jdbcType="TIMESTAMP" property="modifiedon" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
OrgCode, OrgName, OrgLevel, SuperiorOrgCode,charger, CreatedBy, CreatedOn, ModifiedBy, ModifiedOn
</sql>
<select id="selectByExample" parameterType="com.rzyc.model.SysOrgExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from SysOrg
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limit != null">
<if test="offset != null">
limit ${offset}, ${limit}
</if>
<if test="offset == null">
limit ${limit}
</if>
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from SysOrg
where OrgCode = #{orgcode,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from SysOrg
where OrgCode = #{orgcode,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.rzyc.model.SysOrgExample">
delete from SysOrg
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insertSelective" parameterType="com.rzyc.model.SysOrg">
insert into SysOrg
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orgcode != null">
OrgCode,
</if>
<if test="orgname != null">
OrgName,
</if>
<if test="orglevel != null">
OrgLevel,
</if>
<if test="superiororgcode != null">
SuperiorOrgCode,
</if>
<if test="charger != null">
charger,
</if>
<if test="createdby != null">
CreatedBy,
</if>
<if test="createdon != null">
CreatedOn,
</if>
<if test="modifiedby != null">
ModifiedBy,
</if>
<if test="modifiedon != null">
ModifiedOn,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orgcode != null">
#{orgcode,jdbcType=VARCHAR},
</if>
<if test="orgname != null">
#{orgname,jdbcType=VARCHAR},
</if>
<if test="orglevel != null">
#{orglevel,jdbcType=INTEGER},
</if>
<if test="superiororgcode != null">
#{superiororgcode,jdbcType=VARCHAR},
</if>
<if test="charger != null">
#{charger,jdbcType=VARCHAR},
</if>
<if test="createdby != null">
#{createdby,jdbcType=VARCHAR},
</if>
<if test="createdon != null">
#{createdon,jdbcType=TIMESTAMP},
</if>
<if test="modifiedby != null">
#{modifiedby,jdbcType=VARCHAR},
</if>
<if test="modifiedon != null">
#{modifiedon,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.rzyc.model.SysOrgExample" resultType="java.lang.Long">
select count(*) from SysOrg
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update SysOrg
<set>
<if test="record.orgcode != null">
OrgCode = #{record.orgcode,jdbcType=VARCHAR},
</if>
<if test="record.orgname != null">
OrgName = #{record.orgname,jdbcType=VARCHAR},
</if>
<if test="record.orglevel != null">
OrgLevel = #{record.orglevel,jdbcType=INTEGER},
</if>
<if test="record.superiororgcode != null">
SuperiorOrgCode = #{record.superiororgcode,jdbcType=VARCHAR},
</if>
<if test="record.charger != null">
charger = #{record.charger,jdbcType=VARCHAR},
</if>
<if test="record.createdby != null">
CreatedBy = #{record.createdby,jdbcType=VARCHAR},
</if>
<if test="record.createdon != null">
CreatedOn = #{record.createdon,jdbcType=TIMESTAMP},
</if>
<if test="record.modifiedby != null">
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR},
</if>
<if test="record.modifiedon != null">
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update SysOrg
set OrgCode = #{record.orgcode,jdbcType=VARCHAR},
OrgName = #{record.orgname,jdbcType=VARCHAR},
OrgLevel = #{record.orglevel,jdbcType=INTEGER},
SuperiorOrgCode = #{record.superiororgcode,jdbcType=VARCHAR},
charger = #{record.charger,jdbcType=VARCHAR},
CreatedBy = #{record.createdby,jdbcType=VARCHAR},
CreatedOn = #{record.createdon,jdbcType=TIMESTAMP},
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR},
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.rzyc.model.SysOrg">
update SysOrg
<set>
<if test="orgname != null">
OrgName = #{orgname,jdbcType=VARCHAR},
</if>
<if test="orglevel != null">
OrgLevel = #{orglevel,jdbcType=INTEGER},
</if>
<if test="superiororgcode != null">
SuperiorOrgCode = #{superiororgcode,jdbcType=VARCHAR},
</if>
<if test="charger != null">
charger = #{charger,jdbcType=VARCHAR},
</if>
<if test="createdby != null">
CreatedBy = #{createdby,jdbcType=VARCHAR},
</if>
<if test="createdon != null">
CreatedOn = #{createdon,jdbcType=TIMESTAMP},
</if>
<if test="modifiedby != null">
ModifiedBy = #{modifiedby,jdbcType=VARCHAR},
</if>
<if test="modifiedon != null">
ModifiedOn = #{modifiedon,jdbcType=TIMESTAMP},
</if>
</set>
where OrgCode = #{orgcode,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.rzyc.model.SysOrg">
update SysOrg
set OrgName = #{orgname,jdbcType=VARCHAR},
OrgLevel = #{orglevel,jdbcType=INTEGER},
SuperiorOrgCode = #{superiororgcode,jdbcType=VARCHAR},
charger = #{charger,jdbcType=VARCHAR},
CreatedBy = #{createdby,jdbcType=VARCHAR},
CreatedOn = #{createdon,jdbcType=TIMESTAMP},
ModifiedBy = #{modifiedby,jdbcType=VARCHAR},
ModifiedOn = #{modifiedon,jdbcType=TIMESTAMP}
where OrgCode = #{orgcode,jdbcType=VARCHAR}
</update>
<!--地区列表-->
<select id="sysOrgList" resultMap="BaseResultMap">
SELECT * FROM SysOrg so WHERE 1=1
<if test="superiorOrgCode != null and '' != superiorOrgCode">
and so.SuperiorOrgCode = #{superiorOrgCode}
</if>
order by so.OrgCode ASC
</select>
<resultMap id="TopfiveResultMap" type="com.rzyc.bean.bigdata.AreaInfo">
<result column="OrgCode" jdbcType="VARCHAR" property="OrgCode" />
<result column="OrgName" jdbcType="VARCHAR" property="OrgName" />
</resultMap>
<!--地区列表-->
<select id="findBySuper" resultMap="TopfiveResultMap">
select OrgCode,OrgName from SysOrg where SuperiorOrgCode=#{superiorOrgCode}
</select>
<!--通过名字查询-->
<select id="findByName" resultMap="BaseResultMap">
SELECT * FROM SysOrg so
WHERE so.`OrgName` = #{orgName}
<if test="null != superId and '' != superId">
AND so.`SuperiorOrgCode` = #{superId}
</if>
</select>
<!--查询所有-->
<select id="findAll" resultMap="BaseResultMap">
SELECT * FROM SysOrg so
</select>
2022-10-28 15:05:50 +08:00
<!--查询所有-->
<select id="findUserArea" resultMap="BaseResultMap">
SELECT * FROM SysOrg so where FIND_IN_SET(#{userArea},so.parent_path)
</select>
2022-09-16 15:07:17 +08:00
<!--地区列表-->
<resultMap id="AreaResultMap" type="com.rzyc.model.SysOrg">
<id column="OrgCode" jdbcType="VARCHAR" property="orgcode" />
<result column="OrgName" jdbcType="VARCHAR" property="orgname" />
<result column="superName" jdbcType="VARCHAR" property="superName" />
<result column="OrgLevel" jdbcType="INTEGER" property="orglevel" />
<result column="SuperiorOrgCode" jdbcType="VARCHAR" property="superiororgcode" />
<result column="charger" jdbcType="VARCHAR" property="charger" />
<result column="CreatedBy" jdbcType="VARCHAR" property="createdby" />
<result column="CreatedOn" jdbcType="TIMESTAMP" property="createdon" />
<result column="ModifiedBy" jdbcType="VARCHAR" property="modifiedby" />
<result column="ModifiedOn" jdbcType="TIMESTAMP" property="modifiedon" />
</resultMap>
<!--查询所有-->
<select id="areaPage" resultMap="AreaResultMap">
SELECT sp.`OrgName` superName,so.*
FROM SysOrg so
LEFT JOIN SysOrg sp ON so.`SuperiorOrgCode` = sp.`OrgCode`
WHERE so.`OrgName` LIKE #{condition}
2022-10-28 15:05:50 +08:00
and FIND_IN_SET(#{userArea},so.parent_path)
2022-09-16 15:07:17 +08:00
<if test="null != orgcode and '' !=orgcode ">
and so.`SuperiorOrgCode` = #{orgcode}
</if>
ORDER BY so.`OrgLevel` ASC,so.OrgName ASC
</select>
<!--修改地区-->
<update id="changeArea">
update SysOrg
set OrgName = #{orgname,jdbcType=VARCHAR},
OrgLevel = #{orglevel,jdbcType=INTEGER},
SuperiorOrgCode = #{superiororgcode,jdbcType=VARCHAR},
charger = #{charger,jdbcType=VARCHAR},
2022-11-01 17:30:53 +08:00
sort_id = #{sortId,jdbcType=VARCHAR},
parent_path = #{parentPath,jdbcType=VARCHAR},
parent_name = #{parentName,jdbcType=VARCHAR},
2022-09-16 15:07:17 +08:00
ModifiedBy = #{modifiedby,jdbcType=VARCHAR},
ModifiedOn = #{modifiedon,jdbcType=TIMESTAMP}
where OrgCode = #{orgcode,jdbcType=VARCHAR}
</update>
<!--下级地区列表-->
<select id="findByParentId" resultMap="BaseResultMap">
SELECT * FROM `SysOrg` so
WHERE so.`SuperiorOrgCode` = #{orgcode} ORDER BY so.`OrgName` ASC
</select>
<!--获取村社代码及名字-->
<select id="selectCommunityInfo" resultType="hashmap">
select OrgCode,OrgName
from SysOrg
where OrgLevel = 3
<if test="name!=null and name!=''">
and sysorg.OrgName like concat('%',#{name},'%')
</if>
</select>
<resultMap id="CountByOrgMap" type="com.rzyc.bean.organization.vo.CountByOrg">
<result column="OrgCode" property="orgcode"/>
<result column="OrgName" property="orgname"/>
<result column="comDangerTotal" property="comDangerTotal"/>
<result column="comTotaled" property="comTotaled"/>
<result column="majorDangerTotal" property="majorDangerTotal"/>
<result column="majorTotaled" property="majorTotaled"/>
<result column="beforWeekComTotle" property="beforWeekComTotle"/>
<result column="beforWeekComTotaled" property="beforWeekComTotaled"/>
</resultMap>
<sql id="YearScreen">
<if test="null != yearFirst and '' != yearFirst">
and date_format(od.create_time,'%Y-%m-%d') >= str_to_date(#{yearFirst},'%Y-%m-%d')
</if>
<if test="null != yearLast and '' != yearLast">
and date_format(od.create_time,'%Y-%m-%d') &lt;= str_to_date(#{yearLast},'%Y-%m-%d')
</if>
<if test="null != month1 and '' != month1">
and date_format(od.create_time,'%Y-%m-%d') >= str_to_date(#{month1},'%Y-%m-%d')
</if>
<if test="null != month2 and '' != month2">
and date_format(od.create_time,'%Y-%m-%d') &lt;= str_to_date(#{month2},'%Y-%m-%d')
</if>
<if test="null != weekFirst and '' != weekFirst">
and date_format(od.create_time,'%Y-%m-%d') &lt;= str_to_date(#{weekFirst},'%Y-%m-%d')
</if>
<if test="null != weekEnd and '' != weekEnd">
and date_format(od.create_time,'%Y-%m-%d') >= str_to_date(#{weekEnd},'%Y-%m-%d')
</if>
</sql>
<select id="countByOrg" resultMap="CountByOrgMap">
select so.OrgCode,so.OrgName,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`level` = 2
<include refid="YearScreen"></include>
) comDangerTotal,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`status` = 4 and od.`level` = 2
<include refid="YearScreen"></include>
) comTotaled,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`level` = 1
<include refid="YearScreen"></include>
) majorDangerTotal,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`status` = 4
and od.`level` = 1
<include refid="YearScreen"></include>
) majorTotaled
<if test="(null != lastTimeInterval2 and '' != lastTimeInterval2) and (null != lastTimeInterval1 and '' != lastTimeInterval1)">
,(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`level` = 2
<include refid="LastWeekData"></include>
) beforWeekComTotle,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`status` = 4 and od.`level` = 2
<include refid="LastWeekData"></include>
) beforWeekComTotaled,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`level` = 1
<include refid="LastWeekData"></include>
) beforWeekMajorTotle,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`status` = 4
and od.`level` = 1
<include refid="LastWeekData"></include>
) beforWeekMajorTotaled
</if>
from SysOrg so
where so.SuperiorOrgCode = '510114103000';
</select>
<!--年数据-->
<sql id="YearData">
<if test="null != firstDayDateOfYear and '' != firstDayDateOfYear">
and date_format(od.create_time,'%Y-%m-%d') >= str_to_date(#{firstDayDateOfYear},'%Y-%m-%d')
</if>
<if test="null != lastDayOfYear and '' != lastDayOfYear">
and date_format(od.create_time,'%Y-%m-%d') &lt;= str_to_date(#{lastDayOfYear},'%Y-%m-%d')
</if>
</sql>
<!--年数据-->
<select id="censYearData" resultMap="CountByOrgMap">
select so.OrgCode,so.OrgName,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`level` = 2
<include refid="YearData"></include>
) comDangerTotal,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`status` = 4 and od.`level` = 2
<include refid="YearData"></include>
) comTotaled,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`level` = 1
<include refid="YearData"></include>
) majorDangerTotal,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`status` = 4
and od.`level` = 1
<include refid="YearData"></include>
) majorTotaled
from SysOrg so
where so.SuperiorOrgCode = '510114103000';
</select>
<!--月隐患-->
<sql id="MonthData">
<if test="null != firstDayOfMonth and '' != firstDayOfMonth">
and date_format(od.create_time,'%Y-%m-%d') >= str_to_date(#{firstDayOfMonth},'%Y-%m-%d')
</if>
<if test="null != lastDayOfMonth and '' != lastDayOfMonth">
and date_format(od.create_time,'%Y-%m-%d') &lt;= str_to_date(#{lastDayOfMonth},'%Y-%m-%d')
</if>
</sql>
<!--月隐患数据-->
<select id="censMonthData" resultMap="CountByOrgMap">
select so.OrgCode,so.OrgName,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`level` = 2
<include refid="MonthData"></include>
) comDangerTotal,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`status` = 4 and od.`level` = 2
<include refid="MonthData"></include>
) comTotaled,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`level` = 1
<include refid="MonthData"></include>
) majorDangerTotal,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`status` = 4
and od.`level` = 1
<include refid="MonthData"></include>
) majorTotaled
from SysOrg so
where so.SuperiorOrgCode = '510114103000';
</select>
<!--上周隐患数据-->
<sql id="LastWeekData">
<if test="null != lastTimeInterval1 and '' != lastTimeInterval1">
and date_format(od.create_time,'%Y-%m-%d') &lt;= str_to_date(#{lastTimeInterval1},'%Y-%m-%d')
</if>
<if test="null != lastTimeInterval2 and '' != lastTimeInterval2">
and date_format(od.create_time,'%Y-%m-%d') >= str_to_date(#{lastTimeInterval2},'%Y-%m-%d')
</if>
</sql>
<!--本周隐患数据-->
<sql id="ThisWeekData">
<if test="null != weekEnd and '' != weekEnd">
and date_format(od.create_time,'%Y-%m-%d') &lt;= str_to_date(#{weekEnd},'%Y-%m-%d')
</if>
<if test="null != weekFirst and '' != weekFirst">
and date_format(od.create_time,'%Y-%m-%d') >= str_to_date(#{weekFirst},'%Y-%m-%d')
</if>
</sql>
<!--周隐患数据-->
<select id="censWeekData" resultMap="CountByOrgMap">
select so.OrgCode,so.OrgName,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`level` = 2
<include refid="LastWeekData"></include>
) beforWeekComTotle,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`status` = 4 and od.`level` = 2
<include refid="LastWeekData"></include>
) beforWeekComTotaled,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`level` = 1
<include refid="LastWeekData"></include>
) beforWeekMajorTotle,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`status` = 4
and od.`level` = 1
<include refid="LastWeekData"></include>
) beforWeekMajorTotaled,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`level` = 2
<include refid="ThisWeekData"></include>
) comDangerTotal,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`status` = 4 and od.`level` = 2
<include refid="ThisWeekData"></include>
) comTotaled,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`level` = 1
<include refid="ThisWeekData"></include>
) majorDangerTotal,
(select COUNT(*) from org_danger od
left join SysEnterprise se on
se.SysEnterpriseId = od.enterprise_id
where se.State = '启用' and (se.Orgcode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
and od.`status` = 4
and od.`level` = 1
<include refid="ThisWeekData"></include>
) majorTotaled
from SysOrg so
where so.SuperiorOrgCode = '510114103000';
</select>
<!--风险较大镇-->
<select id="topRiskStreet" resultType="java.lang.String">
select so.OrgName
from BookEntHT be
left join SysEnterprise se on be.SysEnterpriseId = se.SysEnterpriseId
left join SysOrg so on se.street_code = so.OrgCode
where be.HTState != '已整改' and se.street_code != '' and se.street_code is not null
and se.State = '启用'
group by so.OrgCode
order by count(se.SysEnterpriseId) desc
limit 3
</select>
<!--地区列表-->
<select id="checkSysOrg" resultMap="BaseResultMap">
SELECT so.*,
(
select count(*) from SysEnterprise se where se.State = '启用' and (se.OrgCode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
)totalEnt,
(
select count(distinct bc.BaseEntId) from BookEntCheck bc
left join SysEnterprise se on se.SysEnterpriseId = bc.BaseEntId
where se.State = '启用' and (se.OrgCode = so.OrgCode or se.street_code = so.OrgCode or se.community_code = so.OrgCode)
<if test="null != startTime and '' != startTime">
and bc.CreatedOn >= #{startTime}
</if>
<if test="null != endTime and '' != endTime">
and bc.CreatedOn &lt;= #{endTime}
</if>
) checkEnt
FROM SysOrg so WHERE 1=1
<if test="superiorOrgCode != null and '' != superiorOrgCode">
and so.SuperiorOrgCode = #{superiorOrgCode}
</if>
order by so.OrgCode ASC
</select>
2022-10-28 15:05:50 +08:00
<!--按照等级查询-->
<select id="findByLevel" resultMap="BaseResultMap">
select * from sysorg so
where so.OrgLevel = #{orgLevel}
</select>
2022-09-16 15:07:17 +08:00
</mapper>