增加SAP帐期关闭传输结果为W的处理逻辑
This commit is contained in:
parent
d01ad92679
commit
f2110a0b54
@ -7,9 +7,7 @@ import com.foreverwin.mom.common.core.util.R;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
@ -51,9 +49,10 @@ public class IntInDataController {
|
||||
return R.ok(intInDataService.distinctFromSystem(intInDataDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "方法名称-開窗", notes = "方法名称-開窗")
|
||||
@GetMapping("/distinct/toSystem")
|
||||
public R selectByToSystem(IntInDataDTO intInDataDTO) {
|
||||
return R.ok(intInDataService.distinctToSystem(intInDataDTO));
|
||||
|
||||
@ApiOperation(value = "交货单过账", notes = "交货单过账")
|
||||
@PostMapping("/tempSendSapAction")
|
||||
public R tempSendSapAction(@RequestBody String postType) {
|
||||
return R.ok(intInDataService.tempSendSapAction(postType));
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ public class Fssm0081Service implements HandlerService {
|
||||
InvokeResponse invokeResponse = new InvokeResponse(invokeRequest);
|
||||
String errorMsg = "成功";
|
||||
String status = "S";
|
||||
String result = "";
|
||||
try {
|
||||
// 处理响应
|
||||
invokeResponse = SapUtil.sendSap(invokeRequest.getMessageContent());
|
||||
@ -43,8 +44,9 @@ public class Fssm0081Service implements HandlerService {
|
||||
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;
|
||||
result = outJson.getString("MSGTY");
|
||||
// 临时方案,SAP返回W当作成功处理
|
||||
status = "S".equals(result) || SapUtil.W_STATUS.equals(result) ? "S" : "E";
|
||||
String message = outJson.getString("MSGTX");
|
||||
invokeResponse.setMessageContent(StringUtils.isEmpty(message) ? "成功" : message);
|
||||
}
|
||||
@ -58,7 +60,7 @@ public class Fssm0081Service implements HandlerService {
|
||||
}
|
||||
invokeResponse.setTransTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
invokeResponse.setTransSid(reqId);
|
||||
intInDataService.saveLogData(invokeRequest, invokeResponse);
|
||||
intInDataService.saveLogData(invokeRequest, invokeResponse, result);
|
||||
}
|
||||
return invokeResponse;
|
||||
}
|
||||
|
||||
@ -34,6 +34,7 @@ public class GoodMvtCreateService implements HandlerService {
|
||||
String errorMsg = "成功";
|
||||
String status = "S";
|
||||
String mblnr = "";
|
||||
String result = "";
|
||||
try {
|
||||
// 处理响应
|
||||
invokeResponse = SapUtil.sendSap(invokeRequest.getMessageContent());
|
||||
@ -45,8 +46,9 @@ public class GoodMvtCreateService implements HandlerService {
|
||||
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;
|
||||
result = outJson.getString("MSGTY");
|
||||
// 临时方案,SAP返回W当作成功处理
|
||||
status = "S".equals(result) || SapUtil.W_STATUS.equals(result) ? "S" : "E";
|
||||
String message = outJson.getString("MSGTX");
|
||||
invokeResponse.setMessageContent(StringUtils.isEmpty(message) ? "成功" : message);
|
||||
mblnr = outJson.getString("MBLNR");
|
||||
@ -61,7 +63,7 @@ public class GoodMvtCreateService implements HandlerService {
|
||||
}
|
||||
invokeResponse.setTransTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
invokeResponse.setTransSid(reqId);
|
||||
intInDataService.saveLogData(invokeRequest, invokeResponse);
|
||||
intInDataService.saveLogData(invokeRequest, invokeResponse,result);
|
||||
// 返回物料凭证号
|
||||
if ("S".equals(invokeResponse.getResult())) {
|
||||
invokeResponse.setMessageContent(mblnr);
|
||||
|
||||
@ -54,6 +54,9 @@ public class SapUtil {
|
||||
private static final String EsbUploadFileServerUrl = "https://agw.esb.nit.pub/oss/upload";
|
||||
private static final String EsbGetFileServerUrl = "https://agw.esb.nit.pub/oss/file";
|
||||
|
||||
// 临时SAP关闭帐期,接口返回 W
|
||||
public static final String W_STATUS = "W";
|
||||
|
||||
|
||||
public static String appendHead(String jsonStr) {
|
||||
JSONObject allJson = new JSONObject();
|
||||
|
||||
@ -6,6 +6,8 @@ import com.foreverwin.iep.common.base.FrontPage;
|
||||
import com.foreverwin.iep.integration.dto.IntInDataLogDTO;
|
||||
import com.foreverwin.iep.integration.entity.IntInDataLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 整合交易接收资料历程
|
||||
*
|
||||
@ -15,4 +17,6 @@ import com.foreverwin.iep.integration.entity.IntInDataLog;
|
||||
public interface IntInDataLogService extends IService<IntInDataLog> {
|
||||
|
||||
IPage<IntInDataLogDTO> search(FrontPage page, IntInDataLogDTO dto);
|
||||
|
||||
List<IntInDataLogDTO> searchWData(String site, String functionName);
|
||||
}
|
||||
|
||||
@ -28,5 +28,9 @@ public interface IntInDataService extends IService<IntInData> {
|
||||
|
||||
void retry(String sid);
|
||||
|
||||
void saveLogData(InvokeRequest invokeRequest, InvokeResponse invokeResponse, String srcStatus);
|
||||
|
||||
void saveLogData(InvokeRequest invokeRequest, InvokeResponse invokeResponse);
|
||||
|
||||
String tempSendSapAction(String postType);
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@ import com.foreverwin.iep.integration.service.IntInDataLogService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 整合交易接收资料历程
|
||||
*
|
||||
@ -25,4 +27,9 @@ public class IntInDataLogServiceImpl extends ServiceImpl<IntInDataLogMapper, Int
|
||||
|
||||
return super.baseMapper.search(page, dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IntInDataLogDTO> searchWData(String site, String functionName) {
|
||||
return super.baseMapper.searchWData(site, functionName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.foreverwin.iep.integration.service.impl;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.foreverwin.iep.common.base.FrontPage;
|
||||
@ -8,13 +9,16 @@ 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.dto.IntInDataDTO;
|
||||
import com.foreverwin.iep.integration.dto.IntInDataLogDTO;
|
||||
import com.foreverwin.iep.integration.entity.IntInData;
|
||||
import com.foreverwin.iep.integration.entity.IntInDataLog;
|
||||
import com.foreverwin.iep.integration.handler.def.sap.SapUtil;
|
||||
import com.foreverwin.iep.integration.mapper.IntInDataMapper;
|
||||
import com.foreverwin.iep.integration.service.IntInDataLogService;
|
||||
import com.foreverwin.iep.integration.service.IntInDataService;
|
||||
import com.foreverwin.iep.integration.service.InvokeService;
|
||||
import com.foreverwin.iep.integration.utils.Local;
|
||||
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;
|
||||
@ -35,6 +39,7 @@ import java.util.UUID;
|
||||
public class IntInDataServiceImpl extends ServiceImpl<IntInDataMapper, IntInData> implements IntInDataService {
|
||||
|
||||
private final IntInDataLogService intInDataLogService;
|
||||
|
||||
@Override
|
||||
public IPage<IntInDataDTO> search(FrontPage page, IntInDataDTO dto) {
|
||||
dto.setSite(TenantContextHolder.getTenantId());
|
||||
@ -80,6 +85,12 @@ public class IntInDataServiceImpl extends ServiceImpl<IntInDataMapper, IntInData
|
||||
invokeService.invoke(invokeRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveLogData(InvokeRequest invokeRequest, InvokeResponse invokeResponse, String srcStatus) {
|
||||
invokeResponse.setResult(srcStatus);
|
||||
saveLogData(invokeRequest, invokeResponse);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveLogData(InvokeRequest invokeRequest, InvokeResponse invokeResponse) {
|
||||
@ -93,12 +104,12 @@ public class IntInDataServiceImpl extends ServiceImpl<IntInDataMapper, IntInData
|
||||
intInData.setKeyValue(invokeRequest.getKeyValue());
|
||||
intInData.setFromSystem(invokeRequest.getFromSystem());
|
||||
intInData.setToSystem(invokeRequest.getToSystem());
|
||||
if(invokeRequest.isRetry()){
|
||||
intInData.setRetryCount(invokeRequest.getRetryCount()+1);
|
||||
if (invokeRequest.isRetry()) {
|
||||
intInData.setRetryCount(invokeRequest.getRetryCount() + 1);
|
||||
intInData.setCreator(invokeRequest.getCreator());
|
||||
intInData.setDateCreate(invokeRequest.getDateCreate());
|
||||
super.updateById(intInData);
|
||||
}else{
|
||||
} else {
|
||||
intInData.setRetryCount(0);
|
||||
intInData.setCreator(SecurityUtils.getUserName());
|
||||
intInData.setDateCreate(LocalDateTime.now());
|
||||
@ -116,4 +127,49 @@ public class IntInDataServiceImpl extends ServiceImpl<IntInDataMapper, IntInData
|
||||
intInDataLogService.save(log);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tempSendSapAction(String postType) {
|
||||
// 1:交货单过账、2:非交货单过账
|
||||
String messageId = "1".equals(postType)?"ZMM_MES_DELIVERY_UPDATE":"ZMM_MES_GOODSMVT_CREATE";
|
||||
String site = TenantContextHolder.getTenantId();
|
||||
List<IntInDataLogDTO> dataLogDTOS = intInDataLogService.searchWData(site, messageId);
|
||||
if(dataLogDTOS!=null && dataLogDTOS.size()<1){
|
||||
throw BusinessException.build(messageId+" 接口未检索到帐期关闭的数据");
|
||||
}else{
|
||||
Integer countSize = dataLogDTOS.size();
|
||||
InvokeResponse invokeResponse = new InvokeResponse();
|
||||
for (int i = 0; i < countSize; i++) {
|
||||
IntInDataLogDTO dataLogDTO = dataLogDTOS.get(i);
|
||||
String logId = dataLogDTO.getSid();
|
||||
String requestBody = dataLogDTO.getRequest();
|
||||
// 处理响应
|
||||
invokeResponse = SapUtil.sendSap(requestBody);
|
||||
if (!"E".equals(invokeResponse.getResult())) {
|
||||
// 请求处理成功
|
||||
JSONObject jsonObject = invokeResponse.getObjectResponse();
|
||||
JSONObject bodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
|
||||
JSONObject outJson = bodyJson.getJSONObject("ES_OUTPUT");
|
||||
String result = outJson.getString("MSGTY");
|
||||
String message = outJson.getString("MSGTX");
|
||||
if("S".equals(result)){
|
||||
// 更新状态
|
||||
IntInDataLog log = intInDataLogService.getById(logId);
|
||||
log.setState("S");
|
||||
log.setResponse(jsonObject.toJSONString());
|
||||
intInDataLogService.updateById(log);
|
||||
}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);
|
||||
}
|
||||
}else{
|
||||
throw BusinessException.build(messageId+" SAP处理失败");
|
||||
}
|
||||
}
|
||||
return "成功处理【"+countSize+"】笔数据";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,8 @@ import com.foreverwin.iep.integration.entity.IntInDataLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 整合交易接收资料历程
|
||||
*
|
||||
@ -19,4 +21,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
public interface IntInDataLogMapper extends BaseMapper<IntInDataLog> {
|
||||
|
||||
IPage<IntInDataLogDTO> search(FrontPage page, @Param("dto") IntInDataLogDTO dto);
|
||||
|
||||
List<IntInDataLogDTO> searchWData(@Param("site") String site, @Param("functionName") String functionName);
|
||||
}
|
||||
|
||||
@ -31,4 +31,15 @@
|
||||
</where>
|
||||
order by A.SEQ DESC
|
||||
</select>
|
||||
|
||||
<select id="searchWData" resultMap="fullMap">
|
||||
select iidl.SID,iidl.INT_IN_DATA_SID,iidl.RESPONSE,iidl.SEQ,iidl.STATE ,iid.REQUEST
|
||||
from wip.int_in_data_log iidl
|
||||
left join wip.int_in_data iid on iid.SID = iidl.INT_IN_DATA_SID
|
||||
where iid.SITE = #{site}
|
||||
and iid.FUNCTION_NAME = #{functionName}
|
||||
and iidl.STATE = 'W'
|
||||
order by iid.DATE_CREATE asc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user