根据岗位编号查询用户,以及生物安全模块的数据分离userId,deptId字段新增修改
This commit is contained in:
@@ -150,9 +150,12 @@
|
||||
|
||||
<select id="searchEarNumbers" resultType="java.lang.String">
|
||||
SELECT DISTINCT manage_tags
|
||||
FROM bas_sheep
|
||||
WHERE manage_tags LIKE CONCAT(#{query}, '%')
|
||||
FROM bas_sheep b
|
||||
<where>
|
||||
manage_tags LIKE CONCAT(#{query}, '%')
|
||||
AND is_delete = 0
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER by manage_tags
|
||||
LIMIT 50
|
||||
</select>
|
||||
|
||||
@@ -58,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and datetime between #{params.beginDatetime} and #{params.endDatetime}
|
||||
</if>
|
||||
<if test="technical != null and technical != ''">and technical = #{technical}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
|
||||
<!-- 基准排序:日期永远第一序,降序 -->
|
||||
@@ -78,13 +79,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
insert into sw_deworm
|
||||
(sheep_id, usage_id, variety, sheep_type, gender, month_age,
|
||||
parity, breed,datetime, technical, comment,
|
||||
update_by, update_time, create_by, create_time)
|
||||
update_by, update_time, create_by, create_time,user_id, dept_id)
|
||||
values
|
||||
<foreach collection="list" item="d" separator=",">
|
||||
(#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType},
|
||||
#{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime},
|
||||
#{d.technical}, #{d.comment},
|
||||
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime})
|
||||
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime},#{d.userId},#{d.deptId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="result != null "> and result = #{result}</if>
|
||||
<if test="treatDay != null "> and treat_day = #{treatDay}</if>
|
||||
<if test="sheepfoldId != null "> and sd.sheepfold_id = #{sheepfoldId}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
<choose>
|
||||
@@ -101,6 +102,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="sheepfoldId != null">sheepfold_id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="treatId != null">#{treatId},</if>
|
||||
@@ -118,6 +121,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="sheepfoldId != null">#{sheepfoldId},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
ds.sheepfold_name
|
||||
FROM sw_disinfect sd
|
||||
LEFT JOIN da_sheepfold ds ON ds.id = sd.sheepfold_id
|
||||
WHERE 1 = 1
|
||||
<where>1 = 1
|
||||
<if test="sheepfoldId != null"> AND sd.sheepfold_id = #{sheepfoldId}</if>
|
||||
<if test="datetime != null"> AND sd.datetime = #{datetime}</if>
|
||||
<if test="technician != null and technician != ''"> AND sd.technician = #{technician}</if>
|
||||
@@ -61,6 +61,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND sm.name like concat('%',#{mediName},'%')
|
||||
)
|
||||
</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
|
||||
</select>
|
||||
@@ -72,12 +74,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<insert id="insertDisinfect" parameterType="Disinfect" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sw_disinfect
|
||||
(sheepfold_id, datetime, technician, way, usage_id, ratio, comment, update_by, update_time, create_by, create_time)
|
||||
(sheepfold_id, datetime, technician, way, usage_id, ratio, comment, update_by, update_time, create_by, create_time, user_id,dept_id)
|
||||
values
|
||||
<foreach collection="list" item="d" separator=",">
|
||||
(#{d.sheepfoldId}, #{d.datetime}, #{d.technician}, #{d.way},
|
||||
#{d.usageId}, #{d.ratio}, #{d.comment},
|
||||
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime})
|
||||
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime},#{d.userId},#{d.deptId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
|
||||
<if test="technical != null and technical != ''"> and technical = #{technical}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
<!-- 基准排序:日期永远第一序,降序 -->
|
||||
ORDER BY datetime DESC
|
||||
@@ -81,13 +82,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
insert into sw_health
|
||||
(sheep_id, usage_id, variety, sheep_type, gender, month_age,
|
||||
parity, breed,datetime, technical, comment,
|
||||
update_by, update_time, create_by, create_time)
|
||||
update_by, update_time, create_by, create_time,user_id,dept_id)
|
||||
values
|
||||
<foreach collection="list" item="d" separator=",">
|
||||
(#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType},
|
||||
#{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime},
|
||||
#{d.technical}, #{d.comment},
|
||||
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime})
|
||||
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime},#{d.userId},#{d.deptId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
<if test="params.beginDatetime != null and params.beginDatetime != '' and params.endDatetime != null and params.endDatetime != ''"> and datetime between #{params.beginDatetime} and #{params.endDatetime}</if>
|
||||
<if test="technical != null and technical != ''"> and technical = #{technical}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
<!-- 基准排序:日期永远第一序,降序 -->
|
||||
ORDER BY datetime DESC
|
||||
@@ -79,13 +80,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
insert into sw_immunity
|
||||
(sheep_id, usage_id, variety, sheep_type, gender, month_age,
|
||||
parity, breed,datetime, technical, comment,
|
||||
update_by, update_time, create_by, create_time)
|
||||
update_by, update_time, create_by, create_time,user_id,dept_id)
|
||||
values
|
||||
<foreach collection="list" item="d" separator=",">
|
||||
(#{d.sheepId}, #{d.usageId}, #{d.variety}, #{d.sheepType},
|
||||
#{d.gender}, #{d.monthAge}, #{d.parity},#{d.breed}, #{d.datetime},
|
||||
#{d.technical}, #{d.comment},
|
||||
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime})
|
||||
#{d.updateBy}, #{d.updateTime}, #{d.createBy}, #{d.createTime},#{d.userId},#{d.deptId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="result != null "> and result = #{result}</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="sheepType != null and sheepType!= ''"> and sqr.sheep_type=#{sheepType}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
<choose>
|
||||
@@ -112,7 +113,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update_by,
|
||||
update_time,
|
||||
create_by,
|
||||
create_time
|
||||
create_time,
|
||||
user_id,
|
||||
dept_id
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
@@ -133,7 +136,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{item.updateBy},
|
||||
#{item.updateTime},
|
||||
#{item.createBy},
|
||||
#{item.createTime}
|
||||
#{item.createTime},
|
||||
#{item.userId},
|
||||
#{item.deptId}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
@@ -111,6 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND sm.name LIKE CONCAT('%', #{name}, '%')
|
||||
)
|
||||
</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER BY smu.datetime DESC
|
||||
</select>
|
||||
@@ -162,6 +163,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
@@ -173,6 +176,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="diseaseId != null "> and disease_id = #{diseaseId}</if>
|
||||
<if test="status != null and status !=''"> and status = #{status}</if>
|
||||
<if test="veterinary != null and veterinary != ''"> and veterinary = #{veterinary}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
ORDER BY datetime DESC
|
||||
<choose>
|
||||
@@ -121,6 +122,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="userId != null">#{user_id},</if>
|
||||
<if test="deptId != null">#{dept_id},</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="diagId != null">#{diagId},</if>
|
||||
@@ -144,6 +147,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -152,14 +157,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
(diag_id, sheep_id, variety, sheep_type, month_age, gender,
|
||||
parity, breed, lact_day, gest_day, datetime,
|
||||
disease_id, disease_pid, veterinary, usage_id,status ,
|
||||
comment, update_by, update_time, create_by, create_time)
|
||||
comment, update_by, update_time, create_by, create_time, user_id, dept_id)
|
||||
values
|
||||
<foreach collection="list" item="t" separator=",">
|
||||
(#{t.diagId}, #{t.sheepId}, #{t.variety}, #{t.sheepType},
|
||||
#{t.monthAge}, #{t.gender}, #{t.parity}, #{t.breed},
|
||||
#{t.lactDay}, #{t.gestDay}, #{t.datetime}, #{t.diseaseId},
|
||||
#{t.diseasePid}, #{t.veterinary},#{t.usageId}, #{t.status}, #{t.comment},
|
||||
#{t.updateBy}, #{t.updateTime},#{t.createBy}, #{t.createTime})
|
||||
#{t.updateBy}, #{t.updateTime},#{t.createBy}, #{t.createTime},#{t.userId},#{t.deptId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
33
zhyc-module/src/main/resources/mapper/common/DeptMapper.xml
Normal file
33
zhyc-module/src/main/resources/mapper/common/DeptMapper.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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.zhyc.module.common.mapper.DeptMapper">
|
||||
|
||||
<resultMap type="Dept" id="DeptResult">
|
||||
<result property="deptId" column="dept_id" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="leader" column="leader" />
|
||||
<result property="status" column="status" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
</resultMap>
|
||||
|
||||
<select id="selectTopSecondLevelDept" resultMap="DeptResult" parameterType="Long">
|
||||
SELECT d2.*
|
||||
FROM sys_dept d1
|
||||
LEFT JOIN sys_dept d2
|
||||
ON d2.dept_id = CASE
|
||||
WHEN d1.ancestors = '0' OR d1.parent_id = 0 THEN d1.dept_id
|
||||
-- 二级部门:逗号只出现1次,返回自身ID
|
||||
WHEN LENGTH(d1.ancestors) - LENGTH(REPLACE(d1.ancestors, ',', '')) = 1
|
||||
THEN d1.dept_id
|
||||
-- 三级及以上:取第3个值(索引2)即二级部门ID
|
||||
ELSE CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(d1.ancestors, ',', 3), ',', -1) AS UNSIGNED)
|
||||
END
|
||||
WHERE d1.dept_id = #{deptId}
|
||||
AND d2.dept_id IS NOT NULL
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -12,14 +12,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<select id="getUserListByCode" resultMap="UserResult">
|
||||
SELECT u.user_id, nick_name , post_name , post_code
|
||||
FROM sys_role r
|
||||
JOIN sys_user_role ur ON r.role_id = ur.role_id
|
||||
JOIN sys_user u ON ur.user_id = u.user_id
|
||||
JOIN sys_user_post up ON u.user_id = up.user_id
|
||||
JOIN sys_post p ON up.post_id = p.post_id
|
||||
WHERE p.post_code LIKE CONCAT('%', #{postCode}, '%')
|
||||
AND r.status = 0 and r.del_flag = 0;
|
||||
</select>
|
||||
<choose>
|
||||
<!-- deptId = 0:查询所有用户,不限制部门 -->
|
||||
<when test="deptId == 0">
|
||||
SELECT DISTINCT u.user_id, u.nick_name, p.post_name, p.post_code
|
||||
FROM sys_user u
|
||||
JOIN sys_user_post up ON u.user_id = up.user_id
|
||||
JOIN sys_post p ON up.post_id = p.post_id
|
||||
WHERE p.post_code LIKE CONCAT('%', #{postCode}, '%')
|
||||
AND u.status = 0
|
||||
AND u.del_flag = 0
|
||||
</when>
|
||||
|
||||
<!-- deptId != 0:递归查询该部门及所有子部门 -->
|
||||
<otherwise>
|
||||
WITH RECURSIVE dept_tree AS (
|
||||
SELECT dept_id FROM sys_dept WHERE dept_id = #{deptId}
|
||||
UNION ALL
|
||||
SELECT d.dept_id
|
||||
FROM sys_dept d
|
||||
INNER JOIN dept_tree dt ON d.parent_id = dt.dept_id
|
||||
)
|
||||
SELECT DISTINCT u.user_id, u.nick_name, p.post_name, p.post_code
|
||||
FROM dept_tree dt
|
||||
JOIN sys_user u ON u.dept_id = dt.dept_id
|
||||
JOIN sys_user_post up ON u.user_id = up.user_id
|
||||
JOIN sys_post p ON up.post_id = p.post_id
|
||||
WHERE p.post_code LIKE CONCAT('%', #{postCode}, '%')
|
||||
AND u.status = 0
|
||||
AND u.del_flag = 0
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user