修改
This commit is contained in:
@@ -1,21 +1,93 @@
|
||||
package org.nl.config;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wms.common.DataTypeEnum;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class DataBaseConfig {
|
||||
@Value("${erp.oracle.enabled}")
|
||||
private boolean oracleIsConnect;
|
||||
@Value("${erp.oracle.jdbcurl}")
|
||||
private String oracleJdbcUrl;
|
||||
@Value("${erp.oracle.username}")
|
||||
private String oracleUserName;
|
||||
@Value("${erp.oracle.password}")
|
||||
private String oraclePassword;
|
||||
|
||||
@Primary
|
||||
@Bean(name = "dataSource")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.druid")
|
||||
public DataSource dataSource() {
|
||||
return new DruidDataSource();
|
||||
}
|
||||
|
||||
@Bean(name = "dataSource1")
|
||||
@ConditionalOnExpression("${erp.oracle.enabled:true}")
|
||||
public DataSource dataSource1() {
|
||||
System.out.println("是否连接oracle:"+oracleIsConnect);
|
||||
System.out.println("erp.oracle.jdbcurl:"+oracleJdbcUrl);
|
||||
System.out.println("erp.oracle.username:"+oracleUserName);
|
||||
System.out.println("erp.oracle.password:"+oraclePassword);
|
||||
log.info("是否连接oracle:"+oracleIsConnect);
|
||||
log.info("erp.oracle.jdbcurl:"+oracleJdbcUrl);
|
||||
log.info("erp.oracle.username:"+oracleUserName);
|
||||
log.info("erp.oracle.password:"+oraclePassword);
|
||||
|
||||
String jdbcUrl = oracleJdbcUrl;
|
||||
String userName = oracleUserName;
|
||||
String password =oraclePassword;
|
||||
|
||||
DruidDataSource druidDataSource = new DruidDataSource();
|
||||
String className;
|
||||
try {
|
||||
className = DriverManager.getDriver(jdbcUrl.trim()).getClass().getName();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException("Get class name error: =" + jdbcUrl);
|
||||
}
|
||||
if (StrUtil.isEmpty(className)) {
|
||||
DataTypeEnum dataTypeEnum = DataTypeEnum.urlOf(jdbcUrl);
|
||||
if (null == dataTypeEnum) {
|
||||
throw new RuntimeException("Not supported data type: jdbcUrl=" + jdbcUrl);
|
||||
}
|
||||
druidDataSource.setDriverClassName(dataTypeEnum.getDriver());
|
||||
} else {
|
||||
druidDataSource.setDriverClassName(className);
|
||||
}
|
||||
|
||||
|
||||
druidDataSource.setUrl(jdbcUrl);
|
||||
druidDataSource.setUsername(userName);
|
||||
druidDataSource.setPassword(password);
|
||||
// 配置获取连接等待超时的时间
|
||||
druidDataSource.setMaxWait(3000);
|
||||
// 配置初始化大小、最小、最大
|
||||
druidDataSource.setInitialSize(5);
|
||||
druidDataSource.setMinIdle(5);
|
||||
druidDataSource.setMaxActive(10);
|
||||
|
||||
// 如果链接出现异常则直接判定为失败而不是一直重试
|
||||
druidDataSource.setBreakAfterAcquireFailure(true);
|
||||
try {
|
||||
druidDataSource.init();
|
||||
} catch (SQLException e) {
|
||||
log.error("Exception during pool initialization", e);
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
|
||||
return druidDataSource;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.nl.wms;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
@@ -17,6 +18,7 @@ import java.util.Map;
|
||||
* @author zds 2018-12-27 16:33:50
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public class WebServiceUtil {
|
||||
/**
|
||||
*
|
||||
@@ -63,8 +65,8 @@ public class WebServiceUtil {
|
||||
int responseCode = connection.getResponseCode();
|
||||
String ret="默认值";
|
||||
|
||||
if(200 == responseCode){//表示服务端响应成功
|
||||
|
||||
if(200 == responseCode){//表示服务端响应成功
|
||||
log.info("请求成功!");
|
||||
//获取当前连接请求返回的数据流
|
||||
InputStream is = connection.getInputStream();
|
||||
|
||||
@@ -98,6 +100,7 @@ public class WebServiceUtil {
|
||||
connection.disconnect();
|
||||
}
|
||||
os.close();
|
||||
log.info("返回参数ret为:"+ret);
|
||||
return ret;
|
||||
// return result;
|
||||
}
|
||||
@@ -127,7 +130,7 @@ public class WebServiceUtil {
|
||||
sb.append("</urn:"+method+">");
|
||||
sb.append("</soapenv:Body>");
|
||||
sb.append("</soapenv:Envelope>");
|
||||
System.out.println("getXML发送数据-----------------"+sb.toString());
|
||||
log.info("getXML组织参数为-----------------"+sb.toString());
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@ package org.nl.wms.basedata.master.rest;
|
||||
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.anno.Log;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wms.basedata.master.constant.MaterOptTypeEnum;
|
||||
@@ -90,9 +91,8 @@ public class MaterialbaseController {
|
||||
@Log("物料同步")
|
||||
@ApiOperation("物料同步")
|
||||
//@PreAuthorize("@el.check('materialtype:list')")
|
||||
public ResponseEntity<Object> synchronize(@RequestBody Map whereJson) {
|
||||
materialBaseService.synchronize(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
public ResponseEntity<Object> synchronize(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(materialBaseService.synchronize(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("查询产品系列类型")
|
||||
|
||||
@@ -89,7 +89,7 @@ public interface MaterialbaseService {
|
||||
*/
|
||||
JSONObject getMaterOptType(String materOpt_code);
|
||||
|
||||
void synchronize(Map whereJson);
|
||||
JSONObject synchronize(JSONObject whereJson);
|
||||
|
||||
JSONArray getProductSeries(String parent_class_id);
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* <<
|
||||
* Davinci
|
||||
* ==
|
||||
* Copyright (C) 2016 - 2019 EDP
|
||||
* ==
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* >>
|
||||
*
|
||||
*/
|
||||
|
||||
package org.nl.wms.common;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author /
|
||||
*/
|
||||
@Slf4j
|
||||
@SuppressWarnings({"unchecked","all"})
|
||||
public enum DataTypeEnum {
|
||||
|
||||
/** mysql */
|
||||
MYSQL("mysql", "mysql", "com.mysql.jdbc.Driver", "`", "`", "'", "'"),
|
||||
|
||||
/** oracle */
|
||||
ORACLE("oracle", "oracle", "oracle.jdbc.driver.OracleDriver", "\"", "\"", "\"", "\""),
|
||||
|
||||
/** sql server */
|
||||
SQLSERVER("sqlserver", "sqlserver", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "\"", "\"", "\"", "\""),
|
||||
|
||||
/** h2 */
|
||||
H2("h2", "h2", "org.h2.Driver", "`", "`", "\"", "\""),
|
||||
|
||||
/** phoenix */
|
||||
PHOENIX("phoenix", "hbase phoenix", "org.apache.phoenix.jdbc.PhoenixDriver", "", "", "\"", "\""),
|
||||
|
||||
/** mongo */
|
||||
MONGODB("mongo", "mongodb", "mongodb.jdbc.MongoDriver", "`", "`", "\"", "\""),
|
||||
|
||||
/** sql4es */
|
||||
ELASTICSEARCH("sql4es", "elasticsearch", "nl.anchormen.sql4es.jdbc.ESDriver", "", "", "'", "'"),
|
||||
|
||||
/** presto */
|
||||
PRESTO("presto", "presto", "com.facebook.presto.jdbc.PrestoDriver", "", "", "\"", "\""),
|
||||
|
||||
/** moonbox */
|
||||
MOONBOX("moonbox", "moonbox", "moonbox.jdbc.MbDriver", "`", "`", "`", "`"),
|
||||
|
||||
/** cassandra */
|
||||
CASSANDRA("cassandra", "cassandra", "com.github.adejanovski.cassandra.jdbc.CassandraDriver", "", "", "'", "'"),
|
||||
|
||||
/** click house */
|
||||
CLICKHOUSE("clickhouse", "clickhouse", "ru.yandex.clickhouse.ClickHouseDriver", "", "", "\"", "\""),
|
||||
|
||||
/** kylin */
|
||||
KYLIN("kylin", "kylin", "org.apache.kylin.jdbc.Driver", "\"", "\"", "\"", "\""),
|
||||
|
||||
/** vertica */
|
||||
VERTICA("vertica", "vertica", "com.vertica.jdbc.Driver", "", "", "'", "'"),
|
||||
|
||||
/** sap */
|
||||
HANA("sap", "sap hana", "com.sap.db.jdbc.Driver", "", "", "'", "'"),
|
||||
|
||||
/** impala */
|
||||
IMPALA("impala", "impala", "com.cloudera.impala.jdbc41.Driver", "", "", "'", "'");
|
||||
|
||||
private String feature;
|
||||
private String desc;
|
||||
private String driver;
|
||||
private String keywordPrefix;
|
||||
private String keywordSuffix;
|
||||
private String aliasPrefix;
|
||||
private String aliasSuffix;
|
||||
|
||||
private static final String JDBC_URL_PREFIX = "jdbc:";
|
||||
|
||||
DataTypeEnum(String feature, String desc, String driver, String keywordPrefix, String keywordSuffix, String aliasPrefix, String aliasSuffix) {
|
||||
this.feature = feature;
|
||||
this.desc = desc;
|
||||
this.driver = driver;
|
||||
this.keywordPrefix = keywordPrefix;
|
||||
this.keywordSuffix = keywordSuffix;
|
||||
this.aliasPrefix = aliasPrefix;
|
||||
this.aliasSuffix = aliasSuffix;
|
||||
}
|
||||
|
||||
public static DataTypeEnum urlOf(String jdbcUrl) {
|
||||
String url = jdbcUrl.toLowerCase().trim();
|
||||
for (DataTypeEnum dataTypeEnum : values()) {
|
||||
if (url.startsWith(JDBC_URL_PREFIX + dataTypeEnum.feature)) {
|
||||
try {
|
||||
Class<?> aClass = Class.forName(dataTypeEnum.getDriver());
|
||||
if (null == aClass) {
|
||||
throw new RuntimeException("Unable to get driver instance for jdbcUrl: " + jdbcUrl);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException("Unable to get driver instance: " + jdbcUrl);
|
||||
}
|
||||
return dataTypeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getFeature() {
|
||||
return feature;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public String getKeywordPrefix() {
|
||||
return keywordPrefix;
|
||||
}
|
||||
|
||||
public String getKeywordSuffix() {
|
||||
return keywordSuffix;
|
||||
}
|
||||
|
||||
public String getAliasPrefix() {
|
||||
return aliasPrefix;
|
||||
}
|
||||
|
||||
public String getAliasSuffix() {
|
||||
return aliasSuffix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
|
||||
package org.nl.wms.ext.sap.rest;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.ext.sap.service.WmsToSapService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhouz
|
||||
* @date 2021-07-21
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "wms发送sap")
|
||||
@RequestMapping("/api/sap/")
|
||||
@Slf4j
|
||||
public class WmsToSapController {
|
||||
private final WmsToSapService wmsToSapService;
|
||||
|
||||
@PostMapping("/getMater")
|
||||
@Log("获取物料基础信息")
|
||||
@ApiOperation("获取物料基础信息")
|
||||
public ResponseEntity<Object> getMater(@RequestBody JSONObject form) {
|
||||
return new ResponseEntity<>(wmsToSapService.getMater(form), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getSaleOrder")
|
||||
@Log("获取销售订单")
|
||||
@ApiOperation("获取销售订单")
|
||||
public ResponseEntity<Object> getSaleOrder(@RequestBody JSONObject form) {
|
||||
return new ResponseEntity<>(wmsToSapService.getSaleOrder(form), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getDeliveryNote")
|
||||
@Log("获取物料基础信息")
|
||||
@ApiOperation("获取物料基础信息")
|
||||
public ResponseEntity<Object> getDeliveryNote(@RequestBody JSONObject form) {
|
||||
return new ResponseEntity<>(wmsToSapService.getDeliveryNote(form), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.nl.wms.ext.sap.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface WmsToSapService {
|
||||
/**
|
||||
* WMS客户端--->SAP服务端
|
||||
* 获取物料信息
|
||||
*
|
||||
* @param form
|
||||
* @return JSONObject
|
||||
*/
|
||||
|
||||
JSONObject getMater(JSONObject form);
|
||||
|
||||
/**
|
||||
* WMS客户端--->SAP服务端
|
||||
* 获取销售订单
|
||||
*
|
||||
* @param form
|
||||
* @return JSONObject
|
||||
*/
|
||||
|
||||
JSONObject getSaleOrder(JSONObject form);
|
||||
|
||||
/**
|
||||
* WMS客户端--->SAP服务端
|
||||
* 获取交货单
|
||||
*
|
||||
* @param form
|
||||
* @return JSONObject
|
||||
*/
|
||||
|
||||
JSONObject getDeliveryNote(JSONObject form);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
package org.nl.wms.ext.sap.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.util.StringUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.json.XML;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.exception.WDKException;
|
||||
import org.nl.wms.WebServiceUtil;
|
||||
import org.nl.wms.ext.sap.service.WmsToSapService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class WmsToSapServiceImpl implements WmsToSapService {
|
||||
|
||||
@Override
|
||||
public JSONObject getMater(JSONObject form) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getDateStr(int day) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date todayDate = new Date();
|
||||
long beforeTime = (todayDate.getTime() / 1000) - 60 * 60 * 24 * day;
|
||||
todayDate.setTime(beforeTime * 1000);
|
||||
String beforeDate = formatter.format(todayDate);
|
||||
return beforeDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getSaleOrder(JSONObject form) {
|
||||
log.info("导入方法开始");
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
String url = "http://192.168.0.82:8000/sap/bc/srt/rfc/sap/zfg_ecc_to_zhwl/800/zfg_ecc_to_zhwl/binding";
|
||||
String method = "ZfmGetSo";
|
||||
|
||||
if (StrUtil.equals(form.getString("is_auto"), "1")) {
|
||||
form.put("IErdatFrm", getDateStr(1));
|
||||
form.put("IErdatTo", getDateStr(0));
|
||||
form.put("IVbeln", ""); // 非必填字段
|
||||
}
|
||||
|
||||
String bill_code = form.getString("bill_code");
|
||||
String date_begin = form.getString("date_begin");
|
||||
String date_end = form.getString("date_end");
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("IVbeln", "");
|
||||
map.put("IErdatFrm", "");
|
||||
map.put("IErdatTo", "");
|
||||
if (StrUtil.isNotEmpty(bill_code)) {
|
||||
map.put("IVbeln", bill_code);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(date_begin)) {
|
||||
map.put("IErdatFrm", date_begin);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(date_end)) {
|
||||
map.put("IErdatTo", date_end);
|
||||
}
|
||||
|
||||
JSONObject ZfmGetSoResponse = null;
|
||||
try {
|
||||
String response = WebServiceUtil.process(url, method, map);
|
||||
JSONObject ret = JSONObject.parseObject(XML.toJSONObject(response).toString());
|
||||
log.info("getXML发送数据-----------------" + ret.toString());
|
||||
JSONObject Envelope = ret.getJSONObject("soap-env:Envelope");
|
||||
JSONObject Body = Envelope.getJSONObject("soap-env:Body");
|
||||
ZfmGetSoResponse = Body.getJSONObject("n0:ZfmGetSoResponse");
|
||||
String check = ZfmGetSoResponse.getString("OResultcode");
|
||||
if ("1005".equals(check)) {
|
||||
System.out.println(ZfmGetSoResponse.getString("OResultmsg"));
|
||||
throw new BadRequestException("sap返回:" + ZfmGetSoResponse.getString("OResultmsg"));
|
||||
} else if (!"1000".equals(check)) {
|
||||
throw new BadRequestException("sap返回:" + ZfmGetSoResponse.getString("OResultmsg"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
JSONObject TZtsalesorder = ZfmGetSoResponse.getJSONObject("TZtsalesorder");
|
||||
log.info("TZtsalesorder为:" + TZtsalesorder.toString());
|
||||
JSONArray item = TZtsalesorder.getJSONArray("item");
|
||||
|
||||
if (TZtsalesorder == null || item == null || item.size() == 0) {
|
||||
result.put("message", "sap无可同步数据");
|
||||
return result;
|
||||
}
|
||||
|
||||
int err_num = 0;
|
||||
for (int i = 0; i < item.size(); i++) {
|
||||
JSONObject row = item.getJSONObject(i);
|
||||
boolean need_update = false;
|
||||
JSONObject sale_jo = WQLObject.getWQLObject("pcs_sale_order").query("sale_code = '" + row.getString("Vbeln") + "' AND seq_no = '" + row.getString("Posnr") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(sale_jo)) {
|
||||
sale_jo = new JSONObject();
|
||||
sale_jo.put("sale_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
} else {
|
||||
need_update = true;
|
||||
if (!sale_jo.getString("status").equals("10")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
sale_jo.put("is_success", "1");
|
||||
sale_jo.put("sale_code", row.getString("Vbeln"));
|
||||
sale_jo.put("seq_no", row.getString("Posnr"));
|
||||
sale_jo.put("sale_type", row.getString("Auart"));
|
||||
String material_code = row.getString("Matnr").replaceAll("^(0+)", "");
|
||||
//获取物料对应的物料标识
|
||||
JSONObject mater_jo = WQLObject.getWQLObject("MD_ME_MaterialBase").query("material_code = '" + material_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(mater_jo)) {
|
||||
sale_jo.put("material_id", "0");
|
||||
sale_jo.put("is_success", "0");
|
||||
sale_jo.put("remark", "未查询到该销售订单对应的物料主数据:" + material_code);
|
||||
err_num++;
|
||||
} else {
|
||||
String material_id = mater_jo.getString("material_id");
|
||||
sale_jo.put("material_id", material_id);
|
||||
}
|
||||
sale_jo.put("status", "10");
|
||||
sale_jo.put("sale_qty", row.getString("Kwmeng"));
|
||||
sale_jo.put("produce_seq", "1");
|
||||
String cust_code = row.getString("Kunnr");
|
||||
JSONObject cust_jo = WQLObject.getWQLObject("md_cs_customerbase").query("cust_code = '" + cust_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(cust_jo)) {
|
||||
sale_jo.put("cust_id", cust_jo.getString("cust_id"));
|
||||
sale_jo.put("cust_code", cust_jo.getString("cust_code"));
|
||||
sale_jo.put("cust_name", cust_jo.getString("cust_name"));
|
||||
} else {
|
||||
sale_jo.put("is_success", "0");
|
||||
sale_jo.put("remark", "未查询到该销售订单对应的客户信息:" + cust_code);
|
||||
err_num++;
|
||||
}
|
||||
String unit_code = row.getString("Vrkme");
|
||||
JSONObject unit_jo = WQLObject.getWQLObject("md_pb_measureunit").query("unit_name = '" + unit_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(unit_jo)) {
|
||||
sale_jo.put("qty_unit_id", "0");
|
||||
sale_jo.put("remark", "未查询到该销售订单对应的单位信息:" + unit_code);
|
||||
err_num++;
|
||||
} else {
|
||||
sale_jo.put("qty_unit_id", unit_jo.getString("measure_unit_id"));
|
||||
}
|
||||
sale_jo.put("plandeliver_date", row.getString("Edaut"));
|
||||
sale_jo.put("create_id", SecurityUtils.getCurrentUserId());
|
||||
sale_jo.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
sale_jo.put("create_time", DateUtil.now());
|
||||
sale_jo.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
sale_jo.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
sale_jo.put("update_time", DateUtil.now());
|
||||
|
||||
if (need_update) {
|
||||
WQLObject.getWQLObject("pcs_sale_order").update(sale_jo);
|
||||
} else {
|
||||
WQLObject.getWQLObject("pcs_sale_order").insert(sale_jo);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (err_num > 0) {
|
||||
result.put("message", "导入成功!一共导入:" + item.size() + "条数据,其中有误数据:" + err_num + "条!");
|
||||
} else {
|
||||
result.put("message", "导入成功!一共导入:" + item.size() + "条数据!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeliveryNote(JSONObject form) {
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
String url = "http://192.168.0.82:8000/sap/bc/srt/rfc/sap/zfg_ecc_to_zhwl/800/zfg_ecc_to_zhwl/binding";
|
||||
String method = "ZfmGetDnZjwl";
|
||||
|
||||
if (StrUtil.equals(form.getString("is_auto"), "1")) {
|
||||
form.put("IErdatFrm", getDateStr(1));
|
||||
form.put("IErdatTo", getDateStr(0));
|
||||
form.put("IVbeln", ""); // 非必填字段
|
||||
}
|
||||
|
||||
String bill_code = form.getString("bill_code");
|
||||
String date_begin = form.getString("date_begin");
|
||||
String date_end = form.getString("date_end");
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("IVbeln", "");
|
||||
map.put("IErdatFrm", "");
|
||||
map.put("IErdatTo", "");
|
||||
if (StrUtil.isNotEmpty(bill_code)) {
|
||||
map.put("IVbeln", bill_code);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(date_begin)) {
|
||||
map.put("IErdatFrm", date_begin);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(date_end)) {
|
||||
map.put("IErdatTo", date_end);
|
||||
}
|
||||
|
||||
JSONObject ZfmGetSoResponse = null;
|
||||
try {
|
||||
String response = WebServiceUtil.process(url, method, map);
|
||||
JSONObject ret = JSONObject.parseObject(XML.toJSONObject(response).toString());
|
||||
log.info("getXML发送数据-----------------" + ret.toString());
|
||||
JSONObject Envelope = ret.getJSONObject("soap-env:Envelope");
|
||||
JSONObject Body = Envelope.getJSONObject("soap-env:Body");
|
||||
ZfmGetSoResponse = Body.getJSONObject("n0:ZfmGetDnZjwlResponse");
|
||||
String check = ZfmGetSoResponse.getString("OResultcode");
|
||||
if ("1005".equals(check)) {
|
||||
System.out.println(ZfmGetSoResponse.getString("OResultmsg"));
|
||||
throw new BadRequestException("sap返回:" + ZfmGetSoResponse.getString("OResultmsg"));
|
||||
} else if (!"1000".equals(check)) {
|
||||
throw new BadRequestException("sap返回:" + ZfmGetSoResponse.getString("OResultmsg"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
log.info(ZfmGetSoResponse.toString());
|
||||
JSONObject TZtsalesorder = ZfmGetSoResponse.getJSONObject("TZtdn");
|
||||
log.info("TZtsalesorder数据为:-------------------" + TZtsalesorder.toString());
|
||||
JSONArray item = TZtsalesorder.getJSONArray("item");
|
||||
log.info(item.size() + "");
|
||||
|
||||
if (TZtsalesorder == null || item == null || item.size() == 0) {
|
||||
result.put("message", "sap无可同步数据");
|
||||
return result;
|
||||
}
|
||||
|
||||
int err_num = 0;
|
||||
for (int i = 0; i < item.size(); i++) {
|
||||
boolean need_update = false;
|
||||
JSONObject row = item.getJSONObject(i);
|
||||
JSONObject deliver_jo = WQLObject.getWQLObject("pcs_delivery_order").query("deliver_code = '" + row.getString("Vbeln") + "' AND seq_no = '" + row.getString("Posnr") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(deliver_jo)) {
|
||||
deliver_jo = new JSONObject();
|
||||
deliver_jo.put("deliver_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
} else {
|
||||
need_update = true;
|
||||
if (!deliver_jo.getString("status").equals("10")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
deliver_jo.put("deliver_code", row.getString("Vbeln"));
|
||||
deliver_jo.put("seq_no", row.getString("Posnr"));
|
||||
deliver_jo.put("deliver_type", row.getString("Lfart"));
|
||||
String material_code = row.getString("Matnr").replaceAll("^(0+)", "");
|
||||
//获取物料对应的物料标识
|
||||
JSONObject mater_jo = WQLObject.getWQLObject("MD_ME_MaterialBase").query("material_code = '" + material_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(mater_jo)) {
|
||||
deliver_jo.put("material_id", "0");
|
||||
deliver_jo.put("is_success", "0");
|
||||
deliver_jo.put("remark", "未查询到该交货单对应的物料主数据:" + material_code);
|
||||
err_num++;
|
||||
} else {
|
||||
String material_id = mater_jo.getString("material_id");
|
||||
deliver_jo.put("material_id", material_id);
|
||||
}
|
||||
deliver_jo.put("status", "10");
|
||||
deliver_jo.put("delivery_qty", row.getString("Lfimg"));
|
||||
String cust_code = row.getString("Kunnr");
|
||||
JSONObject cust_jo = WQLObject.getWQLObject("md_cs_customerbase").query("cust_code = '" + cust_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(cust_jo)) {
|
||||
deliver_jo.put("cust_id", cust_jo.getString("cust_id"));
|
||||
deliver_jo.put("cust_code", cust_jo.getString("cust_code"));
|
||||
deliver_jo.put("cust_name", cust_jo.getString("cust_name"));
|
||||
} else {
|
||||
deliver_jo.put("is_success", "0");
|
||||
deliver_jo.put("remark", "未查询到该交货单对应的客户信息:" + cust_code);
|
||||
err_num++;
|
||||
}
|
||||
String unit_code = row.getString("Vrkme");
|
||||
JSONObject unit_jo = WQLObject.getWQLObject("md_pb_measureunit").query("unit_name = '" + unit_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(unit_jo)) {
|
||||
deliver_jo.put("qty_unit_id", "0");
|
||||
deliver_jo.put("remark", "未查询到该交货单对应的单位信息:" + unit_code);
|
||||
err_num++;
|
||||
} else {
|
||||
deliver_jo.put("qty_unit_id", unit_jo.getString("measure_unit_id"));
|
||||
}
|
||||
String sale_code = row.getString("Vgbel");
|
||||
String seq_no = row.getString("Vgpos");
|
||||
JSONObject sale_jo = WQLObject.getWQLObject("pcs_sale_order").query("sale_code = '" + sale_code + "' AND seq_no = '" + seq_no + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(sale_jo)) {
|
||||
deliver_jo.put("remark", "未查询到该交货单对应的销售订单:" + unit_code + "行号为:" + seq_no);
|
||||
deliver_jo.put("is_success", "0");
|
||||
} else {
|
||||
deliver_jo.put("sale_id", sale_jo.getString("sale_id"));
|
||||
deliver_jo.put("sale_code", sale_jo.getString("sale_code"));
|
||||
deliver_jo.put("sale_seq_no", sale_jo.getString("seq_no"));
|
||||
}
|
||||
deliver_jo.put("create_id", SecurityUtils.getCurrentUserId());
|
||||
deliver_jo.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
deliver_jo.put("create_time", DateUtil.now());
|
||||
deliver_jo.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
deliver_jo.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
deliver_jo.put("update_time", DateUtil.now());
|
||||
if (need_update) {
|
||||
WQLObject.getWQLObject("pcs_delivery_order").update(deliver_jo);
|
||||
} else {
|
||||
WQLObject.getWQLObject("pcs_delivery_order").insert(deliver_jo);
|
||||
}
|
||||
}
|
||||
if (err_num > 0) {
|
||||
result.put("message", "导入成功!一共导入:" + item.size() + "条数据,其中有误数据:" + err_num + "条!");
|
||||
} else {
|
||||
result.put("message", "导入成功!一共导入:" + item.size() + "条数据!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
[交易说明]
|
||||
交易名: 库区分页查询
|
||||
所属模块:
|
||||
功能简述:
|
||||
版权所有:
|
||||
表引用:
|
||||
版本经历:
|
||||
|
||||
[数据库]
|
||||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库
|
||||
|
||||
[IO定义]
|
||||
#################################################
|
||||
## 表字段对应输入参数
|
||||
#################################################
|
||||
|
||||
|
||||
输入.flag TYPEAS s_string
|
||||
输入.import_date1 TYPEAS s_string
|
||||
输入.import_date2 TYPEAS s_string
|
||||
输入.import_date3 TYPEAS s_string
|
||||
输入.import_date4 TYPEAS s_string
|
||||
输入.begin_time TYPEAS s_string
|
||||
输入.end_time TYPEAS s_string
|
||||
|
||||
|
||||
|
||||
[临时表]
|
||||
--这边列出来的临时表就会在运行期动态创建
|
||||
|
||||
[临时变量]
|
||||
--所有中间过程变量均可在此处定义
|
||||
|
||||
[业务过程]
|
||||
|
||||
##########################################
|
||||
# 1、输入输出检查 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 2、主过程前处理 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 3、业务主过程 #
|
||||
##########################################
|
||||
|
||||
IF 输入.flag = "1"
|
||||
QUERY
|
||||
SELECT
|
||||
mater.*
|
||||
FROM
|
||||
V_SAP_ORG mater
|
||||
WHERE 1=1
|
||||
OPTION 输入.import_date3 <> ""
|
||||
(pp.UPDATED_DATE > to_date(输入.import_date3,'yyyy-mm-dd HH24:MI:SS')
|
||||
OR
|
||||
pp.CREATE_DATE > to_date(输入.import_date3,'yyyy-mm-dd HH24:MI:SS')
|
||||
)
|
||||
ENDOPTION
|
||||
OPTION 输入.begin_time <> ""
|
||||
mater.EDIT_TIME >= to_date(输入.begin_time,'yyyy-mm-dd HH24:MI:SS')
|
||||
ENDOPTION
|
||||
OPTION 输入.end_time <> ""
|
||||
mater.EDIT_TIME <= to_date(输入.end_time,'yyyy-mm-dd HH24:MI:SS')
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "2"
|
||||
QUERY
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
ITEM
|
||||
WHERE
|
||||
(UPDATED_DATE > to_date(输入.import_date2,'yyyy-mm-dd HH24:MI:SS')
|
||||
OR
|
||||
CREATE_DATE > to_date(输入.import_date2,'yyyy-mm-dd HH24:MI:SS')
|
||||
)
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "3"
|
||||
QUERY
|
||||
SELECT
|
||||
pp.*
|
||||
FROM
|
||||
PURCHASE pp
|
||||
WHERE 1=1
|
||||
OPTION 输入.import_date3 <> ""
|
||||
(pp.UPDATED_DATE > to_date(输入.import_date3,'yyyy-mm-dd HH24:MI:SS')
|
||||
OR
|
||||
pp.CREATE_DATE > to_date(输入.import_date3,'yyyy-mm-dd HH24:MI:SS')
|
||||
)
|
||||
ENDOPTION
|
||||
OPTION 输入.begin_time <> ""
|
||||
pp.CREATE_DATE >= to_date(输入.begin_time,'yyyy-mm-dd HH24:MI:SS')
|
||||
ENDOPTION
|
||||
OPTION 输入.end_time <> ""
|
||||
pp.CREATE_DATE <= to_date(输入.end_time,'yyyy-mm-dd HH24:MI:SS')
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "4"
|
||||
QUERY
|
||||
SELECT
|
||||
pp.*
|
||||
FROM
|
||||
SALE_OUT pp
|
||||
WHERE 1=1
|
||||
|
||||
OPTION 输入.begin_time <> ""
|
||||
pp.dbilldate >= 输入.begin_time
|
||||
ENDOPTION
|
||||
OPTION 输入.end_time <> ""
|
||||
pp.dbilldate <= 输入.end_time
|
||||
ENDOPTION
|
||||
OPTION 输入.fbillflag <> ""
|
||||
pp.fbillflag = 输入.fbillflag
|
||||
ENDOPTION
|
||||
OPTION 输入.vbillcode <> ""
|
||||
pp.vbillcode like 输入.vbillcode
|
||||
ENDOPTION
|
||||
OPTION 输入.cmaterialvid <> ""
|
||||
pp.cmaterialvid = 输入.cmaterialvid
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "5"
|
||||
QUERY
|
||||
SELECT
|
||||
pp.*
|
||||
FROM
|
||||
PURCHASE_IN pp
|
||||
WHERE 1=1
|
||||
OPTION 输入.import_date4 <> ""
|
||||
pp.CREATIONTIME > 输入.import_date4
|
||||
ENDOPTION
|
||||
OPTION 输入.begin_time <> ""
|
||||
pp.CREATIONTIME >= 输入.begin_time
|
||||
ENDOPTION
|
||||
OPTION 输入.end_time <> ""
|
||||
pp.CREATIONTIME <= 输入.end_time
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -50,12 +50,14 @@ public class DeliveryOrderServiceImpl implements DeliveryOrderService {
|
||||
String begin_time = MapUtil.getStr(whereJson, "begin_time");
|
||||
String end_time = MapUtil.getStr(whereJson, "end_time");
|
||||
String status = MapUtil.getStr(whereJson, "status");
|
||||
String is_success = MapUtil.getStr(whereJson, "is_success");
|
||||
String product_series = "";
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("flag", "1");
|
||||
map.put("begin_time", begin_time);
|
||||
map.put("end_time", end_time);
|
||||
map.put("status", status);
|
||||
map.put("is_success", is_success);
|
||||
if (StrUtil.isNotEmpty(material)) {
|
||||
map.put("material", "%" + material + "%");
|
||||
}
|
||||
|
||||
@@ -50,12 +50,14 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
||||
String begin_time = MapUtil.getStr(whereJson, "begin_time");
|
||||
String end_time = MapUtil.getStr(whereJson, "end_time");
|
||||
String status = MapUtil.getStr(whereJson, "status");
|
||||
String is_success = MapUtil.getStr(whereJson, "is_success");
|
||||
String product_series = "";
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("flag", "1");
|
||||
map.put("begin_time", begin_time);
|
||||
map.put("end_time", end_time);
|
||||
map.put("status", status);
|
||||
map.put("is_success", is_success);
|
||||
if (StrUtil.isNotEmpty(sale_code)) {
|
||||
map.put("sale_code", "%" + sale_code + "%");
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
输入.material TYPEAS s_string
|
||||
输入.product_series TYPEAS f_string
|
||||
输入.status TYPEAS s_string
|
||||
输入.is_success TYPEAS s_string
|
||||
输入.begin_time TYPEAS s_string
|
||||
输入.end_time TYPEAS s_string
|
||||
|
||||
@@ -62,6 +63,9 @@
|
||||
OPTION 输入.status <> ""
|
||||
deliveryorder.status = 输入.status
|
||||
ENDOPTION
|
||||
OPTION 输入.is_success <> ""
|
||||
deliveryorder.is_success = 输入.is_success
|
||||
ENDOPTION
|
||||
OPTION 输入.product_series <> ""
|
||||
material.product_series in 输入.product_series
|
||||
ENDOPTION
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
输入.material TYPEAS s_string
|
||||
输入.product_series TYPEAS f_string
|
||||
输入.status TYPEAS s_string
|
||||
输入.is_success TYPEAS s_string
|
||||
输入.begin_time TYPEAS s_string
|
||||
输入.end_time TYPEAS s_string
|
||||
|
||||
@@ -62,6 +63,9 @@
|
||||
OPTION 输入.status <> ""
|
||||
saleorder.status = 输入.status
|
||||
ENDOPTION
|
||||
OPTION 输入.is_success <> ""
|
||||
saleorder.is_success = 输入.is_success
|
||||
ENDOPTION
|
||||
OPTION 输入.product_series <> ""
|
||||
material.product_series in 输入.product_series
|
||||
ENDOPTION
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
package org.nl.wms.sch.manage;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wms.ext.sap.service.WmsToSapService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AutoImportDeliverOrder {
|
||||
private final WmsToSapService wmsToSapService;
|
||||
|
||||
public void run() {
|
||||
//通过ACS接口获取温度
|
||||
JSONObject form = new JSONObject();
|
||||
form.put("is_auto", "1");
|
||||
wmsToSapService.getDeliveryNote(form);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.nl.wms.sch.manage;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.ext.sap.service.WmsToSapService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AutoImportSaleOrder {
|
||||
private final WmsToSapService wmsToSapService;
|
||||
|
||||
public void run() {
|
||||
//通过ACS接口获取温度
|
||||
JSONObject form = new JSONObject();
|
||||
form.put("is_auto", "1");
|
||||
wmsToSapService.getSaleOrder(form);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user