feat(integration): 更新库存接口- 新增 batchUpdateCompleteInventory 和 batchUpdateMaterialInventory 方法
- 实现库存数量的批量更新 - 添加 RemoteWmsInventoryService 依赖 - 更新 OutSapMaterialLog 实体,增加 inventory_id 字段 - 修改控制器中的物料消耗和完工入库接口,增加库存更新逻辑
This commit is contained in:
parent
1eea8a03c3
commit
fd049306d7
@ -282,6 +282,9 @@ public class OutSapMaterialLog extends Model<OutSapMaterialLog> {
|
||||
@ApiModelProperty(value = "erp冲销标识(Y:冲销成功、无值代表无冲销动作、其它值代表erp冲销返回结果值)")
|
||||
private String erpReverse;
|
||||
|
||||
@ApiModelProperty(value = "条码")
|
||||
private String inventory_id;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String startTime;
|
||||
@TableField(exist = false)
|
||||
|
||||
@ -22,6 +22,8 @@ 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;
|
||||
@ -64,7 +66,8 @@ public class OutSapReportController {
|
||||
private final LotMaterialMapper lotMaterialMapper;
|
||||
private final OutMaterialSapService outMaterialSapService;
|
||||
private final OutSapShoporderStatisticsMapper outSapShoporderStatisticsMapper;
|
||||
private final OutShopOrderStatisticService outSapShoporderStatisticService;
|
||||
private final OutShopOrderStatisticService outSapShoporderStatisticService;
|
||||
private final RemoteWmsInventoryService remoteWmsInventoryService;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("ZMM_MES_GOODMVT_REVERSE") // 通过 Bean 名称注入
|
||||
@ -129,6 +132,7 @@ public class OutSapReportController {
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateCallErp(JSONObject jsonObject, List<OutSapShoporderStatistics> srcList, InvokeResponse invokeResponse) {
|
||||
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
|
||||
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
|
||||
@ -183,84 +187,84 @@ public class OutSapReportController {
|
||||
}
|
||||
|
||||
// --------------------------------------------- 生产报工取消开始 -----------------------------------------------------
|
||||
@ApiOperation(value = "生产管理报工平台-工单取消报工", notes = "生产管理报工平台-工单取消报工")
|
||||
@SysLog("生产管理报工平台-工单取消报工")
|
||||
@PostMapping("/callErpCancel")
|
||||
public R callErpCancel(@RequestBody List<ZShoporderStatisticsTransaction> shoporderStatisticsTransactionList) {
|
||||
InvokeResponse invokeResponse = new InvokeResponse();
|
||||
List<ZShoporderStatisticsTransaction> newList = new ArrayList<>();
|
||||
for (ZShoporderStatisticsTransaction statisticsTransaction : shoporderStatisticsTransactionList) {
|
||||
if (StringUtils.isEmpty(statisticsTransaction.getSid())) {
|
||||
throw BusinessException.build("此笔数据还未报工无需取消报工");
|
||||
}
|
||||
// 重新校验一遍是否已经报过工,防止重复报工
|
||||
ZShoporderStatisticsTransaction targetObj = zShoporderStatisticsTransactionMapper.selectById(statisticsTransaction.getSid());
|
||||
if (targetObj == null || !"S".equals(targetObj.getSyncStatus())) {
|
||||
throw BusinessException.build("工单" + targetObj.getShopOrder() + "还未报工无需取消报工");
|
||||
} else if ("Y".equalsIgnoreCase(targetObj.getErpReverse())) {
|
||||
throw BusinessException.build("该笔数据已经冲销");
|
||||
} else {
|
||||
newList.add(targetObj);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(newList)) {
|
||||
// 传参对象
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
LocalDateTime nowLocalDateTime = LocalDateTime.now();
|
||||
String nowTime = nowLocalDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
String shopOrder = "";
|
||||
try {
|
||||
for (ZShoporderStatisticsTransaction statisticsTransaction : newList) {
|
||||
String site = statisticsTransaction.getSite();
|
||||
shopOrder = statisticsTransaction.getShopOrder();
|
||||
invokeRequest.setTransSid(SapUtil.generateReqId());
|
||||
invokeRequest.setTransTime(nowTime);
|
||||
invokeRequest.setFromSystem("IEP");
|
||||
invokeRequest.setToSystem("ERP");
|
||||
invokeRequest.setSite(site);
|
||||
invokeRequest.setMessageId("ZPP_MES_PRODOR_CANCEL");
|
||||
|
||||
// 组装抛送的报完呢
|
||||
String jsonObjectStr = SapUtil.appendHead(assembleCancelMsgBody(statisticsTransaction));
|
||||
invokeRequest.setMessageContent(jsonObjectStr);
|
||||
invokeRequest.setStart(nowTime);
|
||||
invokeRequest.setKeyValue(shopOrder);
|
||||
invokeRequest.setRetry(false);
|
||||
TenantContextHolder.setTenantId(site);
|
||||
invokeResponse = shopOrderStatisticTransCancelService.call(invokeRequest);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.build("工单" + shopOrder + "取消报工失败!");
|
||||
} finally {
|
||||
// 保存日志
|
||||
saveLogData(invokeRequest, invokeResponse);
|
||||
}
|
||||
}
|
||||
if ("E".equals(invokeResponse.getResult())) {
|
||||
return R.failed(invokeResponse.getMessageContent());
|
||||
} else {
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
private String assembleCancelMsgBody(ZShoporderStatisticsTransaction statisticsTransaction) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("RFC_FUNCTION", "ZPP_MES_PRODOR_CANCEL");
|
||||
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("AUFNR", statisticsTransaction.getShopOrder()); // 工单
|
||||
isInput.put("RUECK", statisticsTransaction.getSyncTransBatch()); // 操作完成的确认编号
|
||||
isInput.put("RMZHL", statisticsTransaction.getSyncTicketLine()); // 确认计算器
|
||||
isInput.put("VORNR", statisticsTransaction.getSyncTicketNo()); // 活动编号
|
||||
bodyRe.put("IS_INPUT", isInput);
|
||||
jsonObject.put("REQUEST_BODY", bodyRe);
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
// @ApiOperation(value = "生产管理报工平台-工单取消报工", notes = "生产管理报工平台-工单取消报工")
|
||||
// @SysLog("生产管理报工平台-工单取消报工")
|
||||
// @PostMapping("/callErpCancel")
|
||||
// public R callErpCancel(@RequestBody List<ZShoporderStatisticsTransaction> shoporderStatisticsTransactionList) {
|
||||
// InvokeResponse invokeResponse = new InvokeResponse();
|
||||
// List<ZShoporderStatisticsTransaction> newList = new ArrayList<>();
|
||||
// for (ZShoporderStatisticsTransaction statisticsTransaction : shoporderStatisticsTransactionList) {
|
||||
// if (StringUtils.isEmpty(statisticsTransaction.getSid())) {
|
||||
// throw BusinessException.build("此笔数据还未报工无需取消报工");
|
||||
// }
|
||||
// // 重新校验一遍是否已经报过工,防止重复报工
|
||||
// ZShoporderStatisticsTransaction targetObj = zShoporderStatisticsTransactionMapper.selectById(statisticsTransaction.getSid());
|
||||
// if (targetObj == null || !"S".equals(targetObj.getSyncStatus())) {
|
||||
// throw BusinessException.build("工单" + targetObj.getShopOrder() + "还未报工无需取消报工");
|
||||
// } else if ("Y".equalsIgnoreCase(targetObj.getErpReverse())) {
|
||||
// throw BusinessException.build("该笔数据已经冲销");
|
||||
// } else {
|
||||
// newList.add(targetObj);
|
||||
// }
|
||||
// }
|
||||
// if (CollectionUtils.isNotEmpty(newList)) {
|
||||
// // 传参对象
|
||||
// InvokeRequest invokeRequest = new InvokeRequest();
|
||||
// LocalDateTime nowLocalDateTime = LocalDateTime.now();
|
||||
// String nowTime = nowLocalDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
// String shopOrder = "";
|
||||
// try {
|
||||
// for (ZShoporderStatisticsTransaction statisticsTransaction : newList) {
|
||||
// String site = statisticsTransaction.getSite();
|
||||
// shopOrder = statisticsTransaction.getShopOrder();
|
||||
// invokeRequest.setTransSid(SapUtil.generateReqId());
|
||||
// invokeRequest.setTransTime(nowTime);
|
||||
// invokeRequest.setFromSystem("IEP");
|
||||
// invokeRequest.setToSystem("ERP");
|
||||
// invokeRequest.setSite(site);
|
||||
// invokeRequest.setMessageId("ZPP_MES_PRODOR_CANCEL");
|
||||
//
|
||||
// // 组装抛送的报完呢
|
||||
// String jsonObjectStr = SapUtil.appendHead(assembleCancelMsgBody(statisticsTransaction));
|
||||
// invokeRequest.setMessageContent(jsonObjectStr);
|
||||
// invokeRequest.setStart(nowTime);
|
||||
// invokeRequest.setKeyValue(shopOrder);
|
||||
// invokeRequest.setRetry(false);
|
||||
// TenantContextHolder.setTenantId(site);
|
||||
// invokeResponse = shopOrderStatisticTransCancelService.call(invokeRequest);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// throw BusinessException.build("工单" + shopOrder + "取消报工失败!");
|
||||
// } finally {
|
||||
// // 保存日志
|
||||
// saveLogData(invokeRequest, invokeResponse);
|
||||
// }
|
||||
// }
|
||||
// if ("E".equals(invokeResponse.getResult())) {
|
||||
// return R.failed(invokeResponse.getMessageContent());
|
||||
// } else {
|
||||
// return R.ok();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String assembleCancelMsgBody(ZShoporderStatisticsTransaction statisticsTransaction) {
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("RFC_FUNCTION", "ZPP_MES_PRODOR_CANCEL");
|
||||
// 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("AUFNR", statisticsTransaction.getShopOrder()); // 工单
|
||||
// isInput.put("RUECK", statisticsTransaction.getSyncTransBatch()); // 操作完成的确认编号
|
||||
// isInput.put("RMZHL", statisticsTransaction.getSyncTicketLine()); // 确认计算器
|
||||
// isInput.put("VORNR", statisticsTransaction.getSyncTicketNo()); // 活动编号
|
||||
// bodyRe.put("IS_INPUT", isInput);
|
||||
// jsonObject.put("REQUEST_BODY", bodyRe);
|
||||
// return jsonObject.toJSONString();
|
||||
// }
|
||||
|
||||
private void saveLogData(InvokeRequest invokeRequest, InvokeResponse invokeResponse) {
|
||||
if (StringUtils.isNotEmpty(invokeRequest.getTransSid())) {
|
||||
@ -295,10 +299,14 @@ public class OutSapReportController {
|
||||
@SysLog("生产管理报工平台-物料消耗报工")
|
||||
@PostMapping("/callErpMaterial")
|
||||
public R callErpMaterial(@RequestBody List<OutSapMaterialLog> outSapMaterialLogs) {
|
||||
InvokeResponse invokeResponse = outMaterialSapService.callLotMaterialConsumption(outSapMaterialLogs, false,"");
|
||||
InvokeResponse invokeResponse = outMaterialSapService.callLotMaterialConsumption(outSapMaterialLogs, false, "");
|
||||
if ("E".equals(invokeResponse.getResult())) {
|
||||
return R.failed("SAP错误:" + invokeResponse.getMessageContent());
|
||||
} else {
|
||||
boolean b = outMaterialSapService.batchUpdateMaterialInventory(outSapMaterialLogs);
|
||||
if (!b) {
|
||||
return R.failed("更新mes库存失败!");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@ -317,68 +325,72 @@ public class OutSapReportController {
|
||||
@SysLog("生产管理报工平台-批次完工入库报工")
|
||||
@PostMapping("/callErpLot")
|
||||
public R callErpLot(@RequestBody List<OutMaterialCompleteLog> outMaterialCompleteLogList) {
|
||||
InvokeResponse invokeResponse = outMaterialSapService.callLotMaterialComplete(outMaterialCompleteLogList, false,"");
|
||||
InvokeResponse invokeResponse = outMaterialSapService.callLotMaterialComplete(outMaterialCompleteLogList, false, "");
|
||||
if ("E".equals(invokeResponse.getResult())) {
|
||||
return R.failed("SAP错误:" + invokeResponse.getMessageContent());
|
||||
} else {
|
||||
boolean b = outMaterialSapService.batchUpdateCompleteInventory(outMaterialCompleteLogList);
|
||||
if (!b){
|
||||
return R.failed("mes库存更新失败,请检查条码号是否正确");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "生产管理报工平台-物料消耗冲销", notes = "生产管理报工平台-物料消耗冲销")
|
||||
@SysLog("生产管理报工平台-物料消耗冲销")
|
||||
@PostMapping("/callErpLotCancel")
|
||||
public R callErpLotCancel(@RequestBody List<ZLotMaterialConsumptionTransaction> lotMaterialConsumptionTransactions) {
|
||||
for (ZLotMaterialConsumptionTransaction consumptionTransaction : lotMaterialConsumptionTransactions) {
|
||||
// 重新校验一遍是否已经报过工,防止重复报工
|
||||
ZLotMaterialConsumptionTransaction targetObj = zLotMaterialConsumptionTransactionMapper.selectById(consumptionTransaction.getSid());
|
||||
if ("S".equals(targetObj.getSyncStatus()) && "Y".equals(targetObj.getErpReverse())) {
|
||||
throw BusinessException.build("批次" + targetObj.getLotNo() + "完工已经报工且已冲销,不可重复冲销");
|
||||
} else if ("S".equals(targetObj.getSyncStatus())) {
|
||||
InvokeResponse invokeResponse = sendSapToCancel(targetObj.getSyncVoucherNo());
|
||||
if (!"S".equals(invokeResponse.getResult())) {
|
||||
return R.failed("SAP错误:" + invokeResponse.getMessageContent());
|
||||
} else {
|
||||
// 更新lotMaterial表
|
||||
targetObj.setErpReverse("Y");
|
||||
zLotMaterialConsumptionTransactionMapper.updateById(targetObj);
|
||||
LotMaterial lotMaterial = lotMaterialMapper.selectById(targetObj.getLotMaterialSid());
|
||||
if (lotMaterial != null) {
|
||||
lotMaterial.setQty(BigDecimal.ZERO);
|
||||
lotMaterialMapper.updateById(lotMaterial);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw BusinessException.build("批次" + targetObj.getLotNo() + "还未报工,不可冲销");
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
// @ApiOperation(value = "生产管理报工平台-物料消耗冲销", notes = "生产管理报工平台-物料消耗冲销")
|
||||
// @SysLog("生产管理报工平台-物料消耗冲销")
|
||||
// @PostMapping("/callErpLotCancel")
|
||||
// public R callErpLotCancel(@RequestBody List<ZLotMaterialConsumptionTransaction> lotMaterialConsumptionTransactions) {
|
||||
// for (ZLotMaterialConsumptionTransaction consumptionTransaction : lotMaterialConsumptionTransactions) {
|
||||
// // 重新校验一遍是否已经报过工,防止重复报工
|
||||
// ZLotMaterialConsumptionTransaction targetObj = zLotMaterialConsumptionTransactionMapper.selectById(consumptionTransaction.getSid());
|
||||
// if ("S".equals(targetObj.getSyncStatus()) && "Y".equals(targetObj.getErpReverse())) {
|
||||
// throw BusinessException.build("批次" + targetObj.getLotNo() + "完工已经报工且已冲销,不可重复冲销");
|
||||
// } else if ("S".equals(targetObj.getSyncStatus())) {
|
||||
// InvokeResponse invokeResponse = sendSapToCancel(targetObj.getSyncVoucherNo());
|
||||
// if (!"S".equals(invokeResponse.getResult())) {
|
||||
// return R.failed("SAP错误:" + invokeResponse.getMessageContent());
|
||||
// } else {
|
||||
// // 更新lotMaterial表
|
||||
// targetObj.setErpReverse("Y");
|
||||
// zLotMaterialConsumptionTransactionMapper.updateById(targetObj);
|
||||
// LotMaterial lotMaterial = lotMaterialMapper.selectById(targetObj.getLotMaterialSid());
|
||||
// if (lotMaterial != null) {
|
||||
// lotMaterial.setQty(BigDecimal.ZERO);
|
||||
// lotMaterialMapper.updateById(lotMaterial);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// throw BusinessException.build("批次" + targetObj.getLotNo() + "还未报工,不可冲销");
|
||||
// }
|
||||
// }
|
||||
// return R.ok();
|
||||
// }
|
||||
|
||||
@ApiOperation(value = "生产管理报工平台-完工入库冲销", notes = "生产管理报工平台-完工入库冲销")
|
||||
@SysLog("生产管理报工平台-完工入库冲销")
|
||||
@PostMapping("/callErpLotInStockCancel")
|
||||
public R callErpLotInStockCancel(@RequestBody List<ZLotMaterialCompleteTransaction> lotMaterialCompleteTransactions) {
|
||||
for (ZLotMaterialCompleteTransaction completeTransaction : lotMaterialCompleteTransactions) {
|
||||
// 重新校验一遍是否已经报过工,防止重复报工
|
||||
ZLotMaterialCompleteTransaction targetObj = zLotMaterialCompleteTransactionMapper.selectById(completeTransaction.getSid());
|
||||
if ("S".equals(targetObj.getSyncStatus()) && "Y".equals(targetObj.getErpReverse())) {
|
||||
throw BusinessException.build("批次" + targetObj.getLotNo() + "完工已经报工且已冲销,不可重复冲销");
|
||||
} else if ("S".equals(targetObj.getSyncStatus())) {
|
||||
InvokeResponse invokeResponse = sendSapToCancel(targetObj.getSyncVoucherNo());
|
||||
if (!"S".equals(invokeResponse.getResult())) {
|
||||
return R.failed("SAP错误:" + invokeResponse.getMessageContent());
|
||||
} else {
|
||||
// 更新冲销标识
|
||||
targetObj.setErpReverse("Y");
|
||||
zLotMaterialCompleteTransactionMapper.updateById(targetObj);
|
||||
}
|
||||
} else {
|
||||
throw BusinessException.build("批次" + targetObj.getLotNo() + "还未报工,不可冲销");
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
// @ApiOperation(value = "生产管理报工平台-完工入库冲销", notes = "生产管理报工平台-完工入库冲销")
|
||||
// @SysLog("生产管理报工平台-完工入库冲销")
|
||||
// @PostMapping("/callErpLotInStockCancel")
|
||||
// public R callErpLotInStockCancel(@RequestBody List<ZLotMaterialCompleteTransaction> lotMaterialCompleteTransactions) {
|
||||
// for (ZLotMaterialCompleteTransaction completeTransaction : lotMaterialCompleteTransactions) {
|
||||
// // 重新校验一遍是否已经报过工,防止重复报工
|
||||
// ZLotMaterialCompleteTransaction targetObj = zLotMaterialCompleteTransactionMapper.selectById(completeTransaction.getSid());
|
||||
// if ("S".equals(targetObj.getSyncStatus()) && "Y".equals(targetObj.getErpReverse())) {
|
||||
// throw BusinessException.build("批次" + targetObj.getLotNo() + "完工已经报工且已冲销,不可重复冲销");
|
||||
// } else if ("S".equals(targetObj.getSyncStatus())) {
|
||||
// InvokeResponse invokeResponse = sendSapToCancel(targetObj.getSyncVoucherNo());
|
||||
// if (!"S".equals(invokeResponse.getResult())) {
|
||||
// return R.failed("SAP错误:" + invokeResponse.getMessageContent());
|
||||
// } else {
|
||||
// // 更新冲销标识
|
||||
// targetObj.setErpReverse("Y");
|
||||
// zLotMaterialCompleteTransactionMapper.updateById(targetObj);
|
||||
// }
|
||||
// } else {
|
||||
// throw BusinessException.build("批次" + targetObj.getLotNo() + "还未报工,不可冲销");
|
||||
// }
|
||||
// }
|
||||
// return R.ok();
|
||||
// }
|
||||
|
||||
private InvokeResponse sendSapToCancel(String syncVoucherNo) {
|
||||
InvokeResponse invokeResponse = new InvokeResponse();
|
||||
|
||||
@ -12,4 +12,11 @@ public interface OutMaterialSapService {
|
||||
InvokeResponse callLotMaterialComplete(List<OutMaterialCompleteLog> outMaterialCompleteLogs, boolean isPass, String postingDate);
|
||||
|
||||
InvokeResponse callLotMaterialConsumption(List<OutSapMaterialLog> outSapMaterialLogs, boolean isPass, String postingDate);
|
||||
|
||||
boolean batchUpdateCompleteInventory(List<OutMaterialCompleteLog> outMaterialCompleteLogs);
|
||||
|
||||
boolean batchUpdateMaterialInventory(List<OutSapMaterialLog> outSapMaterialLogs);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -12,11 +12,16 @@ import com.foreverwin.iep.integration.handler.def.sap.SapUtil;
|
||||
import com.foreverwin.iep.integration.mapper.OutSapCompleteMapper;
|
||||
import com.foreverwin.iep.integration.mapper.OutSapMaterialMapper;
|
||||
import com.foreverwin.iep.integration.service.OutMaterialSapService;
|
||||
import com.foreverwin.iep.integration.service.RegisterDocumentService;
|
||||
import com.foreverwin.mom.common.core.util.R;
|
||||
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
|
||||
import com.foreverwin.mom.common.security.util.SecurityUtils;
|
||||
import com.foreverwin.mom.wms.api.feign.RemoteWmsInventoryService;
|
||||
import com.foreverwin.mom.wms.entity.Inventory;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@ -30,6 +35,8 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService {
|
||||
private final GoodMvtCreateService goodMvtCreateService;
|
||||
private final OutSapCompleteMapper outSapCompleteMapper ;
|
||||
private final OutSapMaterialMapper outSapMaterialMapper;
|
||||
private final RegisterDocumentService registerDocumentService;
|
||||
private final RemoteWmsInventoryService remoteWmsInventoryService;
|
||||
|
||||
private final String messageId = "ZMM_MES_GOODSMVT_CREATE";
|
||||
|
||||
@ -60,7 +67,9 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService {
|
||||
jsonObject.put("MATKL", ""); // 物料组
|
||||
jsonObject.put("WERKS", site); // 工厂
|
||||
jsonObject.put("LGORT", completeTransaction.getErpInventory()); // 存储地点
|
||||
jsonObject.put("CHARG", completeTransaction.getSapBatchNo()); // 批次号
|
||||
String sapBatchNo = registerDocumentService.getSapBatchNo(completeTransaction.getErpInventory());
|
||||
completeTransaction.setSapBatchNo(sapBatchNo);
|
||||
jsonObject.put("CHARG", sapBatchNo); // 批次号
|
||||
jsonObject.put("BWART", completeTransaction.getProductType()); // 移动类型
|
||||
jsonObject.put("SOBKZ", ""); // 特殊库存标识
|
||||
jsonObject.put("AUFNR", completeTransaction.getShopOrder()); // 订单号
|
||||
@ -264,6 +273,54 @@ public class OutMaterialSapServiceImpl implements OutMaterialSapService {
|
||||
return invokeResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean batchUpdateCompleteInventory(List<OutMaterialCompleteLog> outMaterialCompleteLogs) {
|
||||
List<Inventory> inventories = new ArrayList<>();
|
||||
for (OutMaterialCompleteLog outMaterialCompleteLog : outMaterialCompleteLogs) {
|
||||
outMaterialCompleteLog.getLotNo();
|
||||
String inventoryBo = Inventory.genHandle(outMaterialCompleteLog.getSite(), outMaterialCompleteLog.getLotNo());
|
||||
R<Inventory> inventoryDto = remoteWmsInventoryService.getInventoryDto(inventoryBo);
|
||||
Inventory inventory = inventoryDto.getData();
|
||||
if (inventory==null){
|
||||
return false;
|
||||
}
|
||||
BigDecimal qtyOnHand = inventory.getQtyOnHand();
|
||||
BigDecimal mainQty = outMaterialCompleteLog.getMainQty();
|
||||
BigDecimal result = qtyOnHand.add(mainQty);
|
||||
inventory.setQtyOnHand(result);
|
||||
inventories.add(inventory);
|
||||
remoteWmsInventoryService.batchUpdate(inventories);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean batchUpdateMaterialInventory(List<OutSapMaterialLog> outSapMaterialLogs) {
|
||||
List<Inventory> inventories = new ArrayList<>();
|
||||
for (OutSapMaterialLog outSapMaterialLog : outSapMaterialLogs) {
|
||||
outSapMaterialLog.getInventory_id();
|
||||
String inventoryBo = Inventory.genHandle(outSapMaterialLog.getSite(), outSapMaterialLog.getInventory_id());
|
||||
R<Inventory> inventoryDto = remoteWmsInventoryService.getInventoryDto(inventoryBo);
|
||||
|
||||
Inventory inventory = inventoryDto.getData();
|
||||
if (inventory==null){
|
||||
return false;
|
||||
}
|
||||
BigDecimal qtyOnHand = inventory.getQtyOnHand();
|
||||
BigDecimal mainQty = outSapMaterialLog.getMainQty();
|
||||
if (qtyOnHand.compareTo(mainQty) >= 0) {
|
||||
BigDecimal result = qtyOnHand.subtract(mainQty);
|
||||
inventory.setQtyOnHand(result);
|
||||
inventories.add(inventory);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
remoteWmsInventoryService.batchUpdate(inventories);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InvokeResponse updateMaterialConsumption(JSONObject jsonObject, List<OutSapMaterialLog> srcList, InvokeResponse invokeResponse) {
|
||||
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
|
||||
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user