feat(存储仓库库存大于0同步sap):新增job
This commit is contained in:
parent
4bb39b94ec
commit
870cd01d18
@ -2,17 +2,12 @@ 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.foreverwin.iep.integration.component.Invoke;
|
||||
import com.foreverwin.iep.integration.constant.Msg;
|
||||
import com.foreverwin.iep.integration.domain.InvokeRequest;
|
||||
import com.foreverwin.iep.integration.handler.def.sap.SapUtil;
|
||||
import com.foreverwin.iep.integration.utils.JS;
|
||||
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
|
||||
import com.foreverwin.mom.wms.api.feign.RemoteWmsInventoryService;
|
||||
import com.foreverwin.mom.wms.entity.ZWmsInventoryStockHisItf;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
@ -21,11 +16,10 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 发送库存数据到sap存表JOB
|
||||
* 发送库存数据到sapJOB
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
@ -33,8 +27,6 @@ public class SapSendInventoryForWorkJob {
|
||||
|
||||
private final Invoke invoke;
|
||||
|
||||
private final RemoteWmsInventoryService remoteWmsInventoryService;
|
||||
|
||||
@XxlJob("sapSendInventoryForWorkJobHandler")
|
||||
public ReturnT<String> sapSendInventoryForWorkJobHandler() {
|
||||
// 传参对象
|
||||
@ -63,43 +55,8 @@ public class SapSendInventoryForWorkJob {
|
||||
jsonBody.put("MESSAGE_ID", "SAP_SEND_INVENTORY");
|
||||
jsonBody.put("RECEIVER", Msg.ERP);
|
||||
jsonBody.put("RETRY", false);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("RFC_FUNCTION", "ZMM_MES_GET_STOCK_HIS");
|
||||
JSONObject conTextJsonObject = new JSONObject();
|
||||
conTextJsonObject.put("EXCHANGE_SYSTEM", "MES");
|
||||
conTextJsonObject.put("EXCHANGE_ID", uuid);
|
||||
conTextJsonObject.put("EXCHANGE_DOC", "");
|
||||
jsonObject.put("REQUEST_CONTEXT", conTextJsonObject);
|
||||
JSONObject bodyJsonObject = new JSONObject();
|
||||
JSONArray inputJsonArray = new JSONArray();
|
||||
List<ZWmsInventoryStockHisItf> zWmsInventoryStockHisItfList = remoteWmsInventoryService.readZWmsInventoryStockHisItfList(site).getData();
|
||||
if (CollectionUtils.isNotEmpty(zWmsInventoryStockHisItfList)) {
|
||||
for (ZWmsInventoryStockHisItf zWmsInventoryStockHisItf : zWmsInventoryStockHisItfList) {
|
||||
JSONObject inputJsonObject = new JSONObject();
|
||||
inputJsonObject.put("ZUUID", "");
|
||||
inputJsonObject.put("Z_TM", zWmsInventoryStockHisItf.getZTm());
|
||||
inputJsonObject.put("ZDATE", zWmsInventoryStockHisItf.getZdate());
|
||||
inputJsonObject.put("ZTIME", zWmsInventoryStockHisItf.getZtime());
|
||||
inputJsonObject.put("MATNR", zWmsInventoryStockHisItf.getMatnr());
|
||||
inputJsonObject.put("WERKS", zWmsInventoryStockHisItf.getWerks());
|
||||
inputJsonObject.put("LGORT", zWmsInventoryStockHisItf.getLgort());
|
||||
inputJsonObject.put("CHARG", zWmsInventoryStockHisItf.getCharg());
|
||||
inputJsonObject.put("SOBKZ", zWmsInventoryStockHisItf.getSobkz());
|
||||
inputJsonObject.put("VBELN", zWmsInventoryStockHisItf.getVbeln());
|
||||
inputJsonObject.put("POSNR", zWmsInventoryStockHisItf.getPosnr());
|
||||
inputJsonObject.put("KUNNR", zWmsInventoryStockHisItf.getKunnr());
|
||||
inputJsonObject.put("LIFNR", zWmsInventoryStockHisItf.getLifnr());
|
||||
inputJsonObject.put("Z_TP", zWmsInventoryStockHisItf.getZTp());
|
||||
inputJsonObject.put("Z_KC", zWmsInventoryStockHisItf.getZKc());
|
||||
inputJsonArray.add(inputJsonObject);
|
||||
}
|
||||
}
|
||||
bodyJsonObject.put("IT_INPUT", inputJsonArray);
|
||||
jsonObject.put("REQUEST_BODY", bodyJsonObject);
|
||||
|
||||
// messageContent内容
|
||||
JSONObject messageContentJson = SapUtil.appendHead(jsonObject);
|
||||
JSONObject messageContentJson = new JSONObject();
|
||||
jsonBody.put("MESSAGE_CONTENT", messageContentJson);
|
||||
}
|
||||
TenantContextHolder.setTenantId(site);
|
||||
|
||||
@ -2,15 +2,22 @@ package com.foreverwin.iep.integration.handler.def.sap;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.foreverwin.iep.integration.constant.Msg;
|
||||
import com.foreverwin.iep.integration.domain.InvokeRequest;
|
||||
import com.foreverwin.iep.integration.domain.InvokeResponse;
|
||||
import com.foreverwin.iep.integration.service.HandlerService;
|
||||
import com.foreverwin.iep.integration.utils.JS;
|
||||
import com.foreverwin.mom.common.core.constant.SecurityConstants;
|
||||
import com.foreverwin.mom.wms.api.feign.RemoteWmsInventoryService;
|
||||
import com.foreverwin.mom.wms.entity.ZWmsInventoryStockHisItf;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 发送库存数据到sap
|
||||
*/
|
||||
@ -18,22 +25,59 @@ import org.springframework.stereotype.Service;
|
||||
@Service("SAP_SEND_INVENTORY")
|
||||
public class SapSendInventory implements HandlerService {
|
||||
|
||||
private final RemoteWmsInventoryService remoteWmsInventoryService;
|
||||
|
||||
@Override
|
||||
public InvokeResponse call(InvokeRequest invokeRequest) {
|
||||
JSONObject messageContentjsonObject = JS.parseObject(invokeRequest.getMessageContent());
|
||||
String jsonInputString = messageContentjsonObject.get(Msg.MESSAGE_CONTENT).toString(); // JSON 格式的请求数据
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("RFC_FUNCTION", "ZMM_MES_GET_STOCK_HIS");
|
||||
JSONObject conTextJsonObject = new JSONObject();
|
||||
conTextJsonObject.put("EXCHANGE_SYSTEM", "MES");
|
||||
conTextJsonObject.put("EXCHANGE_ID", invokeRequest.getTransSid());
|
||||
conTextJsonObject.put("EXCHANGE_DOC", "");
|
||||
jsonObject.put("REQUEST_CONTEXT", conTextJsonObject);
|
||||
JSONObject bodyJsonObject = new JSONObject();
|
||||
JSONArray inputJsonArray = new JSONArray();
|
||||
List<ZWmsInventoryStockHisItf> zWmsInventoryStockHisItfList = remoteWmsInventoryService.readZWmsInventoryStockHisItfList(invokeRequest.getSite(), SecurityConstants.FROM_IN).getData();
|
||||
if (CollectionUtils.isNotEmpty(zWmsInventoryStockHisItfList)) {
|
||||
for (ZWmsInventoryStockHisItf zWmsInventoryStockHisItf : zWmsInventoryStockHisItfList) {
|
||||
JSONObject inputJsonObject = new JSONObject();
|
||||
inputJsonObject.put("ZUUID", "");
|
||||
inputJsonObject.put("Z_TM", zWmsInventoryStockHisItf.getZTm());
|
||||
inputJsonObject.put("ZDATE", zWmsInventoryStockHisItf.getZdate());
|
||||
inputJsonObject.put("ZTIME", zWmsInventoryStockHisItf.getZtime());
|
||||
inputJsonObject.put("MATNR", zWmsInventoryStockHisItf.getMatnr());
|
||||
inputJsonObject.put("WERKS", zWmsInventoryStockHisItf.getWerks());
|
||||
inputJsonObject.put("LGORT", zWmsInventoryStockHisItf.getLgort());
|
||||
inputJsonObject.put("CHARG", zWmsInventoryStockHisItf.getCharg());
|
||||
inputJsonObject.put("SOBKZ", zWmsInventoryStockHisItf.getSobkz());
|
||||
inputJsonObject.put("VBELN", zWmsInventoryStockHisItf.getVbeln());
|
||||
inputJsonObject.put("POSNR", zWmsInventoryStockHisItf.getPosnr());
|
||||
inputJsonObject.put("KUNNR", zWmsInventoryStockHisItf.getKunnr());
|
||||
inputJsonObject.put("LIFNR", zWmsInventoryStockHisItf.getLifnr());
|
||||
inputJsonObject.put("Z_TP", zWmsInventoryStockHisItf.getZTp());
|
||||
inputJsonObject.put("Z_KC", zWmsInventoryStockHisItf.getZKc());
|
||||
inputJsonArray.add(inputJsonObject);
|
||||
}
|
||||
}
|
||||
bodyJsonObject.put("IT_INPUT", inputJsonArray);
|
||||
jsonObject.put("REQUEST_BODY", bodyJsonObject);
|
||||
|
||||
// messageContent内容
|
||||
JSONObject messageContentJson = SapUtil.appendHead(jsonObject);
|
||||
String jsonInputString = messageContentJson.toString(); // JSON 格式的请求数据
|
||||
|
||||
try {
|
||||
// 统一调用 SAP 接口
|
||||
InvokeResponse invokeResponse = SapUtil.sendSap(jsonInputString);
|
||||
if(!Msg.E.equals(invokeResponse.getResult())){
|
||||
// 请求处理成功
|
||||
JSONObject jsonObject = JS.parseObject(invokeResponse.getMessageContent());
|
||||
JSONObject reJsonObject = JS.parseObject(invokeResponse.getMessageContent());
|
||||
invokeResponse = new InvokeResponse();
|
||||
invokeResponse.setTransSid(invokeRequest.getTransSid());
|
||||
invokeResponse.setResult(Msg.S);
|
||||
invokeResponse.setMessageContent(Msg.SUCCESS);
|
||||
JSONObject responseContextJson = jsonObject.getJSONObject("RESPONSE_CONTEXT");
|
||||
JSONObject responseContextJson = reJsonObject.getJSONObject("RESPONSE_CONTEXT");
|
||||
if (ObjectUtil.isNotEmpty(responseContextJson)) {
|
||||
if (StrUtil.isNotBlank(responseContextJson.getString("RFC_CODE")) && !"200".equals(responseContextJson.getString("RFC_CODE"))) {
|
||||
invokeResponse.setResult(Msg.E);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user