skyouc
6 天以前 6732a988fe843cf59f12aae1460fc97fda5408dd
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderServiceImpl.java
@@ -117,8 +117,9 @@
            throw new CoolException("主单保存失败!!");
        }
        if (params.getItems().isEmpty()) {
            throw new CoolException("收货通知单明细不能为寒食节!!");
            throw new CoolException("收货通知单明细不能为空!!");
        }
        params.setOrders(orders);
        svaeOrUpdateOrderItem(params,loginUserId);
@@ -162,16 +163,15 @@
     * @time 2025/4/7 13:28
     */
    @Transactional(rollbackFor = Exception.class)
    private void svaeOrUpdateOrderItem(AsnOrderAndItemsParams params, Long loginUserId) throws Exception{
    public 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());
            item.put("poCode", orders.getPoCode());
            item.put("createBy", loginUserId);
            item.put("updateBy", loginUserId);
            if (!asnOrderItemService.fieldsSave(item)) {
            if (!asnOrderItemService.fieldsSave(item, loginUserId)) {
                throw new CoolException("明细保存失败!!");
            }
        });
@@ -217,7 +217,7 @@
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R completeOrder(Long id, Long loginUserId) {
    public  R completeOrder(Long id, Long loginUserId) {
        AsnOrder asnOrder = this.getById(id);
        if (Objects.isNull(asnOrder)) {
            throw new CoolException("单据不存在!!");
@@ -238,11 +238,6 @@
        if (Objects.isNull(order)) {
            throw new CoolException("单据不存在!!");
        }
        order.setExceStatus(Short.parseShort(AsnExceStatus.ASN_EXCE_STATUS_TASK_CLOSE.val));
        if (!this.updateById(order)) {
            throw new CoolException("单据关闭失败!!");
        }
        try {
            operateOrderLogs(order);
        } catch (Exception e) {
@@ -259,24 +254,33 @@
     * @time 2025/3/19 19:53
     */
    @Transactional(rollbackFor = Exception.class)
    private void operateOrderLogs(AsnOrder asrder) throws Exception{
    public synchronized void operateOrderLogs(AsnOrder asrder) throws Exception{
        if (Objects.isNull(asrder) || Objects.isNull(asrder.getId())) {
            throw new CoolException("参数不能为空!!");
        }
        if (Objects.isNull(asrder.getAnfme()) || asrder.getAnfme().compareTo(0.00) == 0) {
            throw new CoolException("收货数量不能为零!!");
        asrder.setExceStatus(AsnExceStatus.ASN_EXCE_STATUS_TASK_CLOSE.val);
        if (!this.updateById(asrder)) {
            throw new CoolException("单据关闭失败!!");
        }
        List<AsnOrderItem> orderItems = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>().eq(AsnOrderItem::getAsnId, asrder.getId()));
        if (orderItems.isEmpty()) {
            throw new CoolException("收货明细为空!!");
        }
//        if (Objects.isNull(asrder.getAnfme()) || asrder.getAnfme().compareTo(0.00) == 0) {
//            throw new CoolException("收货数量不能为零!!");
//        }
        AsnOrder order = this.getById(asrder.getId());
        AsnOrderLog orderLog = new AsnOrderLog();
        order.setExceStatus(Short.parseShort(AsnExceStatus.ASN_EXCE_STATUS_TASK_DONE.val));
//        order.setExceStatus(AsnExceStatus.ASN_EXCE_STATUS_TASK_DONE.val);
        BeanUtils.copyProperties(order, orderLog);
        orderLog.setId(null);
        orderLog.setAsnId(order.getId());
        if (!this.saveOrUpdate(order)) {
            throw new CoolException("状态修改失败!!");
        }
        orderLog.setExceStatus(Short.parseShort(AsnExceStatus.ASN_EXCE_STATUS_TASK_CLOSE.val));
//        if (!this.saveOrUpdate(order)) {
//            throw new CoolException("状态修改失败!!");
//        }
//        orderLog.setExceStatus(AsnExceStatus.ASN_EXCE_STATUS_TASK_CLOSE.val);
        if (!asnOrderLogService.save(orderLog)) {
            throw new CoolException("主单历史档添加失败!!");
        }
@@ -286,6 +290,7 @@
            AsnOrderItemLog itemLog = new AsnOrderItemLog();
            BeanUtils.copyProperties(item, itemLog);
            itemLog.setAsnItemId(itemLog.getId())
                    .setLogId(orderLog.getId())
                    .setAsnId(item.getAsnId());
            logs.add(itemLog);
        });