| | |
| | | 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.crm.api.customer.CrmCustomerApi; |
| | | import cn.iocoder.yudao.module.crm.api.customer.dto.CrmCustomerRespDTO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.MesWmReturnSalesPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.MesWmReturnSalesRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.MesWmReturnSalesSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.client.MesMdClientDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesDO; |
| | | import cn.iocoder.yudao.module.mes.service.md.client.MesMdClientService; |
| | | import cn.iocoder.yudao.module.mes.service.wm.returnsales.MesWmReturnSalesService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | | |
| | | /** |
| | | * 管理后台 - MES 销售退货单 Controller |
| | | * |
| | | * @author 芋道源码 |
| | | */ |
| | | @Tag(name = "管理后台 - MES 销售退货单") |
| | | @RestController |
| | | @RequestMapping("/mes/wm/return-sales") |
| | |
| | | @Resource |
| | | private MesWmReturnSalesService returnSalesService; |
| | | @Resource |
| | | private MesMdClientService clientService; |
| | | private CrmCustomerApi crmCustomerApi; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建销售退货单") |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得销售退货单") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:query')") |
| | | public CommonResult<MesWmReturnSalesRespVO> getReturnSales(@RequestParam("id") Long id) { |
| | | MesWmReturnSalesDO returnSales = returnSalesService.getReturnSales(id); |
| | | if (returnSales == null) { |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得销售退货单分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:query')") |
| | | public CommonResult<PageResult<MesWmReturnSalesRespVO>> getReturnSalesPage( |
| | | @Valid MesWmReturnSalesPageReqVO pageReqVO) { |
| | | PageResult<MesWmReturnSalesDO> pageResult = returnSalesService.getReturnSalesPage(pageReqVO); |
| | |
| | | @GetMapping("/check-quantity") |
| | | @Operation(summary = "校验销售退货单数量", description = "校验每行明细数量之和是否等于行退货数量") |
| | | @Parameter(name = "id", description = "编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:query')") |
| | | public CommonResult<Boolean> checkReturnSalesQuantity(@RequestParam("id") Long id) { |
| | | return success(returnSalesService.checkReturnSalesQuantity(id)); |
| | | } |
| | |
| | | return Collections.emptyList(); |
| | | } |
| | | // 1. 获得关联数据 |
| | | Map<Long, MesMdClientDO> clientMap = clientService.getClientMap( |
| | | Map<Long, CrmCustomerRespDTO> customerMap = crmCustomerApi.getCustomerMap( |
| | | convertSet(list, MesWmReturnSalesDO::getClientId)); |
| | | // 2. 构建结果 |
| | | return BeanUtils.toBean(list, MesWmReturnSalesRespVO.class, vo -> |
| | | MapUtils.findAndThen(clientMap, vo.getClientId(), client -> |
| | | vo.setClientCode(client.getCode()).setClientName(client.getName()).setClientNickname(client.getNickname()))); |
| | | MapUtils.findAndThen(customerMap, vo.getClientId(), customer -> |
| | | vo.setClientName(customer.getName()))); |
| | | } |
| | | |
| | | } |
| | | } |