| | |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.api.entity.enums.OrderType; |
| | | import com.vincent.rsf.server.manager.controller.params.AsnOrderAndItemsParams; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.AsnExceStatus; |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | private void svaeOrUpdateOrderItem(AsnOrderAndItemsParams params, Long loginUserId) throws Exception { |
| | | AsnOrder orders = params.getOrders(); |
| | | |
| | | params.getItems().forEach(item -> { |
| | | item.put("asnId", orders.getId()); |
| | | item.put("asnCode", orders.getCode()); |
| | |
| | | * @time 2025/4/29 13:47 |
| | | */ |
| | | @Override |
| | | public R saveOrderAndItems(AsnOrderAndItemsParams params, Long loginUserId) { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R saveOutStock(AsnOrderAndItemsParams params, Long loginUserId) { |
| | | if (Objects.isNull(params.getOrders())) { |
| | | throw new CoolException("主单信息不能为空"); |
| | | } |
| | |
| | | if (Objects.isNull(orders)) { |
| | | throw new CoolException("单据不能为空!!"); |
| | | } |
| | | if (StringUtils.isBlank(orders.getWkType())) { |
| | | throw new CoolException("业务类型不能为空!!"); |
| | | } |
| | | |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_OUT_STOCK_CODE, orders); |
| | | if (Objects.isNull(ruleCode) || StringUtils.isBlank(ruleCode)) { |
| | | throw new CoolException("编码规则错误:请检查「SYS_OUT_STOCK_CODE」是否设置正确!!"); |
| | | } |
| | | |
| | | orders.setCode(ruleCode) |
| | | .setType(OrderType.ORDER_OUT.type) |
| | | .setUpdateBy(loginUserId) |
| | | .setCreateBy(loginUserId); |
| | | if (!this.save(orders)) { |
| | | throw new CoolException("主单保存失败!!"); |
| | | } |
| | | if (params.getItems().isEmpty()) { |
| | | throw new CoolException("收货通知单明细不能为寒食节!!"); |
| | | throw new CoolException("收货通知单明细不能为空!!"); |
| | | } |
| | | params.setOrders(orders); |
| | | try { |
| | | svaeOrUpdateOrderItem(params,loginUserId); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | |
| | | // svaeOrUpdateOrderItem(params,loginUserId); |
| | | |
| | | |
| | | |
| | | return null; |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @author Ryan |
| | |
| | | */ |
| | | @Override |
| | | public R updateOrderItem(AsnOrderAndItemsParams params, Long loginUserId) { |
| | | AsnOrder orders = params.getOrders(); |
| | | if (Objects.isNull(orders)) { |
| | | throw new CoolException("主单信息不能为空!!"); |
| | | } |
| | | if (Objects.isNull(orders.getId())) { |
| | | throw new CoolException("数据错误:单据ID不能为空!!"); |
| | | } |
| | | if (!this.updateById(orders)) { |
| | | throw new CoolException("主单修改失败!!"); |
| | | } |
| | | if (Objects.isNull(params.getItems()) || params.getItems().isEmpty()) { |
| | | return R.ok("明细参数不能为空!!"); |
| | | } |
| | | |
| | | try { |
| | | svaeOrUpdateOrderItem(params,loginUserId); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |