| | |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.nc.SendUtil; |
| | | import com.zy.nc.entity.*; |
| | | import com.zy.nc.service.NccSaleDbddWmsService; |
| | | import com.zy.nc.service.NccSaleXsfhmxWmsService; |
| | | import com.zy.nc.service.NccScPcdaWmsService; |
| | | import com.zy.nc.util.NcResultMessage; |
| | |
| | | |
| | | @Autowired |
| | | private NccSaleXsfhmxWmsService nccSaleXsfhmxWmsService; |
| | | @Autowired |
| | | private NccSaleDbddWmsService nccSaleDbddWmsService; |
| | | |
| | | @Value("${NYNC.ip}") |
| | | private String nyncIp; |
| | |
| | | Object process2 = null; |
| | | String memo = order.getMemo(); |
| | | String remark = ""; |
| | | boolean success = false; |
| | | log.info("订单开始上报:{}", JSON.toJSONString(order)); |
| | | try { |
| | | switch (order.getDocType$().toString()) { |
| | |
| | | if (!Cools.isEmpty(response) && response.isSuccess()) { |
| | | log.info("销售发货response:{}", response); |
| | | step = 10; |
| | | success = true; |
| | | } else { |
| | | remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); |
| | | } |
| | |
| | | if (!Cools.isEmpty(response) && response.isSuccess()) { |
| | | log.info("销售发货response:{}", response); |
| | | step = 10; |
| | | success = true; |
| | | } else { |
| | | remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); |
| | | } |
| | |
| | | if (!Cools.isEmpty(response) && response.isSuccess()) { |
| | | log.info("转库-入库response:{}", response); |
| | | step = 10; |
| | | success = true; |
| | | } else { |
| | | remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); |
| | | } |
| | |
| | | if (!Cools.isEmpty(response) && response.isSuccess()) { |
| | | log.info("转库-出库2response:{}", response); |
| | | step = 10; |
| | | success = true; |
| | | } else { |
| | | remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); |
| | | } |
| | |
| | | if (!Cools.isEmpty(response) && response.isSuccess()) { |
| | | log.info("转库-出库2response:{}", response); |
| | | step = 10; |
| | | success = true; |
| | | } else { |
| | | remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); |
| | | } |
| | |
| | | if (!Cools.isEmpty(response) && response.isSuccess()) { |
| | | log.info("集团内部调拨response:{}", response); |
| | | step = 10; |
| | | success = true; |
| | | } else { |
| | | remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); |
| | | } |
| | |
| | | e.printStackTrace(); |
| | | throw new CoolException("调用接口报错,请联系管理员"); |
| | | } finally { |
| | | reportApiLog(response, order.getDocType$(), nyncIp, saveRefDelivery); |
| | | reportApiLog(order, process1, process2, response, order.getDocType$(), nyncIp, saveRefDelivery, success); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public boolean reportTkrk(String matnr, String batch, String orderNo, Double anfme) { |
| | | Object process1 = processTKRK(matnr, batch, orderNo, anfme); |
| | | //发送请求 |
| | | NcResultMessage response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, saveRefDelivery, JSONObject.toJSONString(process1)); |
| | | log.info("退库入库response:{}", response); |
| | | if (!Cools.isEmpty(response) && response.isSuccess()) { |
| | | log.info("退库入库response:{}", response); |
| | | return true; |
| | | } else { |
| | | // remark = response.getMessage() + "--" + response.getErrorStack().substring(0, 100); |
| | | return false; |
| | | Object process1 = null; |
| | | NcResultMessage response1 = null; |
| | | boolean success1 = false; |
| | | try { |
| | | process1 = processTKRK(matnr, batch, orderNo, anfme); |
| | | //发送请求 |
| | | response1 = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, saveRefDelivery, JSONObject.toJSONString(process1)); |
| | | log.info("退库入库response:{}", response1); |
| | | if (!Cools.isEmpty(response1) && response1.isSuccess()) { |
| | | log.info("退库入库response:{}", response1); |
| | | success1 = true; |
| | | return true; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | process1 = e.getMessage(); |
| | | } finally { |
| | | reportApiLog(null, process1, process1, response1, "TKRK", nyncIp, saveRefDelivery, success1); |
| | | } |
| | | |
| | | Object process2 = null; |
| | | NcResultMessage response2 = null; |
| | | boolean success2 = false; |
| | | try { |
| | | process2 = processDBTK(matnr, batch, orderNo, anfme); |
| | | //发送请求 |
| | | response2 = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, dbdd, JSONObject.toJSONString(process2)); |
| | | log.info("退库入库response:{}", response2); |
| | | if (!Cools.isEmpty(response2) && response2.isSuccess()) { |
| | | log.info("退库入库response:{}", response2); |
| | | success2 = true; |
| | | return true; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | process2 = e.getMessage(); |
| | | } finally { |
| | | reportApiLog(null, process2, process2, response2, "DBRK", nyncIp, dbdd, success2); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | |
| | | saleOutBodyVO.setVbatchcode(orderDetl.getBatch()); |
| | | saleOutBodyVO.setNshouldnum(flag ? -orderDetl.getQty() : orderDetl.getQty()); |
| | | saleOutBodyVO.setNnum(flag ? -orderDetl.getQty() : orderDetl.getQty()); |
| | | saleOutBodyVO.setCstateid(orderDetl.getCstateid()); |
| | | saleOutBodyVOList.add(saleOutBodyVO); |
| | | } |
| | | data.put("SaleOutHeadVO", saleOutHeadVO); |
| | |
| | | |
| | | data.put("SaleOutHeadVO", saleOutHeadVO); |
| | | data.put("SaleOutBodyVO", saleOutBodyVOList); |
| | | return data; |
| | | } |
| | | |
| | | private Object processDBTK(String matnr, String batch, String orderNo, Double anfme) { |
| | | List<NccSaleDbddWms> nccSaleDbddWmsList = nccSaleDbddWmsService.selectList(new EntityWrapper<NccSaleDbddWms>() |
| | | .eq("wlbm", matnr) |
| | | .eq("vbillcode", orderNo) |
| | | ); |
| | | |
| | | if (nccSaleDbddWmsList.isEmpty()) { |
| | | throw new CoolException("调拨订单ERP数据为空"); |
| | | } |
| | | |
| | | NccSaleDbddWms nccSaleDbddWms = nccSaleDbddWmsList.get(0); |
| | | |
| | | //组装对象数据 |
| | | Map<String, Object> data = new HashMap<String, Object>(); |
| | | |
| | | List<IaIjBillB> bids = new ArrayList<>(); |
| | | IaIjBillB iaIjBillB = new IaIjBillB(); |
| | | NccScPcdaWms nccScPcdaWms = nccScPcdaWmsService.selectOne(new EntityWrapper<NccScPcdaWms>().eq("vbatchcode", batch).eq("wlbm", matnr)); |
| | | if (nccScPcdaWms == null) { |
| | | throw new CoolException("批次[{}]物料[{}]未找到" + batch + "-" + matnr); |
| | | } |
| | | |
| | | Double weight = MatUtils.calcWeight(matnr, anfme); |
| | | iaIjBillB.setBid(nccSaleDbddWms.getCbill_bid()); |
| | | iaIjBillB.setNassistnum(weight * -1); |
| | | iaIjBillB.setNnum(anfme * -1); |
| | | iaIjBillB.setVbatchcode(batch); |
| | | iaIjBillB.setClocationid(""); |
| | | iaIjBillB.setCstateid(nccScPcdaWms.getVcode()); |
| | | |
| | | bids.add(iaIjBillB); |
| | | |
| | | data.put("hid", nccSaleDbddWms.getCbillid()); |
| | | data.put("bids", bids); |
| | | return data; |
| | | } |
| | | |
| | |
| | | private Object processDBDD(List<OrderDetl> orderDetls) { |
| | | //组装对象数据 |
| | | Map<String, Object> data = new HashMap<String, Object>(); |
| | | IaIjBill iaIjBill = new IaIjBill(); |
| | | iaIjBill.setPk_org("FYT"); |
| | | //iaIjBill.setCwarehouseid("6101"); |
| | | IaIjBillB iaIjBillB = null; |
| | | List<IaIjBillB> iaIjBillBS = new ArrayList<>(); |
| | | |
| | | String hid = ""; |
| | | List<IaIjBillB> bids = new ArrayList<>(); |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | iaIjBillB = new IaIjBillB(); |
| | | if (orderDetl.getQty() <= 0) { |
| | | continue; |
| | | } |
| | | IaIjBillB iaIjBillB = new IaIjBillB(); |
| | | String remark = orderDetl.getRemark(); |
| | | if (!Cools.isEmpty(remark)) { |
| | | NccSaleDbddWms nccSaleXsfhmxWms = JSONObject.parseObject(remark, NccSaleDbddWms.class); |
| | | iaIjBillB.setCinventoryid(nccSaleXsfhmxWms.getWlbm()); |
| | | iaIjBillB.setCinventoryvid(nccSaleXsfhmxWms.getWlbm()); |
| | | iaIjBillB.setCsrcid(nccSaleXsfhmxWms.getCbillid()); |
| | | iaIjBillB.setNnum(orderDetl.getQty().intValue() + ""); |
| | | iaIjBillB.setPk_org("FYT"); |
| | | Double weight = MatUtils.calcWeight(orderDetl.getMatnr(), orderDetl.getQty()); |
| | | NccSaleDbddWms nccSaleDbddWms = JSONObject.parseObject(remark, NccSaleDbddWms.class); |
| | | iaIjBillB.setBid(nccSaleDbddWms.getCbill_bid()); |
| | | iaIjBillB.setNassistnum(weight); |
| | | iaIjBillB.setNnum(orderDetl.getQty()); |
| | | iaIjBillB.setVbatchcode(orderDetl.getBatch()); |
| | | iaIjBillB.setClocationid(""); |
| | | iaIjBillB.setCstateid(orderDetl.getCstateidVcode()); |
| | | |
| | | hid = nccSaleDbddWms.getCbillid(); |
| | | } |
| | | iaIjBillBS.add(iaIjBillB); |
| | | bids.add(iaIjBillB); |
| | | } |
| | | data.put("ia_ijbill", iaIjBill); |
| | | data.put("ia_ijbill_b", iaIjBillBS); |
| | | data.put("hid", hid); |
| | | data.put("bids", bids); |
| | | return data; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | private Boolean reportApiLog(Object data, String docType, String url, String path) { |
| | | String response = ""; |
| | | boolean success = false; |
| | | private Boolean reportApiLog(Order order, Object process1, Object process2, Object response, String docType, String url, String path, Boolean success) { |
| | | HashMap<String, Object> request = new HashMap<>(); |
| | | request.put("order", order); |
| | | request.put("process1", process1); |
| | | request.put("process2", process2); |
| | | |
| | | apiLogService.save( |
| | | docType, |
| | | url + path, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(data), |
| | | response, |
| | | JSON.toJSONString(request), |
| | | JSON.toJSONString(response), |
| | | success |
| | | ); |
| | | return false; |