Browse Source

任务

master
DX 2 months ago
parent
commit
f5ec4eff45
  1. 2
      yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
  2. 95
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/EnterpriseInspectionsController.java
  3. 28
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsPageReqVO.java
  4. 31
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsRespVO.java
  5. 20
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsSaveReqVO.java
  6. 6
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java
  7. 39
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterpriseinspections/EnterpriseInspectionsDO.java
  8. 28
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java
  9. 56
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsService.java
  10. 75
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java
  11. 25
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java

2
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java

@ -184,4 +184,6 @@ public interface ErrorCodeConstants {
ErrorCode TASK_TAG_NOT_EXISTS = new ErrorCode(1-003-001-004, "任务标签不存在");
ErrorCode ENTERPRISE_INSPECTIONS_NOT_EXISTS = new ErrorCode(1-003-001-005, "任务记录不存在");
}

95
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/EnterpriseInspectionsController.java

@ -0,0 +1,95 @@
package cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO;
import cn.iocoder.yudao.module.system.service.enterpriseinspections.EnterpriseInspectionsService;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
@Tag(name = "管理后台 - 企业检查记录表,用于记录与企业相关的环保检查信息。")
@RestController
@RequestMapping("/system/enterprise-inspections")
@Validated
public class EnterpriseInspectionsController {
@Resource
private EnterpriseInspectionsService enterpriseInspectionsService;
@PostMapping("/create")
@Operation(summary = "创建企业检查记录表,用于记录与企业相关的环保检查信息。")
@PreAuthorize("@ss.hasPermission('system:enterprise-inspections:create')")
public CommonResult<Long> createEnterpriseInspections(@Valid @RequestBody EnterpriseInspectionsSaveReqVO createReqVO) {
return success(enterpriseInspectionsService.createEnterpriseInspections(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新企业检查记录表,用于记录与企业相关的环保检查信息。")
@PreAuthorize("@ss.hasPermission('system:enterprise-inspections:update')")
public CommonResult<Boolean> updateEnterpriseInspections(@Valid @RequestBody EnterpriseInspectionsSaveReqVO updateReqVO) {
enterpriseInspectionsService.updateEnterpriseInspections(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除企业检查记录表,用于记录与企业相关的环保检查信息。")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('system:enterprise-inspections:delete')")
public CommonResult<Boolean> deleteEnterpriseInspections(@RequestParam("id") Long id) {
enterpriseInspectionsService.deleteEnterpriseInspections(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得企业检查记录表,用于记录与企业相关的环保检查信息。")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:enterprise-inspections:query')")
public CommonResult<EnterpriseInspectionsRespVO> getEnterpriseInspections(@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')")
public CommonResult<PageResult<EnterpriseInspectionsRespVO>> getEnterpriseInspectionsPage(@Valid EnterpriseInspectionsPageReqVO pageReqVO) {
PageResult<EnterpriseInspectionsDO> pageResult = enterpriseInspectionsService.getEnterpriseInspectionsPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, EnterpriseInspectionsRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出企业检查记录表,用于记录与企业相关的环保检查信息。 Excel")
@PreAuthorize("@ss.hasPermission('system:enterprise-inspections:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportEnterpriseInspectionsExcel(@Valid EnterpriseInspectionsPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<EnterpriseInspectionsDO> list = enterpriseInspectionsService.getEnterpriseInspectionsPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "企业检查记录表,用于记录与企业相关的环保检查信息。.xls", "数据", EnterpriseInspectionsRespVO.class,
BeanUtils.toBean(list, EnterpriseInspectionsRespVO.class));
}
}

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

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 企业检查记录表,用于记录与企业相关的环保检查信息。分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class EnterpriseInspectionsPageReqVO extends PageParam {
@Schema(description = "任务ID", example = "29150")
private Long taskId;
@Schema(description = "企业ID", example = "27002")
private Long enterpriseId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

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

@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 企业检查记录表,用于记录与企业相关的环保检查信息。 Response VO")
@Data
@ExcelIgnoreUnannotated
public class EnterpriseInspectionsRespVO {
@Schema(description = "检查记录ID,主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3876")
@ExcelProperty("检查记录ID,主键")
private Long id;
@Schema(description = "任务ID", example = "29150")
@ExcelProperty("任务ID")
private Long taskId;
@Schema(description = "企业ID", example = "27002")
@ExcelProperty("企业ID")
private Long enterpriseId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

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

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@Schema(description = "管理后台 - 企业检查记录表,用于记录与企业相关的环保检查信息。新增/修改 Request VO")
@Data
public class EnterpriseInspectionsSaveReqVO {
@Schema(description = "检查记录ID,主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3876")
private Long id;
@Schema(description = "任务ID", example = "29150")
private Long taskId;
@Schema(description = "企业ID", example = "27002")
private Long enterpriseId;
}

6
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java

@ -31,10 +31,10 @@ public class TaskInfoSaveReqVO {
private Integer taskType;
@Schema(description = "任务优先级")
@NotEmpty(message = "任务优先级不能为空")
// @NotEmpty(message = "任务优先级不能为空")
private Integer priority;
@Schema(description = "任务状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@Schema(description = "任务状态", example = "2")
@NotEmpty(message = "任务状态不能为空")
private String status;
@ -60,6 +60,6 @@ public class TaskInfoSaveReqVO {
private List<Long> tagIds;
@Schema(defaultValue = "企业集合")
private List<EnterpriseDO> enterpriseIds;
private List<Long> enterpriseIds;
}

39
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterpriseinspections/EnterpriseInspectionsDO.java

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 企业检查记录表用于记录与企业相关的环保检查信息 DO
*
* @author 芋道源码
*/
@TableName("enterprise_inspections")
@KeySequence("enterprise_inspections_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EnterpriseInspectionsDO extends BaseDO {
/**
* 检查记录ID主键
*/
@TableId
private Long id;
/**
* 任务ID
*/
private Long taskId;
/**
* 企业ID
*/
private Long enterpriseId;
}

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

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.system.dal.mysql.enterpriseinspections;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo.*;
/**
* 企业检查记录表用于记录与企业相关的环保检查信息 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface EnterpriseInspectionsMapper extends BaseMapperX<EnterpriseInspectionsDO> {
default PageResult<EnterpriseInspectionsDO> selectPage(EnterpriseInspectionsPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<EnterpriseInspectionsDO>()
.eqIfPresent(EnterpriseInspectionsDO::getTaskId, reqVO.getTaskId())
.eqIfPresent(EnterpriseInspectionsDO::getEnterpriseId, reqVO.getEnterpriseId())
.betweenIfPresent(EnterpriseInspectionsDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(EnterpriseInspectionsDO::getId));
}
}

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

@ -0,0 +1,56 @@
package cn.iocoder.yudao.module.system.service.enterpriseinspections;
import java.util.*;
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;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import javax.validation.Valid;
/**
* 企业检查记录表用于记录与企业相关的环保检查信息 Service 接口
*
* @author 芋道源码
*/
public interface EnterpriseInspectionsService {
/**
* 创建企业检查记录表用于记录与企业相关的环保检查信息
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createEnterpriseInspections(@Valid EnterpriseInspectionsSaveReqVO createReqVO);
/**
* 更新企业检查记录表用于记录与企业相关的环保检查信息
*
* @param updateReqVO 更新信息
*/
void updateEnterpriseInspections(@Valid EnterpriseInspectionsSaveReqVO updateReqVO);
/**
* 删除企业检查记录表用于记录与企业相关的环保检查信息
*
* @param id 编号
*/
void deleteEnterpriseInspections(Long id);
/**
* 获得企业检查记录表用于记录与企业相关的环保检查信息
*
* @param id 编号
* @return 企业检查记录表用于记录与企业相关的环保检查信息
*/
EnterpriseInspectionsDO getEnterpriseInspections(Long id);
/**
* 获得企业检查记录表用于记录与企业相关的环保检查信息分页
*
* @param pageReqVO 分页查询
* @return 企业检查记录表用于记录与企业相关的环保检查信息分页
*/
PageResult<EnterpriseInspectionsDO> getEnterpriseInspectionsPage(EnterpriseInspectionsPageReqVO pageReqVO);
}

75
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java

@ -0,0 +1,75 @@
package cn.iocoder.yudao.module.system.service.enterpriseinspections;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
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;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.dal.mysql.enterpriseinspections.EnterpriseInspectionsMapper;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
/**
* 企业检查记录表用于记录与企业相关的环保检查信息 Service 实现类
*
* @author 芋道源码
*/
@Service
@Validated
public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsService {
@Resource
private EnterpriseInspectionsMapper enterpriseInspectionsMapper;
@Override
public Long createEnterpriseInspections(EnterpriseInspectionsSaveReqVO createReqVO) {
// 插入
EnterpriseInspectionsDO enterpriseInspections = BeanUtils.toBean(createReqVO, EnterpriseInspectionsDO.class);
enterpriseInspectionsMapper.insert(enterpriseInspections);
// 返回
return enterpriseInspections.getId();
}
@Override
public void updateEnterpriseInspections(EnterpriseInspectionsSaveReqVO updateReqVO) {
// 校验存在
validateEnterpriseInspectionsExists(updateReqVO.getId());
// 更新
EnterpriseInspectionsDO updateObj = BeanUtils.toBean(updateReqVO, EnterpriseInspectionsDO.class);
enterpriseInspectionsMapper.updateById(updateObj);
}
@Override
public void deleteEnterpriseInspections(Long id) {
// 校验存在
validateEnterpriseInspectionsExists(id);
// 删除
enterpriseInspectionsMapper.deleteById(id);
}
private void validateEnterpriseInspectionsExists(Long id) {
if (enterpriseInspectionsMapper.selectById(id) == null) {
throw exception(ENTERPRISE_INSPECTIONS_NOT_EXISTS);
}
}
@Override
public EnterpriseInspectionsDO getEnterpriseInspections(Long id) {
return enterpriseInspectionsMapper.selectById(id);
}
@Override
public PageResult<EnterpriseInspectionsDO> getEnterpriseInspectionsPage(EnterpriseInspectionsPageReqVO pageReqVO) {
return enterpriseInspectionsMapper.selectPage(pageReqVO);
}
}

25
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java

@ -1,7 +1,11 @@
package cn.iocoder.yudao.module.system.service.taskinfo;
import cn.iocoder.yudao.module.infra.api.job.JobApi;
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.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.tasktag.TaskTagMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -38,8 +42,13 @@ public class TaskInfoServiceImpl implements TaskInfoService {
private TaskTagMapper taskTagMapper;
@Resource
private JobApi jobApi;
@Resource
private EnterpriseMapper enterpriseMapper;
@Resource
private EnterpriseInspectionsMapper enterpriseInspectionsMapper;
@Override
@Transactional
public Long createTaskInfo(TaskInfoSaveReqVO createReqVO) {
// 插入
TaskInfoDO taskInfo = BeanUtils.toBean(createReqVO, TaskInfoDO.class);
@ -61,7 +70,23 @@ public class TaskInfoServiceImpl implements TaskInfoService {
// throw new RuntimeException(e);
// }
//添加企业范围
if (!createReqVO.getEnterpriseIds().isEmpty() && createReqVO.getEnterpriseIds().size() > 0) {
List<EnterpriseInspectionsDO> list = new ArrayList<>();
createReqVO.getEnterpriseIds().forEach(item->{
//查询企业信息, 添加检查人字段
final EnterpriseDO enterpriseDO = enterpriseMapper.selectById(item);
if (enterpriseDO == null) {
throw exception(ENTERPRISE_NOT_EXISTS);
}
EnterpriseInspectionsDO inspection = new EnterpriseInspectionsDO();
inspection.setTaskId(taskInfo.getId());
inspection.setEnterpriseId(item);
inspection.setCreator(enterpriseDO.getUserId().toString());
list.add(inspection);
});
enterpriseInspectionsMapper.insertBatch(list);
}
// 返回
return taskInfo.getId();

Loading…
Cancel
Save