|  |  | 
 |  |  | 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) { | 
 |  |  |             if (locTypeDto.getLocType2() == 2) { | 
 |  |  |                 //尝试找1号弯轨堆垛机库位 | 
 |  |  | 
 |  |  |             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(); | 
 |  |  |  | 
 |  |  |         // 生成工作号 |