| | |
| | | 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; |
| | |
| | | |
| | | @Override |
| | | public void updateProductProcessBind(List<SalesLedgerProductProcess> list, Long salesLedgerProductId) { |
| | | if (list == null || list.isEmpty()) { |
| | | return; |
| | | if (salesLedgerProductId == null) { |
| | | throw new ServiceException("新增/修改失败,销售台账产品异常"); |
| | | } |
| | | // 先清空再插入 |
| | | baseMapper.delete(new LambdaQueryWrapper<SalesLedgerProductProcessBind>().in(SalesLedgerProductProcessBind::getSalesLedgerProductId, salesLedgerProductId)); |
| | | list.forEach(s -> { |
| | | SalesLedgerProductProcessBind salesLedgerProductProcessBind = new SalesLedgerProductProcessBind(); |
| | | salesLedgerProductProcessBind.setSalesLedgerProductId(salesLedgerProductId); |
| | | salesLedgerProductProcessBind.setSalesLedgerProductProcessId(s.getId()); |
| | | salesLedgerProductProcessBind.setQuantity(s.getQuantity()); |
| | | baseMapper.insert(salesLedgerProductProcessBind); |
| | | }); |
| | | 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); |
| | | }); |
| | | } |
| | | } |
| | | } |