| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | |
| | | import com.zy.core.model.LiftSlave; |
| | | import com.zy.core.model.ShuttleSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.LiftAssignCommand; |
| | | import com.zy.core.model.command.LiftCommand; |
| | | import com.zy.core.model.command.ShuttleAssignCommand; |
| | | import com.zy.core.model.command.ShuttleCommand; |
| | | import com.zy.core.model.command.*; |
| | | import com.zy.core.model.protocol.ForkLiftStaProtocol; |
| | | import com.zy.core.model.protocol.LiftProtocol; |
| | | import com.zy.core.model.protocol.ShuttleProtocol; |
| | |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | wrkMast.setWrkSts(WrkStsType.INBOUND_DEVICE_RUN.sts); |
| | | wrkMast.setModiTime(new Date()); |
| | | wrkMastService.updateById(wrkMast); |
| | | setLedData(wrkMast.getWrkNo(), wrkMast.getStaNo()); |
| | | |
| | | } else if (wrkMast != null && wrkMast.getWrkSts() != WrkStsType.NEW_INBOUND.sts) { |
| | | continue; |
| | | } |
| | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | setLedData(wrkMast.getWrkNo(), wrkMast.getStaNo()); |
| | | |
| | | } else { |
| | | String msg = jsonObject.getString("msg"); |
| | |
| | | wrkMast.setModiTime(new Date()); |
| | | wrkMast.setShuttleNo(null); |
| | | wrkMastService.updateById(wrkMast); |
| | | setLedData(wrkMast.getWrkNo(), wrkMast.getStaNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private void setLedData(Integer wrkNo, Integer staNo) { |
| | | try { |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("taskNo", wrkNo); |
| | | String response = null; |
| | | response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/led/getTask2") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | String data = jsonObject.getString("data"); |
| | | List<LedCommand> wrkDetls = JSONArray.parseArray(data, LedCommand.class); |
| | | commands.addAll(wrkDetls); |
| | | redisUtil.set("LED_" + staNo, commands, 10); |
| | | log.info("电视机数据设置:{}", data); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 初始化实时地图 |
| | |
| | | |
| | | staProtocol = staProtocol.clone(); |
| | | staProtocol.setStaNo(staNo); |
| | | staProtocol.setWorkNo(wrkMast.getMainWrkNo().shortValue()); |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); |
| | | |
| | | wrkMast.setWrkSts(WrkStsType.INBOUND_DEVICE_RUN.sts); |
| | |
| | | return false; |
| | | } |
| | | } else if (sourceStaNo == 1012) { |
| | | if (staProtocol.getWorkNo().intValue() != wrkMast.getWrkNo()) { |
| | | if (staProtocol.getFinishWorkNo().intValue() != wrkMast.getWrkNo()) { |
| | | News.info("{}任务,{}站点,任务号不一致", wrkMast.getWrkNo(), staProtocol.getSiteId()); |
| | | return false; |
| | | } |
| | |
| | | } else if (wrkMast.getSourceStaNo() == 1032) { |
| | | locNo = "0200308"; |
| | | } |
| | | boolean dispatchShuttle = shuttleDispatchUtils.searchDispatchShuttleS(wrkMast.getWrkNo(), locNo, wrkMast.getLocNo(), "TRANSPORT_LIFT"); |
| | | boolean dispatchShuttle = shuttleDispatchUtils.searchDispatchShuttleNoLift(wrkMast.getWrkNo(), locNo, wrkMast.getLocNo(), "TRANSPORT_LIFT"); |
| | | if (!dispatchShuttle) { |
| | | News.info("{}任务,调度小车失败", wrkMast.getWrkNo()); |
| | | return false; |
| | |
| | | Integer sourceLev = liftThread.getLevToStaNo(Utils.getLev(wrkMast.getSourceLocNo())); |
| | | |
| | | //获取提升机命令 |
| | | List<LiftCommand> liftCommands = liftThread.getPalletOutCommand(wrkMast.getMainWrkNo(), sourceLev, wrkMast.getStaNo()); |
| | | List<LiftCommand> liftCommands = liftThread.getPalletOutCommand(wrkMast.getWrkNo(), sourceLev, wrkMast.getStaNo()); |
| | | LiftCommand liftCommand = liftCommands.get(0); |
| | | // if (wrkMast.getMainWrkNo() != null) { |
| | | liftCommand.setTaskNo(wrkMast.getMainWrkNo()); |
| | | liftCommand.setTaskNo(wrkMast.getWrkNo()); |
| | | // } else { |
| | | // int deviceWrk = commonService.getWorkNo(8);//生成提升机设备工作号 |
| | | // liftCommand.setTaskNo(deviceWrk);//更换随机任务号 |
| | |
| | | LiftAssignCommand assignCommand = new LiftAssignCommand(); |
| | | assignCommand.setCommands(commands); |
| | | assignCommand.setLiftNo(liftProtocol.getLiftNo().shortValue()); |
| | | assignCommand.setTaskNo(wrkMast.getMainWrkNo().shortValue()); |
| | | assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); |
| | | assignCommand.setTaskMode(LiftCommandModeType.PALLET_OUT.id.shortValue()); |
| | | |
| | | wrkMast.setWrkSts(WrkStsType.OUTBOUND_LIFT_RUN.sts); |
| | |
| | | wrkMast.setModiTime(now); |
| | | |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | setLedData(wrkMast.getWrkNo(), wrkMast.getStaNo()); |
| | | //下发任务 |
| | | liftAction.assignWork(wrkMast.getLiftNo(), assignCommand); |
| | | return false; |