Browse Source

fix: 培训管理添加数据权限

zhongwei
liwen 7 months ago
parent
commit
bac3c8c5aa
  1. 3
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestMapper.java
  2. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestMapper.xml
  3. 25
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.java
  4. 48
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml
  5. 3
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainRecordMapper.java
  6. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainRecordMapper.xml
  7. 11
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java
  8. 1
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java
  9. 32
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java

3
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestMapper.java

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.safeproduct.dto.TestDTO;
import com.hnac.hzims.safeproduct.entity.TestEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springblade.core.datascope.annotation.UserDataAuth;
import java.util.List;
import java.util.Map;
@ -23,6 +24,7 @@ public interface TestMapper extends BaseMapper<TestEntity> {
* @param trainPlanId 培训计划id
* @return 考试记录名称列表
*/
@UserDataAuth
List<TestDTO> getTestNameList(String trainPlanId);
/**
@ -31,5 +33,6 @@ public interface TestMapper extends BaseMapper<TestEntity> {
* @param page 分页类
* @return 考试记录数据
*/
@UserDataAuth
IPage<TestEntity> testPage(IPage<TestEntity> page, Map<String, Object> param);
}

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestMapper.xml

@ -4,7 +4,7 @@
<select id="getTestNameList" resultType="com.hnac.hzims.safeproduct.dto.TestDTO">
SELECT
id, test_name
id, test_name, create_user, create_dept
FROM
hzims_test
WHERE
@ -36,6 +36,6 @@
AND test_name like concat('%', #{param.unit}, '%)'
</if>
ORDER BY
create_time DESC
create_time DESC
</select>
</mapper>

25
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.java

@ -7,8 +7,10 @@ import com.hnac.hzims.safeproduct.entity.TrainPlanEntity;
import com.hnac.hzims.safeproduct.vo.TrainMonthVO;
import com.hnac.hzims.safeproduct.vo.TrainYearVO;
import org.apache.ibatis.annotations.Mapper;
import org.springblade.core.datascope.annotation.UserDataAuth;
import java.util.List;
import java.util.Map;
/**
* 培训计划Mapper类
@ -26,6 +28,7 @@ public interface TrainPlanMapper extends BaseMapper<TrainPlanEntity> {
* @param month 月份
* @return 当月培训计划总数
*/
@UserDataAuth
IPage<TrainMonthVO> selectByMonth(IPage<TrainMonthVO> page, String unit, String month);
/**
@ -35,6 +38,7 @@ public interface TrainPlanMapper extends BaseMapper<TrainPlanEntity> {
* @param month 月份
* @return 当月已完成培训计划数
*/
@UserDataAuth
IPage<TrainMonthVO> selectFinishedDataByMonth(IPage<TrainMonthVO> page1, String unit, String month);
/**
@ -44,6 +48,7 @@ public interface TrainPlanMapper extends BaseMapper<TrainPlanEntity> {
* @param year 年份
* @return 年度单位数据
*/
@UserDataAuth
IPage<TrainYearVO> selectUnitByYear(IPage<TrainYearVO> page, String unit, String year);
/**
@ -52,5 +57,25 @@ public interface TrainPlanMapper extends BaseMapper<TrainPlanEntity> {
* @param year 年份
* @return 单位各月的培训计划数
*/
@UserDataAuth
List<AnalysisYearDTO> selectFinishedDataByUnit(List<String> unitList, String year);
/**
* 培训计划分页
* @param param 入参
* @param page 分页类
* @return 培训计划数据
*/
@UserDataAuth
IPage<TrainPlanEntity> trainPlanPage(IPage<TrainPlanEntity> page, Map<String, Object> param);
/**
* 根据单位和计划时间查询培训计划数据
* @param unit 单位
* @param startTime 计划开始时间
* @param endTime 计划结束时间
* @return 培训计划列表
*/
@UserDataAuth
List<TrainPlanEntity> selectListByUnitAndDate(String unit, String startTime, String endTime);
}

48
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml

@ -4,7 +4,7 @@
<select id="selectByMonth" resultType="com.hnac.hzims.safeproduct.vo.TrainMonthVO">
SELECT
unit, count(1) as scheduled_train_num
unit, count(1) as scheduled_train_num, create_user, create_dept
FROM
hzims_train_plan
WHERE
@ -21,7 +21,7 @@
<select id="selectFinishedDataByMonth" resultType="com.hnac.hzims.safeproduct.vo.TrainMonthVO">
SELECT
unit, count(1) as finished_train_num
unit, count(1) as finished_train_num, create_user, create_dept
FROM
hzims_train_plan
WHERE
@ -39,7 +39,7 @@
<select id="selectUnitByYear" resultType="com.hnac.hzims.safeproduct.vo.TrainYearVO">
SELECT
distinct unit
distinct unit, create_user, create_dept
FROM
hzims_train_plan
WHERE
@ -54,7 +54,7 @@
<select id="selectFinishedDataByUnit" resultType="com.hnac.hzims.safeproduct.dto.AnalysisYearDTO">
SELECT
unit, DATE_FORMAT(scheduled_end_time, '%m') as dateTime, count(1) as finished_num
unit, DATE_FORMAT(scheduled_end_time, '%m') as dateTime, count(1) as finished_num, create_user, create_dept
FROM
hzims_train_plan
WHERE
@ -70,4 +70,44 @@
ORDER BY
unit
</select>
<select id="trainPlanPage" resultType="com.hnac.hzims.safeproduct.entity.TrainPlanEntity">
SELECT
*
FROM
hzims_train_plan
WHERE
is_deleted = 0
<if test="param.unit != null and param.unit != ''">
AND unit like concat('%', #{param.unit}, '%')
</if>
<if test="param.startTime != null and param.startTime != ''">
AND scheduled_start_time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
AND scheduled_end_time &lt;= #{param.endTime}
</if>
ORDER BY
create_time DESC
</select>
<select id="selectListByUnitAndDate" resultType="com.hnac.hzims.safeproduct.entity.TrainPlanEntity">
SELECT
*
FROM
hzims_train_plan
WHERE
is_deleted = 0
<if test="unit != 'null' and unit != ''">
AND unit like concat('%', #{unit}, '%')
</if>
<if test="startTime != 'null' and startTime != ''">
AND scheduled_start_time >= #{startTime}
</if>
<if test="endTime != 'null' and endTime != ''">
AND scheduled_end_time &lt;= #{endTime}
</if>
ORDER BY
create_time DESC
</select>
</mapper>

3
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainRecordMapper.java

@ -7,6 +7,7 @@ import com.hnac.hzims.safeproduct.entity.TrainRecordEntity;
import com.hnac.hzims.safeproduct.vo.TrainRecordDetailVO;
import com.hnac.hzims.safeproduct.vo.TrainRecordVO;
import org.apache.ibatis.annotations.Mapper;
import org.springblade.core.datascope.annotation.UserDataAuth;
import java.util.List;
import java.util.Map;
@ -25,6 +26,7 @@ public interface TrainRecordMapper extends BaseMapper<TrainRecordEntity> {
* @param trainPlanId 培训计划id
* @return 培训记录名称列表
*/
@UserDataAuth
List<TrainRecordDTO> getTrainRecordNameList(String trainPlanId);
/**
@ -40,5 +42,6 @@ public interface TrainRecordMapper extends BaseMapper<TrainRecordEntity> {
* @param page 分页类
* @return 培训记录数据
*/
@UserDataAuth
IPage<TrainRecordVO> trainRecordPage(IPage<TrainRecordVO> page, Map<String, Object> param);
}

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainRecordMapper.xml

@ -4,7 +4,7 @@
<select id="getTrainRecordNameList" resultType="com.hnac.hzims.safeproduct.dto.TrainRecordDTO">
SELECT
id, train_record_name
id, train_record_name, create_user, create_dept
FROM
hzims_train_record
WHERE
@ -32,7 +32,7 @@
SELECT
t1.id, t2.scheduled_start_time, t2.scheduled_end_time, t2.unit, t1.train_record_name, t2.location, t2.train_method,
t2.teacher, t2.lesson, t1.actual_start_time, t1.actual_end_time, t2.is_test, t2.train_status, t1.code, t1.content,
t1.command
t1.command, t1.create_user, t1.create_dept
FROM
hzims_train_record t1
LEFT JOIN hzims_train_plan t2 ON t1.train_plan_id = t2.id

11
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java

@ -11,8 +11,6 @@ import com.hnac.hzims.safeproduct.mapper.TestScoreMapper;
import com.hnac.hzims.safeproduct.service.ITestScoreService;
import com.hnac.hzims.safeproduct.vo.TestScoreSumVO;
import com.hnac.hzims.safeproduct.vo.TestScoreVO;
import com.hnac.hzinfo.inspect.ai.entity.RobotTaskEntity;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
@ -22,8 +20,8 @@ import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -41,11 +39,12 @@ import java.util.stream.Collectors;
* @date 2023-12-25
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class TestScoreServiceImpl extends ServiceImpl<TestScoreMapper, TestScoreEntity> implements ITestScoreService {
private final ISysClient sysClient;
private final IUserClient userClient;
@Autowired
ISysClient sysClient;
@Resource
TestMapper testMapper;

1
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java

@ -18,7 +18,6 @@ import com.hnac.hzims.safeproduct.service.ITestScoreService;
import com.hnac.hzims.safeproduct.service.ITestService;
import com.hnac.hzims.safeproduct.utils.BaseUtil;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;

32
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java

@ -5,12 +5,10 @@ import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.converters.longconverter.LongStringConverter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.constants.SafeProductConstant;
import com.hnac.hzims.safeproduct.dto.AnalysisYearDTO;
import com.hnac.hzims.safeproduct.entity.TrainPlanEntity;
@ -265,21 +263,8 @@ public class TrainPlanServiceImpl extends ServiceImpl<TrainPlanMapper, TrainPlan
*/
@Override
public IPage<TrainPlanEntity> trainPlanPage(Map<String, Object> param, Query query) {
QueryWrapper<TrainPlanEntity> queryWrapper = new QueryWrapper<>();
String unit = String.valueOf(param.get("unit"));
String startTime = String.valueOf(param.get("scheduledStartTime"));
String endTime = String.valueOf((param.get("scheduledEndTime")));
if (!unit.equals("null") && !unit.equals("")) {
queryWrapper.lambda().like(TrainPlanEntity::getUnit, unit);
}
if (!startTime.equals("null") && !startTime.equals("")) {
queryWrapper.lambda().ge(TrainPlanEntity::getScheduledStartTime, startTime);
}
if (!endTime.equals("null") && !endTime.equals("")) {
queryWrapper.lambda().le(TrainPlanEntity::getScheduledEndTime, endTime);
}
queryWrapper.lambda().orderByDesc(TrainPlanEntity::getCreateTime);
return this.page(Condition.getPage(query), queryWrapper);
IPage<TrainPlanEntity> page = new Page<>(query.getCurrent(), query.getSize());
return baseMapper.trainPlanPage(page, param);
}
/**
@ -290,17 +275,6 @@ public class TrainPlanServiceImpl extends ServiceImpl<TrainPlanMapper, TrainPlan
* @return 培训计划列表
*/
public List<TrainPlanEntity> getTrainPlanByUnitAndDate(String unit, String startTime, String endTime) {
LambdaQueryWrapper<TrainPlanEntity> queryWrapper = new LambdaQueryWrapper<>();
if (!unit.equals("null")) {
queryWrapper.eq(TrainPlanEntity::getUnit, unit);
}
if (!startTime.equals("null")) {
queryWrapper.ge(TrainPlanEntity::getScheduledStartTime, startTime);
}
if (!endTime.equals("null")) {
queryWrapper.lt(TrainPlanEntity::getScheduledEndTime, endTime);
}
queryWrapper.orderByDesc(TrainPlanEntity::getCreateTime);
return this.list(queryWrapper);
return baseMapper.selectListByUnitAndDate(unit, startTime, endTime);
}
}

Loading…
Cancel
Save