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

753 lines
28 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.user.SysUnitMapper">
<resultMap id="BaseResultMap" type="com.rzyc.model.user.SysUnit">
<id column="SysUnitId" jdbcType="CHAR" property="sysunitid" />
<result column="OrgCode" jdbcType="VARCHAR" property="orgcode" />
<result column="SuperiorUnitId" jdbcType="CHAR" property="superiorunitid" />
2022-12-09 12:00:29 +08:00
<result column="parent_path" jdbcType="CHAR" property="parentPath" />
<result column="parent_name" jdbcType="CHAR" property="parentName" />
2022-09-16 15:07:17 +08:00
<result column="UnitCode" jdbcType="VARCHAR" property="unitcode" />
<result column="UnitName" jdbcType="VARCHAR" property="unitname" />
<result column="PinYin" jdbcType="VARCHAR" property="pinyin" />
<result column="UnitType" jdbcType="VARCHAR" property="unittype" />
<result column="UnitAddress" jdbcType="VARCHAR" property="unitaddress" />
<result column="SimpleName" jdbcType="VARCHAR" property="simplename" />
<result column="Principal" jdbcType="VARCHAR" property="principal" />
<result column="MobileTel" jdbcType="VARCHAR" property="mobiletel" />
<result column="BaseInfo" jdbcType="VARCHAR" property="baseinfo" />
<result column="Telephone" jdbcType="VARCHAR" property="telephone" />
<result column="UnitLocation" jdbcType="VARCHAR" property="unitlocation" />
<result column="Latitude" jdbcType="VARCHAR" property="latitude" />
<result column="Longitude" jdbcType="VARCHAR" property="longitude" />
<result column="Comments" jdbcType="VARCHAR" property="comments" />
<result column="CreatedOn" jdbcType="TIMESTAMP" property="createdon" />
<result column="CreatedBy" jdbcType="VARCHAR" property="createdby" />
<result column="ModifiedOn" jdbcType="TIMESTAMP" property="modifiedon" />
<result column="ModifiedBy" jdbcType="VARCHAR" property="modifiedby" />
<result column="SysEnterpriseId" jdbcType="CHAR" property="sysenterpriseid" />
</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">
2022-12-09 12:00:29 +08:00
SysUnitId, OrgCode,
parent_path,
parent_name,
SuperiorUnitId,
UnitCode, UnitName, PinYin, UnitType, UnitAddress,
2022-09-16 15:07:17 +08:00
SimpleName, Principal, MobileTel, BaseInfo, Telephone, UnitLocation, Latitude, Longitude,
Comments, CreatedOn, CreatedBy, ModifiedOn, ModifiedBy, SysEnterpriseId
</sql>
<select id="selectByExample" parameterType="com.rzyc.model.user.SysUnitExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from SysUnit
<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 SysUnit
where SysUnitId = #{sysunitid,jdbcType=CHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from sysunit
where SysUnitId = #{sysunitid,jdbcType=CHAR}
</delete>
<delete id="deleteByExample" parameterType="com.rzyc.model.user.SysUnitExample">
delete from sysunit
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.rzyc.model.user.SysUnit">
2022-12-09 12:00:29 +08:00
insert into SysUnit (SysUnitId, OrgCode,
SuperiorUnitId,
parent_path,
parent_name,
2022-09-16 15:07:17 +08:00
UnitCode, UnitName, PinYin,
UnitType, UnitAddress, SimpleName,
Principal, MobileTel, BaseInfo,
Telephone, UnitLocation, Latitude,IsHide,
Longitude, Comments, CreatedOn,
CreatedBy, ModifiedOn, ModifiedBy,
SysEnterpriseId)
2022-12-09 12:00:29 +08:00
values (#{sysunitid,jdbcType=CHAR}, #{orgcode,jdbcType=VARCHAR},
#{superiorunitid,jdbcType=CHAR},
#{parentPath,jdbcType=CHAR},
#{parentName,jdbcType=CHAR},
2022-09-16 15:07:17 +08:00
#{unitcode,jdbcType=VARCHAR}, #{unitname,jdbcType=VARCHAR}, #{pinyin,jdbcType=VARCHAR},
#{unittype,jdbcType=VARCHAR}, #{unitaddress,jdbcType=VARCHAR}, #{simplename,jdbcType=VARCHAR},
#{principal,jdbcType=VARCHAR}, #{mobiletel,jdbcType=VARCHAR}, #{baseinfo,jdbcType=VARCHAR},
#{telephone,jdbcType=VARCHAR}, #{unitlocation,jdbcType=VARCHAR},
#{latitude,jdbcType=VARCHAR},
#{isHide,jdbcType=VARCHAR},
#{longitude,jdbcType=VARCHAR}, #{comments,jdbcType=VARCHAR}, #{createdon,jdbcType=TIMESTAMP},
#{createdby,jdbcType=VARCHAR}, #{modifiedon,jdbcType=TIMESTAMP}, #{modifiedby,jdbcType=VARCHAR},
#{sysenterpriseid,jdbcType=CHAR})
</insert>
<insert id="insertSelective" parameterType="com.rzyc.model.user.SysUnit">
insert into SysUnit
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sysunitid != null">
SysUnitId,
</if>
<if test="orgcode != null">
OrgCode,
</if>
<if test="superiorunitid != null">
SuperiorUnitId,
</if>
<if test="unitcode != null">
UnitCode,
</if>
<if test="unitname != null">
UnitName,
</if>
<if test="pinyin != null">
PinYin,
</if>
<if test="unittype != null">
UnitType,
</if>
<if test="unitaddress != null">
UnitAddress,
</if>
<if test="simplename != null">
SimpleName,
</if>
<if test="principal != null">
Principal,
</if>
<if test="mobiletel != null">
MobileTel,
</if>
<if test="baseinfo != null">
BaseInfo,
</if>
<if test="telephone != null">
Telephone,
</if>
<if test="unitlocation != null">
UnitLocation,
</if>
<if test="latitude != null">
Latitude,
</if>
<if test="longitude != null">
Longitude,
</if>
<if test="comments != null">
Comments,
</if>
<if test="createdon != null">
CreatedOn,
</if>
<if test="createdby != null">
CreatedBy,
</if>
<if test="modifiedon != null">
ModifiedOn,
</if>
<if test="modifiedby != null">
ModifiedBy,
</if>
<if test="sysenterpriseid != null">
SysEnterpriseId,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sysunitid != null">
#{sysunitid,jdbcType=CHAR},
</if>
<if test="orgcode != null">
#{orgcode,jdbcType=VARCHAR},
</if>
<if test="superiorunitid != null">
#{superiorunitid,jdbcType=CHAR},
</if>
<if test="unitcode != null">
#{unitcode,jdbcType=VARCHAR},
</if>
<if test="unitname != null">
#{unitname,jdbcType=VARCHAR},
</if>
<if test="pinyin != null">
#{pinyin,jdbcType=VARCHAR},
</if>
<if test="unittype != null">
#{unittype,jdbcType=VARCHAR},
</if>
<if test="unitaddress != null">
#{unitaddress,jdbcType=VARCHAR},
</if>
<if test="simplename != null">
#{simplename,jdbcType=VARCHAR},
</if>
<if test="principal != null">
#{principal,jdbcType=VARCHAR},
</if>
<if test="mobiletel != null">
#{mobiletel,jdbcType=VARCHAR},
</if>
<if test="baseinfo != null">
#{baseinfo,jdbcType=VARCHAR},
</if>
<if test="telephone != null">
#{telephone,jdbcType=VARCHAR},
</if>
<if test="unitlocation != null">
#{unitlocation,jdbcType=VARCHAR},
</if>
<if test="latitude != null">
#{latitude,jdbcType=VARCHAR},
</if>
<if test="longitude != null">
#{longitude,jdbcType=VARCHAR},
</if>
<if test="comments != null">
#{comments,jdbcType=VARCHAR},
</if>
<if test="createdon != null">
#{createdon,jdbcType=TIMESTAMP},
</if>
<if test="createdby != null">
#{createdby,jdbcType=VARCHAR},
</if>
<if test="modifiedon != null">
#{modifiedon,jdbcType=TIMESTAMP},
</if>
<if test="modifiedby != null">
#{modifiedby,jdbcType=VARCHAR},
</if>
<if test="sysenterpriseid != null">
#{sysenterpriseid,jdbcType=CHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.rzyc.model.user.SysUnitExample" resultType="java.lang.Long">
select count(*) from sysunit
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update SysUnit
<set>
<if test="record.sysunitid != null">
SysUnitId = #{record.sysunitid,jdbcType=CHAR},
</if>
<if test="record.orgcode != null">
OrgCode = #{record.orgcode,jdbcType=VARCHAR},
</if>
<if test="record.superiorunitid != null">
SuperiorUnitId = #{record.superiorunitid,jdbcType=CHAR},
</if>
<if test="record.unitcode != null">
UnitCode = #{record.unitcode,jdbcType=VARCHAR},
</if>
<if test="record.unitname != null">
UnitName = #{record.unitname,jdbcType=VARCHAR},
</if>
<if test="record.pinyin != null">
PinYin = #{record.pinyin,jdbcType=VARCHAR},
</if>
<if test="record.unittype != null">
UnitType = #{record.unittype,jdbcType=VARCHAR},
</if>
<if test="record.unitaddress != null">
UnitAddress = #{record.unitaddress,jdbcType=VARCHAR},
</if>
<if test="record.simplename != null">
SimpleName = #{record.simplename,jdbcType=VARCHAR},
</if>
<if test="record.principal != null">
Principal = #{record.principal,jdbcType=VARCHAR},
</if>
<if test="record.mobiletel != null">
MobileTel = #{record.mobiletel,jdbcType=VARCHAR},
</if>
<if test="record.baseinfo != null">
BaseInfo = #{record.baseinfo,jdbcType=VARCHAR},
</if>
<if test="record.telephone != null">
Telephone = #{record.telephone,jdbcType=VARCHAR},
</if>
<if test="record.unitlocation != null">
UnitLocation = #{record.unitlocation,jdbcType=VARCHAR},
</if>
<if test="record.latitude != null">
Latitude = #{record.latitude,jdbcType=VARCHAR},
</if>
<if test="record.longitude != null">
Longitude = #{record.longitude,jdbcType=VARCHAR},
</if>
<if test="record.comments != null">
Comments = #{record.comments,jdbcType=VARCHAR},
</if>
<if test="record.createdon != null">
CreatedOn = #{record.createdon,jdbcType=TIMESTAMP},
</if>
<if test="record.createdby != null">
CreatedBy = #{record.createdby,jdbcType=VARCHAR},
</if>
<if test="record.modifiedon != null">
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP},
</if>
<if test="record.modifiedby != null">
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR},
</if>
<if test="record.sysenterpriseid != null">
SysEnterpriseId = #{record.sysenterpriseid,jdbcType=CHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update SysUnit
set SysUnitId = #{record.sysunitid,jdbcType=CHAR},
OrgCode = #{record.orgcode,jdbcType=VARCHAR},
SuperiorUnitId = #{record.superiorunitid,jdbcType=CHAR},
UnitCode = #{record.unitcode,jdbcType=VARCHAR},
UnitName = #{record.unitname,jdbcType=VARCHAR},
PinYin = #{record.pinyin,jdbcType=VARCHAR},
UnitType = #{record.unittype,jdbcType=VARCHAR},
UnitAddress = #{record.unitaddress,jdbcType=VARCHAR},
SimpleName = #{record.simplename,jdbcType=VARCHAR},
Principal = #{record.principal,jdbcType=VARCHAR},
MobileTel = #{record.mobiletel,jdbcType=VARCHAR},
BaseInfo = #{record.baseinfo,jdbcType=VARCHAR},
Telephone = #{record.telephone,jdbcType=VARCHAR},
UnitLocation = #{record.unitlocation,jdbcType=VARCHAR},
Latitude = #{record.latitude,jdbcType=VARCHAR},
Longitude = #{record.longitude,jdbcType=VARCHAR},
Comments = #{record.comments,jdbcType=VARCHAR},
CreatedOn = #{record.createdon,jdbcType=TIMESTAMP},
CreatedBy = #{record.createdby,jdbcType=VARCHAR},
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP},
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR},
SysEnterpriseId = #{record.sysenterpriseid,jdbcType=CHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.rzyc.model.user.SysUnit">
update SysUnit
<set>
<if test="orgcode != null">
OrgCode = #{orgcode,jdbcType=VARCHAR},
</if>
<if test="superiorunitid != null">
SuperiorUnitId = #{superiorunitid,jdbcType=CHAR},
</if>
<if test="unitcode != null">
UnitCode = #{unitcode,jdbcType=VARCHAR},
</if>
<if test="unitname != null">
UnitName = #{unitname,jdbcType=VARCHAR},
</if>
<if test="pinyin != null">
PinYin = #{pinyin,jdbcType=VARCHAR},
</if>
<if test="unittype != null">
UnitType = #{unittype,jdbcType=VARCHAR},
</if>
<if test="unitaddress != null">
UnitAddress = #{unitaddress,jdbcType=VARCHAR},
</if>
<if test="simplename != null">
SimpleName = #{simplename,jdbcType=VARCHAR},
</if>
<if test="principal != null">
Principal = #{principal,jdbcType=VARCHAR},
</if>
<if test="mobiletel != null">
MobileTel = #{mobiletel,jdbcType=VARCHAR},
</if>
<if test="baseinfo != null">
BaseInfo = #{baseinfo,jdbcType=VARCHAR},
</if>
<if test="telephone != null">
Telephone = #{telephone,jdbcType=VARCHAR},
</if>
<if test="unitlocation != null">
UnitLocation = #{unitlocation,jdbcType=VARCHAR},
</if>
<if test="latitude != null">
Latitude = #{latitude,jdbcType=VARCHAR},
</if>
<if test="longitude != null">
Longitude = #{longitude,jdbcType=VARCHAR},
</if>
<if test="comments != null">
Comments = #{comments,jdbcType=VARCHAR},
</if>
<if test="createdon != null">
CreatedOn = #{createdon,jdbcType=TIMESTAMP},
</if>
<if test="createdby != null">
CreatedBy = #{createdby,jdbcType=VARCHAR},
</if>
<if test="modifiedon != null">
ModifiedOn = #{modifiedon,jdbcType=TIMESTAMP},
</if>
<if test="modifiedby != null">
ModifiedBy = #{modifiedby,jdbcType=VARCHAR},
</if>
<if test="sysenterpriseid != null">
SysEnterpriseId = #{sysenterpriseid,jdbcType=CHAR},
</if>
</set>
where SysUnitId = #{sysunitid,jdbcType=CHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.rzyc.model.user.SysUnit">
update SysUnit
set OrgCode = #{orgcode,jdbcType=VARCHAR},
SuperiorUnitId = #{superiorunitid,jdbcType=CHAR},
UnitCode = #{unitcode,jdbcType=VARCHAR},
UnitName = #{unitname,jdbcType=VARCHAR},
PinYin = #{pinyin,jdbcType=VARCHAR},
UnitType = #{unittype,jdbcType=VARCHAR},
UnitAddress = #{unitaddress,jdbcType=VARCHAR},
SimpleName = #{simplename,jdbcType=VARCHAR},
Principal = #{principal,jdbcType=VARCHAR},
MobileTel = #{mobiletel,jdbcType=VARCHAR},
BaseInfo = #{baseinfo,jdbcType=VARCHAR},
Telephone = #{telephone,jdbcType=VARCHAR},
UnitLocation = #{unitlocation,jdbcType=VARCHAR},
Latitude = #{latitude,jdbcType=VARCHAR},
Longitude = #{longitude,jdbcType=VARCHAR},
Comments = #{comments,jdbcType=VARCHAR},
CreatedOn = #{createdon,jdbcType=TIMESTAMP},
CreatedBy = #{createdby,jdbcType=VARCHAR},
ModifiedOn = #{modifiedon,jdbcType=TIMESTAMP},
ModifiedBy = #{modifiedby,jdbcType=VARCHAR},
SysEnterpriseId = #{sysenterpriseid,jdbcType=CHAR}
where SysUnitId = #{sysunitid,jdbcType=CHAR}
</update>
<!--部门信息-->
<resultMap id="UnitResultMap" type="com.rzyc.model.user.ListPerform">
<id column="ListPerformId" jdbcType="VARCHAR" property="listperformid" />
<result column="PerformClassName" jdbcType="VARCHAR" property="performclassname" />
</resultMap>
<!--政府部门-->
<select id="findAll" resultMap="UnitResultMap">
SELECT su.`SysUnitId` ListPerformId,su.`UnitName` PerformClassName,su.*
FROM `SysUnit` su ORDER BY su.`OrgCode` ASC
</select>
<!--部门列表-->
<select id="findByParentId" resultMap="BaseResultMap">
SELECT * FROM SysUnit su
WHERE 1 = 1
<if test="null != parentId and '' != parentId">
and su.`SuperiorUnitId` = #{parentId}
</if>
<if test="null == parentId or '' == parentId">
and (su.`SuperiorUnitId` = '' or su.SuperiorUnitId is null)
</if>
</select>
<!--部门列表-->
<select id="findUnit" resultMap="BaseResultMap">
SELECT * FROM SysUnit su
2022-12-09 12:00:29 +08:00
where 1 = 1
<if test="null != parentUnitId and '' != parentUnitId">
and FIND_IN_SET(#{parentUnitId},su.parent_path)
</if>
2022-09-16 15:07:17 +08:00
</select>
<!--部门列表-->
<resultMap id="UnitPageResultMap" type="com.rzyc.model.user.SysUnit">
<id column="SysUnitId" jdbcType="CHAR" property="sysunitid" />
<result column="OrgCode" jdbcType="VARCHAR" property="orgcode" />
<result column="SuperiorUnitId" jdbcType="CHAR" property="superiorunitid" />
<result column="UnitCode" jdbcType="VARCHAR" property="unitcode" />
<result column="UnitName" jdbcType="VARCHAR" property="unitname" />
<result column="CreatedOn" jdbcType="TIMESTAMP" property="createdon" />
<result column="CreatedBy" jdbcType="VARCHAR" property="createdby" />
<result column="ModifiedOn" jdbcType="TIMESTAMP" property="modifiedon" />
<result column="ModifiedBy" jdbcType="VARCHAR" property="modifiedby" />
<result column="SysEnterpriseId" jdbcType="CHAR" property="sysenterpriseid" />
<result column="IsHide" jdbcType="CHAR" property="isHide" />
</resultMap>
<!--部门列表-->
<select id="findByName" resultMap="UnitPageResultMap">
SELECT st.`UnitName` superName,su.*
FROM SysUnit su
LEFT JOIN SysUnit st ON su.`SuperiorUnitId` = st.`SysUnitId`
WHERE su.`UnitName` LIKE #{condition}
<if test="null != parentId and '' != parentId">
AND su.SuperiorUnitId = #{parentId}
</if>
2022-12-09 12:00:29 +08:00
<if test="null != parentUnitId and '' != parentUnitId">
and FIND_IN_SET(#{parentUnitId},su.parent_path)
</if>
2022-09-16 15:07:17 +08:00
</select>
<!--修改部门-->
<update id="changeUnit" >
update SysUnit
set
OrgCode = #{record.orgcode,jdbcType=VARCHAR},
SuperiorUnitId = #{record.superiorunitid,jdbcType=CHAR},
2022-12-09 12:00:29 +08:00
parent_path = #{record.parentPath,jdbcType=CHAR},
parent_name = #{record.parentName,jdbcType=CHAR},
2022-09-16 15:07:17 +08:00
UnitCode = #{record.unitcode,jdbcType=VARCHAR},
UnitName = #{record.unitname,jdbcType=VARCHAR},
PinYin = #{record.pinyin,jdbcType=VARCHAR},
UnitType = #{record.unittype,jdbcType=VARCHAR},
UnitAddress = #{record.unitaddress,jdbcType=VARCHAR},
SimpleName = #{record.simplename,jdbcType=VARCHAR},
Principal = #{record.principal,jdbcType=VARCHAR},
MobileTel = #{record.mobiletel,jdbcType=VARCHAR},
BaseInfo = #{record.baseinfo,jdbcType=VARCHAR},
Telephone = #{record.telephone,jdbcType=VARCHAR},
UnitLocation = #{record.unitlocation,jdbcType=VARCHAR},
Latitude = #{record.latitude,jdbcType=VARCHAR},
Longitude = #{record.longitude,jdbcType=VARCHAR},
IsHide = #{record.isHide,jdbcType=VARCHAR},
Comments = #{record.comments,jdbcType=VARCHAR},
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP},
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR}
where SysUnitId = #{record.sysunitid,jdbcType=CHAR}
</update>
<!--登录数据-->
<resultMap id="StatisticsResultMap" type="com.rzyc.bean.user.UnitLoginData">
<id column="SysUnitId" jdbcType="CHAR" property="sysunitid" />
<result column="UnitName" jdbcType="VARCHAR" property="unitname" />
<result column="userNum" jdbcType="INTEGER" property="userNum" />
<result column="loginNum" jdbcType="INTEGER" property="loginNum" />
</resultMap>
<!--登录数据-->
<select id="loginData" resultMap="StatisticsResultMap">
SELECT su.`SysUnitId`,su.`UnitName`,
(SELECT COUNT(*)
FROM SysUser sr
WHERE sr.`SysUnitOrEntId` = su.`SysUnitId`
AND sr.`State` = '启用') userNum,
(SELECT COUNT(1)
FROM SysLogAuth sl
LEFT JOIN SysUser sr ON sl.`AuthUserId` = sr.`SysUserId`
WHERE sr.`SysUnitOrEntId` = su.`SysUnitId`
AND sr.`State` = '启用') loginNum
FROM SysUnit su
WHERE su.`SuperiorUnitId` = #{unitId}
</select>
<!--部门检查情况-->
<resultMap id="UnitCheckResultMap" type="com.rzyc.bean.user.UnitCheck">
<id column="SysUnitId" jdbcType="CHAR" property="sysUnitId" />
<result column="UnitName" jdbcType="VARCHAR" property="unitName" />
<result column="checkEnt" jdbcType="INTEGER" property="checkEnt" />
<result column="dangerNum" jdbcType="INTEGER" property="dangerNum" />
<result column="rectifyNum" jdbcType="INTEGER" property="rectifyNum" />
<result column="notRectifyNum" jdbcType="INTEGER" property="notRectifyNum" />
</resultMap>
<!--部门检查情况-->
<select id="unitCheck" resultMap="UnitCheckResultMap">
SELECT su.`SysUnitId`,su.`UnitName`,
(
SELECT COUNT(1) FROM BookEntCheck bt
WHERE bt.`CheckUniy` = su.`SysUnitId`
<if test="null != startTime and '' != startTime">
AND bt.`BegCheckDate` > #{startTime}
</if>
<if test="null != endTime and '' != endTime">
AND bt.`BegCheckDate` &lt; #{endTime}
</if>
) checkNum,
(
SELECT COUNT(*) FROM BookEntHT bh
LEFT JOIN BookEntCheck bt ON bh.`BookEntCheckId` = bt.`BookEntCheckId`
WHERE bt.`CheckUniy` = su.`SysUnitId`
<if test="null != startTime and '' != startTime">
AND bt.`BegCheckDate` > #{startTime}
</if>
<if test="null != endTime and '' != endTime">
AND bt.`BegCheckDate` &lt; #{endTime}
</if>
) dangerNum,
(
SELECT COUNT(*) FROM BookEntHT bh
LEFT JOIN BookEntCheck bt ON bh.`BookEntCheckId` = bt.`BookEntCheckId`
WHERE bt.`CheckUniy` = su.`SysUnitId` AND bh.HTState = '已整改'
<if test="null != startTime and '' != startTime">
AND bt.`BegCheckDate` > #{startTime}
</if>
<if test="null != endTime and '' != endTime">
AND bt.`BegCheckDate` &lt; #{endTime}
</if>
) rectifyNum,
(
SELECT COUNT(*) FROM BookEntHT bh
LEFT JOIN BookEntCheck bt ON bh.`BookEntCheckId` = bt.`BookEntCheckId`
WHERE bt.`CheckUniy` = su.`SysUnitId` AND bh.HTState = '未整改'
<if test="null != startTime and '' != startTime">
AND bt.`BegCheckDate` > #{startTime}
</if>
<if test="null != endTime and '' != endTime">
AND bt.`BegCheckDate` &lt; #{endTime}
</if>
) notRectifyNum
FROM `SysUnit` su WHERE su.`SuperiorUnitId` = #{unitId}
</select>
<!--企业架构-->
<resultMap id="EntBuildResultMap" type="com.rzyc.bean.ent.EntBulid">
<id column="SysUnitId" jdbcType="CHAR" property="sysUnitId" />
<result column="UnitName" jdbcType="VARCHAR" property="unitName" />
<result column="entUserNum" jdbcType="INTEGER" property="entUserNum" />
<result column="notBuildNum" jdbcType="INTEGER" property="notBuildNum" />
</resultMap>
<!--企业架构-->
<select id="entBuild" resultMap="EntBuildResultMap">
SELECT su.`SysUnitId`,su.`UnitName`,
(
SELECT COUNT(*) FROM SysEnterprise se
WHERE se.`ManagerDept` = su.`SysUnitId`
AND se.`State` = '启用'
) entUserNum,
(
SELECT COUNT(*) FROM SysEnterprise se
LEFT JOIN SysEntUser su ON se.`SysEnterpriseId` = su.`SysEnterpriseId`
WHERE se.`ManagerDept` = su.`SysUnitId`
AND su.forbiddenStatus = 1
AND se.`State` = '启用'
AND su.`SysEntUserId` IS NULL
) notBuildNum
FROM SysUnit su
WHERE su.`SuperiorUnitId` = #{unitId}
</select>
<!--企业清单录入情况-->
<resultMap id="EntListResultMap" type="com.rzyc.bean.ent.EntList">
<id column="SysUnitId" jdbcType="CHAR" property="sysUnitId" />
<result column="UnitName" jdbcType="VARCHAR" property="unitName" />
<result column="entUserNum" jdbcType="INTEGER" property="entUserNum" />
<result column="notListNum" jdbcType="INTEGER" property="notListNum" />
</resultMap>
<!--企业清单录入情况-->
<select id="entList" resultMap="EntListResultMap">
SELECT su.`SysUnitId`,su.`UnitName`,
(
SELECT COUNT(*) FROM SysEnterprise se
WHERE se.`ManagerDept` = su.`SysUnitId`
AND se.`State` = '启用'
) entUserNum,
(
SELECT COUNT(*) FROM SysEnterprise se
LEFT JOIN SysEntList sl ON se.`SysEnterpriseId` = sl.`SysEnterpriseId`
WHERE se.`ManagerDept` = su.`SysUnitId`
AND se.`State` = '启用'
AND sl.`SysEntListId` IS NULL
)notListNum
FROM SysUnit su
WHERE su.`SuperiorUnitId` = #{unitId}
</select>
<!--通过名字查询-->
<select id="findByUnitName" resultMap="BaseResultMap">
SELECT * FROM SysUnit su WHERE su.`UnitName` = #{unitName}
and su.`SuperiorUnitId` = #{superId}
</select>
</mapper>