zxl
2025-06-11 05e49980cd556d24239e00d028dc5efa25e0de14
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package cn.lili.modules.purchase.serviceimpl;
 
import cn.lili.common.utils.BeanUtil;
import cn.lili.modules.purchase.entity.dos.PurchaseQuoted;
import cn.lili.modules.purchase.entity.vos.PurchaseQuotedVO;
import cn.lili.modules.purchase.mapper.PurchaseQuotedMapper;
import cn.lili.modules.purchase.service.PurchaseQuotedItemService;
import cn.lili.modules.purchase.service.PurchaseQuotedService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.List;
 
 
/**
 * 采购单报价业务层实现
 *
 * @author Bulbasaur
 * @since 2020/11/26 16:13
 */
@Service
public class PurchaseQuotedServiceImpl extends ServiceImpl<PurchaseQuotedMapper, PurchaseQuoted> implements PurchaseQuotedService {
    @Autowired
    private PurchaseQuotedItemService purchaseQuotedItemService;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public PurchaseQuotedVO addPurchaseQuoted(PurchaseQuotedVO purchaseQuotedVO) {
 
 
        PurchaseQuoted purchaseQuoted = new PurchaseQuoted();
        BeanUtil.copyProperties(purchaseQuotedVO, purchaseQuoted);
        //添加报价单
        this.save(purchaseQuoted);
        //添加采购单子内容
        purchaseQuotedItemService.addPurchaseQuotedItem(purchaseQuoted.getId(), purchaseQuotedVO.getPurchaseQuotedItems());
        return purchaseQuotedVO;
    }
 
    @Override
    public List<PurchaseQuoted> getByPurchaseOrderId(String purchaseOrderId) {
        LambdaQueryWrapper<PurchaseQuoted> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(PurchaseQuoted::getPurchaseOrderId, purchaseOrderId);
        lambdaQueryWrapper.orderByDesc(PurchaseQuoted::getCreateTime);
        return this.list(lambdaQueryWrapper);
    }
 
    @Override
    public PurchaseQuotedVO getById(String id) {
        //获取报价单
        PurchaseQuotedVO purchaseQuotedVO = new PurchaseQuotedVO();
        PurchaseQuoted purchaseQuoted=this.baseMapper.selectById(id);
        BeanUtil.copyProperties(purchaseQuoted, purchaseQuotedVO);
        //获取报价单子内容
        purchaseQuotedVO.setPurchaseQuotedItems(purchaseQuotedItemService.purchaseQuotedItemList(id));
        return purchaseQuotedVO;
    }
}