|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.wcs.core.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.zy.asrs.framework.common.Cools; | 
|---|
|  |  |  | import com.zy.asrs.wcs.core.entity.Task; | 
|---|
|  |  |  | import com.zy.asrs.wcs.core.kernel.AnalyzeService; | 
|---|
|  |  |  | import com.zy.asrs.wcs.core.model.enums.TaskStsType; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.wcs.rcs.News; | 
|---|
|  |  |  | import com.zy.asrs.wcs.core.entity.Motion; | 
|---|
|  |  |  | import com.zy.asrs.wcs.core.service.MotionService; | 
|---|
|  |  |  | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; | 
|---|
|  |  |  | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; | 
|---|
|  |  |  | import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol; | 
|---|
|  |  |  | import com.zy.asrs.wcs.rcs.thread.DevpThread; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 出库 ====>> 同一时间一台穿梭车只能有一个出库任务 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public synchronized void generateOutboundWrkMast() { | 
|---|
|  |  |  | List<Task> tasks = taskService.selectPakOut(); | 
|---|
|  |  |  | if (tasks.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (Task task : tasks) { | 
|---|
|  |  |  | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); | 
|---|
|  |  |  | StaProtocol staProtocol = devpThread.getStation().get(Integer.parseInt(task.getOriginSite()));//源站 | 
|---|
|  |  |  | StaProtocol staProtocol1 = devpThread.getStation().get(Integer.parseInt(task.getDestSite()));//目标站 | 
|---|
|  |  |  | if (staProtocol == null || staProtocol1 == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | staProtocol = staProtocol.clone(); | 
|---|
|  |  |  | staProtocol1 = staProtocol1.clone(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //            // 查询站点详细信息 | 
|---|
|  |  |  | //            BasDevp staDetl = basDevpService.selectById(outSta.getStaNo()); | 
|---|
|  |  |  | //            if (staDetl == null) { | 
|---|
|  |  |  | //                log.error("出库 ===>> 站点在数据库不存在, 站点编号={}", outSta.getStaNo()); | 
|---|
|  |  |  | //                continue; | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | // 判断堆垛机出库站状态 | 
|---|
|  |  |  | if (staProtocol.isAutoing() && !staProtocol.isLoading() && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!(staProtocol1.isAutoing() && !staProtocol1.isLoading() && staProtocol1.getWorkNo() == 0 && staProtocol1.isOutEnable())) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                //同库位组校验 | 
|---|
|  |  |  | //                List<String> outerLoc = Utils.getGroupOuterLoc(wrkMast.getSourceLocNo()); | 
|---|
|  |  |  | //                List<LocMast> outerLocMasts = locMastService.selectNotEmptyLocNos(outerLoc); | 
|---|
|  |  |  | //                if (!outerLocMasts.isEmpty()) { | 
|---|
|  |  |  | //                    News.info("{}任务,浅库位存在货物,系统等待中", wrkMast.getWrkNo()); | 
|---|
|  |  |  | //                    continue;//浅库位存在未执行任务 | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // generate motion list | 
|---|
|  |  |  | List<Motion> motionList = analyzeService.generateMotion(task); | 
|---|
|  |  |  | if (Cools.isEmpty(motionList)) { | 
|---|
|  |  |  | log.error("出库 ===>> 暂时没有空闲小车, 任务号={}", task.getTaskNo()); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 更新工作主档 | 
|---|
|  |  |  | task.setTaskSts(TaskStsType.ANALYZE_OUTBOUND.sts); // 工作状态 | 
|---|
|  |  |  | task.setUpdateTime(new Date()); | 
|---|
|  |  |  | if (!taskService.updateById(task)) { | 
|---|
|  |  |  | News.error("更新工作档失败!!! [工作号:{}]", task.getTaskNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|