skyouc
2025-03-25 ef69d3bad0c7f03da11cb1c1e46a84bcebe02bc4
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/MatnrGroupController.java
@@ -17,6 +17,7 @@
import com.vincent.rsf.server.manager.service.MatnrGroupService;
import com.vincent.rsf.server.system.controller.BaseController;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -72,8 +73,12 @@
        if (Objects.isNull(matnrGroup.getCode())) {
            throw new CoolException("分组编码不能为空!!");
        }
        if (Objects.isNull(matnrGroup.getParCode())) {
            throw new CoolException("上级编码不能为空!!");
        }
        matnrGroup.setCreateBy(getLoginUserId());
        matnrGroup.setUpdateBy(getLoginUserId());
        List<MatnrGroup> list = matnrGroupService.list(new LambdaQueryWrapper<MatnrGroup>()
                .eq(MatnrGroup::getCode, matnrGroup.getCode()));
        if (!list.isEmpty()) {
@@ -83,6 +88,10 @@
                .eq(MatnrGroup::getName, matnrGroup.getName()));
        if (!groups.isEmpty()) {
            throw new CoolException("分组已存在,请勿重复添加!!");
        }
        //判断上级编码是否为空
        if (!Objects.isNull(matnrGroup.getParCode()) && !StringUtils.isBlank(matnrGroup.getParCode())) {
            matnrGroup.setParCode(matnrGroup.getParCode() + matnrGroup.getCode());
        }
        if (!matnrGroupService.save(matnrGroup)) {
            return R.error("Save Fail");
@@ -109,6 +118,11 @@
            }
        }
        //判断上级编码是否为空
        if (!Objects.isNull(matnrGroup.getParCode()) && !StringUtils.isBlank(matnrGroup.getParCode())) {
            matnrGroup.setCode(matnrGroup.getParCode() + matnrGroup.getCode());
        }
        if (!matnrGroupService.updateById(matnrGroup)) {
            return R.error("Update Fail");
        }