SAP定时任务同步订单

highway
Yangwl 1 year ago
parent a5d3d5727d
commit a72ac03a1e

@ -0,0 +1,11 @@
#for tests only !
#Tue Jul 25 15:29:49 CST 2023
jco.destination.pool_capacity=true
jco.client.lang=zh
jco.client.ashost=192.168.0.53
jco.client.saprouter=
jco.client.user=MES
jco.client.sysnr=0
jco.destination.peak_limit=20
jco.client.passwd=f.6zg4)u7K,V?%$f3X1@sDv,o,cE^tQDiv#oPB+PX*24w(Z.
jco.client.client=800

@ -0,0 +1,96 @@
**** Error file opened at 20230724 105509 China Standard Time Rel. 3.0.17 (2017-07-17) [721.913]
Error: >Mon Jul 24 10:55:09,173< RfcException:
message: Connect to SAP gateway failed
Connection parameters: TYPE=A DEST=ABAP_AS_WITH_POOL ASHOST=192.168.0.53 SYSNR=00 PCS=1
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner '192.168.0.53:3300' not reached
TIME Mon Jul 24 10:55:09 2023
RELEASE 721
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE nixxi.cpp
LINE 3289
DETAIL NiPConnect2: 192.168.0.53:3300
SYSTEM CALL connect
ERRNO 10060
ERRNO TEXT WSAETIMEDOUT: Connection timed out
COUNTER 2
return code: RFC_FAILURE (1)
error group: 102
key: RFC_ERROR_COMMUNICATION
Error: >Mon Jul 24 10:55:30,220< RfcException:
message: Connect to SAP gateway failed
Connection parameters: TYPE=A DEST=ABAP_AS_WITH_POOL ASHOST=192.168.0.53 SYSNR=00 PCS=1
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner '192.168.0.53:3300' not reached
TIME Mon Jul 24 10:55:30 2023
RELEASE 721
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE nixxi.cpp
LINE 3289
DETAIL NiPConnect2: 192.168.0.53:3300
SYSTEM CALL connect
ERRNO 10060
ERRNO TEXT WSAETIMEDOUT: Connection timed out
COUNTER 4
return code: RFC_FAILURE (1)
error group: 102
key: RFC_ERROR_COMMUNICATION
**** Error file opened at 20230725 103104 China Standard Time Rel. 3.0.17 (2017-07-17) [721.913]
Error: >Tue Jul 25 10:31:04,628< RfcException:
message: Connect to SAP gateway failed
Connection parameters: TYPE=A DEST=ABAP_AS_WITH_POOL ASHOST=192.168.0.53 SYSNR=00 PCS=1
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner '192.168.0.53:3300' not reached
TIME Tue Jul 25 10:31:04 2023
RELEASE 721
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE nixxi.cpp
LINE 3289
DETAIL NiPConnect2: 192.168.0.53:3300
SYSTEM CALL connect
ERRNO 10060
ERRNO TEXT WSAETIMEDOUT: Connection timed out
COUNTER 2
return code: RFC_FAILURE (1)
error group: 102
key: RFC_ERROR_COMMUNICATION
Error: >Tue Jul 25 10:31:25,675< RfcException:
message: Connect to SAP gateway failed
Connection parameters: TYPE=A DEST=ABAP_AS_WITH_POOL ASHOST=192.168.0.53 SYSNR=00 PCS=1
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner '192.168.0.53:3300' not reached
TIME Tue Jul 25 10:31:25 2023
RELEASE 721
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE nixxi.cpp
LINE 3289
DETAIL NiPConnect2: 192.168.0.53:3300
SYSTEM CALL connect
ERRNO 10060
ERRNO TEXT WSAETIMEDOUT: Connection timed out
COUNTER 4
return code: RFC_FAILURE (1)
error group: 102
key: RFC_ERROR_COMMUNICATION

@ -4,6 +4,11 @@
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />

@ -8,7 +8,7 @@
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>op-api-system</artifactId>
<description>
@ -16,13 +16,13 @@
</description>
<dependencies>
<!-- OP Common Core-->
<dependency>
<groupId>com.op</groupId>
<artifactId>op-common-core</artifactId>
</dependency>
</dependencies>
</project>
</project>

@ -3,7 +3,9 @@ package com.op.system.api;
import com.op.common.core.constant.ServiceNameConstants;
import com.op.common.core.domain.BaseFileData;
import com.op.common.core.domain.R;
import com.op.system.api.factory.RemoteMesFallbackFactory;
import com.op.system.api.model.SapProOrder;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@ -15,8 +17,15 @@ import java.util.List;
* @author OP
*/
@FeignClient(contextId = "remoteMesService", value = ServiceNameConstants.MES_SERVICE, fallbackFactory = RemoteMesFallbackFactory.class)
public interface RemoteMesService {
@PostMapping("/file/upLoadFile")
public R<Boolean> upLoadFile(@RequestBody List<BaseFileData> files);
@PostMapping("/order/sapAddOrder")
public R<Boolean> sapAddOrder(@RequestBody SapProOrder sapProOrder);
}

@ -3,6 +3,8 @@ package com.op.system.api.factory;
import com.op.common.core.domain.BaseFileData;
import com.op.common.core.domain.R;
import com.op.system.api.RemoteMesService;
import com.op.system.api.model.SapProOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
@ -27,6 +29,12 @@ public class RemoteMesFallbackFactory implements FallbackFactory<RemoteMesServic
public R<Boolean> upLoadFile(List<BaseFileData> files) {
return R.fail("上传失败:" + throwable.getMessage());
}
@Override
public R<Boolean> sapAddOrder(SapProOrder sapProOrder) {
return R.fail("新增SAP订单失败:" + throwable.getMessage());
}
};
}
}

@ -1,6 +1,7 @@
package com.op.system.api.factory;
import com.op.common.core.domain.BaseFileData;
import org.apache.commons.collections4.EnumerationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

@ -0,0 +1,253 @@
package com.op.system.api.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.TreeEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
public class SapProOrder extends TreeEntity {
private static final long serialVersionUID = 1L;
/** ID */
private String id;
/** 计划工厂编码 */
@Excel(name = "计划工厂编码")
private String planFactoryCode;
/** 计划工厂编码 */
@Excel(name = "工厂编码")
private String factoryCode;
/** 订单类型 */
@Excel(name = "订单类型")
private String orderType;
/** 订单号 */
@Excel(name = "订单号")
private String orderCode;
/** 物料号 */
@Excel(name = "物料号")
private String prodCode;
/** 物料名称 */
@Excel(name = "物料名称")
private String prodDesc;
/** 订单数量 */
@Excel(name = "订单数量")
private Long quantity;
/** 已拆分订单数量 */
@Excel(name = "已拆分订单数量")
private Long quantitySplit;
/** 单位 */
@Excel(name = "单位")
private String unit;
/** 任务清单 */
@Excel(name = "任务清单")
private String workerOrder;
public Long getQuantitySplit() {
return quantitySplit;
}
public void setQuantitySplit(Long quantitySplit) {
this.quantitySplit = quantitySplit;
}
/** 计划生产日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "计划生产日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date planProDate;
/** 计划完成日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "计划完成日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date planComplete;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String atrr1;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String atrr2;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String atrr3;
/** 0未拆分 */
@Excel(name = "0未拆分")
private String status;
/** 上级工单 */
@Excel(name = "上级工单")
private String parentOrder;
public String getPlanFactoryCode() {
return planFactoryCode;
}
public void setPlanFactoryCode(String planFactoryCode) {
this.planFactoryCode = planFactoryCode;
}
/** 产品类型 */
@Excel(name = "产品类型")
private String prodType;
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getFactoryCode() {
return factoryCode;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public String getOrderType() {
return orderType;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
public String getOrderCode() {
return orderCode;
}
public void setProdCode(String prodCode) {
this.prodCode = prodCode;
}
public String getProdCode() {
return prodCode;
}
public void setProdDesc(String prodDesc) {
this.prodDesc = prodDesc;
}
public String getProdDesc() {
return prodDesc;
}
public void setQuantity(Long quantity) {
this.quantity = quantity;
}
public Long getQuantity() {
return quantity;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getUnit() {
return unit;
}
public void setWorkerOrder(String workerOrder) {
this.workerOrder = workerOrder;
}
public String getWorkerOrder() {
return workerOrder;
}
public void setPlanProDate(Date planProDate) {
this.planProDate = planProDate;
}
public Date getPlanProDate() {
return planProDate;
}
public void setPlanComplete(Date planComplete) {
this.planComplete = planComplete;
}
public Date getPlanComplete() {
return planComplete;
}
public void setAtrr1(String atrr1) {
this.atrr1 = atrr1;
}
public String getAtrr1() {
return atrr1;
}
public void setAtrr2(String atrr2) {
this.atrr2 = atrr2;
}
public String getAtrr2() {
return atrr2;
}
public void setAtrr3(String atrr3) {
this.atrr3 = atrr3;
}
public String getAtrr3() {
return atrr3;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatus() {
return status;
}
public void setParentOrder(String parentOrder) {
this.parentOrder = parentOrder;
}
public String getParentOrder() {
return parentOrder;
}
public void setProdType(String prodType) {
this.prodType = prodType;
}
public String getProdType() {
return prodType;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("factoryCode", getFactoryCode())
.append("orderType", getOrderType())
.append("orderCode", getOrderCode())
.append("prodCode", getProdCode())
.append("prodDesc", getProdDesc())
.append("quantity", getQuantity())
.append("unit", getUnit())
.append("workerOrder", getWorkerOrder())
.append("planProDate", getPlanProDate())
.append("planComplete", getPlanComplete())
.append("atrr1", getAtrr1())
.append("atrr2", getAtrr2())
.append("atrr3", getAtrr3())
.append("status", getStatus())
.append("parentOrder", getParentOrder())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("prodType", getProdType())
.toString();
}
}

@ -30,4 +30,9 @@ public class ServiceNameConstants {
* serviceid
*/
public static final String WMS_SERVICE = "op-wms";
/**
* SAPserviceid
*/
public static final String SAP_SERVICE = "op-sap";
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
</configuration>
</facet>
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
@ -20,6 +20,8 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="sapjco33" level="project" />
<orderEntry type="library" name="lib" level="project" />
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery:2021.0.4.0" level="project" />
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-alibaba-commons:2021.0.4.0" level="project" />
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-client:2.0.4" level="project" />

@ -77,6 +77,7 @@
<artifactId>op-common-log</artifactId>
</dependency>
<!-- OP Common Swagger -->
<dependency>
<groupId>com.op</groupId>

@ -0,0 +1,25 @@
package com.op.job.config;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.job.domain.SapConn;
import com.op.job.util.SAPConnUtils;
import com.op.system.api.RemoteMesService;
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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
public class SapConnConfig {
}

@ -1,4 +1,4 @@
package com.op.mes.util;
package com.op.job.domain;
public class SapConn {
// SAP服务器

@ -1,19 +1,22 @@
package com.op.job.service;
import java.util.List;
import com.op.common.core.domain.R;
import com.op.system.api.model.SapProOrder;
import org.quartz.SchedulerException;
import com.op.common.core.exception.job.TaskException;
import com.op.job.domain.SysJob;
/**
*
*
*
* @author OP
*/
public interface ISysJobService {
/**
* quartz
*
*
* @param job
* @return
*/
@ -21,7 +24,7 @@ public interface ISysJobService {
/**
* ID
*
*
* @param jobId ID
* @return
*/
@ -29,7 +32,7 @@ public interface ISysJobService {
/**
*
*
*
* @param job
* @return
*/
@ -37,7 +40,7 @@ public interface ISysJobService {
/**
*
*
*
* @param job
* @return
*/
@ -45,7 +48,7 @@ public interface ISysJobService {
/**
* trigger
*
*
* @param job
* @return
*/
@ -53,7 +56,7 @@ public interface ISysJobService {
/**
*
*
*
* @param jobIds ID
* @return
*/
@ -61,7 +64,7 @@ public interface ISysJobService {
/**
*
*
*
* @param job
* @return
*/
@ -69,7 +72,7 @@ public interface ISysJobService {
/**
*
*
*
* @param job
* @return
*/
@ -77,7 +80,7 @@ public interface ISysJobService {
/**
*
*
*
* @param job
* @return
*/
@ -85,7 +88,7 @@ public interface ISysJobService {
/**
*
*
*
* @param job
* @return
*/
@ -93,9 +96,10 @@ public interface ISysJobService {
/**
* cron
*
*
* @param cronExpression
* @return
*/
public boolean checkCronExpressionIsValid(String cronExpression);
}
}

@ -2,6 +2,10 @@ package com.op.job.service;
import java.util.List;
import javax.annotation.PostConstruct;
import com.op.common.core.domain.R;
import com.op.system.api.RemoteMesService;
import com.op.system.api.model.SapProOrder;
import org.quartz.JobDataMap;
import org.quartz.JobKey;
import org.quartz.Scheduler;
@ -18,7 +22,7 @@ import com.op.job.util.ScheduleUtils;
/**
*
*
*
* @author OP
*/
@Service
@ -43,7 +47,7 @@ public class SysJobServiceImpl implements ISysJobService {
/**
* quartz
*
*
* @param job
* @return
*/
@ -54,7 +58,7 @@ public class SysJobServiceImpl implements ISysJobService {
/**
* ID
*
*
* @param jobId ID
* @return
*/
@ -65,7 +69,7 @@ public class SysJobServiceImpl implements ISysJobService {
/**
*
*
*
* @param job
*/
@Override
@ -83,7 +87,7 @@ public class SysJobServiceImpl implements ISysJobService {
/**
*
*
*
* @param job
*/
@Override
@ -101,7 +105,7 @@ public class SysJobServiceImpl implements ISysJobService {
/**
* trigger
*
*
* @param job
*/
@Override
@ -118,7 +122,7 @@ public class SysJobServiceImpl implements ISysJobService {
/**
*
*
*
* @param jobIds ID
* @return
*/
@ -133,7 +137,7 @@ public class SysJobServiceImpl implements ISysJobService {
/**
*
*
*
* @param job
*/
@Override
@ -151,7 +155,7 @@ public class SysJobServiceImpl implements ISysJobService {
/**
*
*
*
* @param job
*/
@Override
@ -174,7 +178,7 @@ public class SysJobServiceImpl implements ISysJobService {
/**
*
*
*
* @param job
*/
@Override
@ -190,7 +194,7 @@ public class SysJobServiceImpl implements ISysJobService {
/**
*
*
*
* @param job
*/
@Override
@ -206,7 +210,7 @@ public class SysJobServiceImpl implements ISysJobService {
/**
*
*
*
* @param job
* @param jobGroup
*/
@ -223,7 +227,7 @@ public class SysJobServiceImpl implements ISysJobService {
/**
* cron
*
*
* @param cronExpression
* @return
*/
@ -231,4 +235,5 @@ public class SysJobServiceImpl implements ISysJobService {
public boolean checkCronExpressionIsValid(String cronExpression) {
return CronUtils.isValid(cronExpression);
}
}
}

@ -5,7 +5,7 @@ import com.op.common.core.utils.StringUtils;
/**
*
*
*
* @author OP
*/
@Component("ryTask")
@ -21,4 +21,5 @@ public class RyTask {
public void ryNoParams() {
System.out.println("执行无参方法");
}
}

@ -0,0 +1,248 @@
package com.op.job.task;
import com.op.common.core.constant.SecurityConstants;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.job.config.SapConnConfig;
import com.op.job.domain.SapConn;
import com.op.job.service.ISysJobService;
import com.op.job.util.SAPConnUtils;
import com.op.system.api.RemoteMesService;
import com.op.system.api.RemoteUserService;
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.Component;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Component("sapTask")
public class SapTask {
static List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>();
@Autowired
private RemoteMesService remoteMesService;
@Value("${sap.ashost}")
public String ashost;
@Value("${sap.sysnr}")
public String sysnr;
@Value("${sap.client}")
public String client;
@Value("${sap.user}")
public String user;
@Value("${sap.passwd}")
public String passwd;
@Value("${sap.lang}")
public String lang;
@Value("${sap.pool_capacity}")
public String pool_capacity;
@Value("${sap.peak_limit}")
public String peak_limit;
@Value("${sap.saprouter}")
public String saprouter;
public void sapSyncTask() {
System.out.println("执行SAP订单同步方法");
// 连接
SapConn con = new SapConn(
ashost,
sysnr,
client,
user,
passwd,
lang,
pool_capacity,
peak_limit,
saprouter
);
JCoDestination jCoDestination = SAPConnUtils.connect(con);
//获取SAP订单数据
RfcTest(jCoDestination);
}
public void maraSyncTask(){
}
public static void main(String[] args) throws JCoException {
System.out.println("执行BOM同步方法");
// 连接
SapConn con = new SapConn(
"192.168.0.53",
"00",
"800",
"MES",
"123456",
"zh",
"true",
"20",
""
);
JCoDestination jCoDestination = SAPConnUtils.connect(con);
//获取BOM数据
//获取调用 RFC 函数对象
JCoFunction func = jCoDestination.getRepository().getFunction("ZPPR_MES_BOM");
// 配置传入参数
JCoParameterList importParameterList = func.getImportParameterList();
// importParameterList.setValue("S_WERKS","1000");
// 调用并获取返回值
func.execute(jCoDestination);
// 获取 内表 - ZMES_PRO
JCoTable bomTable = func.getTableParameterList().getTable("LT_BOM");
JCoRecordMetaData metaData = bomTable.getRecordMetaData();
System.out.println("###"+metaData.toString());
System.out.println("###"+bomTable.getNumRows());
for (int i = 0; i < bomTable.getNumRows(); i++) {
bomTable.setRow(i);
String MATNR = bomTable.getString("MATNR");
String MAKTX = bomTable.getString("MAKTX");
String WERKS = bomTable.getString("WERKS");
String VERID = bomTable.getString("VERID");
String STLNR = bomTable.getString("STLNR");
System.out.println("物料编码:" +MATNR+" - 物料名称:" + MAKTX+" - 工厂:" + WERKS+" - 生产版本:" + VERID+" - BOM单号" + STLNR);
}
}
// public static void main(String[] arg) throws JCoException {
// System.out.println("执行同步方法");
// // 连接
// SapConn con = new SapConn(
// "192.168.0.53",
// "00",
// "800",
// "MES",
// "123456",
// "zh",
// "true",
// "20",
// ""
// );
// JCoDestination jCoDestination = SAPConnUtils.connect(con);
// //获取SAP订单数据
// // 获取调用 RFC 函数对象
// JCoFunction func = jCoDestination.getRepository().getFunction("ZMMR_MES_MAT_GET");
//
// // 配置传入参数
// JCoParameterList importParameterList = func.getImportParameterList();
// importParameterList.setValue("S_MATNR","000000000000000019" );
//
// // 调用并获取返回值
// func.execute(jCoDestination);
// // 获取 内表 - ZMES_PRO
// JCoTable bomTable = func.getTableParameterList().getTable("LT_MARA");
// JCoRecordMetaData metaData = bomTable.getRecordMetaData();
// System.out.println("###"+metaData.toString());
// System.out.println("###"+bomTable.getNumRows());
// for (int i = 0; i < bomTable.getNumRows(); i++) {
// String MATNR = bomTable.getString("MATNR");
// String MAKTX = bomTable.getString("MAKTX");
//// String WERKS = bomTable.getString("WERKS");
//// String VERID = bomTable.getString("VERID");
//// String STLNR = bomTable.getString("STLNR");
// System.out.println("物料号:" +MATNR+" - 物料描述:" + MAKTX);
// }
// }
public List<Map<String, Object>> RfcTest(JCoDestination jCoDestination){
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.setProdCode(PLNBEZ);
proOrder.setProdDesc(MAKTX);
proOrder.setQuantity(Long.parseLong(GAMNG.substring(0,GAMNG.indexOf("."))));
proOrder.setUnit(GMEIN);
proOrder.setWorkerOrder(PLNNR);
proOrder.setPlanProDate(dateparse(GSTRP));
proOrder.setPlanComplete(dateparse(GLTRP));
proOrder.setParentOrder(MAUFNR);
proOrder.setCreateBy(ERNAM);
proOrder.setCreateTime(dateparse(ERDAT));
proOrder.setUpdateBy(ERNAM);
proOrder.setUpdateTime(dateparse(ERDAT));
proOrder.setStatus("0");
// proOrderList.add(proOrder);
// System.out.println("物料编号:" + matnr + " - 创建日期:" + esdra + " - 创建人:" + ernam + " - 物料组:" + matkl + " - 单位:" + meins);
remoteMesService.sapAddOrder(proOrder);
}
} catch (Exception e) {
e.printStackTrace();
}
return returnList;
}
private static Date dateparse(String date) throws ParseException {
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
Date sfdate = sf.parse(date);
return sfdate;
}
}

@ -1,5 +1,8 @@
package com.op.mes.util;
package com.op.job.util;
import com.op.job.domain.SapConn;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
@ -77,4 +80,5 @@ public class SAPConnUtils {
}
return destination;
}
}

@ -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
# 配置中心地址

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
</configuration>
</facet>
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />

@ -83,6 +83,8 @@
<artifactId>op-common-swagger</artifactId>
</dependency>
</dependencies>
<build>

@ -3,6 +3,8 @@ package com.op.mes.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.R;
import com.op.mes.domain.dto.SplitOrderDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -128,6 +130,24 @@ public class ProOrderController extends BaseController {
public AjaxResult add(@RequestBody ProOrder proOrder) {
return toAjax(proOrderService.insertProOrder(proOrder));
}
/**
*
*/
@Log(title = "批量保存SAP生产订单", businessType = BusinessType.INSERT)
@PostMapping("/sapAddOrder")
public R<Boolean> sapAddOrder(@RequestBody ProOrder proOrder) {
try {
if (proOrder!=null){
proOrderService.insertSapProOrder(proOrder);
}
}catch (Exception e){
return R.fail(e.getMessage());
}
return R.ok();
}
/**
*

@ -8,7 +8,6 @@ import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.web.page.TableDataInfo;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.mes.domain.ProProcessContent;
import com.op.mes.service.IProProcessContentService;
import org.springframework.beans.factory.annotation.Autowired;

@ -1,22 +1,15 @@
package com.op.mes.controller;
import java.security.Security;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.nacos.client.constant.Constants;
import com.op.common.core.constant.UserConstants;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.poi.ExcelUtil;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.web.page.TableDataInfo;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.common.security.utils.SecurityUtils;
import com.op.mes.domain.ProProcess;
import com.op.mes.service.IProProcessService;
import org.springframework.beans.factory.annotation.Autowired;

@ -3,7 +3,6 @@ package com.op.mes.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.poi.ExcelUtil;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult;
@ -16,7 +15,6 @@ import com.op.mes.domain.ProRoute;
import com.op.mes.service.IProRouteProcessService;
import com.op.mes.service.IProRouteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;

@ -11,12 +11,11 @@ import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.web.page.TableDataInfo;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.mes.domain.ProProcess;
import com.op.mes.domain.ProRouteProcess;
import com.op.mes.service.IProProcessService;
import com.op.mes.service.IProRouteProcessService;
import com.op.mes.service.IProProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.mes.domain.ProRouteProduct;
import com.op.mes.service.IProRouteProductService;
import com.op.common.core.web.controller.BaseController;

@ -0,0 +1,117 @@
package com.op.mes.controller;
import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.op.mes.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.poi.ExcelUtil;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.web.page.TableDataInfo;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.common.security.utils.SecurityUtils;
import com.op.system.api.domain.SysUser;
/**
*
*
* @author OP
*/
@RestController
@RequestMapping("/user")
public class SysUserController extends BaseController {
@Autowired
private ISysUserService userService;
/**
*
*/
@RequiresPermissions("system:user:list")
@GetMapping("/list")
public TableDataInfo list(SysUser user) {
startPage();
List<SysUser> list = userService.selectUserList(user);
return getDataTable(list);
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:user:export")
@PostMapping("/export")
public void export(HttpServletResponse response, SysUser user) {
List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.exportExcel(response, list, "用户数据");
}
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) throws IOException {
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.importTemplateExcel(response, "用户数据");
}
/**
*
*/
@RequiresPermissions("system:user:add")
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysUser user) {
if (!userService.checkUserNameUnique(user)) {
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setCreateBy(SecurityUtils.getUsername());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
return toAjax(userService.insertUser(user));
}
/**
*
*/
@RequiresPermissions("system:user:edit")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/resetPwd")
public AjaxResult resetPwd(@RequestBody SysUser user) {
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
user.setUpdateBy(SecurityUtils.getUsername());
return toAjax(userService.resetPwd(user));
}
/**
*
*/
@RequiresPermissions("system:user:edit")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysUser user) {
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setUpdateBy(SecurityUtils.getUsername());
return toAjax(userService.updateUserStatus(user));
}
}

@ -1,7 +1,6 @@
package com.op.mes.domain;
import com.op.common.core.annotation.Excel;
import com.op.common.core.domain.BaseFileData;
import com.op.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

@ -2,8 +2,6 @@ package com.op.mes.domain;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* pro_route_process

@ -1,7 +1,6 @@
package com.op.mes.domain.dto;
import com.op.mes.domain.Batch;
import com.op.mes.domain.ProOrder;
import java.util.Date;
import java.util.List;

@ -59,4 +59,4 @@ public interface ProOrderWorkorderBatchMapper {
*/
public int deleteProOrderWorkorderBatchByWorkorderIds(String[] workorderIds);
}
}

@ -1,6 +1,7 @@
package com.op.mes.mapper;
import com.op.mes.domain.ProOrderWorkorder;
import org.apache.ibatis.annotations.Select;
import java.util.Date;
import java.util.List;
@ -67,7 +68,7 @@ public interface ProOrderWorkorderMapper {
* @return
*/
List<ProOrderWorkorder> selectFirWorkOrder(String id);
ProOrderWorkorder selectWorkOrderByCode(String workorderCode);
/**
* code
*
@ -94,3 +95,4 @@ public interface ProOrderWorkorderMapper {
*/
String selectEndWorkOrder(String id);
}

@ -47,6 +47,13 @@ public interface IProOrderService {
*/
public int insertProOrder(ProOrder proOrder);
/**
* SAP
* @param proOrder
* @return
*/
public int insertSapProOrder(ProOrder proOrder);
/**
*
*

@ -0,0 +1,149 @@
package com.op.mes.service;
import java.util.List;
import com.op.system.api.domain.SysUser;
/**
*
*
* @author OP
*/
public interface ISysUserService {
/**
*
*
* @param user
* @return
*/
public List<SysUser> selectUserList(SysUser user);
/**
*
*
* @param user
* @return
*/
public List<SysUser> selectAllocatedList(SysUser user);
/**
*
*
* @param user
* @return
*/
public List<SysUser> selectUnallocatedList(SysUser user);
/**
*
*
* @param userName
* @return
*/
public SysUser selectUserByUserName(String userName);
/**
* ID
*
* @param userId ID
* @return
*/
public SysUser selectUserById(Long userId);
/**
*
*
* @param user
* @return
*/
public boolean checkUserNameUnique(SysUser user);
/**
*
*
* @param user
* @return
*/
public boolean checkPhoneUnique(SysUser user);
/**
* email
*
* @param user
* @return
*/
public boolean checkEmailUnique(SysUser user);
/**
*
*
* @param user
*/
public void checkUserAllowed(SysUser user);
/**
*
*
* @param userId id
*/
public void checkUserDataScope(Long userId);
/**
*
*
* @param user
* @return
*/
public int insertUser(SysUser user);
/**
*
*
* @param user
* @return
*/
public boolean registerUser(SysUser user);
/**
*
*
* @param user
* @return
*/
public int updateUserStatus(SysUser user);
/**
*
*
* @param user
* @return
*/
public int updateUserProfile(SysUser user);
/**
*
*
* @param userName
* @param avatar
* @return
*/
public boolean updateUserAvatar(String userName, String avatar);
/**
*
*
* @param user
* @return
*/
public int resetPwd(SysUser user);
/**
*
*
* @param userName
* @param password
* @return
*/
public int resetUserPwd(String userName, String password);
}

@ -83,9 +83,6 @@ public class ProOrderServiceImpl implements IProOrderService {
// 生成对应工单表
// 一级
ProOrderWorkorder firWorkOrder = setWorkOrder(proOrderWorkorder, product);
// code
int endCode = getEndCode(product.getId());
firWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+endCode);
// 更新到数据库
proOrderWorkorderMapper.insertProOrderWorkorder(firWorkOrder);
// 创建通用批次表对象
@ -103,8 +100,6 @@ public class ProOrderServiceImpl implements IProOrderService {
// 设置父工单
proOrderWorkorder.setParentOrder(firWorkOrder.getWorkorderCode());
ProOrderWorkorder secWorkOrder = setWorkOrder(proOrderWorkorder, product);
// code
secWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+(endCode+1));
// 更新到数据库
proOrderWorkorderMapper.insertProOrderWorkorder(secWorkOrder);
// 生成批次表并更新到数据库
@ -122,8 +117,6 @@ public class ProOrderServiceImpl implements IProOrderService {
ProOrderWorkorder thiWorkOrder = setWorkOrder(proOrderWorkorder, product);
// 设置为底层节点
thiWorkOrder.setIsEnd(1);
// code
thiWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+(endCode+2));
// 更新到数据库
proOrderWorkorderMapper.insertProOrderWorkorder(thiWorkOrder);
// 生成批次表并更新到数据库
@ -131,7 +124,7 @@ public class ProOrderServiceImpl implements IProOrderService {
}
// 设置为底层节点
if (checkEnd == 1) {
if (checkEnd == 1){
updateWorker.setWorkorderId(secWorkOrder.getWorkorderId());
updateWorker.setIsEnd(1);
proOrderWorkorderMapper.updateProOrderWorkorder(updateWorker);
@ -140,7 +133,7 @@ public class ProOrderServiceImpl implements IProOrderService {
}
// 设置为底层节点
if (checkEnd == 1) {
if (checkEnd == 1){
updateWorker.setWorkorderId(firWorkOrder.getWorkorderId());
updateWorker.setIsEnd(1);
proOrderWorkorderMapper.updateProOrderWorkorder(updateWorker);
@ -165,23 +158,23 @@ public class ProOrderServiceImpl implements IProOrderService {
// 通过订单id查询所有工单信息list
List<ProOrderWorkorder> proOrderWorkorderList = proOrderWorkorderMapper.selectFirWorkOrder(id);
// 母工单循环遍历
for (int i = 0; i < proOrderWorkorderList.size(); i++) {
for (int i = 0;i < proOrderWorkorderList.size();i++){
// 通过设备code查询出机型名称
String prodLineName = proOrderMapper.selectProdLineName(proOrderWorkorderList.get(i).getProdLineCode());
// 通过工单id查询批次号
List<String> batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorderList.get(i).getWorkorderId());
List<StringBuilder> batchCodes = new ArrayList<>();
// 格式化数据
for (int j = 0; j < batchCodeList.size(); j++) {
for (int j = 0;j < batchCodeList.size();j++){
batchCodes.add(new StringBuilder(batchCodeList.get(j)).append(";").append("\n"));
}
// 通过母工单workorder_id查询子工单
// 二级
List<ProOrderWorkorder> secProOrderWorkorder = proOrderWorkorderMapper.selectChildWorkOrder(proOrderWorkorderList.get(i).getWorkorderCode());
if (secProOrderWorkorder.size() > 0 && secProOrderWorkorder != null) {
if (secProOrderWorkorder.size() > 0 && secProOrderWorkorder != null){
// 三级
List<ProOrderWorkorder> thiProOrderWorkorders = proOrderWorkorderMapper.selectChildWorkOrder(secProOrderWorkorder.get(0).getWorkorderCode());
if (thiProOrderWorkorders.size() > 0 && thiProOrderWorkorders != null) {
if (thiProOrderWorkorders.size() > 0 && thiProOrderWorkorders != null){
// 将三级放入二级child
thiProOrderWorkorders.get(0).setProdLineCode(prodLineName);
thiProOrderWorkorders.get(0).setBatchCodeList(batchCodes);
@ -233,12 +226,8 @@ public class ProOrderServiceImpl implements IProOrderService {
*/
@Override
@DS("#header.poolName")
public LineAndShiftVo getProdLineShift(String type) {
if (type.equals("white")){
LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectProdLine(), proOrderMapper.selectProShift());
return lineAndShiftVo;
}
LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectPackageLine(), proOrderMapper.selectProShift());
public LineAndShiftVo getProdLineShift() {
LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectProdLine(), proOrderMapper.selectProShift());
return lineAndShiftVo;
}
@ -249,7 +238,6 @@ public class ProOrderServiceImpl implements IProOrderService {
* @return
*/
@Override
@DS("#header.poolName")
public ProOrder selectProOrderById(String id) {
return proOrderMapper.selectProOrderById(id);
}
@ -263,11 +251,7 @@ public class ProOrderServiceImpl implements IProOrderService {
@Override
@DS("#header.poolName")
public List<ProOrder> selectProOrderList(ProOrder proOrder) {
List<ProOrder> proOrderList = proOrderMapper.selectProOrderList(proOrder);
for (int i = 0; i < proOrderList.size(); i++) {
proOrderList.get(i).setStatus(changeStatus(proOrderList.get(i).getStatus()));
}
return proOrderList;
return proOrderMapper.selectProOrderList(proOrder);
}
/**
@ -281,12 +265,15 @@ public class ProOrderServiceImpl implements IProOrderService {
public int insertProOrder(ProOrder proOrder) {
// 获取当前时间
Date date = new Date();
proOrder.setId(IdUtils.fastSimpleUUID());
proOrder.setCreateTime(DateUtils.getNowDate());
return proOrderMapper.insertProOrder(proOrder);
}
@Override
public int insertSapProOrder(ProOrder proOrder) {
DynamicDataSourceContextHolder.push("op_xiaolan");// 这是数据源的key
proOrder.setId(IdUtils.fastSimpleUUID());
proOrder.setParentOrder("0");
proOrder.setStatus("o0");
proOrder.setOrderType(proOrder.getProdType());
proOrder.setOrderCode("DD"+ DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, date));
proOrder.setCreateBy(SecurityContextHolder.getUserName());
proOrder.setCreateTime(date);
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
proOrder.setUpdateTime(date);
@ -396,6 +383,8 @@ public class ProOrderServiceImpl implements IProOrderService {
proOrderWorkorder.setUnit(proOrder.getUnit());
// 已拆分数量
proOrderWorkorder.setQuantitySplit(Long.valueOf(proOrder.getAtrr1()));
// TODO 工艺编码
// TODO 所有父节点
return proOrderWorkorder;
}
@ -406,6 +395,7 @@ public class ProOrderServiceImpl implements IProOrderService {
*/
private ProOrderWorkorderBatch setCommonBatchAttribute() {
ProOrderWorkorderBatch workBatch = new ProOrderWorkorderBatch();
Date date = new Date();
// 更新者
workBatch.setUpdateBy(SecurityContextHolder.getUserName());
// 创建者

@ -13,7 +13,6 @@ import com.op.mes.mapper.BaseFileMapper;
import com.op.mes.mapper.ProProcessMapper;
import com.op.mes.service.IProProcessService;
import com.op.system.api.RemoteUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

@ -1,7 +1,6 @@
package com.op.mes.service.impl;
import java.util.List;
import java.util.stream.Collectors;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.constant.UserConstants;
@ -9,9 +8,9 @@ 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.mes.domain.ProRouteProcess;
import com.op.mes.service.IProRouteProcessService;
import com.op.mes.mapper.ProRouteMapper;
import com.op.mes.mapper.ProRouteProcessMapper;
import com.op.mes.service.IProRouteProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@ -12,7 +12,6 @@ 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.mes.domain.BaseFile;
import com.op.mes.domain.ProProcess;
import com.op.mes.domain.ProRoute;
import com.op.mes.mapper.BaseFileMapper;
import com.op.mes.mapper.ProRouteMapper;

@ -0,0 +1,257 @@
package com.op.mes.service.impl;
import java.util.List;
import javax.validation.Validator;
import com.op.mes.service.ISysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.op.common.core.constant.UserConstants;
import com.op.common.core.exception.ServiceException;
import com.op.common.core.utils.SpringUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.datascope.annotation.DataScope;
import com.op.common.security.utils.SecurityUtils;
import com.op.system.api.domain.SysUser;
import com.op.mes.mapper.SysUserMapper;
/**
*
*
* @author OP
*/
@Service
public class SysUserServiceImpl implements ISysUserService {
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
@Autowired
private SysUserMapper userMapper;
@Autowired
protected Validator validator;
/**
*
*
* @param user
* @return
*/
@Override
@DataScope(deptAlias = "d", userAlias = "u")
public List<SysUser> selectUserList(SysUser user) {
return userMapper.selectUserList(user);
}
/**
*
*
* @param user
* @return
*/
@Override
@DataScope(deptAlias = "d", userAlias = "u")
public List<SysUser> selectAllocatedList(SysUser user) {
return userMapper.selectAllocatedList(user);
}
/**
*
*
* @param user
* @return
*/
@Override
@DataScope(deptAlias = "d", userAlias = "u")
public List<SysUser> selectUnallocatedList(SysUser user) {
return userMapper.selectUnallocatedList(user);
}
/**
*
*
* @param userName
* @return
*/
@Override
public SysUser selectUserByUserName(String userName) {
return userMapper.selectUserByUserName(userName);
}
/**
* ID
*
* @param userId ID
* @return
*/
@Override
public SysUser selectUserById(Long userId) {
return userMapper.selectUserById(userId);
}
/**
*
*
* @param user
* @return
*/
@Override
public boolean checkUserNameUnique(SysUser user) {
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
SysUser info = userMapper.checkUserNameUnique(user.getUserName());
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/**
*
*
* @param user
* @return
*/
@Override
public boolean checkPhoneUnique(SysUser user) {
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/**
* email
*
* @param user
* @return
*/
@Override
public boolean checkEmailUnique(SysUser user) {
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
SysUser info = userMapper.checkEmailUnique(user.getEmail());
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/**
*
*
* @param user
*/
@Override
public void checkUserAllowed(SysUser user) {
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) {
throw new ServiceException("不允许操作超级管理员用户");
}
}
/**
*
*
* @param userId id
*/
@Override
public void checkUserDataScope(Long userId) {
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
SysUser user = new SysUser();
user.setUserId(userId);
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
if (StringUtils.isEmpty(users)) {
throw new ServiceException("没有权限访问用户数据!");
}
}
}
/**
*
*
* @param user
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int insertUser(SysUser user) {
// 新增用户信息
int rows = userMapper.insertUser(user);
return rows;
}
/**
*
*
* @param user
* @return
*/
@Override
public boolean registerUser(SysUser user) {
return userMapper.insertUser(user) > 0;
}
/**
*
*
* @param user
* @return
*/
@Override
public int updateUserStatus(SysUser user) {
return userMapper.updateUser(user);
}
/**
*
*
* @param user
* @return
*/
@Override
public int updateUserProfile(SysUser user) {
return userMapper.updateUser(user);
}
/**
*
*
* @param userName
* @param avatar
* @return
*/
@Override
public boolean updateUserAvatar(String userName, String avatar) {
return userMapper.updateUserAvatar(userName, avatar) > 0;
}
/**
*
*
* @param user
* @return
*/
@Override
public int resetPwd(SysUser user) {
return userMapper.updateUser(user);
}
/**
*
*
* @param userName
* @param password
* @return
*/
@Override
public int resetUserPwd(String userName, String password) {
return userMapper.resetUserPwd(userName, password);
}
}

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
</configuration>
</facet>
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
@ -194,6 +194,5 @@
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.69" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.69" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcutil-jdk15on:1.69" level="project" />
<orderEntry type="library" name="sapjco3" level="project" />
</component>
</module>

@ -1,106 +0,0 @@
package com.op.mes.util;
import com.sap.conn.jco.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Configuration
public class SapConnConfig {
static List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>();
static JCoFunction function;
@Value("${sap.ashost}")
public String ashost;
@Value("${sap.sysnr}")
public String sysnr;
@Value("${sap.client}")
public String client;
@Value("${sap.user}")
public String user;
@Value("${sap.passwd}")
public String passwd;
@Value("${sap.lang}")
public String lang;
@Value("${sap.pool_capacity}")
public String pool_capacity;
@Value("${sap.peak_limit}")
public String peak_limit;
@Value("${sap.saprouter}")
public String saprouter;
@Bean
public void SapConn() {
SapConn con = new SapConn(
ashost,
sysnr,
client,
user,
passwd,
lang,
pool_capacity,
peak_limit,
saprouter
);
// 连接
JCoDestination jCoDestination = SAPConnUtils.connect(con);
RfcTest(jCoDestination);
}
public static List<Map<String, Object>> RfcTest(JCoDestination jCoDestination){
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());
// 循环输出 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("物料编号:" + matnr + " - 创建日期:" + esdra + " - 创建人:" + ernam + " - 物料组:" + matkl + " - 单位:" + meins);
System.out.println("订单号:" +AUFNR+" - 订单类型:" + AUART+ " - 上级订单编号:" + MAUFNR+ " - 物料号:" + PLNBEZ+ " - 物料描述(短文本):" + MAKTX
+ " - 订单的计划工厂:" + PWERK+ " - 订单数量总计:" + GAMNG+ " - 基本计量单位:" + GMEIN+ " - 任务清单组码:" + PLNNR+ " - 基本开始日期:" + GSTRP
+ " - 基本完成日期:" + GLTRP+ " - 输入者:" + ERNAM+ " - 创建日期:" + ERDAT+ " - 系统状态:" + STTXT);
}
} catch (Exception e) {
e.printStackTrace();
}
return returnList;
}
}

@ -1,4 +1,4 @@
package com.op.mes;
package com.op.sap;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@ -0,0 +1,5 @@
package com.op.sap.controller;
public class SapController {
}

@ -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
# 配置中心地址

@ -1,14 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
</descriptors>
<webroots />
</configuration>
</facet>
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />

@ -333,4 +333,5 @@ public class SysUserController extends BaseController {
public R<List<Map<String, String>>> getPoolNameLis(@RequestBody SysUser user) {
return R.ok(userService.getPoolNameList(user));
}
}

@ -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
# 配置中心地址

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
</configuration>
</facet>
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />

@ -1,4 +1,4 @@
package com.op.mes.domain.vo;
package com.op.sap.domain.vo;
import com.op.common.core.utils.StringUtils;

@ -1,4 +1,4 @@
package com.op.mes.domain.vo;
package com.op.sap.domain.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;

@ -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
# 配置中心地址

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
</configuration>
</facet>
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />

Loading…
Cancel
Save