Browse Source

Merge remote-tracking branch 'origin/master'

master
zy 2 months ago
parent
commit
b1aec4d9f8
  1. 1
      yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
  2. 3
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java
  3. 2
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/EnterpriseInspectionsController.java
  4. 17
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsPageReqVO.java
  5. 6
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsRespVO.java
  6. 14
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java
  7. 9
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java
  8. 7
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterpriseinspections/EnterpriseInspectionsDO.java
  9. 9
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/taskinfo/TaskInfoDO.java
  10. 22
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java
  11. 13
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java
  12. 8
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsService.java
  13. 111
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java
  14. 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java
  15. 57
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java

1
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, "任务不能转给自己");
}

3
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<Long> ids;
@Schema(description = "根据标签类型过滤")
private List<Long> tagList;
}

2
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<String> passOn(@Valid @RequestBody PassOnSaveVO passOnSaveVO) {
enterpriseInspectionsService.passOn(passOnSaveVO);

17
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsPageReqVO.java

@ -21,8 +21,23 @@ public class EnterpriseInspectionsPageReqVO extends PageParam {
@Schema(description = "企业ID", example = "27002")
private Long enterpriseId;
@Schema(description = "用户id", example = "1")
private Long userId;
@Schema(description = "企业名称", example = "27002")
private String enterpriseName;
@Schema(description = "任务名称", example = "1")
private String taskName ;
@Schema(description = "企业名称", example = "27002")
private List<Long> enterpriseList;
@Schema(description = "任务名称", example = "1")
private List<Long> taskList;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}
}

6
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;

14
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<PageResult<TaskInfoRespVO>> appPage(@Valid TaskInfoPageReqVO pageReqVO) {
PageResult<TaskInfoDO> 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')")

9
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<TagLibraryDO> tagLibraryIds;
//任务总数
@TableField(exist = false)
private Integer taskExecNum;
//已完成数
@TableField(exist = false)
private Integer taskFinishNum;
@TableField(exist = false)
private List<String> tagList;

7
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;

9
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<EnterpriseDO> enterpriseIdes;
//任务总数
@TableField(exist = false)
private Integer taskExecNum;
//已完成数
@TableField(exist = false)
private Integer taskFinishNum;
@TableField(exist = false)
private List<String> tagList;
}

22
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<EnterpriseDO> {
default List<EnterpriseDO> selectListByStatus() {
return selectList();
}
default List<EnterpriseDO> selectList(EnterprisePageReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<EnterpriseDO>()
.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));
}
}

13
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java

@ -22,9 +22,20 @@ public interface EnterpriseInspectionsMapper extends BaseMapperX<EnterpriseInspe
.eqIfPresent(EnterpriseInspectionsDO::getTaskId, reqVO.getTaskId())
.eqIfPresent(EnterpriseInspectionsDO::getEnterpriseId, reqVO.getEnterpriseId())
.betweenIfPresent(EnterpriseInspectionsDO::getCreateTime, reqVO.getCreateTime())
.inIfPresent(EnterpriseInspectionsDO::getEnterpriseId, reqVO.getEnterpriseList())
.inIfPresent(EnterpriseInspectionsDO::getTaskId, reqVO.getTaskList())
.orderByDesc(EnterpriseInspectionsDO::getId));
}
default PageResult<EnterpriseInspectionsDO> selectAppPage(EnterpriseInspectionsPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<EnterpriseInspectionsDO>()
.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<EnterpriseInspectionsDO> selectList(EnterpriseInspectionsPageReqVO reqVO) {
@ -36,4 +47,4 @@ public interface EnterpriseInspectionsMapper extends BaseMapperX<EnterpriseInspe
}
}
}

8
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsService.java

@ -36,6 +36,8 @@ public interface EnterpriseInspectionsService {
*/
void deleteEnterpriseInspections(Long id);
void passOn(PassOnSaveVO passOnSaveVO);
/**
* 获得企业检查记录表用于记录与企业相关的环保检查信息
*
@ -44,7 +46,7 @@ public interface EnterpriseInspectionsService {
*/
EnterpriseInspectionsDO getEnterpriseInspections(Long id);
List<EnterpriseInspectionsDO> getListByUserIdAndTaskName(Long userId, String taskName);
int deleteEnterpriseInspectionsTaskId(Long taskId);
@ -58,8 +60,4 @@ public interface EnterpriseInspectionsService {
List<EnterpriseInspectionsDO> getEnterpriseInspectionsList(EnterpriseInspectionsPageReqVO pageReqVO);
}

111
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;
@ -22,6 +23,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -33,6 +36,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 +94,15 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe
// 删除
enterpriseInspectionsMapper.deleteById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteEnterpriseInspectionsTaskId(Long taskId) {
LambdaQueryWrapper<EnterpriseInspectionsDO> 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,12 +111,63 @@ 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
public PageResult<EnterpriseInspectionsDO> getEnterpriseInspectionsPage(EnterpriseInspectionsPageReqVO pageReqVO) {
if (pageReqVO.getEnterpriseName() != null) {
LambdaQueryWrapper<EnterpriseDO> wrapper = new LambdaQueryWrapper<>();
wrapper.like(EnterpriseDO::getEnterprisesName, pageReqVO.getEnterpriseName());
final List<EnterpriseDO> enterpriseDOS = enterpriseMapper.selectList(wrapper);
if (enterpriseDOS != null || enterpriseDOS.size() > 0) {
final List<Long> collect = enterpriseDOS.stream().map(item -> item.getId()).collect(Collectors.toList());
pageReqVO.setEnterpriseList(collect);
}
}
if (pageReqVO.getTaskName() != null) {
LambdaQueryWrapper<TaskInfoDO> wrapper = new LambdaQueryWrapper<>();
wrapper.like(TaskInfoDO::getTitle, pageReqVO.getTaskName());
final List<TaskInfoDO> taskInfoDOS = taskInfoMapper.selectList(wrapper);
if (taskInfoDOS != null || taskInfoDOS.size() > 0) {
final List<Long> collect = taskInfoDOS.stream().map(item -> item.getId()).collect(Collectors.toList());
pageReqVO.setTaskList(collect);
}
}
final PageResult<EnterpriseInspectionsDO> enterpriseInspectionsDOPageResult = enterpriseInspectionsMapper.selectPage(pageReqVO);
if ( enterpriseInspectionsDOPageResult.getList() != null && enterpriseInspectionsDOPageResult.getList().size() > 0 ) {
enterpriseInspectionsDOPageResult.getList().forEach(item->{
@ -152,12 +216,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 +251,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 +268,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 +329,8 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe
return inspectionsLogDOS.get(0);
}
@Override
public List<EnterpriseInspectionsDO> getEnterpriseInspectionsList(EnterpriseInspectionsPageReqVO pageReqVO) {
return enterpriseInspectionsMapper.selectList(pageReqVO);
}
}

1
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<TaskInfoDO> getTaskInfoAppPage(TaskInfoPageReqVO pageReqVO);
}

57
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<TaskInfoDO> getTaskInfoAppPage(TaskInfoPageReqVO pageReqVO) {
final PageResult<TaskInfoDO> taskInfoDOPageResult = taskInfoMapper.selectPage(pageReqVO);
if (taskInfoDOPageResult.getList() != null && taskInfoDOPageResult.getList().size() > 0) {
taskInfoDOPageResult.getList().forEach(item->{
QueryWrapper<EnterpriseInspectionsDO> wrapper = new QueryWrapper<>();
wrapper.eq("task_id", item.getId());
wrapper.eq("user_id", getLoginUserId());
item.setTaskExecNum(0);
List<EnterpriseInspectionsDO> enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(wrapper);
if (enterpriseInspectionsDOList != null && enterpriseInspectionsDOList.size() > 0) {
item.setTaskExecNum(enterpriseInspectionsDOList.size());
final List<EnterpriseInspectionsDO> collect = enterpriseInspectionsDOList.stream().filter(res -> res.getStatus() == 5).collect(Collectors.toList());
item.setTaskFinishNum(collect.size());
}
//获取任务标签
QueryWrapper<TaskTagDO> wrapper1 = new QueryWrapper<>();
wrapper1.eq("task_id", item.getId());
List<TaskTagDO> taskTagDOList = taskTagMapper.selectList(wrapper1);
if (taskTagDOList != null && taskTagDOList.size() > 0) {
final List<Long> collect = taskTagDOList.stream().map(TaskTagDO::getTagId).collect(Collectors.toList());
final List<TagLibraryDO> 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<TaskInfoDO> collect = taskInfoDOPageResult.getList().stream().filter(res -> res.getTaskExecNum() > 0).collect(Collectors.toList());
taskInfoDOPageResult.setList(collect);
taskInfoDOPageResult.setTotal(Long.valueOf(collect.size()));
}
return taskInfoDOPageResult;
}
}

Loading…
Cancel
Save