| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.nc.SendUtil; |
| | | import com.zy.nc.entity.*; |
| | | import com.zy.nc.service.NccSaleXsfhmxWmsService; |
| | |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean reportCheckOrder(InventoryCheckOrder checkOrder) { |
| | | Object process1 = processInvcount(checkOrder); |
| | | //发送请求 |
| | | NcResultMessage response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, invcountAdd, 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; |
| | | 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<>(); |
| | | ArrayList<String> orderNoList = new ArrayList<>(); |
| | | for (InventoryCheckOrderDetl checkOrderDetl : checkOrderDetls) { |
| | | if (!warehouseIdList.contains(checkOrderDetl.getCwarehouseid())) { |
| | | warehouseIdList.add(checkOrderDetl.getCwarehouseid()); |
| | | } |
| | | if (!orderNoList.contains(checkOrderDetl.getOrderNo())) { |
| | | orderNoList.add(checkOrderDetl.getOrderNo()); |
| | | } |
| | | } |
| | | |
| | | boolean result = true; |
| | | for (String cwarehouseid : warehouseIdList) { |
| | | Object process1 = processInvcount(matnr, batch, cwarehouseid); |
| | | //发送请求 |
| | | NcResultMessage response = SendUtil.sendDataToNc(SendUtil.token, nyncIp + ":" + port, invcountAdd, JSONObject.toJSONString(process1)); |
| | | log.info("盘点单response:{}", response); |
| | | if (!Cools.isEmpty(response) && response.isSuccess()) { |
| | | log.info("盘点单response:{}", response); |
| | | } else { |
| | | result = false; |
| | | } |
| | | } |
| | | |
| | | |
| | | if (result) { |
| | | List<InventoryCheckOrder> inventoryCheckOrders = inventoryCheckOrderService.selectList(new EntityWrapper<InventoryCheckOrder>() |
| | | .in("order_no", orderNoList) |
| | | .eq("status", 1) |
| | | ); |
| | | |
| | | for (InventoryCheckOrder inventoryCheckOrder : inventoryCheckOrders) { |
| | | inventoryCheckOrder.setStatus("2"); |
| | | inventoryCheckOrderService.updateById(inventoryCheckOrder); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private Object processXSFH(List<OrderDetl> orderDetls, Boolean flag) { |
| | |
| | | return data; |
| | | } |
| | | |
| | | private Object processInvcount(InventoryCheckOrder checkOrder) { |
| | | private Object processInvcount(String matnr, String batch, String cwarehouseid) { |
| | | List<InventoryCheckOrderDetl> inventoryCheckOrderDetls = inventoryCheckOrderDetlService.selectList(new EntityWrapper<InventoryCheckOrderDetl>() |
| | | .eq("order_no", checkOrder.getOrderNo())); |
| | | .eq("matnr", matnr) |
| | | .eq("batch", batch) |
| | | .eq("cwarehouseid", cwarehouseid) |
| | | ); |
| | | if (inventoryCheckOrderDetls.isEmpty()) { |
| | | throw new CoolException("盘点明细不存在"); |
| | | } |
| | | |
| | | //合并数量 |
| | | BigDecimal checkAnfmeDecimal = new BigDecimal(0); |
| | | for (InventoryCheckOrderDetl checkOrderDetl : inventoryCheckOrderDetls) { |
| | | checkAnfmeDecimal = checkAnfmeDecimal.add(BigDecimal.valueOf(checkOrderDetl.getCheckAnfme())); |
| | | } |
| | | |
| | | //计算辅数量 |
| | | Double weight = MatUtils.calcWeight(matnr, checkAnfmeDecimal.doubleValue()); |
| | | |
| | | //组装对象数据 |
| | | Map<String, Object> data = new HashMap<String, Object>(); |
| | | |
| | | //仓库id |
| | | String cwarehouseid = null; |
| | | List<InvCountBodyVO> invCountBodyVOList = new ArrayList<>(); |
| | | for (InventoryCheckOrderDetl inventoryCheckOrderDetl : inventoryCheckOrderDetls) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>() |
| | | .eq("matnr", inventoryCheckOrderDetl.getMatnr()) |
| | | .eq("batch", inventoryCheckOrderDetl.getBatch()) |
| | | ); |
| | | if (wrkDetls.isEmpty()) { |
| | | throw new CoolException("工作档明细不存在"); |
| | | } |
| | | |
| | | cwarehouseid = wrkDetls.get(0).getStandby1(); |
| | | |
| | | InvCountBodyVO invCountBodyVO = new InvCountBodyVO(); |
| | | invCountBodyVO.setCmaterialoid(inventoryCheckOrderDetl.getMatnr()); |
| | | invCountBodyVO.setVbatchcode(inventoryCheckOrderDetl.getBatch()); |
| | | invCountBodyVO.setNcountastnum(inventoryCheckOrderDetl.getCheckAnfme()); |
| | | invCountBodyVOList.add(invCountBodyVO); |
| | | 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(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"); |
| | |
| | | |
| | | data.put("InvCountHeaderVO", invCountHeaderVO); |
| | | data.put("InvCountBodyVO", invCountBodyVOList); |
| | | return data; |
| | | data.put("paper", "1"); |
| | | data.put("splr", "0"); |
| | | |
| | | ArrayList<Map<String, Object>> list = new ArrayList<>(); |
| | | list.add(data); |
| | | return list; |
| | | } |
| | | |
| | | private Object processZKRK(List<OrderDetl> orderDetls) { |
| | |
| | | } |
| | | |
| | | whsTransBillBodyVO = new WhsTransBillBodyVO(); |
| | | whsTransBillBodyVO.setCstateid(nccScPcdaWms.getPkBatchcode()); |
| | | whsTransBillBodyVO.setCstateid(nccScPcdaWms.getPkStorestate()); |
| | | |
| | | String remark = orderDetl.getRemark(); |
| | | //if (!Cools.isEmpty(remark)) { |
| | |
| | | whsTransBillBodyVO.setNnum(orderDetl.getQty()); |
| | | whsTransBillBodyVO.setCmaterialoid(orderDetl.getMatnr()); |
| | | whsTransBillBodyVO.setVbatchcode(orderDetl.getBatch()); |
| | | whsTransBillBodyVO.setPk_batchcode(nccScPcdaWms.getPkBatchcode()); |
| | | //} |
| | | whsTransBillHeaderVO.setCwarehouseid(orderDetl.getStandby1()); |
| | | whsTransBillBodyVOS.add(whsTransBillBodyVO); |
| | |
| | | ic_generalout_b generalout_b = null; |
| | | List<ic_generalout_b> ic_purchasein_bs = new ArrayList<>(); |
| | | for (int i = 0; i < orderDetls.size(); i++) { |
| | | // NccScPcdaWms nccScPcdaWms = nccScPcdaWmsService.selectOne(new EntityWrapper<NccScPcdaWms>().eq("vbatchcode", orderDetls.get(i).getBatch()).eq("wlbm", orderDetls.get(i).getMatnr())); |
| | | // if (nccScPcdaWms == null) { |
| | | // throw new CoolException("批次[{}]物料[{}]未找到" + orderDetls.get(i).getBatch() + orderDetls.get(i).getMatnr()); |
| | | // } |
| | | NccScPcdaWms nccScPcdaWms = nccScPcdaWmsService.selectOne(new EntityWrapper<NccScPcdaWms>().eq("vbatchcode", orderDetls.get(i).getBatch()).eq("wlbm", orderDetls.get(i).getMatnr())); |
| | | if (nccScPcdaWms == null) { |
| | | throw new CoolException("批次[{}]物料[{}]未找到" + orderDetls.get(i).getBatch() + orderDetls.get(i).getMatnr()); |
| | | } |
| | | |
| | | OrderDetl orderDetl = orderDetls.get(i); |
| | | generalout_h.setCwarehouseid(orderDetl.getStandby1()); |
| | | generalout_b = new ic_generalout_b(); |
| | |
| | | generalout_b.setCsourcetype("4K-01"); |
| | | generalout_b.setCsourcebillhid(cspecialhid); |
| | | generalout_b.setCmaterialvid(orderDetl.getMatnr()); |
| | | //generalout_b.setCstateid(nccScPcdaWms.getVcode()); |
| | | generalout_b.setCstateid(nccScPcdaWms.getPkStorestate()); |
| | | generalout_b.setPk_batchcode(nccScPcdaWms.getPkBatchcode()); |
| | | StoreType storeType = storeTypeService.selectOne(new EntityWrapper<StoreType>().eq("store_id", orderDetl.getStandby1())); |
| | | generalout_b.setCdptvid(storeType.getDepartmentId()); |
| | | generalout_b.setBillmaker(renyuan); |