| | |
| | | package com.zy.common.service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.domain.param.*; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.utils.NavigateUtils; |
| | | import com.zy.core.News; |
| | | import com.zy.core.enums.WrkIoType; |
| | | import com.zy.core.enums.WrkStsType; |
| | | import com.zy.core.model.StationObjModel; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | private WrkLastnoService wrkLastnoService; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private BasCrnpService basCrnpService; |
| | | @Autowired |
| | | private NavigateUtils navigateUtils; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | |
| | | /** |
| | | * 生成工作号 |
| | |
| | | } |
| | | } |
| | | return workNo; |
| | | } |
| | | |
| | | //检测工作号是否在指定类型工作范围内 |
| | | public synchronized boolean checkWorkNoContainMk(Integer workNo, Integer wrkMk) { |
| | | WrkLastno wrkLastno = wrkLastnoService.selectById(wrkMk); |
| | | if (Cools.isEmpty(wrkLastno)) { |
| | | throw new CoolException("数据异常,请联系管理员"); |
| | | } |
| | | |
| | | int sNo = wrkLastno.getSNo(); |
| | | int eNo = wrkLastno.getENo(); |
| | | if (workNo >= sNo && workNo <= eNo) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public static String zerofill(String msg, Integer count) { |
| | | if (msg.length() == count) { |
| | | return msg; |
| | | } else if (msg.length() > count) { |
| | | return msg.substring(0, 16); |
| | | } else { |
| | | StringBuilder msgBuilder = new StringBuilder(msg); |
| | | for(int i = 0; i < count - msg.length(); ++i) { |
| | | msgBuilder.insert(0, "0"); |
| | | } |
| | | return msgBuilder.toString(); |
| | | } |
| | | } |
| | | |
| | | public boolean completeTask(CompleteTaskParam param) { |
| | |
| | | } |
| | | |
| | | double ioPri = 800D; |
| | | if(param.getTaskNo()!=null){ |
| | | if (param.getTaskPri() != null) { |
| | | ioPri = param.getTaskPri().doubleValue(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | double ioPri = 100D; |
| | | if(param.getTaskNo()!=null){ |
| | | if (param.getTaskPri() != null) { |
| | | ioPri = param.getTaskPri().doubleValue(); |
| | | } |
| | | |
| | | Integer crnNo = commonService.findCrnNoByLocNo(locMast.getLocNo()); |
| | | if (crnNo == null) { |
| | | throw new CoolException("未找到对应堆垛机"); |
| | | } |
| | | |
| | | // 获取工作号 |
| | |
| | | wrkMast.setSourceStaNo(param.getSourceStaNo());//源站 |
| | | wrkMast.setStaNo(param.getStaNo());//目标站 |
| | | wrkMast.setWmsWrkNo(param.getTaskNo()); |
| | | wrkMast.setBarcode(param.getBarcode()); |
| | | wrkMast.setCrnNo(crnNo); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiTime(now); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | |
| | | } |
| | | |
| | | double ioPri = 100D; |
| | | if(param.getTaskNo()!=null){ |
| | | if (param.getTaskPri() != null) { |
| | | ioPri = param.getTaskPri().doubleValue(); |
| | | } |
| | | |
| | | Integer crnNo = commonService.findCrnNoByLocNo(locMast.getLocNo()); |
| | | if (crnNo == null) { |
| | | throw new CoolException("未找到对应堆垛机"); |
| | | } |
| | | |
| | | // 获取工作号 |
| | |
| | | wrkMast.setIoType(WrkIoType.OUT.id); // 入出库状态: 101.出库 |
| | | wrkMast.setIoPri(ioPri); |
| | | wrkMast.setSourceLocNo(param.getSourceLocNo()); // 源库位 |
| | | wrkMast.setSourceStaNo(param.getSourceStaNo());//源站 |
| | | wrkMast.setStaNo(param.getStaNo());//目标站 |
| | | wrkMast.setWmsWrkNo(param.getTaskNo()); |
| | | wrkMast.setBarcode(param.getBarcode()); |
| | | wrkMast.setCrnNo(crnNo); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiTime(now); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | |
| | | return true; |
| | | } |
| | | |
| | | public Integer findCrnNoByLocNo(String locNo) { |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | String controlRows = basCrnp.getControlRows(); |
| | | if (Cools.isEmpty(controlRows)) { |
| | | continue; |
| | | } |
| | | |
| | | List<Integer> rowList = JSON.parseArray(controlRows, Integer.class); |
| | | if(rowList.contains(Utils.getRow(locNo))) { |
| | | return basCrnp.getCrnNo(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public Integer findInStationId(Integer crnNo, Integer sourceStationId) { |
| | | BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", crnNo)); |
| | | if(basCrnp == null) { |
| | | return null; |
| | | } |
| | | |
| | | Integer targetStationId = null; |
| | | List<StationObjModel> stationList = basCrnp.getInStationList$(); |
| | | for (StationObjModel stationObjModel : stationList) { |
| | | try { |
| | | String startLev = String.valueOf(sourceStationId).substring(0, 1); |
| | | List<NavigateNode> navigateNodes = navigateUtils.calcByStationId(Integer.parseInt(startLev), sourceStationId, stationObjModel.getStationId()); |
| | | if(navigateNodes != null) { |
| | | targetStationId = stationObjModel.getStationId(); |
| | | break; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return targetStationId; |
| | | } |
| | | |
| | | public Integer findOutStationId(Integer crnNo, Integer targetStationId) { |
| | | BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", crnNo)); |
| | | if(basCrnp == null) { |
| | | return null; |
| | | } |
| | | |
| | | Integer finalSourceStationId = null; |
| | | List<StationObjModel> stationList = basCrnp.getOutStationList$(); |
| | | for (StationObjModel stationObjModel : stationList) { |
| | | try { |
| | | String startLev = String.valueOf(targetStationId).substring(0, 1); |
| | | List<NavigateNode> navigateNodes = navigateUtils.calcByStationId(Integer.parseInt(startLev), stationObjModel.getStationId(), targetStationId); |
| | | if(navigateNodes != null) { |
| | | finalSourceStationId = stationObjModel.getStationId(); |
| | | break; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return finalSourceStationId; |
| | | } |
| | | |
| | | } |