| | |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.CombParam; |
| | | import com.zy.asrs.entity.param.MobileAdjustParam; |
| | | import com.zy.asrs.entity.param.OffSaleParam; |
| | | import com.zy.asrs.entity.param.OpenOrderPakinParam; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.mapper.ManLocDetlMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.constant.AgvSiteConstant; |
| | | import com.zy.common.constant.ApiInterfaceConstant; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.model.DetlDto; |
| | |
| | | |
| | | |
| | | @Override |
| | | public R inLocCallAgv(String sta, String inSta) { |
| | | // 判断入库站点有无出库任务过滤盘点捡料 |
| | | int count = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("sta_no", inSta).ne("wrk_sts",15).notIn("io_type",103,107)); |
| | | if (count > 0) { |
| | | return R.parse(inSta + "站点存在出库任务"); |
| | | } |
| | | |
| | | // 先绑定 |
| | | boolean flag = bindPodAndBerth(sta); |
| | | if (!flag) { |
| | | return R.parse(inSta + "绑定失败"); |
| | | } |
| | | |
| | | ForwardAGVTaskParam forwardAGVTaskParam = new ForwardAGVTaskParam(); |
| | | forwardAGVTaskParam.setReqCode(UUID.randomUUID().toString().replace("-", "")); |
| | | forwardAGVTaskParam.setTaskTyp("GT3"); |
| | | forwardAGVTaskParam.setCtnrTyp("2"); |
| | | forwardAGVTaskParam.setPriority("1"); |
| | | List<ForwardAGVTaskParam.PositionCodePaths> positionCodePathsList = new ArrayList<>(); |
| | | positionCodePathsList.add(new ForwardAGVTaskParam.PositionCodePaths(sta, "05")); |
| | | positionCodePathsList.add(new ForwardAGVTaskParam.PositionCodePaths(inSta, "05")); |
| | | forwardAGVTaskParam.setPositionCodePath(positionCodePathsList); |
| | | |
| | | String body = JSON.toJSONString(forwardAGVTaskParam); |
| | | String response = ""; |
| | | String message = ""; |
| | | boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(ApiInterfaceConstant.AGV_IP) |
| | | .setPath(ApiInterfaceConstant.AGV_CALL_IN_PATH) |
| | | .setJson(body) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | jsonObject.getString("message"); |
| | | if (jsonObject.getInteger("code").equals(0)) { |
| | | success = true; |
| | | } else { |
| | | log.error("入库呼叫agv失败!!!url:{};request:{};response:{}", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_CALL_IN_PATH, body, response); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("入库呼叫agv异常", e); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "入库呼叫agv", |
| | | ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_CALL_IN_PATH, |
| | | null, |
| | | "127.0.0.1", |
| | | body, |
| | | response, |
| | | success |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("", e); |
| | | } |
| | | } |
| | | |
| | | return success ? R.ok("呼叫agv成功") : R.parse(message); |
| | | } |
| | | |
| | | @Override |
| | | public R unbind(String site) { |
| | | String staMap = AgvSiteConstant.SiteMap.get(site); |
| | | if (staMap == null) { |
| | | return R.parse("没有找到该站点的入库映射:" + site); |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("reqCode",UUID.randomUUID().toString().replace("-", "")); // 请求唯一值 |
| | | jsonObject.put("ctnrTyp","2"); // 容器类型2 |
| | | jsonObject.put("stgBinCode",staMap); // 仓位编号,根据客仓编号转换 |
| | | jsonObject.put("indBind","0"); // 1绑定,0解绑 |
| | | |
| | | String body = jsonObject.toJSONString(); |
| | | String response = ""; |
| | | String message = ""; |
| | | boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(ApiInterfaceConstant.AGV_IP) |
| | | .setPath(ApiInterfaceConstant.AGV_BIND_PATH) |
| | | .setJson(body) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject res = JSON.parseObject(response); |
| | | message = jsonObject.getString("message"); |
| | | if (res.getInteger("code").equals(0)) { |
| | | success = true; |
| | | } else { |
| | | log.error("调用agv解绑暂存位失败!!!url:{};request:{};response:{}", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, body, response); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("调用agv解绑暂存位异常", e); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "调用agv解绑暂存位", |
| | | ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, |
| | | null, |
| | | "127.0.0.1", |
| | | body, |
| | | response, |
| | | success |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("", e); |
| | | } |
| | | } |
| | | return success ? R.ok("解绑成功") : R.parse(message); |
| | | } |
| | | |
| | | private boolean bindPodAndBerth(String sta) { |
| | | String staMap = AgvSiteConstant.SiteMap.get(sta); |
| | | if (staMap == null) { |
| | | log.error("没有找到该站点的入库映射:{}",sta); |
| | | return false; |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("reqCode",UUID.randomUUID().toString().replace("-", "")); // 请求唯一值 |
| | | jsonObject.put("ctnrTyp","2"); // 容器类型2 |
| | | jsonObject.put("stgBinCode",staMap); // 仓位编号,根据客仓编号转换 |
| | | jsonObject.put("indBind","1"); // 1绑定,0解绑 |
| | | |
| | | String body = jsonObject.toJSONString(); |
| | | String response = ""; |
| | | boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(ApiInterfaceConstant.AGV_IP) |
| | | .setPath(ApiInterfaceConstant.AGV_BIND_PATH) |
| | | .setJson(body) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject res = JSON.parseObject(response); |
| | | if (res.getInteger("code").equals(0)) { |
| | | success = true; |
| | | } else { |
| | | log.error("调用agv绑定仓位失败!!!url:{};request:{};response:{}", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, body, response); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("调用agv绑定仓位异常", e); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "调用agv绑定仓位", |
| | | ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, |
| | | null, |
| | | "127.0.0.1", |
| | | body, |
| | | response, |
| | | success |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("", e); |
| | | } |
| | | } |
| | | return success; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void comb(CombParam param, Long userId) { |
| | | if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { |
| | |
| | | } |
| | | |
| | | if(param.getBarcode().length()!=9){ |
| | | throw new CoolException("条码长度不是8位===>>" + param.getBarcode()); |
| | | throw new CoolException("条码长度不是9位===>>" + param.getBarcode()); |
| | | } |
| | | if (param.getCombMats().size()>1){ |
| | | throw new CoolException("不允许混料===>>" + param.getBarcode()); |