| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.Arith; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.result.FindLocNoAttributeVo; |
| | | import com.zy.asrs.entity.result.KeyValueVo; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.Shelves; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | /** |
| | | * 生成工作号 |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | Config crnSearchListConfig = configService.selectConfigByCode("123CrnSearchList"); |
| | | int crnSearchList = Integer.parseInt(crnSearchListConfig.getValue()); |
| | | |
| | | //此程序用于优化堆垛机异常时的运行时间 |
| | | for (int i = times; i < crnNumber * 2; i++) { |
| | | int[] locNecessaryParameters = Utils.LocNecessaryParameters(rowLastno, curRow, crnNumber); |
| | |
| | | times++; |
| | | } |
| | | } |
| | | |
| | | //优化系统,提高搜索1号堆垛机次数 |
| | | if (crnNo == 2 || crnNo == 3) { |
| | | if (crnSearchList >= 2) { |
| | | //尝试找1号弯轨堆垛机库位 |
| | | crnNo = 1; |
| | | if (basCrnpService.checkSiteError(crnNo, true)) { |
| | | List<Integer> nearRowList = new ArrayList<Integer>(){{add(4);add(6);add(3);add(1);}}; |
| | | for (Integer near : nearRowList) { |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("row1", near) |
| | | .eq("loc_sts", "O") |
| | | .eq("whs_type", rowLastnoType.getType().longValue()) |
| | | .eq("loc_type1", locTypeDto.getLocType1()) |
| | | .eq("loc_type2", locTypeDto.getLocType2()) |
| | | ); |
| | | int crnCountO = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).le("io_type", 100)); |
| | | if (locMasts.size() - crnCountO <= 2) { |
| | | log.error(crnNo + "号堆垛机没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times); |
| | | }else { |
| | | nearRow = near; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (nearRow == 0) { |
| | | throw new CoolException("无可用堆垛机"); |
| | | if (locTypeDto.getLocType2() == 2) { |
| | | //尝试找1号弯轨堆垛机库位 |
| | | crnNo = 1; |
| | | if (basCrnpService.checkSiteError(crnNo, true)) { |
| | | List<Integer> nearRowList = new ArrayList<Integer>(){{add(4);add(6);add(3);add(1);}}; |
| | | for (Integer near : nearRowList) { |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("row1", near) |
| | | .eq("loc_sts", "O") |
| | | .eq("whs_type", rowLastnoType.getType().longValue()) |
| | | .eq("loc_type1", locTypeDto.getLocType1()) |
| | | .eq("loc_type2", locTypeDto.getLocType2()) |
| | | ); |
| | | int crnCountO = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).le("io_type", 100)); |
| | | if (locMasts.size() - crnCountO <= 2) { |
| | | log.error(crnNo + "号堆垛机没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times); |
| | | }else { |
| | | nearRow = near; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (nearRow == 0) { |
| | | throw new CoolException("无可用堆垛机"); |
| | | } |
| | | }else { |
| | | throw new CoolException("无可用堆垛机"); |
| | | } |
| | | } |
| | | |
| | | boolean signRule1 = false; |
| | |
| | | .eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())); |
| | | for (LocMast locMast1 : locMasts) { |
| | | if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) { |
| | | continue; |
| | | } |
| | | |
| | | if (crnNo == 1) { |
| | | if (locMast1.getRow1() == 1 || locMast1.getRow1() == 6) { |
| | | locMast = locMast1;//单深库位直接使用 |
| | | break; |
| | | } |
| | | |
| | | //获取目标库位所在巷道最浅非空库位 |
| | | List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("whs_type", rowLastnoType.getType().longValue()) |
| | | .eq("crn_no", locMast1.getCrnNo()) |
| | | .eq("bay1", locMast1.getBay1()) |
| | | .notIn("loc_sts", "O") |
| | | .orderBy("row1", false) |
| | | ); |
| | | if (locMastList.isEmpty()) { |
| | | locMast = locMast1; |
| | | break; |
| | | } |
| | | |
| | | LocMast locMastF = locMastList.get(0); |
| | | if (!slaveProperties.getDoubleLocs().contains(locMastF.getRow1())) { |
| | | continue; |
| | | } |
| | | |
| | | LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no", locMastF.getLocNo())); |
| | | if (!Cools.isEmpty(locDetl) && findLocNoAttributeVo.beSimilar(locDetl)) { |
| | | String shallowLoc = Utils.getShallowLoc(slaveProperties, locMastF.getLocNo()); |
| | | LocMast shallowLocMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", shallowLoc) |
| | | .eq("loc_sts", "O") |
| | | ); |
| | | if(shallowLocMast != null) { |
| | | locMast = shallowLocMast; |
| | | break; |
| | | } |
| | | } |
| | | continue; |
| | | } |
| | | |
| | |
| | | log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times); |
| | | throw new CoolException("没有空库位"); |
| | | } |
| | | |
| | | if (crnNo == 2 || crnNo == 3) { |
| | | crnSearchList++; |
| | | configService.updateValue("123CrnSearchList", String.valueOf(crnSearchList)); |
| | | } |
| | | |
| | | if (crnNo == 1) { |
| | | configService.updateValue("123CrnSearchList", String.valueOf(0)); |
| | | } |
| | | |
| | | String locNo = locMast.getLocNo(); |
| | | |
| | | // 生成工作号 |