skyouc
2 天以前 e4e3f752792527c5c22df131c8dffa4733c98057
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.vincent.rsf.server.manager.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.common.exception.BusinessException;
import com.vincent.rsf.server.manager.enums.AsnExceStatus;
import com.vincent.rsf.server.manager.mapper.DeliveryMapper;
import com.vincent.rsf.server.manager.entity.Delivery;
import com.vincent.rsf.server.manager.service.DeliveryItemService;
import com.vincent.rsf.server.manager.service.DeliveryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service("deliveryService")
public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> implements DeliveryService {
 
    @Autowired
    private DeliveryItemService deliveryItemService;
 
 
    @Override
    public Delivery removeDo(List<Long> list) {
        List<Delivery> deliveries = this.list(new LambdaQueryWrapper<Delivery>().eq(Delivery::getId, list));
        if (deliveries.isEmpty()) {
            throw new BusinessException("数据错误:单据信息不存在!!");
        }
        deliveries.forEach(delivery -> {
            if (delivery.getExceStatus().equals(AsnExceStatus.OUT_STOCK_STATUS_TASK_INIT.val)){
                if (!this.removeById(delivery.getId())) {
                    throw new CoolException("主单删除失败!!");
                }
                if (!deliveryItemService.removeById(delivery.getId())) {
                    throw new CoolException("单据明细删除失败!1");
                }
            } else {
                throw new CoolException("单据已执行,不可执行删除操作!!");
            }
        });
 
        return null;
    }
}