| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.asrs.wms.asrs.entity.LocDetl; |
| | | import com.zy.asrs.wms.asrs.entity.LocDetlField; |
| | | import com.zy.asrs.wms.asrs.entity.ViewLocDetl; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wms.asrs.entity.*; |
| | | import com.zy.asrs.wms.asrs.entity.enums.LocStsType; |
| | | import com.zy.asrs.wms.asrs.entity.param.FieldParam; |
| | | import com.zy.asrs.wms.asrs.entity.param.FieldSortParam; |
| | | import com.zy.asrs.wms.asrs.mapper.LocDetlMapper; |
| | | import com.zy.asrs.wms.asrs.mapper.ViewLocDetlMapper; |
| | | import com.zy.asrs.wms.asrs.service.LanewayRuleService; |
| | | import com.zy.asrs.wms.asrs.service.LocDetlFieldService; |
| | | import com.zy.asrs.wms.asrs.service.LocDetlService; |
| | | import com.zy.asrs.wms.asrs.service.LocService; |
| | | import com.zy.asrs.wms.common.domain.BaseParam; |
| | | import com.zy.asrs.wms.common.domain.PageParam; |
| | | 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.*; |
| | | |
| | | @Service("locDetlService") |
| | | public class LocDetlServiceImpl extends ServiceImpl<LocDetlMapper, LocDetl> implements LocDetlService { |
| | |
| | | private ViewLocDetlMapper viewLocDetlMapper; |
| | | @Autowired |
| | | private LocDetlFieldService locDetlFieldService; |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private LanewayRuleService lanewayRuleService; |
| | | |
| | | @Override |
| | | public PageParam<ViewLocDetl, BaseParam> getPage(PageParam<ViewLocDetl, BaseParam> pageParam, QueryWrapper<ViewLocDetl> buildWrapper) { |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 根据出库条件查询符合的库存 |
| | | * @param param 查询条件 |
| | | * @param sortParam 排序字段 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<LocDetl> getSuitableMat( List<FieldParam> param, List<FieldSortParam> sortParam) { |
| | | List<Map<String, Object>> stock = viewLocDetlMapper.getSuitableMat(param, sortParam); |
| | | public List<LocDetl> queryStock(String matnr, String batch, List<FieldParam> param) { |
| | | return queryStock(matnr, batch, param, null); |
| | | } |
| | | |
| | | @Override |
| | | public List<LocDetl> queryStock(String matnr, String batch, List<FieldParam> param, List<FieldSortParam> sortParam) { |
| | | List<Map<String, Object>> list = viewLocDetlMapper.getList(matnr, batch, param, sortParam); |
| | | List<LocDetl> locDetlsSort = resortDetls(list); |
| | | return locDetlsSort; |
| | | } |
| | | |
| | | private List<LocDetl> resortDetls(List<Map<String, Object>> list) { |
| | | List<LocDetl> locDetls = new ArrayList<>(); |
| | | for (Map<String, Object> objectMap : stock) { |
| | | LocDetl detl = JSON.parseObject(JSON.toJSONString(objectMap), LocDetl.class); |
| | | detl.syncFieldMap(objectMap); |
| | | locDetls.add(detl); |
| | | |
| | | for (Map<String, Object> map : list) { |
| | | LocDetl locDetl = JSON.parseObject(JSON.toJSONString(map), LocDetl.class); |
| | | locDetls.add(locDetl); |
| | | } |
| | | return locDetls; |
| | | |
| | | locDetls = parseLocDetl(locDetls); |
| | | |
| | | List<Long> sortDirctLoc = new ArrayList<>(); |
| | | HashMap<Long, List<LocDetl>> sortMap = new HashMap<>(); |
| | | for (LocDetl locDetl : locDetls) { |
| | | List<LocDetl> detls = sortMap.get(locDetl.getLocId()); |
| | | if (detls == null) { |
| | | detls = new ArrayList<>(); |
| | | detls.add(locDetl); |
| | | sortMap.put(locDetl.getLocId(), detls); |
| | | }else { |
| | | detls.add(locDetl); |
| | | sortMap.put(locDetl.getLocId(), detls); |
| | | } |
| | | |
| | | Loc loc = locService.getById(locDetl.getLocId()); |
| | | if (loc == null) { |
| | | continue; |
| | | } |
| | | |
| | | if(!loc.getLocStsId().equals(LocStsType.F.val())){ |
| | | continue; |
| | | } |
| | | |
| | | //获取库位所在巷道 |
| | | LanewayRule lanewayRule = lanewayRuleService.getLaneByLoc(loc); |
| | | if(lanewayRule == null) { |
| | | throw new CoolException("库位未配置巷道"); |
| | | } |
| | | |
| | | //获取库位方向 |
| | | List<Integer> direction = null; |
| | | if (lanewayRule.getLaneX$().contains(loc.getRow1())) { |
| | | direction = lanewayRule.getLaneX$(); |
| | | }else { |
| | | direction = lanewayRule.getLaneY$(); |
| | | } |
| | | Collections.reverse(direction); |
| | | |
| | | for (Integer row : direction) { |
| | | Loc one = locService.getOne(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getRow1, row) |
| | | .eq(Loc::getBay1, loc.getBay1()) |
| | | .eq(Loc::getLev1, loc.getLev1())); |
| | | if (one == null) { |
| | | continue; |
| | | } |
| | | |
| | | sortDirctLoc.add(one.getId()); |
| | | } |
| | | } |
| | | |
| | | List<LocDetl> sortDirctDetls = new ArrayList<>(); |
| | | |
| | | for (Long locId : sortDirctLoc) { |
| | | List<LocDetl> detls = sortMap.get(locId); |
| | | if(detls == null) { |
| | | continue; |
| | | } |
| | | |
| | | sortDirctDetls.addAll(detls); |
| | | } |
| | | |
| | | return sortDirctDetls; |
| | | } |
| | | |
| | | } |