| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductProcessBindMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProductProcess; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductProcessMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProductProcessBind; |
| | | import com.ruoyi.sales.service.ISalesLedgerProductProcessService; |
| | | 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 org.springframework.util.StringUtils; |
| | | |
| | | /** |
| | |
| | | @Service |
| | | public class SalesLedgerProductProcessServiceImpl extends ServiceImpl<SalesLedgerProductProcessMapper, SalesLedgerProductProcess> implements ISalesLedgerProductProcessService { |
| | | |
| | | @Autowired |
| | | private SalesLedgerProductProcessBindMapper salesLedgerProductProcessBindMapper; |
| | | |
| | | @Override |
| | | public Page<SalesLedgerProductProcess> salesLedgerProductProcessList(Page<SalesLedgerProductProcess> page, String name) { |
| | | LambdaQueryWrapper<SalesLedgerProductProcess> wrapper = new LambdaQueryWrapper<>(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addProcess(SalesLedgerProductProcess process) { |
| | | checkDuplicate(process.getProcessName(), null, process.getProcessName()); |
| | | this.save(process); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateProcess(SalesLedgerProductProcess process) { |
| | | checkDuplicate(process.getProcessName(), process.getId(), process.getProcessName()); |
| | | this.updateById(process); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteProcess(Integer id) { |
| | | if (id == null) { |
| | | throw new ServiceException("删除失败,删除数据不能为空"); |
| | | } |
| | | SalesLedgerProductProcess salesLedgerProductProcess = baseMapper.selectById(id); |
| | | if (salesLedgerProductProcess == null) { |
| | | throw new ServiceException("删除失败,该额外加工需求不存在"); |
| | | } |
| | | // 查看是否被引用 |
| | | Long selectedCount = salesLedgerProductProcessBindMapper.selectCount(new LambdaQueryWrapper<SalesLedgerProductProcessBind>().eq(SalesLedgerProductProcessBind::getSalesLedgerProductProcessId, salesLedgerProductProcess.getId())); |
| | | if (selectedCount > 0) { |
| | | throw new ServiceException("删除失败,该额外加工已被引用,禁止删除"); |
| | | } |
| | | |
| | | this.removeById(id); |
| | | } |
| | | |