| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.controller.CrnController; |
| | | import com.zy.asrs.controller.OpenController; |
| | | import com.zy.asrs.controller.SiteController; |
| | | import com.zy.asrs.domain.dto.NotifyCustomDataDto; |
| | | import com.zy.asrs.domain.enums.NotifyMsgType; |
| | | import com.zy.asrs.domain.enums.TaskStatusType; |
| | | import com.zy.asrs.domain.enums.WorkNoType; |
| | | import com.zy.asrs.domain.param.CrnOperatorParam; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.Result; |
| | | import com.zy.asrs.entity.param.StorageEscalationParam; |
| | | import com.zy.asrs.entity.param.TaskOverToWms; |
| | | import com.zy.asrs.mapper.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.CommandUtils; |
| | | import com.zy.asrs.utils.CrnOperaUtils; |
| | | import com.zy.asrs.utils.NotifyUtils; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | |
| | | import com.zy.core.model.CrnSlave; |
| | | import com.zy.core.model.DevpSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.CommandPackage; |
| | | import com.zy.core.model.command.CrnCommand; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.BarcodeThread; |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import lombok.Synchronized; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | |
| | | /** |
| | | * 立体仓库WCS系统主流程业务 |
| | |
| | | |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private WrkMastMapper wrkMastMapper; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | |
| | | private StaDescMapper staDescMapper; |
| | | @Autowired |
| | | private CommandInfoService commandInfoService; |
| | | |
| | | @Autowired |
| | | private OpenServiceImpl openServiceImpl; |
| | | @Autowired |
| | | private StaDescService staDescService; |
| | | |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | @Autowired |
| | | private CrnOperaUtils crnOperaUtils; |
| | | @Autowired |
| | | private NotifyUtils notifyUtils; |
| | | @Value("${wms.count}") |
| | | private Integer maxCount; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | @Value("${wms.inboundTaskApplyPath}") |
| | | private String inboundTaskApplyPath; |
| | | @Value("${wms.TaskExecCallback}") |
| | | private String TaskExecCallback; |
| | | @Value("${wms.taskStatusFeedbackPath}") |
| | | private String taskStatusFeedbackPath; |
| | | @Autowired |
| | | private CrnController crnController; |
| | | @Autowired |
| | | private SiteController siteController; |
| | | @Synchronized |
| | | public void shiftTargetToCyclePoint() throws IOException, InterruptedException { |
| | | try { |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | for (DevpSlave.Sta outSta : devp.getOutSta()) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | if (devpThread == null) { |
| | | continue; |
| | | } |
| | | private String taskExecCallback; |
| | | |
| | | StaProtocol staProtocol = getClonedStation(devpThread, outSta.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 获取其他相关站点 |
| | | StaProtocol staProtocol1 = getClonedStation(devpThread, 1001); |
| | | StaProtocol staProtocol2 = getClonedStation(devpThread, 1002); |
| | | StaProtocol staProtocol3 = getClonedStation(devpThread, 1003); |
| | | StaProtocol staProtocol4 = getClonedStation(devpThread, 1004); |
| | | StaProtocol staProtocol6 = getClonedStation(devpThread, 111); |
| | | |
| | | boolean result = false; |
| | | switch (outSta.getStaNo()) { |
| | | case 105: |
| | | result = (staProtocol1 != null && staProtocol1.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 105); |
| | | break; |
| | | case 107: |
| | | result = (staProtocol2 != null && staProtocol2.isLoading()); |
| | | break; |
| | | case 109: |
| | | result = (staProtocol3 != null && staProtocol3.isLoading()); |
| | | break; |
| | | case 110: |
| | | result = ((staProtocol4 != null && staProtocol4.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 110) || |
| | | (staProtocol6 != null && staProtocol6.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 111)); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | if (result) { |
| | | if (staProtocol.getSiteId() == 107 || staProtocol.getSiteId() == 109) { |
| | | StaProtocol staProtocol5 = getClonedStation(devpThread, staProtocol.getSiteId() - 1); |
| | | if (staProtocol5 != null && (staProtocol5.isLoading() && (staProtocol5.getStaNo() == 107 || staProtocol5.getStaNo() == 109))) { |
| | | short workNo = staProtocol5.getWorkNo(); |
| | | staProtocol5.setWorkNo(workNo); |
| | | staProtocol5.setStaNo((short) 112); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol5)); |
| | | } |
| | | } else { |
| | | if(staProtocol.isLoading() && (staProtocol.getStaNo() == 105 || staProtocol.getStaNo() == 110 || staProtocol.getStaNo() == 111)){ |
| | | short workNo = staProtocol.getWorkNo(); |
| | | staProtocol.setWorkNo(workNo); |
| | | staProtocol.setStaNo((short) 112); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("shiftTargetToCyclePoint error", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取站点并克隆 |
| | | */ |
| | | private StaProtocol getClonedStation(DevpThread devpThread, int staNo) { |
| | | StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | return (staProtocol != null) ? staProtocol.clone() : null; |
| | | } |
| | | |
| | | // 112循环站点至出库站 |
| | | public synchronized void shiftCyclePointToTarget() throws IOException, InterruptedException { |
| | | try { |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | if (devpThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | StaProtocol staProtocol = devpThread.getStation().get(112); |
| | | if (staProtocol.getStaNo() != 112 || staProtocol.getWorkNo() == 0 || !staProtocol.isLoading() || staProtocol.getWorkNo() > 9000 || staProtocol.getWorkNo() < 6000) { |
| | | continue; |
| | | } |
| | | // 查询任务信息 |
| | | TaskWrk taskWrk = taskWrkMapper.selectStaWorking(Integer.valueOf(staProtocol.getWorkNo())); |
| | | if (taskWrk == null || taskWrk.getWrkNo() < 6001 || taskWrk.getWrkNo() > 9000) { |
| | | continue; |
| | | } |
| | | |
| | | short workNo = staProtocol.getWorkNo(); |
| | | // 再写入目标站点 |
| | | staProtocol.setWorkNo(workNo); |
| | | staProtocol.setStaNo(Short.valueOf(taskWrk.getTargetPoint())); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol)); |
| | | Thread.sleep(200); |
| | | |
| | | log.info("Shifted from cycle station 112 to target {}, workNo: {}", taskWrk.getTargetPoint(), workNo); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("shiftCyclePointToTarget error", e); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | public synchronized void generateStoreWrkFile1() throws IOException, InterruptedException { |
| | | public synchronized void generateStoreWrkFile1() { |
| | | try { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历入库口 |
| | | for (DevpSlave.Sta inSta : devp.getInSta()) { |
| | | StorageEscalationParam storageEscalationParam = new StorageEscalationParam(); |
| | | // 获取入库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); |
| | |
| | | if (barcodeThread == null) { |
| | | continue; |
| | | } |
| | | String BoxNo = barcodeThread.getBarcode(); |
| | | TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("barcode", BoxNo)); |
| | | if (!Cools.isEmpty(taskWrk1)) { |
| | | log.info("托盘码:" + BoxNo + "任务档存在"); |
| | | if (taskWrk1.getIoType() == 1 && taskWrk1.getStartPoint().equals(staProtocol.getSiteId().toString())) { |
| | | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("crn_no", taskWrk1.getCrnNo()).eq("type_no", 1).eq("stn_no", staProtocol.getSiteId())); |
| | | if (Cools.isEmpty(staDesc)) { |
| | | return; |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | String barcode = barcodeThread.getBarcode(); |
| | | TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("barcode", barcode)); |
| | | if (taskWrk1 != null) { |
| | | log.info("托盘码:" + barcode + "任务档存在"); |
| | | continue; |
| | | } |
| | | |
| | | HashMap<String, Object> requestParam = new HashMap<>(); |
| | | requestParam.put("barcode", barcode);//托盘码 |
| | | requestParam.put("stationCode", inSta.getStaNo());//入库口 |
| | | if (back) { |
| | | storageEscalationParam.setWCSStatus(1); |
| | | storageEscalationParam.setWCSErrorMessage(storageEscalationParam.getWCSErrorMessage() + errMsg); |
| | | requestParam.put("wcsStatus", 1);//失败 |
| | | requestParam.put("wcsErrorMessage", errMsg);//失败原因 |
| | | }else { |
| | | requestParam.put("wcsStatus", 0);//成功 |
| | | } |
| | | log.info("组托入库={}", storageEscalationParam); |
| | | storageEscalationParam.setBoxNo(BoxNo); |
| | | |
| | | String response = ""; |
| | | Boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath(inboundTaskApplyPath) |
| | | .setJson(JSON.toJSONString(storageEscalationParam)) |
| | | .setJson(JSON.toJSONString(requestParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if(back){ |
| | | if(staProtocol.getWorkNo()>=9801&&staProtocol.getWorkNo()<=9825){ |
| | | staProtocol.setStaNo((short)105); |
| | | } else if (staProtocol.getWorkNo()>=9826&&staProtocol.getWorkNo()<=9850) { |
| | | staProtocol.setStaNo((short)107); |
| | | }else if (staProtocol.getWorkNo()>=9851&&staProtocol.getWorkNo()<=9875) { |
| | | staProtocol.setStaNo((short)109); |
| | | }else{ |
| | | staProtocol.setStaNo((short)110); |
| | | } |
| | | |
| | | if (back) { |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | }else{ |
| | | if (!Cools.isEmpty(response)&&!Cools.isEmpty(jsonObject.get("ReturnStatus"))&&jsonObject.get("ReturnStatus").equals(0) && !Cools.isEmpty(jsonObject.get("Result").toString())) { |
| | | Result result = JSON.parseObject(jsonObject.get("Result").toString(), Result.class); |
| | | // 创新一个入库工作档 |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(result.getTaskNo()); |
| | | if (Cools.isEmpty(taskWrk)) { |
| | | taskWrk = createTask1(result, BoxNo); |
| | | if (Cools.isEmpty(taskWrk)) { |
| | | log.error("库位异常,库位号:={}", taskWrk.getOriginTargetPoint()); |
| | | } else { |
| | | taskWrkService.insert(taskWrk); |
| | | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("crn_no", taskWrk.getCrnNo()).eq("type_no", 1).eq("stn_no", staProtocol.getSiteId())); |
| | | staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(staDesc.getCrnStn().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | hashMap.put("TaskNo",taskWrk.getTaskNo()); |
| | | try { |
| | | //开始上报,任务开始时,WCS回调WMS |
| | | response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath(taskStatusFeedbackPath) |
| | | .setJson(JSON.toJSONString(hashMap)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject1 = JSON.parseObject(response); |
| | | Boolean bool = false; |
| | | if(jsonObject1.get("ReturnStatus").equals(0)){ |
| | | taskWrk.setStatus(2);//派发任务 |
| | | bool = true; |
| | | taskWrkService.updateById(taskWrk); |
| | | } |
| | | apiLogService.save("wcs开始入库任务上报wms" |
| | | , wmsUrl + TaskExecCallback |
| | | , null |
| | | , "127.0.0.1" |
| | | , JSON.toJSONString(hashMap) |
| | | , response |
| | | , bool |
| | | ); |
| | | } catch (Exception e) { |
| | | continue; |
| | | } |
| | | |
| | | } |
| | | } |
| | | } else { |
| | | // staProtocol.setWorkNo((short) 9991); |
| | | if(staProtocol.getWorkNo()>=9801&&staProtocol.getWorkNo()<=9825){ |
| | | staProtocol.setStaNo((short)105); |
| | | } else if (staProtocol.getWorkNo()>=9826&&staProtocol.getWorkNo()<=9850) { |
| | | staProtocol.setStaNo((short)107); |
| | | }else if (staProtocol.getWorkNo()>=9851&&staProtocol.getWorkNo()<=9875) { |
| | | staProtocol.setStaNo((short)109); |
| | | }else{ |
| | | staProtocol.setStaNo((short)110); |
| | | } |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | } |
| | | JSONObject result = jsonObject.getJSONObject("data"); |
| | | Integer resultWrkNo = result.getInteger("wrkNo"); |
| | | Integer resultStaNo = result.getInteger("staNo"); |
| | | String resultLocNo = result.getString("locNo"); |
| | | |
| | | } else { |
| | | // staProtocol.setWorkNo((short) 9991); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | } |
| | | // 创新一个入库工作档 |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(String.valueOf(resultWrkNo)); |
| | | if(taskWrk != null) { |
| | | log.info("任务:" + resultWrkNo + "已经存在"); |
| | | continue; |
| | | } |
| | | |
| | | LocMast locMast = locMastService.selectByLocNo(resultLocNo); |
| | | if (locMast == null) { |
| | | log.info(resultLocNo + "库位不存在"); |
| | | continue; |
| | | } |
| | | |
| | | if (!locMast.getLocSts().equals("O")) { |
| | | log.info(resultLocNo + "库位不处于空库位"); |
| | | continue; |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | taskWrk = new TaskWrk(); |
| | | taskWrk.setTaskNo(String.valueOf(resultWrkNo));//任务号 |
| | | taskWrk.setWrkNo(commonService.getWorkNo(WorkNoType.PAKIN.type));//获取入库工作号 |
| | | taskWrk.setStatus(TaskStatusType.RECEIVE.id);//任务状态:接收 |
| | | taskWrk.setWrkSts(2);//2.设备上走 |
| | | taskWrk.setCreateTime(now); |
| | | taskWrk.setIoType(1);//任务类型 |
| | | taskWrk.setIoPri(13);//优先级 |
| | | taskWrk.setBarcode(barcode);//条码 |
| | | taskWrk.setCrnNo(locMast.getCrnNo()); |
| | | taskWrk.setTargetPoint(resultLocNo); |
| | | taskWrk.setStartPoint(String.valueOf(staProtocol.getStaNo())); |
| | | if (!Cools.isEmpty(taskWrk.getTargetPoint())) { |
| | | taskWrk.setOriginTargetPoint(taskWrk.getTargetPoint()); |
| | | } |
| | | |
| | | if (!taskWrkService.insert(taskWrk)) { |
| | | log.info("任务:" + resultWrkNo + "任务创建失败"); |
| | | continue; |
| | | } |
| | | |
| | | locMast.setLocSts("S"); |
| | | locMast.setModiTime(new Date()); |
| | | locMastService.updateById(locMast); |
| | | |
| | | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("crn_no", taskWrk.getCrnNo()).eq("type_no", 1).eq("stn_no", staProtocol.getSiteId())); |
| | | staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(staDesc.getCrnStn().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | |
| | | //上报 |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm"); |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | hashMap.put("taskNo", taskWrk.getTaskNo()); |
| | | hashMap.put("status", TaskStatusType.DISTRIBUTE.id); |
| | | hashMap.put("ioType", 1); |
| | | hashMap.put("barcode", taskWrk.getBarcode()); |
| | | hashMap.put("reportTime", format.format(new Date())); |
| | | |
| | | NotifyCustomDataDto customDataDto = new NotifyCustomDataDto(); |
| | | customDataDto.setUri(wmsUrl); |
| | | customDataDto.setPath(taskExecCallback); |
| | | customDataDto.setData(JSON.toJSONString(hashMap)); |
| | | boolean notifyResult = notifyUtils.notify("task", 1, String.valueOf(taskWrk.getWrkNo()), taskWrk.getTaskNo(), NotifyMsgType.TASK_START, JSON.toJSONString(taskWrk), true, customDataDto); |
| | | if(notifyResult) { |
| | | taskWrk.setStatus(TaskStatusType.DISTRIBUTE.id);//任务派发 |
| | | taskWrkService.updateById(taskWrk); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("请求入库调用接口失败"); |
| | |
| | | , wmsUrl + inboundTaskApplyPath |
| | | , null |
| | | , "127.0.0.1" |
| | | , JSON.toJSONString(storageEscalationParam) |
| | | , JSON.toJSONString(requestParam) |
| | | , response |
| | | , success |
| | | ); |
| | | } |
| | | log.info("入库请求参数=" + JSON.toJSONString(BoxNo)); |
| | | log.info("入库请求参数=" + JSON.toJSONString(barcode)); |
| | | log.info("入库请求返回参数=" + JSON.toJSONString(response)); |
| | | } |
| | | } |
| | |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | |
| | | public synchronized void generateStoreWrkFile() throws IOException, InterruptedException { |
| | | try { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历入库口 |
| | | for (DevpSlave.Sta inSta : devp.getInSta()) { |
| | | // 获取入库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | Short workNo = staProtocol.getWorkNo(); |
| | | Short stano = staProtocol.getStaNo(); |
| | | |
| | | // 尺寸检测异常 |
| | | boolean back = false; |
| | | String errMsg = ""; |
| | | if (staProtocol.isFrontErr()) { |
| | | errMsg = "前超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isBackErr()) { |
| | | errMsg = "后超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isHighErr()) { |
| | | errMsg = "高超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isLeftErr()) { |
| | | errMsg = "左超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isRightErr()) { |
| | | errMsg = "右超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isWeightErr()) { |
| | | errMsg = "超重"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isBarcodeErr()) { |
| | | errMsg = "扫码失败"; |
| | | back = true; |
| | | } |
| | | // 退回 |
| | | if (back) { |
| | | if (stano == inSta.getBackSta().shortValue()) { |
| | | continue; |
| | | } |
| | | if (workNo == 0 && stano == 0) { |
| | | continue; |
| | | } |
| | | if (!staProtocol.isPakMk()) { |
| | | continue; |
| | | } |
| | | // News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); |
| | | staProtocol.setWorkNo(workNo); |
| | | staProtocol.setStaNo(inSta.getStaNo().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(workNo)); |
| | | if (taskWrk != null) { |
| | | taskWrk.setMemo(errMsg);//将错误码存入备注字段进行展示 |
| | | taskWrkMapper.updateById(taskWrk); |
| | | } |
| | | continue; |
| | | } |
| | | // 判断是否满足入库条件 |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() |
| | | && staProtocol.isInEnable() |
| | | && !staProtocol.isEmptyMk() && (workNo >= 9899) |
| | | && staProtocol.isPakMk()) { |
| | | // 获取条码扫描仪信息 |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); |
| | | if (barcodeThread == null) { |
| | | continue; |
| | | } |
| | | String barcode = barcodeThread.getBarcode(); |
| | | if (!Cools.isEmpty(barcode) && !barcode.equals("99999999")) { |
| | | // 请求wms接口,获取工作号和目标库位 |
| | | ToWmsDTO toWmsDTO = new ToWmsDTO(barcode, staProtocol.getSiteId(), staProtocol.isHigh() ? 2 : 1); |
| | | TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("barcode", barcode)); |
| | | if (!Cools.isEmpty(taskWrk1)) { |
| | | log.info("托盘码:" + barcode + "任务档存在"); |
| | | if (taskWrk1.getIoType() == 1 && taskWrk1.getStartPoint().equals(staProtocol.getSiteId().toString())) { |
| | | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("crn_no", taskWrk1.getCrnNo()).eq("type_no", 1).eq("stn_no", staProtocol.getSiteId())); |
| | | if (Cools.isEmpty(staDesc)) { |
| | | log.info("托盘码:" + barcode + "任务档存在"); |
| | | return; |
| | | } else { |
| | | staProtocol.setWorkNo(taskWrk1.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(staDesc.getCrnStn().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | } |
| | | } |
| | | return; |
| | | } |
| | | HashMap<String, Object> headParam = new HashMap<>(); |
| | | headParam.put("Content-Type", "application/json"); |
| | | System.out.println(JSON.toJSONString(toWmsDTO)); |
| | | String response; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | // .setHeaders(headParam) |
| | | .setUri(wmsUrl) |
| | | .setPath(inboundTaskApplyPath) |
| | | .setJson(JSON.toJSONString(toWmsDTO)) |
| | | .build() |
| | | .doPost(); |
| | | } catch (Exception e) { |
| | | log.error("请求入库调用接口失败"); |
| | | log.error("异常信息打印:" + e); |
| | | try { |
| | | BasDevp basDevp = basDevpService.selectById(inSta.getStaNo()); |
| | | if (Cools.isEmpty(basDevp)) { |
| | | log.error("站点号异常" + inSta.getStaNo()); |
| | | } else if (basDevp.getStaErr() != 0) { |
| | | basDevp.setStaErr(2); |
| | | basDevpService.updateById(basDevp); |
| | | } |
| | | } catch (Exception e1) { |
| | | // 退回 |
| | | log.error("扫码检测程序异常" + inSta.getStaNo() + "异常信息" + e1); |
| | | } |
| | | staProtocol.setWorkNo((short) 9999); |
| | | staProtocol.setStaNo(inSta.getStaNo().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(workNo)); |
| | | // if (taskWrk != null) { |
| | | // taskWrk.setMemo(errMsg);//将错误码存入备注字段进行展示 |
| | | // taskWrkMapper.updateById(taskWrk); |
| | | // } |
| | | continue; |
| | | } |
| | | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | log.info("入库请求参数{}" + JSON.toJSONString(toWmsDTO)); |
| | | log.info("入库请求返回参数{}" + JSON.toJSONString(response)); |
| | | if (jsonObject.getInteger("code").equals(200) && !Cools.isEmpty(jsonObject.get("data").toString())) { |
| | | GetWmsDto getWmsDto = JSON.parseObject(jsonObject.get("data").toString(), GetWmsDto.class); |
| | | try { |
| | | BasDevp basDevp = basDevpService.selectById(inSta.getStaNo()); |
| | | if (Cools.isEmpty(basDevp)) { |
| | | log.error("站点号异常1" + inSta.getStaNo()); |
| | | throw new CoolException("站点号异常1,未查询到站点信息" + inSta.getStaNo()); |
| | | } |
| | | Integer staNoCrnNo = Utils.StaNoCrnNo(inSta.getStaNo()); |
| | | if (staNoCrnNo == 0) { |
| | | basDevp.setStaErr(1); |
| | | basDevpService.updateById(basDevp); |
| | | log.error("站点号异常2" + inSta.getStaNo()); |
| | | throw new CoolException("站点号异常2,站点号不存在" + inSta.getStaNo()); |
| | | } else { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("crn_no", staNoCrnNo.longValue()) |
| | | .eq("loc_no", getWmsDto.getLocNo())); |
| | | if (Cools.isEmpty(locMast)) { |
| | | basDevp.setStaErr(1); |
| | | basDevpService.updateById(basDevp); |
| | | log.error("站点号异常3" + inSta.getStaNo()); |
| | | throw new CoolException("站点号异常3:此巷道不存在目标库位" + inSta.getStaNo()); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | // log.error("扫码检测程序异常"+inSta.getStaNo()+"异常信息"+e); |
| | | // 退回 |
| | | log.error("扫码检测程序异常" + inSta.getStaNo() + errMsg); |
| | | log.error("扫码检测程序异常,异常信息" + e); |
| | | |
| | | staProtocol.setWorkNo((short) 9999); |
| | | staProtocol.setStaNo(inSta.getStaNo().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(workNo)); |
| | | // if (taskWrk != null) { |
| | | // taskWrk.setMemo(errMsg);//将错误码存入备注字段进行展示 |
| | | // taskWrkMapper.updateById(taskWrk); |
| | | // } |
| | | continue; |
| | | } |
| | | //查看该库位是否为空库位 |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "O") |
| | | .eq("loc_no", getWmsDto.getLocNo())); |
| | | if (Cools.isEmpty(locMast)) { |
| | | try { |
| | | HashMap<String, Object> headParam1 = new HashMap<>(); |
| | | headParam1.put("taskNo", getWmsDto.getTaskNo()); |
| | | headParam1.put("status", 6); |
| | | headParam1.put("ioType", 1); |
| | | headParam1.put("barcode", barcode); |
| | | String response2; |
| | | response2 = new HttpHandler.Builder() |
| | | // .setHeaders(headParam) |
| | | .setUri(wmsUrl) |
| | | .setPath(taskStatusFeedbackPath) |
| | | .setJson(JSON.toJSONString(headParam1)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject1 = JSON.parseObject(response2); |
| | | apiLogService.save("wcs派发库位==》不为空《==上报wms" |
| | | , wmsUrl + taskStatusFeedbackPath |
| | | , null |
| | | , "127.0.0.1" |
| | | , JSON.toJSONString(headParam1) |
| | | , response |
| | | , true |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("wcs派发库位==》不为空《==上报wms", getWmsDto.getWrkNo()); |
| | | throw new CoolException("wcs派发入库任务上报wms失败,派发库位==》不为空《==,异常信息:" + e); |
| | | } |
| | | } |
| | | |
| | | // 创新一个入库工作档 |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(getWmsDto.getWrkNo()); |
| | | if (Cools.isEmpty(taskWrk)) { |
| | | taskWrk = createTask(getWmsDto, barcode); |
| | | if (Cools.isEmpty(taskWrk)) { |
| | | log.error("库位异常,库位号:{}", getWmsDto.getTargetLocationCode()); |
| | | } else { |
| | | taskWrkService.insert(taskWrk); |
| | | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("crn_no", taskWrk.getCrnNo()).eq("type_no", 1).eq("stn_no", staProtocol.getSiteId())); |
| | | staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(staDesc.getCrnStn().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | continue; |
| | | } |
| | | apiLogService.save("wms请求入库货位接口" |
| | | , wmsUrl + inboundTaskApplyPath |
| | | , null |
| | | , "127.0.0.1" |
| | | , JSON.toJSONString(toWmsDTO) |
| | | , response |
| | | , true |
| | | ); |
| | | |
| | | } else { |
| | | // 退回 |
| | | log.error("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg); |
| | | |
| | | staProtocol.setWorkNo((short) 9999); |
| | | staProtocol.setStaNo(inSta.getStaNo().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(workNo)); |
| | | if (taskWrk != null) { |
| | | taskWrk.setMemo(errMsg);//将错误码存入备注字段进行展示 |
| | | taskWrkMapper.updateById(taskWrk); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("generateStoreWrkFile e", e); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 堆垛机站出库到出库站 |
| | |
| | | continue; |
| | | } |
| | | |
| | | // int workNo = commonService.getWorkNo(WorkNoType.PAKIN.type);//获取入库工作号 |
| | | // taskWrk.setWrkNo(workNo);//工作号 |
| | | // taskWrk.setStatus(TaskStatusType.DISTRIBUTE.id);//派发状态 |
| | | taskWrk.setAssignTime(new Date());//派发时间 |
| | | taskWrk.setWrkSts(3);//工作状态 3.吊车入库 |
| | | taskWrk.setCrnNo(staDesc.getCrnNo());//堆垛机号 |
| | |
| | | try { |
| | | taskWrkService.updateById(taskWrk); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("修改工作档状态 2.设备上走 => 3.吊车入库中 失败!!,工作号={}", taskWrk.getWrkNo()); |
| | | log.error("修改工作档状态 2.设备上走 => 3.吊车入库中 失败!!,异常:" + e); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public synchronized void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol) { |
| | | List<TaskWrk> taskWrksInitial = taskWrkMapper.selectPakOut(slave.getId(), null); |
| | | if (taskWrksInitial.size() == 0) { |
| | | if (taskWrksInitial.isEmpty()) { |
| | | return; |
| | | } |
| | | for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) { |
| | |
| | | log.error("修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", taskWrk.getWrkNo()); |
| | | log.error("修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,异常:" + e); |
| | | } |
| | | // 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()); |
| | | // 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失败", JSON.toJSONString(taskWrk)); |
| | | //// throw new CoolException("wcs派发入库任务上报wms失败"); |
| | | // } |
| | | |
| | | //上报-出库任务开始时,WCS回调WMS |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm"); |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | hashMap.put("taskNo", taskWrk.getTaskNo()); |
| | | hashMap.put("status", TaskStatusType.DISTRIBUTE.id); |
| | | hashMap.put("ioType", 1); |
| | | hashMap.put("barcode", taskWrk.getBarcode()); |
| | | hashMap.put("reportTime", format.format(new Date())); |
| | | |
| | | NotifyCustomDataDto customDataDto = new NotifyCustomDataDto(); |
| | | customDataDto.setUri(wmsUrl); |
| | | customDataDto.setPath(taskExecCallback); |
| | | customDataDto.setData(JSON.toJSONString(hashMap)); |
| | | boolean notifyResult = notifyUtils.notify("task", 1, String.valueOf(taskWrk.getWrkNo()), taskWrk.getTaskNo(), NotifyMsgType.TASK_START, JSON.toJSONString(taskWrk), true, customDataDto); |
| | | if(notifyResult) { |
| | | taskWrk.setStatus(2); |
| | | taskWrkService.updateById(taskWrk); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | response = new HttpHandler.Builder() |
| | | // .setHeaders(headParam) |
| | | .setUri(wmsUrl) |
| | | .setPath(taskStatusFeedbackPath) |
| | | .setPath(taskExecCallback) |
| | | .setJson(JSON.toJSONString(headParam)) |
| | | .build() |
| | | .doPost(); |
| | |
| | | // throw new CoolException("wcs派发移库库任务上报wms失败"); |
| | | }finally { |
| | | apiLogService.save("wcs派发移库任务上报wms" |
| | | , wmsUrl + taskStatusFeedbackPath |
| | | , wmsUrl + taskExecCallback |
| | | , null |
| | | , "127.0.0.1" |
| | | , JSON.toJSONString(headParam) |
| | |
| | | continue; |
| | | } |
| | | //确认完成信号 |
| | | CrnOperatorParam crnOperatorParam = new CrnOperatorParam(); |
| | | crnOperatorParam.setCrnNo(crn.getId()); |
| | | R r = crnController.crnTaskComplete(crnOperatorParam); |
| | | boolean result = crnOperaUtils.crnTaskComplete(crn.getId()); |
| | | Thread.sleep(1000); |
| | | if(!r.get("code").equals(200)){ |
| | | if(!result){ |
| | | return; |
| | | } |
| | | if (!Cools.isEmpty(taskWrk)) { |
| | | if (taskWrk.getIoType() == 1 && taskWrk.getWrkSts() == 3) { |
| | | taskWrk.setWrkSts(4);//入库完成 |
| | | taskWrk.setStatus(5);//完结 |
| | | |
| | | //更新库位状态 |
| | | LocMast locMast = locMastService.selectByLocNo(taskWrk.getTargetPoint()); |
| | | locMast.setLocSts("F");//F.在库 |
| | |
| | | } else if (taskWrk.getIoType() == 2 && taskWrk.getWrkSts() == 12) { |
| | | taskWrk.setWrkSts(13);//出库完成 |
| | | taskWrk.setStatus(5);//完结 |
| | | |
| | | //更新库位状态 |
| | | LocMast locMast = locMastService.selectByLocNo(taskWrk.getStartPoint()); |
| | | locMast.setLocSts("O");//O.空库位 |
| | |
| | | // 有异常 |
| | | if (latest == null) { |
| | | if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) { |
| | | WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo()); |
| | | if (wrkMast == null) { |
| | | TaskWrk taskWrk = taskWrkService.selectByWrkNo(crnProtocol.getTaskNo().intValue()); |
| | | if (taskWrk == null) { |
| | | continue; |
| | | } |
| | | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); |
| | | String errName = crnError == null ? String.valueOf(crnProtocol.getAlarm()) : crnError.getErrName(); |
| | | BasErrLog basErrLog = new BasErrLog( |
| | | null, // 编号 |
| | | wrkMast.getWrkNo(), // 工作号 |
| | | taskWrk.getWrkNo(), // 工作号 |
| | | now, // 发生时间 |
| | | null, // 结束时间 |
| | | wrkMast.getWrkSts(), // 工作状态 |
| | | wrkMast.getIoType(), // 入出库类型 |
| | | taskWrk.getWrkSts().longValue(), // 工作状态 |
| | | taskWrk.getIoType(), // 入出库类型 |
| | | crn.getId(), // 堆垛机 |
| | | null, // plc |
| | | wrkMast.getLocNo(), // 目标库位 |
| | | wrkMast.getStaNo(), // 目标站 |
| | | wrkMast.getSourceStaNo(), // 源站 |
| | | wrkMast.getSourceLocNo(), // 源库位 |
| | | wrkMast.getBarcode(), // 条码 |
| | | taskWrk.getTargetPoint(), // 目标库位 |
| | | null, // 目标站 |
| | | null, // 源站 |
| | | taskWrk.getStartPoint(), // 源库位 |
| | | taskWrk.getBarcode(), // 条码 |
| | | (int) crnProtocol.getAlarm1(), // 异常码 |
| | | errName, // 异常 |
| | | 1, // 异常情况 |
| | |
| | | // } |
| | | // } |
| | | |
| | | //agv取放货任务完成 |
| | | public synchronized void autoCompleteAGV() { |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>()); |
| | | try { |
| | | Thread.sleep(500); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | |
| | | for (BasDevp basDevp : basDevps) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | StaProtocol staProtocol = devpThread.getStation().get(basDevp.getDevNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | if (basDevp.getWrkNo() != 0) { |
| | | if (basDevp.getAgvTargetPick() != 0) {//取货 |
| | | staProtocol.setAgvTypeSign((short) 0); |
| | | staProtocol.setStaNo(basDevp.getDevNo().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(4, staProtocol)); |
| | | } |
| | | boolean sign = true; |
| | | if (basDevp.getAgvTargetPlace() != 0) { |
| | | sign = false; |
| | | basDevp.setAgvTargetPlace(0); |
| | | basDevpService.updateById(basDevp); |
| | | staProtocol.setAgvTypeSign((short) 3);//1 |
| | | staProtocol.setStaNo(basDevp.getDevNo().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(4, staProtocol)); |
| | | } |
| | | } else { |
| | | if (basDevp.getAgvTargetPlace() != 0) { |
| | | if (basDevp.getLoading().equals("Y")) { |
| | | staProtocol.setAgvTypeSign((short) 1); |
| | | staProtocol.setStaNo(basDevp.getDevNo().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(4, staProtocol)); |
| | | } else { |
| | | log.error("AGV放货完成但输送线无物,复位信号 ===>> [staNo:{}] [basDevp:{}]", basDevp.getDevNo(), basDevp); |
| | | basDevp.setAgvTargetPlace(0); |
| | | basDevpService.updateById(basDevp); |
| | | staProtocol.setAgvTypeSign((short) 3);//1 |
| | | staProtocol.setStaNo(basDevp.getDevNo().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(4, staProtocol)); |
| | | } |
| | | |
| | | } |
| | | if (basDevp.getAgvTargetPick() != 0) { |
| | | basDevp.setAgvTargetPick(0); |
| | | basDevpService.updateById(basDevp); |
| | | staProtocol.setAgvTypeSign((short) 2);//0 |
| | | staProtocol.setStaNo(basDevp.getDevNo().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(4, staProtocol)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public synchronized void autoCompleteTask() { |
| | | List<TaskWrk> taskWrks = taskWrkMapper.selectWorkingTask(); |
| | | for (TaskWrk taskWrk : taskWrks) { |
| | |
| | | locMastService.updateById(locMast); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public synchronized String CrnStartRunning(TaskWrk taskWrk) { |
| | | String tasktype = null; |
| | | switch (taskWrk.getIoType()) { |
| | | case 1: |
| | | tasktype = "RK"; |
| | | break; |
| | | case 2: |
| | | tasktype = "CK"; |
| | | break; |
| | | case 3: |
| | | tasktype = "YK"; |
| | | break; |
| | | default: |
| | | tasktype = "未知"; |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("x-api-key", "7a15b5db-29b6-552c-8cff-0cfec3756da2"); |
| | | TaskOverToWms taskOverToWms = new TaskOverToWms(); |
| | | taskOverToWms.setFeedbackFrom("WCS"); //来源 |
| | | taskOverToWms.setWarehouseId("1688469798893297665"); //仓库标识 |
| | | taskOverToWms.setTaskNo(taskWrk.getTaskNo()); //任务号 |
| | | taskOverToWms.setTaskType(tasktype); // 任务类型 |
| | | taskOverToWms.setContainerCode(taskWrk.getBarcode()); // 容器编码 |
| | | if (taskWrk.getIoType() == 1 || taskWrk.getIoType() == 3) { |
| | | taskOverToWms.setEquipmentCode(String.valueOf(taskWrk.getCrnNo())); //设备编码 |
| | | taskOverToWms.setTargetLocationCode(taskWrk.getOriginTargetPoint()); //目标库位 |
| | | } else if (taskWrk.getIoType() == 2) { |
| | | Map<Integer, String> map1 = new HashMap<>(); |
| | | map1.put(102, "J-1101"); |
| | | map1.put(106, "J-1103"); |
| | | map1.put(110, "J-1105"); |
| | | map1.put(114, "J-1107"); |
| | | map1.put(118, "J-1109"); |
| | | map1.put(122, "J-1111"); |
| | | map1.put(305, "H-1101"); |
| | | map1.put(405, "G-1101"); |
| | | taskOverToWms.setEquipmentCode(map1.get(taskWrk.getTargetPoint())); //设备编码 |
| | | taskOverToWms.setSourceLocationCode(taskWrk.getOriginStartPoint()); //源库位 |
| | | } |
| | | |
| | | taskOverToWms.setTaskStatus("executing"); //任务状态 |
| | | String response = null; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setHeaders(map) |
| | | .setUri(wmsUrl) |
| | | .setPath("wcsManager/wcsInterface/taskStatusFeedback") |
| | | .setJson(JSON.toJSONString(taskOverToWms)) |
| | | .build() |
| | | .doPost(); |
| | | } catch (Exception e) { |
| | | log.error("堆垛机任务完成,请求wms任务完成接口失败"); |
| | | } |
| | | apiLogService.save("堆垛机开始运行" |
| | | , wmsUrl + "wcsManager/wcsInterface/taskStatusFeedback" |
| | | , null |
| | | , "127.0.0.1" |
| | | , JSON.toJSONString(taskOverToWms) |
| | | , response |
| | | , true |
| | | ); |
| | | return response; |
| | | } |
| | | |
| | | private TaskWrk createTask1(Result result, String barcode) { |
| | | String locNo = Utils.Fusion(result.getRow(), result.getFloor(), result.getColumn()); |
| | | |
| | | |
| | | Date now = new Date(); |
| | | TaskWrk taskWrk = new TaskWrk(); |
| | | int workNo1 = commonService.getWorkNo(WorkNoType.PAKIN.type);//获取入库工作号 |
| | | taskWrk.setTaskNo(result.getTaskNo());//任务号 |
| | | taskWrk.setWrkNo(workNo1); |
| | | taskWrk.setStatus(TaskStatusType.RECEIVE.id);//任务状态:接收 |
| | | taskWrk.setCreateTime(now); |
| | | taskWrk.setIoType(1);//任务类型 |
| | | taskWrk.setIoPri(13);//优先级 |
| | | taskWrk.setBarcode(barcode);//条码 |
| | | LocMast locMast = locMastService.selectByLocNo(locNo); |
| | | taskWrk.setCrnNo(locMast.getCrnNo()); |
| | | taskWrk.setTargetPoint(locNo); |
| | | taskWrk.setStartPoint("116"); |
| | | if (result.getAlley().equals("1")) { |
| | | taskWrk.setCrnNo(1); |
| | | } else { |
| | | taskWrk.setCrnNo(2); |
| | | } |
| | | if (taskWrk.getIoType() == 1) { |
| | | taskWrk.setWrkSts(2); |
| | | if (!Cools.isEmpty(taskWrk.getTargetPoint())) { |
| | | taskWrk.setOriginTargetPoint(taskWrk.getTargetPoint()); |
| | | } |
| | | } |
| | | return taskWrk; |
| | | } |
| | | |
| | | private TaskWrk createTask(GetWmsDto dto, String barcode) { |