Merge branch 'main' of http://10.10.11.66:3000/mes/nalinv-int
This commit is contained in:
commit
92393dc26a
@ -288,6 +288,16 @@ public class SapInShopOrderCustomFieldsDTO {
|
||||
*/
|
||||
@SerializedName("ZCT_TPSM1")
|
||||
private String zctTpsm1;
|
||||
/**
|
||||
* 过量收货百分比
|
||||
*/
|
||||
@SerializedName("ZGLJH")
|
||||
private String zgljh;
|
||||
/**
|
||||
* 无限制收货标识
|
||||
*/
|
||||
@SerializedName("ZWXZ")
|
||||
private String zwxz;
|
||||
/**
|
||||
* 扩展字段1
|
||||
*/
|
||||
|
||||
@ -4,6 +4,7 @@ import com.foreverwin.iep.integration.domain.InvokeResponse;
|
||||
import com.foreverwin.iep.integration.service.RegisterDocumentService;
|
||||
import com.foreverwin.mom.common.core.util.R;
|
||||
import com.foreverwin.mom.common.log.annotation.SysLog;
|
||||
import com.foreverwin.mom.wms.entity.Document;
|
||||
import com.foreverwin.mom.wms.entity.DocumentDetailed;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -44,8 +45,8 @@ public class RegisterDocumentController {
|
||||
@ApiOperation(value = "采购登记-冲销", notes = "采购登记-冲销")
|
||||
@SysLog("采购登记-冲销")
|
||||
@PostMapping("/cancelDocumentNo")
|
||||
public R cancelDocumentNo(@RequestBody DocumentDetailed documentDetail) {
|
||||
registerDocumentService.cancelDocumentNo(documentDetail);
|
||||
public R cancelDocumentNo(@RequestBody Document document) {
|
||||
registerDocumentService.cancelDocumentNo(document);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@ -428,13 +428,13 @@ public class ShopOrderStatisticTransController {
|
||||
jsonObject.put("MEINS", completeTransaction.getMainUom()); // 基本计量单位
|
||||
jsonObject.put("ERFMG", completeTransaction.getSubQty()); // 以录入项单位表示的数量
|
||||
jsonObject.put("ERFME", completeTransaction.getSubUom()); // 录入单位
|
||||
jsonObject.put("MAT_KDAUF", ""); // 评估销售定单库存的销售定单号
|
||||
jsonObject.put("MAT_KDPOS", ""); // 评估销售订单库存的销售订单项目
|
||||
jsonObject.put("MAT_KDAUF", completeTransaction.getSoNo()); // 评估销售定单库存的销售定单号
|
||||
jsonObject.put("MAT_KDPOS", Integer.valueOf(completeTransaction.getSoLineNo())); // 评估销售订单库存的销售订单项目
|
||||
jsonObject.put("UMWRK", ""); // 收货工厂/发货工厂
|
||||
jsonObject.put("UMLGO", ""); // 收货/发货库存地点
|
||||
jsonObject.put("UMCHA", ""); // 收货/发货批量
|
||||
jsonObject.put("RSNUM", completeTransaction.getSoNo()); // 预留/相关需求的编号
|
||||
jsonObject.put("RSPOS", completeTransaction.getSoLineNo()); // 预留 / 相关需求的项目编号
|
||||
jsonObject.put("RSNUM", ""); // 预留/相关需求的编号
|
||||
jsonObject.put("RSPOS", ""); // 预留 / 相关需求的项目编号
|
||||
jsonObject.put("Z_JH", completeTransaction.getLotNo()); // 卷号
|
||||
jsonObject.put("Z_CVN", completeTransaction.getExternalLot()); // 客户卷号
|
||||
jsonObject.put("Z_GRADE", completeTransaction.getQcGrade()); // 等级
|
||||
|
||||
@ -0,0 +1,106 @@
|
||||
package com.foreverwin.iep.integration.handler.def.sap;
|
||||
|
||||
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.entity.IntInData;
|
||||
import com.foreverwin.iep.integration.entity.IntInDataLog;
|
||||
import com.foreverwin.iep.integration.service.HandlerService;
|
||||
import com.foreverwin.iep.integration.service.IntInDataLogService;
|
||||
import com.foreverwin.iep.integration.service.IntInDataService;
|
||||
import com.foreverwin.iep.integration.utils.JS;
|
||||
import com.foreverwin.iep.integration.utils.Local;
|
||||
import com.foreverwin.mom.common.security.util.SecurityUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 交货单过账冲销
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Service("ZMM_MES_GOODMVT_REVERSE")
|
||||
public class GoodMvtReverseService implements HandlerService {
|
||||
|
||||
private final IntInDataService intInDataService;
|
||||
private final IntInDataLogService intInDataLogService;
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public InvokeResponse call(InvokeRequest invokeRequest) {
|
||||
String reqId = invokeRequest.getTransSid();
|
||||
InvokeResponse invokeResponse = new InvokeResponse(invokeRequest);
|
||||
String errorMsg = "成功";
|
||||
String status = "S";
|
||||
try {
|
||||
// 处理响应
|
||||
invokeResponse = SapUtil.sendSap(invokeRequest.getMessageContent());
|
||||
invokeResponse.setTransSid(invokeRequest.getTransSid());
|
||||
invokeResponse.setTransTime(Local.now());
|
||||
if (!"E".equals(invokeResponse.getResult())) {
|
||||
invokeResponse.setResult("S");
|
||||
// 请求处理成功
|
||||
JSONObject jsonObject = invokeResponse.getObjectResponse();
|
||||
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
|
||||
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
|
||||
String result = outJson.getString("MSGTY");
|
||||
status = !"S".equals(result) ? "E" : result;
|
||||
String message = outJson.getString("MSGTX");
|
||||
invokeResponse.setMessageContent(StringUtils.isEmpty(message) ? "成功" : message);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
status = "E";
|
||||
errorMsg = e.getMessage();
|
||||
} finally {
|
||||
invokeResponse.setResult(status);
|
||||
if (StringUtils.isEmpty(invokeResponse.getMessageContent())) {
|
||||
invokeResponse.setMessageContent(errorMsg);
|
||||
}
|
||||
invokeResponse.setTransTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
invokeResponse.setTransSid(reqId);
|
||||
saveLogData(invokeRequest, invokeResponse);
|
||||
}
|
||||
return invokeResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String validation(InvokeRequest invokeRequest) {
|
||||
JSONObject jsonObject = JS.parseObject(invokeRequest.getMessageContent());
|
||||
return null;
|
||||
}
|
||||
|
||||
private void saveLogData(InvokeRequest invokeRequest, InvokeResponse invokeResponse) {
|
||||
if (StringUtils.isNotEmpty(invokeRequest.getTransSid())) {
|
||||
// 存储日志
|
||||
IntInData intInData = new IntInData();
|
||||
intInData.setSid(invokeRequest.getTransSid());
|
||||
intInData.setRequest(invokeRequest.getMessageContent());
|
||||
intInData.setFunctionName(invokeRequest.getMessageId());
|
||||
intInData.setKeyValue(invokeRequest.getKeyValue());
|
||||
intInData.setFromSystem(invokeRequest.getFromSystem());
|
||||
intInData.setToSystem(invokeRequest.getToSystem());
|
||||
intInData.setRetryCount(0);
|
||||
intInData.setSite(invokeRequest.getSite());
|
||||
intInData.setCreator(SecurityUtils.getUserName());
|
||||
intInData.setDateCreate(LocalDateTime.now());
|
||||
intInDataService.save(intInData);
|
||||
IntInDataLog log = new IntInDataLog();
|
||||
log.setSid(UUID.randomUUID().toString());
|
||||
log.setIntInDataSid(intInData.getSid());
|
||||
log.setCreator(SecurityUtils.getUserName());
|
||||
log.setDateCreate(LocalDateTime.now());
|
||||
log.setSeq(0);
|
||||
log.setMessage(StringUtils.isEmpty(invokeResponse.getMessageContent()) ? "N/A" : invokeResponse.getMessageContent());
|
||||
log.setResponse(invokeResponse.getObjectResponse().toJSONString());
|
||||
log.setState(invokeResponse.getResult());
|
||||
intInDataLogService.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.foreverwin.iep.integration.service;
|
||||
|
||||
import com.foreverwin.iep.integration.domain.InvokeResponse;
|
||||
import com.foreverwin.mom.wms.entity.Document;
|
||||
import com.foreverwin.mom.wms.entity.DocumentDetailed;
|
||||
|
||||
import java.util.List;
|
||||
@ -9,7 +10,7 @@ public interface RegisterDocumentService {
|
||||
|
||||
InvokeResponse createDocumentAndCallErp(List<DocumentDetailed> zwDocumentDetailList);
|
||||
|
||||
void cancelDocumentNo(DocumentDetailed documentDetailed);
|
||||
void cancelDocumentNo(Document document);
|
||||
|
||||
String getSapBatchNo(String erpItem);
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.foreverwin.iep.integration.domain.InvokeRequest;
|
||||
import com.foreverwin.iep.integration.domain.InvokeResponse;
|
||||
import com.foreverwin.iep.integration.handler.def.sap.GoodMvtReverseService;
|
||||
import com.foreverwin.iep.integration.handler.def.sap.MaterialConsumptionService;
|
||||
import com.foreverwin.iep.integration.handler.def.sap.SapUtil;
|
||||
import com.foreverwin.iep.integration.handler.def.sap.ZmmMesChargCreate1Service;
|
||||
@ -19,8 +20,10 @@ 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.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;
|
||||
@ -49,6 +52,10 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
@Qualifier("ZMM_MES_CHARG_CREATE1") // 通过 Bean 名称注入
|
||||
private ZmmMesChargCreate1Service zmmMesChargCreate1Service;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("ZMM_MES_GOODMVT_REVERSE") // 通过 Bean 名称注入
|
||||
private GoodMvtReverseService goodMvtReverseService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public InvokeResponse createDocumentAndCallErp(List<DocumentDetailed> zwDocumentDetailList) {
|
||||
@ -133,11 +140,8 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
invokeRequest.setKeyValue(srcPo);
|
||||
invokeRequest.setRetry(false);
|
||||
|
||||
// 暂时注释不调用SAP
|
||||
remotePoService.saveDocumentData(newDocumentList).getData();
|
||||
|
||||
// 呼叫SAP
|
||||
/*invokeResponse = materialConsumptionService.call(invokeRequest);
|
||||
invokeResponse = materialConsumptionService.call(invokeRequest);
|
||||
|
||||
if ("S".equals(invokeResponse.getResult())) {
|
||||
// 调用远程服务进行单据的保存和记录库存
|
||||
@ -145,7 +149,7 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
documentDetail.setMaterialDocument(invokeResponse.getMessageContent());
|
||||
}
|
||||
remotePoService.saveDocumentData(newDocumentList).getData();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
invokeResponse.setResult("E");
|
||||
@ -158,16 +162,6 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
return invokeResponse;
|
||||
}
|
||||
|
||||
// 冲销
|
||||
@Override
|
||||
@Transactional
|
||||
public void cancelDocumentNo(DocumentDetailed documentDetailed) {
|
||||
String documentNo = documentDetailed.getDocumentNo();
|
||||
String site = TenantContextHolder.getTenantId();
|
||||
remotePoService.cancelDocumentNo(documentDetailed);
|
||||
// @TODO 呼叫SAP
|
||||
}
|
||||
|
||||
private Item findItemCurrentRevision(String itemNo, String site) {
|
||||
QueryWrapper<Item> queryWrapper = new QueryWrapper<Item>();
|
||||
queryWrapper.lambda().eq(Item::getItem, itemNo).eq(Item::getSite, site).eq(Item::getCurrentRevision, "Y");
|
||||
@ -311,4 +305,59 @@ public class RegisterDocumentServiceImpl implements RegisterDocumentService {
|
||||
return jsonObject.toJSONString();
|
||||
}
|
||||
|
||||
|
||||
// 冲销
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
public void cancelDocumentNo(Document document) {
|
||||
// 呼叫SAP
|
||||
String site = TenantContextHolder.getTenantId();
|
||||
String materialDocument = document.getMaterialDocument();
|
||||
if (StringUtils.isEmpty(materialDocument)) {
|
||||
throw BusinessException.build("单据的物料凭证号为空");
|
||||
}
|
||||
remotePoService.cancelDocumentNo(document);
|
||||
// 传送SAP
|
||||
InvokeResponse invokeResponse = assembleCancelBody(site, materialDocument, document.getPostingDate());
|
||||
// 处理MES中自己的逻辑
|
||||
if (!"S".equals(invokeResponse.getResult())) {
|
||||
throw BusinessException.build("SAP错误:" + invokeResponse.getMessageContent());
|
||||
}
|
||||
}
|
||||
|
||||
private InvokeResponse assembleCancelBody(String site, String mblnr, String postDate) {
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
// 呼叫ERP获取批次号
|
||||
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_GOODMVT_REVERSE");
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("RFC_FUNCTION", "ZMM_MES_GOODMVT_REVERSE");
|
||||
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 inputJson = new JSONObject();
|
||||
inputJson.put("MBLNR", mblnr); // 物料凭证编号
|
||||
inputJson.put("BUDAT", postDate); // 凭证中的过账日期
|
||||
inputJson.put("ZPARTNER", SecurityUtils.getUserName()); // 员工BP编号
|
||||
bodyRe.put("IS_INPUT", inputJson);
|
||||
jsonObject.put("REQUEST_BODY", bodyRe);
|
||||
|
||||
// 组装抛送的报完呢
|
||||
String jsonObjectStr = SapUtil.appendHead(jsonObject.toJSONString());
|
||||
invokeRequest.setMessageContent(jsonObjectStr);
|
||||
invokeRequest.setStart(nowTime);
|
||||
invokeRequest.setKeyValue(mblnr);
|
||||
invokeRequest.setRetry(false);
|
||||
return goodMvtReverseService.call(invokeRequest);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user