采购冲销SAP接口实现测试通过
This commit is contained in:
parent
9ad5813acc
commit
d47edca3ac
@ -23,6 +23,7 @@ import com.foreverwin.mom.wms.api.feign.RemotePoService;
|
||||
import com.foreverwin.mom.wms.entity.Document;
|
||||
import com.foreverwin.mom.wms.entity.DocumentDetailed;
|
||||
import com.foreverwin.mom.wms.util.StringUtils;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@ -307,24 +308,24 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
|
||||
// 冲销
|
||||
@Override
|
||||
@Transactional
|
||||
@GlobalTransactional
|
||||
public void cancelDocumentNo(Document document) {
|
||||
// 呼叫SAP
|
||||
String site = TenantContextHolder.getTenantId();
|
||||
String materialDocument = document.getMaterialDocument();
|
||||
if(StringUtils.isEmpty(materialDocument)){
|
||||
if (StringUtils.isEmpty(materialDocument)) {
|
||||
throw BusinessException.build("单据的物料凭证号为空");
|
||||
}
|
||||
InvokeResponse invokeResponse = assembleCancelBody( site,materialDocument);
|
||||
remotePoService.cancelDocumentNo(document);
|
||||
// 传送SAP
|
||||
InvokeResponse invokeResponse = assembleCancelBody(site, materialDocument, document.getPostingDate());
|
||||
// 处理MES中自己的逻辑
|
||||
if("S".equals(invokeResponse.getResult())){
|
||||
remotePoService.cancelDocumentNo(document);
|
||||
}else{
|
||||
throw BusinessException.build("SAP错误"+invokeResponse.getMessageContent());
|
||||
if (!"S".equals(invokeResponse.getResult())) {
|
||||
throw BusinessException.build("SAP错误:" + invokeResponse.getMessageContent());
|
||||
}
|
||||
}
|
||||
|
||||
private InvokeResponse assembleCancelBody(String site,String mblnr) {
|
||||
private InvokeResponse assembleCancelBody(String site, String mblnr, String postDate) {
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
// 呼叫ERP获取批次号
|
||||
LocalDateTime nowLocalDateTime = LocalDateTime.now();
|
||||
@ -334,7 +335,7 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
invokeRequest.setFromSystem("IEP");
|
||||
invokeRequest.setToSystem("ERP");
|
||||
invokeRequest.setSite(site);
|
||||
invokeRequest.setMessageId("ZMM_MES_CHARG_CREATE1");
|
||||
invokeRequest.setMessageId("ZMM_MES_GOODMVT_REVERSE");
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("RFC_FUNCTION", "ZMM_MES_GOODMVT_REVERSE");
|
||||
@ -345,9 +346,9 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
jsonObject.put("REQUEST_CONTEXT", headRe);
|
||||
JSONObject bodyRe = new JSONObject();
|
||||
JSONObject inputJson = new JSONObject();
|
||||
inputJson.put("MBLNR",mblnr); // 物料凭证编号
|
||||
inputJson.put("BUDAT",LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); // 凭证中的过账日期
|
||||
inputJson.put("ZPARTNER",SecurityUtils.getUserName()); // 员工BP编号
|
||||
inputJson.put("MBLNR", mblnr); // 物料凭证编号
|
||||
inputJson.put("BUDAT", postDate); // 凭证中的过账日期
|
||||
inputJson.put("ZPARTNER", SecurityUtils.getUserName()); // 员工BP编号
|
||||
bodyRe.put("IS_INPUT", inputJson);
|
||||
jsonObject.put("REQUEST_BODY", bodyRe);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user