Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
tangyu 2025-01-17 14:25:08 +08:00
commit 616f52c192
7 changed files with 537 additions and 588 deletions

View File

@ -8,12 +8,10 @@ import com.foreverwin.iep.integration.domain.InvokeRequest;
import com.foreverwin.iep.integration.domain.InvokeResponse;
import com.foreverwin.iep.integration.entity.IntInData;
import com.foreverwin.iep.integration.entity.IntInDataLog;
import com.foreverwin.iep.integration.handler.def.sap.GoodMvtCreateService;
import com.foreverwin.iep.integration.handler.def.sap.SapUtil;
import com.foreverwin.iep.integration.handler.def.sap.ShopOrderStatisticTransCancelService;
import com.foreverwin.iep.integration.handler.def.sap.ShopOrderStatisticTransService;
import com.foreverwin.iep.integration.handler.def.sap.*;
import com.foreverwin.iep.integration.service.IntInDataLogService;
import com.foreverwin.iep.integration.service.IntInDataService;
import com.foreverwin.iep.integration.service.LotMaterialDealSendSapService;
import com.foreverwin.iep.integration.service.RegisterDocumentService;
import com.foreverwin.iep.prd.entity.ZLotMaterialCompleteTransaction;
import com.foreverwin.iep.prd.entity.ZLotMaterialConsumptionTransaction;
@ -21,6 +19,8 @@ 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.mapper.LotMaterialMapper;
import com.foreverwin.mom.common.core.exception.BusinessException;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
@ -29,11 +29,15 @@ import com.foreverwin.mom.common.security.util.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
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;
@ -61,6 +65,12 @@ public class ShopOrderStatisticTransController {
private final IntInDataService intInDataService;
private final IntInDataLogService intInDataLogService;
private final RegisterDocumentService registerDocumentService;
private final LotMaterialMapper lotMaterialMapper;
private final LotMaterialDealSendSapService lotMaterialDealSendSapService;
@Autowired
@Qualifier("ZMM_MES_GOODMVT_REVERSE") // 通过 Bean 名称注入
private GoodMvtReverseService goodMvtReverseService;
@ApiOperation(value = "生产管理报工平台-工单报工", notes = "生产管理报工平台-工单报工")
@SysLog("生产管理报工平台-工单报工")
@ -160,13 +170,15 @@ public class ShopOrderStatisticTransController {
InvokeResponse invokeResponse = new InvokeResponse();
List<ZShoporderStatisticsTransaction> newList = new ArrayList<>();
for (ZShoporderStatisticsTransaction statisticsTransaction : shoporderStatisticsTransactionList) {
if(StringUtils.isEmpty(statisticsTransaction.getSid())){
if (StringUtils.isEmpty(statisticsTransaction.getSid())) {
throw BusinessException.build("此笔数据还未报工无需取消报工");
}
// 重新校验一遍是否已经报过工,防止重复报工
ZShoporderStatisticsTransaction targetObj = zShoporderStatisticsTransactionMapper.selectById(statisticsTransaction.getSid());
if (targetObj==null || !"S".equals(targetObj.getSyncStatus())) {
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);
}
@ -263,131 +275,14 @@ public class ShopOrderStatisticTransController {
@SysLog("生产管理报工平台-物料消耗报工")
@PostMapping("/callErpMaterial")
public R callErpMaterial(@RequestBody List<ZLotMaterialConsumptionTransaction> zLotMaterialConsumptionTransactions) {
InvokeResponse invokeResponse = new InvokeResponse();
List<ZLotMaterialConsumptionTransaction> newList = new ArrayList<>();
String site = "";
String postingDate = "";
JSONArray itemList = new JSONArray();
List<ZLotMaterialConsumptionTransaction> srcList = new ArrayList<>();
for (ZLotMaterialConsumptionTransaction consumptionTransaction : zLotMaterialConsumptionTransactions) {
// 重新校验一遍是否已经报过工,防止重复报工
ZLotMaterialConsumptionTransaction targetObj = zLotMaterialConsumptionTransactionMapper.selectById(consumptionTransaction.getSid());
if ("S".equals(targetObj.getSyncStatus())) {
throw BusinessException.build("批次" + targetObj.getLotNo() + "消耗已经报工,不可重复报工");
} else {
postingDate = consumptionTransaction.getSyncPostingDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
targetObj.setSyncPostingDate(consumptionTransaction.getSyncPostingDate());
srcList.add(targetObj);
JSONObject jsonObject = new JSONObject();
site = consumptionTransaction.getSite();
jsonObject.put("ZEILE", ""); // 物料凭证中的项目
jsonObject.put("MATNR", consumptionTransaction.getErpItem()); // 物料编号
jsonObject.put("MATKL", ""); // 物料组
jsonObject.put("WERKS", site); // 工厂
jsonObject.put("LGORT", consumptionTransaction.getErpInventory()); // 存储地点
jsonObject.put("CHARG", consumptionTransaction.getSapBatchNo()); // 批次号
jsonObject.put("BWART", "261"); // 移动类型
jsonObject.put("SOBKZ", ""); // 特殊库存标识
jsonObject.put("AUFNR", consumptionTransaction.getShopOrder()); // 订单号
jsonObject.put("EBELN", ""); // 采购订单号
jsonObject.put("EBELP", ""); // 采购凭证的项目编号
jsonObject.put("MENGE", consumptionTransaction.getMainQty()); // 数量
jsonObject.put("MEINS", consumptionTransaction.getMainUom()); // 基本计量单位
if(consumptionTransaction.getSubQty()!=null){
jsonObject.put("ERFMG", consumptionTransaction.getSubQty()); // 以录入项单位表示的数量
jsonObject.put("ERFME", consumptionTransaction.getSubUom()); // 录入单位
}else{
jsonObject.put("ERFMG", null); // 以录入项单位表示的数量
jsonObject.put("ERFME", ""); // 录入单位
}
jsonObject.put("MAT_KDAUF", ""); // 评估销售定单库存的销售定单号
jsonObject.put("MAT_KDPOS", ""); // 评估销售订单库存的销售订单项目
jsonObject.put("UMWRK", ""); // 收货工厂/发货工厂
jsonObject.put("UMLGO", ""); // 收货/发货库存地点
jsonObject.put("UMCHA", ""); // 收货/发货批量
jsonObject.put("RSNUM", consumptionTransaction.getReservedNo()); // 预留/相关需求的编号
jsonObject.put("RSPOS", consumptionTransaction.getReservedLine()); // 预留 / 相关需求的项目编号
itemList.add(jsonObject);
newList.add(targetObj);
}
}
if (itemList.size() > 0) {
InvokeRequest invokeRequest = new InvokeRequest();
// 传参对象
try {
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(site);
invokeRequest.setMessageId("ZMM_MES_GOODSMVT_CREATE");
// 组装抛送的报完呢
String jsonObjectStr = SapUtil.appendHead(assembleMaterialMsgBody(itemList, postingDate));
invokeRequest.setMessageContent(jsonObjectStr);
invokeRequest.setStart(nowTime);
invokeRequest.setKeyValue(nowTime);
invokeRequest.setRetry(false);
TenantContextHolder.setTenantId(site);
invokeResponse = goodMvtCreateService.call(invokeRequest);
// 处理ERP返回的报文
invokeResponse = updateMaterialConsumption(invokeResponse.getObjectResponse(), srcList, invokeResponse);
} catch (Exception e) {
// 不用回滚,将错误抛出
invokeResponse.setResult("E");
invokeResponse.setMessageContent(e.getMessage());
}
}
InvokeResponse invokeResponse = lotMaterialDealSendSapService.callLotMaterialConsumption(zLotMaterialConsumptionTransactions, false,"");
if ("E".equals(invokeResponse.getResult())) {
return R.failed("SAP错误:"+invokeResponse.getMessageContent());
return R.failed("SAP错误:" + invokeResponse.getMessageContent());
} else {
return R.ok();
}
}
public InvokeResponse updateMaterialConsumption(JSONObject jsonObject, List<ZLotMaterialConsumptionTransaction> srcList, InvokeResponse invokeResponse) {
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
String result = outJson.getString("MSGTY");
String message = outJson.getString("MSGTX");
String msgno = outJson.getString("MSGNO"); // 系统消息编号
String mblnr = outJson.getString("MBLNR"); // 物料凭证编号
for (ZLotMaterialConsumptionTransaction targetObj : srcList) {
targetObj.setSyncStatus(result);
targetObj.setSyncMsgText(message);
targetObj.setSyncMsgNo(msgno);
targetObj.setSyncSubmitter(SecurityUtils.getUserName());
targetObj.setSyncVoucherNo(mblnr);
targetObj.setCreator(SecurityUtils.getUserName());
targetObj.setDateCreate(LocalDateTime.now());
zLotMaterialConsumptionTransactionMapper.updateById(targetObj);
}
invokeResponse.setResult(result);
invokeResponse.setMessageContent(message);
return invokeResponse;
}
// 凭证中的过账日期 yyyy-MM-dd
private String assembleMaterialMsgBody(JSONArray itemList, String postingDate) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("RFC_FUNCTION", "ZMM_MES_GOODSMVT_CREATE");
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 headBody = new JSONObject();
headBody.put("ZPARTNER", SecurityUtils.getUserName()); // 员工BP编号
headBody.put("BUDAT", postingDate); // 凭证中的过账日期
bodyRe.put("IS_HEAD", headBody);
bodyRe.put("IT_ITEM", itemList);
jsonObject.put("REQUEST_BODY", bodyRe);
return jsonObject.toJSONString();
}
// --------------------------------- 批次完工入库报工开始 -----------------------------------------------
@ApiOperation(value = "生产管理报工平台-批次完工入库获取SAP批次号", notes = "生产管理报工平台-批次完工入库获取SAP批次号")
@ -395,123 +290,119 @@ public class ShopOrderStatisticTransController {
@PostMapping("/api/getSapBatchNo")
public R<String> getSapBatchNo(@RequestBody String erpItem) {
String sapBatchNo = registerDocumentService.getSapBatchNo(erpItem);
return R.ok(sapBatchNo);
return R.ok(sapBatchNo);
}
@ApiOperation(value = "生产管理报工平台-批次完工入库报工", notes = "生产管理报工平台-批次完工入库报工")
@SysLog("生产管理报工平台-批次完工入库报工")
@PostMapping("/callErpLot")
public R callErpLot(@RequestBody List<ZLotMaterialCompleteTransaction> zLotMaterialCompleteTransactions) {
InvokeResponse invokeResponse = new InvokeResponse();
List<ZLotMaterialCompleteTransaction> newList = new ArrayList<>();
String site = "";
String postingDate = "";
JSONArray itemList = new JSONArray();
List<ZLotMaterialCompleteTransaction> srcList = new ArrayList<>();
for (ZLotMaterialCompleteTransaction completeTransaction : zLotMaterialCompleteTransactions) {
// 重新校验一遍是否已经报过工,防止重复报工
ZLotMaterialCompleteTransaction targetObj = zLotMaterialCompleteTransactionMapper.selectById(completeTransaction.getSid());
if ("S".equals(targetObj.getSyncStatus())) {
throw BusinessException.build("批次" + targetObj.getLotNo() + "完工已经报工,不可重复报工");
} else {
postingDate = completeTransaction.getSyncPostingDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
targetObj.setSyncPostingDate(completeTransaction.getSyncPostingDate());
srcList.add(targetObj);
JSONObject jsonObject = new JSONObject();
site = completeTransaction.getSite();
jsonObject.put("ZEILE", null); // 物料凭证中的项目
jsonObject.put("MATNR", completeTransaction.getErpItem()); // 物料编号
jsonObject.put("MATKL", ""); // 物料组
jsonObject.put("WERKS", site); // 工厂
jsonObject.put("LGORT", completeTransaction.getErpInventory()); // 存储地点
jsonObject.put("CHARG", completeTransaction.getSapBatchNo()); // 批次号
jsonObject.put("BWART", "101"); // 移动类型
jsonObject.put("SOBKZ", ""); // 特殊库存标识
jsonObject.put("AUFNR", completeTransaction.getShopOrder()); // 订单号
jsonObject.put("EBELN", ""); // 采购订单号
jsonObject.put("EBELP", ""); // 采购凭证的项目编号
jsonObject.put("MENGE", completeTransaction.getMainQty()); // 数量
jsonObject.put("MEINS", completeTransaction.getMainUom()); // 基本计量单位
if(completeTransaction.getSubQty()!=null){
jsonObject.put("ERFMG", completeTransaction.getSubQty()); // 以录入项单位表示的数量
jsonObject.put("ERFME", completeTransaction.getSubUom()); // 录入单位
}else{
jsonObject.put("ERFMG", null); // 以录入项单位表示的数量
jsonObject.put("ERFME", ""); // 录入单位
}
jsonObject.put("MAT_KDAUF", completeTransaction.getSoNo()); // 评估销售定单库存的销售定单号
if(StringUtils.isNotEmpty(completeTransaction.getSoLineNo())){
jsonObject.put("MAT_KDPOS", Integer.valueOf(completeTransaction.getSoLineNo())); // 评估销售订单库存的销售订单项目
}else{
jsonObject.put("MAT_KDPOS", null); // 评估销售订单库存的销售订单项目
}
jsonObject.put("UMWRK", ""); // 收货工厂/发货工厂
jsonObject.put("UMLGO", ""); // 收货/发货库存地点
jsonObject.put("UMCHA", ""); // 收货/发货批量
jsonObject.put("RSNUM", ""); // 预留/相关需求的编号
jsonObject.put("RSPOS", ""); // 预留 / 相关需求的项目编号
jsonObject.put("Z_JH", completeTransaction.getLotNo()); // 卷号
jsonObject.put("Z_CVN", completeTransaction.getExternalLot()); // 客户卷号
jsonObject.put("Z_GRADE", completeTransaction.getQcGrade()); // 等级
itemList.add(jsonObject);
newList.add(targetObj);
}
}
if (itemList.size() > 0) {
InvokeRequest invokeRequest = new InvokeRequest();
// 传参对象
try {
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(site);
invokeRequest.setMessageId("ZMM_MES_GOODSMVT_CREATE");
// 组装抛送的报完呢
String jsonObjectStr = SapUtil.appendHead(assembleMaterialMsgBody(itemList, postingDate));
invokeRequest.setMessageContent(jsonObjectStr);
invokeRequest.setStart(nowTime);
invokeRequest.setKeyValue(nowTime);
invokeRequest.setRetry(false);
TenantContextHolder.setTenantId(site);
invokeResponse = goodMvtCreateService.call(invokeRequest);
// 处理ERP返回的报文
invokeResponse = updateLotComplete(invokeResponse.getObjectResponse(), srcList, invokeResponse);
} catch (Exception e) {
// 不用回滚,将错误抛出
invokeResponse.setResult("E");
invokeResponse.setMessageContent(e.getMessage());
}
}
InvokeResponse invokeResponse = lotMaterialDealSendSapService.callLotMaterialComplete(zLotMaterialCompleteTransactions, false,"");
if ("E".equals(invokeResponse.getResult())) {
return R.failed("SAP错误:"+invokeResponse.getMessageContent());
return R.failed("SAP错误:" + invokeResponse.getMessageContent());
} else {
return R.ok();
}
}
public InvokeResponse updateLotComplete(JSONObject jsonObject, List<ZLotMaterialCompleteTransaction> srcList, InvokeResponse invokeResponse) {
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
String result = outJson.getString("MSGTY");
String message = outJson.getString("MSGTX");
String msgNo = outJson.getString("MSGNO");
String mblnr = outJson.getString("MBLNR"); // 物料凭证编号
for (ZLotMaterialCompleteTransaction targetObj : srcList) {
targetObj.setSyncStatus(result);
targetObj.setSyncMsgText(message);
targetObj.setSyncMsgNo(msgNo);
targetObj.setSyncVoucherNo(mblnr);
targetObj.setSyncSubmitter(SecurityUtils.getUserName());
targetObj.setCreator(SecurityUtils.getUserName());
targetObj.setDateCreate(LocalDateTime.now());
zLotMaterialCompleteTransactionMapper.updateById(targetObj);
@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();
}
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());
}
invokeResponse.setResult(result);
invokeResponse.setMessageContent(message);
return invokeResponse;
}

View File

@ -2,215 +2,94 @@ package com.foreverwin.iep.integration.handler.def.job;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.foreverwin.iep.integration.domain.InvokeRequest;
import com.foreverwin.iep.common.faas.common.util.StringUtils;
import com.foreverwin.iep.integration.domain.InvokeResponse;
import com.foreverwin.iep.integration.handler.def.sap.GoodMvtCreateService;
import com.foreverwin.iep.integration.handler.def.sap.SapUtil;
import com.foreverwin.iep.integration.service.LotMaterialDealSendSapService;
import com.foreverwin.iep.integration.utils.JS;
import com.foreverwin.iep.prd.entity.ZLotMaterialCompleteTransaction;
import com.foreverwin.iep.prd.entity.ZLotMaterialConsumptionTransaction;
import com.foreverwin.iep.prd.mapper.ZLotMaterialCompleteTransactionMapper;
import com.foreverwin.iep.prd.mapper.ZLotMaterialConsumptionTransactionMapper;
import com.foreverwin.mom.common.core.exception.BusinessException;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
import com.foreverwin.mom.common.security.util.SecurityUtils;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.ListUtils;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 101完工入库JOB
* 261物料消耗JOB
*/
@Component
@AllArgsConstructor
public class SapMaterialConsumptionJob {
private final ZLotMaterialConsumptionTransactionMapper zLotMaterialConsumptionTransactionMapper;
private final GoodMvtCreateService goodMvtCreateService;
@XxlJob("sapMaterialConsumptionJobHandler")
public ReturnT<String> sapMaterialConsumptionJobHandler() {
try {
String site = null;
String startDate = null;
String endDate = null;
String postingDate = null;String jobParam = XxlJobHelper.getJobParam();
if (StrUtil.isNotBlank(jobParam)) {
Map<String, String> paramMap = JS.parseMap(jobParam, "=", ";");
site = paramMap.get("site");
startDate = paramMap.get("startDate");
endDate = paramMap.get("endDate");
postingDate = paramMap.get("postingDate");
}
if (StrUtil.isBlank(site)) {
XxlJobHelper.log("ERROR:未维护站点[site]参数");
return ReturnT.FAIL;
} else {
TenantContextHolder.setTenantId(site);
if (StrUtil.isBlank(startDate) && StrUtil.isBlank(endDate)) {
// 没有昨天一天的数据,默认昨天
startDate = DateUtil.format(DateUtil.beginOfDay(DateUtil.yesterday()), "yyyy-MM-dd HH:mm:ss");
endDate = DateUtil.format(DateUtil.endOfDay(DateUtil.yesterday()), "yyyy-MM-dd HH:mm:ss");
}
XxlJobHelper.log("*************************站点:" + site +",开始261物料消耗同步至ERP************************");
XxlJobHelper.log("*************************时间:" + startDate + "至" + endDate + "************************");
XxlJobHelper.log("*************************过账日期:" + postingDate + "************************");
List<ZLotMaterialConsumptionTransaction> zLotMaterialConsumptionTransactionList = zLotMaterialConsumptionTransactionMapper.selectList(
Wrappers.<ZLotMaterialConsumptionTransaction>lambdaQuery().eq(
ZLotMaterialConsumptionTransaction::getSite, site).ne(
ZLotMaterialConsumptionTransaction::getSyncStatus, "S")
.gt(ZLotMaterialConsumptionTransaction::getDateCreate, startDate)
.lt(ZLotMaterialConsumptionTransaction::getDateCreate, endDate));
if (CollectionUtils.isEmpty(zLotMaterialConsumptionTransactionList)) {
XxlJobHelper.log("WARN:没有需要同步的261物料消耗数据!!!");
return ReturnT.SUCCESS;
}
for (ZLotMaterialConsumptionTransaction consumptionTransaction : zLotMaterialConsumptionTransactionList) {
InvokeResponse invokeResponse = new InvokeResponse();
JSONArray itemList = new JSONArray();
List<ZLotMaterialConsumptionTransaction> srcList = new ArrayList<>();
// 重新校验一遍是否已经报过工,防止重复报工
ZLotMaterialConsumptionTransaction targetObj = zLotMaterialConsumptionTransactionMapper.selectById(consumptionTransaction.getSid());
if ("S".equals(targetObj.getSyncStatus())) {
XxlJobHelper.log("ERROR:批次" + targetObj.getLotNo() + "已经报消耗,不可重复报消耗");
} else {
LocalDate syncPostingDate = consumptionTransaction.getSyncPostingDate();
if (syncPostingDate != null) {
// 使用原来的过账日期
postingDate = syncPostingDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
if (StrUtil.isBlank(postingDate)) {
// 如果还不存在,默认为当天过账日期
postingDate = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd");
}
targetObj.setSyncPostingDate(LocalDate.parse(postingDate));
srcList.add(targetObj);
JSONObject jsonObject = new JSONObject();
site = consumptionTransaction.getSite();
jsonObject.put("ZEILE", ""); // 物料凭证中的项目
jsonObject.put("MATNR", consumptionTransaction.getErpItem()); // 物料编号
jsonObject.put("MATKL", ""); // 物料组
jsonObject.put("WERKS", site); // 工厂
jsonObject.put("LGORT", consumptionTransaction.getErpInventory()); // 存储地点
jsonObject.put("CHARG", consumptionTransaction.getSapBatchNo()); // 批次号
jsonObject.put("BWART", "261"); // 移动类型
jsonObject.put("SOBKZ", ""); // 特殊库存标识
jsonObject.put("AUFNR", consumptionTransaction.getShopOrder()); // 订单号
jsonObject.put("EBELN", ""); // 采购订单号
jsonObject.put("EBELP", ""); // 采购凭证的项目编号
jsonObject.put("MENGE", consumptionTransaction.getMainQty()); // 数量
jsonObject.put("MEINS", consumptionTransaction.getMainUom()); // 基本计量单位
if(consumptionTransaction.getSubQty()!=null){
jsonObject.put("ERFMG", consumptionTransaction.getSubQty()); // 以录入项单位表示的数量
jsonObject.put("ERFME", consumptionTransaction.getSubUom()); // 录入单位
}else{
jsonObject.put("ERFMG", null); // 以录入项单位表示的数量
jsonObject.put("ERFME", ""); // 录入单位
}
jsonObject.put("MAT_KDAUF", ""); // 评估销售定单库存的销售定单号
jsonObject.put("MAT_KDPOS", ""); // 评估销售订单库存的销售订单项目
jsonObject.put("UMWRK", ""); // 收货工厂/发货工厂
jsonObject.put("UMLGO", ""); // 收货/发货库存地点
jsonObject.put("UMCHA", ""); // 收货/发货批量
jsonObject.put("RSNUM", consumptionTransaction.getReservedNo()); // 预留/相关需求的编号
jsonObject.put("RSPOS", consumptionTransaction.getReservedLine()); // 预留 / 相关需求的项目编号
itemList.add(jsonObject);
InvokeRequest invokeRequest = new InvokeRequest();
// 传参对象
try {
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(site);
invokeRequest.setMessageId("ZMM_MES_GOODSMVT_CREATE");
// 组装抛送的报完呢
String jsonObjectStr = SapUtil.appendHead(assembleMaterialMsgBody(itemList, postingDate));
invokeRequest.setMessageContent(jsonObjectStr);
invokeRequest.setStart(nowTime);
invokeRequest.setKeyValue(nowTime);
invokeRequest.setRetry(false);
TenantContextHolder.setTenantId(site);
invokeResponse = goodMvtCreateService.call(invokeRequest);
// 处理ERP返回的报文
invokeResponse = updateMaterialConsumption(invokeResponse.getObjectResponse(), srcList, invokeResponse);
} catch (Exception e) {
// 不用回滚,将错误抛出
invokeResponse.setResult("E");
invokeResponse.setMessageContent(e.getMessage());
}
if (!"S".equals(invokeResponse.getResult())) {
XxlJobHelper.log("ERROR:批次" + targetObj.getLotNo() + ",消耗同步ERP失败或者异常:" + invokeResponse.getMessageContent());
} else {
XxlJobHelper.log("SUCCESS:批次" + targetObj.getLotNo() + ",消耗已同步ERP,时间:" + DateUtil.now());
}
}
}
return ReturnT.SUCCESS;
}
} catch (Exception e) {
XxlJobHelper.handleFail("ERROR:101完工入库同步ERP失败:" + e);
return ReturnT.FAIL;
}
}
public InvokeResponse updateMaterialConsumption(JSONObject jsonObject, List<ZLotMaterialConsumptionTransaction> srcList, InvokeResponse invokeResponse) {
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
String result = outJson.getString("MSGTY");
String message = outJson.getString("MSGTX");
String msgno = outJson.getString("MSGNO"); // 系统消息编号
String mblnr = outJson.getString("MBLNR"); // 物料凭证编号
for (ZLotMaterialConsumptionTransaction targetObj : srcList) {
targetObj.setSyncStatus(result);
targetObj.setSyncMsgText(message);
targetObj.setSyncMsgNo(msgno);
targetObj.setSyncSubmitter(SecurityUtils.getUserName());
targetObj.setSyncVoucherNo(mblnr);
targetObj.setUpdater(SecurityUtils.getUserName());
targetObj.setDateUpdate(LocalDateTime.now());
zLotMaterialConsumptionTransactionMapper.updateById(targetObj);
}
invokeResponse.setResult(result);
invokeResponse.setMessageContent(message);
return invokeResponse;
}
// 凭证中的过账日期 yyyy-MM-dd
private String assembleMaterialMsgBody(JSONArray itemList, String postingDate) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("RFC_FUNCTION", "ZMM_MES_GOODSMVT_CREATE");
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 headBody = new JSONObject();
headBody.put("ZPARTNER", SecurityUtils.getUserName()); // 员工BP编号
headBody.put("BUDAT", postingDate); // 凭证中的过账日期
bodyRe.put("IS_HEAD", headBody);
bodyRe.put("IT_ITEM", itemList);
jsonObject.put("REQUEST_BODY", bodyRe);
return jsonObject.toJSONString();
}
private final ZLotMaterialConsumptionTransactionMapper zLotMaterialConsumptionTransactionMapper;
private final LotMaterialDealSendSapService lotMaterialDealSendSapService;
@XxlJob("sapMaterialConsumptionJobHandler")
public ReturnT<String> sapMaterialConsumptionJobHandler() {
try {
String site = null;
String startDate = null;
String endDate = null;
String postingDate = null;
String jobParam = XxlJobHelper.getJobParam();
if (StrUtil.isNotBlank(jobParam)) {
Map<String, String> paramMap = JS.parseMap(jobParam, "=", ";");
site = paramMap.get("site");
startDate = paramMap.get("startDate");
endDate = paramMap.get("endDate");
postingDate = paramMap.get("postingDate");
}
if (StrUtil.isBlank(site)) {
XxlJobHelper.log("ERROR:未维护站点[site]参数");
return ReturnT.FAIL;
} else {
TenantContextHolder.setTenantId(site);
if (StrUtil.isBlank(startDate) && StrUtil.isBlank(endDate)) {
// 没有昨天一天的数据,默认昨天
startDate = DateUtil.format(DateUtil.beginOfDay(DateUtil.yesterday()), "yyyy-MM-dd HH:mm:ss");
endDate = DateUtil.format(DateUtil.endOfDay(DateUtil.yesterday()), "yyyy-MM-dd HH:mm:ss");
}
XxlJobHelper.log("*************************站点:" + site + ",开始261物料消耗同步至ERP************************");
XxlJobHelper.log("*************************时间:" + startDate + "至" + endDate + "************************");
XxlJobHelper.log("*************************过账日期:" + postingDate + "************************");
List<ZLotMaterialConsumptionTransaction> zLotMaterialConsumptionTransactionList = zLotMaterialConsumptionTransactionMapper.selectList(
Wrappers.<ZLotMaterialConsumptionTransaction>lambdaQuery().eq(
ZLotMaterialConsumptionTransaction::getSite, site).ne(
ZLotMaterialConsumptionTransaction::getSyncStatus, "S")
.gt(ZLotMaterialConsumptionTransaction::getDateCreate, startDate)
.lt(ZLotMaterialConsumptionTransaction::getDateCreate, endDate).orderByAsc(ZLotMaterialConsumptionTransaction::getDateCreate));
if (CollectionUtils.isEmpty(zLotMaterialConsumptionTransactionList)) {
XxlJobHelper.log("WARN:没有需要同步的261物料消耗数据!!!");
return ReturnT.SUCCESS;
}
if (StringUtils.isEmpty(postingDate)) {
postingDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
// 10笔10的送
if(zLotMaterialConsumptionTransactionList.size()>0){
List<List<ZLotMaterialConsumptionTransaction>> splitList = ListUtils.partition(zLotMaterialConsumptionTransactionList,10);
for (int i = 0; i < splitList.size(); i++) {
InvokeResponse invokeResponse = lotMaterialDealSendSapService.callLotMaterialConsumption(splitList.get(i), true, postingDate);
if (!"S".equals(invokeResponse.getResult())) {
XxlJobHelper.log("WARN:同步261物料消耗数据失败!!!" + invokeResponse.getMessageContent());
// return ReturnT.FAIL;
}
}
}
return ReturnT.SUCCESS;
}
} catch (Exception e) {
XxlJobHelper.handleFail("ERROR:同步261物料消耗数据同步ERP失败:" + e);
return ReturnT.FAIL;
}
}
}

View File

@ -1,46 +1,28 @@
package com.foreverwin.iep.integration.handler.def.job;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.foreverwin.iep.common.faas.common.util.StringUtils;
import com.foreverwin.iep.integration.component.Invoke;
import com.foreverwin.iep.integration.domain.InvokeRequest;
import com.foreverwin.iep.integration.domain.InvokeResponse;
import com.foreverwin.iep.integration.entity.IntInData;
import com.foreverwin.iep.integration.entity.IntInDataLog;
import com.foreverwin.iep.integration.handler.def.sap.GoodMvtCreateService;
import com.foreverwin.iep.integration.handler.def.sap.SapUtil;
import com.foreverwin.iep.integration.handler.def.sap.ShopOrderStatisticTransService;
import com.foreverwin.iep.integration.service.IntInDataLogService;
import com.foreverwin.iep.integration.service.IntInDataService;
import com.foreverwin.iep.integration.service.LotMaterialDealSendSapService;
import com.foreverwin.iep.integration.utils.JS;
import com.foreverwin.iep.prd.entity.ZLotMaterialCompleteTransaction;
import com.foreverwin.iep.prd.entity.ZShoporderStatisticsTransaction;
import com.foreverwin.iep.prd.entity.ZLotMaterialConsumptionTransaction;
import com.foreverwin.iep.prd.mapper.ZLotMaterialCompleteTransactionMapper;
import com.foreverwin.iep.prd.mapper.ZShoporderStatisticsTransactionMapper;
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.security.util.SecurityUtils;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.ListUtils;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* 101完工入库JOB
@ -48,11 +30,10 @@ import java.util.UUID;
@Component
@AllArgsConstructor
public class SapShopOrderCompleteJob {
private final ZLotMaterialCompleteTransactionMapper zLotMaterialCompleteTransactionMapper;
private final GoodMvtCreateService goodMvtCreateService;
private final LotMaterialDealSendSapService lotMaterialDealSendSapService;
@XxlJob("sapShopOrderCompleteJobHandler")
public ReturnT<String> sapShopOrderCompleteJobHandler() {
try {
@ -71,121 +52,39 @@ public class SapShopOrderCompleteJob {
if (StrUtil.isBlank(site)) {
XxlJobHelper.log("ERROR:未维护站点[site]参数");
return ReturnT.FAIL;
} else {TenantContextHolder.setTenantId(site);
} else {
TenantContextHolder.setTenantId(site);
if (StrUtil.isBlank(startDate) && StrUtil.isBlank(endDate)) {
// 没有昨天一天的数据,默认昨天
startDate = DateUtil.format(DateUtil.beginOfDay(DateUtil.yesterday()), "yyyy-MM-dd HH:mm:ss");
endDate = DateUtil.format(DateUtil.endOfDay(DateUtil.yesterday()), "yyyy-MM-dd HH:mm:ss");
}
XxlJobHelper.log("*************************站点:" + site +",开始101完工入库同步至ERP************************");
XxlJobHelper.log("*************************站点:" + site + ",开始101或531完工入库同步至ERP************************");
XxlJobHelper.log("*************************时间:" + startDate + "至" + endDate + "************************");
XxlJobHelper.log("*************************过账日期:" + postingDate + "************************");
List<ZLotMaterialCompleteTransaction> zLotMaterialCompleteTransactionList = zLotMaterialCompleteTransactionMapper.selectList(
Wrappers.<ZLotMaterialCompleteTransaction>lambdaQuery().eq(
ZLotMaterialCompleteTransaction::getSite, site).ne(
ZLotMaterialCompleteTransaction::getSyncStatus, "S")
.gt(ZLotMaterialCompleteTransaction::getDateCreate, startDate)
.lt(ZLotMaterialCompleteTransaction::getDateCreate, endDate));
.lt(ZLotMaterialCompleteTransaction::getDateCreate, endDate).orderByAsc(ZLotMaterialCompleteTransaction::getDateCreate));
if (CollectionUtils.isEmpty(zLotMaterialCompleteTransactionList)) {
XxlJobHelper.log("WARN:没有需要同步的101完工入库数据!!!");
XxlJobHelper.log("WARN:没有需要同步的101或531完工入库数据!!!");
return ReturnT.SUCCESS;
}
for (ZLotMaterialCompleteTransaction completeTransaction : zLotMaterialCompleteTransactionList) {
InvokeResponse invokeResponse = new InvokeResponse();
JSONArray itemList = new JSONArray();
List<ZLotMaterialCompleteTransaction> srcList = new ArrayList<>();
// 重新校验一遍是否已经报过工,防止重复报工
ZLotMaterialCompleteTransaction targetObj = zLotMaterialCompleteTransactionMapper.selectById(
completeTransaction.getSid());
if ("S".equals(targetObj.getSyncStatus())) {
XxlJobHelper.log("ERROR:批次" + targetObj.getLotNo() + "已经报工,不可重复报工");
} else {
LocalDate syncPostingDate = completeTransaction.getSyncPostingDate();
if (syncPostingDate != null) {
// 使用原来的过账日期
postingDate = syncPostingDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
if (StringUtils.isEmpty(postingDate)) {
postingDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
// 10笔10的送
if(zLotMaterialCompleteTransactionList.size()>0){
List<List<ZLotMaterialCompleteTransaction>> splitList = ListUtils.partition(zLotMaterialCompleteTransactionList,10);
for (int i = 0; i < splitList.size(); i++) {
InvokeResponse invokeResponse = lotMaterialDealSendSapService.callLotMaterialComplete(splitList.get(i), true, postingDate);
if (!"S".equals(invokeResponse.getResult())) {
XxlJobHelper.log("WARN:同步101或531完工入库数据失败!!!" + invokeResponse.getMessageContent());
// return ReturnT.FAIL;
}
if (StrUtil.isBlank(postingDate)) {
// 如果还不存在,默认为当天过账日期
postingDate = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd");
}
targetObj.setSyncPostingDate(LocalDate.parse(postingDate));
srcList.add(targetObj);
JSONObject jsonObject = new JSONObject();
site = completeTransaction.getSite();
jsonObject.put("ZEILE", null); // 物料凭证中的项目
jsonObject.put("MATNR", completeTransaction.getErpItem()); // 物料编号
jsonObject.put("MATKL", ""); // 物料组
jsonObject.put("WERKS", site); // 工厂
jsonObject.put("LGORT", completeTransaction.getErpInventory()); // 存储地点
jsonObject.put("CHARG", completeTransaction.getSapBatchNo()); // 批次号
jsonObject.put("BWART", "101"); // 移动类型
jsonObject.put("SOBKZ", ""); // 特殊库存标识
jsonObject.put("AUFNR", completeTransaction.getShopOrder()); // 订单号
jsonObject.put("EBELN", ""); // 采购订单号
jsonObject.put("EBELP", ""); // 采购凭证的项目编号
jsonObject.put("MENGE", completeTransaction.getMainQty()); // 数量
jsonObject.put("MEINS", completeTransaction.getMainUom()); // 基本计量单位
if (completeTransaction.getSubQty() != null) {
jsonObject.put("ERFMG", completeTransaction.getSubQty()); // 以录入项单位表示的数量
jsonObject.put("ERFME", completeTransaction.getSubUom()); // 录入单位
} else {
jsonObject.put("ERFMG", null); // 以录入项单位表示的数量
jsonObject.put("ERFME", ""); // 录入单位
}
jsonObject.put("MAT_KDAUF", completeTransaction.getSoNo()); // 评估销售定单库存的销售定单号
if (StringUtils.isNotEmpty(completeTransaction.getSoLineNo())) {
jsonObject.put("MAT_KDPOS",
Integer.valueOf(completeTransaction.getSoLineNo())); // 评估销售订单库存的销售订单项目
} else {
jsonObject.put("MAT_KDPOS", null); // 评估销售订单库存的销售订单项目
}
jsonObject.put("UMWRK", ""); // 收货工厂/发货工厂
jsonObject.put("UMLGO", ""); // 收货/发货库存地点
jsonObject.put("UMCHA", ""); // 收货/发货批量
jsonObject.put("RSNUM", ""); // 预留/相关需求的编号
jsonObject.put("RSPOS", ""); // 预留 / 相关需求的项目编号
jsonObject.put("Z_JH", completeTransaction.getLotNo()); // 卷号
jsonObject.put("Z_CVN", completeTransaction.getExternalLot()); // 客户卷号
jsonObject.put("Z_GRADE", completeTransaction.getQcGrade()); // 等级
itemList.add(jsonObject);
// 拼接报文
InvokeRequest invokeRequest = new InvokeRequest();
try {
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(site);
invokeRequest.setMessageId("ZMM_MES_GOODSMVT_CREATE");
// 组装抛送的报完呢
String jsonObjectStr = SapUtil.appendHead(assembleMaterialMsgBody(itemList, postingDate));
invokeRequest.setMessageContent(jsonObjectStr);
invokeRequest.setStart(nowTime);
invokeRequest.setKeyValue(nowTime);
invokeRequest.setRetry(false);
TenantContextHolder.setTenantId(site);
invokeResponse = goodMvtCreateService.call(invokeRequest);
// 处理ERP返回的报文
invokeResponse = updateLotComplete(invokeResponse.getObjectResponse(), srcList,
invokeResponse);
} catch (Exception e) {
// 不用回滚,将错误抛出
invokeResponse.setResult("E");
invokeResponse.setMessageContent(e.getMessage());
}
}
if (!"S".equals(invokeResponse.getResult())) {
XxlJobHelper.log("ERROR:批次" + targetObj.getLotNo() + ",同步ERP失败或者异常:" + invokeResponse.getMessageContent());
} else {
XxlJobHelper.log("SUCCESS:批次" + targetObj.getLotNo() + ",已同步ERP,时间:" + DateUtil.now());
}
}
return ReturnT.SUCCESS;
@ -195,48 +94,5 @@ public class SapShopOrderCompleteJob {
return ReturnT.FAIL;
}
}
// 凭证中的过账日期 yyyy-MM-dd
private String assembleMaterialMsgBody(JSONArray itemList, String postingDate) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("RFC_FUNCTION", "ZMM_MES_GOODSMVT_CREATE");
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 headBody = new JSONObject();
headBody.put("ZPARTNER", SecurityUtils.getUserName()); // 员工BP编号
headBody.put("BUDAT", postingDate); // 凭证中的过账日期
bodyRe.put("IS_HEAD", headBody);
bodyRe.put("IT_ITEM", itemList);
jsonObject.put("REQUEST_BODY", bodyRe);
return jsonObject.toJSONString();
}
// 完成后修改结果
public InvokeResponse updateLotComplete(JSONObject jsonObject, List<ZLotMaterialCompleteTransaction> srcList,
InvokeResponse invokeResponse) {
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
String result = outJson.getString("MSGTY");
String message = outJson.getString("MSGTX");
String msgNo = outJson.getString("MSGNO");
String mblnr = outJson.getString("MBLNR"); // 物料凭证编号
for (ZLotMaterialCompleteTransaction targetObj : srcList) {
targetObj.setSyncStatus(result);
targetObj.setSyncMsgText(message);
targetObj.setSyncMsgNo(msgNo);
targetObj.setSyncVoucherNo(mblnr);
targetObj.setSyncSubmitter(SecurityUtils.getUserName());
targetObj.setUpdater(SecurityUtils.getUserName());
targetObj.setDateUpdate(LocalDateTime.now());
zLotMaterialCompleteTransactionMapper.updateById(targetObj);
}
invokeResponse.setResult(result);
invokeResponse.setMessageContent(message);
return invokeResponse;
}
}

View File

@ -57,7 +57,7 @@ public class ShopOrderStatisticTransCancelService implements HandlerService {
shoporderStatisticsTransaction.setSyncTicketNo(outJson.getString("VORNR"));
String result = outJson.getString("MSGTY");
invokeResponse.setResult(result);
shoporderStatisticsTransaction.setSyncStatus(result);
shoporderStatisticsTransaction.setErpReverse(result);
shoporderStatisticsTransaction.setSyncMessageRemark(outJson.getString("MSGID"));
shoporderStatisticsTransaction.setSyncMessageNo(outJson.getString("MSGNO"));
String message = outJson.getString("MSGTX");
@ -65,7 +65,6 @@ public class ShopOrderStatisticTransCancelService implements HandlerService {
shoporderStatisticsTransaction.setSyncMessageText(message);
shoporderStatisticsTransaction.setUpdater(SecurityUtils.getUserName());
shoporderStatisticsTransaction.setDateUpdate(LocalDateTime.now());
shoporderStatisticsTransaction.setStatus("N");
zShoporderStatisticsTransactionMapper.updateById(shoporderStatisticsTransaction);
return invokeResponse;
}else{

View File

@ -0,0 +1,14 @@
package com.foreverwin.iep.integration.service;
import com.foreverwin.iep.integration.domain.InvokeResponse;
import com.foreverwin.iep.prd.entity.ZLotMaterialCompleteTransaction;
import com.foreverwin.iep.prd.entity.ZLotMaterialConsumptionTransaction;
import java.util.List;
public interface LotMaterialDealSendSapService {
InvokeResponse callLotMaterialComplete(List<ZLotMaterialCompleteTransaction> zLotMaterialCompleteTransactions, boolean isPass, String postingDate);
InvokeResponse callLotMaterialConsumption(List<ZLotMaterialConsumptionTransaction> zLotMaterialConsumptionTransactions, boolean isPass, String postingDate);
}

View File

@ -138,6 +138,8 @@ public class IntInDataServiceImpl extends ServiceImpl<IntInDataMapper, IntInData
throw BusinessException.build(messageId+" 接口未检索到帐期关闭的数据");
}else{
Integer countSize = dataLogDTOS.size();
Integer errorCount = 0;
Integer successCount = 0;
InvokeResponse invokeResponse = new InvokeResponse();
for (int i = 0; i < countSize; i++) {
IntInDataLogDTO dataLogDTO = dataLogDTOS.get(i);
@ -158,18 +160,20 @@ public class IntInDataServiceImpl extends ServiceImpl<IntInDataMapper, IntInData
log.setState("S");
log.setResponse(jsonObject.toJSONString());
intInDataLogService.updateById(log);
successCount = successCount +1;
}else{
IntInDataLog log = intInDataLogService.getById(logId);
log.setState(result);
log.setResponse(jsonObject.toJSONString());
intInDataLogService.updateById(log);
throw BusinessException.build("共【"+countSize+"】数据,第【"+(i+1)+"】笔处理失败,结果为【"+result+"】,请求编号【"+logId+"】报: "+message);
errorCount = errorCount+1;
// throw BusinessException.build("共【"+countSize+"】数据,第【"+(i+1)+"】笔处理失败,结果为【"+result+"】,请求编号【"+logId+"】报: "+message);
}
}else{
throw BusinessException.build(messageId+" SAP处理失败");
}
}
return "成功处理【"+countSize+"】笔数据";
return "共处理【"+countSize+"】笔数据,【"+successCount+"】笔成功,【"+errorCount+"】笔失败";
}
}
}

View File

@ -0,0 +1,306 @@
package com.foreverwin.iep.integration.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.foreverwin.iep.common.faas.common.util.StringUtils;
import com.foreverwin.iep.integration.domain.InvokeRequest;
import com.foreverwin.iep.integration.domain.InvokeResponse;
import com.foreverwin.iep.integration.handler.def.sap.GoodMvtCreateService;
import com.foreverwin.iep.integration.handler.def.sap.SapUtil;
import com.foreverwin.iep.integration.service.LotMaterialDealSendSapService;
import com.foreverwin.iep.prd.entity.ZLotMaterialCompleteTransaction;
import com.foreverwin.iep.prd.entity.ZLotMaterialConsumptionTransaction;
import com.foreverwin.iep.prd.mapper.ZLotMaterialCompleteTransactionMapper;
import com.foreverwin.iep.prd.mapper.ZLotMaterialConsumptionTransactionMapper;
import com.foreverwin.iep.wip.entity.LotMaterial;
import com.foreverwin.iep.wip.mapper.LotMaterialMapper;
import com.foreverwin.mom.common.core.exception.BusinessException;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
import com.foreverwin.mom.common.security.util.SecurityUtils;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
@Service
@AllArgsConstructor
public class LotMaterialDealSendSapServiceImpl implements LotMaterialDealSendSapService {
private final GoodMvtCreateService goodMvtCreateService;
private final ZLotMaterialConsumptionTransactionMapper zLotMaterialConsumptionTransactionMapper;
private final ZLotMaterialCompleteTransactionMapper zLotMaterialCompleteTransactionMapper;
private final LotMaterialMapper lotMaterialMapper;
private final String messageId = "ZMM_MES_GOODSMVT_CREATE";
@Override
public InvokeResponse callLotMaterialComplete(List<ZLotMaterialCompleteTransaction> zLotMaterialCompleteTransactions, boolean isPass, String postingDate) {
InvokeResponse invokeResponse = new InvokeResponse();
List<ZLotMaterialCompleteTransaction> newOneZeroOneList = new ArrayList<>();
List<ZLotMaterialCompleteTransaction> newFiveThreeOneList = new ArrayList<>();
String site = "";
JSONArray oneZeroOneList = new JSONArray();
JSONArray fiveThreeOneList = new JSONArray();
List<ZLotMaterialCompleteTransaction> srcList = new ArrayList<>();
for (ZLotMaterialCompleteTransaction completeTransaction : zLotMaterialCompleteTransactions) {
// 重新校验一遍是否已经报过工,防止重复报工
ZLotMaterialCompleteTransaction targetObj = zLotMaterialCompleteTransactionMapper.selectById(completeTransaction.getSid());
if ("S".equals(targetObj.getSyncStatus()) && !isPass) {
throw BusinessException.build("批次" + targetObj.getLotNo() + "完工已经报工,不可重复报工");
} else {
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);
JSONObject jsonObject = new JSONObject();
site = completeTransaction.getSite();
jsonObject.put("ZEILE", null); // 物料凭证中的项目
jsonObject.put("MATNR", completeTransaction.getErpItem()); // 物料编号
jsonObject.put("MATKL", ""); // 物料组
jsonObject.put("WERKS", site); // 工厂
jsonObject.put("LGORT", completeTransaction.getErpInventory()); // 存储地点
jsonObject.put("CHARG", completeTransaction.getSapBatchNo()); // 批次号
jsonObject.put("BWART", completeTransaction.getProductType()); // 移动类型
jsonObject.put("SOBKZ", ""); // 特殊库存标识
jsonObject.put("AUFNR", completeTransaction.getShopOrder()); // 订单号
jsonObject.put("EBELN", ""); // 采购订单号
jsonObject.put("EBELP", ""); // 采购凭证的项目编号
jsonObject.put("MENGE", completeTransaction.getMainQty()); // 数量
jsonObject.put("MEINS", completeTransaction.getMainUom()); // 基本计量单位
if (com.foreverwin.iep.common.faas.common.util.StringUtils.isEmpty(completeTransaction.getSubUom()) || completeTransaction.getSubQty() == null) {
jsonObject.put("ERFMG", null); // 以录入项单位表示的数量
jsonObject.put("ERFME", ""); // 录入单位
} else {
jsonObject.put("ERFMG", completeTransaction.getSubQty()); // 以录入项单位表示的数量
jsonObject.put("ERFME", completeTransaction.getSubUom()); // 录入单位
}
jsonObject.put("MAT_KDAUF", completeTransaction.getSoNo()); // 评估销售定单库存的销售定单号
if (StringUtils.isNotEmpty(completeTransaction.getSoLineNo())) {
jsonObject.put("MAT_KDPOS", Integer.valueOf(completeTransaction.getSoLineNo())); // 评估销售订单库存的销售订单项目
} else {
jsonObject.put("MAT_KDPOS", null); // 评估销售订单库存的销售订单项目
}
jsonObject.put("UMWRK", ""); // 收货工厂/发货工厂
jsonObject.put("UMLGO", ""); // 收货/发货库存地点
jsonObject.put("UMCHA", ""); // 收货/发货批量
jsonObject.put("RSNUM", ""); // 预留/相关需求的编号
jsonObject.put("RSPOS", ""); // 预留 / 相关需求的项目编号
jsonObject.put("Z_JH", completeTransaction.getLotNo()); // 卷号
jsonObject.put("Z_CVN", completeTransaction.getExternalLot()); // 客户卷号
jsonObject.put("Z_GRADE", completeTransaction.getQcGrade()); // 等级
if ("101".equals(completeTransaction.getProductType())) {
oneZeroOneList.add(jsonObject);
newOneZeroOneList.add(targetObj);
} else if ("531".equals(completeTransaction.getProductType())) {
fiveThreeOneList.add(jsonObject);
newFiveThreeOneList.add(targetObj);
}
}
}
if (oneZeroOneList.size() > 0) {
invokeResponse = sendSap(invokeResponse, site, oneZeroOneList, postingDate, newOneZeroOneList);
} else {
invokeResponse.setResult("S");
}
if ("S".equals(invokeResponse.getResult()) && fiveThreeOneList.size() > 0) {
invokeResponse = sendSap(invokeResponse, site, fiveThreeOneList, postingDate, newFiveThreeOneList);
}
return invokeResponse;
}
public InvokeResponse sendSap(InvokeResponse invokeResponse, String site, JSONArray itemList, String postingDate, List<ZLotMaterialCompleteTransaction> srcList) {
InvokeRequest invokeRequest = new InvokeRequest();
// 传参对象
try {
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(site);
invokeRequest.setMessageId(messageId);
// 组装抛送的报完呢
String jsonObjectStr = SapUtil.appendHead(assembleMaterialMsgBody(itemList, postingDate));
invokeRequest.setMessageContent(jsonObjectStr);
invokeRequest.setStart(nowTime);
invokeRequest.setKeyValue(nowTime);
invokeRequest.setRetry(false);
TenantContextHolder.setTenantId(site);
invokeResponse = goodMvtCreateService.call(invokeRequest);
// 处理ERP返回的报文
invokeResponse = updateLotComplete(invokeResponse.getObjectResponse(), srcList, invokeResponse);
} catch (Exception e) {
// 不用回滚,将错误抛出
invokeResponse.setResult("E");
invokeResponse.setMessageContent(e.getMessage());
}
return invokeResponse;
}
// 凭证中的过账日期 yyyy-MM-dd
private String assembleMaterialMsgBody(JSONArray itemList, String postingDate) {
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 headBody = new JSONObject();
headBody.put("ZPARTNER", SecurityUtils.getUserName()); // 员工BP编号
headBody.put("BUDAT", postingDate); // 凭证中的过账日期
bodyRe.put("IS_HEAD", headBody);
bodyRe.put("IT_ITEM", itemList);
jsonObject.put("REQUEST_BODY", bodyRe);
return jsonObject.toJSONString();
}
public InvokeResponse updateLotComplete(JSONObject jsonObject, List<ZLotMaterialCompleteTransaction> srcList, InvokeResponse invokeResponse) {
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
String result = outJson.getString("MSGTY");
String message = outJson.getString("MSGTX");
String msgNo = outJson.getString("MSGNO");
String mblnr = outJson.getString("MBLNR"); // 物料凭证编号
for (ZLotMaterialCompleteTransaction targetObj : srcList) {
targetObj.setSyncStatus(result);
targetObj.setSyncMsgText(message);
targetObj.setSyncMsgNo(msgNo);
targetObj.setSyncVoucherNo(mblnr);
targetObj.setSyncSubmitter(SecurityUtils.getUserName());
targetObj.setCreator(SecurityUtils.getUserName());
targetObj.setDateCreate(LocalDateTime.now());
zLotMaterialCompleteTransactionMapper.updateById(targetObj);
}
invokeResponse.setResult(result);
invokeResponse.setMessageContent(message);
return invokeResponse;
}
// ------------------------- 物料消耗报工开始 ----------------------------------------------------------
@Override
public InvokeResponse callLotMaterialConsumption(List<ZLotMaterialConsumptionTransaction> zLotMaterialConsumptionTransactions, boolean isPass, String postingDate) {
InvokeResponse invokeResponse = new InvokeResponse();
String site = "";
JSONArray itemList = new JSONArray();
List<ZLotMaterialConsumptionTransaction> srcList = new ArrayList<>();
for (ZLotMaterialConsumptionTransaction consumptionTransaction : zLotMaterialConsumptionTransactions) {
// 重新校验一遍是否已经报过工,防止重复报工
ZLotMaterialConsumptionTransaction targetObj = zLotMaterialConsumptionTransactionMapper.selectById(consumptionTransaction.getSid());
if ("S".equals(targetObj.getSyncStatus()) && !isPass) {
throw BusinessException.build("批次" + targetObj.getLotNo() + "消耗已经报工,不可重复报工");
} else {
if (StringUtils.isEmpty(postingDate)) {
postingDate = consumptionTransaction.getSyncPostingDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
} else {
consumptionTransaction.setSyncPostingDate(LocalDate.parse(postingDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")));
}
targetObj.setSyncPostingDate(consumptionTransaction.getSyncPostingDate());
srcList.add(targetObj);
JSONObject jsonObject = new JSONObject();
site = consumptionTransaction.getSite();
jsonObject.put("ZEILE", ""); // 物料凭证中的项目
jsonObject.put("MATNR", consumptionTransaction.getComponentItem()); // 物料编号
jsonObject.put("MATKL", ""); // 物料组
jsonObject.put("WERKS", site); // 工厂
jsonObject.put("LGORT", consumptionTransaction.getErpInventory()); // 存储地点
jsonObject.put("CHARG", consumptionTransaction.getSapBatchNo()); // 批次号
jsonObject.put("BWART", "261"); // 移动类型
jsonObject.put("SOBKZ", ""); // 特殊库存标识
jsonObject.put("AUFNR", consumptionTransaction.getShopOrder()); // 订单号
jsonObject.put("EBELN", ""); // 采购订单号
jsonObject.put("EBELP", ""); // 采购凭证的项目编号
jsonObject.put("MENGE", consumptionTransaction.getMainQty()); // 数量
jsonObject.put("MEINS", consumptionTransaction.getMainUom()); // 基本计量单位
if (StringUtils.isEmpty(consumptionTransaction.getSubUom()) || consumptionTransaction.getSubQty() == null) {
jsonObject.put("ERFMG", null); // 以录入项单位表示的数量
jsonObject.put("ERFME", ""); // 录入单位
} else {
jsonObject.put("ERFMG", consumptionTransaction.getSubQty()); // 以录入项单位表示的数量
jsonObject.put("ERFME", consumptionTransaction.getSubUom()); // 录入单位
}
jsonObject.put("MAT_KDAUF", ""); // 评估销售定单库存的销售定单号
jsonObject.put("MAT_KDPOS", ""); // 评估销售订单库存的销售订单项目
jsonObject.put("UMWRK", ""); // 收货工厂/发货工厂
jsonObject.put("UMLGO", ""); // 收货/发货库存地点
jsonObject.put("UMCHA", ""); // 收货/发货批量
jsonObject.put("RSNUM", consumptionTransaction.getReservedNo()); // 预留/相关需求的编号
jsonObject.put("RSPOS", consumptionTransaction.getReservedLine()); // 预留 / 相关需求的项目编号
itemList.add(jsonObject);
}
}
if (itemList.size() > 0) {
InvokeRequest invokeRequest = new InvokeRequest();
// 传参对象
try {
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(site);
invokeRequest.setMessageId(messageId);
// 组装抛送的报完呢
String jsonObjectStr = SapUtil.appendHead(assembleMaterialMsgBody(itemList, postingDate));
invokeRequest.setMessageContent(jsonObjectStr);
invokeRequest.setStart(nowTime);
invokeRequest.setKeyValue(nowTime);
invokeRequest.setRetry(false);
TenantContextHolder.setTenantId(site);
invokeResponse = goodMvtCreateService.call(invokeRequest);
// 处理ERP返回的报文
invokeResponse = updateMaterialConsumption(invokeResponse.getObjectResponse(), srcList, invokeResponse);
} catch (Exception e) {
// 不用回滚,将错误抛出
invokeResponse.setResult("E");
invokeResponse.setMessageContent(e.getMessage());
}
}
return invokeResponse;
}
public InvokeResponse updateMaterialConsumption(JSONObject jsonObject, List<ZLotMaterialConsumptionTransaction> srcList, InvokeResponse invokeResponse) {
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
String result = outJson.getString("MSGTY");
String message = outJson.getString("MSGTX");
String msgno = outJson.getString("MSGNO"); // 系统消息编号
String mblnr = outJson.getString("MBLNR"); // 物料凭证编号
for (ZLotMaterialConsumptionTransaction targetObj : srcList) {
targetObj.setSyncStatus(result);
targetObj.setSyncMsgText(message);
targetObj.setSyncMsgNo(msgno);
targetObj.setSyncSubmitter(SecurityUtils.getUserName());
targetObj.setSyncVoucherNo(mblnr);
targetObj.setCreator(SecurityUtils.getUserName());
targetObj.setDateCreate(LocalDateTime.now());
zLotMaterialConsumptionTransactionMapper.updateById(targetObj);
// 如果报工成功,就更新消耗表的erp标识为Y
if ("S".equalsIgnoreCase(result)) {
LotMaterial lotMaterial = lotMaterialMapper.selectById(targetObj.getLotMaterialSid());
if (lotMaterial != null) {
lotMaterial.setErpFlag("Y");
lotMaterialMapper.updateById(lotMaterial);
}
}
}
invokeResponse.setResult(result);
invokeResponse.setMessageContent(message);
return invokeResponse;
}
}