单独修改状态接口

This commit is contained in:
2025-07-19 10:49:29 +08:00
parent c2b6e54a09
commit 0ad3f3f3c8
6 changed files with 217 additions and 20 deletions

View File

@@ -126,4 +126,14 @@ public class WmsStockIoController extends BaseController {
public R<List<WmsStockIoDetailVo>> detailByTypeAndId(@RequestParam String ioType, @RequestParam Long stockIoId) {
return R.ok(iWmsStockIoService.detailByTypeAndId(ioType, stockIoId));
}
/**
* 更新出入库单状态
*/
@Log(title = "出入库单主", businessType = BusinessType.UPDATE)
@PostMapping("/updateStatus/{stockIoId}")
public R<Void> updateStatus(@NotNull(message = "主键不能为空") @PathVariable Long stockIoId,
@RequestParam Integer status) {
return toAjax(iWmsStockIoService.updateStatus(stockIoId, status));
}
}

View File

@@ -62,4 +62,9 @@ public interface IWmsStockIoService {
* 根据ioType和stockIoId联查明细
*/
java.util.List<WmsStockIoDetailVo> detailByTypeAndId(String ioType, Long stockIoId);
/**
* 更新出入库单状态
*/
Boolean updateStatus(Long stockIoId, Integer status);
}

View File

@@ -238,6 +238,35 @@ public class WmsStockIoServiceImpl implements IWmsStockIoService {
return voList;
}
/**
* 更新出入库单状态
*/
@Override
public Boolean updateStatus(Long stockIoId, Integer status) {
WmsStockIo stockIo = baseMapper.selectById(stockIoId);
if (stockIo == null) {
throw new ServiceException("单据不存在");
}
// 状态流转验证
if (stockIo.getStatus() == 0 && status == 1) {
// 草稿 -> 已提交:需要检查是否有明细
List<WmsStockIoDetail> details = stockIoDetailMapper.selectList(
Wrappers.<WmsStockIoDetail>lambdaQuery().eq(WmsStockIoDetail::getStockIoId, stockIoId)
);
if (details == null || details.isEmpty()) {
throw new ServiceException("单据明细不能为空,无法提交");
}
} else if (stockIo.getStatus() == 1 && status == 0) {
// 已提交 -> 草稿:允许回退
} else {
throw new ServiceException("状态流转不允许");
}
stockIo.setStatus(status);
return baseMapper.updateById(stockIo) > 0;
}
/**
* 库存增减isAdd=true为增加false为减少减少时校验库存是否足够
*/