| | |
| | | import com.vincent.rsf.server.common.domain.KeyValVo; |
| | | import com.vincent.rsf.server.common.domain.PageParam; |
| | | import com.vincent.rsf.server.manager.entity.MatnrGroup; |
| | | import com.vincent.rsf.server.manager.entity.Warehouse; |
| | | import com.vincent.rsf.server.manager.service.MatnrGroupService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.Api; |
| | |
| | | @PostMapping("/matnrGroup/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | baseParam.setOrderBy("code asc"); |
| | | PageParam<MatnrGroup, BaseParam> pageParam = new PageParam<>(baseParam, MatnrGroup.class); |
| | | return R.ok().add(matnrGroupService.page(pageParam, pageParam.buildWrapper(true))); |
| | | } |
| | |
| | | @PostMapping("/matnrGroup/update") |
| | | public R update(@RequestBody MatnrGroup matnrGroup) { |
| | | matnrGroup.setUpdateBy(getLoginUserId()); |
| | | matnrGroup.setUpdateTime(new Date()); |
| | | MatnrGroup matGroup = matnrGroupService.getById(matnrGroup.getId()); |
| | | 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("仓库名已存在!!"); |
| | | } |
| | | } |
| | | if (!matnrGroup.getCode().equals(matGroup.getCode())) { |
| | | List<MatnrGroup> areasList = matnrGroupService.list(new LambdaQueryWrapper<MatnrGroup>().eq(MatnrGroup::getCode, matnrGroup.getCode())); |
| | | if (!areasList.isEmpty()) { |
| | | throw new CoolException("仓库编码已存在!!"); |
| | | } |
| | | } |
| | | |
| | | if (!matnrGroupService.updateById(matnrGroup)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | |
| | | public R tree(@RequestBody(required = false) Map<String, Object> map) { |
| | | List<MatnrGroup> matnrs = new ArrayList<>(); |
| | | if (Objects.isNull(map)) { |
| | | matnrs = matnrGroupService.list(new LambdaQueryWrapper<>()); |
| | | matnrs = matnrGroupService.list(new LambdaQueryWrapper<MatnrGroup>().orderByAsc(MatnrGroup::getCode)); |
| | | } else { |
| | | if (Objects.isNull(map.get("condition"))) { |
| | | return R.ok("condition参数不能为空!!"); |
| | | } |
| | | matnrs = matnrGroupService.list(new LambdaQueryWrapper<MatnrGroup>().like(MatnrGroup::getName, map.get("condition"))); |
| | | matnrs = matnrGroupService.list(new LambdaQueryWrapper<MatnrGroup>() |
| | | .like(MatnrGroup::getName, map.get("condition")).orderByAsc(MatnrGroup::getCode)); |
| | | } |
| | | List<MatnrGroup> treeData = Utils.toTreeData(matnrs, 0L, MatnrGroup::getParentId, MatnrGroup::getId, MatnrGroup::setChildren); |
| | | return R.ok().add(treeData); |