| | |
| | | import com.core.common.DateUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.ArmTaskAssignmentParam; |
| | | import com.zy.asrs.mapper.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.PostMesDataUtils; |
| | | import com.zy.asrs.utils.RouteUtils; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import com.zy.asrs.utils.core.ReturnT; |
| | | import com.zy.common.constant.ArmConstant; |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.MatDto; |
| | | import com.zy.common.model.SearchLocParam; |
| | |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private BasRgvMapService basRgvMapService; |
| | | @Autowired |
| | | private BasArmService basArmService; |
| | | @Autowired |
| | | private BasArmMastService basArmMastService; |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | |
| | | } else { |
| | | staProtocolIn = staProtocolIn.clone(); |
| | | } |
| | | StaProtocol staProtocolOut = devpThread.getStation().get(1015); |
| | | if (staProtocolOut == null) { |
| | | continue; |
| | | } else { |
| | | staProtocolOut = staProtocolOut.clone(); |
| | | } |
| | | if(staProtocolOut.getWorkNo() != null && staProtocolOut.getStaNo() == 4006){ |
| | | WrkMast wrkMastOut = wrkMastMapper.selectByWrkNo(staProtocolOut.getWorkNo()); |
| | | WrkMast wrkMast = wrkMastMapper.selectByWrkNo(9997); |
| | | if(wrkMast == null){ |
| | | int[] outStaNos = {1015, 2016}; |
| | | for (int outStaNo : outStaNos) { |
| | | StaProtocol staProtocolOut = devpThread.getStation().get(outStaNo);// 盘点出库衔接站点(可能是 1015,也可能是 2016) |
| | | if (staProtocolOut == null) { |
| | | continue; |
| | | } else { |
| | | staProtocolOut = staProtocolOut.clone(); |
| | | } |
| | | try { |
| | | TransplantWork param = new TransplantWork(); |
| | | param.setWorkNo(wrkMastOut.getWrkNo()); |
| | | param.setBarcode(wrkMastOut.getBarcode()); |
| | | param.setSourceStaNo(1015); |
| | | param.setStaNo(wrkMastOut.getStaNo()); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/auto/TransplantingIn/v1") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | staProtocolOut.setWorkNo(9997); |
| | | devpThread.setPakMk(staProtocolOut.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocolOut)); |
| | | |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | if (staProtocolOut.getWorkNo() != null && staProtocolOut.getStaNo() == 4006) { |
| | | WrkMast wrkMastOut = wrkMastMapper.selectByWrkNo(staProtocolOut.getWorkNo()); |
| | | WrkMast wrkMast = wrkMastMapper.selectByWrkNo(9997); |
| | | if (wrkMastOut == null) { |
| | | continue; |
| | | } |
| | | if (wrkMast != null) { |
| | | News.info("已存在斜街任务,等待任务完成"); |
| | | continue; |
| | | } |
| | | try { |
| | | TransplantWork param = new TransplantWork(); |
| | | param.setWorkNo(wrkMastOut.getWrkNo()); |
| | | param.setBarcode(wrkMastOut.getBarcode()); |
| | | param.setSourceStaNo(outStaNo); |
| | | param.setStaNo(wrkMastOut.getStaNo()); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/auto/TransplantingOut/v1") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | staProtocolOut.setWorkNo(9997); |
| | | devpThread.setPakMk(staProtocolOut.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocolOut)); |
| | | |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(staProtocolIn.getWorkNo() != null &&staProtocolIn.getStaNo() != 4001){ |
| | | WrkMast wrkMastIn = wrkMastMapper.selectByWrkNo(staProtocolIn.getWorkNo()); |
| | | WrkMast wrkMast = wrkMastMapper.selectByWrkNo(9996); |
| | | if(wrkMast == null){ |
| | | if(wrkMastIn == null){ |
| | | continue; |
| | | } |
| | | if(wrkMast != null){ |
| | | News.info("已存在斜街任务,等待任务完成"); |
| | | continue; |
| | | } |
| | | try { |
| | |
| | | param.setStaNo(wrkMastIn.getStaNo()); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/auto/TransplantingOut/v1") |
| | | .setPath("/rpc/auto/TransplantingIn/v1") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /* |
| | | * arm任务下发 |
| | | * */ |
| | | public synchronized void armTaskAssignment() { |
| | | try{ |
| | | List<BasArm> basArmList = basArmService.selectList(new EntityWrapper<>()); |
| | | for (BasArm basArm : basArmList) { |
| | | if (basArm.getStatus()!=1){ |
| | | continue; |
| | | } |
| | | try{ |
| | | List<BasArmMast> basArmMastListRuning = basArmMastService.selectList( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("arm_no", basArm.getArmNo()) |
| | | .eq("sorting_line", basArm.getSortingLine()) |
| | | .eq("status", 1) |
| | | ); |
| | | if (basArmMastListRuning.isEmpty()){ |
| | | List<BasArmMast> basArmMastList = basArmMastService.selectList( |
| | | new EntityWrapper<BasArmMast>() |
| | | .eq("arm_no", basArm.getArmNo()) |
| | | .eq("sorting_line", basArm.getSortingLine()) |
| | | .eq("status", 0) |
| | | ); |
| | | if (basArmMastList.isEmpty()){ |
| | | continue; |
| | | } |
| | | if (basArmMastList.size()>1){ |
| | | log.error("arm编号:"+basArm.getArmNo()+"====》拆码垛任务异常禁止下发!!!任务待执行数量大于1!!!"); |
| | | continue; |
| | | } |
| | | for (BasArmMast basArmMast:basArmMastList) { |
| | | ArmTaskAssignmentParam armTaskAssignmentParam = new ArmTaskAssignmentParam(basArmMast.getSortingLine()); |
| | | //设置工作空间就绪 |
| | | ReturnT<String> result = new PostMesDataUtils().postMesData("机械臂抓取任务",ArmConstant.ARM_URL, ArmConstant.ARM_WORKSPACE, armTaskAssignmentParam); |
| | | if (result.getCode()==200){ |
| | | basArmMast.setStatus(1); |
| | | basArmMastService.updateById(basArmMast); |
| | | } else { |
| | | log.error("机械臂抓取任务:"+JSON.toJSON(basArmMast)+"===》任务信息下发失败"); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e){ |
| | | log.error("arm编号:"+basArm.getArmNo()+"====》拆码垛任务下发失败"+e.getMessage()); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("arm任务下发失败"+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | } |