Merge remote-tracking branch 'origin/master'

highway
wws 12 months ago
commit b4a2f41311

@ -1,15 +1,14 @@
package com.op.system.api.domain.dto;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
/**
* mes_prepare
* mes_prepareDTO
*
* @author Open Platform
* @date 2023-08-03
@ -23,6 +22,7 @@ public class MesPrepareDTO extends BaseEntity {
/** 工单编码 */
@Excel(name = "工单编码")
private String workorderCode;
private String workorderCodeSap;
/** 工单名称 */
@Excel(name = "工单名称")
@ -120,6 +120,25 @@ public class MesPrepareDTO extends BaseEntity {
/** 工厂编码 */
@Excel(name = "工厂编码")
private String factoryCode;
private String dayStr;
public String getWorkorderCodeSap() {
return workorderCodeSap;
}
public void setWorkorderCodeSap(String workorderCodeSap) {
this.workorderCodeSap = workorderCodeSap;
}
public String getDayStr() {
return dayStr;
}
public void setDayStr(String dayStr) {
this.dayStr = dayStr;
}
public String getMaterialCode() {
return materialCode;
}
@ -305,37 +324,37 @@ public class MesPrepareDTO extends BaseEntity {
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("prepareId", getPrepareId())
.append("workorderCode", getWorkorderCode())
.append("workorderName", getWorkorderName())
.append("parentOrder", getParentOrder())
.append("orderId", getOrderId())
.append("orderCode", getOrderCode())
.append("productId", getProductId())
.append("productCode", getProductCode())
.append("prodType", getProdType())
.append("productName", getProductName())
.append("productSpc", getProductSpc())
.append("wetDetailPlanId", getWetDetailPlanId())
.append("productDate", getProductDate())
.append("shiftId", getShiftId())
.append("ancestors", getAncestors())
.append("status", getStatus())
.append("remark", getRemark())
.append("attr1", getAttr1())
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("attr4", getAttr4())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("factoryCode", getFactoryCode())
.append("materialCode", getMaterialCode())
.append("materialName", getMaterialName())
.append("materialSpc", getMaterialSpc())
.append("quantity", getQuantity())
.append("unit", getUnit())
.toString();
.append("prepareId", getPrepareId())
.append("workorderCode", getWorkorderCode())
.append("workorderName", getWorkorderName())
.append("parentOrder", getParentOrder())
.append("orderId", getOrderId())
.append("orderCode", getOrderCode())
.append("productId", getProductId())
.append("productCode", getProductCode())
.append("prodType", getProdType())
.append("productName", getProductName())
.append("productSpc", getProductSpc())
.append("wetDetailPlanId", getWetDetailPlanId())
.append("productDate", getProductDate())
.append("shiftId", getShiftId())
.append("ancestors", getAncestors())
.append("status", getStatus())
.append("remark", getRemark())
.append("attr1", getAttr1())
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("attr4", getAttr4())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("factoryCode", getFactoryCode())
.append("materialCode", getMaterialCode())
.append("materialName", getMaterialName())
.append("materialSpc", getMaterialSpc())
.append("quantity", getQuantity())
.append("unit", getUnit())
.toString();
}
}

@ -1,12 +1,11 @@
package com.op.system.api.domain.dto;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
/**
* mes mes_prepare_detail
@ -42,7 +41,9 @@ public class MesPrepareDetailDTO extends BaseEntity {
/** 生产数量 */
@Excel(name = "生产数量")
private Long quantity;
private String quantity;
private String fundQuanlity;
/** 工单生产日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@ -76,11 +77,57 @@ public class MesPrepareDetailDTO extends BaseEntity {
/** 产品类型 */
@Excel(name = "产品类型")
private String prodType;
/** 库位 */
private String locator;
private String needDate;
private String recoil;
private String buyFlag;
public String getBuyFlag() {
return buyFlag;
}
public void setBuyFlag(String buyFlag) {
this.buyFlag = buyFlag;
}
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String factoryCode;
public String getRecoil() {
return recoil;
}
public void setRecoil(String recoil) {
this.recoil = recoil;
}
public String getFundQuanlity() {
return fundQuanlity;
}
public void setFundQuanlity(String fundQuanlity) {
this.fundQuanlity = fundQuanlity;
}
public String getNeedDate() {
return needDate;
}
public void setNeedDate(String needDate) {
this.needDate = needDate;
}
public String getLocator() {
return locator;
}
public void setLocator(String locator) {
this.locator = locator;
}
public void setRecordId(String recordId) {
this.recordId = recordId;
}
@ -123,11 +170,11 @@ public class MesPrepareDetailDTO extends BaseEntity {
public String getUnit() {
return unit;
}
public void setQuantity(Long quantity) {
public void setQuantity(String quantity) {
this.quantity = quantity;
}
public Long getQuantity() {
public String getQuantity() {
return quantity;
}
public void setProductDate(Date productDate) {
@ -197,27 +244,27 @@ public class MesPrepareDetailDTO extends BaseEntity {
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("recordId", getRecordId())
.append("prepareId", getPrepareId())
.append("materialCode", getMaterialCode())
.append("materailName", getMaterailName())
.append("materailSpc", getMaterailSpc())
.append("unit", getUnit())
.append("quantity", getQuantity())
.append("productDate", getProductDate())
.append("shiftId", getShiftId())
.append("status", getStatus())
.append("remark", getRemark())
.append("attr1", getAttr1())
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("attr4", getAttr4())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("prodType", getProdType())
.append("factoryCode", getFactoryCode())
.toString();
.append("recordId", getRecordId())
.append("prepareId", getPrepareId())
.append("materialCode", getMaterialCode())
.append("materailName", getMaterailName())
.append("materailSpc", getMaterailSpc())
.append("unit", getUnit())
.append("quantity", getQuantity())
.append("productDate", getProductDate())
.append("shiftId", getShiftId())
.append("status", getStatus())
.append("remark", getRemark())
.append("attr1", getAttr1())
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("attr4", getAttr4())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("prodType", getProdType())
.append("factoryCode", getFactoryCode())
.toString();
}
}

@ -53,7 +53,7 @@ public class RyTask {
remoteSapService.shopOrderSync(sapProOrder);
}
/**22
/**22
* 16
* 0 00 22 * * ?
*/

@ -60,6 +60,7 @@ public interface IMesPrepareService {
*/
public int deleteMesPrepareByPrepareId(String prepareId);
/**废弃**/
public R getMesPrepare();
public R reportWorkTask();

@ -140,9 +140,11 @@ public class MesPrepareServiceImpl implements IMesPrepareService {
new LinkedBlockingQueue<Runnable>());
try {
dateSources.forEach(dateSource -> {
logger.info("++++++++++++" + dateSource.get("poolName") + "++++开始++++++++++");
Runnable run = () -> getMesPrepareByFactory(dateSource.get("poolName"));
executorService.execute(run);
if(!"ds_999".equals(dateSource.get("poolName"))){
logger.info("++++++++++++" + dateSource.get("poolName") + "++++开始++++++++++");
Runnable run = () -> getMesPrepareByFactory(dateSource.get("poolName"));
executorService.execute(run);
}
});
} catch (Exception e) {
logger.error("service == deviceOfflineTimingTask == exception", e);
@ -156,67 +158,63 @@ public class MesPrepareServiceImpl implements IMesPrepareService {
}
public void getMesPrepareByFactory(String poolName) {
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
// List<SapMaterialPreparation> list = sapMaterialPreparationList.stream()
// .filter(a->a.getWERKS().equals(poolName))
// .collect(Collectors.toList());
//获取T+1天的所有母工单
MesPrepare qo = new MesPrepare();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, 1);//这里改为1
Date time = cal.getTime();
qo.setDayStr(new SimpleDateFormat("yyyy-MM-dd").format(time));
List<MesPrepare> parents = mesPrepareMapper.getParentWorkOrderT1(qo);
if (CollectionUtils.isEmpty(parents)) {
System.out.println("T+1无母工单数据");
}
for (MesPrepare mesPrepare : parents) {
List<SapMaterialPreparation> sapMaterialPreparationList = remoteSapService.materialPreparation(mesPrepare.getWorkorderCodeSap()).getData();
if (CollectionUtils.isEmpty(sapMaterialPreparationList)) {
System.out.println("sap无领料单数据");
}
//取出各领料单
Set<String> orderCodes = sapMaterialPreparationList.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toSet());
for (String orderCode : orderCodes) {
/**mes_prepare**/
String mesPrepareId = IdUtils.fastSimpleUUID();
MesPrepare mesPrepare0 = new MesPrepare();
mesPrepare0.setPrepareId(mesPrepareId);
mesPrepare0.setWorkorderCode(orderCode);//工单(子)
mesPrepare0.setCreateTime(DateUtils.getNowDate());
mesPrepare0.setCreateBy(SecurityUtils.getUsername());
mesPrepare0.setStatus("L0");//默认待确认
mesPrepareMapper.insertMesPrepare(mesPrepare0);
/**mes_prepare_detail**/
List<MesPrepareDetail> details = new ArrayList<>();
// List<SapMaterialPreparation> listdetails = list.stream()
// .filter(a->a.getAUFNR().equals(orderCode))
// .collect(Collectors.toList());
MesPrepareDetail detail = null;
Date createDate = DateUtils.getNowDate();
for (SapMaterialPreparation sap : sapMaterialPreparationList) {
detail = new MesPrepareDetail();
detail.setPrepareId(mesPrepareId);
detail.setRecordId(IdUtils.fastSimpleUUID());
detail.setAttr1(sap.getRSPOS());//预留/相关需求的项目编号
detail.setMaterialCode(sap.getMATNR());//物料号
detail.setMaterailName(sap.getMAKTX());//物料描述(短文本)
detail.setFactoryCode(sap.getWERKS());//工厂
detail.setLocator(sap.getLGORT());//库存地点
detail.setNeedDate(sap.getBDTER());//组件的需求日期
detail.setQuantity(sap.getBDMNG());////需求量
detail.setFundQuanlity(sap.getZQLSL());//欠料数量
detail.setUnit(sap.getMEINS());//基本计量单位
detail.setRecoil(sap.getRGEKZ());//反冲标识
detail.setBuyFlag(sap.getDBSKZ());//直接采购标识
detail.setCreateBy(SecurityUtils.getUsername());
detail.setCreateTime(createDate);
details.add(detail);
}
mesPrepareDetailMapper.insertMesPrepareDetails(details);
}
}
// DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
// //获取T+1天的所有母工单
// MesPrepare qo = new MesPrepare();
// Calendar cal = Calendar.getInstance();
// cal.add(Calendar.DATE, 1);//这里改为1
// Date time = cal.getTime();
// qo.setDayStr(new SimpleDateFormat("yyyy-MM-dd").format(time));
// List<MesPrepare> parents = mesPrepareMapper.getParentWorkOrderT1(qo);
// if (CollectionUtils.isEmpty(parents)) {
// System.out.println("T+1无母工单数据");
// }
// for (MesPrepare mesPrepare : parents) {
// List<SapMaterialPreparation> sapMaterialPreparationList = remoteSapService.materialPreparation(mesPrepare.getWorkorderCodeSap()).getData();
// if (CollectionUtils.isEmpty(sapMaterialPreparationList)) {
// System.out.println("sap无领料单数据");
// }
// //取出各领料单
// Set<String> orderCodes = sapMaterialPreparationList.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toSet());
// for (String orderCode : orderCodes) {
// /**mes_prepare**/
// String mesPrepareId = IdUtils.fastSimpleUUID();
// MesPrepare mesPrepare0 = new MesPrepare();
// mesPrepare0.setPrepareId(mesPrepareId);
// mesPrepare0.setWorkorderCode(orderCode);//工单(子)
// mesPrepare0.setCreateTime(DateUtils.getNowDate());
// mesPrepare0.setCreateBy(SecurityUtils.getUsername());
// mesPrepare0.setStatus("L0");//默认待确认
// mesPrepareMapper.insertMesPrepare(mesPrepare0);
// /**mes_prepare_detail**/
// List<MesPrepareDetail> details = new ArrayList<>();
//// List<SapMaterialPreparation> listdetails = list.stream()
//// .filter(a->a.getAUFNR().equals(orderCode))
//// .collect(Collectors.toList());
// MesPrepareDetail detail = null;
// Date createDate = DateUtils.getNowDate();
// for (SapMaterialPreparation sap : sapMaterialPreparationList) {
// detail = new MesPrepareDetail();
// detail.setPrepareId(mesPrepareId);
// detail.setRecordId(IdUtils.fastSimpleUUID());
// detail.setAttr1(sap.getRSPOS());//预留/相关需求的项目编号
// detail.setMaterialCode(sap.getMATNR());//物料号
// detail.setMaterailName(sap.getMAKTX());//物料描述(短文本)
// detail.setFactoryCode(sap.getWERKS());//工厂
// detail.setLocator(sap.getLGORT());//库存地点
// detail.setNeedDate(sap.getBDTER());//组件的需求日期
// detail.setQuantity(sap.getBDMNG());////需求量
// detail.setFundQuanlity(sap.getZQLSL());//欠料数量
// detail.setUnit(sap.getMEINS());//基本计量单位
// detail.setRecoil(sap.getRGEKZ());//反冲标识
// detail.setBuyFlag(sap.getDBSKZ());//直接采购标识
// detail.setCreateBy(SecurityUtils.getUsername());
// detail.setCreateTime(createDate);
// details.add(detail);
// }
// mesPrepareDetailMapper.insertMesPrepareDetails(details);
// }
// }
}

@ -100,7 +100,7 @@ public interface ProOrderWorkorderMapper {
ProOrderWorkorder selectWorkOrderByCode(String workorderCode);
/**下发生产订单**/
public int downProOrderWorkorderByWorkorderIds(String[] workorderIds);
public int downWorkorders(String[] workorderIds);
public List<ProOrderWorkorder> getWorkOrderByIds(String[] workorderIds);
@ -158,5 +158,13 @@ public interface ProOrderWorkorderMapper {
ProOrderWorkorder getWorkOrderByCode(String workorderCode);
void updateProOrderWorkorderM(ProOrderWorkorder proWorkOrder);
void insertMesPrepare(MesPrepareDTO mesPrepare0);
int insertMesPrepareDetails(@Param("list") List<MesPrepareDetailDTO> details);
int updateWhiteWorkOrder(ProOrderWorkorder whiteOrder);
ProOrderWorkorder getPWorkOrder(ProOrderWorkorder whiteOrder);
}

@ -2,6 +2,7 @@ package com.op.plan.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.context.SecurityContextHolder;
import com.op.common.core.domain.R;
import com.op.common.core.exception.ServiceException;
@ -21,7 +22,9 @@ 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;
import com.op.system.api.domain.sap.SapMaterialPreparation;
import net.bytebuddy.matcher.FilterableList;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -33,6 +36,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -219,8 +223,6 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
@DS("#header.poolName")
@Transactional(rollbackFor = Exception.class)
public int downProOrderWorkorderByWorkorderIds(String[] workorderIds) {
List<String> ids = new ArrayList<>();
List<ProOrder> psorders = new ArrayList<>();//父级工单
List<SapCreateOrder> sapList = null;//回传给sap的工单
//如果是白坯生成备料单
for (String workorderId : workorderIds) {
@ -256,11 +258,30 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
details.add(detail);
proOrderWorkorderMapper.createPrepareDetails(details);
ids.add(workorderId);
}else{
//无湿料计划,下发不了
}
} else if (whiteOrder != null && !"white".equals(whiteOrder.getProdType())) {//成品的母工单回传sap
whiteOrder.setUpdateBy(SecurityUtils.getUsername());
whiteOrder.setUpdateTime(DateUtils.getNowDate());
return proOrderWorkorderMapper.updateWhiteWorkOrder(whiteOrder);
} else if (whiteOrder != null && !"white".equals(whiteOrder.getProdType())) {
List<String> pcodes = new ArrayList<>();//一起下发用
List<String> wcodes = new ArrayList<>();//领料单用
//成品的母工单//查上一级工单
Boolean isTop = true;
while(isTop) {
pcodes.add(whiteOrder.getWorkorderId());
wcodes.add(whiteOrder.getWorkorderCode());
//查上一级工单
whiteOrder.setWorkorderCode(whiteOrder.getParentOrder());
ProOrderWorkorder pWorkOrder = proOrderWorkorderMapper.getPWorkOrder(whiteOrder);
if(pWorkOrder == null || "0".equals(pWorkOrder.getParentOrder())){
isTop = false;
}else{
BeanUtils.copyProperties(pWorkOrder,whiteOrder);
}
}
sapList = new ArrayList<>();
SapCreateOrder sap = new SapCreateOrder();
sap.setWerks(whiteOrder.getFactoryCode());//工厂编码
@ -274,7 +295,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
//添加调用sap日志
SysSapLog sysSapLog = new SysSapLog();
sysSapLog.setId(IdUtils.fastSimpleUUID());
sysSapLog.setMesssge(sapList.toString());
sysSapLog.setMesssge(Arrays.asList(sapList).toString());
sysSapLog.setMethod("downProOrderWorkorderByWorkorderIds");
sysSapLog.setReqcode("请求");
sysSapLog.setCreateTime(DateUtils.getNowDate());
@ -287,65 +308,31 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
return 0;
}
List<String> returnCodes = r.getData();
Date updateTime = DateUtils.getNowDate();
if (!CollectionUtils.isEmpty(returnCodes)) {
for (String sapCode : returnCodes) {
logger.info("sap工单回传sap虚拟工单号" + StringUtils.join(returnCodes, ","));
for (int m=0;m<returnCodes.size();m++) {
ProOrderWorkorder oworkSap = new ProOrderWorkorder();
oworkSap.setWorkorderCodeSap(sapCode);
oworkSap.setWorkorderId(workorderId);//工单编码
oworkSap.setUpdateTime(DateUtils.getNowDate());
oworkSap.setWorkorderCodeSap(returnCodes.get(m));
oworkSap.setWorkorderId(pcodes.get(returnCodes.size()-(m+1)));//工单编码
oworkSap.setUpdateTime(updateTime);
/**pro_order_workorder**/
proOrderWorkorderMapper.updateWorkOrderCodeSap(oworkSap);
ProOrder order = this.getTopOrder(workorderId);
ProOrderWorkorder oworkSapParent = new ProOrderWorkorder();
oworkSapParent.setWorkorderCodeSap(sapCode);
oworkSapParent.setWorkorderId(order.getOrderCode());//母工单编码
oworkSapParent.setUpdateTime(DateUtils.getNowDate());
proOrderWorkorderMapper.updateWorkOrderCodeSap(oworkSapParent);
logger.info("sap工单回传sap虚拟工单号" + sapCode);
}
}
//子查父工单,都要工单状态改下发
ProOrder pOrder = new ProOrder();
pOrder.setParentOrder(workorderId);
List<ProOrder> pordes = getListBySonCode(pOrder);
if(!CollectionUtils.isEmpty(pordes)){
psorders.addAll(pordes);
}
//获取领料单
Collections.reverse(wcodes);
this.getMesPrepare(returnCodes,wcodes);
ids.add(workorderId);
}
}
}
if(!CollectionUtils.isEmpty(ids)){
String[] idsArray = (String[])ids.toArray(new String[ids.size()]);
List<ProOrderWorkorder> workorders = proOrderWorkorderMapper.getWorkOrderByIds(idsArray);
for (ProOrderWorkorder workorder : workorders) {
//关联工艺
if (StringUtils.isNotBlank(workorder.getRouteCode())) {
List<ProWorkorderProcessDetail> workDetails = proWorkorderProcessDetailMapper.getWorkOrderDetailsByRouteCode(workorder);
if (!CollectionUtils.isEmpty(workDetails)) {
workDetails.forEach(str -> {
str.setRecordId(IdUtils.fastSimpleUUID());
str.setWorkorderId(workorder.getWorkorderId());
str.setStatus("s0");//未执行
str.setCreateBy(SecurityContextHolder.getUserName());
str.setCreateTime(DateUtils.getNowDate());
str.setFactoryCode(workorder.getFactoryCode());
});
proWorkorderProcessDetailMapper.addWorkOrderDetails(workDetails);
}
}
}
//下达工单
if(!CollectionUtils.isEmpty(psorders)){
List<String> pcodes = psorders.stream().map(e -> e.getOrderCode()).collect(Collectors.toList());
ids.addAll(pcodes);
//关闭订单//母订单的订单编码
R closeR= remoteSapService.sapCloseOrder(whiteOrder.getOrderCode());
logger.info("下发工单后关闭订单"+whiteOrder.getOrderCode()+":"+closeR.getMsg());
//下达工单
String[] idsArrayAll = (String[])pcodes.toArray(new String[pcodes.size()]);
return proOrderWorkorderMapper.downWorkorders(idsArrayAll);
}
String[] idsArrayAll = (String[])ids.toArray(new String[ids.size()]);
//下达工单
return proOrderWorkorderMapper.downProOrderWorkorderByWorkorderIds(idsArrayAll);
}
return 0;
}
@ -361,45 +348,73 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
return codeList;
}
// //获取最低级材料
// private void getLastChildren(List<BaseBomComponentDTO> all, List<BaseBomComponentDTO> allChildren , BaseBomComponentDTO bc) {
// List<BaseBomComponentDTO> cList = all.stream().filter(item -> item.getCumc().equals(bc.getComponent()))
// .collect(Collectors.toList());
// if(CollectionUtils.isEmpty(cList)){
// allChildren.add(bc);
// }else{
// for(BaseBomComponentDTO bcc : cList){
// getLastChildren(all, allChildren ,bcc);
// }
// }
// }
// //获取顶级定单的bom组成
// private List<BaseBomComponentDTO> getBomDtos(String workorderId){
// List<BaseBomComponentDTO> bomdtoAdds = new ArrayList<>();//所有数据
//
// List<BaseBomComponentDTO> cumsDtos = new ArrayList<>();
// BaseBomComponentDTO cumsDto = new BaseBomComponentDTO();
// ProOrder order = this.getTopOrder(workorderId);
// cumsDto.setCumc(order.getProdCode());
// cumsDtos.add(cumsDto);
// List<BaseBomComponentDTO> bomdtos = proOrderWorkorderMapper.getBomComponents(order,cumsDtos);//最新版本的第一层子
// bomdtoAdds.addAll(bomdtos);
// Boolean isTrue = true;
// while(isTrue){
// List<BaseBomComponentDTO> bomdtoTop = new ArrayList<>();
// bomdtos.forEach(e->e.setCumc(e.getComponent()));
// bomdtoTop.addAll(bomdtos);
// List<BaseBomComponentDTO> bomdtoSon = proOrderWorkorderMapper.getBomComponents(order,bomdtoTop);
// if(CollectionUtils.isEmpty(bomdtoSon)){
// isTrue = false;
// }else{
// bomdtos = bomdtoSon;
// bomdtoAdds.addAll(bomdtoSon);
// }
// }
//
// return bomdtos;
// }
public void getMesPrepare(List<String> sapWorkOrders,List<String> workOrders) {
for(String sapWorkOrder:sapWorkOrders){
logger.info("获取sap领料单" + sapWorkOrder+"开始");
// //添加调用sap日志
// SysSapLog sysSapLog = new SysSapLog();
// sysSapLog.setId(IdUtils.fastSimpleUUID());
// sysSapLog.setMesssge(sapWorkOrder);
// sysSapLog.setMethod("getMesPrepare");
// sysSapLog.setReqcode("请求");
// sysSapLog.setCreateTime(DateUtils.getNowDate());
// proOrderMapper.addSapLog(sysSapLog);
List<SapMaterialPreparation> sapMaterialPreparationList = remoteSapService.materialPreparation(sapWorkOrder).getData();
if (CollectionUtils.isEmpty(sapMaterialPreparationList)) {
System.out.println("sap无领料单数据");
}
//取出各领料单
List<String> orderCodes = sapMaterialPreparationList.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toList());
Date createDate = DateUtils.getNowDate();
for (int m = 0;m<orderCodes.size();m++) {
String orderCode = orderCodes.get(m);
logger.info("领料单内容:"+orderCode);
/**mes_prepare**/
String mesPrepareId = IdUtils.fastSimpleUUID();
MesPrepareDTO mesPrepare0 = new MesPrepareDTO();
mesPrepare0.setPrepareId(mesPrepareId);
mesPrepare0.setWorkorderCode(workOrders.get(m));
mesPrepare0.setWorkorderName(orderCode);//工单(子)
mesPrepare0.setCreateTime(createDate);
mesPrepare0.setCreateBy(SecurityUtils.getUsername());
mesPrepare0.setStatus("L0");//默认待确认
proOrderWorkorderMapper.insertMesPrepare(mesPrepare0);
/**mes_prepare_detail**/
List<MesPrepareDetailDTO> details = new ArrayList<>();
MesPrepareDetailDTO detail = null;
for (SapMaterialPreparation sap : sapMaterialPreparationList) {
detail = new MesPrepareDetailDTO();
detail.setPrepareId(mesPrepareId);
detail.setRecordId(IdUtils.fastSimpleUUID());
detail.setAttr1(sap.getRSPOS());//预留/相关需求的项目编号
detail.setMaterialCode(sap.getMATNR());//物料号
detail.setMaterailName(sap.getMAKTX());//物料描述(短文本)
detail.setFactoryCode(sap.getWERKS());//工厂
detail.setLocator(sap.getLGORT());//库存地点
detail.setNeedDate(sap.getBDTER());//组件的需求日期
detail.setQuantity(sap.getBDMNG());////需求量
detail.setFundQuanlity(sap.getZQLSL());//欠料数量
detail.setUnit(sap.getMEINS());//基本计量单位
detail.setRecoil(sap.getRGEKZ());//反冲标识
detail.setBuyFlag(sap.getDBSKZ());//直接采购标识
detail.setCreateBy(SecurityUtils.getUsername());
detail.setCreateTime(createDate);
details.add(detail);
logger.info("领料单内容detail"+sap.getRSPOS()+","+sap.getMATNR()+","+
sap.getMAKTX()+","+sap.getWERKS()+","+ sap.getLGORT()+","+
sap.getBDTER()+","+sap.getBDMNG()+","+sap.getZQLSL()+","+
sap.getMEINS()+","+sap.getRGEKZ()+","+sap.getDBSKZ()
);
}
proOrderWorkorderMapper.insertMesPrepareDetails(details);
logger.info("获取sap领料单" + sapWorkOrder+"结束");
}
}
}
//根据工单子单编码获取最顶级订单的母单
private ProOrder getTopOrder(String workorderId) {
//pro_order_workorder

@ -360,6 +360,14 @@
from pro_order_workorder
where workorder_code = #{workorderCode} and del_flag = '0'
</select>
<select id="getPWorkOrder" resultMap="ProOrderWorkorderResult">
select workorder_id, workorder_code, order_id, order_code,
product_code, product_name, product_date, parent_order,
quantity_split,unit,prod_type, factory_code
from pro_order_workorder
where workorder_code = #{workorderCode}
and del_flag = '0'
</select>
<insert id="createPrepareDetails">
insert into mes_prepare_detail
@ -376,6 +384,90 @@
)
</foreach>
</insert>
<insert id="insertMesPrepare">
insert into mes_prepare
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="prepareId != null">prepare_id,</if>
<if test="workorderCode != null and workorderCode != ''">workorder_code,</if>
<if test="workorderName != null">workorder_name,</if>
<if test="parentOrder != null and parentOrder != ''">parent_order,</if>
<if test="orderId != null and orderId != ''">order_id,</if>
<if test="orderCode != null">order_code,</if>
<if test="productId != null">product_id,</if>
<if test="productCode != null and productCode != ''">product_code,</if>
<if test="prodType != null">prod_type,</if>
<if test="productName != null and productName != ''">product_name,</if>
<if test="productSpc != null">product_spc,</if>
<if test="wetDetailPlanId != null">wet_detail_plan_id,</if>
<if test="productDate != null">product_date,</if>
<if test="shiftId != null">shift_id,</if>
<if test="ancestors != null">ancestors,</if>
<if test="status != null">status,</if>
<if test="remark != null">remark,</if>
<if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="attr4 != null">attr4,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="factoryCode != null">factory_code,</if>
<if test="materialCode != null and materialCode != ''">material_code,</if>
<if test="materialName != null and materialName != ''">material_name,</if>
<if test="materialSpc != null">material_spc,</if>
<if test="unit != null and unit != ''">unit,</if>
<if test="quantity != null">quantity,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="prepareId != null">#{prepareId},</if>
<if test="workorderCode != null and workorderCode != ''">#{workorderCode},</if>
<if test="workorderName != null">#{workorderName},</if>
<if test="parentOrder != null and parentOrder != ''">#{parentOrder},</if>
<if test="orderId != null and orderId != ''">#{orderId},</if>
<if test="orderCode != null">#{orderCode},</if>
<if test="productId != null">#{productId},</if>
<if test="productCode != null and productCode != ''">#{productCode},</if>
<if test="prodType != null">#{prodType},</if>
<if test="productName != null and productName != ''">#{productName},</if>
<if test="productSpc != null">#{productSpc},</if>
<if test="wetDetailPlanId != null">#{wetDetailPlanId},</if>
<if test="productDate != null">#{productDate},</if>
<if test="shiftId != null">#{shiftId},</if>
<if test="ancestors != null">#{ancestors},</if>
<if test="status != null">#{status},</if>
<if test="remark != null">#{remark},</if>
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="attr4 != null">#{attr4},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="factoryCode != null">#{factoryCode},</if>
<if test="materialCode != null and materialCode != ''">#{materialCode},</if>
<if test="materialName != null and materialName != ''">#{materialName},</if>
<if test="materialSpc != null">#{materialSpc},</if>
<if test="unit != null and unit != ''">#{unit},</if>
<if test="quantity != null">#{quantity},</if>
</trim>
</insert>
<insert id="insertMesPrepareDetails">
INSERT INTO mes_prepare_detail (
record_id,prepare_id,material_code,material_name,unit,
quantity,create_by,create_time,factory_code,status,
locator,need_date,recoil,fund_quanlity,buy_flag
)VALUES
<foreach collection="list" item="d" index="index" separator=",">
(
#{d.recordId},#{d.prepareId},#{d.materialCode},#{d.materailName},#{d.unit},
#{d.quantity},#{d.createBy},#{d.createTime},#{d.factoryCode},#{d.status},
#{d.locator},#{d.needDate},#{d.recoil},#{d.fundQuanlity},#{d.buyFlag}
)
</foreach>
</insert>
<update id="updateProOrderWorkorder" parameterType="ProOrderWorkorder">
update pro_order_workorder
@ -415,12 +507,12 @@
where workorder_id = #{workorderId}
</update>
<!--工单下发-->
<update id="downProOrderWorkorderByWorkorderIds">
<update id="downWorkorders">
update pro_order_workorder
set status = 'w1'
where workorder_code in
<foreach item="workorderCode" collection="array" open="(" separator="," close=")">
#{workorderCode}
where workorder_id in
<foreach item="workorderId" collection="array" open="(" separator="," close=")">
#{workorderId}
</foreach>
and del_flag = '0'
</update>
@ -440,6 +532,11 @@
</trim>
where workorder_id = #{workorderId}
</update>
<update id="updateWhiteWorkOrder">
update pro_order_workorder
set status = 'w1'
where workorder_id = #{workorderId}
</update>
<delete id="deleteProOrderWorkorderByWorkorderId" parameterType="String">
update pro_order_workorder

@ -67,7 +67,6 @@ public class DestinationManager {
properties.store(fos, "for test only!");
} catch (Exception e) {
// TODO: handle exception
// System.out.println("Create Data file fault,error msg:" + e.toString());
throw new RuntimeException("无法创建目标文件" + cfg.getName());
}
}

@ -2,7 +2,6 @@ package com.op.sap.controller;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.web.controller.BaseController;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
@ -207,7 +206,7 @@ public class SapController extends BaseController {
@PostMapping("/sapCreateOrder")
@Log(title = "生产订单创建接口", businessType = BusinessType.SAP)
public R<List<String>> SapCreateOrder(@RequestBody List<SapCreateOrder> sapCreateOrderList){
public R<List<Map<String, String>>> SapCreateOrder(@RequestBody List<SapCreateOrder> sapCreateOrderList){
return sapOrderService.SapCreateOrder(sapCreateOrderList);
}

@ -1,7 +1,6 @@
package com.op.sap.service;
import com.op.common.core.domain.R;
import com.op.common.core.web.domain.AjaxResult;
import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.domain.sap.SapRFW;
@ -9,6 +8,7 @@ import com.op.system.api.domain.sap.SapShopOrderQuery;
import com.op.system.api.model.SapProOrder;
import java.util.List;
import java.util.Map;
/**
* 20238
@ -27,7 +27,7 @@ public interface SapOrderService {
* @param sapCreateOrderList
* @return
*/
R<List<String>> SapCreateOrder(List<SapCreateOrder> sapCreateOrderList);
R<List<Map<String, String>>> SapCreateOrder(List<SapCreateOrder> sapCreateOrderList);
/**
*

@ -23,12 +23,14 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Component
@Service
public class SapBomServiceImpl implements SapBomService {
private static final String END_DATE="99991231";
@ -41,13 +43,16 @@ public class SapBomServiceImpl implements SapBomService {
@Autowired
private SqlSessionFactory sqlSessionFactory;
@Autowired
private JCoDestination dest;
@Override
public R bomSync(SapBomQuery sapBomQuery) {
try {
// 获取调用 RFC 函数对象
//获取连接
JCoDestination dest = SAPConnUtils.connect();
//JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_BOM");
if (func == null) {

@ -20,6 +20,7 @@ import com.sap.conn.jco.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.validation.Validator;
@ -28,6 +29,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Component
@Service
public class SapItemSyncImpl implements SapItemSyncService {
@ -41,15 +43,19 @@ public class SapItemSyncImpl implements SapItemSyncService {
@Autowired
protected Validator validator;
@Autowired
private JCoDestination dest;
private static final Logger log = LoggerFactory.getLogger(SapItemSyncImpl.class);
@Override
public R itemSync(SapItemQuery sapItemQuery) {
try {
// 获取调用 RFC 函数对象
//获取连接
JCoDestination dest = SAPConnUtils.connect();
// JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMMR_MES_MAT_GET");
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
@ -186,6 +192,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
baseProduct.setUpdateBy(SecurityUtils.getUsername());
sapBaseProductList.add(baseProduct);
}
//this.importProducts(sapBaseProductList)
return R.ok(this.importProducts(sapBaseProductList));
}catch (Exception e){
return R.fail(e.getMessage());
@ -198,7 +205,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
try {
// 获取调用 RFC 函数对象
//获取连接
JCoDestination dest = SAPConnUtils.connect();
// JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_GOODSMVT_CREATE");
// 配置传入参数

@ -9,17 +9,22 @@ import com.op.sap.util.SAPConnUtils;
import com.op.system.api.domain.sap.SapMaterialPreparation;
import com.sap.conn.jco.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Component
@Service
public class SapMaterialPreparationServiceImpl implements SapMaterialPreparationService {
@Autowired
SapMaterialPreparationMapper sapMaterialPreparationMapper;
@Autowired
private JCoDestination dest;
@Override
public R<List<SapMaterialPreparation>> MaterialPreparation(String shopOrder) {
// 连接
@ -27,7 +32,7 @@ public class SapMaterialPreparationServiceImpl implements SapMaterialPreparation
try {
// 获取调用 RFC 函数对象
//获取连接
JCoDestination dest = SAPConnUtils.connect();
// JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_MATERIAL_PREPARATION");
if (func == null) {

@ -15,16 +15,23 @@ import com.op.system.api.domain.sap.SapShopOrderQuery;
import com.op.system.api.model.SapProOrder;
import com.sap.conn.jco.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
@Service
public class SapOrderServiceImpl implements SapOrderService {
private static final String END_DATE="99991231";
@Autowired
private JCoDestination dest;
@Override
public R<List<SapProOrder>> shopOrderSync(SapShopOrderQuery sapShopOrderQuery) {
@ -32,7 +39,7 @@ public class SapOrderServiceImpl implements SapOrderService {
try {
// 获取调用 RFC 函数对象
//获取连接
JCoDestination dest = SAPConnUtils.connect();
//JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRO_TO");
if (func == null) {
@ -141,11 +148,11 @@ public class SapOrderServiceImpl implements SapOrderService {
}
@Override
public R<List<String>> SapCreateOrder(List<SapCreateOrder> sapCreateOrderList) {
public R<List<Map<String, String>>> SapCreateOrder(List<SapCreateOrder> sapCreateOrderList) {
String L_MSG=null;
try {
//获取连接
JCoDestination dest = SAPConnUtils.connect();
// JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORD_CREATE");
if (func == null) {
@ -154,9 +161,9 @@ public class SapOrderServiceImpl implements SapOrderService {
// 配置传入参数
JCoParameterList jCoParameterList = func.getImportParameterList();
List<String> LV_ORDER_NUM_List=new ArrayList<>();
if (sapCreateOrderList!=null && sapCreateOrderList.size()>0){
List<Map<String,String>> LV_ORDER_NUM_List=new ArrayList<>();
for (SapCreateOrder sapCreateOrder:sapCreateOrderList){
jCoParameterList.setValue("P_WERKS",sapCreateOrder.getWerks());
jCoParameterList.setValue("P_AUFPAR",sapCreateOrder.getAufpar());
@ -169,17 +176,24 @@ public class SapOrderServiceImpl implements SapOrderService {
System.out.println(J);
L_MSG= func.getExportParameterList().getString("L_MSG");
String LV_ORDER_NUMBER= func.getExportParameterList().getString("LV_ORDER_NUMBER");
if (!StringUtils.isEmpty(LV_ORDER_NUMBER)){
LV_ORDER_NUM_List.add(LV_ORDER_NUMBER);
}else {
return R.fail(L_MSG);
JCoTable LT_ZGD=func.getTableParameterList().getTable("LT_ZGD");
System.out.println(LT_ZGD);
//DynamicDataSourceContextHolder.push("ds_1000");//controller已经完成切换
for (int i = 0; i <LT_ZGD.getNumRows(); i++) {
LT_ZGD.setRow(i);
Map map=new HashMap();
String LEAD_AUFNR = LT_ZGD.getString("LEAD_AUFNR");
String AUFNR = LT_ZGD.getString("AUFNR");
map.put("LEAD_AUFNR",LEAD_AUFNR);
map.put("AUFNR",AUFNR);
LV_ORDER_NUM_List.add(map);
}
}
return R.ok(LV_ORDER_NUM_List,L_MSG);
}else {
return R.fail("接收的数据为空");
}
}catch (Exception e){
return R.fail(L_MSG);
}
@ -191,7 +205,7 @@ public class SapOrderServiceImpl implements SapOrderService {
String L_MSG=null;
try {
//获取连接
JCoDestination dest = SAPConnUtils.connect();
// JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORD_CLOSE");
if (func == null) {
@ -223,7 +237,7 @@ public class SapOrderServiceImpl implements SapOrderService {
String MESSAGE=null;
try {
//获取连接
JCoDestination dest = SAPConnUtils.connect();
// JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORDCONF_CREATE_TT");
if (func == null) {

@ -14,6 +14,7 @@ import com.op.sap.util.SAPConnUtils;
import com.op.system.api.domain.sap.*;
import com.sap.conn.jco.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.validation.Validator;
import java.rmi.ServerException;
@ -23,6 +24,7 @@ import java.util.List;
import java.util.TreeSet;
import java.util.stream.Collectors;
@Component
@Service
public class SapRouterServiceImpl implements SapRouterService {
private static final String END_DATE="99991231";
@ -41,6 +43,9 @@ public class SapRouterServiceImpl implements SapRouterService {
@Autowired
protected Validator validator;
@Autowired
private JCoDestination dest;
@Override
public R sapRouterSync(SapRouterQuery sapRouterQuery) {
int successNum = 0;
@ -50,7 +55,7 @@ public class SapRouterServiceImpl implements SapRouterService {
try {
// 获取调用 RFC 函数对象
//获取连接
JCoDestination dest = SAPConnUtils.connect();
// JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_ROUTING");
if (func == null) {

@ -14,6 +14,7 @@ import com.op.system.api.domain.sap.SapSupplier;
import com.op.system.api.domain.sap.SapWorkCenter;
import com.sap.conn.jco.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -22,19 +23,22 @@ import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Component
@Service
public class SapWorkCenterServiceImpl implements SapWorkCenterService {
private static final String END_DATE="99991231";
@Autowired
private SapBomMapper sapBomMapper;
@Autowired
private JCoDestination dest;
@Override
public R sapWorkCenterSync(SapWorkCenterQuery sapWorkCenterQuery) {
try {
// 获取调用 RFC 函数对象
//获取连接
JCoDestination dest = SAPConnUtils.connect();
// JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_GET_ARBPL");
if (func == null) {
@ -111,7 +115,7 @@ public class SapWorkCenterServiceImpl implements SapWorkCenterService {
try {
// 获取调用 RFC 函数对象
//获取连接
JCoDestination dest = SAPConnUtils.connect();
// JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_GET_LFB1");
if (func == null) {
@ -188,7 +192,7 @@ public class SapWorkCenterServiceImpl implements SapWorkCenterService {
try {
// 获取调用 RFC 函数对象
//获取连接
JCoDestination dest = SAPConnUtils.connect();
// JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_GET_KNA1");
if (func == null) {

@ -4,20 +4,29 @@ package com.op.sap.util;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
@Component
public class SAPConnUtils {
protected Logger logger = LoggerFactory.getLogger(getClass());
private static final String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL";
public static JCoDestination connect() {
@Bean
public JCoDestination connect() {
JCoDestination destination = null;
try {
destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED);
// System.out.println(destination.getAttributes());
if (destination!=null){
logger.info("连接SAP成功");
}
} catch (JCoException e) {
// TODO: handle exception
logger.info("连接SAP失败错误: " + e.toString());
throw new RuntimeException("连接SAP失败错误: " + e.toString());
// System.out.println("连接SAP失败错误: " + e.toString());
}
return destination;
}
}

Loading…
Cancel
Save