diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/EnterpriseInspectionsController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/EnterpriseInspectionsController.java index cee971e..48d4a27 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/EnterpriseInspectionsController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/EnterpriseInspectionsController.java @@ -79,6 +79,15 @@ public class EnterpriseInspectionsController { return success(BeanUtils.toBean(enterpriseInspections, EnterpriseInspectionsRespVO.class)); } + @GetMapping("/getEnterpriseInspectionsByTaskId") + @Operation(summary = "根据任务id查询自己偶发") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('system:enterprise-inspections:query')") + public CommonResult getEnterpriseInspectionsByTaskId(@RequestParam("id") Long id) { + EnterpriseInspectionsDO enterpriseInspections = enterpriseInspectionsService.getEnterpriseInspections(id); + return success(BeanUtils.toBean(enterpriseInspections, EnterpriseInspectionsRespVO.class)); + } + @GetMapping("/page") @Operation(summary = "获得企业检查记录表,用于记录与企业相关的环保检查信息。分页") @PreAuthorize("@ss.hasPermission('system:enterprise-inspections:query')") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsPageReqVO.java index bf8a840..a4be474 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsPageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsPageReqVO.java @@ -40,4 +40,10 @@ public class EnterpriseInspectionsPageReqVO extends PageParam { @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] createTime; + @Schema(description = "任务状态", example = "1") + private Integer inspectionsStatus; + + @Schema(description = "按部门") + private Long departmentId; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java index 6cfda08..33b487b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java @@ -53,7 +53,8 @@ public interface TaskInfoMapper extends BaseMapperX { .eqIfPresent(TaskInfoDO::getTaskStep, reqVO.getTaskStep()) .eqIfPresent(TaskInfoDO::getTaskTotal, reqVO.getTaskTotal()) .inIfPresent(TaskInfoDO::getId, reqVO.getTagList()) - .orderByDesc(TaskInfoDO::getId)); + .gtIfPresent(TaskInfoDO::getStatus, 1) + .orderByAsc(TaskInfoDO::getStatus)); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java index fe8884c..4887509 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java @@ -148,6 +148,9 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe @Override public PageResult getEnterpriseInspectionsPage(EnterpriseInspectionsPageReqVO pageReqVO) { +// final Long userId = getLoginUserId(); + + //根据企业名称查询 if (pageReqVO.getEnterpriseName() != null) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.like(EnterpriseDO::getEnterprisesName, pageReqVO.getEnterpriseName()); @@ -158,6 +161,7 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe } } + //根据任务名称查询 if (pageReqVO.getTaskName() != null) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.like(TaskInfoDO::getTitle, pageReqVO.getTaskName()); @@ -202,19 +206,15 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe throw exception(ENTERPRISE_NOT_EXISTS); } item.setEnterpriseName(enterpriseDO.getEnterprisesName()); - - //查询检查记录 - QueryWrapper inspectionsLogWrapper = new QueryWrapper<>(); - inspectionsLogWrapper.eq("inspections_id", item.getId()); - inspectionsLogWrapper.orderByDesc("create_time"); - final List inspectionsLogDOS = inspectionsLogMapper.selectList(inspectionsLogWrapper); - if (inspectionsLogDOS != null && inspectionsLogDOS.size() > 0) { - item.setInspectionStatus(inspectionsLogDOS.get(0).getStatus()); - item.setInspectName(inspectionsLogDOS.get(0).getInspectName()); - item.setCooperateWithName(inspectionsLogDOS.get(0).getCooperateWithName()); - item.setExecTime(inspectionsLogDOS.get(0).getCreateTime()); + //查询执行的最新一条记录 + final InspectionsLogDO inspectionsLogNew = this.getInspectionsLogNew(item.getId()); + if (inspectionsLogNew != null) { + item.setInspectionStatus(inspectionsLogNew.getStatus()); + item.setInspectName(inspectionsLogNew.getInspectName()); + item.setCooperateWithName(inspectionsLogNew.getCooperateWithName()); + item.setExecTime(inspectionsLogNew.getCreateTime()); //根据执法人员id 查询其所属部门 - final Long userId = Long.valueOf(inspectionsLogDOS.get(0).getCreator()); + final Long userId = Long.valueOf(inspectionsLogNew.getCreator()); final AdminUserDO user = adminUserService.getUser(userId); if (user == null) { @@ -228,7 +228,7 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe //根据执法人员id 查询其所属部门 final Long userId = Long.valueOf(item.getUserId()); final AdminUserDO user = adminUserService.getUser(userId); - + item.setInspectionStatus(1); item.setInspectName(user.getRealName()); if (user == null) { @@ -238,6 +238,13 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe }); } + if (pageReqVO.getInspectionsStatus() != null) { + final List collect = enterpriseInspectionsDOPageResult.getList().stream().filter(item -> item.getInspectionStatus() == pageReqVO.getInspectionsStatus()).collect(Collectors.toList()); + enterpriseInspectionsDOPageResult.setList(collect); + enterpriseInspectionsDOPageResult.setTotal(Long.valueOf(collect.size())); + } + + return enterpriseInspectionsDOPageResult; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java index 46f1175..83fb550 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java @@ -14,6 +14,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.taglibrary.TagLibraryMapper; import cn.iocoder.yudao.module.system.dal.mysql.tasktag.TaskTagMapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import org.springframework.transaction.annotation.Transactional; @@ -45,6 +46,7 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; */ @Service @Validated +@Slf4j public class TaskInfoServiceImpl implements TaskInfoService { @Resource @@ -94,7 +96,11 @@ public class TaskInfoServiceImpl implements TaskInfoService { EnterpriseInspectionsDO inspection = new EnterpriseInspectionsDO(); inspection.setTaskId(taskInfo.getId()); inspection.setEnterpriseId(item); - inspection.setCreator(enterpriseDO.getUserId().toString()); + + if (enterpriseDO.getUserId() != null) { + inspection.setCreator(enterpriseDO.getUserId().toString()); + } + list.add(inspection); }); @@ -186,9 +192,10 @@ public class TaskInfoServiceImpl implements TaskInfoService { //按标签查询 if (pageReqVO.getTagList() != null && pageReqVO.getTagList().size() > 0) { + log.info("pageReqVO.getTagList():{}", pageReqVO.getTagList()); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(TaskTagDO::getTaskId, pageReqVO.getTagList()); - final List taskTagDOS = taskTagMapper.selectList(); + final List taskTagDOS = taskTagMapper.selectList(wrapper); if (taskTagDOS != null && taskTagDOS.size() > 0) { pageReqVO.setTagList(taskTagDOS.stream().map(TaskTagDO::getTagId).collect(Collectors.toList())); }