gongchunyi
9 小时以前 4f02a4e8881202c1051e4ea98afce530e325df1d
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductProcessBindServiceImpl.java
@@ -1,10 +1,15 @@
package com.ruoyi.sales.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.sales.pojo.SalesLedgerProductProcess;
import com.ruoyi.sales.pojo.SalesLedgerProductProcessBind;
import com.ruoyi.sales.mapper.SalesLedgerProductProcessBindMapper;
import com.ruoyi.sales.service.ISalesLedgerProductProcessBindService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * <p>
@@ -17,4 +22,20 @@
@Service
public class SalesLedgerProductProcessBindServiceImpl extends ServiceImpl<SalesLedgerProductProcessBindMapper, SalesLedgerProductProcessBind> implements ISalesLedgerProductProcessBindService {
    @Override
    public void updateProductProcessBind(List<SalesLedgerProductProcess> list, Long salesLedgerProductId) {
        if (salesLedgerProductId == null) {
            throw new ServiceException("新增/修改失败,销售台账产品异常");
        }
        baseMapper.delete(new LambdaQueryWrapper<SalesLedgerProductProcessBind>().in(SalesLedgerProductProcessBind::getSalesLedgerProductId, salesLedgerProductId));
        if (list != null && !list.isEmpty()) {
            list.forEach(s -> {
                SalesLedgerProductProcessBind salesLedgerProductProcessBind = new SalesLedgerProductProcessBind();
                salesLedgerProductProcessBind.setSalesLedgerProductId(salesLedgerProductId);
                salesLedgerProductProcessBind.setSalesLedgerProductProcessId(s.getId());
                salesLedgerProductProcessBind.setQuantity(s.getQuantity());
                baseMapper.insert(salesLedgerProductProcessBind);
            });
        }
    }
}