| | |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.plan.ErpPurchasePlanAuditReqVO; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.plan.ErpPurchasePlanImportExcelVO; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.plan.ErpPurchasePlanImportReqVO; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.plan.ErpPurchasePlanImportRespVO; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.plan.ErpPurchasePlanPageReqVO; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.plan.ErpPurchasePlanRespVO; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.plan.ErpPurchasePlanSaveReqVO; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | 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('erp:purchase-plan:query')") |
| | | public CommonResult<ErpPurchasePlanRespVO> getPurchasePlan(@RequestParam("id") Long id) { |
| | | ErpPurchasePlanDO plan = purchasePlanService.getPurchasePlan(id); |
| | | if (plan == null) { |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得采购计划分页") |
| | | @PreAuthorize("@ss.hasPermission('erp:purchase-plan:query')") |
| | | public CommonResult<PageResult<ErpPurchasePlanRespVO>> getPurchasePlanPage(@Valid ErpPurchasePlanPageReqVO pageReqVO) { |
| | | PageResult<ErpPurchasePlanDO> pageResult = purchasePlanService.getPurchasePlanPage(pageReqVO); |
| | | return success(buildPurchasePlanVOPageResult(pageResult)); |
| | |
| | | ExcelUtils.write(response, "采购计划.xls", "数据", ErpPurchasePlanRespVO.class, list); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入采购计划模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<ErpPurchasePlanImportExcelVO> list = Arrays.asList( |
| | | ErpPurchasePlanImportExcelVO.builder().no("CGJH-示例-001").name("示例采购计划") |
| | | .demandSource(null).planDate(null).supplierName("") |
| | | .remark("").productCode("").productUnitCode("").count(null) |
| | | .demandTime(null).itemRemark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.writeTemplate(response, "采购计划导入模板.xls", "采购计划列表", ErpPurchasePlanImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入采购计划") |
| | | @PreAuthorize("@ss.hasPermission('erp:purchase-plan:import')") |
| | | public CommonResult<ErpPurchasePlanImportRespVO> importExcel(@Valid ErpPurchasePlanImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<ErpPurchasePlanImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), ErpPurchasePlanImportExcelVO.class); |
| | | return success(purchasePlanService.importPurchasePlanList(list, importReqVO)); |
| | | } |
| | | |
| | | @PutMapping("/submit") |
| | | @Operation(summary = "提交采购计划审批") |
| | | @Operation(summary = "提交采购计划审核(草稿/审核不通过 → 审批中)") |
| | | @Parameter(name = "id", description = "编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('erp:purchase-plan:submit')") |
| | | public CommonResult<Boolean> submitPurchasePlan(@RequestParam("id") Long id, |
| | | @RequestParam("processDefinitionKey") String processDefinitionKey) { |
| | | Long userId = getLoginUserId(); |
| | | purchasePlanService.submitPurchasePlan(id, processDefinitionKey, userId); |
| | | public CommonResult<Boolean> submitPurchasePlan(@RequestParam("id") Long id) { |
| | | purchasePlanService.submitPurchasePlan(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/approve-process-list") |
| | | @Operation(summary = "获取采购计划审批流程列表") |
| | | @PreAuthorize("@ss.hasPermission('erp:purchase-plan:query')") |
| | | public CommonResult<List<Map<String, Object>>> getApproveProcessList() { |
| | | return success(purchasePlanService.getPurchasePlanApproveProcessDefinitionList()); |
| | | @PutMapping("/audit") |
| | | @Operation(summary = "审核采购计划(审批中 → 审核通过/审核不通过),仅审批人本人可操作") |
| | | @PreAuthorize("@ss.hasPermission('erp:purchase-plan:audit')") |
| | | public CommonResult<Boolean> auditPurchasePlan(@Valid @RequestBody ErpPurchasePlanAuditReqVO auditReqVO) { |
| | | purchasePlanService.auditPurchasePlan(auditReqVO.getId(), auditReqVO.getPass(), |
| | | auditReqVO.getReviewRemark()); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/approver-ids") |
| | | @Operation(summary = "获得采购计划的审批人编号集合,供前端判断是否展示审核按钮") |
| | | public CommonResult<Set<Long>> getApproverUserIds() { |
| | | return success(purchasePlanService.getPurchasePlanApproverUserIds()); |
| | | } |
| | | |
| | | @PostMapping("/generate-from-stock-alert") |