fix:修复result显示bug
This commit is contained in:
parent
117f293e83
commit
f966dd9387
|
@ -51,6 +51,11 @@ public class LexMarkResultDTO implements Serializable {
|
||||||
*/
|
*/
|
||||||
private Param param;
|
private Param param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情描述
|
||||||
|
*/
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.dpkj.common.utils;
|
package com.dpkj.common.utils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.dpkj.common.dto.LexMarkDTO;
|
import com.dpkj.common.dto.LexMarkDTO;
|
||||||
import com.dpkj.common.dto.LexMarkResultDTO;
|
import com.dpkj.common.dto.LexMarkResultDTO;
|
||||||
import com.dpkj.common.exception.RRException;
|
import com.dpkj.common.exception.RRException;
|
||||||
|
@ -15,6 +16,7 @@ import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第三方服务,主要是调用打印机等
|
* 第三方服务,主要是调用打印机等
|
||||||
*
|
*
|
||||||
|
@ -42,15 +44,14 @@ public class ThirdService {
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
connection.setRequestMethod("POST");
|
connection.setRequestMethod("POST");
|
||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
connection.setRequestProperty("Content - Type", "application/json");
|
connection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
|
||||||
// 将LexMarkDTO对象转换为JSON字符串
|
// 将LexMarkDTO对象转换为JSON字符串
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
String jsonInputString = JSON.toJSONString(lexMarkDTO);
|
||||||
String jsonInputString = objectMapper.writeValueAsString(lexMarkDTO);
|
|
||||||
|
|
||||||
try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) {
|
try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) {
|
||||||
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
||||||
wr.write(input, 0, input.length);
|
wr.write(input, 0, input.length);
|
||||||
|
log.info(jsonInputString);
|
||||||
}
|
}
|
||||||
|
|
||||||
int responseCode = connection.getResponseCode();
|
int responseCode = connection.getResponseCode();
|
||||||
|
@ -68,10 +69,18 @@ public class ThirdService {
|
||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
// 将响应JSON字符串转换为LexMarkResultDTO对象
|
// 将响应JSON字符串转换为LexMarkResultDTO对象
|
||||||
ObjectMapper resultMapper = new ObjectMapper();
|
LexMarkResultDTO lexMarkResultDTO = JSON.parseObject(response.toString(), LexMarkResultDTO.class);
|
||||||
return resultMapper.readValue(response.toString(), LexMarkResultDTO.class);
|
if( lexMarkResultDTO.getResult() != 0){
|
||||||
|
log.error("利盟服务请求出错:{}", lexMarkResultDTO);
|
||||||
|
throw new RRException(lexMarkResultDTO.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return lexMarkResultDTO;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("利盟服务请求失败:{}", lexMarkDTO, e);
|
log.error("利盟服务请求失败:{}", lexMarkDTO, e);
|
||||||
|
if ( e instanceof RRException ){
|
||||||
|
throw new RRException(((RRException) e).getCode(), e.getMessage());
|
||||||
|
}
|
||||||
throw new RRException("利盟服务请求失败");
|
throw new RRException("利盟服务请求失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class Result<T> implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Result<T> ok(T data) {
|
public static <T> Result<T> ok(T data) {
|
||||||
return error("", data);
|
return ok("", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Result<T> ok(String msg, T data) {
|
public static <T> Result<T> ok(String msg, T data) {
|
||||||
|
|
Loading…
Reference in New Issue