| | |
| | | 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; |
| | | |
| | |
| | | private LocService locService; |
| | | |
| | | @Autowired |
| | | private MatnrGroupService matnrGroupService; |
| | | |
| | | @Autowired |
| | | private LocTypeRelaService locTypeRelaService; |
| | | |
| | | @Autowired |
| | | private LocTypeService locTypeService; |
| | | |
| | | |
| | | /** |
| | |
| | | for (Matnr matnrId : matnrIds) { |
| | | LocAreaMatRela locAreaMatRela = new LocAreaMatRela(); |
| | | locAreaMatRela |
| | | .setAreaMatId(param.getAreaMatId()) |
| | | .setAreaId(param.getAreaId()) |
| | | .setLocId(locId) |
| | | .setLocTypeId(typeId) |
| | |
| | | LocAreaMatRela locAreaMatRela = new LocAreaMatRela(); |
| | | locAreaMatRela |
| | | .setAreaId(param.getAreaId()) |
| | | .setAreaMatId(param.getAreaMatId()) |
| | | .setLocId(locTypeRela.getLocId()) |
| | | .setLocTypeId(locTypeRela.getTypeId()) |
| | | .setMatnrId(matnr.getId()) |
| | |
| | | } |
| | | 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; |
| | | } |
| | | } |