sap联调

highway
zhaoxiaolin 1 year ago
parent 9bb46f6a5e
commit 28145447cb

@ -1,11 +0,0 @@
#for test only!
#Tue Oct 17 09:57:19 CST 2023
jco.destination.pool_capacity=true
jco.client.lang=zh
jco.client.ashost=192.168.0.53
jco.client.saprouter=
jco.client.user=MES
jco.client.sysnr=0
jco.destination.peak_limit=20
jco.client.passwd=123456
jco.client.client=800

@ -1,114 +0,0 @@
**** Error file opened at 20230724 105509 China Standard Time Rel. 3.0.17 (2017-07-17) [721.913]
Error: >Mon Jul 24 10:55:09,173< RfcException:
message: Connect to SAP gateway failed
Connection parameters: TYPE=A DEST=ABAP_AS_WITH_POOL ASHOST=192.168.0.53 SYSNR=00 PCS=1
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner '192.168.0.53:3300' not reached
TIME Mon Jul 24 10:55:09 2023
RELEASE 721
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE nixxi.cpp
LINE 3289
DETAIL NiPConnect2: 192.168.0.53:3300
SYSTEM CALL connect
ERRNO 10060
ERRNO TEXT WSAETIMEDOUT: Connection timed out
COUNTER 2
return code: RFC_FAILURE (1)
error group: 102
key: RFC_ERROR_COMMUNICATION
Error: >Mon Jul 24 10:55:30,220< RfcException:
message: Connect to SAP gateway failed
Connection parameters: TYPE=A DEST=ABAP_AS_WITH_POOL ASHOST=192.168.0.53 SYSNR=00 PCS=1
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner '192.168.0.53:3300' not reached
TIME Mon Jul 24 10:55:30 2023
RELEASE 721
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE nixxi.cpp
LINE 3289
DETAIL NiPConnect2: 192.168.0.53:3300
SYSTEM CALL connect
ERRNO 10060
ERRNO TEXT WSAETIMEDOUT: Connection timed out
COUNTER 4
return code: RFC_FAILURE (1)
error group: 102
key: RFC_ERROR_COMMUNICATION
**** Error file opened at 20230725 103104 China Standard Time Rel. 3.0.17 (2017-07-17) [721.913]
Error: >Tue Jul 25 10:31:04,628< RfcException:
message: Connect to SAP gateway failed
Connection parameters: TYPE=A DEST=ABAP_AS_WITH_POOL ASHOST=192.168.0.53 SYSNR=00 PCS=1
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner '192.168.0.53:3300' not reached
TIME Tue Jul 25 10:31:04 2023
RELEASE 721
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE nixxi.cpp
LINE 3289
DETAIL NiPConnect2: 192.168.0.53:3300
SYSTEM CALL connect
ERRNO 10060
ERRNO TEXT WSAETIMEDOUT: Connection timed out
COUNTER 2
return code: RFC_FAILURE (1)
error group: 102
key: RFC_ERROR_COMMUNICATION
Error: >Tue Jul 25 10:31:25,675< RfcException:
message: Connect to SAP gateway failed
Connection parameters: TYPE=A DEST=ABAP_AS_WITH_POOL ASHOST=192.168.0.53 SYSNR=00 PCS=1
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner '192.168.0.53:3300' not reached
TIME Tue Jul 25 10:31:25 2023
RELEASE 721
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE nixxi.cpp
LINE 3289
DETAIL NiPConnect2: 192.168.0.53:3300
SYSTEM CALL connect
ERRNO 10060
ERRNO TEXT WSAETIMEDOUT: Connection timed out
COUNTER 4
return code: RFC_FAILURE (1)
error group: 102
key: RFC_ERROR_COMMUNICATION
**** Error file opened at 20230816 113444 China Standard Time Rel. 3.0.17 (2017-07-17) [721.913]
Error: >Wed Aug 16 11:34:44,064< >RfcGetException rc (7) message: Invalid value in OPTION field of value table for IN itab operator. operator.
<RfcGetException
**** Error file opened at 20230816 174253 China Standard Time Rel. 3.0.17 (2017-07-17) [721.913]
Error: >Wed Aug 16 17:42:53,538< >RfcGetException rc (7) message: Invalid value in OPTION field of value table for IN itab operator. operator.
<RfcGetException
**** Error file opened at 20230816 174447 China Standard Time Rel. 3.0.17 (2017-07-17) [721.913]
Error: >Wed Aug 16 17:44:47,079< >RfcGetException rc (7) message: Invalid value in OPTION field of value table for IN itab operator. operator.
<RfcGetException

@ -0,0 +1,90 @@
package com.op.system.api.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
/**
*
*
* @author OP
*/
public class SysSapLog {
private String id;
private String messsge;
private Date createTime;
private String reqcode;
private String method;
private String remark;
private String status;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getMesssge() {
return messsge;
}
public void setMesssge(String messsge) {
this.messsge = messsge;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getReqcode() {
return reqcode;
}
public void setReqcode(String reqcode) {
this.reqcode = reqcode;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("messsge", getMesssge())
.append("createTime", getCreateTime())
.append("reqcode", getReqcode())
.append("method", getMethod())
.append("remark", getRemark())
.append("status", getStatus())
.toString();
}
}

@ -1,5 +1,8 @@
package com.op.system.api.domain.sap;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
public class SapShopOrderQuery {
// S_AUFNR订单号 S_MATNR物料号 S_ERDAT(创建日期)
@ -39,4 +42,12 @@ public class SapShopOrderQuery {
public void setErdat(String erdat) {
this.erdat = erdat;
}
@Override
public String toString() {
return "{aufnr:"+":"+getAufnr()+","+
"matnr"+":"+getMatnr()+","+
"erdat"+":"+getErdat()+","+
"erdat"+":"+getWerk()+"}";
}
}

@ -9,6 +9,7 @@ import com.op.plan.domain.ProOrder;
import com.op.plan.domain.ProShift;
import com.op.plan.domain.*;
import com.op.plan.domain.vo.CascaderDTO;
import com.op.system.api.domain.SysSapLog;
import com.op.system.api.model.SapProOrder;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
@ -220,4 +221,6 @@ public interface ProOrderMapper {
* @param orderCode
*/
void updateOrderStatusCompleteByOrderCode(String orderCode);
void addSapLog(SysSapLog sysSapLog);
}

@ -27,6 +27,7 @@ import com.op.plan.domain.dto.SplitOrderDTO;
import com.op.plan.mapper.*;
import com.op.system.api.RemoteSapService;
import com.op.system.api.RemoteUserService;
import com.op.system.api.domain.SysSapLog;
import com.op.system.api.domain.SysUser;
import com.op.system.api.domain.sap.SapShopOrderQuery;
import com.op.system.api.model.SapProOrder;
@ -422,26 +423,35 @@ public class ProOrderServiceImpl implements IProOrderService {
SapShopOrderQuery sapqo = new SapShopOrderQuery();
// sapqo.setCreateTime(DateUtils.addDays(DateUtils.getNowDate(),-4));
// //获取当前所选工厂
// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
// String key = "#header.poolName";
// sapqo.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_",""));
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
sapqo.setWerk(request.getHeader(key.substring(8)).replace("ds_",""));
SapProOrder maxCreateTime = proOrderMapper.getMaxCreatetime();
if(maxCreateTime == null ){
sapqo.setErdat(DateFormatUtils.format(new Date(), "yyyyMMdd"));//S_ERDAT(创建日期) 例如20230923
}else{
sapqo.setErdat(maxCreateTime.getCreateTimeStr());//S_ERDAT(创建日期) 例如20230923
}
//添加调用sap日志
SysSapLog sysSapLog = new SysSapLog();
sysSapLog.setId(IdUtils.fastSimpleUUID());
sysSapLog.setMesssge(sapqo.toString());
sysSapLog.setMethod("syncSAP");
sysSapLog.setReqcode("返回");
sysSapLog.setCreateTime(DateUtils.getNowDate());
proOrderMapper.addSapLog(sysSapLog);
//取>=20230923的sap数据
R<List<SapProOrder>> rSapProOrder = remoteSapService.shopOrderSync(sapqo);//sap只能同步指定日期的数据
if(rSapProOrder == null){
return AjaxResult.error("无"+sapqo.getErdat()+"之后的最新订单");
}
List<SapProOrder> newOrders = rSapProOrder.getData();
syncSAPFunc(newOrders,SecurityUtils.getUsername());
if(CollectionUtils.isEmpty(newOrders)){
System.out.println("无"+sapqo.getErdat()+"之后的最新订单");
}else {
syncSAPFunc(newOrders, "Job");
}
return success();
}
@ -703,12 +713,22 @@ public class ProOrderServiceImpl implements IProOrderService {
sapqo.setErdat(maxCreateTime.getCreateTimeStr());//S_ERDAT(创建日期) 例如20230923
}
//添加调用sap日志
SysSapLog sysSapLog = new SysSapLog();
sysSapLog.setId(IdUtils.fastSimpleUUID());
sysSapLog.setMesssge(sapqo.toString());
sysSapLog.setMethod("shopOrderSync");
sysSapLog.setReqcode("请求");
sysSapLog.setCreateTime(DateUtils.getNowDate());
proOrderMapper.addSapLog(sysSapLog);
R<List<SapProOrder>> rSapProOrder = remoteSapService.shopOrderSync(sapqo);
List<SapProOrder> newOrders = rSapProOrder.getData();
if(CollectionUtils.isEmpty(newOrders)){
logger.error("无"+sapqo.getErdat()+"之后的最新订单");
System.out.println("无"+sapqo.getErdat()+"之后的最新订单");
}else {
syncSAPFunc(newOrders, "Job");
}
syncSAPFunc(newOrders,"Job");
}
/**

@ -17,6 +17,7 @@ import com.op.plan.domain.vo.CascaderDTO;
import com.op.plan.mapper.*;
import com.op.plan.service.IProOrderWorkorderService;
import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.SysSapLog;
import com.op.system.api.domain.dto.MesPrepareDTO;
import com.op.system.api.domain.dto.MesPrepareDetailDTO;
import com.op.system.api.domain.sap.SapCreateOrder;
@ -264,6 +265,16 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
sap.setDates(DateUtils.parseDateToStr("yyyy-MM-dd", whiteOrder.getProductDate()));//开始时间
sap.setDatee(DateUtils.parseDateToStr("yyyy-MM-dd", whiteOrder.getProductDate()));//完成时间
sapList.add(sap);
//添加调用sap日志
SysSapLog sysSapLog = new SysSapLog();
sysSapLog.setId(IdUtils.fastSimpleUUID());
sysSapLog.setMesssge(StringUtils.join(sapList,","));
sysSapLog.setMethod("downProOrderWorkorderByWorkorderIds");
sysSapLog.setReqcode("请求");
sysSapLog.setCreateTime(DateUtils.getNowDate());
proOrderMapper.addSapLog(sysSapLog);
R<List<String>> r = remoteSapService.SapCreateOrder(sapList);
logger.info("sap工单回传" + r.getMsg());
if (500 == r.getCode()) {

@ -256,6 +256,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GETDATE(),
</trim>
</insert>
<insert id="addSapLog">
insert into sys_sap_log
(id,messsge,create_time,reqcode,method,remark,status)
values(
#{id},#{messsge}, #{createTime}, #{reqcode},#{method},#{remark},#{status})
</insert>
<update id="updateProOrder" parameterType="ProOrder">
update pro_order

@ -16,6 +16,7 @@ import com.op.system.api.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.quality.service.IQcCheckTaskIncomeService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@ -99,12 +100,6 @@ public class QcCheckTaskIncomeServiceImpl implements IQcCheckTaskIncomeService {
qcCheckTaskIncome.setCheckNo(bpDD+liushuiStr);
/**qc_check_task_income**/
String beLongId = IdUtils.fastSimpleUUID();
qcCheckTaskIncome.setRecordId(beLongId);
qcCheckTaskIncome.setFactoryCode(factoryCode);
qcCheckTaskIncome.setCreateTime(nowDate);
qcCheckTaskIncomeMapper.insertQcCheckTaskIncome(qcCheckTaskIncome);
/**取检测项**/
QcCheckTypeProject qctp= new QcCheckTypeProject();
@ -127,6 +122,13 @@ public class QcCheckTaskIncomeServiceImpl implements IQcCheckTaskIncomeService {
return 0;//没有找到检测项目
}
/**qc_check_task**/
String beLongId = IdUtils.fastSimpleUUID();
qcCheckTaskIncome.setRecordId(beLongId);
qcCheckTaskIncome.setFactoryCode(factoryCode);
qcCheckTaskIncome.setCreateTime(nowDate);
qcCheckTaskIncomeMapper.insertQcCheckTaskIncome(qcCheckTaskIncome);
/**qc_check_task_detail**/
for(QcCheckTaskDetail item:items){
item.setRecordId(IdUtils.fastSimpleUUID());
item.setBelongTo(beLongId);

@ -99,13 +99,6 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
qcCheckTaskProduce.setCheckNo(bpDD+liushuiStr);
/**qc_check_task_produce**/
String beLongId = IdUtils.fastSimpleUUID();
qcCheckTaskProduce.setRecordId(beLongId);
qcCheckTaskProduce.setFactoryCode(factoryCode);
qcCheckTaskProduce.setCreateTime(nowDate);
qcCheckTaskProduceMapper.insertQcCheckTaskProduce(qcCheckTaskProduce);
/**取检测项**/
QcCheckTypeProject qctp= new QcCheckTypeProject();
qctp.setTypeId(qcCheckTaskProduce.getCheckType());//生产过程检验
@ -127,6 +120,13 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
return 0;//没有找到检测项目
}
/**qc_check_task**/
String beLongId = IdUtils.fastSimpleUUID();
qcCheckTaskProduce.setRecordId(beLongId);
qcCheckTaskProduce.setFactoryCode(factoryCode);
qcCheckTaskProduce.setCreateTime(nowDate);
qcCheckTaskProduceMapper.insertQcCheckTaskProduce(qcCheckTaskProduce);
/**qc_check_task_detail**/
for(QcCheckTaskDetail item:items){
item.setRecordId(IdUtils.fastSimpleUUID());
item.setBelongTo(beLongId);

@ -100,13 +100,6 @@ public class QcCheckTaskWarehousingServiceImpl implements IQcCheckTaskWarehousin
qcCheckTaskWarehousing.setCheckNo(bpDD+liushuiStr);
/**qc_check_task_warehousing**/
String beLongId = IdUtils.fastSimpleUUID();
qcCheckTaskWarehousing.setRecordId(beLongId);
qcCheckTaskWarehousing.setFactoryCode(factoryCode);
qcCheckTaskWarehousing.setCreateTime(nowDate);
qcCheckTaskWarehousingMapper.insertQcCheckTaskWarehousing(qcCheckTaskWarehousing);
/**取检测项**/
QcCheckTypeProject qctp= new QcCheckTypeProject();
qctp.setTypeId(qcCheckTaskWarehousing.getCheckType());//生产过程检验
@ -128,6 +121,13 @@ public class QcCheckTaskWarehousingServiceImpl implements IQcCheckTaskWarehousin
return 0;//没有找到检测项目
}
/**qc_check_task**/
String beLongId = IdUtils.fastSimpleUUID();
qcCheckTaskWarehousing.setRecordId(beLongId);
qcCheckTaskWarehousing.setFactoryCode(factoryCode);
qcCheckTaskWarehousing.setCreateTime(nowDate);
qcCheckTaskWarehousingMapper.insertQcCheckTaskWarehousing(qcCheckTaskWarehousing);
/**qc_check_task_detail**/
for(QcCheckTaskDetail item:items){
item.setRecordId(IdUtils.fastSimpleUUID());
item.setBelongTo(beLongId);

@ -47,7 +47,7 @@ public class SapOrderServiceImpl implements SapOrderService {
// S_WERKS(工厂) S_AUFNR订单号 S_MATNR物料号 S_ERDAT(创建日期) 例如20230923
if (!StringUtils.isNull(sapShopOrderQuery.getWerk())){
JCoTable S_WERKS = func.getTableParameterList().getTable("S_WERKS");
JCoTable S_WERKS = func.getTableParameterList().getTable("S_PWERK");
S_WERKS.appendRow();
S_WERKS.setValue(Constants.SIGN, "I");
S_WERKS.setValue(Constants.OPTION, "EQ");

@ -63,8 +63,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from pro_route_product pp
where pp.route_id = #{routeId}
)
<if test="itemName != null and itemName != ''"> and bp.product_desc_zh like concat('%', #{itemName}, '%')</if>
<if test="itemName != null and itemName != ''"> and (bp.product_desc_zh like concat('%', #{itemName}, '%')
or bp.product_code like concat('%', #{itemName}, '%'))</if>
</select>
<!-- <select id="getRouteProdProductListDo" resultType="com.op.technology.domain.ProRouteProduct">-->
@ -81,7 +81,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from pro_route_product pp
left join base_product bp on pp.item_code = bp.product_code
where pp.route_id = #{routeId}
<if test="itemName != null and itemName != ''"> and bp.product_desc_zh like concat('%', #{itemName}, '%')</if>
<if test="itemName != null and itemName != ''"> and (bp.product_desc_zh like concat('%', #{itemName}, '%')
or bp.product_code like concat('%', #{itemName}, '%'))</if>
</select>
<insert id="insertProRouteProduct" parameterType="ProRouteProduct">

Loading…
Cancel
Save