package com.ruoyi.production.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.basic.service.BaseParamService; import com.ruoyi.production.dto.ProductProcessParamDto; import com.ruoyi.production.dto.ProductProcessParamSortDTO; import com.ruoyi.production.mapper.ProductProcessParamMapper; import com.ruoyi.production.pojo.ProductProcessParam; import com.ruoyi.production.service.ProductProcessParamService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Date; import java.util.List; /** *
* 工序绑定参数接口实现类 *
* * @author deslrey * @version 1.0 * @since 2026/03/14 13:18 */ @Slf4j @Service public class ProductProcessParamServiceImpl extends ServiceImpl implements ProductProcessParamService { @Autowired private BaseParamService baseParamService; @Override public List listByProcessId(Long processId) { if (processId == null) { throw new IllegalArgumentException("工序ID不能为空"); } return baseMapper.selectDtoListByProcessId(processId); } @Override public void add(ProductProcessParam productProcessParam) { if (productProcessParam.getProcessId() == null) { throw new IllegalArgumentException("关联工序ID不能为空"); } if (productProcessParam.getParamId() == null) { throw new IllegalArgumentException("关联基础参数ID不能为空"); } productProcessParam.setCreateTime(new Date()); if (!this.save(productProcessParam)) { throw new RuntimeException("新增失败"); } } @Override public void edit(ProductProcessParam productProcessParam) { if (productProcessParam.getId() == null) { throw new IllegalArgumentException("ID不能为空"); } productProcessParam.setUpdateTime(new Date()); if (!this.updateById(productProcessParam)) { throw new RuntimeException("修改失败"); } } @Override public void deleteByIds(List ids) { if (ids == null || ids.isEmpty()) { throw new IllegalArgumentException("ID不能为空"); } if (!this.removeByIds(ids)) { throw new RuntimeException("删除失败"); } } @Override public void updateSort(ProductProcessParamSortDTO dto) { if (dto == null || dto.getItems() == null || dto.getItems().isEmpty()) { throw new IllegalArgumentException("排序数据不能为空"); } List list = new ArrayList<>(); for (ProductProcessParamSortDTO.SortItem item : dto.getItems()) { ProductProcessParam param = new ProductProcessParam(); param.setId(item.getId()); param.setSort(item.getSort()); list.add(param); } this.updateBatchById(list); } }