Commit 037558c4 by gechengyang

修复相关缺陷

parent 21bf1484
package org.sss.presentation.noui.api.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class Menu implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String id;
private String label;
private String value;
public List<Menu> subMenu = new ArrayList<>();
public String getId() {
return id;
}
public String getLabel() {
return label;
}
public String getValue() {
return value;
}
public List<Menu> getSubMenu() {
return subMenu;
}
public void setId(String id) {
this.id = id;
}
public void setLabel(String label) {
this.label = label;
}
public void setValue(String value) {
this.value = value;
}
public void setSubMenu(List<Menu> subMenu) {
this.subMenu = subMenu;
}
}
package org.sss.presentation.noui.context;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -53,7 +58,7 @@ public class NoUiPresentation extends AbstractNullPresentation {
// ArrayList<IAttribute<?>>();
// public final List<IAttribute<?>> requiredList = new
// ArrayList<IAttribute<?>>();
public String message = null; // 弹出的message
private String message = null; // 弹出的message
public IPanel popupPanel = null;
public String transactionName = null;
public boolean clearFlag = false;
......@@ -61,6 +66,10 @@ public class NoUiPresentation extends AbstractNullPresentation {
private boolean isChain = false;
public Boolean logoutFlag = null;
public String getMessage() {
return this.message;
}
public boolean isChain() {
return isChain;
}
......@@ -165,6 +174,40 @@ public class NoUiPresentation extends AbstractNullPresentation {
}
public boolean message(MessageType paramMessageType, String paramString, Object paramObject) throws ContainerException {
String str1 = "";
try {
if ((paramObject instanceof String)) {
str1 = (String) paramObject;
} else if ((paramObject instanceof Throwable)) {
File localFile = new File(getRootPath(), "dump");
if (!localFile.exists())
localFile.mkdirs();
String str2 = new SimpleDateFormat("yyyyMMddHHmmss.SSS").format(new Date()) + ".log";
PrintStream localPrintStream = new PrintStream(new FileOutputStream(new File(localFile, str2)));
((Throwable) paramObject).printStackTrace(localPrintStream);
localPrintStream.close();
str1 = String.format(getI18nValue("eibs", "error.message"), new Object[] { ((Throwable) paramObject).getMessage(), str2 });
} else if (paramObject != null) {
str1 = paramObject.toString();
}
if (paramString == null) {
paramString = getI18nValue("eibs", "error.title");
}
/*
* if (MessageType.ERROR.equals(paramMessageType)) {
* log.error(StringUtils.isEmpty(paramString) ? str1 : str1 + ":" +
* paramString); }
*/
this.message = str1;
// log.debug(paramString + "--" + paramObject);
} catch (Exception e) {
if ((paramObject instanceof Throwable)) {
log.error("dump message error", (Throwable) paramObject);
}
log.warn("function message error", e);
}
return false;
}
......
......@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.sss.common.model.ILoginContext;
import org.sss.common.model.IMenuItem;
import org.sss.presentation.noui.api.exception.NoUiException;
import org.sss.presentation.noui.api.model.Menu;
import org.sss.presentation.noui.api.request.NoUiRequest;
import org.sss.presentation.noui.api.response.ErrorCodes;
import org.sss.presentation.noui.api.response.ResultUtil;
......@@ -64,8 +65,11 @@ public class LoginController {
authMap.put(ILoginContext.REQUEST, request);
context.getSession().auth(authMap);
IMenuItem menuItem = context.getAuth().getMenu();
List<Map<String, String>> menuList = new ArrayList<Map<String, String>>();
getMenu(menuItem, menuList);
// List<Map<String, String>> menuList = new
// ArrayList<Map<String, String>>();
// getMenu(menuItem, menuList);
List<Menu> menuList = new ArrayList<>();
getMenus(menuItem, menuList);
Map<String, Object> retDatamap = new HashMap<String, Object>();
retDatamap.put("token", token);
......@@ -86,17 +90,26 @@ public class LoginController {
return ResultUtil.result(ErrorCodes.ERROR, "login failed", null);
}
private void getMenu(IMenuItem menuItem, List<Map<String, String>> menuList) {
/*
* private void getMenu(IMenuItem menuItem, List<Map<String, String>>
* menuList) { Iterator<IMenuItem> iterator = menuItem.iterator(); while
* (iterator.hasNext()) { IMenuItem item = iterator.next(); if
* (item.iterator().hasNext()) { getMenu(item, menuList); } else {
* HashMap<String, String> menuMap = new HashMap<>();
* menuMap.put(item.getValue(), item.getLabel()); menuList.add(menuMap); } }
* }
*/
private void getMenus(IMenuItem menuItem, List<Menu> menuList) {
Iterator<IMenuItem> iterator = menuItem.iterator();
while (iterator.hasNext()) {
IMenuItem item = iterator.next();
if (item.iterator().hasNext()) {
getMenu(item, menuList);
} else {
HashMap<String, String> menuMap = new HashMap<>();
menuMap.put(item.getValue(), item.getLabel());
menuList.add(menuMap);
}
Menu menu = new Menu();
menu.setValue(item.getValue());
menu.setLabel(item.getLabel());
menuList.add(menu);
List<Menu> subMenuList = menu.getSubMenu();
getMenus(item, subMenuList);
}
}
}
......@@ -28,7 +28,7 @@ import org.sss.presentation.noui.util.RedisUtil;
import org.sss.presentation.noui.util.StringUtil;
@Controller
public class PxiAddController {
public class PxiController {
private static final Log log = LogFactory.getLog(LoginController.class);
// Event 事件
......@@ -75,7 +75,60 @@ public class PxiAddController {
redisLoginInfo.setSysmod(sysmodBytes);
RedisUtil.set(StringUtil.userUniqueId(noUiRequest), redisLoginInfo);
return ResultUtil.result(ErrorCodes.SUCCESS, ErrorCodes.SUCCESS_INFO,
return ResultUtil.result(ErrorCodes.SUCCESS, NoUiPresentationUtil.retMsg(context),
NoUiPresentationUtil.handleEventReturnData(context, noUiRequest, alias),
NoUiPresentationUtil.handleErrorReturnData(context, alias), NoUiPresentationUtil.handleCodeTableReturnData(context, alias));
} catch (Exception e) {
log.error("OnClick command error", e);
}
return ResultUtil.result(ErrorCodes.ERROR, "提交处理异常", null);
}
// Event 事件
@ResponseBody
@RequestMapping(value = "/pxisel/_sel", method = RequestMethod.POST)
public Object sel(@RequestBody Map<String, Object> dataMap, HttpServletRequest request, HttpSession session) {
String mappingUrl = "/pxisel/_sel";
NoUiRequest noUiRequest = new NoUiRequest(request, mappingUrl, dataMap);
NoUiContext context = NoUiContextManager.createNoUiContext(noUiRequest);
Alias alias = new Alias(mappingUrl);
String trnName = alias.getTrnName();
// 交易参数赋值
Map<String, ?> paramsMap = noUiRequest.getParamsMap();
for (String key : paramsMap.keySet()) {
context.getSession().storeData(key, paramsMap.get(key));
}
// 设置old sysmod
RedisLoginInfo redisLoginInfo = (RedisLoginInfo) RedisUtil.get(StringUtil.userUniqueId(noUiRequest));
NoUiPresentationUtil.setSysmod(context, (byte[]) redisLoginInfo.getSysmod());
// 交易跳转
context.getSession().chain(true, trnName);
try {
// 模型赋值
NoUiPresentationUtil.hanleInput(context, noUiRequest, alias);
String aliasActionUrl = alias.getAliasActionUrl();
String actionUrl = alias.getRel().get(aliasActionUrl);
// context.getRoot().bindEvents(context);
IDatafield<?> dataField = (IDatafield<?>) context.getSession().getBaseObject(context.getRoot(), actionUrl);
if (null == dataField)
throw new NoUiException("onClickUrl :" + actionUrl + "is not exsit");
else {
if (dataField instanceof IDatafield)
((IDatafield<?>) dataField).invokeEventRules(context, EventType.ON_CLICK, null);
}
// 保存新的RedisLoginInfo
byte[] sysmodBytes = NoUiPresentationUtil.sysmodToBytes(context);
// IBaseObject sysmod =
// context.getSession().getBaseObject(context.getRoot(), "sysmod");
redisLoginInfo.setSysmod(sysmodBytes);
RedisUtil.set(StringUtil.userUniqueId(noUiRequest), redisLoginInfo);
return ResultUtil.result(ErrorCodes.SUCCESS, NoUiPresentationUtil.retMsg(context),
NoUiPresentationUtil.handleEventReturnData(context, noUiRequest, alias),
NoUiPresentationUtil.handleErrorReturnData(context, alias), NoUiPresentationUtil.handleCodeTableReturnData(context, alias));
} catch (Exception e) {
......
......@@ -159,6 +159,11 @@ public class NoUiPresentationUtil {
}
}
public static String retMsg(NoUiContext context) {
NoUiPresentation gui = (NoUiPresentation) context.getGui();
return StringUtil.isEmpty(gui.getMessage()) ? ErrorCodes.SUCCESS_INFO : gui.getMessage();
}
public static Map<String, Object> handleEventReturnData(NoUiContext context, NoUiRequest request, Alias alias) {
Map<String, Object> data = new HashMap<String, Object>();
NoUiPresentation gui = (NoUiPresentation) context.getGui();
......@@ -174,7 +179,7 @@ public class NoUiPresentationUtil {
}
}
return null;
return data;
}
private static Object handIBaseObject(NoUiContext context, Object val, String path) {
......
......@@ -30,6 +30,6 @@ menu.parent2=\u6d4b\u8bd5\u4e00\u7ea7\u83dc\u53552
menu.parent11=\u6d4b\u8bd5\u4e8c\u7ea7\u83dc\u5355
menu.office=\u4e3b\u9875\u4ea4\u6613
menu.tstsel=\u6d4b\u8bd5\u67e5\u8be2
menu.tstopn=\u6d4b\u8bd5\u65b0\u5efa
menu.pxisel=\u6d4b\u8bd5\u67e5\u8be2
menu.pxiadd=\u6d4b\u8bd5\u65b0\u5efa
menu.tstxxx=Test
\ No newline at end of file
......@@ -30,6 +30,6 @@ menu.parent2=First level menu2
menu.parent11=Second level menu
menu.office=Office
menu.tstsel=Test INFO.
menu.tstopn=Test create
menu.pxisel=Test INFO.
menu.pxiadd=Test create
menu.tstxxx=Test
\ No newline at end of file
......@@ -30,6 +30,6 @@ menu.parent2=\u6d4b\u8bd5\u4e00\u7ea7\u83dc\u53552
menu.parent11=\u6d4b\u8bd5\u4e8c\u7ea7\u83dc\u5355
menu.office=\u4e3b\u9875\u4ea4\u6613
menu.tstsel=\u6d4b\u8bd5\u67e5\u8be2
menu.tstopn=\u6d4b\u8bd5\u65b0\u5efa
menu.tstxxx=Test
\ No newline at end of file
menu.pxisel=\u6d4b\u8bd5\u67e5\u8be2
menu.pxiadd=\u6d4b\u8bd5\u65b0\u5efa
menu.tstxxx=Test
_save=pxip\\sav
nam=pxigrp\\rec\\nam
sex=pxigrp\\rec\\sex
univer=pxigrp\\rec\\univer
major=pxigrp\\rec\\major
tel=pxigrp\\rec\\tel
headimg=pxigrp\\rec\\headimg
age=pxigrp\\rec\\age
balance=pxigrp\\rec\\balance
\ No newline at end of file
_save=\\pxip\\sav
nam=\\pxigrp\\rec\\nam
sex=\\pxigrp\\rec\\sex
univer=\\pxigrp\\rec\\univer
major=\\pxigrp\\rec\\major
tel=\\pxigrp\\rec\\tel
headimg=\\pxigrp\\rec\\headimg
age=\\pxigrp\\rec\\age
balance=\\pxigrp\\rec\\balance
\ No newline at end of file
_sel=\\pxip\\sel
pxilst=\\pxip\\pxilst
nam=\\pxip\\nam
\ No newline at end of file
......@@ -21,9 +21,80 @@ public class HttpTest {
String token = (String) map2.get("token");
pxiadd(token, userId, terminalType);
pxisel(token, userId, terminalType);
}
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/pxisel/_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("nam", "gechengyang");
/*
* 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 pxiadd(String token, String userId, String terminalType) {
PrintWriter out = null;
......
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