diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java index 8fa1964..a9e37a4 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java @@ -191,4 +191,5 @@ public interface ErrorCodeConstants { ErrorCode ENTERPRISE_INSPECTIONS_STATUS_ERROR = new ErrorCode(1-003-002-000, "此状态下,不能转发执法任务"); + ErrorCode ENTERPRISE_INSPECTIONS_STATUS_ERROR2 = new ErrorCode(1-003-002-001, "任务不能转给自己"); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java index 0cc39ae..bc7c1f1 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java @@ -77,5 +77,8 @@ public class EnterprisePageReqVO extends PageParam { @Schema(description = "邀请人") private List ids; + @Schema(description = "根据标签类型过滤") + private List tagList; + } 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 0dd30ee..41c264c 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 @@ -46,7 +46,7 @@ public class EnterpriseInspectionsController { } @PostMapping("/passOn") - @Operation(summary = "执法记录转交") + @Operation(summary = "执法记录变更") @PreAuthorize("@ss.hasPermission('system:enterprise-inspections:create')") public CommonResult passOn(@Valid @RequestBody PassOnSaveVO passOnSaveVO) { enterpriseInspectionsService.passOn(passOnSaveVO); 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 7fc1dc5..e57c842 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 @@ -21,8 +21,11 @@ public class EnterpriseInspectionsPageReqVO extends PageParam { @Schema(description = "企业ID", example = "27002") private Long enterpriseId; + @Schema(description = "用户id", example = "1") + private Long userId; + @Schema(description = "创建时间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] createTime; -} \ No newline at end of file +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsRespVO.java index 95e0c16..d68cbc6 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsRespVO.java @@ -24,6 +24,10 @@ public class EnterpriseInspectionsRespVO { @ExcelProperty("任务名称") private String taskName; + @Schema(description = "任务编码", example = "29150") + @ExcelProperty("任务编码") + private String taskNumber; + @Schema(description = "企业ID", example = "27002") @ExcelProperty("企业ID") private Long enterpriseId; @@ -40,6 +44,8 @@ public class EnterpriseInspectionsRespVO { @ExcelProperty("进度状态") private String inspectionStatus; + + @Schema(description = "执法部门", example = "一大队") @ExcelProperty("执法部门") private String department; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java index c41e5d4..3c7b669 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java @@ -173,6 +173,20 @@ public class TaskInfoController { return success(BeanUtils.toBean(pageResult, TaskInfoRespVO.class)); } + @GetMapping("/appPage") + @Operation(summary = "获得任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。分页") + @PreAuthorize("@ss.hasPermission('system:task-info:query')") + public CommonResult> appPage(@Valid TaskInfoPageReqVO pageReqVO) { + PageResult pageResult = taskInfoService.getTaskInfoAppPage(pageReqVO); +// AdminUserDO user = adminUserService.getUser(SecurityFrameworkUtils.getLoginUserId()); +// DeptDO dep= deptService.getDept( user.getDeptId()); +// pageResult.getList().forEach(item->{ +// item.setPublishDep(dep.getName()); +// item.setCreateName(adminUserService.getUser(Long.valueOf(item.getCreator())).getRealName()); +// }); + return success(BeanUtils.toBean(pageResult, TaskInfoRespVO.class)); + } + @GetMapping("/export-excel") @Operation(summary = "导出任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。 Excel") @PreAuthorize("@ss.hasPermission('system:task-info:export')") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java index c1d07b8..813ed2b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java @@ -111,9 +111,16 @@ public class TaskInfoRespVO { @ExcelProperty("标签集合") private List tagLibraryIds; + //任务总数 + @TableField(exist = false) + private Integer taskExecNum; + //已完成数 + @TableField(exist = false) + private Integer taskFinishNum; - + @TableField(exist = false) + private List tagList; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterpriseinspections/EnterpriseInspectionsDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterpriseinspections/EnterpriseInspectionsDO.java index be2a3fa..c047432 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterpriseinspections/EnterpriseInspectionsDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterpriseinspections/EnterpriseInspectionsDO.java @@ -43,12 +43,17 @@ public class EnterpriseInspectionsDO extends BaseDO { */ private Long userId; - //状态 1.任务未启动 2. 任务已启动 3.已转交,未执行不展示 4.已转交,整改中,留痕 + //状态 1.任务未启动 2. 任务已启动 4.已转交,整改中,留痕 private Integer status; + //任务编号 + @TableField(exist = false) + private String taskNumber; + //任务名称 @TableField(exist = false) private String taskName; + //企业名称 @TableField(exist = false) private String enterpriseName; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/taskinfo/TaskInfoDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/taskinfo/TaskInfoDO.java index d7abff8..06905b9 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/taskinfo/TaskInfoDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/taskinfo/TaskInfoDO.java @@ -105,5 +105,14 @@ public class TaskInfoDO extends BaseDO { @TableField(exist = false) private List enterpriseIdes; + //任务总数 + @TableField(exist = false) + private Integer taskExecNum; + + //已完成数 + @TableField(exist = false) + private Integer taskFinishNum; + @TableField(exist = false) + private List tagList; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java index ef24f4e..0db6b1d 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java @@ -43,5 +43,25 @@ public interface EnterpriseMapper extends BaseMapperX { default List selectListByStatus() { return selectList(); } - + default List selectList(EnterprisePageReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(EnterpriseDO::getId, reqVO.getId()) + .eqIfPresent(EnterpriseDO::getDepartmentId, reqVO.getDepartmentId()) + .eqIfPresent(EnterpriseDO::getUserId, reqVO.getUserId()) + .eqIfPresent(EnterpriseDO::getType, reqVO.getType()) + .eqIfPresent(EnterpriseDO::getRegion, reqVO.getRegion()) + .likeIfPresent(EnterpriseDO::getEnterprisesName, reqVO.getEnterprisesName()) + .eqIfPresent(EnterpriseDO::getAddress, reqVO.getAddress()) + .likeIfPresent(EnterpriseDO::getContactName, reqVO.getContactName()) + .eqIfPresent(EnterpriseDO::getEnvironmentalContactPhone, reqVO.getEnvironmentalContactPhone()) + .eqIfPresent(EnterpriseDO::getRegistrationNumber, reqVO.getRegistrationNumber()) + .eqIfPresent(EnterpriseDO::getIntroduction, reqVO.getIntroduction()) + .betweenIfPresent(EnterpriseDO::getEstablishmentDate, reqVO.getEstablishmentDate()) + .eqIfPresent(EnterpriseDO::getGpsLocation, reqVO.getGpsLocation()) + .eqIfPresent(EnterpriseDO::getCreator, reqVO.getCreate()) + .betweenIfPresent(EnterpriseDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(EnterpriseDO::getUpdater, reqVO.getUpdater()) + .inIfPresent(EnterpriseDO::getId,reqVO.getIds()) + .orderByDesc(EnterpriseDO::getId)); + } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java index 643f803..4590141 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java @@ -25,6 +25,15 @@ public interface EnterpriseInspectionsMapper extends BaseMapperX selectAppPage(EnterpriseInspectionsPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(EnterpriseInspectionsDO::getTaskId, reqVO.getTaskId()) + .eqIfPresent(EnterpriseInspectionsDO::getUserId, reqVO.getUserId()) + .eqIfPresent(EnterpriseInspectionsDO::getEnterpriseId, reqVO.getEnterpriseId()) + .betweenIfPresent(EnterpriseInspectionsDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(EnterpriseInspectionsDO::getId)); + } + default List selectList(EnterpriseInspectionsPageReqVO reqVO) { @@ -36,4 +45,4 @@ public interface EnterpriseInspectionsMapper extends BaseMapperX getListByUserIdAndTaskName(Long userId, String taskName); int deleteEnterpriseInspectionsTaskId(Long taskId); @@ -58,8 +60,4 @@ public interface EnterpriseInspectionsService { List getEnterpriseInspectionsList(EnterpriseInspectionsPageReqVO pageReqVO); - - - - } 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 3a739c2..45f4871 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 @@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.system.dal.dataobject.taglibrary.TagLibraryDO; import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; import cn.iocoder.yudao.module.system.dal.dataobject.tasktag.TaskTagDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper; import cn.iocoder.yudao.module.system.dal.mysql.enterprise.EnterpriseMapper; import cn.iocoder.yudao.module.system.dal.mysql.inspectionslog.InspectionsLogMapper; import cn.iocoder.yudao.module.system.dal.mysql.taglibrary.TagLibraryMapper; @@ -33,6 +34,8 @@ import cn.iocoder.yudao.module.system.dal.mysql.enterpriseinspections.Enterprise import javax.annotation.Resource; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; /** @@ -89,7 +92,15 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe // 删除 enterpriseInspectionsMapper.deleteById(id); } + @Override + @Transactional(rollbackFor = Exception.class) + public int deleteEnterpriseInspectionsTaskId(Long taskId) { + LambdaQueryWrapper taskMembersDOLambdaQueryWrapper = new LambdaQueryWrapper<>(); + taskMembersDOLambdaQueryWrapper.eq(EnterpriseInspectionsDO::getTaskId, taskId); + // 删除 + return enterpriseInspectionsMapper.delete(taskMembersDOLambdaQueryWrapper); + } private void validateEnterpriseInspectionsExists(Long id) { if (enterpriseInspectionsMapper.selectById(id) == null) { throw exception(ENTERPRISE_INSPECTIONS_NOT_EXISTS); @@ -98,7 +109,38 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe @Override public EnterpriseInspectionsDO getEnterpriseInspections(Long id) { - return enterpriseInspectionsMapper.selectById(id); + + final EnterpriseInspectionsDO enterpriseInspectionsDO = enterpriseInspectionsMapper.selectById(id); + if (enterpriseInspectionsDO == null) { + throw exception(ENTERPRISE_INSPECTIONS_NOT_EXISTS); + } + + final TaskInfoDO taskInfoDO = taskInfoMapper.selectById(enterpriseInspectionsDO.getTaskId()); + if (taskInfoDO == null) { + throw exception(TASK_INFO_NOT_EXISTS); + } + enterpriseInspectionsDO.setTaskName(taskInfoDO.getTitle()); + enterpriseInspectionsDO.setTaskName(taskInfoDO.getTitle()); + enterpriseInspectionsDO.setTaskNumber(taskInfoDO.getTaskNumber()); + + final EnterpriseDO enterpriseDO = enterpriseMapper.selectById(enterpriseInspectionsDO.getEnterpriseId()); + if (enterpriseDO == null) { + throw exception(ENTERPRISE_NOT_EXISTS); + } + //任务类型 + enterpriseInspectionsDO.setEnterpriseName(enterpriseDO.getEnterprisesName()); + + final AdminUserDO user = adminUserService.getUser(enterpriseInspectionsDO.getUserId()); + if (user == null) { + throw exception(USER_NOT_EXISTS); + } + enterpriseInspectionsDO.setInspectName(user.getRealName()); + + final DeptDO dept = deptService.getDept(user.getDeptId()); + + enterpriseInspectionsDO.setDepartment(dept.getName()); + + return enterpriseInspectionsDO; } @Override @@ -152,12 +194,24 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe //根据执法人员id 查询其所属部门 final Long userId = Long.valueOf(inspectionsLogDOS.get(0).getCreator()); final AdminUserDO user = adminUserService.getUser(userId); + if (user == null) { throw exception(USER_NOT_EXISTS); } + final DeptDO dept = deptService.getDept(user.getDeptId()); item.setDepartment(dept.getName()); + } else { + + //根据执法人员id 查询其所属部门 + final Long userId = Long.valueOf(item.getUserId()); + final AdminUserDO user = adminUserService.getUser(userId); + + item.setInspectName(user.getRealName()); + if (user == null) { + throw exception(USER_NOT_EXISTS); + } } }); } @@ -175,6 +229,11 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe //循环记录id列表 passOnSaveVO.getInspectionsId().forEach(item->{ final EnterpriseInspectionsDO enterpriseInspectionsDO = enterpriseInspectionsMapper.selectById(item); + + if (enterpriseInspectionsDO.getUserId() == passOnSaveVO.getUserId()) { + throw exception(ENTERPRISE_INSPECTIONS_STATUS_ERROR2); + } + if (enterpriseInspectionsDO == null) { throw exception(ENTERPRISE_INSPECTIONS_NOT_EXISTS); } @@ -187,22 +246,25 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe //已经开始 就要判断是否是整改状态 整改状态才能转 enterpriseInspectionsDO.setStatus(4); } else { - enterpriseInspectionsDO.setStatus(3); + enterpriseInspectionsDO.setStatus(1); + enterpriseInspectionsDO.setUserId(passOnSaveVO.getUserId()); } enterpriseInspectionsMapper.updateById(enterpriseInspectionsDO); - AdminUserDO user = adminUserService.getUser(passOnSaveVO.getUserId()); - if (user == null) { - throw exception(USER_NOT_EXISTS); + if (enterpriseInspectionsDO.getStatus() == 4) { + AdminUserDO user = adminUserService.getUser(passOnSaveVO.getUserId()); + if (user == null) { + throw exception(USER_NOT_EXISTS); + } + EnterpriseInspectionsDO inspectionsDO = new EnterpriseInspectionsDO(); + inspectionsDO.setEnterpriseId(enterpriseInspectionsDO.getEnterpriseId()); + inspectionsDO.setTaskId(enterpriseInspectionsDO.getTaskId()); + inspectionsDO.setUserId(passOnSaveVO.getUserId()); + inspectionsDO.setInspectName(user.getRealName()); + enterpriseInspectionsMapper.insert(inspectionsDO); } - EnterpriseInspectionsDO inspectionsDO = new EnterpriseInspectionsDO(); - inspectionsDO.setEnterpriseId(enterpriseInspectionsDO.getEnterpriseId()); - inspectionsDO.setTaskId(enterpriseInspectionsDO.getTaskId()); - inspectionsDO.setUserId(passOnSaveVO.getUserId()); - inspectionsDO.setInspectName(user.getRealName()); - enterpriseInspectionsMapper.insert(inspectionsDO); } else { throw exception(ENTERPRISE_INSPECTIONS_STATUS_ERROR); } @@ -245,5 +307,8 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe return inspectionsLogDOS.get(0); } - + @Override + public List getEnterpriseInspectionsList(EnterpriseInspectionsPageReqVO pageReqVO) { + return enterpriseInspectionsMapper.selectList(pageReqVO); + } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java index 920b587..15c7e3c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java @@ -58,4 +58,5 @@ public interface TaskInfoService { //定时执行任务 void sendTask(Long taskId); + PageResult getTaskInfoAppPage(TaskInfoPageReqVO pageReqVO); } 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 b12b5a4..d8ef08d 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 @@ -3,18 +3,24 @@ package cn.iocoder.yudao.module.system.service.taskinfo; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; import cn.iocoder.yudao.module.infra.api.job.JobApi; +import cn.iocoder.yudao.module.system.controller.admin.tasktag.vo.TaskTagPageReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO; +import cn.iocoder.yudao.module.system.dal.dataobject.taglibrary.TagLibraryDO; import cn.iocoder.yudao.module.system.dal.dataobject.tasktag.TaskTagDO; import cn.iocoder.yudao.module.system.dal.mysql.enterprise.EnterpriseMapper; import cn.iocoder.yudao.module.system.dal.mysql.enterpriseinspections.EnterpriseInspectionsMapper; +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.QueryWrapper; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; import java.util.*; +import java.util.stream.Collectors; + import cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo.*; import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -27,6 +33,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.taskinfo.TaskInfoMapper; import javax.annotation.Resource; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; /** @@ -48,6 +55,8 @@ public class TaskInfoServiceImpl implements TaskInfoService { private EnterpriseMapper enterpriseMapper; @Resource private EnterpriseInspectionsMapper enterpriseInspectionsMapper; + @Resource + private TagLibraryMapper tagLibraryMapper; @Override @Transactional @@ -156,12 +165,6 @@ public class TaskInfoServiceImpl implements TaskInfoService { } - - - - - - @Override public void sendTask(Long taskId) { final TaskInfoDO taskInfoDO = taskInfoMapper.selectById(taskId); @@ -176,4 +179,46 @@ public class TaskInfoServiceImpl implements TaskInfoService { } + @Override + public PageResult getTaskInfoAppPage(TaskInfoPageReqVO pageReqVO) { + + final PageResult taskInfoDOPageResult = taskInfoMapper.selectPage(pageReqVO); + if (taskInfoDOPageResult.getList() != null && taskInfoDOPageResult.getList().size() > 0) { + taskInfoDOPageResult.getList().forEach(item->{ + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("task_id", item.getId()); + wrapper.eq("user_id", getLoginUserId()); + item.setTaskExecNum(0); + List enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(wrapper); + if (enterpriseInspectionsDOList != null && enterpriseInspectionsDOList.size() > 0) { + item.setTaskExecNum(enterpriseInspectionsDOList.size()); + final List collect = enterpriseInspectionsDOList.stream().filter(res -> res.getStatus() == 5).collect(Collectors.toList()); + item.setTaskFinishNum(collect.size()); + } + + //获取任务标签 + QueryWrapper wrapper1 = new QueryWrapper<>(); + wrapper1.eq("task_id", item.getId()); + List taskTagDOList = taskTagMapper.selectList(wrapper1); + if (taskTagDOList != null && taskTagDOList.size() > 0) { + final List collect = taskTagDOList.stream().map(TaskTagDO::getTagId).collect(Collectors.toList()); + final List tagLibraryDOS = tagLibraryMapper.selectByIds(collect); + if (tagLibraryDOS != null && tagLibraryDOS.size() > 0) { + item.setTagList(tagLibraryDOS.stream().map(TagLibraryDO::getTagName).collect(Collectors.toList())); + } + } + enterpriseInspectionsMapper.selectList(); + }); + } + + //筛选出 TaskExecNum 为0的 + if (taskInfoDOPageResult.getList() != null && taskInfoDOPageResult.getList().size() > 0) { + final List collect = taskInfoDOPageResult.getList().stream().filter(res -> res.getTaskExecNum() > 0).collect(Collectors.toList()); + taskInfoDOPageResult.setList(collect); + taskInfoDOPageResult.setTotal(Long.valueOf(collect.size())); + } + + return taskInfoDOPageResult; + } + }