|
|
|
@ -1,937 +0,0 @@
|
|
|
|
|
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.*;
|
|
|
|
|
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<SapProOrder> 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<SapProOrder> 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<Boolean> 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<SapProOrder> 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<SapBaseProduct> 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<Boolean> 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<SapProOrder> 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<Boolean> 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<SapProRoute> proRouteList = new ArrayList<>();
|
|
|
|
|
// for (int i = 0; i <maraTable.getNumRows(); i++) {
|
|
|
|
|
// SapProRoute proRoute = new SapProRoute();
|
|
|
|
|
// maraTable.setRow(i);
|
|
|
|
|
// String WERKS = maraTable.getString("WERKS");
|
|
|
|
|
// String PLNTY = maraTable.getString("PLNTY");
|
|
|
|
|
// String PLNNR = maraTable.getString("PLNNR");
|
|
|
|
|
// String PLNAL = maraTable.getString("PLNAL");
|
|
|
|
|
// String LOEKZ = maraTable.getString("LOEKZ");
|
|
|
|
|
// String MATNR = maraTable.getString("MATNR");
|
|
|
|
|
// String MAKTX = maraTable.getString("MAKTX");
|
|
|
|
|
// String VERWE = maraTable.getString("VERWE");
|
|
|
|
|
// String STATU = maraTable.getString("STATU");
|
|
|
|
|
// String LOSVN = maraTable.getString("LOSVN");
|
|
|
|
|
// String LOSBS = maraTable.getString("LOSBS");
|
|
|
|
|
// String KTEXT = maraTable.getString("KTEXT");
|
|
|
|
|
// String VORNR = maraTable.getString("VORNR");
|
|
|
|
|
// String STEUS = maraTable.getString("STEUS");
|
|
|
|
|
// String KTSCH = maraTable.getString("KTSCH");
|
|
|
|
|
// String LTXA1 = maraTable.getString("LTXA1");
|
|
|
|
|
// String ANDAT = maraTable.getString("ANDAT");
|
|
|
|
|
// String ANNAM = maraTable.getString("ANNAM");
|
|
|
|
|
// String AEDAT = maraTable.getString("AEDAT");
|
|
|
|
|
// String AENAM = maraTable.getString("AENAM");
|
|
|
|
|
// String ARBPL = maraTable.getString("ARBPL");
|
|
|
|
|
// String UMREN = maraTable.getString("UMREN");
|
|
|
|
|
// String UMREZ = maraTable.getString("UMREZ");
|
|
|
|
|
// String BMSCH = maraTable.getString("BMSCH");
|
|
|
|
|
// String MEINH = maraTable.getString("MEINH");
|
|
|
|
|
// String LAR01 = maraTable.getString("LAR01");
|
|
|
|
|
// String VGW01 = maraTable.getString("VGW01");
|
|
|
|
|
// String VGE01 = maraTable.getString("VGE01");
|
|
|
|
|
// String VGW02 = maraTable.getString("VGW02");
|
|
|
|
|
// String VGE02 = maraTable.getString("VGE02");
|
|
|
|
|
// String VGW03 = maraTable.getString("VGW03");
|
|
|
|
|
// String VGE03 = maraTable.getString("VGE03");
|
|
|
|
|
// String VGW04 = maraTable.getString("VGW04");
|
|
|
|
|
// String VGE04 = maraTable.getString("VGE04");
|
|
|
|
|
// String VGW05 = maraTable.getString("VGW05");
|
|
|
|
|
// String VGE05 = maraTable.getString("VGE05");
|
|
|
|
|
// String VGW06 = maraTable.getString("VGW06");
|
|
|
|
|
// String VGE06 = maraTable.getString("VGE06");
|
|
|
|
|
// String UEMUS = maraTable.getString("UEMUS");
|
|
|
|
|
// String UEKAN = maraTable.getString("UEKAN");
|
|
|
|
|
// String FLIES = maraTable.getString("FLIES");
|
|
|
|
|
// String SPMUS = maraTable.getString("SPMUS");
|
|
|
|
|
// String SPLIM = maraTable.getString("SPLIM");
|
|
|
|
|
// String CKSELKZ = maraTable.getString("CKSELKZ");
|
|
|
|
|
// proRoute.setRouteId(UUID.randomUUID().toString().replaceAll("-",""));
|
|
|
|
|
// proRoute.setRouteCode(PLNNR);
|
|
|
|
|
// proRoute.setRouteName(KTEXT);
|
|
|
|
|
// proRoute.setCreateBy(ANNAM);
|
|
|
|
|
// proRoute.setRouteDesc(KTEXT);
|
|
|
|
|
// proRoute.setEnableFlag("Y");
|
|
|
|
|
// proRoute.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ANDAT));
|
|
|
|
|
// if (proRoute.getRouteName().isEmpty()){
|
|
|
|
|
// proRoute.setRouteName("无");
|
|
|
|
|
// }
|
|
|
|
|
// proRouteList.add(i,proRoute);
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// proRouteList = proRouteList.stream().collect(Collectors.collectingAndThen
|
|
|
|
|
// (Collectors.toCollection(() ->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<Boolean> 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<SapProRoute> proRouteList = new ArrayList<>();
|
|
|
|
|
// List<SapProRouteProduct> proRouteProductList = new ArrayList<>();
|
|
|
|
|
// for (int i = 0; i <maraTable.getNumRows(); i++) {
|
|
|
|
|
// SapProRouteProduct proRouteProduct = new SapProRouteProduct();
|
|
|
|
|
// SapProRoute proRoute = new SapProRoute();
|
|
|
|
|
// maraTable.setRow(i);
|
|
|
|
|
// String WERKS = maraTable.getString("WERKS");
|
|
|
|
|
// String PLNTY = maraTable.getString("PLNTY");
|
|
|
|
|
// String PLNNR = maraTable.getString("PLNNR");
|
|
|
|
|
// String PLNAL = maraTable.getString("PLNAL");
|
|
|
|
|
// String LOEKZ = maraTable.getString("LOEKZ");
|
|
|
|
|
// String MATNR = maraTable.getString("MATNR");
|
|
|
|
|
// String MAKTX = maraTable.getString("MAKTX");
|
|
|
|
|
// String VERWE = maraTable.getString("VERWE");
|
|
|
|
|
// String STATU = maraTable.getString("STATU");
|
|
|
|
|
// String LOSVN = maraTable.getString("LOSVN");
|
|
|
|
|
// String LOSBS = maraTable.getString("LOSBS");
|
|
|
|
|
// String KTEXT = maraTable.getString("KTEXT");
|
|
|
|
|
// String VORNR = maraTable.getString("VORNR");
|
|
|
|
|
// String STEUS = maraTable.getString("STEUS");
|
|
|
|
|
// String KTSCH = maraTable.getString("KTSCH");
|
|
|
|
|
// String LTXA1 = maraTable.getString("LTXA1");
|
|
|
|
|
// String ANDAT = maraTable.getString("ANDAT");
|
|
|
|
|
// String ANNAM = maraTable.getString("ANNAM");
|
|
|
|
|
// String AEDAT = maraTable.getString("AEDAT");
|
|
|
|
|
// String AENAM = maraTable.getString("AENAM");
|
|
|
|
|
// String ARBPL = maraTable.getString("ARBPL");
|
|
|
|
|
// String UMREN = maraTable.getString("UMREN");
|
|
|
|
|
// String UMREZ = maraTable.getString("UMREZ");
|
|
|
|
|
// String BMSCH = maraTable.getString("BMSCH");
|
|
|
|
|
// String MEINH = maraTable.getString("MEINH");
|
|
|
|
|
// String LAR01 = maraTable.getString("LAR01");
|
|
|
|
|
// String VGW01 = maraTable.getString("VGW01");
|
|
|
|
|
// String VGE01 = maraTable.getString("VGE01");
|
|
|
|
|
// String VGW02 = maraTable.getString("VGW02");
|
|
|
|
|
// String VGE02 = maraTable.getString("VGE02");
|
|
|
|
|
// String VGW03 = maraTable.getString("VGW03");
|
|
|
|
|
// String VGE03 = maraTable.getString("VGE03");
|
|
|
|
|
// String VGW04 = maraTable.getString("VGW04");
|
|
|
|
|
// String VGE04 = maraTable.getString("VGE04");
|
|
|
|
|
// String VGW05 = maraTable.getString("VGW05");
|
|
|
|
|
// String VGE05 = maraTable.getString("VGE05");
|
|
|
|
|
// String VGW06 = maraTable.getString("VGW06");
|
|
|
|
|
// String VGE06 = maraTable.getString("VGE06");
|
|
|
|
|
// String UEMUS = maraTable.getString("UEMUS");
|
|
|
|
|
// String UEKAN = maraTable.getString("UEKAN");
|
|
|
|
|
// String FLIES = maraTable.getString("FLIES");
|
|
|
|
|
// String SPMUS = maraTable.getString("SPMUS");
|
|
|
|
|
// String SPLIM = maraTable.getString("SPLIM");
|
|
|
|
|
// String CKSELKZ = maraTable.getString("CKSELKZ");
|
|
|
|
|
// proRoute.setRouteCode(PLNNR);
|
|
|
|
|
// proRoute.setRouteName(KTEXT);
|
|
|
|
|
// proRoute.setCreateBy(ANNAM);
|
|
|
|
|
// proRoute.setRouteDesc(KTEXT);
|
|
|
|
|
// proRoute.setRouteId(UUID.randomUUID().toString().replaceAll("-",""));
|
|
|
|
|
// proRoute.setEnableFlag("Y");
|
|
|
|
|
// if (proRoute.getRouteName().isEmpty()){
|
|
|
|
|
// proRoute.setRouteName("无");
|
|
|
|
|
// }
|
|
|
|
|
// proRouteList.add(i,proRoute);
|
|
|
|
|
// proRouteProduct.setRecordId(UUID.randomUUID().toString().replace("-",""));
|
|
|
|
|
// proRouteProduct.setItemCode(MATNR);
|
|
|
|
|
// proRouteProduct.setItemName(MAKTX);
|
|
|
|
|
// proRouteProduct.setRouteId(proRouteList.get(i).getRouteId());
|
|
|
|
|
// proRouteProductList.add(i,proRouteProduct);
|
|
|
|
|
// }
|
|
|
|
|
// //根据routecode去重
|
|
|
|
|
// proRouteList = proRouteList.stream().collect(Collectors.collectingAndThen
|
|
|
|
|
// (Collectors.toCollection(() ->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 <proRouteList.size(); i++) {sapProRouteMapper.insertProRoute(proRouteList.get(i));}
|
|
|
|
|
// for (int j=0; j<proRouteProductList.size(); j++) {
|
|
|
|
|
// //item_id为空时不插入
|
|
|
|
|
// if (!sapBaseProductMapper.selectBaseProductIDByProductCode(proRouteProductList.get(j).getItemCode()).isEmpty()){
|
|
|
|
|
// proRouteProductList.get(j).setItemId
|
|
|
|
|
// (sapBaseProductMapper.selectBaseProductIDByProductCode(proRouteProductList.get(j).getItemCode()));
|
|
|
|
|
// sapProRouteProductMapper.insertProRouteProduct(proRouteProductList.get(j));
|
|
|
|
|
// }}
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// catch (Exception e){
|
|
|
|
|
// return R.fail(e.getMessage());
|
|
|
|
|
// }
|
|
|
|
|
// return R.ok();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public R<Boolean> 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());
|
|
|
|
|
Map<String,SapProRoute> mapProRoute = new IdentityHashMap<String,SapProRoute>();
|
|
|
|
|
Map<String,SapProProcess> mapProProcess = new IdentityHashMap<String,SapProProcess>();
|
|
|
|
|
Map<String,SapProRouteProcess> mapProRouteProcessNew = new IdentityHashMap<String,SapProRouteProcess>();
|
|
|
|
|
Map<String,SapProRouteProcess> mapProRouteProcessOld = new IdentityHashMap<String,SapProRouteProcess>();
|
|
|
|
|
List<SapProProcess> proProcessList = new ArrayList<>();
|
|
|
|
|
List<SapProRouteProcess> proRouteProcessList = new ArrayList<>();
|
|
|
|
|
List<SapProProcessContent> proProcessContentList = new ArrayList<>();
|
|
|
|
|
List<SapProRoute> proRouteList = new ArrayList();
|
|
|
|
|
Set<String> set = new HashSet<>();
|
|
|
|
|
for (int i = 0,arr1=0,arr2=0; i <maraTable.getNumRows(); i++) {
|
|
|
|
|
SapProProcess proProcess = new SapProProcess();
|
|
|
|
|
SapProRouteProcess proRouteProcessNew = new SapProRouteProcess();
|
|
|
|
|
SapProRouteProcess proRouteProcessOld = new SapProRouteProcess();
|
|
|
|
|
SapProProcessContent proProcessContent = new SapProProcessContent();
|
|
|
|
|
SapProRoute proRoute = new SapProRoute();
|
|
|
|
|
maraTable.setRow(i);
|
|
|
|
|
// System.out.println(i);
|
|
|
|
|
String WERKS = maraTable.getString("WERKS");
|
|
|
|
|
String PLNTY = maraTable.getString("PLNTY");
|
|
|
|
|
String PLNNR = maraTable.getString("PLNNR");
|
|
|
|
|
String PLNAL = maraTable.getString("PLNAL");
|
|
|
|
|
String LOEKZ = maraTable.getString("LOEKZ");
|
|
|
|
|
String MATNR = maraTable.getString("MATNR");
|
|
|
|
|
String MAKTX = maraTable.getString("MAKTX");
|
|
|
|
|
String VERWE = maraTable.getString("VERWE");
|
|
|
|
|
String STATU = maraTable.getString("STATU");
|
|
|
|
|
String LOSVN = maraTable.getString("LOSVN");
|
|
|
|
|
String LOSBS = maraTable.getString("LOSBS");
|
|
|
|
|
String KTEXT = maraTable.getString("KTEXT");
|
|
|
|
|
String VORNR = maraTable.getString("VORNR");
|
|
|
|
|
String STEUS = maraTable.getString("STEUS");
|
|
|
|
|
String KTSCH = maraTable.getString("KTSCH");
|
|
|
|
|
String LTXA1 = maraTable.getString("LTXA1");
|
|
|
|
|
String ANDAT = maraTable.getString("ANDAT");
|
|
|
|
|
String ANNAM = maraTable.getString("ANNAM");
|
|
|
|
|
String AEDAT = maraTable.getString("AEDAT");
|
|
|
|
|
String AENAM = maraTable.getString("AENAM");
|
|
|
|
|
String ARBPL = maraTable.getString("ARBPL");
|
|
|
|
|
String UMREN = maraTable.getString("UMREN");
|
|
|
|
|
String UMREZ = maraTable.getString("UMREZ");
|
|
|
|
|
String BMSCH = maraTable.getString("BMSCH");
|
|
|
|
|
String MEINH = maraTable.getString("MEINH");
|
|
|
|
|
String LAR01 = maraTable.getString("LAR01");
|
|
|
|
|
String VGW01 = maraTable.getString("VGW01");
|
|
|
|
|
String VGE01 = maraTable.getString("VGE01");
|
|
|
|
|
String VGW02 = maraTable.getString("VGW02");
|
|
|
|
|
String VGE02 = maraTable.getString("VGE02");
|
|
|
|
|
String VGW03 = maraTable.getString("VGW03");
|
|
|
|
|
String VGE03 = maraTable.getString("VGE03");
|
|
|
|
|
String VGW04 = maraTable.getString("VGW04");
|
|
|
|
|
String VGE04 = maraTable.getString("VGE04");
|
|
|
|
|
String VGW05 = maraTable.getString("VGW05");
|
|
|
|
|
String VGE05 = maraTable.getString("VGE05");
|
|
|
|
|
String VGW06 = maraTable.getString("VGW06");
|
|
|
|
|
String VGE06 = maraTable.getString("VGE06");
|
|
|
|
|
String UEMUS = maraTable.getString("UEMUS");
|
|
|
|
|
String UEKAN = maraTable.getString("UEKAN");
|
|
|
|
|
String FLIES = maraTable.getString("FLIES");
|
|
|
|
|
String SPMUS = maraTable.getString("SPMUS");
|
|
|
|
|
String SPLIM = maraTable.getString("SPLIM");
|
|
|
|
|
String CKSELKZ = maraTable.getString("CKSELKZ");
|
|
|
|
|
//根据工厂切换数据源
|
|
|
|
|
// String pre = "ds_";
|
|
|
|
|
// String werks = pre+WERKS;
|
|
|
|
|
// String url = sapSysUserMapper.getPoolName(werks);
|
|
|
|
|
set.add(WERKS);
|
|
|
|
|
// if (url.isEmpty()){
|
|
|
|
|
// System.out.println("当前无工厂");
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// String[] split = url.split("=");
|
|
|
|
|
// System.out.println(split[1]);
|
|
|
|
|
|
|
|
|
|
// DynamicDataSourceContextHolder.push(split[1]);
|
|
|
|
|
// DynamicDataSourceContextHolder.push(werks);
|
|
|
|
|
|
|
|
|
|
// System.out.println(DynamicDataSourceContextHolder.peek());
|
|
|
|
|
|
|
|
|
|
proRoute.setRouteCode(PLNNR);
|
|
|
|
|
proRoute.setRouteName(KTEXT);
|
|
|
|
|
proRoute.setCreateBy(ANNAM);
|
|
|
|
|
proRoute.setRouteDesc(KTEXT);
|
|
|
|
|
proRoute.setTecMan(VGW01);
|
|
|
|
|
proRoute.setTecManUnit(VGE01);
|
|
|
|
|
proRoute.setTecMachine(VGW02);
|
|
|
|
|
proRoute.setTecMachineUnit(VGE02);
|
|
|
|
|
proRoute.setTecDepreciation(VGW03);
|
|
|
|
|
proRoute.setTecDepreciationUnit(VGE03);
|
|
|
|
|
proRoute.setTecOther(VGW04);
|
|
|
|
|
proRoute.setTecOtherUnit(VGE04);
|
|
|
|
|
proRoute.setTecConfAcivity5(VGW05);
|
|
|
|
|
proRoute.setTecConfAcivity5Unit(VGE05);
|
|
|
|
|
proRoute.setTecConfAcivity6(VGW06);
|
|
|
|
|
proRoute.setTecConfAcivity6Unit(VGE06);
|
|
|
|
|
proRoute.setAttr1(Integer.valueOf(i).toString());
|
|
|
|
|
proRoute.setRouteId(UUID.randomUUID().toString().replaceAll("-",""));
|
|
|
|
|
proRoute.setEnableFlag("Y");
|
|
|
|
|
|
|
|
|
|
if (proRoute.getRouteName().isEmpty()){
|
|
|
|
|
proRoute.setRouteName("无");
|
|
|
|
|
}
|
|
|
|
|
mapProRoute.put(WERKS,proRoute);
|
|
|
|
|
proRouteList.add(i,proRoute);
|
|
|
|
|
// if (proRoute.getRouteName()!="无"){
|
|
|
|
|
// {
|
|
|
|
|
//// System.out.println(sapProRouteMapper.selectProRouteByRouteCode(value.getRouteCode()));
|
|
|
|
|
// if (sapProRouteMapper.selectProRouteByRouteCode(proRoute.getRouteCode())==0){
|
|
|
|
|
// proRoute.setRouteId(UUID.randomUUID().toString().replaceAll("-",""));
|
|
|
|
|
// arr1 = 1;
|
|
|
|
|
// }
|
|
|
|
|
// else{
|
|
|
|
|
// arr1=0;
|
|
|
|
|
// }
|
|
|
|
|
// }}
|
|
|
|
|
|
|
|
|
|
proProcess.setProcessId(UUID.randomUUID().toString().replaceAll("-",""));
|
|
|
|
|
proProcess.setProcessName(LTXA1);
|
|
|
|
|
proProcess.setProcessCode(LTXA1);
|
|
|
|
|
proProcess.setAttention(LTXA1);
|
|
|
|
|
proProcess.setEnableFlag("Y");
|
|
|
|
|
proProcess.setWorkCenter(ARBPL);
|
|
|
|
|
proProcess.setAttr1(Integer.valueOf(i).toString());
|
|
|
|
|
proProcess.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ANDAT));
|
|
|
|
|
proProcess.setCreateBy(ANNAM);
|
|
|
|
|
proProcess.setUpdateBy(AENAM);
|
|
|
|
|
mapProProcess.put(WERKS,proProcess);
|
|
|
|
|
proProcessList.add(i,proProcess);
|
|
|
|
|
// if (proProcess.getProcessCode()!=null){
|
|
|
|
|
// if (sapProProcessMapper.selectProProcessByProcessName(proProcess.getProcessName())==0){
|
|
|
|
|
// proProcess.setProcessId(UUID.randomUUID().toString().replaceAll("-",""));
|
|
|
|
|
// arr2 = 1;
|
|
|
|
|
// }
|
|
|
|
|
// else{
|
|
|
|
|
// arr2 = 0;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
proRouteProcessNew.setRouteId(proRoute.getRouteId());
|
|
|
|
|
proRouteProcessNew.setProcessId(proProcess.getProcessId());
|
|
|
|
|
proRouteProcessNew.setAttr1(Integer.valueOf(i).toString());
|
|
|
|
|
proRouteProcessNew.setProcessCode(proProcess.getProcessCode());
|
|
|
|
|
proRouteProcessNew.setProcessName(proProcess.getProcessName());
|
|
|
|
|
proRouteProcessNew.setOrderNum(1);
|
|
|
|
|
proRouteProcessNew.setCreateTime(DateUtils.dateTime(("yyyy-MM-dd"),ANDAT));
|
|
|
|
|
proRouteProcessNew.setCreateBy(ANNAM);
|
|
|
|
|
proRouteProcessNew.setUpdateBy(AENAM);
|
|
|
|
|
|
|
|
|
|
proRouteProcessNew.setRecordId(UUID.randomUUID().toString().replace("-",""));
|
|
|
|
|
|
|
|
|
|
mapProRouteProcessNew.put(WERKS,proRouteProcessNew);
|
|
|
|
|
proRouteProcessOld.setProcessCode(proProcess.getProcessCode());
|
|
|
|
|
proRouteProcessOld.setProcessName(proProcess.getProcessName());
|
|
|
|
|
proRouteProcessOld.setOrderNum(1);
|
|
|
|
|
proRouteProcessOld.setCreateTime(DateUtils.dateTime(("yyyy-MM-dd"),ANDAT));
|
|
|
|
|
|
|
|
|
|
proRouteProcessOld.setCreateBy(ANNAM);
|
|
|
|
|
proRouteProcessOld.setUpdateBy(AENAM);
|
|
|
|
|
mapProRouteProcessOld.put(WERKS,proRouteProcessOld);
|
|
|
|
|
|
|
|
|
|
// sapProRouteProcessMapper.insertProRouteProcess(proRouteProcess);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// sapProRouteProcessMapper.updateProRouteProcess(proRouteProcess);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //根据routecode去重
|
|
|
|
|
//
|
|
|
|
|
// for (int i = 0; i < proRouteList.size(); i++) {
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// //quchong
|
|
|
|
|
//
|
|
|
|
|
// for (int i = 0; i < proProcessList.size(); i++) {
|
|
|
|
|
// if (!proProcessList.get(i).getProcessCode().isEmpty()){
|
|
|
|
|
// proProcessList.get(i).setProcessId(UUID.randomUUID().toString().replaceAll("-",""));
|
|
|
|
|
// sapProProcessMapper.insertProProcess(proProcessList.get(i));
|
|
|
|
|
//// System.out.println(proProcessList.get(i));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// proProcessContentList = proProcessContentList.stream().collect(Collectors.collectingAndThen
|
|
|
|
|
// (Collectors.toCollection(() ->new TreeSet<>(Comparator.comparing(SapProProcessContent::getContentText))),
|
|
|
|
|
// ArrayList::new));
|
|
|
|
|
// for (int j=0; j<proProcessContentList.size(); j++) {
|
|
|
|
|
// if (!proProcessContentList.get(j).getContentText().isEmpty()){
|
|
|
|
|
// sapProProcessContentMapper.insertProProcessContent(proProcessContentList.get(j));
|
|
|
|
|
// }}
|
|
|
|
|
// proRouteProcessList = proRouteProcessList.stream().collect(Collectors.collectingAndThen
|
|
|
|
|
// (Collectors.toCollection(() ->new TreeSet<>(Comparator.comparing(SapProRouteProcess::getProcessCode))),
|
|
|
|
|
// ArrayList::new));
|
|
|
|
|
// for (int k = 0;k<proRouteProcessList.size();k++){
|
|
|
|
|
// if (!proRouteProcessList.get(k).getProcessCode().isEmpty()){
|
|
|
|
|
// sapProRouteProcessMapper.insertProRouteProcess(proRouteProcessList.get(k));
|
|
|
|
|
// }}
|
|
|
|
|
// proRouteProcessList = proRouteProcessList.stream().collect(Collectors.collectingAndThen
|
|
|
|
|
// (Collectors.toCollection(() ->new TreeSet<>(Comparator.comparing(SapProRouteProcess::getProcessCode))),
|
|
|
|
|
// ArrayList::new));
|
|
|
|
|
// for (int k = 0;k<proRouteProcessList.size();k++){
|
|
|
|
|
// if (!proRouteProcessList.get(k).getProcessCode().isEmpty()){ sapProRouteProcessMapper.insertProRouteProcess(proRouteProcessList.get(k));}
|
|
|
|
|
// if (proRouteList.get(k).getRouteName()!="无"){ sapProRouteMapper.insertProRoute(proRouteList.get(k)); }
|
|
|
|
|
// if (!proProcessList.get(k).getProcessCode().isEmpty()){ sapProProcessMapper.insertProProcess(proProcessList.get(k)); }
|
|
|
|
|
// if (!proProcessContentList.get(k).getContentText().isEmpty()){ sapProProcessContentMapper.insertProProcessContent(proProcessContentList.get(k)); }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
Integer nums = sapSysUserMapper.getNums();
|
|
|
|
|
List<String> list = Arrays.asList(set.toArray(new String[0]));
|
|
|
|
|
// Integer nums = sapSysUserMapper.getNums();
|
|
|
|
|
for (int i=0;i<nums;i++){
|
|
|
|
|
String s = list.get(i);
|
|
|
|
|
mapProRoute.forEach((key,value)->{
|
|
|
|
|
if (key.equals(s)){
|
|
|
|
|
DynamicDataSourceContextHolder.push("ds_"+s);
|
|
|
|
|
if (value.getRouteName()!="无"){
|
|
|
|
|
{
|
|
|
|
|
// System.out.println(s);
|
|
|
|
|
// System.out.println(sapProRouteMapper.selectProRouteByRouteCode(value.getRouteCode()));
|
|
|
|
|
if (sapProRouteMapper.selectProRouteByRouteCode(value.getRouteCode())==0){
|
|
|
|
|
value.setRouteId(UUID.randomUUID().toString().replaceAll("-",""));
|
|
|
|
|
sapProRouteMapper.insertProRoute(value);
|
|
|
|
|
// arr1 = 1;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
// System.out.println(value);
|
|
|
|
|
sapProRouteMapper.updateProRoute(value);
|
|
|
|
|
// arr1=0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
mapProProcess.forEach((key, value) ->{
|
|
|
|
|
if (key.equals(s)){
|
|
|
|
|
DynamicDataSourceContextHolder.push("ds_"+s);
|
|
|
|
|
if (value.getProcessCode()!=null&&value.getProcessCode()!=""){
|
|
|
|
|
if (sapProProcessMapper.selectProProcessByProcessName(value.getProcessName())==0){
|
|
|
|
|
value.setProcessId(UUID.randomUUID().toString().replaceAll("-",""));
|
|
|
|
|
// System.out.println(value.getProcessCode()+"================================================");
|
|
|
|
|
sapProProcessMapper.insertProProcess(value);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
// System.out.println(value);
|
|
|
|
|
sapProProcessMapper.updateProProcess(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
mapProRouteProcessNew.forEach((key, value) ->{
|
|
|
|
|
if (key.equals(s)){
|
|
|
|
|
DynamicDataSourceContextHolder.push("ds_"+s);
|
|
|
|
|
if ((sapProRouteProcessMapper.selectProRouteProcessByProcessCode(value.getProcessCode()))==0){
|
|
|
|
|
// System.out.println(value);
|
|
|
|
|
sapProRouteProcessMapper.insertProRouteProcess(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
mapProRouteProcessOld.forEach((key, value) ->{
|
|
|
|
|
if (key.equals(s)){
|
|
|
|
|
DynamicDataSourceContextHolder.push("ds_"+s);
|
|
|
|
|
if ((sapProRouteProcessMapper.selectProRouteProcessByProcessCode(value.getProcessCode()))!=0){
|
|
|
|
|
// System.out.println(value);
|
|
|
|
|
sapProRouteProcessMapper.updateProRouteProcess(value);
|
|
|
|
|
}}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e){
|
|
|
|
|
return R.fail(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public static void main(String[] args) throws JCoException {
|
|
|
|
|
// // 连接
|
|
|
|
|
// SapConn con = new SapConn(
|
|
|
|
|
// "192.168.0.53",
|
|
|
|
|
// "00",
|
|
|
|
|
// "800",
|
|
|
|
|
// "MES",
|
|
|
|
|
// "123456",
|
|
|
|
|
// "zh",
|
|
|
|
|
// "true",
|
|
|
|
|
// "20",
|
|
|
|
|
// ""
|
|
|
|
|
// );
|
|
|
|
|
// JCoDestination jCoDestination = SAPConnUtils.connect(con);
|
|
|
|
|
// // 获取调用 RFC 函数对象
|
|
|
|
|
// JCoFunction func = jCoDestination.getRepository().getFunction("ZPPR_MES_PRO_TO");
|
|
|
|
|
// // 配置传入参数
|
|
|
|
|
// 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("ZMES_PRO");
|
|
|
|
|
// JCoRecordMetaData metaData = maraTable.getRecordMetaData();
|
|
|
|
|
// System.out.println("###" + metaData.toString());
|
|
|
|
|
// SapProOrder proOrder = new SapProOrder();
|
|
|
|
|
// List<SapProOrder> 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 );
|
|
|
|
|
//// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|