Index: forgon-core/src/main/java/com/forgon/system/activity/service/ActivityAspect.java =================================================================== diff -u -r23571 -r23609 --- forgon-core/src/main/java/com/forgon/system/activity/service/ActivityAspect.java (.../ActivityAspect.java) (revision 23571) +++ forgon-core/src/main/java/com/forgon/system/activity/service/ActivityAspect.java (.../ActivityAspect.java) (revision 23609) @@ -34,7 +34,8 @@ this.activityManager = activityManager; } - // @Pointcut("execution(* com.forgon.directory.action.UserAction.*(..))") +// @Pointcut("execution(* com.forgon.directory.action.UserAction.*(..))") +// @Pointcut("execution(* com.forgon.disinfectsystem.packing.controller.PackingController.packingTousse(..))") @Pointcut("@annotation(com.forgon.system.activity.model.Activity)") public void activity() { } Index: forgon-tools/src/main/java/com/forgon/tools/StrutsResponseUtils.java =================================================================== diff -u -r17849 -r23609 --- forgon-tools/src/main/java/com/forgon/tools/StrutsResponseUtils.java (.../StrutsResponseUtils.java) (revision 17849) +++ forgon-tools/src/main/java/com/forgon/tools/StrutsResponseUtils.java (.../StrutsResponseUtils.java) (revision 23609) @@ -1,114 +1,103 @@ package com.forgon.tools; -import java.io.IOException; -import java.io.PrintWriter; - import javax.servlet.ServletResponse; -import com.forgon.tools.json.JSONUtil; - import net.sf.json.JSONArray; import net.sf.json.JSONObject; +import com.forgon.tools.json.JSONUtil; +import com.forgon.tools.util.ResponseUtils; + /** * struts的action响应的工具类。用于向页面输出执行结果 + * * @author kzh * */ public class StrutsResponseUtils { /** * 向页面输出执行结果,没有消息的文本描述 - * @param success 执行是否成功 + * + * @param success + * 执行是否成功 */ - public static void output(boolean success){ - output(success,null,StrutsParamUtils.getResponse()); + public static void output(boolean success) { + output(success, null, StrutsParamUtils.getResponse()); } + /** * 向页面输出执行结果,并输出消息的文本描述 - * @param success 执行是否成功 - * @param msg 消息的文本描述信息 + * + * @param success + * 执行是否成功 + * @param msg + * 消息的文本描述信息 */ - public static void output(boolean success,String msg){ - output(success,msg,StrutsParamUtils.getResponse()); + public static void output(boolean success, String msg) { + output(success, msg, StrutsParamUtils.getResponse()); } + /** * 向指定的页面输出执行结果,并输出消息的文本描述 - * @param success 执行是否成功 - * @param msg 消息的文本描述信息 - * @param response 页面的响应对象 + * + * @param success + * 执行是否成功 + * @param msg + * 消息的文本描述信息 + * @param response + * 页面的响应对象 */ - public static void output(boolean success,String msg,ServletResponse response){ - output(JSONUtil.buildJsonObject(success, msg), response); + public static void output(boolean success, String msg, + ServletResponse response) { + ResponseUtils.output(JSONUtil.buildJsonObject(success, msg), response); } + /** * 向页面输出json对象 - * @param jsonObj 封装好的json格式对象 + * + * @param jsonObj + * 封装好的json格式对象 */ - public static void output(JSONObject jsonObj){ - output(jsonObj,StrutsParamUtils.getResponse()); + public static void output(JSONObject jsonObj) { + ResponseUtils.output(jsonObj, StrutsParamUtils.getResponse()); } + + + /** - * 向指定的页面输出json对象 - * @param jsonObj 封装好的json格式对象 - * @param response 页面的响应对象 - */ - public static void output(JSONObject jsonObj,ServletResponse response){ - doOutput(jsonObj,response); - } - /** * 向页面输出json数组 - * @param array json数组 + * + * @param array + * json数组 */ - public static void output(JSONArray array){ - output(array,StrutsParamUtils.getResponse()); + public static void output(JSONArray array) { + output(array, StrutsParamUtils.getResponse()); } - + /** * 向页面输出json数组 - * @param array json数组 + * + * @param array + * json数组 */ - public static void output(JSONArray array,ServletResponse response){ - doOutput(array,response); + public static void output(JSONArray array, ServletResponse response) { + ResponseUtils.doOutput(array, response); } + /** * 向页面输出obj + * * @param obj */ - public static void output(Object obj){ - doOutput(obj,StrutsParamUtils.getResponse()); + public static void output(Object obj) { + ResponseUtils.doOutput(obj, StrutsParamUtils.getResponse()); } - /** - * 内部实现函数,实现输出功能 - * @param obj - * @param response - */ - private static void doOutput(Object obj,ServletResponse response){ - if(response != null && obj != null){ - - /** - * 设置Response对象的编码和内容类型,如果没有设置contentType,前台Web页面解析式xml时会有警告信息 - * @param response - */ - - //response.setCharacterEncoding("UTF-8"); - response.setContentType("text/html;charset=UTF-8"); - PrintWriter out = null; - try { - out = response.getWriter(); - out.println(obj.toString()); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if(out != null){ - out.close(); - } - } - } - } + public static void output(boolean success, JSONArray array) { output(JSONUtil.buildJsonObject(success, array)); } - public static void output(boolean success, JSONObject data){ + + public static void output(boolean success, JSONObject data) { output(JSONUtil.buildJsonObject(success, data)); } } Index: forgon-tools/src/main/java/com/forgon/tools/util/SpringResponseUtils.java =================================================================== diff -u --- forgon-tools/src/main/java/com/forgon/tools/util/SpringResponseUtils.java (revision 0) +++ forgon-tools/src/main/java/com/forgon/tools/util/SpringResponseUtils.java (revision 23609) @@ -0,0 +1,25 @@ +/** + * + */ +package com.forgon.tools.util; + +import net.sf.json.JSONObject; + +import com.forgon.tools.StrutsParamUtils; + +/** + * @author dandan 2018年6月19日 下午6:51:38 + * + */ +public class SpringResponseUtils { + + /** + * 向页面输出json对象 + * + * @param jsonObj + * 封装好的json格式对象 + */ + public static void output(JSONObject jsonObj) { + ResponseUtils.output(jsonObj, StrutsParamUtils.getResponse()); + } +} Index: forgon-tools/src/main/java/com/forgon/tools/util/ResponseUtils.java =================================================================== diff -u --- forgon-tools/src/main/java/com/forgon/tools/util/ResponseUtils.java (revision 0) +++ forgon-tools/src/main/java/com/forgon/tools/util/ResponseUtils.java (revision 23609) @@ -0,0 +1,61 @@ +/** + * + */ +package com.forgon.tools.util; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletResponse; + +import net.sf.json.JSONObject; + +/** + * @author dandan 2018年6月19日 下午6:18:43 + * + */ +public class ResponseUtils { + + /** + * 向指定的页面输出json对象 + * + * @param jsonObj + * 封装好的json格式对象 + * @param response + * 页面的响应对象 + */ + public static void output(JSONObject jsonObj, ServletResponse response) { + ResponseUtils.doOutput(jsonObj, response); + } + + /** + * 内部实现函数,实现输出功能 + * + * @param obj + * @param response + */ + public static void doOutput(Object obj, ServletResponse response) { + if (response != null && obj != null) { + + /** + * 设置Response对象的编码和内容类型,如果没有设置contentType,前台Web页面解析式xml时会有警告信息 + * + * @param response + */ + + // response.setCharacterEncoding("UTF-8"); + response.setContentType("text/html;charset=UTF-8"); + PrintWriter out = null; + try { + out = response.getWriter(); + out.println(obj.toString()); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (out != null) { + out.close(); + } + } + } + } +} Index: forgon-core/src/main/java/com/forgon/system/activity/controller/ActivityController.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/system/activity/controller/ActivityController.java (revision 0) +++ forgon-core/src/main/java/com/forgon/system/activity/controller/ActivityController.java (revision 23609) @@ -0,0 +1,42 @@ +/** + * + */ +package com.forgon.system.activity.controller; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentLinkedQueue; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import net.sf.json.JSONArray; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import com.forgon.system.activity.model.ActivityInfo; +import com.forgon.system.activity.service.ActivityManager; +import com.forgon.tools.util.ResponseUtils; + +/** + * @author dandan 2018年6月20日 下午4:13:48 + * + */ +@Controller +@RequestMapping("/system/activity") +public class ActivityController { + private ActivityManager activityManager; + + public void setActivityManager(ActivityManager activityManager) { + this.activityManager = activityManager; + } + + @RequestMapping(value="/loadAllActivities") + public void loadAllActivities(HttpServletRequest request, HttpServletResponse response) { + ConcurrentLinkedQueue activityInfoList = activityManager + .getActivityInfoList(); + List list = new ArrayList(activityInfoList); + ResponseUtils.doOutput(JSONArray.fromObject(list),response); + } +}