| | |
| | | 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.wm.returnvendor.vo.MesWmReturnVendorImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.returnvendor.vo.MesWmReturnVendorImportRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.returnvendor.vo.MesWmReturnVendorAuditReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.returnvendor.vo.MesWmReturnVendorPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.returnvendor.vo.MesWmReturnVendorRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.returnvendor.vo.MesWmReturnVendorSaveReqVO; |
| | | import cn.iocoder.yudao.module.erp.api.purchase.ErpSupplierApi; |
| | | import cn.iocoder.yudao.module.erp.api.purchase.dto.ErpSupplierRespDTO; |
| | | import cn.iocoder.yudao.module.srm.api.supplier.SrmSupplierApi; |
| | | import cn.iocoder.yudao.module.srm.api.supplier.dto.SrmSupplierRespDTO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnvendor.MesWmReturnVendorDO; |
| | | import cn.iocoder.yudao.module.mes.service.wm.returnvendor.MesWmReturnVendorService; |
| | | 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.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | |
| | | @Resource |
| | | private MesWmReturnVendorService returnVendorService; |
| | | @Resource |
| | | private ErpSupplierApi supplierApi; |
| | | private SrmSupplierApi srmSupplierApi; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建供应商退货单") |
| | |
| | | } |
| | | |
| | | @PutMapping("/submit") |
| | | @Operation(summary = "提交供应商退货单") |
| | | @Operation(summary = "提交供应商退货单审批(草稿→待拣货),审核人由审批配置统一指定") |
| | | @Parameter(name = "id", description = "编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('mes:wm-return-vendor:update')") |
| | | public CommonResult<Boolean> submitReturnVendor(@RequestParam("id") Long id) { |
| | | returnVendorService.submitReturnVendor(id); |
| | | returnVendorService.submitReturnVendorApproval(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/audit") |
| | | @Operation(summary = "审核供应商退货单(待拣货→待执行退货/草稿),仅审批人本人可操作") |
| | | @PreAuthorize("@ss.hasPermission('mes:wm-return-vendor:audit')") |
| | | public CommonResult<Boolean> auditReturnVendor(@Valid @RequestBody MesWmReturnVendorAuditReqVO auditReqVO) { |
| | | returnVendorService.auditReturnVendor(auditReqVO.getId(), auditReqVO.getPass(), auditReqVO.getReviewRemark()); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/approver-ids") |
| | | @Operation(summary = "获得供应商退货单的审核人编号集合,供前端判断是否展示审核按钮") |
| | | @PreAuthorize("@ss.hasPermission('mes:wm-return-vendor:query')") |
| | | public CommonResult<Set<Long>> getApproverUserIds() { |
| | | return success(returnVendorService.getReturnVendorApproverUserIds()); |
| | | } |
| | | |
| | | @PutMapping("/stock") |
| | |
| | | return success(returnVendorService.checkReturnVendorQuantity(id)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得供应商退货单导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesWmReturnVendorImportExcelVO> list = Collections.singletonList( |
| | | MesWmReturnVendorImportExcelVO.builder() |
| | | .code("RV20250226001").name("示例供应商退货单") |
| | | .purchaseOrderCode("PO20250226001") |
| | | .returnDate(java.time.LocalDateTime.of(2026, 3, 1, 10, 0, 0)) |
| | | .transportCode("SF1234567890") |
| | | .returnReason("质量不合格").remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "供应商退货单导入模板.xls", "供应商退货单列表", MesWmReturnVendorImportExcelVO.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:wm-return-vendor:import')") |
| | | public CommonResult<MesWmReturnVendorImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesWmReturnVendorImportExcelVO> list = ExcelUtils.read(file, MesWmReturnVendorImportExcelVO.class); |
| | | return success(returnVendorService.importReturnVendorList(list, updateSupport)); |
| | | } |
| | | |
| | | // ==================== 拼接 VO ==================== |
| | | |
| | | private List<MesWmReturnVendorRespVO> buildRespVOList(List<MesWmReturnVendorDO> list) { |
| | |
| | | return Collections.emptyList(); |
| | | } |
| | | // 1. 获得关联数据 |
| | | Map<Long, ErpSupplierRespDTO> vendorMap = supplierApi.getSupplierList( |
| | | Map<Long, SrmSupplierRespDTO> vendorMap = srmSupplierApi.getSupplierList( |
| | | convertSet(list, MesWmReturnVendorDO::getVendorId)).getCheckedData().stream() |
| | | .collect(java.util.stream.Collectors.toMap(ErpSupplierRespDTO::getId, s -> s)); |
| | | .collect(java.util.stream.Collectors.toMap(SrmSupplierRespDTO::getId, s -> s)); |
| | | // 2. 构建结果 |
| | | return BeanUtils.toBean(list, MesWmReturnVendorRespVO.class, vo -> |
| | | MapUtils.findAndThen(vendorMap, vo.getVendorId(), vendor -> |