| | |
| | | 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.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 java.io.IOException; |
| | | 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; |
| | |
| | | } |
| | | |
| | | @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 = "获取采购计划审批流程列表") |
| | | @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 = "获得采购计划的审批人编号集合,供前端判断是否展示审核按钮") |
| | | @PreAuthorize("@ss.hasPermission('erp:purchase-plan:query')") |
| | | public CommonResult<List<Map<String, Object>>> getApproveProcessList() { |
| | | return success(purchasePlanService.getPurchasePlanApproveProcessDefinitionList()); |
| | | public CommonResult<Set<Long>> getApproverUserIds() { |
| | | return success(purchasePlanService.getPurchasePlanApproverUserIds()); |
| | | } |
| | | |
| | | @PostMapping("/generate-from-stock-alert") |
| | |
| | | return success(plan.getId()); |
| | | } |
| | | |
| | | @GetMapping("/get-stock-alert-suggest-items") |
| | | @Operation(summary = "获取库存预警建议采购明细", description = "遍历启用安全库存的物料,按默认仓库缺量返回建议采购明细,不落库") |
| | | @PreAuthorize("@ss.hasPermission('erp:purchase-plan:create')") |
| | | public CommonResult<List<ErpPurchasePlanRespVO.Item>> getStockAlertSuggestItems() { |
| | | List<ErpPurchasePlanRespVO.Item> items = purchasePlanService.getStockAlertSuggestItems(); |
| | | if (CollUtil.isEmpty(items)) { |
| | | return success(items); |
| | | } |
| | | // 1.2 单位信息 |
| | | Map<Long, MdmUnitMeasureRespDTO> unitMeasureMap = mdmUnitMeasureApi.getUnitMeasureMap( |
| | | convertSet(items, ErpPurchasePlanRespVO.Item::getProductUnitId)); |
| | | items.forEach(item -> MapUtils.findAndThen(unitMeasureMap, item.getProductUnitId(), |
| | | unit -> item.setProductUnitName(unit.getName()))); |
| | | return success(items); |
| | | } |
| | | |
| | | @PostMapping("/generate-requests") |
| | | @Operation(summary = "生成采购申请") |
| | | @PreAuthorize("@ss.hasPermission('erp:purchase-plan:generate-request')") |