| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.StaDescService; |
| | | import com.zy.asrs.service.TaskWrkService; |
| | | import com.zy.asrs.utils.CommandUtils; |
| | | import com.zy.asrs.service.ToWmsService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.CrnTaskModeType; |
| | | import com.zy.core.enums.SlaveType; |
| | |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | |
| | | |
| | | @Autowired |
| | | private CommonService commonService; |
| | | |
| | | @Autowired |
| | | private StaDescService staDescService; |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | @Value("${wms.taskStatusFeedbackPath}") |
| | | private String taskStatusFeedbackPath; |
| | | |
| | | |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | |
| | | |
| | | @Autowired |
| | | private ToWmsService toWmsService; |
| | | |
| | | @Override |
| | | public TaskWrk selectByTaskNo(String taskNo) { |
| | |
| | | taskWrk.setCrnNo(staDesc.getCrnNo());//堆垛机号 |
| | | taskWrk.setModiTime(new Date()); |
| | | taskWrk.setModiUser(userId); |
| | | updateById(taskWrk); |
| | | super.updateById(taskWrk); |
| | | |
| | | CrnSlave.CrnStn crnStn = Utils.getCrnStnByStaNo(staDesc.getCrnStn(), true); |
| | | if (crnStn == null) { |
| | |
| | | crnCommand.setDestinationPosY(Utils.getBayShort(taskWrk.getTargetPoint())); // 目标库位层 |
| | | crnCommand.setDestinationPosZ(Utils.getLevShort(taskWrk.getTargetPoint())); // 目标库位排 |
| | | crnCommand.setCommand((short) 1); |
| | | if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(5, crnCommand), false)) { |
| | | if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(5, crnCommand))) { |
| | | log.error("堆垛机命令生成失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | throw new CoolException("堆垛机命令生成失败"); |
| | | } else { |
| | | try { |
| | | HashMap<String, Object> headParam = new HashMap<>(); |
| | | headParam.put("taskNo", taskWrk.getTaskNo()); |
| | | headParam.put("status", taskWrk.getStatus()); |
| | | headParam.put("ioType", taskWrk.getIoType()); |
| | | headParam.put("barcode", taskWrk.getBarcode()); |
| | | // headParam.put("reportTime",new Date()); |
| | | String response; |
| | | response = new HttpHandler.Builder() |
| | | // .setHeaders(headParam) |
| | | .setUri(wmsUrl) |
| | | .setPath(taskStatusFeedbackPath) |
| | | .setJson(JSON.toJSONString(headParam)) |
| | | .build() |
| | | .doPost(); |
| | | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | apiLogService.save("wcs派发入库任务上报wms" |
| | | , wmsUrl + taskStatusFeedbackPath |
| | | , null |
| | | , "127.0.0.1" |
| | | , JSON.toJSONString(headParam) |
| | | , response |
| | | , true |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("wcs派发入库任务上报wms失败", taskWrk); |
| | | // throw new CoolException("wcs派发入库任务上报wms失败"); |
| | | } |
| | | |
| | | toWmsService.addReportLog(taskWrk); |
| | | } |
| | | } |
| | | |
| | |
| | | taskWrk.setCrnNo(staDesc.getCrnNo());//堆垛机号 |
| | | taskWrk.setModiTime(new Date()); |
| | | taskWrk.setModiUser(userId); |
| | | updateById(taskWrk); |
| | | super.updateById(taskWrk); |
| | | |
| | | CrnSlave.CrnStn crnStn = Utils.getCrnStnByStaNo(staDesc.getCrnStn(), false); |
| | | if (crnStn == null) { |
| | |
| | | crnCommand.setDestinationPosY(crnStn.getLev().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(crnStn.getRow().shortValue()); // 目标库位层 |
| | | crnCommand.setCommand((short) 1); |
| | | if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(5, crnCommand))) { |
| | | if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(5, crnCommand))) { |
| | | log.error("堆垛机命令生成失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | throw new CoolException("堆垛机命令生成失败"); |
| | | } |
| | |
| | | StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()).clone(); |
| | | staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo((short) Integer.parseInt(taskWrk.getTargetPoint())); |
| | | if (!CommandUtils.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(3, staProtocol))) { |
| | | if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(3, staProtocol))) { |
| | | log.error("输送线命令生成失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | throw new CoolException("输送线命令生成失败"); |
| | | } |
| | |
| | | //taskWrk.setCrnNo(staDesc.getCrnNo());//堆垛机号 |
| | | taskWrk.setModiTime(new Date()); |
| | | taskWrk.setModiUser(userId); |
| | | updateById(taskWrk); |
| | | super.updateById(taskWrk); |
| | | } |
| | | |
| | | @Override |