320 lines
12 KiB
XML
320 lines
12 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.rzyc.mapper.DutyTreeMapper">
|
|
<resultMap id="BaseResultMap" type="com.rzyc.model.DutyTree">
|
|
<result column="duty_tree_id" jdbcType="VARCHAR" property="dutyTreeId" />
|
|
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
|
<result column="target_id" jdbcType="VARCHAR" property="targetId" />
|
|
<result column="target_type" jdbcType="INTEGER" property="targetType" />
|
|
<result column="modified" jdbcType="VARCHAR" property="modified" />
|
|
<result column="created" jdbcType="VARCHAR" property="created" />
|
|
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
|
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
|
</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">
|
|
duty_tree_id, user_id, target_id, target_type, modified, created, modify_time, create_time
|
|
</sql>
|
|
<select id="selectByExample" parameterType="com.rzyc.model.DutyTreeExample" resultMap="BaseResultMap">
|
|
select
|
|
<if test="distinct">
|
|
distinct
|
|
</if>
|
|
<include refid="Base_Column_List" />
|
|
from duty_tree
|
|
<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>
|
|
<delete id="deleteByExample" parameterType="com.rzyc.model.DutyTreeExample">
|
|
delete from duty_tree
|
|
<if test="_parameter != null">
|
|
<include refid="Example_Where_Clause" />
|
|
</if>
|
|
</delete>
|
|
<insert id="insert" parameterType="com.rzyc.model.DutyTree">
|
|
insert into duty_tree (duty_tree_id, user_id, target_id,
|
|
target_type, modified, created,
|
|
modify_time, create_time)
|
|
values (#{dutyTreeId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{targetId,jdbcType=VARCHAR},
|
|
#{targetType,jdbcType=INTEGER}, #{modified,jdbcType=VARCHAR}, #{created,jdbcType=VARCHAR},
|
|
#{modifyTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP})
|
|
</insert>
|
|
<insert id="insertSelective" parameterType="com.rzyc.model.DutyTree">
|
|
insert into duty_tree
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="dutyTreeId != null">
|
|
duty_tree_id,
|
|
</if>
|
|
<if test="userId != null">
|
|
user_id,
|
|
</if>
|
|
<if test="targetId != null">
|
|
target_id,
|
|
</if>
|
|
<if test="targetType != null">
|
|
target_type,
|
|
</if>
|
|
<if test="modified != null">
|
|
modified,
|
|
</if>
|
|
<if test="created != null">
|
|
created,
|
|
</if>
|
|
<if test="modifyTime != null">
|
|
modify_time,
|
|
</if>
|
|
<if test="createTime != null">
|
|
create_time,
|
|
</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="dutyTreeId != null">
|
|
#{dutyTreeId,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="userId != null">
|
|
#{userId,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="targetId != null">
|
|
#{targetId,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="targetType != null">
|
|
#{targetType,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="modified != null">
|
|
#{modified,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="created != null">
|
|
#{created,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="modifyTime != null">
|
|
#{modifyTime,jdbcType=TIMESTAMP},
|
|
</if>
|
|
<if test="createTime != null">
|
|
#{createTime,jdbcType=TIMESTAMP},
|
|
</if>
|
|
</trim>
|
|
</insert>
|
|
<select id="countByExample" parameterType="com.rzyc.model.DutyTreeExample" resultType="java.lang.Long">
|
|
select count(*) from duty_tree
|
|
<if test="_parameter != null">
|
|
<include refid="Example_Where_Clause" />
|
|
</if>
|
|
</select>
|
|
<update id="updateByExampleSelective" parameterType="map">
|
|
update duty_tree
|
|
<set>
|
|
<if test="record.dutyTreeId != null">
|
|
duty_tree_id = #{record.dutyTreeId,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="record.userId != null">
|
|
user_id = #{record.userId,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="record.targetId != null">
|
|
target_id = #{record.targetId,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="record.targetType != null">
|
|
target_type = #{record.targetType,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="record.modified != null">
|
|
modified = #{record.modified,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="record.created != null">
|
|
created = #{record.created,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="record.modifyTime != null">
|
|
modify_time = #{record.modifyTime,jdbcType=TIMESTAMP},
|
|
</if>
|
|
<if test="record.createTime != null">
|
|
create_time = #{record.createTime,jdbcType=TIMESTAMP},
|
|
</if>
|
|
</set>
|
|
<if test="_parameter != null">
|
|
<include refid="Update_By_Example_Where_Clause" />
|
|
</if>
|
|
</update>
|
|
<update id="updateByExample" parameterType="map">
|
|
update duty_tree
|
|
set duty_tree_id = #{record.dutyTreeId,jdbcType=VARCHAR},
|
|
user_id = #{record.userId,jdbcType=VARCHAR},
|
|
target_id = #{record.targetId,jdbcType=VARCHAR},
|
|
target_type = #{record.targetType,jdbcType=INTEGER},
|
|
modified = #{record.modified,jdbcType=VARCHAR},
|
|
created = #{record.created,jdbcType=VARCHAR},
|
|
modify_time = #{record.modifyTime,jdbcType=TIMESTAMP},
|
|
create_time = #{record.createTime,jdbcType=TIMESTAMP}
|
|
<if test="_parameter != null">
|
|
<include refid="Update_By_Example_Where_Clause" />
|
|
</if>
|
|
</update>
|
|
|
|
<!--批量插入-->
|
|
<insert id="insertList">
|
|
insert into duty_tree (duty_tree_id, user_id, target_id,
|
|
target_type, modified, created,
|
|
modify_time, create_time)
|
|
values
|
|
<foreach collection="records" item="record" separator=",">
|
|
(#{record.dutyTreeId,jdbcType=VARCHAR}, #{record.userId,jdbcType=VARCHAR},
|
|
#{record.targetId,jdbcType=VARCHAR},
|
|
#{record.targetType,jdbcType=INTEGER}, #{record.modified,jdbcType=VARCHAR},
|
|
#{record.created,jdbcType=VARCHAR},
|
|
#{record.modifyTime,jdbcType=TIMESTAMP}, #{record.createTime,jdbcType=TIMESTAMP})
|
|
</foreach>
|
|
|
|
</insert>
|
|
|
|
<!--删除用户责任书-->
|
|
<delete id="delByUserId">
|
|
delete from duty_tree where user_id = #{userId} and target_type = #{targetType}
|
|
</delete>
|
|
|
|
<!--责任树-->
|
|
<select id="findTree" resultMap="BaseResultMap">
|
|
SELECT * FROM `duty_tree` dt
|
|
WHERE dt.`target_type` = #{targetType}
|
|
AND dt.`user_id` = #{userId}
|
|
AND dt.`target_id` = #{targetId}
|
|
</select>
|
|
|
|
<!--查询企业责任人-->
|
|
<select id="findByTargetId" resultMap="BaseResultMap">
|
|
SELECT * FROM duty_tree dt WHERE dt.`target_id` = #{targetId} AND dt.`target_type` = 2
|
|
</select>
|
|
|
|
<!--需检查企业总数-->
|
|
<select id="userEntNum" resultType="java.lang.Integer">
|
|
SELECT count(se.SysEnterpriseId) FROM `duty_tree` dt
|
|
left join SysEnterprise se on dt.target_id = se.SysEnterpriseId
|
|
WHERE dt.`user_id` = #{userId}
|
|
and se.State = '启用'
|
|
AND dt.`target_type` = 2;
|
|
</select>
|
|
|
|
<!--当月检查企业总数-->
|
|
<select id="userCheckEntNum" resultType="java.lang.Integer">
|
|
SELECT count(se.SysEnterpriseId) FROM `duty_tree` dt
|
|
left join SysEnterprise se on dt.target_id = se.SysEnterpriseId
|
|
WHERE dt.`user_id` = #{userId}
|
|
and se.State = '启用'
|
|
|
|
and ( select count(*) from ChkPerson cp
|
|
left join BookEntCheck bc on cp.BookEntCheckId = bc.BookEntCheckId
|
|
where bc.BaseEntId = se.SysEnterpriseId
|
|
and date_format(cp.CreatedOn,'%Y-%m')=date_format(now(),'%Y-%m')
|
|
and cp.SysUserId = #{userId} ) > 0
|
|
|
|
|
|
AND dt.`target_type` = 2;
|
|
</select>
|
|
|
|
<!--责任树用户数-->
|
|
<select id="countUser" resultType="java.lang.Integer">
|
|
SELECT count(*)
|
|
FROM `duty_tree` dt
|
|
LEFT JOIN SysUser su ON dt.`target_id` = su.`SysUserId`
|
|
WHERE dt.user_id = #{userId}
|
|
AND dt.target_type = 1
|
|
AND su.`State` = '启用'
|
|
|
|
</select>
|
|
|
|
<!--责任树企业数-->
|
|
<select id="countEnt" resultType="java.lang.Integer">
|
|
SELECT count(*) FROM `duty_tree` dt
|
|
LEFT JOIN SysEnterprise se ON dt.target_id = se.SysEnterpriseId
|
|
WHERE dt.user_id = #{userId}
|
|
AND dt.target_type = 2 AND se.State = '启用'
|
|
</select>
|
|
|
|
<!--上级用户-->
|
|
<select id="topUser" resultMap="BaseResultMap">
|
|
SELECT * FROM `duty_tree` dt WHERE dt.`target_id` = #{targetId}
|
|
</select>
|
|
|
|
<!--下级用户-->
|
|
<select id="findUser" resultMap="BaseResultMap">
|
|
SELECT * FROM `duty_tree` dt WHERE dt.`user_id` = #{userId} AND dt.`target_type` = 1
|
|
</select>
|
|
|
|
<!--通过目标id查询-->
|
|
<select id="findTargetId" resultMap="BaseResultMap">
|
|
SELECT * FROM `duty_tree` dt
|
|
WHERE dt.target_id = #{targetId}
|
|
ORDER BY dt.`create_time` DESC LIMIT 1
|
|
</select>
|
|
|
|
<!--用户已选择企业信息-->
|
|
<select id="findByUserId" resultMap="BaseResultMap">
|
|
SELECT * FROM `duty_tree` dt WHERE dt.`user_id` = #{userId} AND dt.`target_type` = 2
|
|
</select>
|
|
</mapper>
|