highway
zhaoxiaolin 1 year ago
parent 1b53ac43d9
commit 404b202516

@ -2,14 +2,10 @@ package com.op.sap.controller;
import com.op.common.core.domain.R;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.sap.service.SapBomService;
import com.op.sap.service.*;
import com.op.sap.service.SapMaterialPreparationService;
import com.op.sap.service.SapOrderService;
import com.op.sap.service.SapRouterService;
import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.domain.sap.SapMaterialPreparation;
import com.op.system.api.domain.sap.SapRFW;
@ -35,6 +31,12 @@ public class SapController extends BaseController {
@Autowired
private SapRouterService sapRouterService;
@Autowired
private SapItemSyncService sapItemSyncService;
@Autowired
private SapWorkCenterService sapWorkCenterService;
/**
*
* @return
@ -49,17 +51,18 @@ public class SapController extends BaseController {
*
* @return
*/
// @PostMapping("/itemSync")
// public List itemSync(){
// return sapService.itemSync();
// }
@PostMapping("/itemSync")
@Log(title = "同步SAP物料清单", businessType = BusinessType.SAP)
public R itemSync(){
return sapItemSyncService.itemSync();
}
/**
*
* @return
*/
@PostMapping("/bomSync")
@Log(title = "同步SAP物料清单", businessType = BusinessType.SAP)
@Log(title = "同步SAP物料组件清单", businessType = BusinessType.SAP)
public R bomSync(){
return sapBomService.bomSync();
}
@ -99,6 +102,11 @@ public class SapController extends BaseController {
return sapOrderService.sapCloseOrder(shopOrder);
}
/**
*
* @param sapRFW
* @return
*/
@PostMapping("/sapRFWOrder")
@Log(title = "生产订单报工接口", businessType = BusinessType.SAP)
public R sapRFWOrder(@RequestBody SapRFW sapRFW){
@ -106,9 +114,42 @@ public class SapController extends BaseController {
}
/**
* 线
* @return
*/
@PostMapping("/sapRouterSync")
@Log(title = "工艺路线同步接口", businessType = BusinessType.SAP)
public R sapRouerSync() {
return sapRouterService.sapRouterSync();
}
/**
*
*/
@PostMapping("/sapWorkCenterSync")
@Log(title = "工作中心接口", businessType = BusinessType.SAP)
public R sapWorkCenterSync(){
return sapWorkCenterService.sapWorkCenterSync();
}
/**
*
*/
@PostMapping("/sapSupplierSync")
@Log(title = "供应商主数据", businessType = BusinessType.SAP)
public R sapSupplierSync(){
return sapWorkCenterService.sapSupplierSync();
}
/**
*
* @return
*/
@PostMapping("/sapCustomSync")
@Log(title = "客户主数据", businessType = BusinessType.SAP)
public R sapCustomSync(){
return sapWorkCenterService.sapCustomSync();
}
}

@ -0,0 +1,125 @@
package com.op.sap.domain;
public class SapMaterialPreparation {
//订单号
private String AUFNR;
//预留/相关需求的项目编号
private String RSPOS;
//物料号
private String MATNR;
//物料描述(短文本)
private String MAKTX;
//工厂
private String WERKS;
//库存地点
private String LGORT;
//组件的需求日期
private String BDTER;
//需求量
private String BDMNG;
//欠料数量
private String ZQLSL;
//基本计量单位
private String MEINS;
//标识:反冲
private String RGEKZ;
//直接采购标识
private String DBSKZ;
public String getAUFNR() {
return AUFNR;
}
public void setAUFNR(String AUFNR) {
this.AUFNR = AUFNR;
}
public String getRSPOS() {
return RSPOS;
}
public void setRSPOS(String RSPOS) {
this.RSPOS = RSPOS;
}
public String getMATNR() {
return MATNR;
}
public void setMATNR(String MATNR) {
this.MATNR = MATNR;
}
public String getMAKTX() {
return MAKTX;
}
public void setMAKTX(String MAKTX) {
this.MAKTX = MAKTX;
}
public String getWERKS() {
return WERKS;
}
public void setWERKS(String WERKS) {
this.WERKS = WERKS;
}
public String getLGORT() {
return LGORT;
}
public void setLGORT(String LGORT) {
this.LGORT = LGORT;
}
public String getBDTER() {
return BDTER;
}
public void setBDTER(String BDTER) {
this.BDTER = BDTER;
}
public String getBDMNG() {
return BDMNG;
}
public void setBDMNG(String BDMNG) {
this.BDMNG = BDMNG;
}
public String getZQLSL() {
return ZQLSL;
}
public void setZQLSL(String ZQLSL) {
this.ZQLSL = ZQLSL;
}
public String getMEINS() {
return MEINS;
}
public void setMEINS(String MEINS) {
this.MEINS = MEINS;
}
public String getRGEKZ() {
return RGEKZ;
}
public void setRGEKZ(String RGEKZ) {
this.RGEKZ = RGEKZ;
}
public String getDBSKZ() {
return DBSKZ;
}
public void setDBSKZ(String DBSKZ) {
this.DBSKZ = DBSKZ;
}
}

@ -4,16 +4,20 @@ import com.op.system.api.domain.sap.SapBom;
import com.op.system.api.domain.sap.SapBomComponent;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface SapBomMapper {
/**
* BOM
*
* @param sapBom BOM
* @return
*/
List<SapBom> selectBaseBomByBomCode(String bomCode);
public int insertBaseBom(SapBom sapBom);
void insertBaseBomBatch(List<SapBom> sapBomList);
public int insertBasetBomComponent(SapBomComponent sapBomComponent);
}

@ -2,7 +2,10 @@ 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.SapBom;
public interface SapBomService {
public R bomSync();
SapBom getMaxRevisionBom(String STLNR);
}

@ -0,0 +1,17 @@
package com.op.sap.service;
import com.op.common.core.domain.R;
import java.util.List;
/**
* 20238
*/
public interface SapItemSyncService {
/**
*
* @return
*/
R itemSync();
}

@ -8,12 +8,38 @@ import com.op.system.api.model.SapProOrder;
import java.util.List;
/**
* 20238
*/
public interface SapOrderService {
/**
*
* @param sapProOrder
* @return
*/
R<List<SapProOrder>> shopOrderSync(SapProOrder sapProOrder);
/**
*
* @param sapCreateOrderList
* @return
*/
R<List<String>> SapCreateOrder(List<SapCreateOrder> sapCreateOrderList);
/**
*
* @param shopOrder
* @return
*/
R sapCloseOrder(String shopOrder);
/**
*
* @param sapRFW
* @return
*/
R sapRFWOrder(SapRFW sapRFW);
}

@ -0,0 +1,12 @@
package com.op.sap.service;
import com.op.common.core.domain.R;
public interface SapWorkCenterService {
R sapWorkCenterSync();
R sapSupplierSync();
R sapCustomSync();
}

@ -4,7 +4,11 @@ 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.exception.ServiceException;
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.core.web.domain.AjaxResult;
import com.op.sap.util.HandleEnum;
import com.op.system.api.domain.sap.SapBom;
import com.op.system.api.domain.sap.SapBomComponent;
import com.op.sap.mapper.SapBomComponentMapper;
@ -13,14 +17,15 @@ import com.op.sap.service.SapBomService;
import com.op.sap.util.SAPConnUtils;
import com.sap.conn.jco.*;
import org.apache.ibatis.session.ExecutorType;
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.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;
import java.util.*;
import java.util.stream.Collectors;
@Service
@ -32,6 +37,9 @@ public class SapBomServiceImpl implements SapBomService {
@Autowired
private SapBomComponentMapper sapBomComponentMapper;
@Autowired
private SqlSessionFactory sqlSessionFactory;
@Override
public R bomSync() {
@ -52,10 +60,10 @@ public class SapBomServiceImpl implements SapBomService {
// jCoTable.setValue(Constants.LOW, "00012222");
JCoTable jCoTables = func.getTableParameterList().getTable("S_MATNR");
jCoTables.appendRow();
jCoTables.setValue(Constants.SIGN, "I");
jCoTables.setValue(Constants.OPTION, "EQ");
jCoTables.setValue(Constants.LOW, "000000010101000115");
// jCoTables.appendRow();
// jCoTables.setValue(Constants.SIGN, "I");
// jCoTables.setValue(Constants.OPTION, "EQ");
// jCoTables.setValue(Constants.LOW, "000000010101000115");
JCoTable S_WERKS_jCoTables = func.getTableParameterList().getTable("S_WERKS");
S_WERKS_jCoTables.appendRow();
@ -68,15 +76,14 @@ public class SapBomServiceImpl implements SapBomService {
JCoTable maraTable = func.getTableParameterList().getTable("LT_BOM");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
SapBom sapBom = new SapBom();
SapBomComponent sapBomComponent=new SapBomComponent();
DynamicDataSourceContextHolder.push("op_xiaolan");
List<SapBom> sapBomList=new ArrayList<>();
List<SapBomComponent> sapBomComponentList=new ArrayList<>();
for (int i = 0; i < maraTable.getNumRows(); i++) {
maraTable.setRow(i);
String STLNR = maraTable.getString("STLNR");
if (STLNR == null || STLNR.equals("")){
throw new ServiceException("组件清单码为空");
}
String MATNR = maraTable.getString("MATNR");
String MAKTX = maraTable.getString("MAKTX");
String WERKS = maraTable.getString("WERKS");
@ -107,40 +114,59 @@ public class SapBomServiceImpl implements SapBomService {
String BEIKZ = maraTable.getString("BEIKZ");
String BEIKZ_NM = maraTable.getString("BEIKZ_NM");
String SANKA = maraTable.getString("SANKA");
System.out.println("物料编码:" + MATNR +
" - 物料名称:" + MAKTX + " - 工厂:" + WERKS +
" - 生产版本:" + VERID + " - BOM单号" + STLNR
+ " - 可选BOM" + STLAL + " - 创建日期:" + ANDAT + " - 创建者:" + ANNAM +
" - 修改日期:" + AEDAT + " - 修改者:" + AENAM
+ " - 生产版本有效期:" + ADATU + " - 生产版本截止日期:" + BDATU + " - BOM计算数量" + LOSGR +
" - BOM计算单位" + MEINS +
" - BOM基本数量" + BMENG + " - BOM基本单位" + BMEIN + " - BOM层次" + STUFE + " - 项目编号:" + WEGXX
+ " - 组件编码:" + PMATNR + " - 组件名称:" + PMAKTX + " - 组件上层物料名称:" + OJTXB
+ " - 标准用量:" + PMENGE + " - 损耗率:" + PAUSCH + " - 损耗额:" + PXHLCE + " - 含损耗用量:" + PMNGKO
+ " - 组件数量单位:" + PMEINS + " - 组件采购标志:" + PBESKZ + " - 物料供应标识:" + BEIKZ + " - 物料供应标识:" + BEIKZ_NM
+ " - 成本核算标识相关:" + SANKA);
// sapBom.setFactoryCode(WERKS);
// sapBom.setProductionVersion(VERID);
// sapBom.setBomCode(STLNR);
// sapBom.setOptionalBom(STLAL);
// sapBom.setPvvd(DateUtils.dateTime("yyyy-MM-dd", ADATU));
// sapBom.setPved(DateUtils.dateTime("yyyy-MM-dd", BDATU));
// sapBom.setBomCalculateNumber(new BigDecimal(LOSGR));
// sapBom.setBomCalculateUnit(MEINS);
// sapBom.setBomBaseNumber(new BigDecimal(BMENG));
// sapBom.setBomBaseUnit(BMEIN);
// sapBom.setComponentUnit(PMEINS);
// sapBom.setComponentProFlag(PBESKZ);
// sapBom.setCreateBy(ANNAM);
// // sapBom.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ANDAT));
// sapBom.setUpdateBy(AENAM);
// // sapBom.setUpdateTime(DateUtils.dateTime("yyyy-MM-dd", AEDAT));
String OJMBR = maraTable.getString("OJMBR");
if (!StringUtils.isEmpty(STLAL)){
System.out.println("物料编码:" + MATNR +
" - 物料名称:" + MAKTX + " - 工厂:" + WERKS +
" - 生产版本:" + VERID + " - BOM单号" + STLNR
+ " - 可选BOM" + STLAL + " - 创建日期:" + ANDAT + " - 创建者:" + ANNAM +
" - 修改日期:" + AEDAT + " - 修改者:" + AENAM
+ " - 生产版本有效期:" + ADATU + " - 生产版本截止日期:" + BDATU + " - BOM计算数量" + LOSGR +
" - BOM计算单位" + MEINS +
" - BOM基本数量" + BMENG + " - BOM基本单位" + BMEIN + " - BOM层次" + STUFE + " - 项目编号:" + WEGXX
+ " - 组件编码:" + PMATNR + " - 组件名称:" + PMAKTX + " - 组件上层物料编码:" + OJMBR+" - 组件上层物料名称:" + OJTXB
+ " - 标准用量:" + PMENGE + " - 损耗率:" + PAUSCH + " - 损耗额:" + PXHLCE + " - 含损耗用量:" + PMNGKO
+ " - 组件数量单位:" + PMEINS + " - 组件采购标志:" + PBESKZ + " - 物料供应标识:" + BEIKZ + " - 物料供应标识:" + BEIKZ_NM
+ " - 成本核算标识相关:" + SANKA);
}
//插入BOM表
//BomBO
/**
* BOM
*/
SapBom sapBom = new SapBom();
sapBom.setFactoryCode(WERKS);
sapBom.setProductionVersion(STLAL);
sapBom.setBomCode(STLNR);
sapBom.setCumc(OJMBR);
sapBom.setComponent(PMATNR);
sapBom.setOptionalBom(STLAL);
sapBom.setPvvd(DateUtils.dateTime("yyyy-MM-dd", ADATU));
sapBom.setPved(DateUtils.dateTime("yyyy-MM-dd", BDATU));
sapBom.setBomCalculateNumber(new BigDecimal(LOSGR));
sapBom.setBomCalculateUnit(MEINS);
sapBom.setBomBaseNumber(new BigDecimal(BMENG));
sapBom.setBomBaseUnit(BMEIN);
sapBom.setComponentUnit(PMEINS);
sapBom.setComponentProFlag(PBESKZ);
// sapBom.setCurrentVersion("");
sapBom.setCreateBy(ANNAM);
sapBom.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ANDAT));
sapBom.setUpdateBy(AENAM);
sapBom.setUpdateTime(DateUtils.dateTime("yyyy-MM-dd", AEDAT));
SapBomComponent sapBomComponent=new SapBomComponent();
sapBomComponent.setBomCode(STLNR);
sapBomComponent.setSite(WERKS);
sapBomComponent.setSite("1000");
sapBomComponent.setMsi(BEIKZ);
sapBomComponent.setSanka(SANKA);
sapBomComponent.setProductCode(MATNR);
sapBomComponent.setCumc(OJTXB);
sapBomComponent.setCumc(OJMBR);
sapBomComponent.setComponent(PMATNR);
sapBomComponent.setBomHierarchy(STUFE);
sapBomComponent.setProjectNo(WEGXX);
sapBomComponent.setStandardDosage(new BigDecimal(PMENGE));
@ -148,13 +174,13 @@ public class SapBomServiceImpl implements SapBomService {
sapBomComponent.setLossAmount(new BigDecimal(PXHLCE));
sapBomComponent.setCilosses(new BigDecimal(PMNGKO));
sapBomComponent.setCreateBy(ANNAM);
// sapBomComponent.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ANDAT));
sapBomComponent.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ANDAT));
sapBomComponent.setUpdateBy(AENAM);
// sapBomComponent.setUpdateTime(DateUtils.dateTime("yyyy-MM-dd", AEDAT));
// sapBomList.add(sapBom);
// sapBomComponentMapper.insertSapBomComponent(sapBomComponent);
sapBomComponent.setUpdateTime(DateUtils.dateTime("yyyy-MM-dd", AEDAT));
sapBomComponentList.add(sapBomComponent);
sapBomList.add(sapBom);
}
// inserBaseBom(sapBomList);
createBOM(sapBomList,sapBomComponentList);
return R.ok();
} catch (Exception e) {
return R.fail(e.getMessage());
@ -162,10 +188,65 @@ public class SapBomServiceImpl implements SapBomService {
}
}
public void inserBaseBom(List<SapBom> sapBomList){
sapBomList = sapBomList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SapBom::getBomCode))), ArrayList::new));
for (SapBom sapBom:sapBomList) {
sapBomMapper.insertBaseBom(sapBom);
@Override
public SapBom getMaxRevisionBom(String STLNR) {
List<SapBom> list = sapBomMapper.selectBaseBomByBomCode(STLNR);
if (list == null || list.size() <= 0) {
return null;
}
return list.get(0);
}
public void createBOM(List<SapBom> sapBomList,List<SapBomComponent> sapBomComponentList){
List<SapBom> newBomList = sapBomList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SapBom::getBomCode))), ArrayList::new));
if (newBomList.size()>0){
DynamicDataSourceContextHolder.push("ds_1000");
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH,false);
for (SapBom sapBom:newBomList) {
List<SapBomComponent> sapBomComponents;
//查询Bom号是否存在
SapBom bomModel = this.getMaxRevisionBom(sapBom.getBomCode());
//存在且版本号大于现有版本
if (bomModel!=null&&sapBom.getOptionalBom()!=null&&Float.parseFloat(sapBom.getOptionalBom())>Float.parseFloat(bomModel.getOptionalBom()))
{
//升级BOM
String bomBo = HandleEnum.BOM.getHandle(sapBom.getFactoryCode(),sapBom.getBomCode(),sapBom.getOptionalBom());
sapBom.setBomBo(bomBo);
//插入BOM表
sapBomMapper.insertBaseBom(sapBom);
//筛选组件清单
sapBomComponents = sapBomComponentList.stream().filter(sbc->
sbc.getBomCode().equals(sapBom.getBomCode())).collect(Collectors.toList());
//执行插入
sapBomComponents.stream().forEach(components -> {
components.setBomBo(bomBo);
sapBomComponentMapper.insertSapBomComponent(components);
});
}
else if (bomModel==null&&sapBom.getOptionalBom()!=null){
//插入初始BOM
String bomBo = HandleEnum.BOM.getHandle(sapBom.getFactoryCode(),sapBom.getBomCode(),sapBom.getOptionalBom());
sapBom.setBomBo(bomBo);
//插入BOM表
sapBomMapper.insertBaseBom(sapBom);
//筛选组件清单
sapBomComponents = sapBomComponentList.stream().filter(sbc->
sbc.getBomCode().equals(sapBom.getBomCode())).collect(Collectors.toList());
//执行插入
sapBomComponents.stream().forEach(components -> {
components.setBomBo(bomBo);
sapBomComponentMapper.insertSapBomComponent(components);
});
}
sqlSession.commit();
sqlSession.clearCache();
}
}
}

@ -0,0 +1,130 @@
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.sap.mapper.SapBaseProductMapper;
import com.op.sap.service.SapItemSyncService;
import com.op.sap.util.SAPConnUtils;
import com.op.system.api.domain.sap.SapBaseProduct;
import com.sap.conn.jco.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@Service
public class SapItemSyncImpl implements SapItemSyncService {
@Autowired
private SapBaseProductMapper sapBaseProductMapper;
@Override
public R itemSync() {
try {
// 获取调用 RFC 函数对象
//获取连接
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");
}
JCoTable jCoTables = func.getTableParameterList().getTable("S_MATNR");
System.out.println(jCoTables);
// jCoTables.appendRow();
// jCoTables.setValue(Constants.SIGN, "I");
// jCoTables.setValue(Constants.OPTION, "EQ");
// jCoTables.setValue(Constants.LOW, "000000010101000115");
// 获取调用 RFC 函数对象
func.execute(dest);
// 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("LT_MARA");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
DynamicDataSourceContextHolder.push("ds_1000");
for (int i = 0; i < maraTable.getNumRows(); i++) {
SapBaseProduct baseProduct = new SapBaseProduct();
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+
"物料描述(短文本):" + MAKTX+
"国际文件号(EAN/UPC)" + EAN11+
"物料类型:" + MTART+
"物料类型描述:" + MTBEZ+
"物料组:" + MATKL+
"物料组描述:" + WGBEZ+
"毛重:" + BRGEW+
"净重:" + NTGEW+
"体积:" + VOLUM+
"体积单位:" + VOLEH+
"基本计量单位:" + MEINS+
"帐面库存单位的可选计量单位 " + MEINH+
"基本计量单位转换分子:" + UMREZ+
"转换为基本计量单位的分母:" + UMREN+
"在客户级标记要删除的物料:" + LVORM+
"数量:" + MENGE+
"总货架寿命 " + MHDHB+
"产品组:" + SPART+
"产品组描述:" + SPART_NM+
"物料组1" + MVGR1+
"物料组1描述" + MVGR1_NM+
"物料组2" + MVGR2+
"物料组2描述" + MVGR2_NM+
" 物料组3" + MVGR3+
" 物料组描述 " + MVGR3_NM);
//查询物料存不存在
baseProduct.setProductCode(MATNR);
SapBaseProduct sapBaseProduct=sapBaseProductMapper.selectBaseProductByProductCode(baseProduct);
if (sapBaseProduct==null){
sapBaseProduct.setProductCode(MATNR);
sapBaseProduct.setProductDescZh(MAKTX);
// baseProduct.setProductean11(EAN11);
sapBaseProduct.setProductGroup(MATKL);
sapBaseProduct.setProductGroupName(WGBEZ);
sapBaseProduct.setGrossWeight(BRGEW);
sapBaseProduct.setNetWeight(NTGEW);
sapBaseProduct.setVolume(VOLUM);
sapBaseProduct.setDelFlag("0");
// sapBaseProductMapper.insertBaseProduct(sapBaseProduct);
}
}
return R.ok();
}catch (Exception e){
return R.fail(e.getMessage());
}
}
}

@ -0,0 +1,169 @@
package com.op.sap.service.impl;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.sap.service.SapWorkCenterService;
import com.op.sap.util.SAPConnUtils;
import com.op.system.api.domain.sap.SapWorkCenter;
import com.sap.conn.jco.*;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class SapWorkCenterServiceImpl implements SapWorkCenterService {
@Override
public R sapWorkCenterSync() {
try {
// 获取调用 RFC 函数对象
//获取连接
JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_GET_ARBPL");
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
// 配置传入参数
JCoTable jCoTable = func.getTableParameterList().getTable("S_WERKS");
// jCoTable.appendRow();
// jCoTable.setValue("SIGN", "I");
// jCoTable.setValue("OPTION", "EQ");
// jCoTable.setValue("LOW", "1000");
func.execute(dest);//执行调用函数
// 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("LT_ARBPL");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
List<SapWorkCenter> sapWorkCenterList=new ArrayList<>();
for (int i = 0; i <maraTable.getNumRows(); i++) {
maraTable.setRow(i);
SapWorkCenter sapWorkCenter=new SapWorkCenter();
String WERKS = maraTable.getString("WERKS");
String NAME1 = maraTable.getString("NAME1");
String ARBPL = maraTable.getString("ARBPL");
String KTEXT = maraTable.getString("KTEXT");
String AEDAT_GRND = maraTable.getString("AEDAT_GRND");
System.out.println(
"工厂:" + WERKS+
"工厂描述:" + NAME1+
"工作中心:" + ARBPL+
"工作中心描述 " + KTEXT+
"更新日期:" + AEDAT_GRND);
sapWorkCenter.setWeeks(WERKS);
sapWorkCenter.setName1(NAME1);
sapWorkCenter.setArbpl(ARBPL);
sapWorkCenter.setKtext(KTEXT);
sapWorkCenter.setAedat_grnd(DateUtils.dateTime("yyyy-MM-dd", AEDAT_GRND));
sapWorkCenterList.add(sapWorkCenter);
}
return R.ok(sapWorkCenterList);
}catch (Exception e){
return R.fail(e.getMessage());
}
}
@Override
public R sapSupplierSync() {
try {
// 获取调用 RFC 函数对象
//获取连接
JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_GET_LFB1");
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
// 配置传入参数
JCoTable jCoTable = func.getTableParameterList().getTable("S_BUKRS");
jCoTable.appendRow();
jCoTable.setValue("SIGN", "I");
jCoTable.setValue("OPTION", "EQ");
jCoTable.setValue("LOW", "1000");
func.execute(dest);//执行调用函数
// 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("LT_LIFNR");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
List<SapWorkCenter> sapWorkCenterList=new ArrayList<>();
for (int i = 0; i <maraTable.getNumRows(); i++) {
maraTable.setRow(i);
SapWorkCenter sapWorkCenter=new SapWorkCenter();
String BUKRS = maraTable.getString("BUKRS");
String LIFNR = maraTable.getString("LIFNR");
String NAME1 = maraTable.getString("NAME1");
String TELF1 = maraTable.getString("TELF1");
String STRAS = maraTable.getString("STRAS");
System.out.println(
"公司代码:" + BUKRS+
"供应商:" + LIFNR+
"供应商名称:" + NAME1+
"第一个电话号 " + TELF1+
"住宅号及街道:" + STRAS);
// sapWorkCenter.setWeeks(WERKS);
// sapWorkCenter.setName1(NAME1);
// sapWorkCenter.setArbpl(ARBPL);
// sapWorkCenter.setKtext(KTEXT);
// sapWorkCenter.setAedat_grnd(DateUtils.dateTime("yyyy-MM-dd", AEDAT_GRND));
// sapWorkCenterList.add(sapWorkCenter);
}
return R.ok(sapWorkCenterList);
}catch (Exception e){
return R.fail(e.getMessage());
}
}
@Override
public R sapCustomSync() {
try {
// 获取调用 RFC 函数对象
//获取连接
JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_GET_KNA1");
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
// 配置传入参数
JCoTable jCoTable = func.getTableParameterList().getTable("S_BUKRS");
jCoTable.appendRow();
jCoTable.setValue("SIGN", "I");
jCoTable.setValue("OPTION", "EQ");
jCoTable.setValue("LOW", "1000");
func.execute(dest);//执行调用函数
// 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("LT_KUNNR");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
List<SapWorkCenter> sapWorkCenterList=new ArrayList<>();
for (int i = 0; i <maraTable.getNumRows(); i++) {
maraTable.setRow(i);
SapWorkCenter sapWorkCenter=new SapWorkCenter();
String BUKRS = maraTable.getString("BUKRS");
String KUNNR = maraTable.getString("KUNNR");
String NAME1 = maraTable.getString("NAME1");
String TELF1 = maraTable.getString("TELF1");
String STRAS = maraTable.getString("STRAS");
String ERDAT = maraTable.getString("ERDAT");
System.out.println(
"公司代码:" + BUKRS+
"客户编号:" + KUNNR+
"客户名称:" + NAME1+
"第一个电话号 " + TELF1+
"住宅号及街道:" + STRAS+
"记录创建日期"+ERDAT);
// sapWorkCenter.setWeeks(WERKS);
// sapWorkCenter.setName1(NAME1);
// sapWorkCenter.setArbpl(ARBPL);
// sapWorkCenter.setKtext(KTEXT);
// sapWorkCenter.setAedat_grnd(DateUtils.dateTime("yyyy-MM-dd", AEDAT_GRND));
// sapWorkCenterList.add(sapWorkCenter);
}
return R.ok(sapWorkCenterList);
}catch (Exception e){
return R.fail(e.getMessage());
}
}
}

@ -0,0 +1,260 @@
package com.op.sap.util;
import java.text.MessageFormat;
/**
* HANDLE
*
* @author Ervin Chen
* @date 2020/2/5 14:50
*/
public enum HandleEnum {
/**
*
*/
SFC("SFCBO:", "SFCBO:{0},{1}"),
/**
*
**/
USER("UserBO:", "UserBO:{0},{1}"),
/**
*
**/
BOM("BOMBO:", "BOMBO:{0},{1},{2}"),
PRINT("PrintBO:", "PrintBO:{0},{1}"),
/**
*
**/
CALL_ITEM("CallItemBO:", "CallItemBO:{0},{1}"),
/**
*
*/
SHOP_ORDER("ShopOrderBO:", "ShopOrderBO:{0},{1}"),
/**
*
*/
SFC_BOM("SFCBOMBO:", "SFCBOMBO:{0}"),
SFC_DATA("SFCDataBO:", "SFCDataBO:{0},{1}"),
/**
*
*/
ITEM("ItemBO:", "ItemBO:{0},{1},{2}"),
/**
*
*/
RESOURCE("ResourceBO:", "ResourceBO:{0},{1}"),
/**
*
**/
STATUS("StatusBO:", "StatusBO:{0},{1}"),
/**
*
**/
RESOURCE_TYPE("ResourceTypeBO:", "ResourceTypeBO:{0},{1}"),
/****/
RESOURCE_TYPE_RESOURCEBO("ResourceTypeResourceBO", "ResourceTypeResourceBO:{0},{1}"),
/**
* 线
*/
ROUTER("RouterBO:", "RouterBO:{0},{1},{2},{3}"),
ROUTER_OPERATION("RouterOperationBO:", "RouterOperationBO:RouterStepBO:{0},{1}"),
/**
* 线
**/
ROUTER_STEP("RouterStepBO:", "RouterStepBO:{0},{1},{2},{3},{4}"),
/**
*
*/
INVENTORY("InventoryBO:", "InventoryBO:{0},{1}"),
/**
*
*/
ITEM_GROUP("ItemGroupBO:", "ItemGroupBO:{0},{1}"),
/**
*
*/
DATA_FIELD("DataFieldBO:", "DataFieldBO:{0},{1}"),
/**
*
*/
NEXT_NUMBER("NextNumberBO:", "NextNumberBO:{0},{1}"),
/**
*
*/
OPERATION("OperationBO:", "OperationBO:{0},{1},{2}"),
/**
*
**/
WORK_CENTER("WorkCenterBO:", "WorkCenterBO:{0},{1}"),
/****/
SFC_DISPATCH("SfcDispatchBO:", "SfcDispatchBO:{0},{1}"),
/**
*
*/
INSPECTION_ITEM("InspectionItemBO:", "InspectionItemBO:{0},{1},{2}"),
/**
*
*/
NEXT_NUMBER_CODE("NextNumberCodeBO:", "NextNumberCodeBO:{0},{1},{2}"),
/**
*
**/
RESOURCE_INSPECT_PLAN("ResourceInspectPlanBo", "ResourceInspectPlanBo:{0},{1},{2}"),
/**
* ,HANDLE,HANDLE
**/
RESOURCE_INSPECT_RESOURCE("ResourceInspectResourceBo", "ResourceInspectResourceBo:{0},{1},{2}"),
/**
*
**/
RESOURCE_INSPECT_TASK("ResourceInspectTaskBo", "ResourceInspectTaskBo:{0},{1}"),
/**
*
**/
SPLIT_SFC("SplitSfcBo", "SplitSfcBo:{0},{1}"),
/**
*
**/
RESOURCE_REPAIR_TASK("ResourceRepairTaskBo", "ResourceRepairTaskBo:{0},{1}"),
/**
*
**/
ITEM_BATCH("ItemBatchBo", "ItemBatchBo:{0},{1},{2}"),
/**
*
**/
PROD_READY_TASK("ProdReadyTaskBO", "ProdReadyTaskBO:{0},{1}"),
/**
*
**/
PROD_READY_TASK_DETAIL("ProdReadyTaskDetailBO", "ProdReadyTaskDetailBO:{0},{1}"),
/**
*
**/
RESOURCE_INSPECT_TASK_PARAM("ResourceInspectTaskParamBo", "ResourceInspectTaskParamBo:{0},{1}"),
/**
*
**/
ABNORMAL_BILL("AbnormalBillBo", "AbnormalBillBo:{0},{1}"),
/**
*
**/
ABNORMAL_BILL_DISPOSE("AbnormalBillDisposeBo", "AbnormalBillDisposeBo:{0},{1}"),
/**
*
**/
NC_CODE("NCCodeBO", "NCCodeBO:{0},{1}"),
/**
*
**/
NC_GROUP("NCGroupBO", "NCGroupBO:{0},{1}"),
/**
*
**/
DATA_TYPE("DataTypeBO", "DataTypeBO:{0},{1},{2}"),
/**
*
**/
RESOURCE_INSPECT_TASK_SPARE("ResourceInspectTaskSpareBo", "ResourceInspectTaskSpareBo:{0},{1}"),
/**
*
**/
INSPECTION_TASK("InspectionBO:", "InspectionBO:{0},{1}"),
/**
*
**/
INSPECTION_TASK_DETAIL("InspectionTaskDetailBO:", "InspectionTaskDetailBO:{0},{1}"),
/**
*
**/
SELF_REPORT("SelfReportBO:", "SelfReportBO:{0},{1}"),
/**
*
**/
LOAD_INVENTORY("LoadInventoryBO:", "LoadInventoryBO:{0},{1}"),
/**
*
**/
USR("UserBO", "UserBO:{0},{1}"),
TOOL("ToolBO", "ToolBO:{0},{1}"),
USER_RESOURCE("UserResourceBo", "UserResourceBo:{0},{1},{2}"),
SFC_SCRAP("SfcScrapBo", "SfcScrapBo:{0},{1}"),
ABNORMAL_PLAN("AbnormalPlanBo", "AbnormalPlanBo:{0},{1}");
private String prefix;
private String pattern;
HandleEnum(String prefix, String pattern) {
this.prefix = prefix;
this.pattern = pattern;
}
public String getHandle(String... parts) {
return MessageFormat.format(pattern, parts);
}
public String getPart(String handle, int position) {
String handleParts = handle.replace(prefix, "");
String[] parts = handleParts.split(",");
if (position >= parts.length) {
return null;
} else {
return parts[position];
}
}
public String getPrefix() {
return prefix;
}
}

@ -14,12 +14,12 @@ spring:
nacos:
discovery:
namespace: lanju-op
group: zxl
group: ywl
# 服务注册地址
server-addr: 140.249.53.142:8848
config:
namespace: lanju-op
group: zxl
group: ywl
#命名空间
#group: local
# 配置中心地址

@ -68,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into base_bom_component
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="bomBo != null">bom_bo,</if>
<if test="bomCode != null and bomCode != ''">bom_code,</if>
<if test="site != null">site,</if>
<if test="productCode != null">product_code,</if>
@ -94,6 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="bomBo != null">#{bomBo},</if>
<if test="bomCode != null and bomCode != ''">#{bomCode},</if>
<if test="site != null">#{site},</if>
<if test="productCode != null">#{productCode},</if>

@ -60,14 +60,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectBaseBomByFactoryCode" parameterType="String" resultMap="BaseBomResult">
<select id="selectBaseBomByBomCode" parameterType="String" resultMap="BaseBomResult">
<include refid="selectBaseBomVo"/>
where factory_code = #{factoryCode}
where bom_code = #{bomCode}
order by production_version desc
</select>
<insert id="insertBaseBom" parameterType="com.op.system.api.domain.sap.SapBom">
insert into base_bom
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="bomBo != null">bom_bo,</if>
<if test="factoryCode != null">factory_code,</if>
<if test="productionVersion != null">production_version,</if>
<if test="bomCode != null">bom_code,</if>
@ -94,6 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="currentVersion != null">current_version,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bomBo != null">#{bomBo},</if>
<if test="factoryCode != null">#{factoryCode},</if>
<if test="productionVersion != null">#{productionVersion},</if>
<if test="bomCode != null">#{bomCode},</if>
@ -120,6 +123,64 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="currentVersion != null">#{currentVersion},</if>
</trim>
</insert>
<insert id="insertBaseBomBatch">
insert into base_bom
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="item.bomBo != null">bom_bo,</if>
<if test="item.factoryCode != null">factory_code,</if>
<if test="item.productionVersion != null">production_version,</if>
<if test="item.bomCode != null">bom_code,</if>
<if test="item.optionalBom != null">optional_bom,</if>
<if test="item.optionalBomText != null">optional_bom_text,</if>
<if test="item.pvvd != null">pvvd,</if>
<if test="item.pved != null">pved,</if>
<if test="item.bomCalculateNumber != null">bom_calculate_number,</if>
<if test="item.bomCalculateUnit != null">bom_calculate_unit,</if>
<if test="item.bomBaseNumber != null">bom_base_number,</if>
<if test="item.bomBaseUnit != null">bom_base_unit,</if>
<if test="item.componentUnit != null">component_unit,</if>
<if test="item.componentProFlag != null">component_pro_flag,</if>
<if test="item.msi != null">msi,</if>
<if test="item.sanka != null">sanka,</if>
<if test="item.attr1 != null">attr1,</if>
<if test="item.attr2 != null">attr2,</if>
<if test="item.attr3 != null">attr3,</if>
<if test="item.createBy != null">create_by,</if>
<if test="item.createTime != null">create_time,</if>
<if test="item.updateBy != null">update_by,</if>
<if test="item.updateTime != null">update_time,</if>
<if test="item.remark != null">remark,</if>
<if test="item.currentVersion != null">current_version,</if>
</trim>
VALUES
<foreach collection="list" index="index" item="item" separator=",">
<if test="item.bomBo != null">#{bomBo},</if>
<if test="item.factoryCode != null">#{factoryCode},</if>
<if test="item.productionVersion != null">#{productionVersion},</if>
<if test="item.bomCode != null">#{bomCode},</if>
<if test="item.optionalBom != null">#{optionalBom},</if>
<if test="item.optionalBomText != null">#{optionalBomText},</if>
<if test="item.pvvd != null">#{pvvd},</if>
<if test="item.pved != null">#{pved},</if>
<if test="item.bomCalculateNumber != null">#{bomCalculateNumber},</if>
<if test="item.bomCalculateUnit != null">#{bomCalculateUnit},</if>
<if test="item.bomBaseNumber != null">#{bomBaseNumber},</if>
<if test="item.bomBaseUnit != null">#{bomBaseUnit},</if>
<if test="item.componentUnit != null">#{componentUnit},</if>
<if test="item.componentProFlag != null">#{componentProFlag},</if>
<if test="item.msi != null">#{msi},</if>
<if test="item.sanka != null">#{sanka},</if>
<if test="item.attr1 != null">#{attr1},</if>
<if test="item.attr2 != null">#{attr2},</if>
<if test="item.attr3 != null">#{attr3},</if>
<if test="item.createBy != null">#{createBy},</if>
<if test="item.createTime != null">#{createTime},</if>
<if test="item.updateBy != null">#{updateBy},</if>
<if test="item.updateTime != null">#{updateTime},</if>
<if test="item.remark != null">#{remark},</if>
<if test="item.currentVersion != null">#{currentVersion},</if>
</foreach>
</insert>
<update id="updateBaseBom" parameterType="com.op.system.api.domain.sap.SapBom">
update base_bom

Loading…
Cancel
Save