| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean reportTkrk(String matnr, String batch, String orderNo, Double anfme) { |
| | | public boolean reportTkrk(WaitPakin waitPakin) { |
| | | String matnr = waitPakin.getMatnr(); |
| | | String batch = waitPakin.getBatch(); |
| | | String orderNo = waitPakin.getOrderNo(); |
| | | Double anfme = waitPakin.getAnfme(); |
| | | |
| | | Object process1 = null; |
| | | NcResultMessage response1 = null; |
| | | boolean success1 = false; |
| | | try { |
| | | process1 = processTKRK(matnr, batch, orderNo, anfme); |
| | | process1 = processTKRK(matnr, batch, orderNo, anfme, waitPakin.getCstateid()); |
| | | //发送请求 |
| | | response1 = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, saveRefDelivery, JSONObject.toJSONString(process1)); |
| | | log.info("退库入库response:{}", response1); |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | process1 = e.getMessage(); |
| | | } finally { |
| | | reportApiLog(null, process1, process1, response1, "TKRK", nyncIp, saveRefDelivery, success1); |
| | | } |
| | |
| | | NcResultMessage response2 = null; |
| | | boolean success2 = false; |
| | | try { |
| | | process2 = processDBTK(matnr, batch, orderNo, anfme); |
| | | process2 = processDBTK(matnr, batch, orderNo, anfme, waitPakin.getCstateidVcode()); |
| | | //发送请求 |
| | | response2 = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, dbdd, JSONObject.toJSONString(process2)); |
| | | log.info("退库入库response:{}", response2); |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | process2 = e.getMessage(); |
| | | } finally { |
| | | reportApiLog(null, process2, process2, response2, "DBRK", nyncIp, dbdd, success2); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean reportCheckOrder(String matnr, String batch) { |
| | | List<InventoryCheckOrderDetl> checkOrderDetls = inventoryCheckOrderDetlService.selectList(new EntityWrapper<InventoryCheckOrderDetl>() |
| | | .eq("matnr", matnr) |
| | | .eq("batch", batch) |
| | | ); |
| | | |
| | | ArrayList<String> warehouseIdList = new ArrayList<>(); |
| | | public boolean reportCheckOrder(List<InventoryCheckOrderDetl> checkOrderDetls) { |
| | | ArrayList<String> orderNoList = new ArrayList<>(); |
| | | HashMap<String, List<InventoryCheckOrderDetl>> map = new HashMap<>(); |
| | | for (InventoryCheckOrderDetl checkOrderDetl : checkOrderDetls) { |
| | | if (!warehouseIdList.contains(checkOrderDetl.getCwarehouseid())) { |
| | | warehouseIdList.add(checkOrderDetl.getCwarehouseid()); |
| | | if (map.containsKey(checkOrderDetl.getCwarehouseid())) { |
| | | List<InventoryCheckOrderDetl> list = map.get(checkOrderDetl.getCwarehouseid()); |
| | | list.add(checkOrderDetl); |
| | | map.put(checkOrderDetl.getCwarehouseid(), list); |
| | | }else { |
| | | List<InventoryCheckOrderDetl> list = new ArrayList<>(); |
| | | list.add(checkOrderDetl); |
| | | map.put(checkOrderDetl.getCwarehouseid(), list); |
| | | } |
| | | |
| | | if (!orderNoList.contains(checkOrderDetl.getOrderNo())) { |
| | | orderNoList.add(checkOrderDetl.getOrderNo()); |
| | | } |
| | | } |
| | | |
| | | boolean result = true; |
| | | for (String cwarehouseid : warehouseIdList) { |
| | | Object process1 = processInvcount(matnr, batch, cwarehouseid); |
| | | for (Map.Entry<String, List<InventoryCheckOrderDetl>> entry : map.entrySet()) { |
| | | String cwarehouseid = entry.getKey(); |
| | | List<InventoryCheckOrderDetl> list = entry.getValue(); |
| | | Object process1 = processInvcount(list, cwarehouseid); |
| | | //发送请求 |
| | | NcResultMessage response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, invcountAdd, JSONObject.toJSONString(process1)); |
| | | log.info("盘点单response:{}", response); |
| | |
| | | result = false; |
| | | } |
| | | } |
| | | |
| | | |
| | | if (result) { |
| | | List<InventoryCheckOrder> inventoryCheckOrders = inventoryCheckOrderService.selectList(new EntityWrapper<InventoryCheckOrder>() |
| | |
| | | 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); |
| | |
| | | return data; |
| | | } |
| | | |
| | | private Object processTKRK(String matnr,String batch, String orderNo, Double anfme) { |
| | | private Object processTKRK(String matnr, String batch, String orderNo, Double anfme, String cstateid) { |
| | | // EntityWrapper<NccXsckmxTkWms> wrapper = new EntityWrapper<>(); |
| | | // wrapper.eq("VBATCHCODE", batch).eq("VSOURCEBILLCODE", orderNo); |
| | | // NccXsckmxTkWms nccXsckmxTkWms = nccXsckmxTkWmsService.selectOne(wrapper); |
| | |
| | | .eq("VBILLCODE", orderNo) |
| | | .eq("WLBM", matnr) |
| | | ); |
| | | if(null == nccSaleXsfhmxWms) { |
| | | if (null == nccSaleXsfhmxWms) { |
| | | throw new CoolException("未找到销售单据"); |
| | | } |
| | | |
| | |
| | | |
| | | saleOutBodyVO.setVbatchcode(batch); |
| | | saleOutBodyVO.setNnum(anfme * -1); |
| | | saleOutBodyVO.setCstateid(cstateid); |
| | | saleOutBodyVOList.add(saleOutBodyVO); |
| | | |
| | | data.put("SaleOutHeadVO", saleOutHeadVO); |
| | |
| | | return data; |
| | | } |
| | | |
| | | private Object processDBTK(String matnr, String batch, String orderNo, Double anfme) { |
| | | private Object processDBTK(String matnr, String batch, String orderNo, Double anfme, String cstateid) { |
| | | List<NccSaleDbddWms> nccSaleDbddWmsList = nccSaleDbddWmsService.selectList(new EntityWrapper<NccSaleDbddWms>() |
| | | .eq("wlbm", matnr) |
| | | .eq("vbillcode", orderNo) |
| | |
| | | |
| | | 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); |
| | | } |
| | | // 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); |
| | | iaIjBillB.setNassistnum(weight * -1); |
| | | iaIjBillB.setNnum(anfme * -1); |
| | | iaIjBillB.setVbatchcode(batch); |
| | | iaIjBillB.setClocationid(""); |
| | | iaIjBillB.setCstateid(nccScPcdaWms.getVcode()); |
| | | iaIjBillB.setCstateid(cstateid); |
| | | |
| | | bids.add(iaIjBillB); |
| | | |
| | | data.put("hid", nccSaleDbddWms.getCbill_bid()); |
| | | data.put("hid", nccSaleDbddWms.getCbillid()); |
| | | data.put("bids", bids); |
| | | return data; |
| | | } |
| | | |
| | | private Object processInvcount(String matnr, String batch, String cwarehouseid) { |
| | | List<InventoryCheckOrderDetl> inventoryCheckOrderDetls = inventoryCheckOrderDetlService.selectList(new EntityWrapper<InventoryCheckOrderDetl>() |
| | | .eq("matnr", matnr) |
| | | .eq("batch", batch) |
| | | .eq("cwarehouseid", cwarehouseid) |
| | | ); |
| | | private Object processInvcount(List<InventoryCheckOrderDetl> inventoryCheckOrderDetls, String cwarehouseid) { |
| | | if (inventoryCheckOrderDetls.isEmpty()) { |
| | | throw new CoolException("盘点明细不存在"); |
| | | } |
| | | |
| | | //合并数量 |
| | | BigDecimal checkAnfmeDecimal = new BigDecimal(0); |
| | | HashMap<String, InventoryCheckOrderDetl> map = new HashMap<>(); |
| | | for (InventoryCheckOrderDetl checkOrderDetl : inventoryCheckOrderDetls) { |
| | | checkAnfmeDecimal = checkAnfmeDecimal.add(BigDecimal.valueOf(checkOrderDetl.getCheckAnfme())); |
| | | } |
| | | String key = checkOrderDetl.getMatnr() + "_" + checkOrderDetl.getBatch() + "_" + checkOrderDetl.getCstateid(); |
| | | if (map.containsKey(key)) { |
| | | InventoryCheckOrderDetl orderDetl = map.get(key); |
| | | BigDecimal checkAnfmeDecimal = BigDecimal.valueOf(orderDetl.getCheckAnfme()); |
| | | checkAnfmeDecimal = checkAnfmeDecimal.add(BigDecimal.valueOf(checkOrderDetl.getCheckAnfme())); |
| | | //计算辅数量 |
| | | Double weight = MatUtils.calcWeight(orderDetl.getMatnr(), checkAnfmeDecimal.doubleValue()); |
| | | |
| | | //计算辅数量 |
| | | Double weight = MatUtils.calcWeight(matnr, checkAnfmeDecimal.doubleValue()); |
| | | orderDetl.setCheckAnfme(checkAnfmeDecimal.doubleValue()); |
| | | orderDetl.setWeight(weight); |
| | | map.put(key, orderDetl); |
| | | } else { |
| | | //计算辅数量 |
| | | Double weight = MatUtils.calcWeight(checkOrderDetl.getMatnr(), checkOrderDetl.getCheckAnfme()); |
| | | checkOrderDetl.setWeight(weight); |
| | | map.put(key, checkOrderDetl); |
| | | } |
| | | } |
| | | |
| | | //组装对象数据 |
| | | Map<String, Object> data = new HashMap<String, Object>(); |
| | | |
| | | List<InvCountBodyVO> invCountBodyVOList = new ArrayList<>(); |
| | | |
| | | NccScPcdaWms nccScPcdaWms = nccScPcdaWmsService.selectOne(new EntityWrapper<NccScPcdaWms>() |
| | | .eq("WLBM", matnr) |
| | | .eq("VBATCHCODE", batch) |
| | | ); |
| | | if (null == nccScPcdaWms) { |
| | | throw new CoolException("ERP数据库无法查询到盘点上报数据"); |
| | | for (Map.Entry<String, InventoryCheckOrderDetl> entry : map.entrySet()) { |
| | | InventoryCheckOrderDetl checkOrderDetl = entry.getValue(); |
| | | String matnr = checkOrderDetl.getMatnr(); |
| | | String batch = checkOrderDetl.getBatch(); |
| | | |
| | | NccScPcdaWms nccScPcdaWms = nccScPcdaWmsService.selectOne(new EntityWrapper<NccScPcdaWms>() |
| | | .eq("WLBM", matnr) |
| | | .eq("VBATCHCODE", batch) |
| | | ); |
| | | if (null == nccScPcdaWms) { |
| | | throw new CoolException("ERP数据库无法查询到盘点上报数据"); |
| | | } |
| | | InvCountBodyVO invCountBodyVO = new InvCountBodyVO(); |
| | | invCountBodyVO.setCmaterialoid(matnr); |
| | | invCountBodyVO.setVbatchcode(batch); |
| | | invCountBodyVO.setNcountnum(checkOrderDetl.getCheckAnfme()); |
| | | invCountBodyVO.setNcountastnum(checkOrderDetl.getWeight()); |
| | | invCountBodyVO.setCstateid(nccScPcdaWms.getPkStorestate()); |
| | | invCountBodyVO.setPk_batchcode(nccScPcdaWms.getPkBatchcode()); |
| | | invCountBodyVOList.add(invCountBodyVO); |
| | | } |
| | | InvCountBodyVO invCountBodyVO = new InvCountBodyVO(); |
| | | invCountBodyVO.setCmaterialoid(matnr); |
| | | invCountBodyVO.setVbatchcode(batch); |
| | | invCountBodyVO.setNcountnum(checkAnfmeDecimal.doubleValue()); |
| | | invCountBodyVO.setNcountastnum(weight); |
| | | invCountBodyVO.setCstateid(nccScPcdaWms.getPkStorestate()); |
| | | invCountBodyVO.setPk_batchcode(nccScPcdaWms.getPkBatchcode()); |
| | | invCountBodyVOList.add(invCountBodyVO); |
| | | |
| | | |
| | | InvCountHeaderVO invCountHeaderVO = new InvCountHeaderVO(); |
| | | invCountHeaderVO.setPk_org("FYT"); |
| | |
| | | IaIjBillB iaIjBillB = new IaIjBillB(); |
| | | String remark = orderDetl.getRemark(); |
| | | if (!Cools.isEmpty(remark)) { |
| | | NccScPcdaWms nccScPcdaWms = nccScPcdaWmsService.selectOne(new EntityWrapper<NccScPcdaWms>().eq("vbatchcode", orderDetl.getBatch()).eq("wlbm", orderDetl.getMatnr())); |
| | | if (nccScPcdaWms == null) { |
| | | throw new CoolException("批次[{}]物料[{}]未找到" + orderDetl.getBatch() + "-" + orderDetl.getMatnr()); |
| | | } |
| | | |
| | | Double weight = MatUtils.calcWeight(orderDetl.getMatnr(), orderDetl.getQty()); |
| | | NccSaleDbddWms nccSaleDbddWms = JSONObject.parseObject(remark, NccSaleDbddWms.class); |
| | | iaIjBillB.setBid(nccSaleDbddWms.getCbill_bid()); |
| | |
| | | iaIjBillB.setNnum(orderDetl.getQty()); |
| | | iaIjBillB.setVbatchcode(orderDetl.getBatch()); |
| | | iaIjBillB.setClocationid(""); |
| | | iaIjBillB.setCstateid(nccScPcdaWms.getVcode()); |
| | | iaIjBillB.setCstateid(orderDetl.getCstateidVcode()); |
| | | |
| | | hid = nccSaleDbddWms.getCbillid(); |
| | | bids.add(iaIjBillB); |
| | | } |
| | | bids.add(iaIjBillB); |
| | | } |
| | | data.put("hid", hid); |
| | | data.put("bids", bids); |
| | |
| | | } |
| | | |
| | | whsTransBillBodyVO = new WhsTransBillBodyVO(); |
| | | whsTransBillBodyVO.setCstateid(nccScPcdaWms.getPkStorestate()); |
| | | whsTransBillBodyVO.setCstateid(orderDetl.getCstateid()); |
| | | |
| | | String remark = orderDetl.getRemark(); |
| | | //if (!Cools.isEmpty(remark)) { |
| | |
| | | generalout_b.setCsourcetype("4K-01"); |
| | | generalout_b.setCsourcebillhid(cspecialhid); |
| | | generalout_b.setCmaterialvid(orderDetl.getMatnr()); |
| | | generalout_b.setCstateid(nccScPcdaWms.getPkStorestate()); |
| | | generalout_b.setCstateid(orderDetl.getCstateid()); |
| | | generalout_b.setPk_batchcode(nccScPcdaWms.getPkBatchcode()); |
| | | StoreType storeType = storeTypeService.selectOne(new EntityWrapper<StoreType>().eq("store_id", orderDetl.getStandby1())); |
| | | generalout_b.setCdptvid(storeType.getDepartmentId()); |