| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | 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.entity.*; |
| | | import com.zy.asrs.service.BasCircularShuttleService; |
| | | import com.zy.asrs.service.BasDevpPositionService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.task.escalationParam.RgvTaskReportingParam; |
| | | import com.zy.asrs.utils.PostMesDataUtils; |
| | | import com.zy.asrs.utils.SortTheExecutionOfTheCarUtil; |
| | | import com.zy.asrs.utils.TimeCalculatorUtils; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.*; |
| | |
| | | import com.zy.core.model.protocol.RgvProtocol; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.RgvThread; |
| | | import com.zy.system.entity.license.LicenseVerify; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | private BasCircularShuttleService basCircularShuttleService; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | |
| | | @Value("${constant-parameters.perimeter}") |
| | | private Long perimeter; |
| | |
| | | private Long rgvCount; |
| | | @Value("${constant-parameters.rgvDate}") |
| | | private Double rgvDate; |
| | | |
| | | /* |
| | | * 验证许可证是否有效 |
| | | * */ |
| | | public synchronized boolean licenseVerify() { |
| | | try{ |
| | | // if (true) { |
| | | // return true; |
| | | // } |
| | | return new LicenseVerify().verify(); |
| | | } catch (Exception e){ |
| | | log.info("许可证验证失败!!异常:{}",e.getMessage()); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 站点任务检测 更新小车位置信息 |
| | |
| | | log.info("更新小车排序信息异常={}", rgvNo); |
| | | return; |
| | | } |
| | | List<BasCircularShuttle> basCircularShuttleList = basCircularShuttleService.selectList(new EntityWrapper<BasCircularShuttle>().orderBy("rgv_id", true)); |
| | | List<BasCircularShuttle> basCircularShuttleList = basCircularShuttleService.selectList(new EntityWrapper<BasCircularShuttle>().eq("status", 0).orderBy("rgv_id", true)); |
| | | if (basCircularShuttleList.get(0).getRgvNo().equals(rgvNo)) { |
| | | return; |
| | | } |
| | |
| | | Integer rgvNo = 0; |
| | | List<BasCircularShuttle> basCircularShuttleList = basCircularShuttleService.selectList(new EntityWrapper<BasCircularShuttle>().orderBy("rgv_id", true)); |
| | | for (BasCircularShuttle basCircularShuttle : basCircularShuttleList) { |
| | | if (basCircularShuttle.getStatus() != 0){ |
| | | sign = true; |
| | | continue; |
| | | } |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo()); |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | if (rgvProtocol == null) { |
| | |
| | | break runRgv; |
| | | } |
| | | BasCircularShuttle basCircularShuttle = basCircularShuttleService.selectOne(new EntityWrapper<BasCircularShuttle>().eq("rgv_id", rgvId)); |
| | | if (basCircularShuttle.getStatus() != 0){ |
| | | continue ; |
| | | } |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo()); |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | if (rgvProtocol == null) { |
| | |
| | | && rgvProtocol.getTaskNo1() == 0 |
| | | && rgvProtocol.getAlarm() == 0) { |
| | | if (rgvProtocol.getStatusType() == RgvStatusType.ROAM) { |
| | | // double finalVelocity = 0.0; // 最终速度 (m/s) |
| | | // double distance = (Math.pow(finalVelocity, 2) - Math.pow(rgvProtocol.instantaneousSpeed / 60, 2)) / (2 * acceleration); |
| | | // BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("dev_no", wrkMast.getSourceStaNo())); |
| | | // if (distance * proportion > ((SortTheExecutionOfTheCarUtil.LatelyAndLessThan(basDevpPosition.getPlcPosition(), rgvProtocol.getRgvPos(), perimeter) + (rgvProtocol.instantaneousSpeed / 60) * proportion * rgvDate))) { |
| | | // continue; |
| | | // } |
| | | List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position", true)); |
| | | if (basDevpPositions.isEmpty()) { |
| | | log.error("获取所有站点信息异常,RGV任务下发失败,请联系管理员!!!"); |
| | | break runRgv; |
| | | } |
| | | List<Integer> devpList = SortTheExecutionOfTheCarUtil.BasDevpPositionExtractSites(basDevpPositions); |
| | | |
| | | if (!SortTheExecutionOfTheCarUtil.calculateShortestDistanceDirection(devpList,rgvProtocol.getEndStaM(),wrkMast.getSourceStaNo())){ |
| | | continue; |
| | | double finalVelocity = 0.0; // 最终速度 (m/s) |
| | | double distance = (Math.pow(finalVelocity, 2) - Math.pow(rgvProtocol.instantaneousSpeed / 60, 2)) / (2 * acceleration); |
| | | BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("dev_no", wrkMast.getSourceStaNo())); |
| | | if ((distance * proportion + (rgvProtocol.instantaneousSpeed / 60) * proportion * rgvDate) > (SortTheExecutionOfTheCarUtil.LatelyAndLessThan(basDevpPosition.getPlcPosition(), rgvProtocol.getRgvPos(), perimeter) )) { |
| | | // List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position", true)); |
| | | // if (basDevpPositions.isEmpty()) { |
| | | // log.error("获取所有站点信息异常,RGV任务下发失败,请联系管理员!!!"); |
| | | // break runRgv; |
| | | // } |
| | | // List<Integer> devpList = SortTheExecutionOfTheCarUtil.BasDevpPositionExtractSites(basDevpPositions); |
| | | // |
| | | // if (!SortTheExecutionOfTheCarUtil.calculateShortestDistanceDirection(devpList,rgvProtocol.getEndStaM(),wrkMast.getSourceStaNo())){ |
| | | continue; |
| | | // } |
| | | } |
| | | } |
| | | RgvCommand rgvCommand = new RgvCommand(); |
| | |
| | | break; |
| | | } |
| | | wrkMast.setWrkSts(3L); |
| | | wrkMast.setAppeTime(new Date()); |
| | | Date now = new Date(); |
| | | wrkMast.setAppeTime(now); |
| | | try{ |
| | | try{ |
| | | if (true){ |
| | | RgvTaskReportingParam rgvTaskReportingParam = new RgvTaskReportingParam(wrkMast); |
| | | ReturnT<String> result = new PostMesDataUtils().postMesDataWcs("", "", rgvTaskReportingParam); |
| | | if (result.getCode()==200){ |
| | | wrkMast.setWrkSts(4L); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMastService.updateById(wrkMast); |
| | | continue; |
| | | }else { |
| | | log.error("工作号"+wrkMast.getWrkNo()+"任务完成信息上传处理失败"); |
| | | } |
| | | } else { |
| | | //测试用 |
| | | wrkMast.setWrkSts(5L); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMastService.updateById(wrkMast); |
| | | WrkMast wrkMast1 = new WrkMast(); |
| | | int workNo = commonService.getWorkNo(0); |
| | | wrkMast1.setWrkNo((long) workNo); |
| | | wrkMast1.setSourceStaNo(wrkMast.getStaNoCs()); |
| | | wrkMast1.setStaNo(wrkMast.getSourceNoCs()); |
| | | wrkMast1.setWrkSts(1L); |
| | | wrkMast1.setIoType(1); |
| | | wrkMast1.setModiTime(now); |
| | | wrkMast1.setAppeTime(now); |
| | | wrkMast1.setMemo("测试数据"); |
| | | wrkMastService.insert(wrkMast1); |
| | | continue; |
| | | } |
| | | } catch (Exception e){ |
| | | log.error("工作号"+wrkMast.getWrkNo()+"任务完成信息上传处理失败,异常信息:"+e); |
| | | } |
| | | } catch (Exception e){} |
| | | wrkMastService.updateById(wrkMast); |
| | | } |
| | | } |