lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/CutterServiceImpl.java
@@ -10,12 +10,12 @@
import org.jeecg.modules.dnc.exception.ExceptionCast;
import org.jeecg.modules.dnc.mapper.CutterMapper;
import org.jeecg.modules.dnc.response.CommonCode;
import org.jeecg.modules.dnc.response.ProcessInfoCode;
import org.jeecg.modules.dnc.service.ICutterService;
import org.jeecg.modules.dnc.utils.ValidateUtil;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class CutterServiceImpl extends ServiceImpl<CutterMapper, Cutter> implements ICutterService {
@@ -29,11 +29,12 @@
    public Result<?> add(Cutter cutter){
        if(cutter == null)
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        if(!ValidateUtil.validateString(cutter.getProcessStepId()))
        if(!ValidateUtil.validateString(cutter.getAttributionId()))
            Result.error("无效的刀具");
        boolean b =this.checkCutterNo(cutter);
        if(!b)
        List<Cutter> cutterList =this.checkCutterNo(cutter);
        if (cutterList != null && !cutterList.isEmpty()) {
            return Result.error("已存在相同的刀具编号");
        }
        boolean save = this.save(cutter);
        if(save){
            return Result.OK("添加刀具成功");
@@ -48,21 +49,34 @@
     */
    @Override
    public Result<?> edit(Cutter cutter){
        if(cutter == null)
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        if(!ValidateUtil.validateString(cutter.getCutterName()))
            ExceptionCast.cast(ProcessInfoCode.PROCESS_NAME_NONE);
        Cutter en = super.getById(cutter.getId());
        if(en == null)
            ExceptionCast.cast(ProcessInfoCode.WORKSTEP_NOT_EXIST);
        boolean b =this.checkCutterNo(cutter);
        if(!b)
            return Result.error("已存在相同的刀具编号");
        boolean save = this.updateById(cutter);
        if(save){
            return Result.OK("刀具信息编辑成功");
        // 检查传入的刀具对象是否为空
        if (cutter == null) {
           return Result.OK("刀具对象不能为空");
        }
        return Result.OK("刀具信息编辑失败");
        // 检查刀具名称是否有效
        if (!ValidateUtil.validateString(cutter.getCutterName())) {
            return Result.OK("刀具名称无效");
        }
        // 根据刀具 ID 获取刀具信息
        Cutter existingCutter = super.getById(cutter.getId());
        if (existingCutter == null) {
            return Result.OK("刀具不存在");
        }
        // 过滤掉当前要编辑的刀具,检查是否有其他刀具存在相同编号
        List<Cutter> otherCuttersWithSameNo = this.checkCutterNo(cutter).stream()
                .filter(cut -> !cut.getId().equals(cutter.getId()))
                .collect(Collectors.toList());
        if (!otherCuttersWithSameNo.isEmpty()) {
            // 如果存在除当前刀具外的其他刀具编号重复
            return Result.error("已存在相同的刀具编号");
        }
        // 尝试更新刀具信息
        boolean updated = this.updateById(cutter);
        if (updated) {
            return Result.OK("刀具信息编辑成功");
        } else {
            return Result.error("刀具信息编辑失败");
        }
    }
    /**
@@ -89,13 +103,12 @@
     * @param cutter
     * @return
     */
    public boolean checkCutterNo(Cutter cutter){
    public List<Cutter> checkCutterNo(Cutter cutter){
        QueryWrapper<Cutter> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StrUtil.isNotEmpty(cutter.getProcessStepId()),"process_step_id",cutter.getProcessStepId());
        queryWrapper.eq("type",cutter.getType());
        queryWrapper.eq(StrUtil.isNotEmpty(cutter.getCutterCode()),"craft_code",cutter.getCutterCode());
        List<Cutter> list = baseMapper.selectList(queryWrapper);
        return list.isEmpty();
        queryWrapper.eq(StrUtil.isNotEmpty(cutter.getAttributionId()),"attribution_id",cutter.getAttributionId());
        queryWrapper.eq("attribution_type",cutter.getAttributionType());
        queryWrapper.eq(StrUtil.isNotEmpty(cutter.getCutterCode()),"cutter_code",cutter.getCutterCode());
        return baseMapper.selectList(queryWrapper);
    }
    /**
@@ -106,12 +119,12 @@
    @Override
    public Result<?> query(Cutter cutter, Integer pageNo, Integer pageSize){
        QueryWrapper<Cutter> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StrUtil.isNotEmpty(cutter.getProcessStepId()),"process_step_id",cutter.getProcessStepId());
        if (cutter.getType() != null){
            queryWrapper.eq("type",cutter.getType());
        queryWrapper.eq(StrUtil.isNotEmpty(cutter.getAttributionId()),"attribution_id",cutter.getAttributionId());
        if (cutter.getAttributionType() != null){
            queryWrapper.eq("attribution_type",cutter.getAttributionType());
        }
        queryWrapper.like(StrUtil.isNotEmpty(cutter.getCutterName()),"craft_code",cutter.getCutterCode());
        queryWrapper.like(StrUtil.isNotEmpty(cutter.getCutterName()),"craft_name",cutter.getCutterName());
        queryWrapper.like(StrUtil.isNotEmpty(cutter.getCutterCode()),"cutter_code",cutter.getCutterCode());
        queryWrapper.like(StrUtil.isNotEmpty(cutter.getCutterName()),"cutter_name",cutter.getCutterName());
        queryWrapper.orderByDesc("create_time");
        Page<Cutter> page = new Page<>(pageNo,pageSize);
        IPage<Cutter> cutterIPage = baseMapper.selectPage(page, queryWrapper);