Browse Source

更新

master
张江玮 2 years ago
parent
commit
3ac5b86d18
  1. 45
      acs/nladmin-system/src/main/java/org/nl/acs/common/WebServiceUtil.java
  2. 11
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java
  3. 26
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java
  4. 8
      acs/nladmin-system/src/main/java/org/nl/acs/test/rest/TestController.java
  5. 2
      acs/nladmin-system/src/main/java/org/nl/acs/test/service/TestService.java
  6. 7
      acs/nladmin-system/src/main/java/org/nl/acs/test/service/impl/TestServiceImpl.java

45
acs/nladmin-system/src/main/java/org/nl/acs/common/WebServiceUtil.java

@ -1,5 +1,6 @@
package org.nl.acs.common;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
@ -9,6 +10,7 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@ -27,7 +29,7 @@ public class WebServiceUtil {
* @return 第三方系统返回的JSONObject调用结果
* @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();
//第一步:创建服务地址
@ -69,7 +71,7 @@ public class WebServiceUtil {
//获取当前连接请求返回的数据流
InputStream is = connection.getInputStream();
InputStreamReader isr = new InputStreamReader(is, "utf-8");
InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
BufferedReader br = new BufferedReader(isr);
@ -88,9 +90,9 @@ public class WebServiceUtil {
ret = ret.replaceAll("\\<\\?.+\\?\\>", "<?xml version='1.0' encoding='UTF-8'?>");
else
ret = (new StringBuilder("<?xml version='1.0' encoding='UTF-8'?>")).append(ret).toString();
/* String now = xml2jsonString(ret);
System.out.println("打印返回结果转成jsonString-------------");
System.out.println("打印返回结果转成jsonString-------------");
result =JSONObject.parseObject(now);*/
is.close();
isr.close();
@ -110,28 +112,17 @@ public class WebServiceUtil {
* @param form 查询条件
* @return
*/
private static String getXML(Map<String, String> form, String method) {
StringBuffer sb = new StringBuffer();
sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?> ");
sb.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:soap:functions:mc-style\">");
sb.append("<soapenv:Header/>");
sb.append("<soapenv:Body>");
sb.append("<urn:" + method + ">");
if (method.contains("ZSd0002SendMatMd"))
sb.append("<In>");
// 设置请求参数
for (Iterator<String> it = form.keySet().iterator(); it.hasNext(); ) {
String key = it.next();
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();
private static String getXML(JSONObject form, String method) {
return "<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\"" +
"<soapenv:Header/>" +
"<soapenv:Body>" +
"<tem:" + method + ">" +
"<tem:JsonStr>" +
form.toJSONString() +
"</tem:JsonStr>" +
"</tem:" + method + ">" +
"</soapenv:Body>" +
"</soapenv:Envelope>";
}
}

11
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java

@ -21,6 +21,7 @@ import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
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.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
@ -538,14 +539,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
MDC.put(log_file_type, log_type);
// log.info("shipDeviceUpdate-----输入参数{}", param);
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("taskExecution");
String methods_url = addressDto.getMethods_url();
String url = wmsUrl + methods_url;
return HttpRequest
.post(url)
.body(param.toString())
.execute();
String s = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(param.toJSONString());
log.info(s);
}
} catch (Throwable ignored) {

26
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java

@ -465,7 +465,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
for (int i = 0; i < datas.size(); i++) {
String data = datas.get(i).toString();
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 start_device_code = request.getSTARTPOSITION();
// String start_device_code2 = request.getStart_device_code2();
@ -493,21 +493,21 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
String next_point_code2 = "";
String put_point_code = "";
if (StrUtil.isEmpty(task_code)) {
response.setREQCODE(ext_task_id);
response.setREQCODE(task_code);
response.setREPLYTIME(DateUtil.now());
response.setREQCODE("1");
response.setRTMSG("任务号不能为空!");
return response;
}
if (StrUtil.isEmpty(start_device_code)) {
response.setREQCODE(ext_task_id);
response.setREQCODE(task_code);
response.setREPLYTIME(DateUtil.now());
response.setREQCODE("1");
response.setRTMSG("起点不能为空!");
return response;
}
if (StrUtil.isEmpty(next_device_code)) {
response.setREQCODE(ext_task_id);
response.setREQCODE(task_code);
response.setREPLYTIME(DateUtil.now());
response.setREQCODE("1");
response.setRTMSG("终点不能为空!");
@ -584,7 +584,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
// }
TaskDto taskDto = taskService.findByCodeFromCache(task_code);
if (taskDto != null) {
response.setREQCODE(ext_task_id);
response.setREQCODE(task_code);
response.setREPLYTIME(DateUtil.now());
response.setREQCODE("1");
response.setRTMSG("不能存在相同的任务号!");
@ -593,7 +593,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
if (!StrUtil.isEmpty(vehicle_code)) {
TaskDto vehicle_dto = taskService.findByContainer(vehicle_code);
if (vehicle_dto != null) {
response.setREQCODE(ext_task_id);
response.setREQCODE(task_code);
response.setREPLYTIME(DateUtil.now());
response.setREQCODE("1");
response.setRTMSG("不能存在相同的料车号!");
@ -602,14 +602,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
}
if (StrUtil.isEmpty(start_point_code)) {
response.setREQCODE(ext_task_id);
response.setREQCODE(task_code);
response.setREPLYTIME(DateUtil.now());
response.setREQCODE("1");
response.setRTMSG(start_device_code + "未找到对应点位!");
return response;
}
if (StrUtil.isEmpty(next_point_code)) {
response.setREQCODE(ext_task_id);
response.setREQCODE(task_code);
response.setREPLYTIME(DateUtil.now());
response.setREQCODE("1");
response.setRTMSG(next_device_code + "未找到对应点位!");
@ -618,7 +618,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
JSONObject jo = new JSONObject();
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("next_point_code", next_point_code);
jo.put("start_point_code2", start_point_code2);
@ -641,8 +641,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("params", params);
jo.put("task_type", task_type);
if (!StrUtil.isEmpty(ext_task_id)) {
jo.put("ext_task_id", ext_task_id);
if (!StrUtil.isEmpty(task_code)) {
jo.put("ext_task_id", task_code);
}
TaskDto task_dto = jo.toJavaObject(TaskDto.class);
@ -675,7 +675,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
} else {
JSONObject json = new JSONObject();
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("code", resp.code);
json.put("data", data);
@ -688,7 +688,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
}
} catch (Exception e) {
// e.printStackTrace();
response.setREQCODE(ext_task_id);
response.setREQCODE(task_code);
response.setREPLYTIME(DateUtil.now());
response.setREQCODE("1");
response.setRTMSG(e.getMessage());

8
acs/nladmin-system/src/main/java/org/nl/acs/test/rest/TestController.java

@ -2,12 +2,14 @@
package org.nl.acs.test.rest;
import cn.dev33.satoken.annotation.SaIgnore;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.test.service.TestService;
import org.nl.modules.logging.annotation.Log;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
@ -34,10 +36,12 @@ public class TestController {
@Log("test1")
@ApiOperation("test1")
@PostMapping("/test1")
@SaIgnore
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> test1() throws IOException {
testService.test1();
return new ResponseEntity<>(HttpStatus.CREATED);
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_TYPE,"text/plain;charset=UTF-8");
return new ResponseEntity<>(testService.test1(), headers, HttpStatus.CREATED);
}
@Log("test2")

2
acs/nladmin-system/src/main/java/org/nl/acs/test/service/TestService.java

@ -19,7 +19,7 @@ public interface TestService {
*
* @throws IOException
*/
void test1() throws IOException;
String test1() throws IOException;
/**
* 触发打印

7
acs/nladmin-system/src/main/java/org/nl/acs/test/service/impl/TestServiceImpl.java

@ -6,9 +6,11 @@ import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.test.service.TestService;
import org.nl.acs.wsdl.org.tempuri.RTMSAGVSERVICE;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
@ -23,8 +25,9 @@ public class TestServiceImpl implements TestService
{
@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

Loading…
Cancel
Save