| | |
| | | } |
| | | |
| | | @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>() |
| | |
| | | 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"); |