Commit 5e1df948 by gechengyang

modify

parent b6598e9d
...@@ -29,4 +29,6 @@ public class ErrorCodes { ...@@ -29,4 +29,6 @@ public class ErrorCodes {
public static final String INTERRUPTED_ERROR = "R9997"; public static final String INTERRUPTED_ERROR = "R9997";
public static final String REDIS_CONNECTION_ERROR = "R9998"; public static final String REDIS_CONNECTION_ERROR = "R9998";
public static final String ERROR = "R9999"; public static final String ERROR = "R9999";
public static final String BUSINESS_ERROR = "E0001";
} }
...@@ -15,7 +15,9 @@ import log.Log; ...@@ -15,7 +15,9 @@ import log.Log;
import log.LogFactory; import log.LogFactory;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.sss.common.impl.AbstractNullPresentation; import org.sss.common.impl.AbstractNullPresentation;
import org.sss.common.impl.ProxyDatafield;
import org.sss.common.model.CodetableItem; import org.sss.common.model.CodetableItem;
import org.sss.common.model.IAttribute; import org.sss.common.model.IAttribute;
import org.sss.common.model.IAttributeValue; import org.sss.common.model.IAttributeValue;
...@@ -31,6 +33,7 @@ import org.sss.common.model.RowOpType; ...@@ -31,6 +33,7 @@ import org.sss.common.model.RowOpType;
import org.sss.common.model.ViewType; import org.sss.common.model.ViewType;
import org.sss.exception.ContainerException; import org.sss.exception.ContainerException;
import org.sss.presentation.noui.api.request.NoUiRequest; import org.sss.presentation.noui.api.request.NoUiRequest;
import org.sss.presentation.noui.api.response.ErrorCodes;
import org.sss.presentation.noui.common.Constants; import org.sss.presentation.noui.common.Constants;
import org.sss.presentation.noui.util.NoUiUtils; import org.sss.presentation.noui.util.NoUiUtils;
import org.sss.util.ContainerUtils; import org.sss.util.ContainerUtils;
...@@ -67,6 +70,7 @@ public class NoUiPresentation extends AbstractNullPresentation { ...@@ -67,6 +70,7 @@ public class NoUiPresentation extends AbstractNullPresentation {
// public final List<IAttribute<?>> requiredList = new // public final List<IAttribute<?>> requiredList = new
// ArrayList<IAttribute<?>>(); // ArrayList<IAttribute<?>>();
private String message = null; // 弹出的message private String message = null; // 弹出的message
private String message_code = null;
public IPanel popupPanel = null; public IPanel popupPanel = null;
public String transactionName = null; public String transactionName = null;
public boolean clearFlag = false; public boolean clearFlag = false;
...@@ -74,6 +78,10 @@ public class NoUiPresentation extends AbstractNullPresentation { ...@@ -74,6 +78,10 @@ public class NoUiPresentation extends AbstractNullPresentation {
private boolean isChain = false; private boolean isChain = false;
public Boolean logoutFlag = null; public Boolean logoutFlag = null;
public String getMessageCode() {
return this.message_code;
}
public String getMessage() { public String getMessage() {
return this.message; return this.message;
} }
...@@ -204,6 +212,9 @@ public class NoUiPresentation extends AbstractNullPresentation { ...@@ -204,6 +212,9 @@ public class NoUiPresentation extends AbstractNullPresentation {
if (paramString == null) { if (paramString == null) {
paramString = getI18nValue("eibs", "error.title"); paramString = getI18nValue("eibs", "error.title");
} }
if ((!StringUtils.isEmpty(paramString)) && paramString.equals(ErrorCodes.BUSINESS_ERROR)) {
this.message_code = ErrorCodes.BUSINESS_ERROR;
}
/* /*
* if (MessageType.ERROR.equals(paramMessageType)) { * if (MessageType.ERROR.equals(paramMessageType)) {
* log.error(StringUtils.isEmpty(paramString) ? str1 : str1 + ":" + * log.error(StringUtils.isEmpty(paramString) ? str1 : str1 + ":" +
...@@ -425,6 +436,12 @@ public class NoUiPresentation extends AbstractNullPresentation { ...@@ -425,6 +436,12 @@ public class NoUiPresentation extends AbstractNullPresentation {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
private final void setModified(IAttribute paramIAttribute, boolean paramBoolean) { private final void setModified(IAttribute paramIAttribute, boolean paramBoolean) {
if (paramIAttribute instanceof ProxyDatafield) {
while (paramIAttribute instanceof ProxyDatafield) {
paramIAttribute = ((ProxyDatafield) paramIAttribute).getHost();
}
}
modifyMap.put(((IBaseObject) paramIAttribute).getUrl(), paramIAttribute); modifyMap.put(((IBaseObject) paramIAttribute).getUrl(), paramIAttribute);
} }
......
...@@ -111,7 +111,7 @@ public class AbstractCommonController { ...@@ -111,7 +111,7 @@ public class AbstractCommonController {
Map<String, Object> afterReturnData = handleReturnData(eventType, context, noUiRequest, alias); Map<String, Object> afterReturnData = handleReturnData(eventType, context, noUiRequest, alias);
return ResultUtil.result(ErrorCodes.SUCCESS, NoUiPresentationUtil.retMsg(context), afterReturnData, return ResultUtil.result(NoUiPresentationUtil.retCode(context), NoUiPresentationUtil.retMsg(context), afterReturnData,
NoUiPresentationUtil.handleErrorReturnData(context, alias), NoUiPresentationUtil.handleCodeTableReturnData(context, alias)); NoUiPresentationUtil.handleErrorReturnData(context, alias), NoUiPresentationUtil.handleCodeTableReturnData(context, alias));
} catch (Exception e) { } catch (Exception e) {
log.error("OnClick command error", e); log.error("OnClick command error", e);
......
...@@ -169,6 +169,11 @@ public class NoUiPresentationUtil { ...@@ -169,6 +169,11 @@ public class NoUiPresentationUtil {
return StringUtil.isEmpty(gui.getMessage()) ? ErrorCodes.SUCCESS_INFO : gui.getMessage(); return StringUtil.isEmpty(gui.getMessage()) ? ErrorCodes.SUCCESS_INFO : gui.getMessage();
} }
public static String retCode(NoUiContext context) {
NoUiPresentation gui = (NoUiPresentation) context.getGui();
return StringUtil.isEmpty(gui.getMessageCode()) ? ErrorCodes.SUCCESS : gui.getMessageCode();
}
public static Map<String, Object> handleEventReturnData(EventType eventType, NoUiContext context, NoUiRequest request, Alias alias) { public static Map<String, Object> handleEventReturnData(EventType eventType, NoUiContext context, NoUiRequest request, Alias alias) {
Map<String, Object> data = new HashMap<String, Object>(); Map<String, Object> data = new HashMap<String, Object>();
...@@ -239,30 +244,6 @@ public class NoUiPresentationUtil { ...@@ -239,30 +244,6 @@ public class NoUiPresentationUtil {
return null; return null;
} }
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
try {
Date d = sdf.parse("2018/11/11 11:11:11");
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf1.format(d));
System.out.println(new BigDecimal("999999999999.99").toString());
long b = 999999999;
String bb = b + "";
System.out.println(String.valueOf(b));
java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
nf.setGroupingUsed(false);
// 设置数的小数部分所允许的最小位数
nf.setMinimumFractionDigits(0);
// 设置数的小数部分所允许的最大位数
nf.setMaximumFractionDigits(2);
System.out.println(nf.format(999999999999.0));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Object handIBaseObject(NoUiContext context, Object val, String path) { public static Object handIBaseObject(NoUiContext context, Object val, String path) {
if (val == null) if (val == null)
return null; return null;
...@@ -306,15 +287,16 @@ public class NoUiPresentationUtil { ...@@ -306,15 +287,16 @@ public class NoUiPresentationUtil {
public static Map<String, Object> handleCodeTableReturnData(NoUiContext context, Alias alias) { public static Map<String, Object> handleCodeTableReturnData(NoUiContext context, Alias alias) {
NoUiPresentation gui = (NoUiPresentation) context.getGui(); NoUiPresentation gui = (NoUiPresentation) context.getGui();
Map<String, Object> codeTableMap = gui.getCodetable(); Map<String, Object> codeTableMap = gui.getCodetable();
Map<String, Object> retCodeTableMap = new HashMap<>();
for (Map.Entry<String, Object> codeTableEntity : codeTableMap.entrySet()) { for (Map.Entry<String, Object> codeTableEntity : codeTableMap.entrySet()) {
String key = codeTableEntity.getKey(); String key = codeTableEntity.getKey();
String realKey = alias.getRevertRel().get(key); String realKey = alias.getRevertRel().get(key);
if (!StringUtils.isEmpty(realKey)) if (!StringUtils.isEmpty(realKey))
codeTableMap.put(realKey, codeTableEntity.getValue()); retCodeTableMap.put(realKey, codeTableEntity.getValue());
else else
codeTableMap.put(key, codeTableEntity.getValue()); retCodeTableMap.put(key, codeTableEntity.getValue());
} }
return codeTableMap; return retCodeTableMap;
} }
public static void setSysmod(NoUiContext context, byte[] oldSysmod) { public static void setSysmod(NoUiContext context, byte[] oldSysmod) {
......
package org.sss.presentation.noui.api.servlet;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.Gson;
public class CyHttpTest {
public static void main(String[] args) {
String userId = "tst1";
String terminalType = "WEB";
Map<String, Object> map1 = login(userId, terminalType);
Map<String, Object> map2 = (Map<String, Object>) map1.get("data");
String token = (String) map2.get("token");
// pxiadd(token, userId, terminalType);
pxisel(token, userId, terminalType);
// pxiame(token, userId, terminalType);
// check(token, userId, terminalType);
// upload(token, userId, terminalType);
}
public static void upload(String token, String userId, String terminalType) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
// "http://172.17.2.100:8080/oauth/token?username=user_1&password=123456&grant_type=password&client_id=client&client_secret=123456"
URL realUrl = new URL("http://localhost:8080/business/service/pxiadd/_upload");
// URL realUrl = new
// URL("http://localhost:8080/healthServer/getMacSeq");
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.addRequestProperty("token", token);
conn.addRequestProperty("userId", userId);
conn.addRequestProperty("terminalType", terminalType);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
Map<String, Object> map = new HashMap<String, Object>();
map.put("nam", "gcy");
map.put("major", "M");
/*
* map.put("sex", "F"); map.put("univer", "湖北大学"); map.put("major",
* "计算机"); map.put("headimg", "NO IMAGE"); map.put("age", 20);
* map.put("tel", "18912345678"); map.put("balance", 10000);
*/
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("data", map);
String str = "1234";
// System.out.println(JSON.toJSON(student));
out.print(str);
// out.print("abc");
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
System.out.println("result=" + result);
}
public static void check(String token, String userId, String terminalType) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
// "http://172.17.2.100:8080/oauth/token?username=user_1&password=123456&grant_type=password&client_id=client&client_secret=123456"
URL realUrl = new URL("http://localhost:8080/business/service/pxisel/check");
// URL realUrl = new
// URL("http://localhost:8080/healthServer/getMacSeq");
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.addRequestProperty("token", token);
conn.addRequestProperty("userId", userId);
conn.addRequestProperty("terminalType", terminalType);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
Map<String, Object> map = new HashMap<String, Object>();
map.put("nam", "gcy");
map.put("major", "M");
/*
* map.put("sex", "F"); map.put("univer", "湖北大学"); map.put("major",
* "计算机"); map.put("headimg", "NO IMAGE"); map.put("age", 20);
* map.put("tel", "18912345678"); map.put("balance", 10000);
*/
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("data", map);
// System.out.println(JSON.toJSON(student));
out.print(new Gson().toJson(map2));
// out.print("abc");
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
System.out.println("result=" + result);
}
public static void pxisel(String token, String userId, String terminalType) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
// "http://172.17.2.100:8080/oauth/token?username=user_1&password=123456&grant_type=password&client_id=client&client_secret=123456"
URL realUrl = new URL("http://localhost:8080/business/service/dblbch/sel");
// URL realUrl = new
// URL("http://localhost:8080/healthServer/getMacSeq");
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.addRequestProperty("token", token);
conn.addRequestProperty("userId", userId);
conn.addRequestProperty("terminalType", terminalType);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
Map<String, Object> map = new HashMap<String, Object>();
map.put("extkey", "0");
/*
* map.put("sex", "F"); map.put("univer", "湖北大学"); map.put("major",
* "计算机"); map.put("headimg", "NO IMAGE"); map.put("age", 20);
* map.put("tel", "18912345678"); map.put("balance", 10000);
*/
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("data", map);
// System.out.println(JSON.toJSON(student));
out.print(new Gson().toJson(map2));
// out.print("abc");
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
System.out.println("result=" + result);
}
public static void pxiame(String token, String userId, String terminalType) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
// "http://172.17.2.100:8080/oauth/token?username=user_1&password=123456&grant_type=password&client_id=client&client_secret=123456"
URL realUrl = new URL("http://localhost:8080/business/service/pxiame/init");
// URL realUrl = new
// URL("http://localhost:8080/healthServer/getMacSeq");
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.addRequestProperty("token", token);
conn.addRequestProperty("userId", userId);
conn.addRequestProperty("terminalType", terminalType);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
Map<String, Object> map = new HashMap<String, Object>();
map.put("pxiinr", "00000023");
/*
* map.put("sex", "F"); map.put("univer", "湖北大学"); map.put("major",
* "计算机"); map.put("headimg", "NO IMAGE"); map.put("age", 20);
* map.put("tel", "18912345678"); map.put("balance", 10000);
*/
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("params", map);
// System.out.println(JSON.toJSON(student));
out.print(new Gson().toJson(map2));
// out.print("abc");
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
System.out.println("result=" + result);
}
public static void pxiadd(String token, String userId, String terminalType) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
// "http://172.17.2.100:8080/oauth/token?username=user_1&password=123456&grant_type=password&client_id=client&client_secret=123456"
URL realUrl = new URL("http://localhost:8080/business/service/pxiadd/sav");
// URL realUrl = new
// URL("http://localhost:8080/healthServer/getMacSeq");
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.addRequestProperty("token", token);
conn.addRequestProperty("userId", userId);
conn.addRequestProperty("terminalType", terminalType);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
Map<String, Object> map = new HashMap<String, Object>();
map.put("nam", "gggeeeccc");
map.put("sex", "");
map.put("univer", "2121");
map.put("major", "2121");
map.put("headimg", "");
map.put("age", "21212");
map.put("tel", "12999998899");
map.put("balance", "");
map.put("balance1", "");
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("data", map);
// System.out.println(JSON.toJSON(student));
out.print(new Gson().toJson(map2));
// out.print("abc");
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
System.out.println("result=" + result);
}
public static Map<String, Object> login(String userId, String terminalType) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
// "http://172.17.2.100:8080/oauth/token?username=user_1&password=123456&grant_type=password&client_id=client&client_secret=123456"
URL realUrl = new URL("http://localhost:8080/business/service/login");
// URL realUrl = new
// URL("http://localhost:8080/healthServer/getMacSeq");
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "application/json");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.addRequestProperty("userId", userId);
conn.addRequestProperty("terminalType", terminalType);
conn.addRequestProperty("username", "421182199008062952");
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
Map<String, String> map = new HashMap<String, String>();
map.put("username", "tst1");
map.put("password", "1");
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("data", map);
// System.out.println(JSON.toJSON(student));
out.print(new Gson().toJson(map2));
// out.print("abc");
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
System.out.println("result=" + result);
return new Gson().fromJson(result, Map.class);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment