|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.service.RowLastnoService; | 
|---|
|  |  |  | import com.zy.asrs.service.WorkService; | 
|---|
|  |  |  | import com.zy.asrs.utils.Utils; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Service("locMastService") | 
|---|
|  |  |  | public class LocMastServiceImpl extends ServiceImpl<LocMastMapper, LocMast> implements LocMastService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> queryFreeLocMastEnd1(Integer row, Short locType1,Boolean inoutEveryday){ | 
|---|
|  |  |  | return this.baseMapper.queryFreeLocMastEnd1(row, locType1,inoutEveryday); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> queryFreeLocMast2(Short locType1, Integer rowBeg, Integer rowEnd, Integer bayBeg, Integer bayEnd, Integer levBeg, Integer levEnd) { | 
|---|
|  |  |  | return this.baseMapper.queryFreeLocMast2(locType1, rowBeg, rowEnd, bayBeg, bayEnd, levBeg, levEnd); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Boolean checkEmptyCount(LocMast locMast) { | 
|---|
|  |  |  | public Boolean checkEmptyCount(LocMast locMast, int quaOfBlank) { | 
|---|
|  |  |  | //        quaOfBlank = 0; | 
|---|
|  |  |  | if (locMast == null) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return this.baseMapper.selectEmptyLocCount(locMast.getLocType1(), locMast.getCrnNo()) > 1; | 
|---|
|  |  |  | Integer nowQua = this.baseMapper.selectEmptyLocCount(locMast.getLocType1(), locMast.getLocType2(), locMast.getCrnNo()); | 
|---|
|  |  |  | boolean res = nowQua > quaOfBlank; | 
|---|
|  |  |  | if (!res) { | 
|---|
|  |  |  | log.warn("{}号堆垛机库位不足,因滞留空库位{}个,目前空库位{}个", locMast.getCrnNo(), quaOfBlank, nowQua); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return res; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Boolean checkEmptyCount0(LocMast locMast, int quaOfBlank) { | 
|---|
|  |  |  | if (locMast == null) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer nowQua = 0; | 
|---|
|  |  |  | nowQua = this.baseMapper.selectEmptyLocCount0(locMast.getLocType1(), locMast.getLocType2(), locMast.getCrnNo()); | 
|---|
|  |  |  | if (Cools.isEmpty(nowQua)) { | 
|---|
|  |  |  | nowQua = 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | boolean res = nowQua > quaOfBlank; | 
|---|
|  |  |  | if (!res) { | 
|---|
|  |  |  | log.warn("{}号堆垛机库位不足,因滞留空库位{}个,目前空库位{}个", locMast.getCrnNo(), quaOfBlank, nowQua); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return res; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | rows = locNos.stream().map(item -> Integer.parseInt(item.substring(0, 2))).distinct().collect(Collectors.toList()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        if (!rows.retainAll(new ArrayList<Integer>() {{ add(1);add(2);add(3);}}) | 
|---|
|  |  |  | //                || !rows.retainAll(new ArrayList<Integer>() {{ add(8);add(9);add(10);add(11);}}) | 
|---|
|  |  |  | //                || !rows.retainAll(new ArrayList<Integer>() {{ add(15);add(16);add(17);add(18);}}) | 
|---|
|  |  |  | //        ) { | 
|---|
|  |  |  | //            locNos.sort(Comparator.comparingInt(o -> Integer.parseInt(o.substring(0, 2)))); | 
|---|
|  |  |  | //        } else if (!rows.retainAll(new ArrayList<Integer>() {{ add(4);add(5);add(6);add(7);}}) | 
|---|
|  |  |  | //                || !rows.retainAll(new ArrayList<Integer>() {{ add(12);add(13);add(14);}}) | 
|---|
|  |  |  | //                || !rows.retainAll(new ArrayList<Integer>() {{ add(19);add(20);add(21);}}) | 
|---|
|  |  |  | //        ) { | 
|---|
|  |  |  | //            locNos.sort((o1, o2) -> Integer.parseInt(o2.substring(0, 2)) - Integer.parseInt(o1.substring(0, 2))); | 
|---|
|  |  |  | // plan first | 
|---|
|  |  |  | //        for (int i = 0; i<locNos.size(); i++) { | 
|---|
|  |  |  | //            LocMast locMast = this.selectById(locNos.get(i)); | 
|---|
|  |  |  | //            if (locMast.getLocSts().equals("O")) { | 
|---|
|  |  |  | //                if (i == 0) { | 
|---|
|  |  |  | //                    return locMast; | 
|---|
|  |  |  | //                } else { | 
|---|
|  |  |  | //                    LocMast lastLoc = this.selectById(locNos.get(i - 1)); | 
|---|
|  |  |  | //                    if (lastLoc.getLocSts().equals("F") || lastLoc.getLocSts().equals("D")  || lastLoc.getLocSts().equals("X")) { | 
|---|
|  |  |  | //                        return locMast; | 
|---|
|  |  |  | //                    } else { | 
|---|
|  |  |  | //                        break; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | for (int i = 0; i<locNos.size(); i++) { | 
|---|
|  |  |  | LocMast locMast = this.selectById(locNos.get(i)); | 
|---|
|  |  |  | //        return null; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // plan second | 
|---|
|  |  |  | LocMast finalRes = null; | 
|---|
|  |  |  | for (String locNo : locNos) { | 
|---|
|  |  |  | LocMast locMast = this.selectById(locNo); | 
|---|
|  |  |  | if(locMast == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (locMast.getLocSts().equals("O")) { | 
|---|
|  |  |  | if (i == 0) { | 
|---|
|  |  |  | return locMast; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | LocMast lastLoc = this.selectById(locNos.get(i - 1)); | 
|---|
|  |  |  | if (lastLoc.getLocSts().equals("F") || lastLoc.getLocSts().equals("D")  || lastLoc.getLocSts().equals("X")) { | 
|---|
|  |  |  | return locMast; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (finalRes == null) { | 
|---|
|  |  |  | finalRes = locMast; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (finalRes != null) { | 
|---|
|  |  |  | log.error("{}库位异常:{}库位状态为O.空库位,但{}库位状态为{}", finalRes.getLocNo(), finalRes.getLocNo(), locMast.getLocNo(), locMast.getLocSts()); | 
|---|
|  |  |  | finalRes = null; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (locMast.getLocSts().equals("R") || locMast.getLocSts().equals("P")) { | 
|---|
|  |  |  | finalRes = null; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | finalRes = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | return finalRes; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | this.baseMapper.updateLocSts(locNo,locSts); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> findOutMast(Short locType1, List<Integer> crnNos) { | 
|---|
|  |  |  | if (crnNos.size() == 0) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return this.baseMapper.findOutMast(locType1, crnNos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> findInEmptyLocMast(Short locType1, List<Integer> rows, Integer crnNo) { | 
|---|
|  |  |  | return this.baseMapper.findInEmptyLocMast(locType1, rows, crnNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> findInEmptyLocMastNew(Short locType1, List<String> locNos, Integer crnNo) { | 
|---|
|  |  |  | return this.baseMapper.findInEmptyLocMastNew(locType1, locNos, crnNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> findEmptyLocMastByLocNos(Short locType1, List<String> locNos, Integer crnNo) { | 
|---|
|  |  |  | return this.baseMapper.findEmptyLocMastByLocNos(locType1, locNos, crnNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> findEmptyLowFrequencyLocMast(Short locType1, Integer crnNo) { | 
|---|
|  |  |  | return this.baseMapper.findEmptyLowFrequencyLocMast(locType1, crnNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> findEmptyLocMast(Short locType1, Integer crnNo) { | 
|---|
|  |  |  | return this.baseMapper.findEmptyLocMast(locType1, crnNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> selectLocByLev(Integer lev) { | 
|---|
|  |  |  | return this.baseMapper.selectLocByLev(lev); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> selectByLocNos(List<String> locNos) { | 
|---|
|  |  |  | if (locNos == null || locNos.size() == 0) { | 
|---|
|  |  |  | return new ArrayList<LocMast>(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return this.baseMapper.selectByLocNos(locNos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|