| | |
| | | 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())) { |
| | |
| | | throw new CoolException(param.getBarcode() + "数据正在进行入库"); |
| | | } |
| | | |
| | | if(param.getBarcode().length()!=8){ |
| | | throw new CoolException("条码长度不是8位===>>" + param.getBarcode()); |
| | | if(param.getBarcode().length()!=9){ |
| | | throw new CoolException("条码长度不是9位===>>" + param.getBarcode()); |
| | | } |
| | | if (param.getCombMats().size()>1){ |
| | | throw new CoolException("不允许混料===>>" + param.getBarcode()); |
| | |
| | | throw new CoolException("修改单据作业数量失败"); |
| | | } |
| | | |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(),orderDetl.getManu()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); |
| | | assert one != null; |
| | |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | waitPakin.setManu(detlDto.getMark()); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | |
| | | @Override |
| | | // @Transactional |
| | | public void leftoversOut(Map<String, Object> map,Long userId) { |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", map.get("barcode")).eq("io_type", 103)); |
| | | String barcode = map.get("barcode").toString(); |
| | | String barcode2 = map.get("barcode2").toString(); |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", barcode).eq("io_type", 103)); |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException("未查询到拣料任务"); |
| | | } |
| | | Date now = new Date(); |
| | | int workNo = commonService.getWorkNo(1); |
| | | WrkMast wrkMast1 = new WrkMast(); |
| | | wrkMast1.sync(wrkMast); |
| | | wrkMast1.setWrkNo(workNo); |
| | | wrkMast1.setWrkSts(2L); |
| | | wrkMast1.setIoType(200); |
| | | wrkMast1.setSourceStaNo(wrkMast.getStaNo() == 113 ? 111 : 117); |
| | | wrkMast1.setStaNo(map.get("floor").hashCode() == 2 ? 204:304); |
| | | wrkMast1.setIoTime(now); |
| | | wrkMast1.setIoPri(13D); // 优先级:13 |
| | | wrkMast1.setCrnNo(wrkMast.getCrnNo()); |
| | | wrkMast1.setSourceLocNo(wrkMast.getLocNo()); // 源库位 |
| | | wrkMast1.setFullPlt("Y"); // 满板:Y |
| | | wrkMast1.setPicking("N"); // 拣料 |
| | | wrkMast1.setExitMk("N"); // 退出 |
| | | wrkMast1.setEmptyMk("N"); // 空板 |
| | | wrkMast1.setLinkMis("N"); |
| | | wrkMast1.setAppeUser(userId); // 操作人员数据 |
| | | wrkMast1.setAppeTime(now); |
| | | wrkMast1.setModiUser(userId); |
| | | wrkMast1.setModiTime(now); |
| | | wrkMast1.setBarcode(wrkMast.getBarcode()); |
| | | if (!wrkMastService.insert(wrkMast1)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | WrkMast wrkMast2 = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", barcode2).eq("io_type", 200)); |
| | | if (Cools.isEmpty(wrkMast2)) { |
| | | Date now = new Date(); |
| | | |
| | | WrkMast wrkMast1 = new WrkMast(); |
| | | wrkMast1.sync(wrkMast); |
| | | wrkMast1.setWrkNo(workNo); |
| | | wrkMast1.setWrkSts(2L); |
| | | wrkMast1.setIoType(200); |
| | | wrkMast1.setSourceStaNo(wrkMast.getStaNo() == 113 ? 111 : 117); |
| | | wrkMast1.setStaNo(wrkMast.getStaNo() == 113 ? 204 : 304); |
| | | wrkMast1.setIoTime(now); |
| | | wrkMast1.setIoPri(13D); // 优先级:13 |
| | | wrkMast1.setCrnNo(wrkMast.getCrnNo()); |
| | | wrkMast1.setSourceLocNo(wrkMast.getLocNo()); // 源库位 |
| | | wrkMast1.setFullPlt("Y"); // 满板:Y |
| | | wrkMast1.setPicking("N"); // 拣料 |
| | | wrkMast1.setExitMk("N"); // 退出 |
| | | wrkMast1.setEmptyMk("N"); // 空板 |
| | | wrkMast1.setLinkMis("N"); |
| | | wrkMast1.setAppeUser(userId); // 操作人员数据 |
| | | wrkMast1.setAppeTime(now); |
| | | wrkMast1.setModiUser(userId); |
| | | wrkMast1.setModiTime(now); |
| | | wrkMast1.setBarcode(barcode2); |
| | | if (!wrkMastService.insert(wrkMast1)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("zpallet", map.get("barcode"))); |
| | | if (Cools.isEmpty(wrkDetls)) { |
| | | throw new CoolException("未查询到拣料任务明细"); |