更新
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.acs.common;
|
package org.nl.acs.common;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@@ -9,6 +10,7 @@ import java.io.InputStreamReader;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -27,7 +29,7 @@ public class WebServiceUtil {
|
|||||||
* @return 第三方系统返回的JSONObject调用结果
|
* @return 第三方系统返回的JSONObject调用结果
|
||||||
* @throws Exception 工具类一般不处理具体异常,抛出由调用方处理,否则容易形成黑箱
|
* @throws Exception 工具类一般不处理具体异常,抛出由调用方处理,否则容易形成黑箱
|
||||||
*/
|
*/
|
||||||
public static String process(String url, String method, HashMap<String, String> form) throws Exception {
|
public static String process(String url, String method, JSONObject form) throws Exception {
|
||||||
//构建返回值
|
//构建返回值
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
//第一步:创建服务地址
|
//第一步:创建服务地址
|
||||||
@@ -69,7 +71,7 @@ public class WebServiceUtil {
|
|||||||
//获取当前连接请求返回的数据流
|
//获取当前连接请求返回的数据流
|
||||||
InputStream is = connection.getInputStream();
|
InputStream is = connection.getInputStream();
|
||||||
|
|
||||||
InputStreamReader isr = new InputStreamReader(is, "utf-8");
|
InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
BufferedReader br = new BufferedReader(isr);
|
BufferedReader br = new BufferedReader(isr);
|
||||||
|
|
||||||
@@ -88,9 +90,9 @@ public class WebServiceUtil {
|
|||||||
ret = ret.replaceAll("\\<\\?.+\\?\\>", "<?xml version='1.0' encoding='UTF-8'?>");
|
ret = ret.replaceAll("\\<\\?.+\\?\\>", "<?xml version='1.0' encoding='UTF-8'?>");
|
||||||
else
|
else
|
||||||
ret = (new StringBuilder("<?xml version='1.0' encoding='UTF-8'?>")).append(ret).toString();
|
ret = (new StringBuilder("<?xml version='1.0' encoding='UTF-8'?>")).append(ret).toString();
|
||||||
|
|
||||||
/* String now = xml2jsonString(ret);
|
/* String now = xml2jsonString(ret);
|
||||||
System.out.println("打印返回结果转成jsonString-------------");
|
System.out.println("打印返回结果转成jsonString-------------");
|
||||||
result =JSONObject.parseObject(now);*/
|
result =JSONObject.parseObject(now);*/
|
||||||
is.close();
|
is.close();
|
||||||
isr.close();
|
isr.close();
|
||||||
@@ -110,28 +112,17 @@ public class WebServiceUtil {
|
|||||||
* @param form 查询条件
|
* @param form 查询条件
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static String getXML(Map<String, String> form, String method) {
|
private static String getXML(JSONObject form, String method) {
|
||||||
StringBuffer sb = new StringBuffer();
|
return "<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
|
||||||
sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?> ");
|
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\"" +
|
||||||
sb.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:soap:functions:mc-style\">");
|
"<soapenv:Header/>" +
|
||||||
sb.append("<soapenv:Header/>");
|
"<soapenv:Body>" +
|
||||||
sb.append("<soapenv:Body>");
|
"<tem:" + method + ">" +
|
||||||
sb.append("<urn:" + method + ">");
|
"<tem:JsonStr>" +
|
||||||
if (method.contains("ZSd0002SendMatMd"))
|
form.toJSONString() +
|
||||||
sb.append("<In>");
|
"</tem:JsonStr>" +
|
||||||
// 设置请求参数
|
"</tem:" + method + ">" +
|
||||||
for (Iterator<String> it = form.keySet().iterator(); it.hasNext(); ) {
|
"</soapenv:Body>" +
|
||||||
String key = it.next();
|
"</soapenv:Envelope>";
|
||||||
String value = form.get(key);
|
|
||||||
sb.append(" <" + key + ">" + value + "</" + key + ">");
|
|
||||||
}
|
|
||||||
if (method.contains("ZSd0002SendMatMd"))
|
|
||||||
sb.append("</In>");
|
|
||||||
sb.append("</urn:" + method + ">");
|
|
||||||
sb.append("</soapenv:Body>");
|
|
||||||
sb.append("</soapenv:Envelope>");
|
|
||||||
log.info("getXML组织参数为-----------------" + sb.toString());
|
|
||||||
return sb.toString();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import org.nl.acs.log.service.DeviceExecuteLogService;
|
|||||||
import org.nl.acs.task.service.TaskService;
|
import org.nl.acs.task.service.TaskService;
|
||||||
import org.nl.acs.task.service.dto.TaskDto;
|
import org.nl.acs.task.service.dto.TaskDto;
|
||||||
import org.nl.acs.wsdl.org.tempuri.IRTMSAGVSERVICE;
|
import org.nl.acs.wsdl.org.tempuri.IRTMSAGVSERVICE;
|
||||||
|
import org.nl.acs.wsdl.org.tempuri.RTMSAGVSERVICE;
|
||||||
import org.nl.modules.system.service.ParamService;
|
import org.nl.modules.system.service.ParamService;
|
||||||
import org.slf4j.MDC;
|
import org.slf4j.MDC;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -538,14 +539,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
MDC.put(log_file_type, log_type);
|
MDC.put(log_file_type, log_type);
|
||||||
// log.info("shipDeviceUpdate-----输入参数{}", param);
|
// log.info("shipDeviceUpdate-----输入参数{}", param);
|
||||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
|
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
|
||||||
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
|
String s = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(param.toJSONString());
|
||||||
AddressDto addressDto = addressService.findByCode("taskExecution");
|
log.info(s);
|
||||||
String methods_url = addressDto.getMethods_url();
|
|
||||||
String url = wmsUrl + methods_url;
|
|
||||||
return HttpRequest
|
|
||||||
.post(url)
|
|
||||||
.body(param.toString())
|
|
||||||
.execute();
|
|
||||||
}
|
}
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
|
|
||||||
|
|||||||
@@ -465,7 +465,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
for (int i = 0; i < datas.size(); i++) {
|
for (int i = 0; i < datas.size(); i++) {
|
||||||
String data = datas.get(i).toString();
|
String data = datas.get(i).toString();
|
||||||
CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class);
|
CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class);
|
||||||
String ext_task_id = request.getREQCODE();
|
// String ext_task_id = request.getREQCODE();
|
||||||
String task_code = request.getTASKCODE();
|
String task_code = request.getTASKCODE();
|
||||||
String start_device_code = request.getSTARTPOSITION();
|
String start_device_code = request.getSTARTPOSITION();
|
||||||
// String start_device_code2 = request.getStart_device_code2();
|
// String start_device_code2 = request.getStart_device_code2();
|
||||||
@@ -493,21 +493,21 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
String next_point_code2 = "";
|
String next_point_code2 = "";
|
||||||
String put_point_code = "";
|
String put_point_code = "";
|
||||||
if (StrUtil.isEmpty(task_code)) {
|
if (StrUtil.isEmpty(task_code)) {
|
||||||
response.setREQCODE(ext_task_id);
|
response.setREQCODE(task_code);
|
||||||
response.setREPLYTIME(DateUtil.now());
|
response.setREPLYTIME(DateUtil.now());
|
||||||
response.setREQCODE("1");
|
response.setREQCODE("1");
|
||||||
response.setRTMSG("任务号不能为空!");
|
response.setRTMSG("任务号不能为空!");
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
if (StrUtil.isEmpty(start_device_code)) {
|
if (StrUtil.isEmpty(start_device_code)) {
|
||||||
response.setREQCODE(ext_task_id);
|
response.setREQCODE(task_code);
|
||||||
response.setREPLYTIME(DateUtil.now());
|
response.setREPLYTIME(DateUtil.now());
|
||||||
response.setREQCODE("1");
|
response.setREQCODE("1");
|
||||||
response.setRTMSG("起点不能为空!");
|
response.setRTMSG("起点不能为空!");
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
if (StrUtil.isEmpty(next_device_code)) {
|
if (StrUtil.isEmpty(next_device_code)) {
|
||||||
response.setREQCODE(ext_task_id);
|
response.setREQCODE(task_code);
|
||||||
response.setREPLYTIME(DateUtil.now());
|
response.setREPLYTIME(DateUtil.now());
|
||||||
response.setREQCODE("1");
|
response.setREQCODE("1");
|
||||||
response.setRTMSG("终点不能为空!");
|
response.setRTMSG("终点不能为空!");
|
||||||
@@ -584,7 +584,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
// }
|
// }
|
||||||
TaskDto taskDto = taskService.findByCodeFromCache(task_code);
|
TaskDto taskDto = taskService.findByCodeFromCache(task_code);
|
||||||
if (taskDto != null) {
|
if (taskDto != null) {
|
||||||
response.setREQCODE(ext_task_id);
|
response.setREQCODE(task_code);
|
||||||
response.setREPLYTIME(DateUtil.now());
|
response.setREPLYTIME(DateUtil.now());
|
||||||
response.setREQCODE("1");
|
response.setREQCODE("1");
|
||||||
response.setRTMSG("不能存在相同的任务号!");
|
response.setRTMSG("不能存在相同的任务号!");
|
||||||
@@ -593,7 +593,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
if (!StrUtil.isEmpty(vehicle_code)) {
|
if (!StrUtil.isEmpty(vehicle_code)) {
|
||||||
TaskDto vehicle_dto = taskService.findByContainer(vehicle_code);
|
TaskDto vehicle_dto = taskService.findByContainer(vehicle_code);
|
||||||
if (vehicle_dto != null) {
|
if (vehicle_dto != null) {
|
||||||
response.setREQCODE(ext_task_id);
|
response.setREQCODE(task_code);
|
||||||
response.setREPLYTIME(DateUtil.now());
|
response.setREPLYTIME(DateUtil.now());
|
||||||
response.setREQCODE("1");
|
response.setREQCODE("1");
|
||||||
response.setRTMSG("不能存在相同的料车号!");
|
response.setRTMSG("不能存在相同的料车号!");
|
||||||
@@ -602,14 +602,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (StrUtil.isEmpty(start_point_code)) {
|
if (StrUtil.isEmpty(start_point_code)) {
|
||||||
response.setREQCODE(ext_task_id);
|
response.setREQCODE(task_code);
|
||||||
response.setREPLYTIME(DateUtil.now());
|
response.setREPLYTIME(DateUtil.now());
|
||||||
response.setREQCODE("1");
|
response.setREQCODE("1");
|
||||||
response.setRTMSG(start_device_code + "未找到对应点位!");
|
response.setRTMSG(start_device_code + "未找到对应点位!");
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
if (StrUtil.isEmpty(next_point_code)) {
|
if (StrUtil.isEmpty(next_point_code)) {
|
||||||
response.setREQCODE(ext_task_id);
|
response.setREQCODE(task_code);
|
||||||
response.setREPLYTIME(DateUtil.now());
|
response.setREPLYTIME(DateUtil.now());
|
||||||
response.setREQCODE("1");
|
response.setREQCODE("1");
|
||||||
response.setRTMSG(next_device_code + "未找到对应点位!");
|
response.setRTMSG(next_device_code + "未找到对应点位!");
|
||||||
@@ -618,7 +618,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
|
|
||||||
JSONObject jo = new JSONObject();
|
JSONObject jo = new JSONObject();
|
||||||
jo.put("task_code", task_code);
|
jo.put("task_code", task_code);
|
||||||
jo.put("task_id", ext_task_id);
|
jo.put("task_id", task_code);
|
||||||
jo.put("start_point_code", start_point_code);
|
jo.put("start_point_code", start_point_code);
|
||||||
jo.put("next_point_code", next_point_code);
|
jo.put("next_point_code", next_point_code);
|
||||||
jo.put("start_point_code2", start_point_code2);
|
jo.put("start_point_code2", start_point_code2);
|
||||||
@@ -641,8 +641,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
jo.put("params", params);
|
jo.put("params", params);
|
||||||
jo.put("task_type", task_type);
|
jo.put("task_type", task_type);
|
||||||
|
|
||||||
if (!StrUtil.isEmpty(ext_task_id)) {
|
if (!StrUtil.isEmpty(task_code)) {
|
||||||
jo.put("ext_task_id", ext_task_id);
|
jo.put("ext_task_id", task_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskDto task_dto = jo.toJavaObject(TaskDto.class);
|
TaskDto task_dto = jo.toJavaObject(TaskDto.class);
|
||||||
@@ -675,7 +675,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
} else {
|
} else {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("task_code", task_code);
|
json.put("task_code", task_code);
|
||||||
json.put("ext_task_id", ext_task_id);
|
// json.put("ext_task_id", ext_task_id);
|
||||||
json.put("message", resp.getComment());
|
json.put("message", resp.getComment());
|
||||||
json.put("code", resp.code);
|
json.put("code", resp.code);
|
||||||
json.put("data", data);
|
json.put("data", data);
|
||||||
@@ -688,7 +688,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
response.setREQCODE(ext_task_id);
|
response.setREQCODE(task_code);
|
||||||
response.setREPLYTIME(DateUtil.now());
|
response.setREPLYTIME(DateUtil.now());
|
||||||
response.setREQCODE("1");
|
response.setREQCODE("1");
|
||||||
response.setRTMSG(e.getMessage());
|
response.setRTMSG(e.getMessage());
|
||||||
|
|||||||
@@ -2,12 +2,14 @@
|
|||||||
package org.nl.acs.test.rest;
|
package org.nl.acs.test.rest;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.acs.test.service.TestService;
|
import org.nl.acs.test.service.TestService;
|
||||||
import org.nl.modules.logging.annotation.Log;
|
import org.nl.modules.logging.annotation.Log;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@@ -34,10 +36,12 @@ public class TestController {
|
|||||||
@Log("test1")
|
@Log("test1")
|
||||||
@ApiOperation("test1")
|
@ApiOperation("test1")
|
||||||
@PostMapping("/test1")
|
@PostMapping("/test1")
|
||||||
|
@SaIgnore
|
||||||
//@PreAuthorize("@el.check('task:add')")
|
//@PreAuthorize("@el.check('task:add')")
|
||||||
public ResponseEntity<Object> test1() throws IOException {
|
public ResponseEntity<Object> test1() throws IOException {
|
||||||
testService.test1();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
headers.add(HttpHeaders.CONTENT_TYPE,"text/plain;charset=UTF-8");
|
||||||
|
return new ResponseEntity<>(testService.test1(), headers, HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("test2")
|
@Log("test2")
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public interface TestService {
|
|||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
void test1() throws IOException;
|
String test1() throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 触发打印
|
* 触发打印
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.acs.test.service.TestService;
|
import org.nl.acs.test.service.TestService;
|
||||||
|
import org.nl.acs.wsdl.org.tempuri.RTMSAGVSERVICE;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,8 +25,9 @@ public class TestServiceImpl implements TestService
|
|||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void test1() throws IOException {
|
public String test1() {
|
||||||
|
String s = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback("{}");
|
||||||
|
return new String(s.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user