| | |
| | | package com.ruoyi.technology.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.technology.bean.dto.TechnologyOperationParamDto; |
| | | import com.ruoyi.technology.bean.vo.TechnologyOperationParamVo; |
| | | import com.ruoyi.technology.mapper.TechnologyOperationMapper; |
| | | import com.ruoyi.technology.mapper.TechnologyOperationParamMapper; |
| | | import com.ruoyi.technology.mapper.TechnologyParamMapper; |
| | | import com.ruoyi.technology.pojo.TechnologyOperationParam; |
| | | import com.ruoyi.technology.pojo.TechnologyParam; |
| | | import com.ruoyi.technology.service.TechnologyOperationParamService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 工序参数 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author 芯导软件(江苏)有限公司 |
| | | * @since 2026-04-20 10:05:35 |
| | | */ |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class TechnologyOperationParamServiceImpl extends ServiceImpl<TechnologyOperationParamMapper, TechnologyOperationParam> implements TechnologyOperationParamService { |
| | | |
| | | private final TechnologyOperationParamMapper technologyOperationParamMapper; |
| | | private final TechnologyOperationMapper technologyOperationMapper; |
| | | private final TechnologyParamMapper technologyParamMapper; |
| | | |
| | | /** |
| | | * 按工序或参数条件查询工序参数列表。 |
| | | */ |
| | | @Override |
| | | public List<TechnologyOperationParamVo> listOperationParam(TechnologyOperationParamDto technologyOperationParamDto) { |
| | | Long operationId = technologyOperationParamDto == null ? null : technologyOperationParamDto.getTechnologyOperationId(); |
| | | Long paramId = technologyOperationParamDto == null ? null : technologyOperationParamDto.getTechnologyParamId(); |
| | | return technologyOperationParamMapper.listOperationParam(operationId, paramId); |
| | | } |
| | | |
| | | /** |
| | | * 保存工序参数并校验工序、参数和唯一性。 |
| | | */ |
| | | @Override |
| | | public boolean saveTechnologyOperationParam(TechnologyOperationParam technologyOperationParam) { |
| | | if (technologyOperationParam.getTechnologyOperationId() == null |
| | | || technologyOperationMapper.selectById(technologyOperationParam.getTechnologyOperationId()) == null) { |
| | | throw new ServiceException("Operation not found"); |
| | | } |
| | | if (technologyOperationParam.getTechnologyParamId() == null) { |
| | | throw new ServiceException("Param is required"); |
| | | } |
| | | TechnologyParam technologyParam = technologyParamMapper.selectById(technologyOperationParam.getTechnologyParamId()); |
| | | if (technologyParam == null) { |
| | | throw new ServiceException("Param not found"); |
| | | } |
| | | boolean duplicate = technologyOperationParamMapper.selectCount(Wrappers.<TechnologyOperationParam>lambdaQuery() |
| | | .eq(TechnologyOperationParam::getTechnologyOperationId, technologyOperationParam.getTechnologyOperationId()) |
| | | .eq(TechnologyOperationParam::getTechnologyParamId, technologyOperationParam.getTechnologyParamId()) |
| | | .ne(technologyOperationParam.getId() != null, TechnologyOperationParam::getId, technologyOperationParam.getId())) > 0; |
| | | if (duplicate) { |
| | | throw new ServiceException("Duplicate param in operation"); |
| | | } |
| | | return this.saveOrUpdate(technologyOperationParam); |
| | | } |
| | | |
| | | /** |
| | | * 删除单个工序参数。 |
| | | */ |
| | | @Override |
| | | public String batchDelete(Long id) { |
| | | TechnologyOperationParam deleteItem = technologyOperationParamMapper.selectById(id); |
| | | if (deleteItem == null) { |
| | | return "Delete failed"; |
| | | } |
| | | technologyOperationParamMapper.deleteById(id); |
| | | return "Success"; |
| | | } |
| | | } |