| | |
| | | @PostMapping("/matnrGroup/save") |
| | | public R save(@RequestBody MatnrGroup matnrGroup) { |
| | | if (Objects.isNull(matnrGroup)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | |
| | | if (Objects.isNull(matnrGroup.getName())) { |
| | | throw new CoolException("分组名称不能为空!!"); |
| | | return R.error("分组名称不能为空!!"); |
| | | } |
| | | if (Objects.isNull(matnrGroup.getCode())) { |
| | | throw new CoolException("分组编码不能为空!!"); |
| | | } |
| | | if (Objects.isNull(matnrGroup.getParCode())) { |
| | | throw new CoolException("上级编码不能为空!!"); |
| | | return R.error("分组编码不能为空!!"); |
| | | } |
| | | matnrGroup.setCreateBy(getLoginUserId()); |
| | | matnrGroup.setUpdateBy(getLoginUserId()); |
| | | |
| | | List<MatnrGroup> list = matnrGroupService.list(new LambdaQueryWrapper<MatnrGroup>() |
| | | .eq(!Objects.isNull(matnrGroup.getParCode()), MatnrGroup::getParCode, matnrGroup.getParCode()) |
| | | .eq(MatnrGroup::getCode, matnrGroup.getCode())); |
| | | if (!list.isEmpty()) { |
| | | throw new CoolException("物料分组编码不能重复!!"); |
| | | return R.error("物料分组编码不能重复!!"); |
| | | } |
| | | List<MatnrGroup> groups = matnrGroupService.list(new LambdaQueryWrapper<MatnrGroup>() |
| | | .eq(MatnrGroup::getName, matnrGroup.getName())); |
| | | if (!groups.isEmpty()) { |
| | | throw new CoolException("分组已存在,请勿重复添加!!"); |
| | | return R.error("分组已存在,请勿重复添加!!"); |
| | | } |
| | | //判断上级编码是否为空 |
| | | if (!Objects.isNull(matnrGroup.getParCode()) && !StringUtils.isBlank(matnrGroup.getParCode())) { |
| | |
| | | @OperationLog("Update 物料分类表") |
| | | @PostMapping("/matnrGroup/update") |
| | | public R update(@RequestBody MatnrGroup matnrGroup) { |
| | | |
| | | matnrGroup.setUpdateBy(getLoginUserId()); |
| | | MatnrGroup matGroup = matnrGroupService.getById(matnrGroup.getId()); |
| | | if (Objects.isNull(matGroup)) { |
| | | return R.error("物料分组不存在!!"); |
| | | } |
| | | if (!matnrGroup.getName().equals(matGroup.getName())) { |
| | | List<MatnrGroup> areasList = matnrGroupService.list(new LambdaQueryWrapper<MatnrGroup>().eq(MatnrGroup::getName, matnrGroup.getName())); |
| | | if (!areasList.isEmpty()) { |
| | | throw new CoolException("仓库名已存在!!"); |
| | | return R.error("仓库名已存在!!"); |
| | | } |
| | | } |
| | | if (!matnrGroup.getCode().equals(matGroup.getCode())) { |
| | | List<MatnrGroup> areasList = matnrGroupService.list(new LambdaQueryWrapper<MatnrGroup>().eq(MatnrGroup::getCode, matnrGroup.getCode())); |
| | | if (!Objects.isNull(matnrGroup.getCode()) && !matnrGroup.getCode().equals(matGroup.getCode())) { |
| | | List<MatnrGroup> areasList = matnrGroupService.list(new LambdaQueryWrapper<MatnrGroup>() |
| | | .eq(!Objects.isNull(matnrGroup.getParCode()), MatnrGroup::getParCode, matnrGroup.getParCode()) |
| | | .eq(MatnrGroup::getCode, matnrGroup.getCode())); |
| | | if (!areasList.isEmpty()) { |
| | | throw new CoolException("仓库编码已存在!!"); |
| | | return R.error("仓库编码已存在!!"); |
| | | } |
| | | } |
| | | |
| | | //判断上级编码是否为空 |
| | | if (!Objects.isNull(matnrGroup.getParCode()) && !StringUtils.isBlank(matnrGroup.getParCode())) { |
| | | matnrGroup.setCode(matnrGroup.getParCode() + matnrGroup.getCode()); |
| | | } |
| | | |
| | | if (!matnrGroupService.updateById(matnrGroup)) { |