| | |
| | | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.project.vo.MesPdProjectAuditReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.project.vo.MesPdProjectImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.project.vo.MesPdProjectImportRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.project.vo.MesPdProjectPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.project.vo.MesPdProjectRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.project.vo.MesPdProjectSaveReqVO; |
| | |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Stream; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得设计项目") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:pd-project:query')") |
| | | public CommonResult<MesPdProjectRespVO> getProject(@RequestParam("id") Long id) { |
| | | MesPdProjectDO project = projectService.getProject(id); |
| | | if (project == null) { |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得设计项目分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:pd-project:query')") |
| | | public CommonResult<PageResult<MesPdProjectRespVO>> getProjectPage(@Valid MesPdProjectPageReqVO pageReqVO) { |
| | | PageResult<MesPdProjectDO> pageResult = projectService.getProjectPage(pageReqVO); |
| | | return success(new PageResult<>(buildProjectRespVOList(pageResult.getList()), pageResult.getTotal())); |
| | |
| | | // 导出 Excel |
| | | ExcelUtils.write(response, "设计项目.xls", "数据", MesPdProjectRespVO.class, |
| | | buildProjectRespVOList(list)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得设计项目导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesPdProjectImportExcelVO> list = Collections.singletonList( |
| | | MesPdProjectImportExcelVO.builder().taskCode("PD-001").taskName("示例设计任务") |
| | | .productCode("").productName("").version("V1.0") |
| | | .chiefDesigner(1L).reviewer(1L) |
| | | .planFinishTime(LocalDateTime.of(2026, 12, 31, 0, 0)) |
| | | .remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.writeTemplate(response, "设计项目导入模板.xls", "设计项目列表", MesPdProjectImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入设计项目") |
| | | @Parameters({ |
| | | @Parameter(name = "file", description = "Excel 文件", required = true), |
| | | @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true") |
| | | }) |
| | | @PreAuthorize("@ss.hasPermission('mes:pd-project:import')") |
| | | public CommonResult<MesPdProjectImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesPdProjectImportExcelVO> list = ExcelUtils.read(file, MesPdProjectImportExcelVO.class); |
| | | return success(projectService.importProjectList(list, updateSupport)); |
| | | } |
| | | |
| | | @PutMapping("/publish") |
| | |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/audit") |
| | | @Operation(summary = "审核设计项目(待审核→待归档)") |
| | | @PutMapping("/submit-approval") |
| | | @Operation(summary = "提交设计项目审批(待审核→审批中),审核人由审批配置统一指定") |
| | | @Parameter(name = "id", description = "编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('mes:pd-project:update')") |
| | | public CommonResult<Boolean> auditProject(@RequestParam("id") Long id) { |
| | | projectService.auditProject(id); |
| | | public CommonResult<Boolean> submitProjectApproval(@RequestParam("id") Long id) { |
| | | projectService.submitProjectApproval(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/audit") |
| | | @Operation(summary = "审核设计项目(审批中→待归档/待审核),仅审批人本人可操作") |
| | | @PreAuthorize("@ss.hasPermission('mes:pd-project:audit')") |
| | | public CommonResult<Boolean> auditProject(@Valid @RequestBody MesPdProjectAuditReqVO auditReqVO) { |
| | | projectService.auditProject(auditReqVO.getId(), auditReqVO.getPass(), auditReqVO.getReviewRemark()); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/approver-ids") |
| | | @Operation(summary = "获得设计项目的审核人编号集合,供前端判断是否展示审核按钮") |
| | | public CommonResult<Set<Long>> getApproverUserIds() { |
| | | return success(projectService.getProjectApproverUserIds()); |
| | | } |
| | | |
| | | @PutMapping("/archive") |
| | | @Operation(summary = "归档设计项目(待归档→已归档),同时自动创建归档台账") |
| | | @Parameter(name = "id", description = "编号", required = true) |