From 6967106f6f1a454c718b3ae5a9b88ceb96d5eb59 Mon Sep 17 00:00:00 2001 From: tangyu <1184163753@qq.com> Date: Tue, 18 Mar 2025 17:38:19 +0800 Subject: [PATCH] =?UTF-8?q?egrationfeat(int):=20=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E7=89=A9=E6=96=99=E6=B6=88=E8=80=97=E5=92=8C=E5=AE=8C=E5=B7=A5?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E7=9A=84=E5=86=B2=E9=94=80=E5=8A=9F=E8=83=BD?= =?UTF-8?q?-=20=E6=96=B0=E5=A2=9E=E7=89=A9=E6=96=99=E6=B6=88=E8=80=97?= =?UTF-8?q?=E5=86=B2=E9=94=80=E5=92=8C=E5=AE=8C=E5=B7=A5=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E5=86=B2=E9=94=80=E7=9A=84=E6=8E=A5=E5=8F=A3=E5=92=8C=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=20-=20=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E6=98=A0=E5=B0=84=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=9A=84=E6=96=B9=E6=B3=95=20-=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=BA=93=E5=AD=98=E6=9B=B4=E6=96=B0=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E6=89=B9=E9=87=8F=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=20-=20=E5=A2=9E=E5=8A=A0=E5=86=B2=E9=94=80=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86=E5=92=8C=E8=B0=83?= =?UTF-8?q?=E7=94=A8SAP=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/OutSapReportController.java | 155 +++++++++++++++--- .../service/OutMaterialSapService.java | 7 +- .../impl/OutMaterialSapServiceImpl.java | 103 ++++++++++-- .../mapper/OutSapCompleteMapper.java | 5 + 4 files changed, 237 insertions(+), 33 deletions(-) diff --git a/int-core/src/main/java/com/foreverwin/iep/integration/controller/OutSapReportController.java b/int-core/src/main/java/com/foreverwin/iep/integration/controller/OutSapReportController.java index bb9a4f9..a01d8aa 100644 --- a/int-core/src/main/java/com/foreverwin/iep/integration/controller/OutSapReportController.java +++ b/int-core/src/main/java/com/foreverwin/iep/integration/controller/OutSapReportController.java @@ -1,6 +1,7 @@ package com.foreverwin.iep.integration.controller; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.foreverwin.iep.common.faas.common.util.StringUtils; import com.foreverwin.iep.integration.domain.InvokeRequest; @@ -8,27 +9,30 @@ import com.foreverwin.iep.integration.domain.InvokeResponse; import com.foreverwin.iep.integration.dto.OutShopOrderDto; import com.foreverwin.iep.integration.entity.*; import com.foreverwin.iep.integration.handler.def.sap.*; +import com.foreverwin.iep.integration.mapper.OutSapCompleteMapper; +import com.foreverwin.iep.integration.mapper.OutSapMaterialMapper; import com.foreverwin.iep.integration.mapper.OutSapShoporderStatisticsMapper; import com.foreverwin.iep.integration.service.*; import com.foreverwin.iep.prd.entity.ZLotMaterialCompleteTransaction; import com.foreverwin.iep.prd.entity.ZLotMaterialConsumptionTransaction; -import com.foreverwin.iep.prd.entity.ZShoporderStatisticsTransaction; import com.foreverwin.iep.prd.mapper.ZLotMaterialCompleteTransactionMapper; import com.foreverwin.iep.prd.mapper.ZLotMaterialConsumptionTransactionMapper; import com.foreverwin.iep.prd.mapper.ZShoporderStatisticsTransactionMapper; import com.foreverwin.iep.wip.entity.LotMaterial; +import com.foreverwin.iep.wip.feign.RemoteWipService; import com.foreverwin.iep.wip.mapper.LotMaterialMapper; +import com.foreverwin.mom.common.core.constant.SecurityConstants; import com.foreverwin.mom.common.core.exception.BusinessException; import com.foreverwin.mom.common.core.util.R; import com.foreverwin.mom.common.data.tenant.TenantContextHolder; import com.foreverwin.mom.common.log.annotation.SysLog; import com.foreverwin.mom.common.security.util.SecurityUtils; import com.foreverwin.mom.wms.api.feign.RemoteWmsInventoryService; -import com.foreverwin.mom.wms.entity.Inventory; -import com.foreverwin.mom.wms.entity.InventoryRecord; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; +import lombok.val; +import org.apache.ibatis.annotations.Update; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.web.bind.annotation.PostMapping; @@ -36,12 +40,12 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.UUID; /** @@ -56,19 +60,17 @@ import java.util.UUID; @Api(value = "shopOrderStatisticTransCallErp", tags = "完工入库事务表管理") public class OutSapReportController { - private final ZShoporderStatisticsTransactionMapper zShoporderStatisticsTransactionMapper; - private final ShopOrderStatisticTransService shopOrderStatisticTransService; - private final ShopOrderStatisticTransCancelService shopOrderStatisticTransCancelService; - private final ZLotMaterialConsumptionTransactionMapper zLotMaterialConsumptionTransactionMapper; - private final ZLotMaterialCompleteTransactionMapper zLotMaterialCompleteTransactionMapper; + private final IntInDataService intInDataService; private final IntInDataLogService intInDataLogService; - private final RegisterDocumentService registerDocumentService; - private final LotMaterialMapper lotMaterialMapper; private final OutMaterialSapService outMaterialSapService; private final OutSapShoporderStatisticsMapper outSapShoporderStatisticsMapper; private final OutShopOrderStatisticService outSapShoporderStatisticService; - private final RemoteWmsInventoryService remoteWmsInventoryService; + private final OutSapCompleteMapper outSapCompleteMapper; + private final LotMaterialMapper lotMaterialMapper; + private final ZLotMaterialCompleteTransactionMapper zLotMaterialCompleteTransactionMapper; + private final OutSapMaterialMapper outSapMaterialMapper; + private final RemoteWipService remoteWipService; @Autowired @Qualifier("ZMM_MES_GOODMVT_REVERSE") // 通过 Bean 名称注入 @@ -222,20 +224,83 @@ public class OutSapReportController { @SysLog("生产管理报工平台-物料消耗报工") @PostMapping("/callErpMaterial") public R callErpMaterial(@RequestBody OutShopOrderDto outShopOrderDto) { - InvokeResponse invokeResponse = outMaterialSapService.callLotMaterialConsumption(outShopOrderDto.getList(), false, "", outShopOrderDto.getShopOrder()); - if ("E".equals(invokeResponse.getResult())) { - return R.failed("SAP错误:" + invokeResponse.getMessageContent()); - } else { - boolean b = outMaterialSapService.batchUpdateMaterialInventory(outShopOrderDto.getList()); - if (!b) { - return R.failed("更新mes库存失败!"); +// InvokeResponse invokeResponse = outMaterialSapService.callLotMaterialConsumption(outShopOrderDto.getList(), false, "", outShopOrderDto.getShopOrder()); +// if ("E".equals(invokeResponse.getResult())) { +// return R.failed("SAP错误:" + invokeResponse.getMessageContent()); +// } else { +// boolean b = outMaterialSapService.batchUpdateMaterialInventory(outShopOrderDto.getList()); +// if (!b) { +// return R.failed("更新mes库存失败!"); +// } +// return R.ok(); +// } + String s = outMaterialSapService.batchUpdateMaterialInventory(outShopOrderDto.getList()); + if (Objects.equals(s, "OK")) { + InvokeResponse invokeResponse = outMaterialSapService.callLotMaterialConsumption(outShopOrderDto.getList(), false, "", outShopOrderDto.getShopOrder()); + if ("E".equals(invokeResponse.getResult())) { + return R.failed("SAP错误:" + invokeResponse.getMessageContent()); } return R.ok(); + } else { + return R.failed("更新mes库存失败!" + s); } } + @ApiOperation(value = "生产管理报工平台-物料消耗冲销", notes = "生产管理报工平台-物料消耗冲销") + @SysLog("生产管理报工平台-物料消耗冲销") + @PostMapping("/callErpLotCancel") + public R callErpLotCancel(@RequestBody List outSapMaterialLogs) { + for (OutSapMaterialLog targetObj : outSapMaterialLogs) { + String lotSerial = targetObj.getLotSerial(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("LOT_SERIAL", lotSerial); + List outSapMaterialLogs1 = outSapMaterialMapper.selectList(queryWrapper); + OutSapMaterialLog outSapMaterialLog = outSapMaterialLogs1.get(0); + String syncVoucherNo = outSapMaterialLog.getSyncVoucherNo(); + InvokeResponse invokeResponse = sendSapToCancel(syncVoucherNo); + if (!"S".equals(invokeResponse.getResult())) { + return R.failed("SAP错误:" + invokeResponse.getMessageContent()); + }else { + outMaterialSapService.batchUpdateMaterialSapCancel(outSapMaterialLogs1); + // 更新lotMaterial表 + targetObj.setErpReverse("Y"); + targetObj.setSyncStatus("C"); + outSapMaterialMapper.updateById(targetObj); + } + } + + return R.ok(); + } + + @ApiOperation(value = "生产管理报工平台-完工入库冲销", notes = "生产管理报工平台-完工入库冲销") + @SysLog("生产管理报工平台-完工入库冲销") + @PostMapping("/callErpLotInStockCancel") + public R callErpLotInStockCancel(@RequestBody List outMaterialCompleteLogs) { + for (OutMaterialCompleteLog targetObj : outMaterialCompleteLogs) { + // 重新校验一遍是否已经报过工,防止重复报工 + String lotNo = targetObj.getLotNo(); + String site = targetObj.getSite(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("LOT_NO", lotNo); + queryWrapper.eq("SITE", site); + ZLotMaterialCompleteTransaction zLotMaterialCompleteTransaction1 = zLotMaterialCompleteTransactionMapper.selectOne(queryWrapper); + String syncVoucherNo = zLotMaterialCompleteTransaction1.getSyncVoucherNo(); + InvokeResponse invokeResponse = sendSapToCancel(syncVoucherNo); + if (!"S".equals(invokeResponse.getResult())) { + return R.failed("SAP错误:" + invokeResponse.getMessageContent()); + } else { + outSapCompleteMapper.updateAFieldBySyncVoucherNo(syncVoucherNo); + QueryWrapper queryWrapper1 = new QueryWrapper<>(); + queryWrapper1.eq("SYNC_VOUCHER_NO", syncVoucherNo); + List zLotMaterialCompleteTransactions = zLotMaterialCompleteTransactionMapper.selectList(queryWrapper1); + outMaterialSapService.batchDeleteCompleteSapCancel(zLotMaterialCompleteTransactions); + } + + } + return R.ok(); + } @ApiOperation(value = "生产管理报工平台-批次完工入库报工", notes = "生产管理报工平台-批次完工入库报工") @@ -244,15 +309,61 @@ public class OutSapReportController { public R callErpLot(@RequestBody OutShopOrderDto outShopOrderDto) { String shopOrder = outShopOrderDto.getShopOrder(); List list = outShopOrderDto.getList(); - InvokeResponse invokeResponse = outMaterialSapService.callLotMaterialComplete(list, false, "",shopOrder); + InvokeResponse invokeResponse = outMaterialSapService.callLotMaterialComplete(list, false, "", shopOrder); if ("E".equals(invokeResponse.getResult())) { return R.failed("SAP错误:" + invokeResponse.getMessageContent()); } else { String site = TenantContextHolder.getTenantId(); - outMaterialSapService.warehousing(list, site); - outMaterialSapService.saveMaterialCompleteData(list, site); + outMaterialSapService.warehousing(list, site); + outMaterialSapService.saveMaterialCompleteData(list, site); return R.ok(); } } + private InvokeResponse sendSapToCancel(String syncVoucherNo) { + InvokeResponse invokeResponse = new InvokeResponse(); + InvokeRequest invokeRequest = new InvokeRequest(); + // 传参对象 + try { + String messageId = "ZMM_MES_GOODMVT_REVERSE"; + LocalDateTime nowLocalDateTime = LocalDateTime.now(); + String nowTime = nowLocalDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + invokeRequest.setTransSid(SapUtil.generateReqId()); + invokeRequest.setTransTime(nowTime); // 设定过账日期 + invokeRequest.setFromSystem("IEP"); + invokeRequest.setToSystem("ERP"); + invokeRequest.setSite(TenantContextHolder.getTenantId()); + invokeRequest.setMessageId(messageId); + + String postingDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("RFC_FUNCTION", messageId); + JSONObject headRe = new JSONObject(); + headRe.put("EXCHANGE_SYSTEM", "MES"); + headRe.put("EXCHANGE_ID", SapUtil.generateReqId()); + headRe.put("EXCHANGE_DOC", "iMES_Call_SAP"); + jsonObject.put("REQUEST_CONTEXT", headRe); + JSONObject bodyRe = new JSONObject(); + JSONObject isInput = new JSONObject(); + isInput.put("MBLNR", syncVoucherNo); // 物料凭证编号 + isInput.put("ZPARTNER", SecurityUtils.getUserName()); // 员工BP编号 + isInput.put("BUDAT", postingDate); // 凭证中的过账日期 + bodyRe.put("IS_INPUT", isInput); + jsonObject.put("REQUEST_BODY", bodyRe); + + // 组装抛送的报完呢 + String jsonObjectStr = SapUtil.appendHead(jsonObject.toJSONString()); + invokeRequest.setMessageContent(jsonObjectStr); + invokeRequest.setStart(nowTime); + invokeRequest.setKeyValue(nowTime); + invokeRequest.setRetry(false); + invokeResponse = goodMvtReverseService.call(invokeRequest); + } catch (Exception e) { + // 不用回滚,将错误抛出 + invokeResponse.setResult("E"); + invokeResponse.setMessageContent(e.getMessage()); + } + return invokeResponse; + } + } diff --git a/int-core/src/main/java/com/foreverwin/iep/integration/service/OutMaterialSapService.java b/int-core/src/main/java/com/foreverwin/iep/integration/service/OutMaterialSapService.java index b426c73..91b99d5 100644 --- a/int-core/src/main/java/com/foreverwin/iep/integration/service/OutMaterialSapService.java +++ b/int-core/src/main/java/com/foreverwin/iep/integration/service/OutMaterialSapService.java @@ -3,6 +3,7 @@ package com.foreverwin.iep.integration.service; import com.foreverwin.iep.integration.domain.InvokeResponse; import com.foreverwin.iep.integration.entity.OutMaterialCompleteLog; import com.foreverwin.iep.integration.entity.OutSapMaterialLog; +import com.foreverwin.iep.prd.entity.ZLotMaterialCompleteTransaction; import java.util.List; @@ -15,9 +16,13 @@ public interface OutMaterialSapService { boolean batchUpdateCompleteInventory(List outMaterialCompleteLogs); - boolean batchUpdateMaterialInventory(List outSapMaterialLogs); + String batchUpdateMaterialInventory(List outSapMaterialLogs); + String batchUpdateMaterialSapCancel(List outSapMaterialLogs); + + String batchDeleteCompleteSapCancel(List outMaterialCompleteLogs); + void warehousing(List outMaterialCompleteLogs, String site); void saveMaterialCompleteData(List outMaterialCompleteLogs, String site); diff --git a/int-core/src/main/java/com/foreverwin/iep/integration/service/impl/OutMaterialSapServiceImpl.java b/int-core/src/main/java/com/foreverwin/iep/integration/service/impl/OutMaterialSapServiceImpl.java index 6b1e452..45f03c7 100644 --- a/int-core/src/main/java/com/foreverwin/iep/integration/service/impl/OutMaterialSapServiceImpl.java +++ b/int-core/src/main/java/com/foreverwin/iep/integration/service/impl/OutMaterialSapServiceImpl.java @@ -28,6 +28,7 @@ import com.foreverwin.mom.common.security.util.SecurityUtils; import com.foreverwin.mom.wms.api.feign.RemoteWmsInventoryRecordService; import com.foreverwin.mom.wms.api.feign.RemoteWmsInventoryService; import com.foreverwin.mom.wms.entity.Inventory; +import com.foreverwin.mom.wms.entity.InventoryLog; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; @@ -50,6 +51,7 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService { private final RemoteWmsInventoryRecordService remoteWmsInventoryRecordService; private final RemoteWipService zLotMaterialCompleteTransactionService; private final OperationOutMapper operationOutMapper; + private final RemoteWipService remoteWipService; private final String messageId = "ZMM_MES_GOODSMVT_CREATE"; @@ -64,15 +66,15 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService { List srcList = new ArrayList<>(); for (OutMaterialCompleteLog completeTransaction : outMaterialCompleteLogs) { // 重新校验一遍是否已经报过工,防止重复报工 - OutMaterialCompleteLog targetObj = completeTransaction; if (StringUtils.isEmpty(postingDate)) { postingDate = completeTransaction.getSyncPostingDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); } else { completeTransaction.setSyncPostingDate(LocalDate.parse(postingDate, DateTimeFormatter.ofPattern("yyyy-MM-dd"))); } - targetObj.setSyncPostingDate(completeTransaction.getSyncPostingDate()); - srcList.add(targetObj); + completeTransaction.setSyncPostingDate(completeTransaction.getSyncPostingDate()); + completeTransaction.setLotSerial(completeTransaction.getLotSerial()); + srcList.add(completeTransaction); JSONObject jsonObject = new JSONObject(); site = completeTransaction.getSite(); jsonObject.put("ZEILE", null); // 物料凭证中的项目 @@ -113,10 +115,10 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService { jsonObject.put("Z_GRADE", completeTransaction.getQcGrade()); // 等级 if ("101".equals(completeTransaction.getProductType())) { oneZeroOneList.add(jsonObject); - newOneZeroOneList.add(targetObj); + newOneZeroOneList.add(completeTransaction); } else if ("531".equals(completeTransaction.getProductType())) { fiveThreeOneList.add(jsonObject); - newFiveThreeOneList.add(targetObj); + newFiveThreeOneList.add(completeTransaction); } } @@ -230,6 +232,7 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService { consumptionTransaction.setSyncPostingDate(LocalDate.parse(postingDate, DateTimeFormatter.ofPattern("yyyy-MM-dd"))); } targetObj.setSyncPostingDate(consumptionTransaction.getSyncPostingDate()); +// targetObj.setLotMaterialSid(consumptionTransaction.getLotMaterialSid()); srcList.add(targetObj); JSONObject jsonObject = new JSONObject(); site = consumptionTransaction.getSite(); @@ -320,13 +323,13 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService { BigDecimal result = qtyOnHand.add(mainQty); inventory.setQtyOnHand(result); inventories.add(inventory); - remoteWmsInventoryService.batchUpdate(inventories); } + remoteWmsInventoryService.batchUpdate(inventories); return true; } @Override - public boolean batchUpdateMaterialInventory(List outSapMaterialLogs) { + public String batchUpdateMaterialInventory(List outSapMaterialLogs) { Map inventoryMap = new HashMap<>(); Map quantityMap = new HashMap<>(); @@ -344,7 +347,7 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService { R inventoryDto = remoteWmsInventoryService.getInventoryDto(inventoryBo); Inventory inventory = inventoryDto.getData(); if (inventory == null) { - return false; + return "未找到相应库存,物料消耗失败!"; } BigDecimal qtyOnHand = inventory.getQtyOnHand(); if (qtyOnHand.compareTo(totalQuantityToSubtract) >= 0) { @@ -352,12 +355,82 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService { inventory.setQtyOnHand(result); inventoryMap.put(inventoryBo, inventory); } else { - return false; + return inventoryBo + " 的库存不足,物料消耗失败!"; } } //批量更新所有Inventory remoteWmsInventoryService.batchUpdate(new ArrayList<>(inventoryMap.values())); - return true; + return "OK"; + } + + + //冲销mes物料消耗 + @Override + public String batchUpdateMaterialSapCancel(List outSapMaterialLogs) { + Map inventoryMap = new HashMap<>(); + Map quantityMap = new HashMap<>(); + + for (OutSapMaterialLog outSapMaterialLog : outSapMaterialLogs) { + String inventoryBo = Inventory.genHandle(outSapMaterialLog.getSite(), outSapMaterialLog.getInventoryId()); + BigDecimal quantityToSubtract = outSapMaterialLog.getMainQty(); + //累加相同inventoryBo的加数量 + quantityMap.put(inventoryBo, quantityMap.getOrDefault(inventoryBo, BigDecimal.ZERO).add(quantityToSubtract)); + outSapMaterialLog.setSyncStatus("C"); + outSapMaterialLog.setErpReverse("Y"); + outSapMaterialLog.setSyncMsgText("已冲销"); + outSapMaterialMapper.updateById(outSapMaterialLog); + } + + + //遍历汇总后的quantityMap,进行加操作 + for (Map.Entry entry : quantityMap.entrySet()){ + String inventoryBo = entry.getKey(); + BigDecimal totalQuantityToSubtract = entry.getValue(); + R inventoryDto = remoteWmsInventoryService.getInventoryDto(inventoryBo); + Inventory inventory = inventoryDto.getData(); + if (inventory == null) { + return "未找到相应库存,冲销mes库存失败!"; + } + BigDecimal qtyOnHand = inventory.getQtyOnHand(); + BigDecimal result = qtyOnHand.add(totalQuantityToSubtract); + inventory.setQtyOnHand(result); + inventoryMap.put(inventoryBo, inventory); + + } + //批量更新所有Inventory + remoteWmsInventoryService.batchUpdate(new ArrayList<>(inventoryMap.values())); + return "OK"; + } + + //冲销mes完工入库 + @Override + public String batchDeleteCompleteSapCancel(List outMaterialCompleteLogs) { + Vector lotNos = new Vector<>(); + Vector srcList = new Vector<>(); + for (ZLotMaterialCompleteTransaction outMaterialCompleteLog : outMaterialCompleteLogs){ + + String lotNo = outMaterialCompleteLog.getLotNo(); + String site = outMaterialCompleteLog.getSite(); + if (lotNo == null){ + return "未找到对应的库存"; + } + outMaterialCompleteLog.setErpReverse("Y"); + outMaterialCompleteLog.setSyncStatus("C"); + srcList.add(outMaterialCompleteLog); + + String s = Inventory.genHandle(site, lotNo); + lotNos.add(s); + } + remoteWipService.remoteSaveOrUpdateBatchZLotMaterialCompleteTransaction(srcList,SecurityConstants.FROM_IN); + //删除对应的库存 + remoteWmsInventoryService.batchDelete(lotNos); + + + return "OK"; + + + + } @@ -398,6 +471,8 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService { DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); DateTimeFormatter dateTimeFormatter2 = DateTimeFormatter.ofPattern("yyyy/MM/dd"); Vector inventories = new Vector<>(); + Vector inventoryLogs = new Vector<>(); + for (OutMaterialCompleteLog outMaterialCompleteLog : outMaterialCompleteLogs) { String dataTime = String.valueOf(outMaterialCompleteLog.getSyncPostingDate()); LocalDateTime pdt = null; @@ -471,6 +546,13 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService { inventory.setAuxiliaryOty(String.valueOf(subQty)); } inventories.add(inventory); + + InventoryLog inventoryLog = new InventoryLog(); + inventoryLog.setSite(site); + inventoryLog.setCreator(user); + inventoryLog.setCreateTime(LocalDateTime.now()); + + } remoteWmsInventoryService.batchSave(inventories); } @@ -493,6 +575,7 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService { zLotMaterialCompleteTransaction.setItemDesc(outMaterialCompleteLog.getItemDesc()); zLotMaterialCompleteTransaction.setMainQty(outMaterialCompleteLog.getMainQty()); zLotMaterialCompleteTransaction.setMainUom(outMaterialCompleteLog.getMainUom()); + zLotMaterialCompleteTransaction.setLotSerial(outMaterialCompleteLog.getLotSerial()); if (outMaterialCompleteLog.getInventoryMark() != null) { zLotMaterialCompleteTransaction.setInventoryMark(outMaterialCompleteLog.getInventoryMark()); } diff --git a/int-db/src/main/java/com/foreverwin/iep/integration/mapper/OutSapCompleteMapper.java b/int-db/src/main/java/com/foreverwin/iep/integration/mapper/OutSapCompleteMapper.java index 8f612d6..e923885 100644 --- a/int-db/src/main/java/com/foreverwin/iep/integration/mapper/OutSapCompleteMapper.java +++ b/int-db/src/main/java/com/foreverwin/iep/integration/mapper/OutSapCompleteMapper.java @@ -3,6 +3,7 @@ package com.foreverwin.iep.integration.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.foreverwin.iep.integration.entity.OutMaterialCompleteLog; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Update; /** * 完工入库事务表 @@ -13,4 +14,8 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface OutSapCompleteMapper extends BaseMapper { + @Update("UPDATE out_material_complete_log SET ERP_REVERSE = 'Y',SYNC_STATUS = 'C' WHERE SYNC_VOUCHER_NO = #{syncVoucherNo}") + int updateAFieldBySyncVoucherNo(String syncVoucher); + + }