From 03efbd1db7393af74f1106635f5667a04dbc8201 Mon Sep 17 00:00:00 2001 From: zhaoxl Date: Tue, 22 Aug 2023 14:37:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20'op-modules/op-sap/src/main/java/com/op/sap/service/impl'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SapBaseFileServiceImpl.java | 110 +++ .../impl/SapBaseProductServiceImpl.java | 110 +++ .../impl/SapProRouteProductServiceImpl.java | 132 +++ .../service/impl/SapProRouteServiceImpl.java | 209 +++++ .../op/sap/service/impl/SapServiceImpl.java | 862 ++++++++++++++++++ 5 files changed, 1423 insertions(+) create mode 100644 op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapBaseFileServiceImpl.java create mode 100644 op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapBaseProductServiceImpl.java create mode 100644 op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapProRouteProductServiceImpl.java create mode 100644 op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapProRouteServiceImpl.java create mode 100644 op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapServiceImpl.java diff --git a/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapBaseFileServiceImpl.java b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapBaseFileServiceImpl.java new file mode 100644 index 00000000..16cc0a3b --- /dev/null +++ b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapBaseFileServiceImpl.java @@ -0,0 +1,110 @@ +package com.op.sap.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.op.common.core.domain.BaseFileData; +import com.op.common.core.utils.DateUtils; +import com.op.sap.domain.SapBaseFile; +import com.op.sap.mapper.SapBaseFileMapper; +import com.op.sap.service.SapBaseFileService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 附件Service业务层处理 + * + * @author Open Platform + * @date 2023-07-10 + */ +@Service +public class SapBaseFileServiceImpl implements SapBaseFileService { + @Autowired + private SapBaseFileMapper baseFileMapper; + + /** + * 查询附件 + * + * @param fileId 附件主键 + * @return 附件 + */ + @Override + @DS("#header.poolName") + public SapBaseFile selectBaseFileByFileId(String fileId) { + return baseFileMapper.selectBaseFileByFileId(fileId); + } + + /** + * 查询附件列表 + * + * @param baseFile 附件 + * @return 附件 + */ + @Override + @DS("#header.poolName") + public List selectBaseFileList(SapBaseFile baseFile) { + return baseFileMapper.selectBaseFileList(baseFile); + } + + /** + * 新增附件 + * + * @param baseFile 附件 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int insertBaseFile(SapBaseFile baseFile) { + baseFile.setCreateTime(DateUtils.getNowDate()); + return baseFileMapper.insertBaseFile(baseFile); + } + + /** + * 修改附件 + * + * @param baseFile 附件 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int updateBaseFile(SapBaseFile baseFile) { + baseFile.setUpdateTime(DateUtils.getNowDate()); + return baseFileMapper.updateBaseFile(baseFile); + } + + /** + * 批量删除附件 + * + * @param fileIds 需要删除的附件主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteBaseFileByFileIds(String[] fileIds) { + return baseFileMapper.deleteBaseFileByFileIds(fileIds); + } + + /** + * 删除附件信息 + * + * @param fileId 附件主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteBaseFileByFileId(String fileId) { + return baseFileMapper.deleteBaseFileByFileId(fileId); + } + + /** + * 新增附件 + * + * @param baseFiles 附件 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public Boolean insertBaseFileBatch(List baseFiles) { + return baseFileMapper.insertBaseFileBatch(baseFiles); + } +} diff --git a/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapBaseProductServiceImpl.java b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapBaseProductServiceImpl.java new file mode 100644 index 00000000..365cbf4a --- /dev/null +++ b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapBaseProductServiceImpl.java @@ -0,0 +1,110 @@ +package com.op.sap.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.op.common.core.utils.DateUtils; +import com.op.common.security.utils.SecurityUtils; +import com.op.sap.domain.SapBaseProduct; +import com.op.sap.mapper.SapBaseProductMapper; +import com.op.sap.service.ISapBaseProductService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 物料信息Service业务层处理 + * + * @author Open Platform + * @date 2023-07-18 + */ +@Service +public class SapBaseProductServiceImpl implements ISapBaseProductService { + + + @Autowired + private SapBaseProductMapper baseProductMapper; + + /** + * 查询物料信息 + * + * @param productId 物料信息主键 + * @return 物料信息 + */ + @Override + @DS("#header.poolName") + public SapBaseProduct selectBaseProductByProductId(String productId) { + return baseProductMapper.selectBaseProductByProductId(productId); + } + + /** + * 查询物料信息列表 + * + * @param baseProduct 物料信息 + * @return 物料信息 + */ + @Override + @DS("#header.poolName") + public List selectBaseProductList(SapBaseProduct baseProduct) { + return baseProductMapper.selectBaseProductList(baseProduct); + } + + /** + * 新增物料信息 + * + * @param baseProduct 物料信息 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int insertBaseProduct(SapBaseProduct baseProduct) { + + baseProduct.setCreateTime(DateUtils.getNowDate()); + baseProduct.setCreateBy(SecurityUtils.getUsername()); + return baseProductMapper.insertBaseProduct(baseProduct); + } + + /** + * 修改物料信息 + * + * @param baseProduct 物料信息 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int updateBaseProduct(SapBaseProduct baseProduct) { + baseProduct.setUpdateTime(DateUtils.getNowDate()); + baseProduct.setUpdateBy(SecurityUtils.getUsername()); + return baseProductMapper.updateBaseProduct(baseProduct); + } + + /** + * 批量删除物料信息 + * + * @param productIds 需要删除的物料信息主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteBaseProductByProductIds(String[] productIds) { + return baseProductMapper.deleteBaseProductByProductIds(productIds); + } + + /** + * 删除物料信息信息 + * + * @param productId 物料信息主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteBaseProductByProductId(String productId) { + return baseProductMapper.deleteBaseProductByProductId(productId); + } + + @Override + public String selectBaseProductIDByProductCode(String productCode) { + return baseProductMapper.selectBaseProductIDByProductCode(productCode); + } + + +} diff --git a/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapProRouteProductServiceImpl.java b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapProRouteProductServiceImpl.java new file mode 100644 index 00000000..2671f564 --- /dev/null +++ b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapProRouteProductServiceImpl.java @@ -0,0 +1,132 @@ +package com.op.sap.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.op.common.core.utils.DateUtils; +import com.op.common.core.utils.uuid.IdUtils; +import com.op.common.security.utils.SecurityUtils; +import com.op.sap.domain.SapProRouteProduct; +import com.op.sap.mapper.SapProRouteProductMapper; +import com.op.sap.service.SapProRouteProductService; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +/** + * 工艺线体关联Service业务层处理 + * + * @author Open Platform + * @date 2023-07-13 + */ +@Service +public class SapProRouteProductServiceImpl implements SapProRouteProductService { + @Autowired + private SapProRouteProductMapper proRouteProductMapper; + + /** + * 查询工艺线体关联 + * + * @param recordId 工艺线体关联主键 + * @return 工艺线体关联 + */ + @Override + @DS("#header.poolName") + public SapProRouteProduct selectProRouteProductByRecordId(String recordId) { + return proRouteProductMapper.selectProRouteProductByRecordId(recordId); + } + + /** + * 查询工艺线体关联列表 + * + * @param proRouteProduct 工艺线体关联 + * @return 工艺线体关联 + */ + @Override + @DS("#header.poolName") + public List selectProRouteProductList(SapProRouteProduct proRouteProduct) { + return proRouteProductMapper.selectProRouteProductList(proRouteProduct); + } + + /** + * 新增工艺线体关联 + * + * @param proRouteProduct 工艺线体关联 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int insertProRouteProduct(SapProRouteProduct proRouteProduct) { + Date now = DateUtils.getNowDate(); + if(StringUtils.isNotBlank(proRouteProduct.getRouteId())){ + //删除之前的关联关系 + proRouteProductMapper.deleteByRouteId(proRouteProduct); + } + if(proRouteProduct.getSelectedValues()!=null){ + SapProRouteProduct proRouteProductDto =null; + for(String ProductCode:proRouteProduct.getSelectedValues()){ + //查询物料编码对应的各种信息 + proRouteProductDto = new SapProRouteProduct(); + proRouteProductDto.setRecordId(IdUtils.fastSimpleUUID()); + proRouteProductDto.setCreateTime(now); + proRouteProductDto.setCreateBy(SecurityUtils.getUsername()); + proRouteProductDto.setRouteId(proRouteProduct.getRouteId()); + proRouteProductDto.setItemId(proRouteProduct.getItemId()); + proRouteProductDto.setItemCode(ProductCode); + proRouteProductDto.setItemName(proRouteProduct.getItemName()); + proRouteProductMapper.insertProRouteProduct(proRouteProductDto); + } + } + //新增关联关系 + return 1; + } + + /** + * 修改工艺线体关联 + * + * @param proRouteProduct 工艺线体关联 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int updateProRouteProduct(SapProRouteProduct proRouteProduct) { + proRouteProduct.setUpdateTime(DateUtils.getNowDate()); + return proRouteProductMapper.updateProRouteProduct(proRouteProduct); + } + + /** + * 批量删除工艺线体关联 + * + * @param recordIds 需要删除的工艺线体关联主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteProRouteProductByRecordIds(String[] recordIds) { + return proRouteProductMapper.deleteProRouteProductByRecordIds(recordIds); + } + + /** + * 删除工艺线体关联信息 + * + * @param recordId 工艺线体关联主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteProRouteProductByRecordId(String recordId) { + return proRouteProductMapper.deleteProRouteProductByRecordId(recordId); + } + + @Override + @DS("#header.poolName") + public SapProRouteProduct getList(SapProRouteProduct proRouteProduct) { + SapProRouteProduct dto = new SapProRouteProduct(); + List unSelected = proRouteProductMapper.getRouteProdProductListUndo(proRouteProduct); + dto.setUnSelect(unSelected); + List selected= proRouteProductMapper.getRouteProdProductListDo(proRouteProduct); + dto.setSelected(selected); + return dto; + } +} diff --git a/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapProRouteServiceImpl.java b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapProRouteServiceImpl.java new file mode 100644 index 00000000..53e2e191 --- /dev/null +++ b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapProRouteServiceImpl.java @@ -0,0 +1,209 @@ +package com.op.sap.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.op.common.core.constant.UserConstants; +import com.op.common.core.domain.BaseFileData; +import com.op.common.core.utils.DateUtils; +import com.op.common.core.utils.StringUtils; +import com.op.common.core.utils.uuid.IdUtils; +import com.op.common.security.utils.SecurityUtils; +import com.op.sap.domain.SapBaseFile; +import com.op.sap.domain.SapProRoute; +import com.op.sap.mapper.SapBaseFileMapper; +import com.op.sap.mapper.SapProRouteMapper; +import com.op.sap.service.SapProRouteService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + + +/** + * 工艺路线Service业务层处理 + * + * @author yinjinlu + * @date 2022-05-12 + */ +@Service +public class SapProRouteServiceImpl implements SapProRouteService { + @Autowired + private SapProRouteMapper proRouteMapper; + @Autowired + private SapBaseFileMapper baseFileMapper; + + /** + * 查询工艺路线 + * + * @param routeId 工艺路线主键 + * @return 工艺路线 + */ + @Override + @DS("#header.poolName") + public SapProRoute selectProRouteByRouteId(String routeId) { + + SapProRoute p = proRouteMapper.selectProRouteByRouteId(routeId); + List files = baseFileMapper.getBaseFileBatch(routeId); + if (!CollectionUtils.isEmpty(files)) { + p.setFiles(files); + } + return p; + } + + /** + * 查询工艺路线列表 + * + * @param proRoute 工艺路线 + * @return 工艺路线 + */ + @Override + @DS("#header.poolName") + public List selectProRouteList(SapProRoute proRoute) { + return proRouteMapper.selectProRouteList(proRoute); + } + + @Override + public SapProRoute getRouteByProductId(String itemId) { + return proRouteMapper.getRouteByProductId(itemId); + } + + + @Override + @DS("#header.poolName") + public Boolean checkRouteCodeUnique(SapProRoute proRoute) { + SapProRoute route = proRouteMapper.checkRouteCodeUnique(proRoute); + String routeId = proRoute.getRouteId(); + if (StringUtils.isNotNull(route) && !route.getRouteId().equals(routeId)) { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 新增工艺路线 + * + * @param proRoute 工艺路线 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int insertProRoute(SapProRoute proRoute) { + proRoute.setCreateTime(DateUtils.getNowDate()); + proRoute.setRouteVersion("V.1"); + //上传附件 + if (StringUtils.isNotEmpty(proRoute.getFileList())) { + String[] ids = proRoute.getFileList().split(","); + List files = new ArrayList<>(); + BaseFileData file = null; + for (String id : ids) { + file = new BaseFileData(); + file.setFileId(IdUtils.fastSimpleUUID()); + file.setFileName(id.split("&fileName=")[1]); + file.setFileAddress(id); + file.setSourceId(proRoute.getRouteId()); + file.setCreateBy(SecurityUtils.getUsername()); + file.setCreateTime(new Date()); + files.add(file); + } + baseFileMapper.insertBaseFileBatch(files); + } + + return proRouteMapper.insertProRoute(proRoute); + } + + /** + * 修改工艺路线 + * + * @param proRoute 工艺路线 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int updateProRoute(SapProRoute proRoute) { + proRoute.setUpdateTime(DateUtils.getNowDate()); + //上传附件 + if (StringUtils.isNotEmpty(proRoute.getFileList())) { + baseFileMapper.deleteBaseFileBySourceId(proRoute.getRouteId()); + String[] ids = proRoute.getFileList().split(","); + List files = new ArrayList<>(); + BaseFileData file = null; + for (String id : ids) { + file = new BaseFileData(); + file.setFileId(IdUtils.fastSimpleUUID()); + file.setFileAddress(id); + file.setFileName(id.split("&fileName=")[1]); + file.setSourceId(proRoute.getRouteId()); + file.setCreateBy(SecurityUtils.getUsername()); + file.setCreateTime(new Date()); + files.add(file); + } + baseFileMapper.insertBaseFileBatch(files); + } + + //更新版本V.1->递增 + String nowRouteVersion = proRoute.getRouteVersion().replace("V", "") + .replace(".", ""); + int nowRouteVersionNum = Integer.parseInt(nowRouteVersion); + String newRouteVersionNum = "V." + (++nowRouteVersionNum); + proRoute.setRouteVersion(newRouteVersionNum); + return proRouteMapper.updateProRoute(proRoute); + } + + /** + * 批量删除工艺路线 + * + * @param routeIds 需要删除的工艺路线主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteProRouteByRouteIds(String[] routeIds) { + return proRouteMapper.deleteProRouteByRouteIds(routeIds); + } + + /** + * 删除工艺路线信息 + * + * @param routeId 工艺路线主键 + * @return 结果 + */ + @Override + @DS("#header.poolName") + public int deleteProRouteByRouteId(String routeId) { + return proRouteMapper.deleteProRouteByRouteId(routeId); + } + + @Override + @DS("#header.poolName") + public int batchInsertProRoute(SapProRoute proRoute) { + proRoute.setCreateTime(DateUtils.getNowDate()); + if (StringUtils.isNotEmpty(proRoute.getFileList())) { + List ids = proRoute.getIdList(); +// for (int j = ids.size(); j < 1; j--) { + for (String id :ids) { + String[] f = proRoute.getFileList().split(","); + List files = new ArrayList<>(); + BaseFileData file = null; + for (String file1 : f) { + file = new BaseFileData(); + file.setFileId(IdUtils.fastSimpleUUID()); + file.setFileName(file1.split("&fileName=")[1]); + file.setFileAddress(file1); + file.setSourceId(id); + file.setCreateBy(SecurityUtils.getUsername()); + file.setCreateTime(new Date()); + files.add(file); + } + baseFileMapper.insertBaseFileBatch(files); + } + } + return 1; + } + + @Override + public int selectProRrouteByRouteCode(String routeCode) { + return proRouteMapper.selectProRouteByRouteCode(routeCode); + } +} diff --git a/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapServiceImpl.java b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapServiceImpl.java new file mode 100644 index 00000000..6691157c --- /dev/null +++ b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapServiceImpl.java @@ -0,0 +1,862 @@ +package com.op.sap.service.impl; + +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import com.op.common.core.constant.Constants; +import com.op.common.core.domain.R; +import com.op.common.core.utils.DateUtils; +import com.op.common.core.utils.uuid.IdUtils; +import com.op.common.core.utils.uuid.UUID; +import com.op.sap.domain.*; +import com.op.sap.mapper.*; +import com.op.sap.service.ISapBaseProductService; +import com.op.sap.service.SapService; +import com.op.sap.util.SAPConnUtils; +import com.op.system.api.model.SapProOrder; +import com.sap.conn.jco.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.TreeSet; +import java.util.stream.Collectors; + +@Service +public class SapServiceImpl implements SapService { + +// @Autowired +// private RemotePlanService remotePlanService; + + @Autowired + private ISapBaseProductService sapBaseProductService; + @Autowired + private SapSysDeptMapper sapSysDeptMapper; + @Autowired + private SapSysUserMapper sapSysUserMapper; + + @Autowired + private SapBaseProductMapper sapBaseProductMapper; + @Autowired + private SapProRouteMapper sapProRouteMapper; + @Autowired + private SapProRouteProductMapper sapProRouteProductMapper; + @Autowired + private SapProProcessMapper sapProProcessMapper; + @Autowired + private SapProProcessContentMapper sapProProcessContentMapper; + @Autowired + private SapProRouteProcessMapper sapProRouteProcessMapper; +// @Override +// public List shopOrderSync(SapProOrder sapProOrder) { +// +// +// // 连接 +// SapConn con = new SapConn( +// ashost, +// sysnr, +// client, +// user, +// passwd, +// lang, +// pool_capacity, +// peak_limit, +// saprouter +// ); +// JCoDestination jCoDestination = SAPConnUtils.connect(con); +// try { +// // 获取调用 RFC 函数对象 +// JCoFunction func = jCoDestination.getRepository().getFunction("ZPPR_MES_PRO_TO"); +// // 配置传入参数 +// JCoParameterList importParameterList = func.getImportParameterList(); +//// importParameterList.setValue("S_AUFNR",001002125255 ); +// // 调用并获取返回值 +// func.execute(jCoDestination); +// // 获取 内表 - ZMES_PRO +// JCoTable maraTable = func.getTableParameterList().getTable("ZMES_PRO"); +// JCoRecordMetaData metaData = maraTable.getRecordMetaData(); +// System.out.println("###" + metaData.toString()); +// SapProOrder proOrder = new SapProOrder(); +// List proOrderList = new ArrayList<>(); +// // 循环输出 Table 数据 +// for (int i = 0; i < maraTable.getNumRows(); i++) { +// maraTable.setRow(i); +// String AUFNR = maraTable.getString("AUFNR"); +// String AUART = maraTable.getString("AUART"); +// String MAUFNR = maraTable.getString("MAUFNR"); +// String PLNBEZ = maraTable.getString("PLNBEZ"); +// String MAKTX = maraTable.getString("MAKTX"); +// String PWERK = maraTable.getString("PWERK"); +// String GAMNG = maraTable.getString("GAMNG"); +// String GMEIN = maraTable.getString("GMEIN"); +// String PLNNR = maraTable.getString("PLNNR"); +// String GSTRP = maraTable.getString("GSTRP"); +// String GLTRP = maraTable.getString("GLTRP"); +// String ERNAM = maraTable.getString("ERNAM"); +// String ERDAT = maraTable.getString("ERDAT"); +// String STTXT = maraTable.getString("STTXT"); +// System.out.println("订单号:" + AUFNR + " - 订单类型:" + AUART + " - 上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX +// + " - 订单的计划工厂:" + PWERK + " - 订单数量总计:" + GAMNG + " - 基本计量单位:" + GMEIN + " - 任务清单组码:" + PLNNR + " - 基本开始日期:" + GSTRP +// + " - 基本完成日期:" + GLTRP + " - 输入者:" + ERNAM + " - 创建日期:" + ERDAT + " - 系统状态:" + STTXT); +// proOrder.setId(IdUtils.fastSimpleUUID()); +// proOrder.setPlanFactoryCode(PWERK); +// proOrder.setOrderCode(AUFNR); +// proOrder.setOrderType(AUART); +// proOrder.setProdCode(PLNBEZ); +// proOrder.setProdDesc(MAKTX); +// proOrder.setQuantity(Long.parseLong(GAMNG.substring(0, GAMNG.indexOf(".")))); +// proOrder.setUnit(GMEIN); +// proOrder.setWorkerOrder(PLNNR); +// proOrder.setPlanProDate(DateUtils.dateTime("yyyy-MM-dd", GSTRP)); +// proOrder.setPlanComplete(DateUtils.dateTime("yyyy-MM-dd", GLTRP)); +// proOrder.setParentOrder(MAUFNR); +// proOrder.setCreateBy(ERNAM); +// proOrder.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ERDAT)); +// proOrder.setUpdateBy(ERNAM); +// proOrder.setUpdateTime(DateUtils.dateTime("yyyy-MM-dd", ERDAT)); +// proOrder.setStatus("0"); +// proOrderList.add(proOrder); +// // remotePlanService.sapAddOrder(proOrder); +// // remoteMesService.sapAddOrder(proOrder); +// } +// return proOrderList; +// } catch (Exception e) { +// return null; +// } +// } +// +// +// @Override +// public R sapItem() { +// DynamicDataSourceContextHolder.push("lanju_op_xiaolan_ds"); +// // 连接 +// SapConn con = new SapConn( +// ashost, +// sysnr, +// client, +// user, +// passwd, +// lang, +// pool_capacity, +// peak_limit, +// saprouter +// ); +// JCoDestination jCoDestination = SAPConnUtils.connect(con); +// try { +//// // 获取调用 RFC 函数对象 +//// JCoFunction func = jCoDestination.getRepository().getFunction("ZMMR_MES_MAT_GET"); +//// // 配置传入参数 +//// JCoParameterList importParameterList = func.getImportParameterList(); +//// //importParameterList.setValue("S_AUFNR",001002125255 ); +//// // 调用并获取返回值 +//// func.execute(jCoDestination); +//// // 获取 内表 - ZMES_PRO +//// JCoTable maraTable = func.getTableParameterList().getTable("LT_MARA"); +//// JCoRecordMetaData metaData = maraTable.getRecordMetaData(); +//// System.out.println("###"+metaData.toString()); +//// SapProOrder proOrder=new SapProOrder(); +//// List proOrderList=new ArrayList<>(); +//// // 循环输出 Table 数据 +//// for (int i = 0; i < maraTable.getNumRows(); i++) { +//// maraTable.setRow(i); +//// String AUFNR = maraTable.getString("AUFNR"); +//// String AUART = maraTable.getString("AUART"); +//// String MAUFNR = maraTable.getString("MAUFNR"); +//// String PLNBEZ = maraTable.getString("PLNBEZ"); +// //获取调用 RFC 函数对象 +// JCoFunction func = jCoDestination.getRepository().getFunction("ZMMR_MES_MAT_GET"); +// // 配置传入参数 +// JCoParameterList importParameterList = func.getImportParameterList(); +// //importParameterList.setValue("S_AUFNR",001002125255 ); +// // 调用并获取返回值 +// func.execute(jCoDestination); +// // 获取 内表 - LT_BOM +// JCoTable maraTable = func.getTableParameterList().getTable("LT_MARA"); +// JCoRecordMetaData metaData = maraTable.getRecordMetaData(); +// System.out.println("###" + metaData.toString()); +//// SapProOrder proOrder=new SapProOrder(); +// SapBaseProduct baseProduct = new SapBaseProduct(); +// String[] str = new String[maraTable.getNumRows()]; +// List baseProductList = new ArrayList<>(); +// // 循环输出 Table 数据 +// for (int i = 0; i < maraTable.getNumRows(); i++) { +// +// maraTable.setRow(i); +// String MATNR = maraTable.getString("MATNR"); +// String MAKTX = maraTable.getString("MAKTX"); +// String EAN11 = maraTable.getString("EAN11"); +// String MTART = maraTable.getString("MTART"); +// String MTBEZ = maraTable.getString("MTBEZ"); +// String MATKL = maraTable.getString("MATKL"); +// String WGBEZ = maraTable.getString("WGBEZ"); +// BigDecimal BRGEW = maraTable.getBigDecimal("BRGEW"); +// BigDecimal NTGEW = maraTable.getBigDecimal("NTGEW"); +// BigDecimal VOLUM = maraTable.getBigDecimal("VOLUM"); +// String VOLEH = maraTable.getString("VOLEH"); +// String MEINS = maraTable.getString("MEINS"); +// String MEINH = maraTable.getString("MEINH"); +// String UMREZ = maraTable.getString("UMREZ"); +// String UMREN = maraTable.getString("UMREN"); +// String LVORM = maraTable.getString("LVORM"); +// String MENGE = maraTable.getString("MENGE"); +// String MHDHB = maraTable.getString("MHDHB"); +// String SPART = maraTable.getString("SPART"); +// String SPART_NM = maraTable.getString("SPART_NM"); +// String MVGR1 = maraTable.getString("MVGR1"); +// String MVGR1_NM = maraTable.getString("MVGR1_NM"); +// String MVGR2 = maraTable.getString("MVGR2"); +// String MVGR2_NM = maraTable.getString("MVGR2_NM"); +// String MVGR3 = maraTable.getString("MVGR3"); +// String MVGR3_NM = maraTable.getString("MVGR3_NM"); +// String MVGR4 = maraTable.getString("MVGR4"); +// String MVGR4_NM = maraTable.getString("MVGR4_NM"); +// String MVGR5 = maraTable.getString("MVGR5"); +// String MVGR5_NM = maraTable.getString("MVGR5_NM"); +//// String SANKA = maraTable.getString("SANKA"); +//// System.out.println("MATNR" + MATNR + "MAKTX" + MAKTX); +// baseProduct.setProductCode(MATNR); +// baseProduct.setProductDescZh(MAKTX); +//// baseProduct.setProductean11(EAN11); +// baseProduct.setProductGroup(MATKL); +// baseProduct.setProductGroupName(WGBEZ); +// baseProduct.setGrossWeight(BRGEW); +// baseProduct.setNetWeight(NTGEW); +// baseProduct.setVolume(VOLUM); +// baseProduct.setDelFlag("0"); +// str[i] = baseProduct.getProductCode(); +// if (i!=0){ +// if (str[i].equals(str[i-1])) { +// System.out.println("chongfu"); +// +// }else { +// sapBaseProductMapper.insertBaseProduct(baseProduct); +// } +// } +// +// +//// baseProductList.add(i, baseProduct); +//// sapBaseProductMapper.insertBaseProduct(baseProduct); +// +// +// } +// } catch (Exception e) { +// return R.fail(e.getMessage()); +// } +// return R.ok(); +// } +// +// @Override +// public R sapBom() { +// // 连接 +// SapConn con = new SapConn( +// ashost, +// sysnr, +// client, +// user, +// passwd, +// lang, +// pool_capacity, +// peak_limit, +// saprouter +// ); +// JCoDestination jCoDestination = SAPConnUtils.connect(con); +// try { +// // 获取调用 RFC 函数对象 +// JCoFunction func = jCoDestination.getRepository().getFunction("ZMMR_MES_MAT_GET"); +// // 配置传入参数 +// JCoParameterList importParameterList = func.getImportParameterList(); +// //importParameterList.setValue("S_AUFNR",001002125255 ); +// // 调用并获取返回值 +// func.execute(jCoDestination); +// // 获取 内表 - ZMES_PRO +// JCoTable maraTable = func.getTableParameterList().getTable("LT_MARA"); +// JCoRecordMetaData metaData = maraTable.getRecordMetaData(); +// System.out.println("###" + metaData.toString()); +// SapProOrder proOrder = new SapProOrder(); +// List proOrderList = new ArrayList<>(); +// // 循环输出 Table 数据 +// for (int i = 0; i < maraTable.getNumRows(); i++) { +// maraTable.setRow(i); +// String AUFNR = maraTable.getString("AUFNR"); +// String AUART = maraTable.getString("AUART"); +// String MAUFNR = maraTable.getString("MAUFNR"); +// String PLNBEZ = maraTable.getString("PLNBEZ"); +// System.out.println("工厂:" + AUFNR + " - 物料号:" + AUART + " - 物料组:" +// + MAUFNR + " - 生产版本:" + PLNBEZ); +// } +// +//// sapBaseProductService.insertBaseProduct(baseProduct); +// } +// catch( +// Exception e) +// +// { +// return R.fail(e.getMessage()); +// } +// return R.ok(); +//} +// +// @Override +// public R sapProRoute() { +// DynamicDataSourceContextHolder.push("lanju_op_xiaolan_ds"); +// // 连接 +// SapConn con = new SapConn( +// ashost, +// sysnr, +// client, +// user, +// passwd, +// lang, +// pool_capacity, +// peak_limit, +// saprouter +// ); +// JCoDestination jCoDestination = SAPConnUtils.connect(con); +// try { +// // 获取调用 RFC 函数对象 +// JCoFunction func = jCoDestination.getRepository().getFunction("ZPPR_MES_ROUTING"); +// // 配置传入参数 +// JCoParameterList importParameterList = func.getImportParameterList(); +//// System.out.println(importParameterList.getListMetaData()); +// // importParameterList.setValue("S_ERDAT","2019-11-07" ); +// // 调用并获取返回值 +// func.execute(jCoDestination); +// // 获取 内表 - ZMES_PRO +// JCoTable maraTable = func.getTableParameterList().getTable("LT_ROUTING"); +// JCoRecordMetaData metaData = maraTable.getRecordMetaData(); +// String[] str = new String[maraTable.getNumRows()]; +//// System.out.println("###" + metaData.toString()); +// +// List proRouteList = new ArrayList<>(); +// for (int i = 0; i new TreeSet<>(Comparator.comparing(SapProRoute::getRouteCode))), +// ArrayList::new)); +// for (int i = 0; i < proRouteList.size(); i++) { +// sapProRouteMapper.insertProRoute(proRouteList.get(i)); +// } +// +// +// } +// catch (Exception e){ +// return R.fail(e.getMessage()); +// } +// return R.ok(); +// } + +// @Override +// public R sapProRouteProduct() { +// DynamicDataSourceContextHolder.push("lanju_op_xiaolan_ds"); +// +// try { +// // 获取调用 RFC 函数对象 +// //获取连接 +// JCoDestination dest = SAPConnUtils.connect(); +// JCoRepository repository = dest.getRepository(); +// JCoFunction func = repository.getFunction("ZPPR_MES_ROUTING"); +// if (func == null) { +// throw new RuntimeException("Function does not exist in SAP"); +// } +// // 配置传入参数 +//// JCoTable jCoTable = func.getTableParameterList().getTable("S_STLNR"); +//// jCoTable.appendRow(); +//// jCoTable.setValue(Constants.SIGN, "I"); +//// jCoTable.setValue(Constants.OPTION, "EQ"); +//// jCoTable.setValue(Constants.LOW, "00012222"); +// +//// JCoTable jCoTables = func.getTableParameterList().getTable("LT_ROUTING"); +//// jCoTables.appendRow(); +//// jCoTables.setValue(Constants.SIGN, "I"); +//// jCoTables.setValue(Constants.OPTION, "EQ"); +//// jCoTables.setValue(Constants.LOW, "00012222"); +// // 获取调用 RFC 函数对象 +// func.execute(dest); +// // 获取 内表 - ZMES_PRO +// JCoTable maraTable = func.getTableParameterList().getTable("LT_ROUTING"); +// JCoRecordMetaData metaData = maraTable.getRecordMetaData(); +// System.out.println("###" + metaData.toString()); +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// // 获取调用 RFC 函数对象 +// JCoFunction func = jCoDestination.getRepository().getFunction("ZPPR_MES_ROUTING"); +// // 配置传入参数 +// JCoParameterList importParameterList = func.getImportParameterList(); +//// System.out.println(importParameterList.getListMetaData()); +// // importParameterList.setValue("S_ERDAT","2019-11-07" ); +// // 调用并获取返回值 +// func.execute(jCoDestination); +// // 获取 内表 - ZMES_PRO +// JCoTable maraTable = func.getTableParameterList().getTable("LT_ROUTING"); +// JCoRecordMetaData metaData = maraTable.getRecordMetaData(); +// String[] str = new String[maraTable.getNumRows()]; +//// System.out.println("###" + metaData.toString()); +// List proRouteList = new ArrayList<>(); +// List proRouteProductList = new ArrayList<>(); +// for (int i = 0; i new TreeSet<>(Comparator.comparing(SapProRoute::getRouteCode))), +// ArrayList::new)); +// for (int i = 0; i < proRouteList.size(); i++) { +// sapProRouteMapper.insertProRoute(proRouteList.get(i)); +// } +//// for (int i = 0; i sapProRouteProcess() { +// DynamicDataSourceContextHolder.push("lanju_op_xiaolan_ds"); +// DynamicDataSourceContextHolder.push("lanju_op_cloud"); + + try { + // 获取调用 RFC 函数对象 + //获取连接 + JCoDestination dest = SAPConnUtils.connect(); + JCoRepository repository = dest.getRepository(); + JCoFunction func = repository.getFunction("ZPPR_MES_ROUTING"); + if (func == null) { + throw new RuntimeException("Function does not exist in SAP"); + } + // 获取调用 RFC 函数对象 + func.execute(dest); + // 获取 内表 - ZMES_PRO + JCoTable maraTable = func.getTableParameterList().getTable("LT_ROUTING"); + JCoRecordMetaData metaData = maraTable.getRecordMetaData(); + System.out.println("###" + metaData.toString()); +// System.out.println("###" + metaData.toString()); + List proProcessList = new ArrayList<>(); + List proRouteProcessList = new ArrayList<>(); + List proProcessContentList = new ArrayList<>(); + List proRouteList = new ArrayList(); + for (int i = 0,arr1=0,arr2=0; i new TreeSet<>(Comparator.comparing(SapProProcessContent::getContentText))), +// ArrayList::new)); +// for (int j=0; jnew TreeSet<>(Comparator.comparing(SapProRouteProcess::getProcessCode))), +// ArrayList::new)); +// for (int k = 0;knew TreeSet<>(Comparator.comparing(SapProRouteProcess::getProcessCode))), +// ArrayList::new)); +// for (int k = 0;k proOrderList = new ArrayList<>(); +// for (int i = 0; i < maraTable.getNumRows(); i++) { +// maraTable.setRow(i); +// String AUFNR = maraTable.getString("AUFNR"); +// String AUART = maraTable.getString("AUART"); +// String MAUFNR = maraTable.getString("MAUFNR"); +// String PLNBEZ = maraTable.getString("PLNBEZ"); +// String MAKTX = maraTable.getString("MAKTX"); +// String PWERK = maraTable.getString("PWERK"); +// String GAMNG = maraTable.getString("GAMNG"); +// String GMEIN = maraTable.getString("GMEIN"); +// String PLNNR = maraTable.getString("PLNNR"); +// String GSTRP = maraTable.getString("GSTRP"); +// String GLTRP = maraTable.getString("GLTRP"); +// String ERNAM = maraTable.getString("ERNAM"); +// String ERDAT = maraTable.getString("ERDAT"); +// String STTXT = maraTable.getString("STTXT"); +// System.out.println("订单号:" +AUFNR+" - 订单类型:" + AUART+ " - 上级订单编号:" + MAUFNR+ " - 物料号:" + PLNBEZ+ " - 物料描述(短文本):" + MAKTX +// + " - 订单的计划工厂:" + PWERK+ " - 订单数量总计:" + GAMNG+ " - 基本计量单位:" + GMEIN+ " - 任务清单组码:" + PLNNR+ " - 基本开始日期:" + GSTRP +// + " - 基本完成日期:" + GLTRP+ " - 输入者:" + ERNAM+ " - 创建日期:" + ERDAT+ " - 系统状态:" + STTXT); +// } +// // 循环输出 Table 数据 +//// for (int i = 0; i < maraTable.getNumRows(); i++) { +//// maraTable.setRow(i); +//// String MATNR = maraTable.getString("MATNR"); +//// String MAKTX = maraTable.getString("MAKTX"); +//// String EAN11 = maraTable.getString("EAN11"); +//// String MTART = maraTable.getString("MTART"); +//// String MTBEZ = maraTable.getString("MTBEZ"); +//// String MATKL = maraTable.getString("MATKL"); +//// String WGBEZ = maraTable.getString("WGBEZ"); +//// String BRGEW = maraTable.getString("BRGEW"); +//// String NTGEW = maraTable.getString("NTGEW"); +//// String VOLUM = maraTable.getString("VOLUM"); +//// String VOLEH = maraTable.getString("VOLEH"); +//// String MEINS = maraTable.getString("MEINS"); +//// String MEINH = maraTable.getString("MEINH"); +//// String UMREZ = maraTable.getString("UMREZ"); +//// String UMREN = maraTable.getString("UMREN"); +//// String LVORM = maraTable.getString("LVORM"); +//// String MENGE = maraTable.getString("MENGE"); +//// String MHDHB = maraTable.getString("MHDHB"); +//// String SPART = maraTable.getString("SPART"); +//// String SPART_NM = maraTable.getString("SPART_NM"); +//// String MVGR1 = maraTable.getString("MVGR1"); +//// String MVGR1_NM = maraTable.getString("MVGR1_NM"); +//// String MVGR2 = maraTable.getString("MVGR2"); +//// String MVGR2_NM = maraTable.getString("MVGR2_NM"); +//// String MVGR3 = maraTable.getString("MVGR3"); +//// String MVGR3_NM = maraTable.getString("MVGR3_NM"); +//// String MVGR4 = maraTable.getString("MVGR4"); +//// String MVGR4_NM = maraTable.getString("MVGR4_NM"); +//// String MVGR5 = maraTable.getString("MVGR5"); +//// String MVGR5_NM = maraTable.getString("MVGR5_NM"); +//// System.out.println("物料号:" + MATNR + " - 物料描述:" + MAKTX + " - 国际文件号(EAN/UPC):" + EAN11 + " - 物料类型:" + MTART ); +//// } +// } + +}