rsf-common/src/main/java/com/vincent/rsf/common/utils/Utils.java
@@ -48,6 +48,26 @@ return result; } public static <T, R> List<T> getAllTree(List<T> data, R parentId, Function<? super T, ? extends R> parentIdMapper, Function<? super T, ? extends R> idMapper, BiConsumer<T, List<T>> consumer) { List<T> result = new ArrayList<>(); for (T datum : data) { R dParentId = parentIdMapper.apply(datum); R dId = idMapper.apply(datum); if (dParentId.equals(dId)) { List<T> children = toTreeData(data, dId, parentIdMapper, idMapper, consumer); if (!children.isEmpty()) { consumer.accept(datum, children); } result.add(datum); } if (dParentId.equals(dId)) { continue; } } return result; } public static <T> void treeRemove(List<T> list, String condition, Function<? super T, ? extends String> fetcher, Function<T, List<T>> childrenGetter) { Iterator<T> iterator = list.iterator(); while (iterator.hasNext()) { rsf-server/src/main/java/asnOrderItemLog.sql
File was deleted rsf-server/src/main/java/asnOrderLog.sql
File was deleted rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocAreaMatRelaController.java
@@ -16,6 +16,7 @@ import com.vincent.rsf.server.system.controller.BaseController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; 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.*; @@ -60,10 +61,9 @@ @OperationLog("Create loc areas mats rela") @PostMapping("/locAreaMatRela/save") public R save(@RequestBody LocAreaMatRela locAreaMatRela) { locAreaMatRela.setCreateBy(getLoginUserId()); locAreaMatRela.setCreateTime(new Date()); locAreaMatRela.setUpdateBy(getLoginUserId()); locAreaMatRela.setUpdateTime(new Date()); if (!locAreaMatRelaService.save(locAreaMatRela)) { return R.error("Save Fail"); } @@ -82,10 +82,53 @@ return R.ok("Update Success").add(locAreaMatRela); } @PreAuthorize("hasAuthority('manager:locAreaMatRela:remove')") @ApiOperation("删除物料分组") @GetMapping("/locAreaMatRela/group") @PreAuthorize("hasAuthority('manager:locAreaMatRela:update')") public R remByGroup(@RequestBody Map<String, Object> map) { if (Objects.isNull(map)) { throw new CoolException("参数不能为空!!"); } if (!StringUtils.isBlank(map.get("groupId").toString())) { throw new CoolException("库位类型不能为空!!"); } if (!StringUtils.isBlank(map.get("areaMatId").toString())) { throw new CoolException("主单ID不能为空!!"); } if (locAreaMatRelaService.removeByGroupId(map)) { return R.ok(); } else { return R.error("删除失败!!"); } } @ApiOperation("删除库位类型") @GetMapping("/locAreaMatRela/locType/remove") @PreAuthorize("hasAuthority('manager:locAreaMatRela:update')") public R removByLocType(@RequestBody Map<String, Object> param) { if (Objects.isNull(param)) { throw new CoolException("参数不能为空!!!"); } if (!StringUtils.isBlank(param.get("locTypeId").toString())) { throw new CoolException("库位类型不能为空!!"); } if (!StringUtils.isBlank(param.get("areaMatId").toString())) { throw new CoolException("主单ID不能为空!!"); } if (locAreaMatRelaService.removeByLocType(param)) { return R.ok(); } else { return R.ok("删除失败!!"); } } @PreAuthorize("hasAuthority('manager:locAreaMatRela:list')") @OperationLog("Delete loc areas mats rela") @PostMapping("/locAreaMatRela/remove/{ids}") public R remove(@PathVariable Long[] ids) { if (Objects.isNull(ids)) { throw new CoolException("参数不能为空!!"); } if (!locAreaMatRelaService.removeByIds(Arrays.asList(ids))) { return R.error("Delete Fail"); } @@ -107,6 +150,27 @@ } @PreAuthorize("hasAuthority('manager:locAreaMatRela:list')") @ApiOperation("获取库区物料分组") @GetMapping("/locAreaMatRela/groups/{id}") public R getAreaMatGroup(@PathVariable Long id) { if (Objects.isNull(id)) { throw new CoolException("参数不能为空!!"); } return R.ok(locAreaMatRelaService.getAllGroups(id)); } @PreAuthorize("hasAuthority('manager:locAreaMatRela:list')") @ApiOperation("获取库区库位类型") @GetMapping("/locAreaMatRela/locType/{id}") public R getAreaMatLocType(@PathVariable Long id) { if (Objects.isNull(id)) { throw new CoolException("参数不能为空!!"); } return R.ok(locAreaMatRelaService.getAllLocType(id)); } @PreAuthorize("hasAuthority('manager:locAreaMatRela:list')") @PostMapping("/locAreaMatRela/export") public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { ExcelUtil.build(ExcelUtil.create(locAreaMatRelaService.list(), LocAreaMatRela.class), response); @@ -122,12 +186,12 @@ if (Objects.isNull(param.getAreaId())) { throw new CoolException("库区不能为空!!"); } // if (Objects.isNull(param.getTypeId()) || Objects.isNull(param.getLocId()) || param.getLocId().isEmpty() || param.getTypeId().isEmpty()) { // throw new CoolException("库位类型或库位不能为空!!"); // } // if (Objects.isNull(param.getGroupId()) || Objects.isNull(param.getMatnrId()) || param.getMatnrId().isEmpty()) { // throw new CoolException("物料或物料分类不能为空!!"); // } if (Objects.isNull(param.getWarehouseId())) { throw new CoolException("仓库不能为空!!"); } if (Objects.isNull(param.getAreaMatId())) { throw new CoolException("主单ID不能为空!!"); } return locAreaMatRelaService.binMatnrs(param); } rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/MatnrGroupController.java
@@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletResponse; import java.util.*; import java.util.stream.Collectors; @Api(tags = "物料分组") @RestController @@ -141,18 +142,12 @@ @PreAuthorize("hasAuthority('manager:matnrGroup:list')") @PostMapping("/matnrGroup/tree") public R tree(@RequestBody(required = false) Map<String, Object> map) { List<MatnrGroup> matnrs = new ArrayList<>(); if (Objects.isNull(map)) { 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")).orderByAsc(MatnrGroup::getCode)); return R.error("参数不能为空!!"); } List<MatnrGroup> treeData = Utils.toTreeData(matnrs, 0L, MatnrGroup::getParentId, MatnrGroup::getId, MatnrGroup::setChildren); return R.ok().add(treeData); List<MatnrGroup> matnrs = matnrGroupService.getTreeData(map); return R.ok().add(matnrs); } rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WarehouseAreasController.java
@@ -98,15 +98,15 @@ throw new CoolException("数据错误:仓库库区不存在!!"); } if (!warehouseAreas.getName().equals(areas.getName())) { List<WarehouseAreas> areasList = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().eq(WarehouseAreas::getName, areas.getName())); List<WarehouseAreas> areasList = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().eq(WarehouseAreas::getName, warehouseAreas.getName())); if (!areasList.isEmpty()) { throw new CoolException("仓库名已存在!!"); throw new CoolException("名称已存在!!"); } } if (!warehouseAreas.getCode().equals(areas.getCode())) { List<WarehouseAreas> areasList = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().eq(WarehouseAreas::getCode, areas.getCode())); List<WarehouseAreas> areasList = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().eq(WarehouseAreas::getCode, warehouseAreas.getCode())); if (!areasList.isEmpty()) { throw new CoolException("仓库编码已存在!!"); throw new CoolException("编码已存在!!"); } } rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/params/LocAreaMatsParam.java
@@ -26,6 +26,12 @@ @ApiModelProperty("库区ID") private Long areaId; @ApiModelProperty("仓库ID") private Long warehouseId; @ApiModelProperty("主单ID") private Long areaMatId; @ApiModelProperty("库位类型") private List<Long> typeId; rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocAreaMatRela.java
@@ -45,6 +45,12 @@ private Long areaId; /** * 主单ID */ @ApiModelProperty("主单ID") private Long areaMatId; /** * 编号 */ @ApiModelProperty(value= "编号") rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/LocTypeRela.java
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; import com.vincent.rsf.server.manager.service.LocService; import com.vincent.rsf.server.manager.service.WarehouseService; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -16,6 +18,7 @@ import java.io.Serializable; import java.util.Date; import java.util.Objects; @Data @Accessors(chain = true) @@ -50,4 +53,39 @@ this.typeId = typeId; } // /** // * @author Ryan // * @description 获取库位 // * @param // * @return // * @time 2025/3/24 10:28 // */ // public String getLocId$() { // if (this.warehouseId == null) { return null; } // WarehouseService warehouseService = SpringUtils.getBean(WarehouseService.class); // Warehouse warehouse = warehouseService.getById(this.warehouseId); // if (Objects.isNull(warehouse)) { // return null; // } // return warehouse.getName(); // } /** * @author Ryan * @description 获取库区名称 * @param * @return * @time 2025/3/24 10:27 */ public String getAreaId$() { if (this.locId == null) { return null; } LocService locService = SpringUtils.getBean(LocService.class); Loc byId = locService.getById(this.locId); if (Objects.isNull(byId)) { return null; } return byId.getCode(); } } rsf-server/src/main/java/com/vincent/rsf/server/manager/service/LocAreaMatRelaService.java
@@ -4,8 +4,22 @@ import com.vincent.rsf.framework.common.R; import com.vincent.rsf.server.manager.controller.params.LocAreaMatsParam; import com.vincent.rsf.server.manager.entity.LocAreaMatRela; import com.vincent.rsf.server.manager.entity.LocType; import com.vincent.rsf.server.manager.entity.LocTypeRela; import com.vincent.rsf.server.manager.entity.MatnrGroup; import java.util.List; import java.util.Map; public interface LocAreaMatRelaService extends IService<LocAreaMatRela> { R binMatnrs(LocAreaMatsParam param); Boolean removeByGroupId(Map<String, Object> params); boolean removeByLocType(Map<String, Object> params); List<MatnrGroup> getAllGroups(Long id); List<LocType> getAllLocType(Long id); } rsf-server/src/main/java/com/vincent/rsf/server/manager/service/MatnrGroupService.java
@@ -3,7 +3,11 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.vincent.rsf.server.manager.entity.MatnrGroup; import java.util.List; import java.util.Map; public interface MatnrGroupService extends IService<MatnrGroup> { List<MatnrGroup> getTreeData(Map<String, Object> map); } rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocAreaMatRelaServiceImpl.java
@@ -4,20 +4,17 @@ import com.vincent.rsf.framework.common.R; import com.vincent.rsf.framework.exception.CoolException; import com.vincent.rsf.server.manager.controller.params.LocAreaMatsParam; import com.vincent.rsf.server.manager.entity.LocTypeRela; import com.vincent.rsf.server.manager.entity.Matnr; import com.vincent.rsf.server.manager.entity.*; import com.vincent.rsf.server.manager.mapper.LocAreaMatRelaMapper; import com.vincent.rsf.server.manager.entity.LocAreaMatRela; import com.vincent.rsf.server.manager.service.LocAreaMatRelaService; import com.vincent.rsf.server.manager.service.*; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.vincent.rsf.server.manager.service.LocService; import com.vincent.rsf.server.manager.service.LocTypeRelaService; import com.vincent.rsf.server.manager.service.MatnrService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @@ -31,7 +28,13 @@ private LocService locService; @Autowired private MatnrGroupService matnrGroupService; @Autowired private LocTypeRelaService locTypeRelaService; @Autowired private LocTypeService locTypeService; /** @@ -73,6 +76,7 @@ for (Matnr matnrId : matnrIds) { LocAreaMatRela locAreaMatRela = new LocAreaMatRela(); locAreaMatRela .setAreaMatId(param.getAreaMatId()) .setAreaId(param.getAreaId()) .setLocId(locId) .setLocTypeId(typeId) @@ -94,6 +98,7 @@ LocAreaMatRela locAreaMatRela = new LocAreaMatRela(); locAreaMatRela .setAreaId(param.getAreaId()) .setAreaMatId(param.getAreaMatId()) .setLocId(locTypeRela.getLocId()) .setLocTypeId(locTypeRela.getTypeId()) .setMatnrId(matnr.getId()) @@ -107,4 +112,100 @@ } return R.ok("绑定成功!!"); } /** * @author Ryan * @description 移除物料分组下绑定关系 * @param * @return * @time 2025/3/24 13:33 */ @Override public Boolean removeByGroupId(Map<String, Object> param) { if (Objects.isNull(param)) { throw new CoolException("物料分组ID不能为空!!"); } if (!StringUtils.isBlank(param.get("groupId").toString())) { throw new CoolException("物料分类不能为空!!"); } if (!StringUtils.isBlank(param.get("areaMatId").toString())) { throw new CoolException("主单ID不能为空!!"); } if (!this.remove(new LambdaQueryWrapper<LocAreaMatRela>() .eq(LocAreaMatRela::getAreaMatId, Long.parseLong(param.get("areaMatId").toString())) .eq(LocAreaMatRela::getGroupId, Long.parseLong(param.get("groupId").toString())))) { throw new CoolException("删除失败!!"); } return true; } /** * @author Ryan * @description 移除库位类型绑定关系 * @param * @return * @time 2025/3/24 13:32 */ @Override public boolean removeByLocType(Map<String, Object> param) { if (Objects.isNull(param)) { throw new CoolException("库位类型ID不能为空!!"); } if (!this.remove(new LambdaQueryWrapper<LocAreaMatRela>() .eq(LocAreaMatRela::getAreaMatId, Long.parseLong(param.get("areaMatId").toString())) .eq(LocAreaMatRela::getLocTypeId, Long.parseLong(param.get("locTypeId").toString())))) { throw new CoolException("删除失败!!"); } return true; } /** * @author Ryan * @description 获取物料分组 * @param * @return * @time 2025/3/24 13:32 */ @Override public List<MatnrGroup> getAllGroups(Long id) { if (Objects.isNull(id)) { throw new CoolException("主单ID不能为空!!"); } List<LocAreaMatRela> locAreaMatRelas = this.list(new LambdaQueryWrapper<LocAreaMatRela>().eq(LocAreaMatRela::getAreaMatId, id)); if (locAreaMatRelas.isEmpty()) { throw new CoolException("库区绑定物料为空!!"); } List<Long> longList = locAreaMatRelas.stream().map(LocAreaMatRela::getGroupId).collect(Collectors.toList()); List<MatnrGroup> groups = matnrGroupService.list(new LambdaQueryWrapper<MatnrGroup>().in(MatnrGroup::getId, longList)); if (groups.isEmpty()) { throw new CoolException("数据错误:物料分组不存在!!"); } return groups; } /** * @author Ryan * @description 获取绑定库位物料 * @param * @return * @time 2025/3/24 13:36 */ @Override public List<LocType> getAllLocType(Long id) { if (Objects.isNull(id)) { throw new CoolException("主单ID不能为空!!"); } List<LocAreaMatRela> locAreaMatRelas = this.list(new LambdaQueryWrapper<LocAreaMatRela>().eq(LocAreaMatRela::getAreaMatId, id)); if (locAreaMatRelas.isEmpty()) { throw new CoolException("库区绑定物料为空!!"); } List<Long> longList = locAreaMatRelas.stream().map(LocAreaMatRela::getLocTypeId).collect(Collectors.toList()); List<LocType> list = locTypeService.list(new LambdaQueryWrapper<LocType>().in(LocType::getId, longList)); if (list.isEmpty()) { throw new CoolException("数据错误:库位类型不存在!!"); } return list; } } rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/MatnrGroupServiceImpl.java
@@ -2,16 +2,48 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.vincent.rsf.common.utils.Utils; import com.vincent.rsf.framework.common.R; import com.vincent.rsf.framework.exception.CoolException; import com.vincent.rsf.server.manager.mapper.MatnrGroupMapper; import com.vincent.rsf.server.manager.entity.MatnrGroup; import com.vincent.rsf.server.manager.service.MatnrGroupService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @Service("matnrGroupService") public class MatnrGroupServiceImpl extends ServiceImpl<MatnrGroupMapper, MatnrGroup> implements MatnrGroupService { @Override public List<MatnrGroup> getTreeData(Map<String, Object> map) { List<MatnrGroup> matnrs = new ArrayList<>(); if (Objects.isNull(map)) { matnrs = this.list(new LambdaQueryWrapper<MatnrGroup>().orderByAsc(MatnrGroup::getCode)); } else { if (Objects.isNull(map.get("condition"))) { throw new CoolException("condition参数不能为空!!"); } if (!StringUtils.isBlank(map.get("condition").toString())) { List<MatnrGroup> groups = this.list(new LambdaQueryWrapper<MatnrGroup>() .like(MatnrGroup::getName, map.get("condition")) .orderByAsc(MatnrGroup::getCode)); List<Long> collect = groups.stream().map(MatnrGroup::getId).collect(Collectors.toList()); List<MatnrGroup> list = this.list(new LambdaQueryWrapper<MatnrGroup>().in(MatnrGroup::getId, collect)); matnrs.addAll(list); List<MatnrGroup> treeData = Utils.toTreeData(matnrs, 0L, MatnrGroup::getParentId, MatnrGroup::getId, MatnrGroup::setChildren); return treeData; } else { matnrs = this.list(new LambdaQueryWrapper<MatnrGroup>().orderByAsc(MatnrGroup::getCode)); } } List<MatnrGroup> treeData = Utils.toTreeData(matnrs, 0L, MatnrGroup::getParentId, MatnrGroup::getId, MatnrGroup::setChildren); return treeData; } } rsf-server/src/main/java/com/vincent/rsf/server/system/controller/DictDataController.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.vincent.rsf.framework.common.Cools; import com.vincent.rsf.framework.common.R; import com.vincent.rsf.framework.exception.CoolException; import com.vincent.rsf.server.common.utils.ExcelUtil; import com.vincent.rsf.server.common.annotation.OperationLog; import com.vincent.rsf.server.common.domain.BaseParam; @@ -55,10 +56,20 @@ @OperationLog("Create 字典数据集") @PostMapping("/dictData/save") public R save(@RequestBody DictData dictData) { if (Objects.isNull(dictData.getLabel())) { throw new CoolException("别名不能为空!!"); } if (Objects.isNull(dictData.getValue())) { throw new CoolException("值不能为空!!"); } if (Objects.isNull(dictData.getDictTypeCode())) { throw new CoolException("编码不能为空!!"); } if (Objects.isNull(dictData.getDictTypeId())) { throw new CoolException("主单ID不能为空!!"); } dictData.setCreateBy(getLoginUserId()); dictData.setCreateTime(new Date()); dictData.setUpdateBy(getLoginUserId()); dictData.setUpdateTime(new Date()); if (!dictDataService.save(dictData)) { return R.error("Save Fail"); } rsf-server/src/main/java/com/vincent/rsf/server/system/controller/DictTypeController.java
@@ -61,13 +61,15 @@ if (Objects.isNull(dictType.getName())) { throw new CoolException("字典名称不能为空!!"); } if (Objects.isNull(dictType.getDescription())) { throw new CoolException("字典描述不能为空!!"); } if (Objects.isNull(dictType.getCode())) { throw new CoolException("字典编码不能为空!!"); } if (!dictTypeService.list(new LambdaQueryWrapper<DictType>().eq(DictType::getCode, dictType.getCode())).isEmpty()) { throw new CoolException("编码不能重复!!"); } if (!dictTypeService.list(new LambdaQueryWrapper<DictType>().eq(DictType::getName, dictType.getName())).isEmpty()) { throw new CoolException("名称不能重复!!"); } if (!dictTypeService.save(dictType)) { return R.error("Save Fail"); } @@ -78,8 +80,10 @@ @OperationLog("Update 数据字典") @PostMapping("/dictType/update") public R update(@RequestBody DictType dictType) { if (Objects.isNull(dictType)) { throw new CoolException("参数不能为空!!"); } dictType.setUpdateBy(getLoginUserId()); dictType.setUpdateTime(new Date()); if (!dictTypeService.updateById(dictType)) { return R.error("Update Fail"); } rsf-server/src/main/java/locArea.sql
File was deleted rsf-server/src/main/java/locAreaMat.sql
File was deleted rsf-server/src/main/java/locAreaMatRela.sql
File was deleted rsf-server/src/main/java/locAreaRela.sql
File was deleted rsf-server/src/main/resources/application.yml
@@ -31,8 +31,8 @@ :banner: false db-config: id-type: auto logic-delete-value: 1 logic-not-delete-value: 0 # logic-delete-value: 1 # logic-not-delete-value: 0 super: pwd: xltys1995