优化,修改HSE管理相关代码逻辑

This commit is contained in:
lcj
2025-04-16 09:52:20 +08:00
parent 20e778a1a7
commit 86745097ca
5 changed files with 37 additions and 98 deletions

View File

@ -222,6 +222,9 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
.eq(BusProjectTeamMember::getPostId, ProjectTeamMemberPostEnum.FOREMAN.getValue());
Set<Long> foremanIdList = projectTeamMemberService.list(lqw).stream()
.map(BusProjectTeamMember::getMemberId).collect(Collectors.toSet());
if (CollUtil.isEmpty(foremanIdList)) {
return List.of();
}
// 获取项目班组长信息
Map<Long, List<BusConstructionUser>> foremanMap = constructionUserService.listByIds(foremanIdList).stream()
.collect(Collectors.groupingBy(BusConstructionUser::getTeamId));

View File

@ -17,8 +17,8 @@ public class QuestionUserAnswerBatchDownloadFileReq implements Serializable {
private static final long serialVersionUID = 5011807834768249135L;
/**
* 用户id列表
* 主键列表
*/
private List<Long> userIdList;
private List<Long> idList;
}

View File

@ -20,74 +20,19 @@ public class SafetyLogQueryReq implements Serializable {
*/
private Long id;
/**
* 项目id
*/
private Long projectId;
/**
* 发生日期
*/
private String dateOfOccurrence;
/**
* 最高气温
* 创建人
*/
private Long airTemperatureMax;
/**
* 最低气温
*/
private Long airTemperatureMin;
/**
* 气候
*/
private String weather;
/**
* 进展
*/
private String progress;
/**
* 作业内容
*/
private String jobContent;
/**
* 交底情况
*/
private String discloseCondition;
/**
* 活动情况
*/
private String activityCondition;
/**
* 检查情况
*/
private String examineCondition;
/**
* 实施情况
*/
private String implementCondition;
/**
* 安全检查情况
*/
private String safetyInspectionCondition;
/**
* 停工或加班情况
*/
private String stoppageOrOvertime;
/**
* 其他情况
*/
private String otherCondition;
/**
* 备注
*/
private String remark;
private String creatorName;
}

View File

@ -163,7 +163,7 @@ public class BusQuestionUserAnswerServiceImpl extends ServiceImpl<BusQuestionUse
// 校验是否为压缩包zip格式
String suffix = FileUtil.getSuffix(originalFilename);
if (!suffix.equals("zip")) {
throw new ServiceException("请上传zip格式的文件", HttpStatus.BAD_REQUEST);
throw new ServiceException("请上传zip格式的压缩文件", HttpStatus.BAD_REQUEST);
}
// 2. 临时存储文件路径
// 2.1 压缩包临时文件路径
@ -519,17 +519,21 @@ public class BusQuestionUserAnswerServiceImpl extends ServiceImpl<BusQuestionUse
@Override
public void batchDownloadFile(QuestionUserAnswerBatchDownloadFileReq req, HttpServletResponse response) {
// 获取用户试卷存储文件
List<Long> userIdList = req.getUserIdList();
List<Long> idList = req.getIdList();
if (CollUtil.isEmpty(idList)) {
return;
}
List<BusQuestionUserAnswer> questionUserAnswerList = lambdaQuery()
.in(BusQuestionUserAnswer::getUserId, userIdList)
.in(BusQuestionUserAnswer::getId, idList)
.list();
if (CollUtil.isEmpty(questionUserAnswerList)) {
return;
}
// 查询对应施工人员信息
Set<Long> userIdSet = questionUserAnswerList.stream().map(BusQuestionUserAnswer::getUserId).collect(Collectors.toSet());
Map<Long, List<BusConstructionUser>> userMap = constructionUserService.lambdaQuery()
.select(BusConstructionUser::getId, BusConstructionUser::getUserName)
.in(BusConstructionUser::getId, userIdList).list()
.in(BusConstructionUser::getId, userIdSet).list()
.stream().collect(Collectors.groupingBy(BusConstructionUser::getId));
if (CollUtil.isEmpty(userMap)) {
return;

View File

@ -21,8 +21,9 @@ import org.dromara.safety.domain.req.safetylog.SafetyLogUpdateReq;
import org.dromara.safety.domain.vo.BusSafetyLogVo;
import org.dromara.safety.mapper.BusSafetyLogMapper;
import org.dromara.safety.service.IBusSafetyLogService;
import org.dromara.system.domain.SysUser;
import org.dromara.system.domain.vo.SysUserVo;
import org.dromara.system.service.ISysUserService;
import org.dromara.system.mapper.SysUserMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -44,7 +45,7 @@ public class BusSafetyLogServiceImpl extends ServiceImpl<BusSafetyLogMapper, Bus
private IBusProjectService projectService;
@Resource
private ISysUserService userService;
private SysUserMapper userMapper;
/**
* 查询安全日志
@ -179,7 +180,7 @@ public class BusSafetyLogServiceImpl extends ServiceImpl<BusSafetyLogMapper, Bus
// 关联创建用户信息
Long createBy = safetyLog.getCreateBy();
if (createBy != null) {
SysUserVo sysUserVo = userService.selectUserById(createBy);
SysUserVo sysUserVo = userMapper.selectVoById(createBy);
safetyLogVo.setCreator(IdAndNameVO.build(sysUserVo.getUserId(), sysUserVo.getUserName()));
}
return safetyLogVo;
@ -198,37 +199,23 @@ public class BusSafetyLogServiceImpl extends ServiceImpl<BusSafetyLogMapper, Bus
return lqw;
}
Long id = req.getId();
Long projectId = req.getProjectId();
String dateOfOccurrence = req.getDateOfOccurrence();
Long airTemperatureMax = req.getAirTemperatureMax();
Long airTemperatureMin = req.getAirTemperatureMin();
String weather = req.getWeather();
String progress = req.getProgress();
String jobContent = req.getJobContent();
String discloseCondition = req.getDiscloseCondition();
String activityCondition = req.getActivityCondition();
String examineCondition = req.getExamineCondition();
String implementCondition = req.getImplementCondition();
String safetyInspectionCondition = req.getSafetyInspectionCondition();
String stoppageOrOvertime = req.getStoppageOrOvertime();
String otherCondition = req.getOtherCondition();
String remark = req.getRemark();
// 模糊查询
lqw.like(StringUtils.isNotBlank(progress), BusSafetyLog::getProgress, progress);
lqw.like(StringUtils.isNotBlank(jobContent), BusSafetyLog::getJobContent, jobContent);
lqw.like(StringUtils.isNotBlank(discloseCondition), BusSafetyLog::getDiscloseCondition, discloseCondition);
lqw.like(StringUtils.isNotBlank(activityCondition), BusSafetyLog::getActivityCondition, activityCondition);
lqw.like(StringUtils.isNotBlank(examineCondition), BusSafetyLog::getExamineCondition, examineCondition);
lqw.like(StringUtils.isNotBlank(implementCondition), BusSafetyLog::getImplementCondition, implementCondition);
lqw.like(StringUtils.isNotBlank(safetyInspectionCondition), BusSafetyLog::getSafetyInspectionCondition, safetyInspectionCondition);
lqw.like(StringUtils.isNotBlank(stoppageOrOvertime), BusSafetyLog::getStoppageOrOvertime, stoppageOrOvertime);
lqw.like(StringUtils.isNotBlank(otherCondition), BusSafetyLog::getOtherCondition, otherCondition);
lqw.like(StringUtils.isNotBlank(remark), BusSafetyLog::getRemark, remark);
String creatorName = req.getCreatorName();
// 联表查询
if (StringUtils.isNotBlank(creatorName)) {
LambdaQueryWrapper<SysUser> userQueryWrapper = new LambdaQueryWrapper<>();
userQueryWrapper.like(SysUser::getUserName, creatorName);
List<SysUserVo> sysUserVos = userMapper.selectUserList(userQueryWrapper);
if (CollUtil.isNotEmpty(sysUserVos)) {
List<Long> userIds = sysUserVos.stream().map(SysUserVo::getUserId).toList();
lqw.in(BusSafetyLog::getCreateBy, userIds);
}
}
// 精确查询
lqw.eq(ObjectUtils.isNotEmpty(id), BusSafetyLog::getId, id);
lqw.eq(ObjectUtils.isNotEmpty(projectId), BusSafetyLog::getProjectId, projectId);
lqw.eq(ObjectUtils.isNotEmpty(dateOfOccurrence), BusSafetyLog::getDateOfOccurrence, dateOfOccurrence);
lqw.eq(ObjectUtils.isNotEmpty(airTemperatureMax), BusSafetyLog::getAirTemperatureMax, airTemperatureMax);
lqw.eq(ObjectUtils.isNotEmpty(airTemperatureMin), BusSafetyLog::getAirTemperatureMin, airTemperatureMin);
lqw.eq(ObjectUtils.isNotEmpty(weather), BusSafetyLog::getWeather, weather);
return lqw;
}