| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | |
| | | List<MesWmMiscIssueLineDO> lines = miscIssueLineService.getMiscIssueLineListByIssueId(issue.getId()); |
| | | wmTransactionService.createTransactionList(convertList(lines, line -> new MesWmTransactionSaveReqDTO() |
| | | .setType(MesWmTransactionTypeEnum.OUT.getType()).setItemId(line.getItemId()) |
| | | .setQuantity(line.getQuantity().negate()) // 出库数量为负数 |
| | | .setQuantity(negateQuantity(line.getQuantity())) // 出库数量为负数 |
| | | .setBatchId(line.getBatchId()).setBatchCode(line.getBatchCode()) |
| | | .setWarehouseId(line.getWarehouseId()).setLocationId(line.getLocationId()).setAreaId(line.getAreaId()) |
| | | .setBizType(MesBizTypeConstants.WM_MISC_ISSUE).setBizId(issue.getId()).setBizCode(issue.getCode()).setBizLineId(line.getId()))); |
| | | } |
| | | |
| | | /** |
| | | * 出库数量取负:数量为空时抛出明确的业务异常,避免 NPE |
| | | */ |
| | | private BigDecimal negateQuantity(BigDecimal quantity) { |
| | | if (quantity == null) { |
| | | throw exception(WM_MISC_ISSUE_QUANTITY_INVALID); |
| | | } |
| | | return quantity.negate(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void cancelMiscIssue(Long id) { |