Commit 4d4287dd4c93f6b6c4844ec400efc06ba978e6c4
1 parent
f99f8548
✨ feat(mes): 添加销售退货单及行相关功能和数据结构
新增销售退货单及行的相关数据结构、请求和响应对象,包含销售退货单的基本信息、行信息以及相关的 API 接口,支持销售退货单的创建、更新、查询和删除操作,提升了系统的功能性和可维护性。
Showing
26 changed files
with
1946 additions
and
0 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/MesWmReturnSalesController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 8 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 9 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 10 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 11 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.MesWmReturnSalesPageReqVO; | |
| 12 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.MesWmReturnSalesRespVO; | |
| 13 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.MesWmReturnSalesSaveReqVO; | |
| 14 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.client.MesMdClientDO; | |
| 15 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesDO; | |
| 16 | +import cn.iocoder.yudao.module.mes.service.md.client.MesMdClientService; | |
| 17 | +import cn.iocoder.yudao.module.mes.service.wm.returnsales.MesWmReturnSalesService; | |
| 18 | +import io.swagger.v3.oas.annotations.Operation; | |
| 19 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 20 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 21 | +import jakarta.annotation.Resource; | |
| 22 | +import jakarta.servlet.http.HttpServletResponse; | |
| 23 | +import jakarta.validation.Valid; | |
| 24 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 25 | +import org.springframework.validation.annotation.Validated; | |
| 26 | +import org.springframework.web.bind.annotation.*; | |
| 27 | + | |
| 28 | +import java.io.IOException; | |
| 29 | +import java.util.Collections; | |
| 30 | +import java.util.List; | |
| 31 | +import java.util.Map; | |
| 32 | + | |
| 33 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | |
| 34 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 35 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 36 | + | |
| 37 | +/** | |
| 38 | + * 管理后台 - MES 销售退货单 Controller | |
| 39 | + * | |
| 40 | + * @author 芋道源码 | |
| 41 | + */ | |
| 42 | +@Tag(name = "管理后台 - MES 销售退货单") | |
| 43 | +@RestController | |
| 44 | +@RequestMapping("/mes/wm/return-sales") | |
| 45 | +@Validated | |
| 46 | +public class MesWmReturnSalesController { | |
| 47 | + | |
| 48 | + @Resource | |
| 49 | + private MesWmReturnSalesService returnSalesService; | |
| 50 | + @Resource | |
| 51 | + private MesMdClientService clientService; | |
| 52 | + | |
| 53 | + @PostMapping("/create") | |
| 54 | + @Operation(summary = "创建销售退货单") | |
| 55 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:create')") | |
| 56 | + public CommonResult<Long> createReturnSales(@Valid @RequestBody MesWmReturnSalesSaveReqVO createReqVO) { | |
| 57 | + return success(returnSalesService.createReturnSales(createReqVO)); | |
| 58 | + } | |
| 59 | + | |
| 60 | + @PutMapping("/update") | |
| 61 | + @Operation(summary = "修改销售退货单") | |
| 62 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:update')") | |
| 63 | + public CommonResult<Boolean> updateReturnSales(@Valid @RequestBody MesWmReturnSalesSaveReqVO updateReqVO) { | |
| 64 | + returnSalesService.updateReturnSales(updateReqVO); | |
| 65 | + return success(true); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @DeleteMapping("/delete") | |
| 69 | + @Operation(summary = "删除销售退货单") | |
| 70 | + @Parameter(name = "id", description = "编号", required = true) | |
| 71 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:delete')") | |
| 72 | + public CommonResult<Boolean> deleteReturnSales(@RequestParam("id") Long id) { | |
| 73 | + returnSalesService.deleteReturnSales(id); | |
| 74 | + return success(true); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @GetMapping("/get") | |
| 78 | + @Operation(summary = "获得销售退货单") | |
| 79 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 80 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:query')") | |
| 81 | + public CommonResult<MesWmReturnSalesRespVO> getReturnSales(@RequestParam("id") Long id) { | |
| 82 | + MesWmReturnSalesDO returnSales = returnSalesService.getReturnSales(id); | |
| 83 | + if (returnSales == null) { | |
| 84 | + return success(null); | |
| 85 | + } | |
| 86 | + return success(buildRespVOList(Collections.singletonList(returnSales)).get(0)); | |
| 87 | + } | |
| 88 | + | |
| 89 | + @GetMapping("/page") | |
| 90 | + @Operation(summary = "获得销售退货单分页") | |
| 91 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:query')") | |
| 92 | + public CommonResult<PageResult<MesWmReturnSalesRespVO>> getReturnSalesPage( | |
| 93 | + @Valid MesWmReturnSalesPageReqVO pageReqVO) { | |
| 94 | + PageResult<MesWmReturnSalesDO> pageResult = returnSalesService.getReturnSalesPage(pageReqVO); | |
| 95 | + return success(new PageResult<>(buildRespVOList(pageResult.getList()), pageResult.getTotal())); | |
| 96 | + } | |
| 97 | + | |
| 98 | + @GetMapping("/export-excel") | |
| 99 | + @Operation(summary = "导出销售退货单 Excel") | |
| 100 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:export')") | |
| 101 | + @ApiAccessLog(operateType = EXPORT) | |
| 102 | + public void exportReturnSalesExcel(@Valid MesWmReturnSalesPageReqVO pageReqVO, | |
| 103 | + HttpServletResponse response) throws IOException { | |
| 104 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 105 | + PageResult<MesWmReturnSalesDO> pageResult = returnSalesService.getReturnSalesPage(pageReqVO); | |
| 106 | + ExcelUtils.write(response, "销售退货单.xls", "数据", MesWmReturnSalesRespVO.class, | |
| 107 | + buildRespVOList(pageResult.getList())); | |
| 108 | + } | |
| 109 | + | |
| 110 | + @PutMapping("/submit") | |
| 111 | + @Operation(summary = "提交销售退货单") | |
| 112 | + @Parameter(name = "id", description = "编号", required = true) | |
| 113 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:submit')") | |
| 114 | + public CommonResult<Boolean> submitReturnSales(@RequestParam("id") Long id) { | |
| 115 | + returnSalesService.submitReturnSales(id); | |
| 116 | + return success(true); | |
| 117 | + } | |
| 118 | + | |
| 119 | + @PutMapping("/execute") | |
| 120 | + @Operation(summary = "执行退货") | |
| 121 | + @Parameter(name = "id", description = "编号", required = true) | |
| 122 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:execute')") | |
| 123 | + public CommonResult<Boolean> executeReturnSales(@RequestParam("id") Long id) { | |
| 124 | + returnSalesService.executeReturnSales(id); | |
| 125 | + return success(true); | |
| 126 | + } | |
| 127 | + | |
| 128 | + @PutMapping("/stock") | |
| 129 | + @Operation(summary = "执行上架") | |
| 130 | + @Parameter(name = "id", description = "编号", required = true) | |
| 131 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:stock')") | |
| 132 | + public CommonResult<Boolean> stockReturnSales(@RequestParam("id") Long id) { | |
| 133 | + returnSalesService.stockReturnSales(id); | |
| 134 | + return success(true); | |
| 135 | + } | |
| 136 | + | |
| 137 | + @PutMapping("/cancel") | |
| 138 | + @Operation(summary = "取消销售退货单") | |
| 139 | + @Parameter(name = "id", description = "编号", required = true) | |
| 140 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:cancel')") | |
| 141 | + public CommonResult<Boolean> cancelReturnSales(@RequestParam("id") Long id) { | |
| 142 | + returnSalesService.cancelReturnSales(id); | |
| 143 | + return success(true); | |
| 144 | + } | |
| 145 | + | |
| 146 | + @GetMapping("/check-quantity") | |
| 147 | + @Operation(summary = "校验销售退货单数量", description = "校验每行明细数量之和是否等于行退货数量") | |
| 148 | + @Parameter(name = "id", description = "编号", required = true) | |
| 149 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:query')") | |
| 150 | + public CommonResult<Boolean> checkReturnSalesQuantity(@RequestParam("id") Long id) { | |
| 151 | + return success(returnSalesService.checkReturnSalesQuantity(id)); | |
| 152 | + } | |
| 153 | + | |
| 154 | + // ==================== 拼接 VO ==================== | |
| 155 | + | |
| 156 | + private List<MesWmReturnSalesRespVO> buildRespVOList(List<MesWmReturnSalesDO> list) { | |
| 157 | + if (CollUtil.isEmpty(list)) { | |
| 158 | + return Collections.emptyList(); | |
| 159 | + } | |
| 160 | + // 1. 获得关联数据 | |
| 161 | + Map<Long, MesMdClientDO> clientMap = clientService.getClientMap( | |
| 162 | + convertSet(list, MesWmReturnSalesDO::getClientId)); | |
| 163 | + // 2. 构建结果 | |
| 164 | + return BeanUtils.toBean(list, MesWmReturnSalesRespVO.class, vo -> | |
| 165 | + MapUtils.findAndThen(clientMap, vo.getClientId(), client -> | |
| 166 | + vo.setClientCode(client.getCode()).setClientName(client.getName()).setClientNickname(client.getNickname()))); | |
| 167 | + } | |
| 168 | + | |
| 169 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/MesWmReturnSalesDetailController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 7 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.detail.MesWmReturnSalesDetailRespVO; | |
| 8 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.detail.MesWmReturnSalesDetailSaveReqVO; | |
| 9 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; | |
| 10 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; | |
| 11 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesDetailDO; | |
| 12 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseAreaDO; | |
| 13 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseDO; | |
| 14 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseLocationDO; | |
| 15 | +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | |
| 16 | +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; | |
| 17 | +import cn.iocoder.yudao.module.mes.service.wm.returnsales.MesWmReturnSalesDetailService; | |
| 18 | +import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseAreaService; | |
| 19 | +import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseLocationService; | |
| 20 | +import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseService; | |
| 21 | +import io.swagger.v3.oas.annotations.Operation; | |
| 22 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 23 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 24 | +import jakarta.annotation.Resource; | |
| 25 | +import jakarta.validation.Valid; | |
| 26 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 27 | +import org.springframework.validation.annotation.Validated; | |
| 28 | +import org.springframework.web.bind.annotation.*; | |
| 29 | + | |
| 30 | +import java.util.Collections; | |
| 31 | +import java.util.List; | |
| 32 | +import java.util.Map; | |
| 33 | + | |
| 34 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 35 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 36 | + | |
| 37 | +/** | |
| 38 | + * 管理后台 - MES 销售退货相关 | |
| 39 | + * | |
| 40 | + * @author 芋道源码 | |
| 41 | + */ | |
| 42 | +@Tag(name = "管理后台 - MES 销售退货明细") | |
| 43 | +@RestController | |
| 44 | +@RequestMapping("/mes/wm/return-sales-detail") | |
| 45 | +@Validated | |
| 46 | +public class MesWmReturnSalesDetailController { | |
| 47 | + | |
| 48 | + @Resource | |
| 49 | + private MesWmReturnSalesDetailService returnSalesDetailService; | |
| 50 | + | |
| 51 | + @Resource | |
| 52 | + private MesMdItemService itemService; | |
| 53 | + | |
| 54 | + @Resource | |
| 55 | + private MesMdUnitMeasureService unitMeasureService; | |
| 56 | + | |
| 57 | + @Resource | |
| 58 | + private MesWmWarehouseService warehouseService; | |
| 59 | + | |
| 60 | + @Resource | |
| 61 | + private MesWmWarehouseLocationService locationService; | |
| 62 | + | |
| 63 | + @Resource | |
| 64 | + private MesWmWarehouseAreaService areaService; | |
| 65 | + | |
| 66 | + @PostMapping("/create") | |
| 67 | + @Operation(summary = "创建销售退货明细") | |
| 68 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:create')") | |
| 69 | + public CommonResult<Long> createReturnSalesDetail(@Valid @RequestBody MesWmReturnSalesDetailSaveReqVO createReqVO) { | |
| 70 | + return success(returnSalesDetailService.createReturnSalesDetail(createReqVO)); | |
| 71 | + } | |
| 72 | + | |
| 73 | + @PutMapping("/update") | |
| 74 | + @Operation(summary = "修改销售退货明细") | |
| 75 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:update')") | |
| 76 | + public CommonResult<Boolean> updateReturnSalesDetail(@Valid @RequestBody MesWmReturnSalesDetailSaveReqVO updateReqVO) { | |
| 77 | + returnSalesDetailService.updateReturnSalesDetail(updateReqVO); | |
| 78 | + return success(true); | |
| 79 | + } | |
| 80 | + | |
| 81 | + @DeleteMapping("/delete") | |
| 82 | + @Operation(summary = "删除销售退货明细") | |
| 83 | + @Parameter(name = "id", description = "编号", required = true) | |
| 84 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:delete')") | |
| 85 | + public CommonResult<Boolean> deleteReturnSalesDetail(@RequestParam("id") Long id) { | |
| 86 | + returnSalesDetailService.deleteReturnSalesDetail(id); | |
| 87 | + return success(true); | |
| 88 | + } | |
| 89 | + | |
| 90 | + @GetMapping("/get") | |
| 91 | + @Operation(summary = "获得销售退货明细") | |
| 92 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 93 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:query')") | |
| 94 | + public CommonResult<MesWmReturnSalesDetailRespVO> getReturnSalesDetail(@RequestParam("id") Long id) { | |
| 95 | + MesWmReturnSalesDetailDO detail = returnSalesDetailService.getReturnSalesDetail(id); | |
| 96 | + if (detail == null) { | |
| 97 | + return success(null); | |
| 98 | + } | |
| 99 | + return success(buildRespVOList(Collections.singletonList(detail)).get(0)); | |
| 100 | + } | |
| 101 | + | |
| 102 | + @GetMapping("/list-by-line") | |
| 103 | + @Operation(summary = "获得销售退货明细列表(按行编号)") | |
| 104 | + @Parameter(name = "lineId", description = "行编号", required = true, example = "1024") | |
| 105 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:query')") | |
| 106 | + public CommonResult<List<MesWmReturnSalesDetailRespVO>> getReturnSalesDetailListByLineId( | |
| 107 | + @RequestParam("lineId") Long lineId) { | |
| 108 | + List<MesWmReturnSalesDetailDO> list = returnSalesDetailService.getReturnSalesDetailListByLineId(lineId); | |
| 109 | + return success(buildRespVOList(list)); | |
| 110 | + } | |
| 111 | + | |
| 112 | + // ==================== 拼接 VO ==================== | |
| 113 | + | |
| 114 | + private List<MesWmReturnSalesDetailRespVO> buildRespVOList(List<MesWmReturnSalesDetailDO> list) { | |
| 115 | + if (CollUtil.isEmpty(list)) { | |
| 116 | + return Collections.emptyList(); | |
| 117 | + } | |
| 118 | + // 1. 获得关联数据 | |
| 119 | + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( | |
| 120 | + convertSet(list, MesWmReturnSalesDetailDO::getItemId)); | |
| 121 | + Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( | |
| 122 | + convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId)); | |
| 123 | + Map<Long, MesWmWarehouseDO> warehouseMap = warehouseService.getWarehouseMap( | |
| 124 | + convertSet(list, MesWmReturnSalesDetailDO::getWarehouseId)); | |
| 125 | + Map<Long, MesWmWarehouseLocationDO> locationMap = locationService.getWarehouseLocationMap( | |
| 126 | + convertSet(list, MesWmReturnSalesDetailDO::getLocationId)); | |
| 127 | + Map<Long, MesWmWarehouseAreaDO> areaMap = areaService.getWarehouseAreaMap( | |
| 128 | + convertSet(list, MesWmReturnSalesDetailDO::getAreaId)); | |
| 129 | + // 2. 构建结果 | |
| 130 | + return BeanUtils.toBean(list, MesWmReturnSalesDetailRespVO.class, vo -> { | |
| 131 | + // TODO @AI:set 的时候,链式调用; | |
| 132 | + MapUtils.findAndThen(itemMap, vo.getItemId(), item -> { | |
| 133 | + vo.setItemCode(item.getCode()); | |
| 134 | + vo.setItemName(item.getName()); | |
| 135 | + vo.setItemSpecification(item.getSpecification()); | |
| 136 | + MapUtils.findAndThen(unitMeasureMap, item.getUnitMeasureId(), | |
| 137 | + unitMeasure -> vo.setItemUnit(unitMeasure.getName())); | |
| 138 | + }); | |
| 139 | + MapUtils.findAndThen(warehouseMap, vo.getWarehouseId(), warehouse -> { | |
| 140 | + // TODO @AI:set 的时候,链式调用; | |
| 141 | + vo.setWarehouseCode(warehouse.getCode()); | |
| 142 | + vo.setWarehouseName(warehouse.getName()); | |
| 143 | + }); | |
| 144 | + MapUtils.findAndThen(locationMap, vo.getLocationId(), location -> { | |
| 145 | + // TODO @AI:set 的时候,链式调用; | |
| 146 | + vo.setLocationCode(location.getCode()); | |
| 147 | + vo.setLocationName(location.getName()); | |
| 148 | + }); | |
| 149 | + MapUtils.findAndThen(areaMap, vo.getAreaId(), area -> { | |
| 150 | + // TODO @AI:set 的时候,链式调用; | |
| 151 | + vo.setAreaCode(area.getCode()); | |
| 152 | + vo.setAreaName(area.getName()); | |
| 153 | + }); | |
| 154 | + }); | |
| 155 | + } | |
| 156 | + | |
| 157 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/MesWmReturnSalesLineController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 7 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 8 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.line.MesWmReturnSalesLinePageReqVO; | |
| 9 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.line.MesWmReturnSalesLineRespVO; | |
| 10 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.line.MesWmReturnSalesLineSaveReqVO; | |
| 11 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; | |
| 12 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; | |
| 13 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesLineDO; | |
| 14 | +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | |
| 15 | +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; | |
| 16 | +import cn.iocoder.yudao.module.mes.service.wm.returnsales.MesWmReturnSalesLineService; | |
| 17 | +import io.swagger.v3.oas.annotations.Operation; | |
| 18 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 19 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 20 | +import jakarta.annotation.Resource; | |
| 21 | +import jakarta.validation.Valid; | |
| 22 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 23 | +import org.springframework.validation.annotation.Validated; | |
| 24 | +import org.springframework.web.bind.annotation.*; | |
| 25 | + | |
| 26 | +import java.util.Collections; | |
| 27 | +import java.util.List; | |
| 28 | +import java.util.Map; | |
| 29 | + | |
| 30 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 31 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * 管理后台 - MES 销售退货相关 | |
| 35 | + * | |
| 36 | + * @author 芋道源码 | |
| 37 | + */ | |
| 38 | +@Tag(name = "管理后台 - MES 销售退货单行") | |
| 39 | +@RestController | |
| 40 | +@RequestMapping("/mes/wm/return-sales-line") | |
| 41 | +@Validated | |
| 42 | +public class MesWmReturnSalesLineController { | |
| 43 | + | |
| 44 | + @Resource | |
| 45 | + private MesWmReturnSalesLineService returnSalesLineService; | |
| 46 | + | |
| 47 | + @Resource | |
| 48 | + private MesMdItemService itemService; | |
| 49 | + | |
| 50 | + @Resource | |
| 51 | + private MesMdUnitMeasureService unitMeasureService; | |
| 52 | + | |
| 53 | + @PostMapping("/create") | |
| 54 | + @Operation(summary = "创建销售退货单行") | |
| 55 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:create')") | |
| 56 | + public CommonResult<Long> createReturnSalesLine(@Valid @RequestBody MesWmReturnSalesLineSaveReqVO createReqVO) { | |
| 57 | + return success(returnSalesLineService.createReturnSalesLine(createReqVO)); | |
| 58 | + } | |
| 59 | + | |
| 60 | + @PutMapping("/update") | |
| 61 | + @Operation(summary = "修改销售退货单行") | |
| 62 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:update')") | |
| 63 | + public CommonResult<Boolean> updateReturnSalesLine(@Valid @RequestBody MesWmReturnSalesLineSaveReqVO updateReqVO) { | |
| 64 | + returnSalesLineService.updateReturnSalesLine(updateReqVO); | |
| 65 | + return success(true); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @DeleteMapping("/delete") | |
| 69 | + @Operation(summary = "删除销售退货单行") | |
| 70 | + @Parameter(name = "id", description = "编号", required = true) | |
| 71 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:delete')") | |
| 72 | + public CommonResult<Boolean> deleteReturnSalesLine(@RequestParam("id") Long id) { | |
| 73 | + returnSalesLineService.deleteReturnSalesLine(id); | |
| 74 | + return success(true); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @GetMapping("/get") | |
| 78 | + @Operation(summary = "获得销售退货单行") | |
| 79 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 80 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:query')") | |
| 81 | + public CommonResult<MesWmReturnSalesLineRespVO> getReturnSalesLine(@RequestParam("id") Long id) { | |
| 82 | + MesWmReturnSalesLineDO line = returnSalesLineService.getReturnSalesLine(id); | |
| 83 | + if (line == null) { | |
| 84 | + return success(null); | |
| 85 | + } | |
| 86 | + return success(buildRespVOList(Collections.singletonList(line)).get(0)); | |
| 87 | + } | |
| 88 | + | |
| 89 | + @GetMapping("/page") | |
| 90 | + @Operation(summary = "获得销售退货单行分页") | |
| 91 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:query')") | |
| 92 | + public CommonResult<PageResult<MesWmReturnSalesLineRespVO>> getReturnSalesLinePage( | |
| 93 | + @Valid MesWmReturnSalesLinePageReqVO pageReqVO) { | |
| 94 | + PageResult<MesWmReturnSalesLineDO> pageResult = returnSalesLineService.getReturnSalesLinePage(pageReqVO); | |
| 95 | + return success(new PageResult<>(buildRespVOList(pageResult.getList()), pageResult.getTotal())); | |
| 96 | + } | |
| 97 | + | |
| 98 | + @GetMapping("/list-by-return-sales") | |
| 99 | + @Operation(summary = "获得销售退货单行列表(按退货单编号)") | |
| 100 | + @Parameter(name = "returnId", description = "退货单编号", required = true, example = "1024") | |
| 101 | + @PreAuthorize("@ss.hasPermission('mes:wm-return-sales:query')") | |
| 102 | + public CommonResult<List<MesWmReturnSalesLineRespVO>> getReturnSalesLineListByReturnId( | |
| 103 | + @RequestParam("returnId") Long returnId) { | |
| 104 | + List<MesWmReturnSalesLineDO> list = returnSalesLineService.getReturnSalesLineListByReturnId(returnId); | |
| 105 | + return success(buildRespVOList(list)); | |
| 106 | + } | |
| 107 | + | |
| 108 | + // ==================== 拼接 VO ==================== | |
| 109 | + | |
| 110 | + private List<MesWmReturnSalesLineRespVO> buildRespVOList(List<MesWmReturnSalesLineDO> list) { | |
| 111 | + if (CollUtil.isEmpty(list)) { | |
| 112 | + return Collections.emptyList(); | |
| 113 | + } | |
| 114 | + // 1. 获得关联数据 | |
| 115 | + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( | |
| 116 | + convertSet(list, MesWmReturnSalesLineDO::getItemId)); | |
| 117 | + Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( | |
| 118 | + convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId)); | |
| 119 | + // 2. 构建结果 | |
| 120 | + return BeanUtils.toBean(list, MesWmReturnSalesLineRespVO.class, vo -> { | |
| 121 | + MapUtils.findAndThen(itemMap, vo.getItemId(), item -> { | |
| 122 | + // TODO @AI:set 的时候,链式调用; | |
| 123 | + vo.setItemCode(item.getCode()); | |
| 124 | + vo.setItemName(item.getName()); | |
| 125 | + vo.setItemSpecification(item.getSpecification()); | |
| 126 | + MapUtils.findAndThen(unitMeasureMap, item.getUnitMeasureId(), | |
| 127 | + unitMeasure -> vo.setItemUnit(unitMeasure.getName())); | |
| 128 | + }); | |
| 129 | + }); | |
| 130 | + } | |
| 131 | + | |
| 132 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/vo/MesWmReturnSalesPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | + | |
| 9 | +import java.time.LocalDateTime; | |
| 10 | + | |
| 11 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 管理后台 - MES 销售退货相关 | |
| 15 | + * | |
| 16 | + * @author 芋道源码 | |
| 17 | + */ | |
| 18 | +@Schema(description = "管理后台 - MES 销售退货单分页 Request VO") | |
| 19 | +@Data | |
| 20 | +@EqualsAndHashCode(callSuper = true) | |
| 21 | +public class MesWmReturnSalesPageReqVO extends PageParam { | |
| 22 | + | |
| 23 | + @Schema(description = "退货单编号", example = "RS202603010001") | |
| 24 | + private String code; | |
| 25 | + | |
| 26 | + @Schema(description = "退货单名称", example = "销售退货") | |
| 27 | + private String name; | |
| 28 | + | |
| 29 | + @Schema(description = "销售订单编号", example = "SO202603010001") | |
| 30 | + private String salesOrderCode; | |
| 31 | + | |
| 32 | + @Schema(description = "客户 ID", example = "1") | |
| 33 | + private Long clientId; | |
| 34 | + | |
| 35 | + @Schema(description = "状态", example = "0") | |
| 36 | + private Integer status; | |
| 37 | + | |
| 38 | + @Schema(description = "退货日期") | |
| 39 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 40 | + private LocalDateTime[] returnDate; | |
| 41 | + | |
| 42 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/vo/MesWmReturnSalesRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 管理后台 - MES 销售退货相关 | |
| 10 | + * | |
| 11 | + * @author 芋道源码 | |
| 12 | + */ | |
| 13 | +@Schema(description = "管理后台 - MES 销售退货单 Response VO") | |
| 14 | +@Data | |
| 15 | +public class MesWmReturnSalesRespVO { | |
| 16 | + | |
| 17 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | + @Schema(description = "退货单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "RS202603010001") | |
| 21 | + private String code; | |
| 22 | + | |
| 23 | + @Schema(description = "退货单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "销售退货") | |
| 24 | + private String name; | |
| 25 | + | |
| 26 | + @Schema(description = "销售订单编号", example = "SO202603010001") | |
| 27 | + private String salesOrderCode; | |
| 28 | + | |
| 29 | + @Schema(description = "客户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 30 | + private Long clientId; | |
| 31 | + | |
| 32 | + @Schema(description = "客户编码", example = "C001") | |
| 33 | + private String clientCode; | |
| 34 | + | |
| 35 | + @Schema(description = "客户名称", example = "XX客户") | |
| 36 | + private String clientName; | |
| 37 | + | |
| 38 | + @Schema(description = "客户简称", example = "XX") | |
| 39 | + private String clientNickname; | |
| 40 | + | |
| 41 | + @Schema(description = "退货日期") | |
| 42 | + private LocalDateTime returnDate; | |
| 43 | + | |
| 44 | + @Schema(description = "退货原因", example = "质量问题") | |
| 45 | + private String returnReason; | |
| 46 | + | |
| 47 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | |
| 48 | + private Integer status; | |
| 49 | + | |
| 50 | + @Schema(description = "备注", example = "备注") | |
| 51 | + private String remark; | |
| 52 | + | |
| 53 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 54 | + private LocalDateTime createTime; | |
| 55 | + | |
| 56 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/vo/MesWmReturnSalesSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import jakarta.validation.constraints.NotBlank; | |
| 5 | +import jakarta.validation.constraints.NotNull; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 管理后台 - MES 销售退货单新增/修改 Request VO | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + */ | |
| 15 | +@Schema(description = "管理后台 - MES 销售退货单新增/修改 Request VO") | |
| 16 | +@Data | |
| 17 | +public class MesWmReturnSalesSaveReqVO { | |
| 18 | + | |
| 19 | + @Schema(description = "编号", example = "1024") | |
| 20 | + private Long id; | |
| 21 | + | |
| 22 | + @Schema(description = "退货单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "RS202603010001") | |
| 23 | + @NotBlank(message = "退货单编号不能为空") | |
| 24 | + private String code; | |
| 25 | + | |
| 26 | + @Schema(description = "退货单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "销售退货") | |
| 27 | + @NotBlank(message = "退货单名称不能为空") | |
| 28 | + private String name; | |
| 29 | + | |
| 30 | + @Schema(description = "销售订单编号", example = "SO202603010001") | |
| 31 | + private String salesOrderCode; | |
| 32 | + | |
| 33 | + @Schema(description = "客户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 34 | + @NotNull(message = "客户 ID 不能为空") | |
| 35 | + private Long clientId; | |
| 36 | + | |
| 37 | + @Schema(description = "退货日期", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 38 | + @NotNull(message = "退货日期不能为空") | |
| 39 | + private LocalDateTime returnDate; | |
| 40 | + | |
| 41 | + @Schema(description = "退货原因", example = "质量问题") | |
| 42 | + private String returnReason; | |
| 43 | + | |
| 44 | + @Schema(description = "备注", example = "备注") | |
| 45 | + private String remark; | |
| 46 | + | |
| 47 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/vo/detail/MesWmReturnSalesDetailPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.detail; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 管理后台 - MES 销售退货相关 | |
| 10 | + * | |
| 11 | + * @author 芋道源码 | |
| 12 | + */ | |
| 13 | +@Schema(description = "管理后台 - MES 销售退货明细分页 Request VO") | |
| 14 | +@Data | |
| 15 | +@EqualsAndHashCode(callSuper = true) | |
| 16 | +public class MesWmReturnSalesDetailPageReqVO extends PageParam { | |
| 17 | + | |
| 18 | + @Schema(description = "退货单ID", example = "1") | |
| 19 | + private Long returnId; | |
| 20 | + | |
| 21 | + @Schema(description = "行ID", example = "1") | |
| 22 | + private Long lineId; | |
| 23 | + | |
| 24 | + @Schema(description = "物料ID", example = "1") | |
| 25 | + private Long itemId; | |
| 26 | + | |
| 27 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/vo/detail/MesWmReturnSalesDetailRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.detail; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import java.math.BigDecimal; | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 管理后台 - MES 销售退货相关 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@Schema(description = "管理后台 - MES 销售退货明细 Response VO") | |
| 15 | +@Data | |
| 16 | +public class MesWmReturnSalesDetailRespVO { | |
| 17 | + | |
| 18 | + @Schema(description = "明细ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 19 | + private Long id; | |
| 20 | + | |
| 21 | + @Schema(description = "退货单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 22 | + private Long returnId; | |
| 23 | + | |
| 24 | + @Schema(description = "行ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 25 | + private Long lineId; | |
| 26 | + | |
| 27 | + @Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 28 | + private Long itemId; | |
| 29 | + | |
| 30 | + @Schema(description = "物料编码", example = "M001") | |
| 31 | + private String itemCode; | |
| 32 | + | |
| 33 | + @Schema(description = "物料名称", example = "物料A") | |
| 34 | + private String itemName; | |
| 35 | + | |
| 36 | + @Schema(description = "物料规格", example = "100*200") | |
| 37 | + private String itemSpecification; | |
| 38 | + | |
| 39 | + @Schema(description = "计量单位", example = "个") | |
| 40 | + private String itemUnit; | |
| 41 | + | |
| 42 | + @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") | |
| 43 | + private BigDecimal quantity; | |
| 44 | + | |
| 45 | + @Schema(description = "批次ID", example = "1") | |
| 46 | + private Long batchId; | |
| 47 | + | |
| 48 | + @Schema(description = "批次号", example = "B001") | |
| 49 | + private String batchCode; | |
| 50 | + | |
| 51 | + @Schema(description = "仓库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 52 | + private Long warehouseId; | |
| 53 | + | |
| 54 | + @Schema(description = "仓库编码", example = "WH001") | |
| 55 | + private String warehouseCode; | |
| 56 | + | |
| 57 | + @Schema(description = "仓库名称", example = "仓库A") | |
| 58 | + private String warehouseName; | |
| 59 | + | |
| 60 | + @Schema(description = "库区ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 61 | + private Long locationId; | |
| 62 | + | |
| 63 | + @Schema(description = "库区编码", example = "LOC001") | |
| 64 | + private String locationCode; | |
| 65 | + | |
| 66 | + @Schema(description = "库区名称", example = "库区A") | |
| 67 | + private String locationName; | |
| 68 | + | |
| 69 | + @Schema(description = "库位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 70 | + private Long areaId; | |
| 71 | + | |
| 72 | + @Schema(description = "库位编码", example = "AREA001") | |
| 73 | + private String areaCode; | |
| 74 | + | |
| 75 | + @Schema(description = "库位名称", example = "库位A") | |
| 76 | + private String areaName; | |
| 77 | + | |
| 78 | + @Schema(description = "备注", example = "备注") | |
| 79 | + private String remark; | |
| 80 | + | |
| 81 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 82 | + private LocalDateTime createTime; | |
| 83 | + | |
| 84 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/vo/detail/MesWmReturnSalesDetailSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.detail; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import jakarta.validation.constraints.DecimalMin; | |
| 5 | +import jakarta.validation.constraints.NotNull; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import java.math.BigDecimal; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 管理后台 - MES 销售退货相关 | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + */ | |
| 15 | +@Schema(description = "管理后台 - MES 销售退货明细新增/修改 Request VO") | |
| 16 | +@Data | |
| 17 | +public class MesWmReturnSalesDetailSaveReqVO { | |
| 18 | + | |
| 19 | + @Schema(description = "明细ID", example = "1") | |
| 20 | + private Long id; | |
| 21 | + | |
| 22 | + @Schema(description = "退货单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 23 | + @NotNull(message = "退货单ID不能为空") | |
| 24 | + private Long returnId; | |
| 25 | + | |
| 26 | + @Schema(description = "行ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 27 | + @NotNull(message = "行ID不能为空") | |
| 28 | + private Long lineId; | |
| 29 | + | |
| 30 | + @Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 31 | + @NotNull(message = "物料ID不能为空") | |
| 32 | + private Long itemId; | |
| 33 | + | |
| 34 | + @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") | |
| 35 | + @NotNull(message = "数量不能为空") | |
| 36 | + @DecimalMin(value = "0", inclusive = false, message = "数量必须大于 0") | |
| 37 | + private BigDecimal quantity; | |
| 38 | + | |
| 39 | + @Schema(description = "批次ID", example = "1") | |
| 40 | + private Long batchId; | |
| 41 | + | |
| 42 | + @Schema(description = "仓库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 43 | + @NotNull(message = "仓库ID不能为空") | |
| 44 | + private Long warehouseId; | |
| 45 | + | |
| 46 | + @Schema(description = "库区ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 47 | + @NotNull(message = "库区ID不能为空") | |
| 48 | + private Long locationId; | |
| 49 | + | |
| 50 | + @Schema(description = "库位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 51 | + @NotNull(message = "库位ID不能为空") | |
| 52 | + private Long areaId; | |
| 53 | + | |
| 54 | + @Schema(description = "备注", example = "备注") | |
| 55 | + private String remark; | |
| 56 | + | |
| 57 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/vo/line/MesWmReturnSalesLinePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.line; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 管理后台 - MES 销售退货相关 | |
| 10 | + * | |
| 11 | + * @author 芋道源码 | |
| 12 | + */ | |
| 13 | +@Schema(description = "管理后台 - MES 销售退货单行分页 Request VO") | |
| 14 | +@Data | |
| 15 | +@EqualsAndHashCode(callSuper = true) | |
| 16 | +public class MesWmReturnSalesLinePageReqVO extends PageParam { | |
| 17 | + | |
| 18 | + @Schema(description = "退货单ID", example = "1") | |
| 19 | + private Long returnId; | |
| 20 | + | |
| 21 | + @Schema(description = "物料ID", example = "1") | |
| 22 | + private Long itemId; | |
| 23 | + | |
| 24 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/vo/line/MesWmReturnSalesLineRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.line; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import java.math.BigDecimal; | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 管理后台 - MES 销售退货相关 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@Schema(description = "管理后台 - MES 销售退货单行 Response VO") | |
| 15 | +@Data | |
| 16 | +public class MesWmReturnSalesLineRespVO { | |
| 17 | + | |
| 18 | + @Schema(description = "行ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 19 | + private Long id; | |
| 20 | + | |
| 21 | + @Schema(description = "退货单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 22 | + private Long returnId; | |
| 23 | + | |
| 24 | + @Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 25 | + private Long itemId; | |
| 26 | + | |
| 27 | + @Schema(description = "物料编码", example = "M001") | |
| 28 | + private String itemCode; | |
| 29 | + | |
| 30 | + @Schema(description = "物料名称", example = "物料A") | |
| 31 | + private String itemName; | |
| 32 | + | |
| 33 | + @Schema(description = "物料规格", example = "100*200") | |
| 34 | + private String itemSpecification; | |
| 35 | + | |
| 36 | + @Schema(description = "计量单位", example = "个") | |
| 37 | + private String itemUnit; | |
| 38 | + | |
| 39 | + @Schema(description = "退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") | |
| 40 | + private BigDecimal quantityReturned; | |
| 41 | + | |
| 42 | + @Schema(description = "批次ID", example = "1") | |
| 43 | + private Long batchId; | |
| 44 | + | |
| 45 | + @Schema(description = "批次号", example = "B001") | |
| 46 | + private String batchCode; | |
| 47 | + | |
| 48 | + @Schema(description = "质量状态", example = "合格") | |
| 49 | + private String qualityStatus; | |
| 50 | + | |
| 51 | + @Schema(description = "备注", example = "备注") | |
| 52 | + private String remark; | |
| 53 | + | |
| 54 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 55 | + private LocalDateTime createTime; | |
| 56 | + | |
| 57 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/returnsales/vo/line/MesWmReturnSalesLineSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.line; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import jakarta.validation.constraints.DecimalMin; | |
| 5 | +import jakarta.validation.constraints.NotNull; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import java.math.BigDecimal; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 管理后台 - MES 销售退货相关 | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + */ | |
| 15 | +@Schema(description = "管理后台 - MES 销售退货单行新增/修改 Request VO") | |
| 16 | +@Data | |
| 17 | +public class MesWmReturnSalesLineSaveReqVO { | |
| 18 | + | |
| 19 | + @Schema(description = "行ID", example = "1") | |
| 20 | + private Long id; | |
| 21 | + | |
| 22 | + @Schema(description = "退货单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 23 | + @NotNull(message = "退货单ID不能为空") | |
| 24 | + private Long returnId; | |
| 25 | + | |
| 26 | + @Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 27 | + @NotNull(message = "物料ID不能为空") | |
| 28 | + private Long itemId; | |
| 29 | + | |
| 30 | + @Schema(description = "退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") | |
| 31 | + @NotNull(message = "退货数量不能为空") | |
| 32 | + @DecimalMin(value = "0", inclusive = false, message = "退货数量必须大于 0") | |
| 33 | + private BigDecimal quantityReturned; | |
| 34 | + | |
| 35 | + @Schema(description = "批次ID", example = "1") | |
| 36 | + private Long batchId; | |
| 37 | + | |
| 38 | + @Schema(description = "质量状态", example = "合格") | |
| 39 | + private String qualityStatus; | |
| 40 | + | |
| 41 | + @Schema(description = "备注", example = "备注") | |
| 42 | + private String remark; | |
| 43 | + | |
| 44 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/returnsales/MesWmReturnSalesDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.client.MesMdClientDO; | |
| 5 | +import cn.iocoder.yudao.module.mes.enums.wm.MesWmReturnSalesStatusEnum; | |
| 6 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 8 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 9 | +import lombok.*; | |
| 10 | + | |
| 11 | +import java.time.LocalDateTime; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + * MES 销售退货单 DO | |
| 17 | + */ | |
| 18 | +@TableName("mes_wm_return_sales") | |
| 19 | +@KeySequence("mes_wm_return_sales_seq") | |
| 20 | +@Data | |
| 21 | +@EqualsAndHashCode(callSuper = true) | |
| 22 | +@ToString(callSuper = true) | |
| 23 | +@Builder | |
| 24 | +@NoArgsConstructor | |
| 25 | +@AllArgsConstructor | |
| 26 | +public class MesWmReturnSalesDO extends BaseDO { | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 编号 | |
| 30 | + */ | |
| 31 | + @TableId | |
| 32 | + private Long id; | |
| 33 | + /** | |
| 34 | + * 退货单编号 | |
| 35 | + */ | |
| 36 | + private String code; | |
| 37 | + /** | |
| 38 | + * 退货单名称 | |
| 39 | + */ | |
| 40 | + private String name; | |
| 41 | + /** | |
| 42 | + * 销售订单编号 | |
| 43 | + */ | |
| 44 | + private String salesOrderCode; | |
| 45 | + // TODO @AI:这个前端界面必填;注意 save vo(validator)、前端界面,以及 service 校验 | |
| 46 | + /** | |
| 47 | + * 客户 ID | |
| 48 | + * | |
| 49 | + * 关联 {@link MesMdClientDO#getId()} | |
| 50 | + */ | |
| 51 | + private Long clientId; | |
| 52 | + // TODO @AI:这个前端界面必填;注意 save vo(validator)、前端界面 | |
| 53 | + /** | |
| 54 | + * 退货日期 | |
| 55 | + */ | |
| 56 | + private LocalDateTime returnDate; | |
| 57 | + // TODO @AI:这个前端界面必填;注意 save vo(validator)、前端界面 | |
| 58 | + /** | |
| 59 | + * 退货原因 | |
| 60 | + */ | |
| 61 | + private String returnReason; | |
| 62 | + /** | |
| 63 | + * 状态 | |
| 64 | + * | |
| 65 | + * 枚举 {@link MesWmReturnSalesStatusEnum} | |
| 66 | + */ | |
| 67 | + private Integer status; | |
| 68 | + /** | |
| 69 | + * 备注 | |
| 70 | + */ | |
| 71 | + private String remark; | |
| 72 | + | |
| 73 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/returnsales/MesWmReturnSalesDetailDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; | |
| 5 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseAreaDO; | |
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseDO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseLocationDO; | |
| 8 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 9 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 10 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 11 | +import lombok.*; | |
| 12 | + | |
| 13 | +import java.math.BigDecimal; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * | |
| 17 | + * @author 芋道源码 | |
| 18 | + * MES 销售退货明细 DO | |
| 19 | + */ | |
| 20 | +@TableName("mes_wm_return_sales_detail") | |
| 21 | +@KeySequence("mes_wm_return_sales_detail_seq") | |
| 22 | +@Data | |
| 23 | +@EqualsAndHashCode(callSuper = true) | |
| 24 | +@ToString(callSuper = true) | |
| 25 | +@Builder | |
| 26 | +@NoArgsConstructor | |
| 27 | +@AllArgsConstructor | |
| 28 | +public class MesWmReturnSalesDetailDO extends BaseDO { | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 编号 | |
| 32 | + */ | |
| 33 | + @TableId | |
| 34 | + private Long id; | |
| 35 | + // TODO @AI:必须传递;并且要在 save vo(validator)中校验;前端界面必填;service 校验存在 | |
| 36 | + /** | |
| 37 | + * 退货单 ID | |
| 38 | + * | |
| 39 | + * 关联 {@link MesWmReturnSalesDO#getId()} | |
| 40 | + */ | |
| 41 | + private Long returnId; | |
| 42 | + /** | |
| 43 | + * 行 ID | |
| 44 | + * | |
| 45 | + * 关联 {@link MesWmReturnSalesLineDO#getId()} | |
| 46 | + */ | |
| 47 | + private Long lineId; | |
| 48 | + // TODO @AI:必须传递;并且要在 save vo(validator)中校验;前端界面必填;service 校验存在 | |
| 49 | + /** | |
| 50 | + * 物料 ID | |
| 51 | + * | |
| 52 | + * 关联 {@link MesMdItemDO#getId()} | |
| 53 | + */ | |
| 54 | + private Long itemId; | |
| 55 | + // TODO @AI:必须传递;并且要在 save vo(validator)中校验;前端界面必填; | |
| 56 | + /** | |
| 57 | + * 数量 | |
| 58 | + */ | |
| 59 | + private BigDecimal quantity; | |
| 60 | + /** | |
| 61 | + * 批次 ID | |
| 62 | + */ | |
| 63 | + private Long batchId; | |
| 64 | + // TODO @AI:必须传递;并且要在 save vo(validator)中校验;前端界面必填;service 校验存在 | |
| 65 | + /** | |
| 66 | + * 仓库 ID | |
| 67 | + * | |
| 68 | + * 关联 {@link MesWmWarehouseDO#getId()} | |
| 69 | + */ | |
| 70 | + private Long warehouseId; | |
| 71 | + /** | |
| 72 | + * 库区 ID | |
| 73 | + * | |
| 74 | + * 关联 {@link MesWmWarehouseLocationDO#getId()} | |
| 75 | + */ | |
| 76 | + private Long locationId; | |
| 77 | + /** | |
| 78 | + * 库位 ID | |
| 79 | + * | |
| 80 | + * 关联 {@link MesWmWarehouseAreaDO#getId()} | |
| 81 | + */ | |
| 82 | + private Long areaId; | |
| 83 | + /** | |
| 84 | + * 备注 | |
| 85 | + */ | |
| 86 | + private String remark; | |
| 87 | + | |
| 88 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/returnsales/MesWmReturnSalesLineDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; | |
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | +import lombok.*; | |
| 9 | + | |
| 10 | +import java.math.BigDecimal; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + * MES 销售退货单行 DO | |
| 16 | + */ | |
| 17 | +@TableName("mes_wm_return_sales_line") | |
| 18 | +@KeySequence("mes_wm_return_sales_line_seq") | |
| 19 | +@Data | |
| 20 | +@EqualsAndHashCode(callSuper = true) | |
| 21 | +@ToString(callSuper = true) | |
| 22 | +@Builder | |
| 23 | +@NoArgsConstructor | |
| 24 | +@AllArgsConstructor | |
| 25 | +public class MesWmReturnSalesLineDO extends BaseDO { | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 编号 | |
| 29 | + */ | |
| 30 | + @TableId | |
| 31 | + private Long id; | |
| 32 | + /** | |
| 33 | + * 退货单 ID | |
| 34 | + * | |
| 35 | + * 关联 {@link MesWmReturnSalesDO#getId()} | |
| 36 | + */ | |
| 37 | + private Long returnId; | |
| 38 | + /** | |
| 39 | + * 物料 ID | |
| 40 | + * | |
| 41 | + * 关联 {@link MesMdItemDO#getId()} | |
| 42 | + */ | |
| 43 | + private Long itemId; | |
| 44 | + // TODO @AI:这个改成 quantity;简化(听我的) | |
| 45 | + /** | |
| 46 | + * 退货数量 | |
| 47 | + */ | |
| 48 | + private BigDecimal quantityReturned; | |
| 49 | + /** | |
| 50 | + * 批次 ID | |
| 51 | + */ | |
| 52 | + private Long batchId; | |
| 53 | + // TODO @AI:需要 @下对应的枚举类,方便理解; | |
| 54 | + /** | |
| 55 | + * 质量状态 | |
| 56 | + */ | |
| 57 | + private String qualityStatus; | |
| 58 | + /** | |
| 59 | + * 备注 | |
| 60 | + */ | |
| 61 | + private String remark; | |
| 62 | + | |
| 63 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/returnsales/MesWmReturnSalesDetailMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.detail.MesWmReturnSalesDetailPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesDetailDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + * MES 销售退货明细 Mapper | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface MesWmReturnSalesDetailMapper extends BaseMapperX<MesWmReturnSalesDetailDO> { | |
| 19 | + | |
| 20 | + default PageResult<MesWmReturnSalesDetailDO> selectPage(MesWmReturnSalesDetailPageReqVO reqVO) { | |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesWmReturnSalesDetailDO>() | |
| 22 | + .eqIfPresent(MesWmReturnSalesDetailDO::getReturnId, reqVO.getReturnId()) | |
| 23 | + .eqIfPresent(MesWmReturnSalesDetailDO::getLineId, reqVO.getLineId()) | |
| 24 | + .eqIfPresent(MesWmReturnSalesDetailDO::getItemId, reqVO.getItemId()) | |
| 25 | + .orderByDesc(MesWmReturnSalesDetailDO::getId)); | |
| 26 | + } | |
| 27 | + | |
| 28 | + default List<MesWmReturnSalesDetailDO> selectListByReturnId(Long returnId) { | |
| 29 | + return selectList(new LambdaQueryWrapperX<MesWmReturnSalesDetailDO>() | |
| 30 | + .eq(MesWmReturnSalesDetailDO::getReturnId, returnId)); | |
| 31 | + } | |
| 32 | + | |
| 33 | + default List<MesWmReturnSalesDetailDO> selectListByLineId(Long lineId) { | |
| 34 | + return selectList(new LambdaQueryWrapperX<MesWmReturnSalesDetailDO>() | |
| 35 | + .eq(MesWmReturnSalesDetailDO::getLineId, lineId)); | |
| 36 | + } | |
| 37 | + | |
| 38 | + default void deleteByReturnId(Long returnId) { | |
| 39 | + delete(new LambdaQueryWrapperX<MesWmReturnSalesDetailDO>() | |
| 40 | + .eq(MesWmReturnSalesDetailDO::getReturnId, returnId)); | |
| 41 | + } | |
| 42 | + | |
| 43 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/returnsales/MesWmReturnSalesLineMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.line.MesWmReturnSalesLinePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesLineDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + * MES 销售退货单行 Mapper | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface MesWmReturnSalesLineMapper extends BaseMapperX<MesWmReturnSalesLineDO> { | |
| 19 | + | |
| 20 | + default PageResult<MesWmReturnSalesLineDO> selectPage(MesWmReturnSalesLinePageReqVO reqVO) { | |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesWmReturnSalesLineDO>() | |
| 22 | + .eqIfPresent(MesWmReturnSalesLineDO::getReturnId, reqVO.getReturnId()) | |
| 23 | + .eqIfPresent(MesWmReturnSalesLineDO::getItemId, reqVO.getItemId()) | |
| 24 | + .orderByDesc(MesWmReturnSalesLineDO::getId)); | |
| 25 | + } | |
| 26 | + | |
| 27 | + default List<MesWmReturnSalesLineDO> selectListByReturnId(Long returnId) { | |
| 28 | + return selectList(new LambdaQueryWrapperX<MesWmReturnSalesLineDO>() | |
| 29 | + .eq(MesWmReturnSalesLineDO::getReturnId, returnId)); | |
| 30 | + } | |
| 31 | + | |
| 32 | + default void deleteByReturnId(Long returnId) { | |
| 33 | + delete(new LambdaQueryWrapperX<MesWmReturnSalesLineDO>() | |
| 34 | + .eq(MesWmReturnSalesLineDO::getReturnId, returnId)); | |
| 35 | + } | |
| 36 | + | |
| 37 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/returnsales/MesWmReturnSalesMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.MesWmReturnSalesPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + * MES 销售退货单 Mapper | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface MesWmReturnSalesMapper extends BaseMapperX<MesWmReturnSalesDO> { | |
| 17 | + | |
| 18 | + default PageResult<MesWmReturnSalesDO> selectPage(MesWmReturnSalesPageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesWmReturnSalesDO>() | |
| 20 | + .likeIfPresent(MesWmReturnSalesDO::getCode, reqVO.getCode()) | |
| 21 | + .likeIfPresent(MesWmReturnSalesDO::getName, reqVO.getName()) | |
| 22 | + .likeIfPresent(MesWmReturnSalesDO::getSalesOrderCode, reqVO.getSalesOrderCode()) | |
| 23 | + .eqIfPresent(MesWmReturnSalesDO::getClientId, reqVO.getClientId()) | |
| 24 | + .eqIfPresent(MesWmReturnSalesDO::getStatus, reqVO.getStatus()) | |
| 25 | + .betweenIfPresent(MesWmReturnSalesDO::getReturnDate, reqVO.getReturnDate()) | |
| 26 | + .orderByDesc(MesWmReturnSalesDO::getId)); | |
| 27 | + } | |
| 28 | + | |
| 29 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java
| ... | ... | @@ -413,4 +413,16 @@ public interface ErrorCodeConstants { |
| 413 | 413 | ErrorCode WM_PRODUCT_RECPT_LINE_NOT_EXISTS = new ErrorCode(1_040_712_100, "产品收货单行不存在"); |
| 414 | 414 | ErrorCode WM_PRODUCT_RECPT_DETAIL_NOT_EXISTS = new ErrorCode(1_040_712_200, "产品收货明细不存在"); |
| 415 | 415 | |
| 416 | + // ========== MES 仓库管理-销售退货单(1-040-713-000) ========== | |
| 417 | + ErrorCode WM_RETURN_SALES_NOT_EXISTS = new ErrorCode(1_040_713_000, "销售退货单不存在"); | |
| 418 | + ErrorCode WM_RETURN_SALES_CODE_DUPLICATE = new ErrorCode(1_040_713_001, "销售退货单编码已存在"); | |
| 419 | + ErrorCode WM_RETURN_SALES_STATUS_NOT_PREPARE = new ErrorCode(1_040_713_002, "只有草稿状态才允许此操作"); | |
| 420 | + ErrorCode WM_RETURN_SALES_STATUS_NOT_APPROVING = new ErrorCode(1_040_713_003, "只有待执行状态才允许执行退货"); | |
| 421 | + ErrorCode WM_RETURN_SALES_STATUS_NOT_APPROVED = new ErrorCode(1_040_713_004, "只有待上架状态才允许执行上架"); | |
| 422 | + ErrorCode WM_RETURN_SALES_NO_LINE = new ErrorCode(1_040_713_005, "销售退货单至少需要一条行数据"); | |
| 423 | + ErrorCode WM_RETURN_SALES_DETAIL_QUANTITY_MISMATCH = new ErrorCode(1_040_713_006, "销售退货单行数量与明细数量不一致"); | |
| 424 | + ErrorCode WM_RETURN_SALES_CANCEL_NOT_ALLOWED = new ErrorCode(1_040_713_007, "销售退货单已完成或已取消,无法取消"); | |
| 425 | + ErrorCode WM_RETURN_SALES_LINE_NOT_EXISTS = new ErrorCode(1_040_713_100, "销售退货单行不存在"); | |
| 426 | + ErrorCode WM_RETURN_SALES_DETAIL_NOT_EXISTS = new ErrorCode(1_040_713_200, "销售退货单明细不存在"); | |
| 427 | + | |
| 416 | 428 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/wm/MesWmReturnSalesStatusEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.enums.wm; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.core.ArrayValuable; | |
| 4 | +import cn.iocoder.yudao.module.mes.enums.MesOrderStatusConstants; | |
| 5 | +import lombok.AllArgsConstructor; | |
| 6 | +import lombok.Getter; | |
| 7 | + | |
| 8 | +import java.util.Arrays; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * MES 销售退货单状态枚举 | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + */ | |
| 15 | +@Getter | |
| 16 | +@AllArgsConstructor | |
| 17 | +public enum MesWmReturnSalesStatusEnum implements ArrayValuable<Integer> { | |
| 18 | + | |
| 19 | + // TODO @AI:参考 {@link MesWmProductReceiptStatusEnum},增加注释,说明每个状态对应的业务含义,以及对应的方法(如果有的话)。方便开发人员理解。 | |
| 20 | + /** | |
| 21 | + * 草稿 | |
| 22 | + */ | |
| 23 | + PREPARE(MesOrderStatusConstants.PREPARE, "草稿"), | |
| 24 | + /** | |
| 25 | + * 待执行 | |
| 26 | + */ | |
| 27 | + APPROVING(MesOrderStatusConstants.APPROVING, "待执行"), | |
| 28 | + /** | |
| 29 | + * 待上架 | |
| 30 | + */ | |
| 31 | + APPROVED(MesOrderStatusConstants.APPROVED, "待上架"), | |
| 32 | + /** | |
| 33 | + * 已完成 | |
| 34 | + */ | |
| 35 | + FINISHED(MesOrderStatusConstants.FINISHED, "已完成"), | |
| 36 | + /** | |
| 37 | + * 已取消 | |
| 38 | + */ | |
| 39 | + CANCELED(MesOrderStatusConstants.CANCELLED, "已取消"); | |
| 40 | + | |
| 41 | + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesWmReturnSalesStatusEnum::getStatus).toArray(Integer[]::new); | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 状态值 | |
| 45 | + */ | |
| 46 | + private final Integer status; | |
| 47 | + /** | |
| 48 | + * 状态名 | |
| 49 | + */ | |
| 50 | + private final String name; | |
| 51 | + | |
| 52 | + @Override | |
| 53 | + public Integer[] array() { | |
| 54 | + return ARRAYS; | |
| 55 | + } | |
| 56 | + | |
| 57 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesDetailService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.detail.MesWmReturnSalesDetailSaveReqVO; | |
| 4 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesDetailDO; | |
| 5 | +import jakarta.validation.Valid; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * | |
| 11 | + * @author 芋道源码 | |
| 12 | + * MES 销售退货明细 Service 接口 | |
| 13 | + */ | |
| 14 | +public interface MesWmReturnSalesDetailService { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 创建销售退货明细 | |
| 18 | + * | |
| 19 | + * @param createReqVO 创建信息 | |
| 20 | + * @return 编号 | |
| 21 | + */ | |
| 22 | + Long createReturnSalesDetail(@Valid MesWmReturnSalesDetailSaveReqVO createReqVO); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 更新销售退货明细 | |
| 26 | + * | |
| 27 | + * @param updateReqVO 更新信息 | |
| 28 | + */ | |
| 29 | + void updateReturnSalesDetail(@Valid MesWmReturnSalesDetailSaveReqVO updateReqVO); | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 删除销售退货明细 | |
| 33 | + * | |
| 34 | + * @param id 编号 | |
| 35 | + */ | |
| 36 | + void deleteReturnSalesDetail(Long id); | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 获得销售退货明细 | |
| 40 | + * | |
| 41 | + * @param id 编号 | |
| 42 | + * @return 销售退货明细 | |
| 43 | + */ | |
| 44 | + MesWmReturnSalesDetailDO getReturnSalesDetail(Long id); | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 根据行ID获取明细列表 | |
| 48 | + * | |
| 49 | + * @param lineId 行ID | |
| 50 | + * @return 明细列表 | |
| 51 | + */ | |
| 52 | + List<MesWmReturnSalesDetailDO> getReturnSalesDetailListByLineId(Long lineId); | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 根据退货单ID获取明细列表 | |
| 56 | + * | |
| 57 | + * @param returnId 退货单ID | |
| 58 | + * @return 明细列表 | |
| 59 | + */ | |
| 60 | + List<MesWmReturnSalesDetailDO> getReturnSalesDetailListByReturnId(Long returnId); | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 根据退货单ID删除明细 | |
| 64 | + * | |
| 65 | + * @param returnId 退货单ID | |
| 66 | + */ | |
| 67 | + void deleteReturnSalesDetailByReturnId(Long returnId); | |
| 68 | + | |
| 69 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesDetailServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.detail.MesWmReturnSalesDetailSaveReqVO; | |
| 5 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesDetailDO; | |
| 6 | +import cn.iocoder.yudao.module.mes.dal.mysql.wm.returnsales.MesWmReturnSalesDetailMapper; | |
| 7 | +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | |
| 8 | +import jakarta.annotation.Resource; | |
| 9 | +import org.springframework.context.annotation.Lazy; | |
| 10 | +import org.springframework.stereotype.Service; | |
| 11 | +import org.springframework.validation.annotation.Validated; | |
| 12 | + | |
| 13 | +import java.util.List; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 16 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_RETURN_SALES_DETAIL_NOT_EXISTS; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * | |
| 20 | + * @author 芋道源码 | |
| 21 | + * MES 销售退货明细 Service 实现类 | |
| 22 | + */ | |
| 23 | +@Service | |
| 24 | +@Validated | |
| 25 | +public class MesWmReturnSalesDetailServiceImpl implements MesWmReturnSalesDetailService { | |
| 26 | + | |
| 27 | + @Resource | |
| 28 | + private MesWmReturnSalesDetailMapper returnSalesDetailMapper; | |
| 29 | + | |
| 30 | + @Resource | |
| 31 | + @Lazy | |
| 32 | + private MesWmReturnSalesLineService returnSalesLineService; | |
| 33 | + | |
| 34 | + @Resource | |
| 35 | + private MesMdItemService itemService; | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public Long createReturnSalesDetail(MesWmReturnSalesDetailSaveReqVO createReqVO) { | |
| 39 | + // 校验父数据存在 | |
| 40 | + returnSalesLineService.validateReturnSalesLineExists(createReqVO.getLineId()); | |
| 41 | + // 校验物料存在 | |
| 42 | + itemService.validateItemExists(createReqVO.getItemId()); | |
| 43 | + | |
| 44 | + // 插入 | |
| 45 | + MesWmReturnSalesDetailDO detail = BeanUtils.toBean(createReqVO, MesWmReturnSalesDetailDO.class); | |
| 46 | + returnSalesDetailMapper.insert(detail); | |
| 47 | + return detail.getId(); | |
| 48 | + } | |
| 49 | + | |
| 50 | + @Override | |
| 51 | + public void updateReturnSalesDetail(MesWmReturnSalesDetailSaveReqVO updateReqVO) { | |
| 52 | + // 校验存在 | |
| 53 | + validateReturnSalesDetailExists(updateReqVO.getId()); | |
| 54 | + // 校验父数据存在 | |
| 55 | + returnSalesLineService.validateReturnSalesLineExists(updateReqVO.getLineId()); | |
| 56 | + // 校验物料存在 | |
| 57 | + itemService.validateItemExists(updateReqVO.getItemId()); | |
| 58 | + | |
| 59 | + // 更新 | |
| 60 | + MesWmReturnSalesDetailDO updateObj = BeanUtils.toBean(updateReqVO, MesWmReturnSalesDetailDO.class); | |
| 61 | + returnSalesDetailMapper.updateById(updateObj); | |
| 62 | + } | |
| 63 | + | |
| 64 | + @Override | |
| 65 | + public void deleteReturnSalesDetail(Long id) { | |
| 66 | + // 校验存在 | |
| 67 | + validateReturnSalesDetailExists(id); | |
| 68 | + // 删除 | |
| 69 | + returnSalesDetailMapper.deleteById(id); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @Override | |
| 73 | + public MesWmReturnSalesDetailDO getReturnSalesDetail(Long id) { | |
| 74 | + return returnSalesDetailMapper.selectById(id); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Override | |
| 78 | + public List<MesWmReturnSalesDetailDO> getReturnSalesDetailListByLineId(Long lineId) { | |
| 79 | + return returnSalesDetailMapper.selectListByLineId(lineId); | |
| 80 | + } | |
| 81 | + | |
| 82 | + @Override | |
| 83 | + public List<MesWmReturnSalesDetailDO> getReturnSalesDetailListByReturnId(Long returnId) { | |
| 84 | + return returnSalesDetailMapper.selectListByReturnId(returnId); | |
| 85 | + } | |
| 86 | + | |
| 87 | + @Override | |
| 88 | + public void deleteReturnSalesDetailByReturnId(Long returnId) { | |
| 89 | + returnSalesDetailMapper.deleteByReturnId(returnId); | |
| 90 | + } | |
| 91 | + | |
| 92 | + private void validateReturnSalesDetailExists(Long id) { | |
| 93 | + if (returnSalesDetailMapper.selectById(id) == null) { | |
| 94 | + throw exception(WM_RETURN_SALES_DETAIL_NOT_EXISTS); | |
| 95 | + } | |
| 96 | + } | |
| 97 | + | |
| 98 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesLineService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.line.MesWmReturnSalesLinePageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.line.MesWmReturnSalesLineSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesLineDO; | |
| 7 | +import jakarta.validation.Valid; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + * MES 销售退货单行 Service 接口 | |
| 15 | + */ | |
| 16 | +public interface MesWmReturnSalesLineService { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 创建销售退货单行 | |
| 20 | + * | |
| 21 | + * @param createReqVO 创建信息 | |
| 22 | + * @return 编号 | |
| 23 | + */ | |
| 24 | + Long createReturnSalesLine(@Valid MesWmReturnSalesLineSaveReqVO createReqVO); | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 更新销售退货单行 | |
| 28 | + * | |
| 29 | + * @param updateReqVO 更新信息 | |
| 30 | + */ | |
| 31 | + void updateReturnSalesLine(@Valid MesWmReturnSalesLineSaveReqVO updateReqVO); | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 删除销售退货单行 | |
| 35 | + * | |
| 36 | + * @param id 编号 | |
| 37 | + */ | |
| 38 | + void deleteReturnSalesLine(Long id); | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 获得销售退货单行 | |
| 42 | + * | |
| 43 | + * @param id 编号 | |
| 44 | + * @return 销售退货单行 | |
| 45 | + */ | |
| 46 | + MesWmReturnSalesLineDO getReturnSalesLine(Long id); | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * 获得销售退货单行分页 | |
| 50 | + * | |
| 51 | + * @param pageReqVO 分页查询 | |
| 52 | + * @return 销售退货单行分页 | |
| 53 | + */ | |
| 54 | + PageResult<MesWmReturnSalesLineDO> getReturnSalesLinePage(MesWmReturnSalesLinePageReqVO pageReqVO); | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * 根据退货单ID获取行列表 | |
| 58 | + * | |
| 59 | + * @param returnId 退货单ID | |
| 60 | + * @return 行列表 | |
| 61 | + */ | |
| 62 | + List<MesWmReturnSalesLineDO> getReturnSalesLineListByReturnId(Long returnId); | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * 根据退货单ID删除行 | |
| 66 | + * | |
| 67 | + * @param returnId 退货单ID | |
| 68 | + */ | |
| 69 | + void deleteReturnSalesLineByReturnId(Long returnId); | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * 校验销售退货单行是否存在 | |
| 73 | + * | |
| 74 | + * @param id 编号 | |
| 75 | + * @return 销售退货单行 | |
| 76 | + */ | |
| 77 | + MesWmReturnSalesLineDO validateReturnSalesLineExists(Long id); | |
| 78 | + | |
| 79 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesLineServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.line.MesWmReturnSalesLinePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.line.MesWmReturnSalesLineSaveReqVO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesLineDO; | |
| 8 | +import cn.iocoder.yudao.module.mes.dal.mysql.wm.returnsales.MesWmReturnSalesLineMapper; | |
| 9 | +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | |
| 10 | +import jakarta.annotation.Resource; | |
| 11 | +import org.springframework.context.annotation.Lazy; | |
| 12 | +import org.springframework.stereotype.Service; | |
| 13 | +import org.springframework.validation.annotation.Validated; | |
| 14 | + | |
| 15 | +import java.util.List; | |
| 16 | + | |
| 17 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 18 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_RETURN_SALES_LINE_NOT_EXISTS; | |
| 19 | + | |
| 20 | +/** | |
| 21 | + * | |
| 22 | + * @author 芋道源码 | |
| 23 | + * MES 销售退货单行 Service 实现类 | |
| 24 | + */ | |
| 25 | +@Service | |
| 26 | +@Validated | |
| 27 | +public class MesWmReturnSalesLineServiceImpl implements MesWmReturnSalesLineService { | |
| 28 | + | |
| 29 | + @Resource | |
| 30 | + private MesWmReturnSalesLineMapper returnSalesLineMapper; | |
| 31 | + | |
| 32 | + @Resource | |
| 33 | + @Lazy | |
| 34 | + private MesWmReturnSalesService returnSalesService; | |
| 35 | + @Resource | |
| 36 | + private MesMdItemService itemService; | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + public Long createReturnSalesLine(MesWmReturnSalesLineSaveReqVO createReqVO) { | |
| 40 | + // 校验父数据存在 | |
| 41 | + returnSalesService.validateReturnSalesExists(createReqVO.getReturnId()); | |
| 42 | + // 校验物料存在 | |
| 43 | + itemService.validateItemExists(createReqVO.getItemId()); | |
| 44 | + // TODO @AI:请选择批次;假设物料开启了批次号 | |
| 45 | + | |
| 46 | + // 插入 | |
| 47 | + MesWmReturnSalesLineDO line = BeanUtils.toBean(createReqVO, MesWmReturnSalesLineDO.class); | |
| 48 | + returnSalesLineMapper.insert(line); | |
| 49 | + return line.getId(); | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Override | |
| 53 | + public void updateReturnSalesLine(MesWmReturnSalesLineSaveReqVO updateReqVO) { | |
| 54 | + // 校验存在 | |
| 55 | + validateReturnSalesLineExists(updateReqVO.getId()); | |
| 56 | + // 校验父数据存在 | |
| 57 | + returnSalesService.validateReturnSalesExists(updateReqVO.getReturnId()); | |
| 58 | + // 校验物料存在 | |
| 59 | + itemService.validateItemExists(updateReqVO.getItemId()); | |
| 60 | + // TODO @AI:请选择批次;假设物料开启了批次号 | |
| 61 | + | |
| 62 | + // 更新 | |
| 63 | + MesWmReturnSalesLineDO updateObj = BeanUtils.toBean(updateReqVO, MesWmReturnSalesLineDO.class); | |
| 64 | + returnSalesLineMapper.updateById(updateObj); | |
| 65 | + } | |
| 66 | + | |
| 67 | + @Override | |
| 68 | + public void deleteReturnSalesLine(Long id) { | |
| 69 | + // 校验存在 | |
| 70 | + validateReturnSalesLineExists(id); | |
| 71 | + // 删除 | |
| 72 | + returnSalesLineMapper.deleteById(id); | |
| 73 | + } | |
| 74 | + | |
| 75 | + @Override | |
| 76 | + public MesWmReturnSalesLineDO getReturnSalesLine(Long id) { | |
| 77 | + return returnSalesLineMapper.selectById(id); | |
| 78 | + } | |
| 79 | + | |
| 80 | + @Override | |
| 81 | + public PageResult<MesWmReturnSalesLineDO> getReturnSalesLinePage(MesWmReturnSalesLinePageReqVO pageReqVO) { | |
| 82 | + return returnSalesLineMapper.selectPage(pageReqVO); | |
| 83 | + } | |
| 84 | + | |
| 85 | + @Override | |
| 86 | + public List<MesWmReturnSalesLineDO> getReturnSalesLineListByReturnId(Long returnId) { | |
| 87 | + return returnSalesLineMapper.selectListByReturnId(returnId); | |
| 88 | + } | |
| 89 | + | |
| 90 | + @Override | |
| 91 | + public void deleteReturnSalesLineByReturnId(Long returnId) { | |
| 92 | + returnSalesLineMapper.deleteByReturnId(returnId); | |
| 93 | + } | |
| 94 | + | |
| 95 | + @Override | |
| 96 | + public MesWmReturnSalesLineDO validateReturnSalesLineExists(Long id) { | |
| 97 | + MesWmReturnSalesLineDO line = returnSalesLineMapper.selectById(id); | |
| 98 | + if (line == null) { | |
| 99 | + throw exception(WM_RETURN_SALES_LINE_NOT_EXISTS); | |
| 100 | + } | |
| 101 | + return line; | |
| 102 | + } | |
| 103 | + | |
| 104 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.MesWmReturnSalesPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.MesWmReturnSalesSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesDO; | |
| 7 | +import jakarta.validation.Valid; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * | |
| 11 | + * @author 芋道源码 | |
| 12 | + * MES 销售退货单 Service 接口 | |
| 13 | + */ | |
| 14 | +public interface MesWmReturnSalesService { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 创建销售退货单 | |
| 18 | + * | |
| 19 | + * @param createReqVO 创建信息 | |
| 20 | + * @return 编号 | |
| 21 | + */ | |
| 22 | + Long createReturnSales(@Valid MesWmReturnSalesSaveReqVO createReqVO); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 修改销售退货单 | |
| 26 | + * | |
| 27 | + * @param updateReqVO 修改信息 | |
| 28 | + */ | |
| 29 | + void updateReturnSales(@Valid MesWmReturnSalesSaveReqVO updateReqVO); | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 删除销售退货单 | |
| 33 | + * | |
| 34 | + * @param id 编号 | |
| 35 | + */ | |
| 36 | + void deleteReturnSales(Long id); | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 获得销售退货单 | |
| 40 | + * | |
| 41 | + * @param id 编号 | |
| 42 | + * @return 销售退货单 | |
| 43 | + */ | |
| 44 | + MesWmReturnSalesDO getReturnSales(Long id); | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 获得销售退货单分页 | |
| 48 | + * | |
| 49 | + * @param pageReqVO 分页参数 | |
| 50 | + * @return 销售退货单分页 | |
| 51 | + */ | |
| 52 | + PageResult<MesWmReturnSalesDO> getReturnSalesPage(MesWmReturnSalesPageReqVO pageReqVO); | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 校验销售退货单是否存在 | |
| 56 | + * | |
| 57 | + * @param id 编号 | |
| 58 | + * @return 销售退货单 | |
| 59 | + */ | |
| 60 | + MesWmReturnSalesDO validateReturnSalesExists(Long id); | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 提交销售退货单(草稿 -> 待执行) | |
| 64 | + * | |
| 65 | + * @param id 编号 | |
| 66 | + */ | |
| 67 | + void submitReturnSales(Long id); | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * 执行退货(待执行 -> 待上架) | |
| 71 | + * | |
| 72 | + * @param id 编号 | |
| 73 | + */ | |
| 74 | + void executeReturnSales(Long id); | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * 执行上架(待上架 -> 已完成),更新库存台账 | |
| 78 | + * | |
| 79 | + * @param id 编号 | |
| 80 | + */ | |
| 81 | + void stockReturnSales(Long id); | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * 取消销售退货单(任意非已完成/已取消状态 -> 已取消) | |
| 85 | + * | |
| 86 | + * @param id 编号 | |
| 87 | + */ | |
| 88 | + void cancelReturnSales(Long id); | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * 校验销售退货单的数量:每行明细数量之和是否等于行退货数量 | |
| 92 | + * | |
| 93 | + * @param id 编号 | |
| 94 | + * @return 是否全部一致 | |
| 95 | + */ | |
| 96 | + Boolean checkReturnSalesQuantity(Long id); | |
| 97 | + | |
| 98 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.wm.returnsales; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.hutool.core.util.ObjUtil; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 7 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 8 | +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | |
| 9 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.MesWmReturnSalesPageReqVO; | |
| 10 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.returnsales.vo.MesWmReturnSalesSaveReqVO; | |
| 11 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesDO; | |
| 12 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesDetailDO; | |
| 13 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.returnsales.MesWmReturnSalesLineDO; | |
| 14 | +import cn.iocoder.yudao.module.mes.dal.mysql.wm.returnsales.MesWmReturnSalesMapper; | |
| 15 | +import cn.iocoder.yudao.module.mes.enums.wm.MesWmReturnSalesStatusEnum; | |
| 16 | +import cn.iocoder.yudao.module.mes.service.md.client.MesMdClientService; | |
| 17 | +import jakarta.annotation.Resource; | |
| 18 | +import org.springframework.stereotype.Service; | |
| 19 | +import org.springframework.transaction.annotation.Transactional; | |
| 20 | +import org.springframework.validation.annotation.Validated; | |
| 21 | + | |
| 22 | +import java.math.BigDecimal; | |
| 23 | +import java.util.List; | |
| 24 | + | |
| 25 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 26 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * | |
| 30 | + * @author 芋道源码 | |
| 31 | + * MES 销售退货单 Service 实现类 | |
| 32 | + */ | |
| 33 | +@Service | |
| 34 | +@Validated | |
| 35 | +public class MesWmReturnSalesServiceImpl implements MesWmReturnSalesService { | |
| 36 | + | |
| 37 | + @Resource | |
| 38 | + private MesWmReturnSalesMapper returnSalesMapper; | |
| 39 | + | |
| 40 | + @Resource | |
| 41 | + private MesWmReturnSalesLineService returnSalesLineService; | |
| 42 | + @Resource | |
| 43 | + private MesWmReturnSalesDetailService returnSalesDetailService; | |
| 44 | + @Resource | |
| 45 | + private MesMdClientService clientService; | |
| 46 | + | |
| 47 | + @Override | |
| 48 | + @Transactional(rollbackFor = Exception.class) | |
| 49 | + public Long createReturnSales(MesWmReturnSalesSaveReqVO createReqVO) { | |
| 50 | + // 1. 校验关联数据 | |
| 51 | + clientService.validateClientExists(createReqVO.getClientId()); | |
| 52 | + | |
| 53 | + // 2. 插入主表 | |
| 54 | + MesWmReturnSalesDO returnSales = BeanUtils.toBean(createReqVO, MesWmReturnSalesDO.class); | |
| 55 | + returnSales.setStatus(MesWmReturnSalesStatusEnum.PREPARE.getStatus()); | |
| 56 | + returnSalesMapper.insert(returnSales); | |
| 57 | + return returnSales.getId(); | |
| 58 | + } | |
| 59 | + | |
| 60 | + @Override | |
| 61 | + @Transactional(rollbackFor = Exception.class) | |
| 62 | + public void updateReturnSales(MesWmReturnSalesSaveReqVO updateReqVO) { | |
| 63 | + // 1.1 校验存在 + 准备中状态 | |
| 64 | + validateReturnSalesExistsAndPrepare(updateReqVO.getId()); | |
| 65 | + // 1.2 校验关联数据 | |
| 66 | + clientService.validateClientExists(updateReqVO.getClientId()); | |
| 67 | + | |
| 68 | + // 2. 更新主表 | |
| 69 | + MesWmReturnSalesDO updateObj = BeanUtils.toBean(updateReqVO, MesWmReturnSalesDO.class); | |
| 70 | + returnSalesMapper.updateById(updateObj); | |
| 71 | + } | |
| 72 | + | |
| 73 | + @Override | |
| 74 | + @Transactional(rollbackFor = Exception.class) | |
| 75 | + public void deleteReturnSales(Long id) { | |
| 76 | + // 1. 校验存在 + 准备中状态 | |
| 77 | + validateReturnSalesExistsAndPrepare(id); | |
| 78 | + | |
| 79 | + // 2.1 级联删除明细 | |
| 80 | + returnSalesDetailService.deleteReturnSalesDetailByReturnId(id); | |
| 81 | + // 2.2 级联删除行 | |
| 82 | + returnSalesLineService.deleteReturnSalesLineByReturnId(id); | |
| 83 | + // 2.3 删除主表 | |
| 84 | + returnSalesMapper.deleteById(id); | |
| 85 | + } | |
| 86 | + | |
| 87 | + @Override | |
| 88 | + public MesWmReturnSalesDO getReturnSales(Long id) { | |
| 89 | + return returnSalesMapper.selectById(id); | |
| 90 | + } | |
| 91 | + | |
| 92 | + @Override | |
| 93 | + public PageResult<MesWmReturnSalesDO> getReturnSalesPage(MesWmReturnSalesPageReqVO pageReqVO) { | |
| 94 | + return returnSalesMapper.selectPage(pageReqVO); | |
| 95 | + } | |
| 96 | + | |
| 97 | + @Override | |
| 98 | + @Transactional(rollbackFor = Exception.class) | |
| 99 | + public void submitReturnSales(Long id) { | |
| 100 | + // 校验存在 + 草稿状态 | |
| 101 | + validateReturnSalesExistsAndPrepare(id); | |
| 102 | + // 校验至少有一条行 | |
| 103 | + List<MesWmReturnSalesLineDO> lines = returnSalesLineService.getReturnSalesLineListByReturnId(id); | |
| 104 | + if (CollUtil.isEmpty(lines)) { | |
| 105 | + throw exception(WM_RETURN_SALES_NO_LINE); | |
| 106 | + } | |
| 107 | + | |
| 108 | + // 提交(草稿 -> 待执行) | |
| 109 | + returnSalesMapper.updateById(new MesWmReturnSalesDO() | |
| 110 | + .setId(id).setStatus(MesWmReturnSalesStatusEnum.APPROVING.getStatus())); | |
| 111 | + } | |
| 112 | + | |
| 113 | + @Override | |
| 114 | + @Transactional(rollbackFor = Exception.class) | |
| 115 | + public void executeReturnSales(Long id) { | |
| 116 | + // 校验存在 | |
| 117 | + MesWmReturnSalesDO returnSales = validateReturnSalesExists(id); | |
| 118 | + if (ObjUtil.notEqual(MesWmReturnSalesStatusEnum.APPROVING.getStatus(), returnSales.getStatus())) { | |
| 119 | + throw exception(WM_RETURN_SALES_STATUS_NOT_APPROVING); | |
| 120 | + } | |
| 121 | + // 执行退货(待执行 -> 待上架) | |
| 122 | + returnSalesMapper.updateById(new MesWmReturnSalesDO() | |
| 123 | + .setId(id).setStatus(MesWmReturnSalesStatusEnum.APPROVED.getStatus())); | |
| 124 | + } | |
| 125 | + | |
| 126 | + @Override | |
| 127 | + @Transactional(rollbackFor = Exception.class) | |
| 128 | + public void stockReturnSales(Long id) { | |
| 129 | + // 校验存在 | |
| 130 | + MesWmReturnSalesDO returnSales = validateReturnSalesExists(id); | |
| 131 | + if (ObjUtil.notEqual(MesWmReturnSalesStatusEnum.APPROVED.getStatus(), returnSales.getStatus())) { | |
| 132 | + throw exception(WM_RETURN_SALES_STATUS_NOT_APPROVED); | |
| 133 | + } | |
| 134 | + | |
| 135 | + // 遍历所有明细,更新库存台账(增加库存) | |
| 136 | + // TODO @芋艿:【后续在弄】这里需要库存更新;后面在弄 | |
| 137 | + List<MesWmReturnSalesDetailDO> details = returnSalesDetailService.getReturnSalesDetailListByReturnId(id); | |
| 138 | + for (MesWmReturnSalesDetailDO detail : details) { | |
| 139 | + // materialStockService.increaseStock( | |
| 140 | + // detail.getItemId(), detail.getWarehouseId(), detail.getLocationId(), detail.getAreaId(), | |
| 141 | + // detail.getBatchId(), detail.getQuantity(), null, null, null); | |
| 142 | + } | |
| 143 | + | |
| 144 | + // 更新退货单状态 | |
| 145 | + returnSalesMapper.updateById(new MesWmReturnSalesDO() | |
| 146 | + .setId(id).setStatus(MesWmReturnSalesStatusEnum.FINISHED.getStatus())); | |
| 147 | + } | |
| 148 | + | |
| 149 | + @Override | |
| 150 | + @Transactional(rollbackFor = Exception.class) | |
| 151 | + public void cancelReturnSales(Long id) { | |
| 152 | + // 校验存在 | |
| 153 | + MesWmReturnSalesDO returnSales = validateReturnSalesExists(id); | |
| 154 | + // 已完成和已取消不允许取消 | |
| 155 | + if (ObjectUtils.equalsAny(returnSales.getStatus(), | |
| 156 | + MesWmReturnSalesStatusEnum.FINISHED.getStatus(), | |
| 157 | + MesWmReturnSalesStatusEnum.CANCELED.getStatus())) { | |
| 158 | + throw exception(WM_RETURN_SALES_CANCEL_NOT_ALLOWED); | |
| 159 | + } | |
| 160 | + | |
| 161 | + // 取消 | |
| 162 | + returnSalesMapper.updateById(new MesWmReturnSalesDO() | |
| 163 | + .setId(id).setStatus(MesWmReturnSalesStatusEnum.CANCELED.getStatus())); | |
| 164 | + } | |
| 165 | + | |
| 166 | + @Override | |
| 167 | + public Boolean checkReturnSalesQuantity(Long id) { | |
| 168 | + List<MesWmReturnSalesLineDO> lines = returnSalesLineService.getReturnSalesLineListByReturnId(id); | |
| 169 | + for (MesWmReturnSalesLineDO line : lines) { | |
| 170 | + List<MesWmReturnSalesDetailDO> details = returnSalesDetailService.getReturnSalesDetailListByLineId(line.getId()); | |
| 171 | + BigDecimal totalDetailQty = CollectionUtils.getSumValue(details, | |
| 172 | + MesWmReturnSalesDetailDO::getQuantity, BigDecimal::add, BigDecimal.ZERO); | |
| 173 | + if (line.getQuantityReturned() != null && totalDetailQty.compareTo(line.getQuantityReturned()) != 0) { | |
| 174 | + return false; | |
| 175 | + } | |
| 176 | + } | |
| 177 | + return true; | |
| 178 | + } | |
| 179 | + | |
| 180 | + @Override | |
| 181 | + public MesWmReturnSalesDO validateReturnSalesExists(Long id) { | |
| 182 | + MesWmReturnSalesDO returnSales = returnSalesMapper.selectById(id); | |
| 183 | + if (returnSales == null) { | |
| 184 | + throw exception(WM_RETURN_SALES_NOT_EXISTS); | |
| 185 | + } | |
| 186 | + return returnSales; | |
| 187 | + } | |
| 188 | + | |
| 189 | + /** | |
| 190 | + * 校验销售退货单存在且为准备中状态 | |
| 191 | + */ | |
| 192 | + private MesWmReturnSalesDO validateReturnSalesExistsAndPrepare(Long id) { | |
| 193 | + MesWmReturnSalesDO returnSales = validateReturnSalesExists(id); | |
| 194 | + if (ObjUtil.notEqual(MesWmReturnSalesStatusEnum.PREPARE.getStatus(), returnSales.getStatus())) { | |
| 195 | + throw exception(WM_RETURN_SALES_STATUS_NOT_PREPARE); | |
| 196 | + } | |
| 197 | + return returnSales; | |
| 198 | + } | |
| 199 | + | |
| 200 | +} | ... | ... |