|  |  | 
 |  |  | package com.vincent.rsf.server.manager.service.impl; | 
 |  |  |  | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
 |  |  | import com.vincent.rsf.framework.common.R; | 
 |  |  | import com.vincent.rsf.framework.exception.CoolException; | 
 |  |  | import com.vincent.rsf.server.manager.entity.AsnOrder; | 
 |  |  | import com.vincent.rsf.server.manager.entity.AsnOrderItem; | 
 |  |  | import com.vincent.rsf.server.manager.entity.AsnOrderItemLog; | 
 |  |  | import com.vincent.rsf.server.manager.enums.AsnExceStatus; | 
 |  |  | import com.vincent.rsf.server.manager.mapper.AsnOrderLogMapper; | 
 |  |  | import com.vincent.rsf.server.manager.entity.AsnOrderLog; | 
 |  |  | import com.vincent.rsf.server.manager.service.AsnOrderItemLogService; | 
 |  |  | import com.vincent.rsf.server.manager.service.AsnOrderItemService; | 
 |  |  | import com.vincent.rsf.server.manager.service.AsnOrderLogService; | 
 |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
 |  |  | import com.vincent.rsf.server.manager.service.AsnOrderService; | 
 |  |  | import org.springframework.beans.BeanUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  |  | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Objects; | 
 |  |  |  | 
 |  |  | @Service("asnOrderLogService") | 
 |  |  | public class AsnOrderLogServiceImpl extends ServiceImpl<AsnOrderLogMapper, AsnOrderLog> implements AsnOrderLogService { | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private AsnOrderItemLogService asnOrderItemLogService; | 
 |  |  |     @Autowired | 
 |  |  |     private AsnOrderItemService asnOrderItemService; | 
 |  |  |     @Autowired | 
 |  |  |     private AsnOrderService asnOrderService; | 
 |  |  |     /** | 
 |  |  |      * @author Ryan | 
 |  |  |      * @description 继续收货 | 
 |  |  |      * @param | 
 |  |  |      * @return | 
 |  |  |      * @time 2025/4/17 15:08 | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public R continueRecipt(Long id) { | 
 |  |  |         AsnOrderLog orderLog = this.getOne(new LambdaQueryWrapper<AsnOrderLog>().eq(AsnOrderLog::getId, id)); | 
 |  |  |         if (Objects.isNull(orderLog)) { | 
 |  |  |             throw new CoolException("单据不存在!!"); | 
 |  |  |         } | 
 |  |  |         AsnOrder order = new AsnOrder(); | 
 |  |  |         BeanUtils.copyProperties(orderLog, order); | 
 |  |  |         order.setId(orderLog.getAsnId()) | 
 |  |  |                 .setDeleted(0) | 
 |  |  |                 .setExceStatus(AsnExceStatus.ASN_EXCE_STATUS_EXCE_ING.val); | 
 |  |  |         if (!asnOrderService.saveOrUpdate(order)) { | 
 |  |  |             throw new CoolException("单据保存失败!!"); | 
 |  |  |         } | 
 |  |  |         List<AsnOrderItemLog> itemLogs = asnOrderItemLogService | 
 |  |  |                 .list(new LambdaQueryWrapper<AsnOrderItemLog>() | 
 |  |  |                 .eq(AsnOrderItemLog::getLogId, id)); | 
 |  |  |         List<AsnOrderItem> orderItems = new ArrayList<>(); | 
 |  |  |         if (!Objects.isNull(itemLogs) || !itemLogs.isEmpty()) { | 
 |  |  |             for (AsnOrderItemLog itemLog : itemLogs) { | 
 |  |  |                 AsnOrderItem item = new AsnOrderItem(); | 
 |  |  |                 BeanUtils.copyProperties(itemLog, item); | 
 |  |  |                 item.setId(itemLog.getAsnItemId()) | 
 |  |  |                         .setAsnId(order.getId()) | 
 |  |  |                         .setDeleted(0); | 
 |  |  |                 orderItems.add(item); | 
 |  |  |             } | 
 |  |  |            if (!asnOrderItemService.saveOrUpdateBatch(orderItems)) { | 
 |  |  |                throw new CoolException("明细保存失败"); | 
 |  |  |            } | 
 |  |  |         } | 
 |  |  |         if (!this.removeById(orderLog.getId())) { | 
 |  |  |             throw new CoolException("历史单据删除失败!!"); | 
 |  |  |         } | 
 |  |  |         if (!asnOrderItemLogService.remove(new LambdaQueryWrapper<AsnOrderItemLog>() | 
 |  |  |                 .eq(AsnOrderItemLog::getLogId, orderLog.getId()))) { | 
 |  |  |             throw new CoolException("历史单据明细删除失败!!"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  | } |