From 0d5d25e4806c403d8f3e2188097359ccfa31d6dc Mon Sep 17 00:00:00 2001
From: lin <sbla5888@163.com>
Date: Wed, 28 Feb 2024 17:53:23 +0800
Subject: [PATCH] 打卡数据过滤
---
src/main/java/org/springblade/modules/checkInRecords/service/impl/CheckInRecordsServiceImpl.java | 29 +++++++--
src/main/java/org/springblade/modules/checkInRecords/vo/CheckInRecordsVO.java | 11 +++
src/main/java/org/springblade/modules/checkInRecords/mapper/CheckInRecordsMapper.xml | 112 ++++++++++++++++++++++---------------
src/main/java/org/springblade/modules/checkInRecords/mapper/CheckInRecordsMapper.java | 12 +++
4 files changed, 111 insertions(+), 53 deletions(-)
diff --git a/src/main/java/org/springblade/modules/checkInRecords/mapper/CheckInRecordsMapper.java b/src/main/java/org/springblade/modules/checkInRecords/mapper/CheckInRecordsMapper.java
index 470c80a..d4a7900 100644
--- a/src/main/java/org/springblade/modules/checkInRecords/mapper/CheckInRecordsMapper.java
+++ b/src/main/java/org/springblade/modules/checkInRecords/mapper/CheckInRecordsMapper.java
@@ -39,7 +39,16 @@
* @param checkInRecords
* @return
*/
- List<CheckInRecordsVO> selectCheckInRecordsPage(IPage page, @Param("checkInRecords") CheckInRecordsVO checkInRecords);
+ List<CheckInRecordsVO> selectCheckInRecordsPage(IPage page,
+ @Param("checkInRecords") CheckInRecordsVO checkInRecords,
+ @Param("deptIdList") List<Long> deptIdList);
+
+
+// List<CheckInRecordsVO> selectCheckInRecordsPage(IPage<CheckInRecordsVO> page,
+// @Param("checkInRecords")CheckInRecordsVO checkInRecords,
+// @Param("isAdministrator") Integer isAdministrator,
+// @Param("gridCodeList")List gridCodeList,
+// @Param("regionChildCodesList")List regionChildCodesList);
/**
@@ -57,4 +66,5 @@
* @return 打卡记录表集合
*/
public List<CheckInRecordsDTO> selectCheckInRecordsList(CheckInRecordsDTO checkInRecordsDTO);
+
}
diff --git a/src/main/java/org/springblade/modules/checkInRecords/mapper/CheckInRecordsMapper.xml b/src/main/java/org/springblade/modules/checkInRecords/mapper/CheckInRecordsMapper.xml
index 52b5e66..642c787 100644
--- a/src/main/java/org/springblade/modules/checkInRecords/mapper/CheckInRecordsMapper.xml
+++ b/src/main/java/org/springblade/modules/checkInRecords/mapper/CheckInRecordsMapper.xml
@@ -19,59 +19,78 @@
jcir.lat,
jcir.address,
jcir.deleted_flag,
- bu.`name`
+ bu.`name`,
+ bd.region_code
FROM
jczz_check_in_records jcir
LEFT JOIN blade_user bu ON bu.id = jcir.create_user_id
+ LEFT JOIN blade_dept bd on bd.id = bu.dept_id
<where>
- <if test="checkInRecords.id != null "> and jcir.id = #{checkInRecords.id}</if>
- <if test="checkInRecords.createUserId != null "> and jcir.create_user_id = #{checkInRecords.createUserId}</if>
- <if test="checkInRecords.createTime != null "> and jcir.create_time = #{checkInRecords.createTime}</if>
- <if test="checkInRecords.workTheme != null and checkInRecords.workTheme != ''"> and jcir.work_theme = #{checkInRecords.workTheme}</if>
- <if test="checkInRecords.workContent != null and checkInRecords.workContent != ''"> and jcir.work_content = #{checkInRecords.workContent}</if>
- <if test="checkInRecords.img != null and checkInRecords.img != ''"> and jcir.img = #{checkInRecords.img}</if>
- <if test="checkInRecords.lng != null and checkInRecords.lng != ''"> and jcir.lng = #{checkInRecords.lng}</if>
- <if test="checkInRecords.lat != null and checkInRecords.lat != ''"> and jcir.lat = #{checkInRecords.lat}</if>
- <if test="checkInRecords.address != null and checkInRecords.address != ''"> and jcir.address = #{checkInRecords.address}</if>
- <if test="checkInRecords.deletedFlag != null "> and jcir.deleted_flag = #{checkInRecords.deletedFlag}</if>
- <if test="checkInRecords.name != null and checkInRecords.name !='' "> and bu.name like concat('%',#{checkInRecords.name},'%') </if>
+ <if test="checkInRecords.id != null ">and jcir.id = #{checkInRecords.id}</if>
+ <if test="checkInRecords.createUserId != null ">and jcir.create_user_id = #{checkInRecords.createUserId}
+ </if>
+ <if test="checkInRecords.createTime != null ">and jcir.create_time = #{checkInRecords.createTime}</if>
+ <if test="checkInRecords.workTheme != null and checkInRecords.workTheme != ''">and jcir.work_theme =
+ #{checkInRecords.workTheme}
+ </if>
+ <if test="checkInRecords.workContent != null and checkInRecords.workContent != ''">and jcir.work_content =
+ #{checkInRecords.workContent}
+ </if>
+ <if test="checkInRecords.img != null and checkInRecords.img != ''">and jcir.img = #{checkInRecords.img}
+ </if>
+ <if test="checkInRecords.lng != null and checkInRecords.lng != ''">and jcir.lng = #{checkInRecords.lng}
+ </if>
+ <if test="checkInRecords.lat != null and checkInRecords.lat != ''">and jcir.lat = #{checkInRecords.lat}
+ </if>
+ <if test="checkInRecords.address != null and checkInRecords.address != ''">and jcir.address =
+ #{checkInRecords.address}
+ </if>
+ <if test="checkInRecords.deletedFlag != null ">and jcir.deleted_flag = #{checkInRecords.deletedFlag}</if>
+ <if test="checkInRecords.name != null and checkInRecords.name !='' ">and bu.name like
+ concat('%',#{checkInRecords.name},'%')
+ </if>
<if test="checkInRecords.startTime!=null and checkInRecords.startTime!=''">
AND date_format(jcir.create_time,'%Y-%m-%d')>= #{checkInRecords.startTime}
</if>
<if test="checkInRecords.endTime!=null and checkInRecords.endTime!=''">
AND date_format(jcir.create_time,'%Y-%m-%d')<= #{checkInRecords.endTime}
</if>
+
+ <if test="deptIdList !=null and deptIdList.size() > 0">
+ and
+ <foreach collection="deptIdList" index="index" item="item" open="(" separator="or" close=")">
+ bu.dept_id like concat('%',#{item},'%')
+ </foreach>
+ </if>
</where>
order by jcir.create_time desc
</select>
<resultMap type="org.springblade.modules.checkInRecords.dto.CheckInRecordsDTO" id="CheckInRecordsDTOResult">
- <result property="id" column="id" />
- <result property="createUserId" column="create_user_id" />
- <result property="createTime" column="create_time" />
- <result property="workTheme" column="work_theme" />
- <result property="workContent" column="work_content" />
- <result property="img" column="img" />
- <result property="lng" column="lng" />
- <result property="lat" column="lat" />
- <result property="address" column="address" />
- <result property="deletedFlag" column="deleted_flag" />
+ <result property="id" column="id"/>
+ <result property="createUserId" column="create_user_id"/>
+ <result property="createTime" column="create_time"/>
+ <result property="workTheme" column="work_theme"/>
+ <result property="workContent" column="work_content"/>
+ <result property="img" column="img"/>
+ <result property="lng" column="lng"/>
+ <result property="lat" column="lat"/>
+ <result property="address" column="address"/>
+ <result property="deletedFlag" column="deleted_flag"/>
</resultMap>
<sql id="selectCheckInRecords">
- select
- id,
- create_user_id,
- create_time,
- work_theme,
- work_content,
- img,
- lng,
- lat,
- address,
- deleted_flag
- from
- jczz_check_in_records
+ select id,
+ create_user_id,
+ create_time,
+ work_theme,
+ work_content,
+ img,
+ lng,
+ lat,
+ address,
+ deleted_flag
+ from jczz_check_in_records
</sql>
<select id="selectCheckInRecordsById" parameterType="int" resultMap="CheckInRecordsDTOResult">
@@ -80,19 +99,20 @@
id = #{id}
</select>
- <select id="selectCheckInRecordsList" parameterType="org.springblade.modules.checkInRecords.dto.CheckInRecordsDTO" resultMap="CheckInRecordsDTOResult">
+ <select id="selectCheckInRecordsList" parameterType="org.springblade.modules.checkInRecords.dto.CheckInRecordsDTO"
+ resultMap="CheckInRecordsDTOResult">
<include refid="selectCheckInRecords"/>
<where>
- <if test="id != null "> and id = #{id}</if>
- <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
- <if test="createTime != null "> and create_time = #{createTime}</if>
- <if test="workTheme != null and workTheme != ''"> and work_theme = #{workTheme}</if>
- <if test="workContent != null and workContent != ''"> and work_content = #{workContent}</if>
- <if test="img != null and img != ''"> and img = #{img}</if>
- <if test="lng != null and lng != ''"> and lng = #{lng}</if>
- <if test="lat != null and lat != ''"> and lat = #{lat}</if>
- <if test="address != null and address != ''"> and address = #{address}</if>
- <if test="deletedFlag != null "> and deleted_flag = #{deletedFlag}</if>
+ <if test="id != null ">and id = #{id}</if>
+ <if test="createUserId != null ">and create_user_id = #{createUserId}</if>
+ <if test="createTime != null ">and create_time = #{createTime}</if>
+ <if test="workTheme != null and workTheme != ''">and work_theme = #{workTheme}</if>
+ <if test="workContent != null and workContent != ''">and work_content = #{workContent}</if>
+ <if test="img != null and img != ''">and img = #{img}</if>
+ <if test="lng != null and lng != ''">and lng = #{lng}</if>
+ <if test="lat != null and lat != ''">and lat = #{lat}</if>
+ <if test="address != null and address != ''">and address = #{address}</if>
+ <if test="deletedFlag != null ">and deleted_flag = #{deletedFlag}</if>
</where>
</select>
</mapper>
diff --git a/src/main/java/org/springblade/modules/checkInRecords/service/impl/CheckInRecordsServiceImpl.java b/src/main/java/org/springblade/modules/checkInRecords/service/impl/CheckInRecordsServiceImpl.java
index 047b9d1..834f5ed 100644
--- a/src/main/java/org/springblade/modules/checkInRecords/service/impl/CheckInRecordsServiceImpl.java
+++ b/src/main/java/org/springblade/modules/checkInRecords/service/impl/CheckInRecordsServiceImpl.java
@@ -17,16 +17,26 @@
package org.springblade.modules.checkInRecords.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.logging.log4j.util.Strings;
+import org.springblade.common.cache.SysCache;
+import org.springblade.common.param.CommonParamSet;
+import org.springblade.common.utils.SpringUtils;
+import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.checkInRecords.dto.CheckInRecordsDTO;
import org.springblade.modules.checkInRecords.entity.CheckInRecordsEntity;
import org.springblade.modules.checkInRecords.vo.CheckInRecordsVO;
import org.springblade.modules.checkInRecords.mapper.CheckInRecordsMapper;
import org.springblade.modules.checkInRecords.service.ICheckInRecordsService;
import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.modules.system.service.IDeptService;
+import org.springblade.modules.system.vo.DeptVO;
+import org.springblade.modules.taskPlaceSelfCheck.vo.TaskPlaceSelfCheckVO;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
/**
* 打卡记录表 服务实现类
@@ -39,9 +49,18 @@
@Override
public IPage<CheckInRecordsVO> selectCheckInRecordsPage(IPage<CheckInRecordsVO> page, CheckInRecordsVO checkInRecords) {
- return page.setRecords(baseMapper.selectCheckInRecordsPage(page, checkInRecords));
- }
+ // todo 数据过滤
+ String deptId = checkInRecords.getDeptId();
+ if (Strings.isBlank(deptId) && !AuthUtil.isAdministrator() && !AuthUtil.isAdmin()) {
+ deptId = AuthUtil.getDeptId();
+ }
+ List<Long> deptIdList = SysCache.getDeptChildIds(deptId);
+ // 公共参数设置
+// CommonParamSet commonParamSet = new CommonParamSet().invoke(CheckInRecordsVO.class,checkInRecords);
+ IPage<CheckInRecordsVO> checkInRecordsVOIPage = page.setRecords(baseMapper.selectCheckInRecordsPage(page, checkInRecords, deptIdList));
+ return checkInRecordsVOIPage;
+ }
/**
@@ -51,8 +70,7 @@
* @return 打卡记录表
*/
@Override
- public CheckInRecordsDTO selectCheckInRecordsById(Integer id)
- {
+ public CheckInRecordsDTO selectCheckInRecordsById(Integer id) {
return this.baseMapper.selectCheckInRecordsById(id);
}
@@ -63,8 +81,7 @@
* @return 打卡记录表集合
*/
@Override
- public List<CheckInRecordsDTO> selectCheckInRecordsList(CheckInRecordsDTO checkInRecordsDTO)
- {
+ public List<CheckInRecordsDTO> selectCheckInRecordsList(CheckInRecordsDTO checkInRecordsDTO) {
return this.baseMapper.selectCheckInRecordsList(checkInRecordsDTO);
}
diff --git a/src/main/java/org/springblade/modules/checkInRecords/vo/CheckInRecordsVO.java b/src/main/java/org/springblade/modules/checkInRecords/vo/CheckInRecordsVO.java
index 1eeb1a7..4ec46fc 100644
--- a/src/main/java/org/springblade/modules/checkInRecords/vo/CheckInRecordsVO.java
+++ b/src/main/java/org/springblade/modules/checkInRecords/vo/CheckInRecordsVO.java
@@ -16,6 +16,7 @@
*/
package org.springblade.modules.checkInRecords.vo;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.checkInRecords.entity.CheckInRecordsEntity;
@@ -43,4 +44,14 @@
*/
private String endTime;
+ private String deptId;
+
+ // 角色名称
+ @ApiModelProperty(value = "角色名称", example = "")
+ private String roleName;
+
+ // 社区编号
+ @ApiModelProperty(value = "社区编号", example = "")
+ private String communityCode;
+
}
--
Gitblit v1.9.3