egrationfeat(int): 实现物料消耗和完工入库的冲销功能- 新增物料消耗冲销和完工入库冲销的接口和实现
- 修改数据库映射,增加更新字段的方法 - 优化库存更新逻辑,支持批量更新 - 增加冲销相关的数据处理和调用SAP接口
This commit is contained in:
parent
09bab8d7fa
commit
6967106f6f
@ -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<OutSapMaterialLog> 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<OutSapMaterialLog> outSapMaterialLogs) {
|
||||
for (OutSapMaterialLog targetObj : outSapMaterialLogs) {
|
||||
String lotSerial = targetObj.getLotSerial();
|
||||
QueryWrapper<OutSapMaterialLog> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("LOT_SERIAL", lotSerial);
|
||||
List<OutSapMaterialLog> 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<OutMaterialCompleteLog> outMaterialCompleteLogs) {
|
||||
for (OutMaterialCompleteLog targetObj : outMaterialCompleteLogs) {
|
||||
// 重新校验一遍是否已经报过工,防止重复报工
|
||||
String lotNo = targetObj.getLotNo();
|
||||
String site = targetObj.getSite();
|
||||
QueryWrapper<ZLotMaterialCompleteTransaction> 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<ZLotMaterialCompleteTransaction> queryWrapper1 = new QueryWrapper<>();
|
||||
queryWrapper1.eq("SYNC_VOUCHER_NO", syncVoucherNo);
|
||||
List<ZLotMaterialCompleteTransaction> 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<OutMaterialCompleteLog> outShopOrderDto) {
|
||||
String shopOrder = outShopOrderDto.getShopOrder();
|
||||
List<OutMaterialCompleteLog> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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<OutMaterialCompleteLog> outMaterialCompleteLogs);
|
||||
|
||||
boolean batchUpdateMaterialInventory(List<OutSapMaterialLog> outSapMaterialLogs);
|
||||
String batchUpdateMaterialInventory(List<OutSapMaterialLog> outSapMaterialLogs);
|
||||
|
||||
|
||||
String batchUpdateMaterialSapCancel(List<OutSapMaterialLog> outSapMaterialLogs);
|
||||
|
||||
String batchDeleteCompleteSapCancel(List<ZLotMaterialCompleteTransaction> outMaterialCompleteLogs);
|
||||
|
||||
void warehousing(List<OutMaterialCompleteLog> outMaterialCompleteLogs, String site);
|
||||
|
||||
void saveMaterialCompleteData(List<OutMaterialCompleteLog> outMaterialCompleteLogs, String site);
|
||||
|
||||
@ -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<OutMaterialCompleteLog> 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<OutSapMaterialLog> outSapMaterialLogs) {
|
||||
public String batchUpdateMaterialInventory(List<OutSapMaterialLog> outSapMaterialLogs) {
|
||||
Map<String, Inventory> inventoryMap = new HashMap<>();
|
||||
Map<String, BigDecimal> quantityMap = new HashMap<>();
|
||||
|
||||
@ -344,7 +347,7 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService {
|
||||
R<Inventory> 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<OutSapMaterialLog> outSapMaterialLogs) {
|
||||
Map<String, Inventory> inventoryMap = new HashMap<>();
|
||||
Map<String, BigDecimal> 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<String, BigDecimal> entry : quantityMap.entrySet()){
|
||||
String inventoryBo = entry.getKey();
|
||||
BigDecimal totalQuantityToSubtract = entry.getValue();
|
||||
R<Inventory> 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<ZLotMaterialCompleteTransaction> outMaterialCompleteLogs) {
|
||||
Vector<String> lotNos = new Vector<>();
|
||||
Vector<ZLotMaterialCompleteTransaction> 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<Inventory> inventories = new Vector<>();
|
||||
Vector<InventoryLog> 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());
|
||||
}
|
||||
|
||||
@ -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<OutMaterialCompleteLog> {
|
||||
|
||||
@Update("UPDATE out_material_complete_log SET ERP_REVERSE = 'Y',SYNC_STATUS = 'C' WHERE SYNC_VOUCHER_NO = #{syncVoucherNo}")
|
||||
int updateAFieldBySyncVoucherNo(String syncVoucher);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user