Merge remote-tracking branch 'mesnac/master'

master
Leon 3 years ago
commit bee1bda939

@ -41,6 +41,16 @@ public class IntegrationLogDto {
*/
private String param;
private String handle;
public String getHandle() {
return handle;
}
public void setHandle(String handle) {
this.handle = handle;
}
public String getIntegrationType() {
return integrationType;
}

@ -3,6 +3,7 @@
<mapper namespace="com.foreverwin.mesnac.anomaly.mapper.ReportMapper">
<resultMap id="IntegrationLogDto" type="com.foreverwin.mesnac.anomaly.dto.IntegrationLogDto">
<result column="HANDLE" property="handle"/>
<result column="INTEGRATION_TYPE" property="integrationType"/>
<result column="CATEGORY" property="category"/>
<result column="STATUS" property="status"/>
@ -11,7 +12,7 @@
<result column="PARAM" property="param"/>
</resultMap>
<select id="findIntegrationLog" resultMap="IntegrationLogDto">
SELECT INTEGRATION_TYPE, CATEGORY, INTEGRATION_WAY,STATUS,
SELECT HANDLE,INTEGRATION_TYPE, CATEGORY, INTEGRATION_WAY,STATUS,
REQUEST_DATE_TIME,RESULT_MESSAGE RESULT_MESSAGE,PARAM PARAM
FROM Z_INTEGRATION_LOG
<where>

@ -490,8 +490,6 @@ public class ZprodordconfStruIn implements java.io.Serializable {
", ism04=" + ism04 +
", ism05=" + ism05 +
", ism06=" + ism06 +
", __equalsCalc=" + __equalsCalc +
", __hashCodeCalc=" + __hashCodeCalc +
'}';
}
}

@ -1,10 +1,13 @@
package com.foreverwin.mesnac.integration.controller;
import com.foreverwin.mesnac.integration.model.IntegrationLog;
import com.foreverwin.mesnac.integration.service.IntegrationLogService;
import com.foreverwin.modular.core.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
*
@ -16,6 +19,14 @@ import org.springframework.web.bind.annotation.RestController;
public class IntegrationLogController {
@Autowired
private IntegrationLogService integrationLogService;
@ResponseBody
@PostMapping("redoSend")
public R shopOrderRelease(@RequestBody List<IntegrationLog> integrationLogs) {
for (IntegrationLog integrationLog: integrationLogs) {
integrationLogService.redoSend(integrationLog.getHandle());
}
return R.ok();
}
}

@ -15,4 +15,6 @@ public interface IntegrationLogService extends IService<IntegrationLog> {
void saveIntegrationLog(IntegrationLog integrationLog);
void redoSend(String handle);
}

@ -1,14 +1,25 @@
package com.foreverwin.mesnac.integration.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mesnac.common.erp.ZprodordconfStruIn;
import com.foreverwin.mesnac.common.erp.ZprodordconfStruOut;
import com.foreverwin.mesnac.common.erp.holders.TableOfZprodordconfStruInHolder;
import com.foreverwin.mesnac.common.erp.holders.TableOfZprodordconfStruOutHolder;
import com.foreverwin.mesnac.common.util.ERPAPI;
import com.foreverwin.mesnac.integration.mapper.IntegrationLogMapper;
import com.foreverwin.mesnac.integration.model.IntegrationLog;
import com.foreverwin.mesnac.integration.service.IntegrationLogService;
import com.foreverwin.modular.core.exception.BaseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.rmi.RemoteException;
import java.time.LocalDateTime;
/**
* <p>
*
@ -31,5 +42,42 @@ public class IntegrationLogServiceImpl extends ServiceImpl<IntegrationLogMapper,
integrationLogMapper.insert(integrationLog);
}
@Override
public void redoSend(String handle) {
IntegrationLog byId = getById(handle);
if (byId==null||!byId.getStatus().equals("R")){
throw new BaseException("状态已变更,请刷新");
}
String param = byId.getParam();
JSONObject jsonObject = JSONObject.parseObject(param);
ZprodordconfStruIn struIn = JSON.toJavaObject(jsonObject, ZprodordconfStruIn.class);
ZprodordconfStruIn[] ins = new ZprodordconfStruIn[1];
ins[0] = struIn;
TableOfZprodordconfStruInHolder inHolder = new TableOfZprodordconfStruInHolder(ins);
ZprodordconfStruOut[] outs = new ZprodordconfStruOut[1];
ZprodordconfStruOut struOut = new ZprodordconfStruOut();
struOut.setAufnr(ins[0].getAufnr());
struOut.setVornr(ins[0].getVornr());
struOut.setAueru("1");
struOut.setLmnga(ins[0].getLmnga());
struOut.setRet("");
struOut.setMsg("");
outs[0] = struOut;
TableOfZprodordconfStruOutHolder outHolder = new TableOfZprodordconfStruOutHolder(outs);
try {
ERPAPI.erpWebService().zmesProdordconf(inHolder, outHolder);
String status = outHolder.value[1].getRet();
String message = outHolder.value[1].getMsg();
if (!status.equals("S")) {
throw new BaseException("ERP接口返回错误消息:" + message);
}
byId.setRequestDateTime(LocalDateTime.now());
updateById(byId);
} catch (RemoteException e) {
throw new BaseException("ERP接口错误: " + e.getMessage());
}
}
}

@ -1,5 +1,6 @@
package com.foreverwin.mesnac.production.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -43,6 +44,7 @@ import com.sap.me.production.AssembleComponentsRequest;
import com.sap.me.production.AssemblyComponent;
import com.sap.me.production.AssemblyDataField;
import com.sap.me.production.AssemblyServiceInterface;
import org.apache.axis.AxisFault;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.i18n.LocaleContextHolder;
@ -51,7 +53,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.rmi.RemoteException;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.*;
@ -486,6 +487,7 @@ public class PodTemplateServiceImpl implements PodTemplateService {
struOut.setMsg("");
outs[0] = struOut;
TableOfZprodordconfStruOutHolder outHolder = new TableOfZprodordconfStruOutHolder(outs);
IntegrationLog log = new IntegrationLog();
//调用WS
try {
@ -498,20 +500,25 @@ public class PodTemplateServiceImpl implements PodTemplateService {
if (!status.equals("S")) {
throw new BaseException("ERP接口返回错误消息:" + message);
}
} catch (RemoteException e) {
throw new BaseException("ERP接口错误: " + e.getMessage());
log.setStatus(status);
log.setResultMessage(message);
} catch (Exception e) {
log.setStatus("E");
log.setResultMessage("ERP接口错误: " + e.getMessage());
String faultString = ((AxisFault) e).getFaultString();
if (StringUtil.isBlank(faultString)||!faultString.equals("(401)Unauthorized")){
throw new BaseException("ERP接口错误: " + e.getMessage());
}
log.setStatus("R");
} finally {
//记录接口日志
IntegrationLog log = new IntegrationLog();
log.setHandle(UUID.randomUUID().toString());
log.setSite(CommonMethods.getSite());
log.setIntegrationType(IntegrationTypeConstant.REPORT_ORDER);
log.setCategory("REQUEST");
log.setIntegrationWay("ERP");
log.setIntegrationMethod("erpWebService.zmesProdordconf");
log.setParam(Arrays.toString(ins));
log.setStatus("");
log.setResultMessage(Arrays.toString(outHolder.value));
log.setParam(JSONObject.toJSONString(struIn));
log.setTransactionId("");
log.setRequestDateTime(LocalDateTime.now());
log.setCreatedDateTime(LocalDateTime.now());

Loading…
Cancel
Save