diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/WmsProductPutServiceImpl.java b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/WmsProductPutServiceImpl.java index 05c0d9bd..d54ade9a 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/WmsProductPutServiceImpl.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/WmsProductPutServiceImpl.java @@ -306,12 +306,59 @@ public class WmsProductPutServiceImpl implements IWmsProductPutService { Date date = new Date(); String formattedDate = dateFormat.format(date);//批次 //List wmsProductPutList= new ArrayList<>(); + List wmsReportWorkList=new ArrayList<>(); + List wmsReportWorkListRk=new ArrayList<>(); + List wmsReportWorkListagain=new ArrayList<>(); for (wmsReportWork mesReportWork: - mesReportWorks) { + mesReportWorks) { + WmsProductPut wmsProductPutk=new WmsProductPut(); + wmsProductPutk.setWorkOrder(mesReportWork.getReportCode()); + wmsProductPutk.setFactoryCode(mesReportWork.getFactoryCode()); + wmsProductPutk.setWhCode(mesReportWork.getWhCode());//仓库编码 + wmsProductPutk.setProductName(mesReportWork.getProductName()); + wmsProductPutk.setProductCode(mesReportWork.getProductCode()); + wmsProductPutk.setProductOrder(mesReportWork.getWorkorderCodeSap()); + wmsProductPutk.setPlanQuantity(mesReportWork.getQuantityFeedback()); + wmsProductPutk.setPutQuantity(mesReportWork.getQuantityQualified()); + wmsProductPutk.setStatus("1"); + wmsProductPutk.setUnitOfMeasure(mesReportWork.getUnit()); + wmsProductPutk.setBatchNumber(mesReportWork.getBatch());// + //wmsProductPutk.setSapStatus("2"); + List wmsProductPutList= wmsProductPutMapper.selectWmsProductPutList(wmsProductPutk); + if (wmsProductPutList.size()>0){ + String id= wmsProductPutList.get(0).getId(); + mesReportWork.setId(id); + wmsReportWorkList.add(mesReportWork); + }else { + wmsReportWorkListRk.add(mesReportWork); + } + } + for (wmsReportWork mesReportWork: + wmsReportWorkList) { + WmsProductPut wmsProductPutk=new WmsProductPut(); + wmsProductPutk.setWorkOrder(mesReportWork.getReportCode()); + wmsProductPutk.setFactoryCode(mesReportWork.getFactoryCode()); + wmsProductPutk.setWhCode(mesReportWork.getWhCode());//仓库编码 + wmsProductPutk.setProductName(mesReportWork.getProductName()); + wmsProductPutk.setProductCode(mesReportWork.getProductCode()); + wmsProductPutk.setProductOrder(mesReportWork.getWorkorderCodeSap()); + wmsProductPutk.setPlanQuantity(mesReportWork.getQuantityFeedback()); + wmsProductPutk.setPutQuantity(mesReportWork.getQuantityQualified()); + wmsProductPutk.setStatus("1"); + wmsProductPutk.setUnitOfMeasure(mesReportWork.getUnit()); + wmsProductPutk.setBatchNumber(mesReportWork.getBatch());// + wmsProductPutk.setSapStatus("2"); + List wmsProductPutList= wmsProductPutMapper.selectWmsProductPutList(wmsProductPutk); + if (wmsProductPutList.size()>0){ + wmsReportWorkListagain.add(mesReportWork);//再次过账 + } + } + for (wmsReportWork mesReportWork: + wmsReportWorkListRk) { WmsProductPut wmsProductPutk=new WmsProductPut(); //wms_product_put mesReportWork.setId(IdUtils.fastSimpleUUID()); - wmsProductPutk.setId(mesReportWork.getId()); + wmsProductPutk.setWorkOrder(mesReportWork.getReportCode()); wmsProductPutk.setFactoryCode(mesReportWork.getFactoryCode()); wmsProductPutk.setWhCode(mesReportWork.getWhCode());//仓库编码 @@ -321,13 +368,17 @@ public class WmsProductPutServiceImpl implements IWmsProductPutService { wmsProductPutk.setPlanQuantity(mesReportWork.getQuantityFeedback()); wmsProductPutk.setPutQuantity(mesReportWork.getQuantityQualified()); wmsProductPutk.setStatus("1"); - wmsProductPutk.setSapStatus("0"); + wmsProductPutk.setUnitOfMeasure(mesReportWork.getUnit()); wmsProductPutk.setBatchNumber(mesReportWork.getBatch());// + //List wmsProductPutList= wmsProductPutMapper.selectWmsProductPutList(wmsProductPutk); + wmsProductPutk.setAttr3(formattedDate);// wmsProductPutk.setCreateBy(mesReportWork.getCreateBy()); wmsProductPutk.setCreateTime(new Date()); - wmsProductPutk.setUnitOfMeasure(mesReportWork.getUnit()); + wmsProductPutk.setProductDate(mesReportWork.getProductDate()); + wmsProductPutk.setId(mesReportWork.getId()); + wmsProductPutk.setSapStatus("0"); wmsProductPutMapper.insertWmsProductPut(wmsProductPutk); //入库记录 WmsProductPutRecords wmsProductPutRecords=new WmsProductPutRecords(); @@ -368,36 +419,71 @@ public class WmsProductPutServiceImpl implements IWmsProductPutService { wmsFpStorageNewsMapper.insertWmsFpStorageNews(wmsFpStorageNews); } } - List> mapList = new ArrayList<>(); - for (wmsReportWork mesReportWork: - mesReportWorks) { - Map map = new HashMap<>(); - map.put("AUFNR",mesReportWork.getWorkorderCodeSap()); - map.put("WERKS",mesReportWork.getFactoryCode()); - map.put("LGORT",mesReportWork.getWhCode()); - map.put("QUANTITY",mesReportWork.getQuantityQualified()); - map.put("ERFME",mesReportWork.getUnit()); - map.put("BATCH",mesReportWork.getBatch()); - map.put("HSDAT",mesReportWork.getProductDate()); - mapList.add(map); + if(wmsReportWorkListRk.size()>0){ + List> mapList = new ArrayList<>(); + for (wmsReportWork mesReportWork: + wmsReportWorkListRk) { + Map map = new HashMap<>(); + map.put("AUFNR",mesReportWork.getWorkorderCodeSap()); + map.put("WERKS",mesReportWork.getFactoryCode()); + map.put("LGORT",mesReportWork.getWhCode()); + map.put("QUANTITY",mesReportWork.getQuantityQualified()); + map.put("ERFME",mesReportWork.getUnit()); + map.put("BATCH",mesReportWork.getBatch()); + map.put("HSDAT",mesReportWork.getProductDate()); + mapList.add(map); + } + //过账 + R result=remoteSapService.sapOrderReceipt(mapList); + int code= result.getCode(); + String msg= result.getMsg(); + for (wmsReportWork mesReportWork: + wmsReportWorkListRk) { + WmsProductPut wmsProductPut2=new WmsProductPut(); + wmsProductPut2.setId(mesReportWork.getId()); + wmsProductPut2.setSapMessage(msg); + if (code==200) {//过账成功 + String tem= (String) result.getData(); + wmsProductPut2.setSapProof(tem); + wmsProductPut2.setSapStatus("1"); + }else { + wmsProductPut2.setSapStatus("2"); + } + wmsProductPutMapper.updateWmsProductPut(wmsProductPut2); + } } - //过账 - R result=remoteSapService.sapOrderReceipt(mapList); - int code= result.getCode(); - String msg= result.getMsg(); - for (wmsReportWork mesReportWork: - mesReportWorks) { - WmsProductPut wmsProductPut2=new WmsProductPut(); + if (wmsReportWorkListagain.size()>0){ + List> mapList = new ArrayList<>(); + for (wmsReportWork mesReportWork: + wmsReportWorkListagain) { + Map map = new HashMap<>(); + map.put("AUFNR",mesReportWork.getWorkorderCodeSap()); + map.put("WERKS",mesReportWork.getFactoryCode()); + map.put("LGORT",mesReportWork.getWhCode()); + map.put("QUANTITY",mesReportWork.getQuantityQualified()); + map.put("ERFME",mesReportWork.getUnit()); + map.put("BATCH",mesReportWork.getBatch()); + map.put("HSDAT",mesReportWork.getProductDate()); + mapList.add(map); + } + //过账 + R result=remoteSapService.sapOrderReceipt(mapList); + int code= result.getCode(); + String msg= result.getMsg(); + for (wmsReportWork mesReportWork: + wmsReportWorkListagain) { + WmsProductPut wmsProductPut2=new WmsProductPut(); wmsProductPut2.setId(mesReportWork.getId()); wmsProductPut2.setSapMessage(msg); - if (code==200) {//过账成功 - String tem= (String) result.getData(); - wmsProductPut2.setSapProof(tem); - wmsProductPut2.setSapStatus("1"); - }else { - wmsProductPut2.setSapStatus("2"); + if (code==200) {//过账成功 + String tem= (String) result.getData(); + wmsProductPut2.setSapProof(tem); + wmsProductPut2.setSapStatus("1"); + }else { + wmsProductPut2.setSapStatus("2"); + } + wmsProductPutMapper.updateWmsProductPut(wmsProductPut2); } - wmsProductPutMapper.updateWmsProductPut(wmsProductPut2); } String SUCCESS="操作完成"; return SUCCESS;