Index: ssts-web/src/main/webapp/systemmanage/system/activityView.jsp =================================================================== diff -u --- ssts-web/src/main/webapp/systemmanage/system/activityView.jsp (revision 0) +++ ssts-web/src/main/webapp/systemmanage/system/activityView.jsp (revision 23571) @@ -0,0 +1,83 @@ +<%@page import="java.util.Collections"%> +<%@page import="org.apache.velocity.runtime.directive.Foreach"%> +<%@page import="net.sf.json.JSONArray"%> +<%@page import="java.text.SimpleDateFormat"%> +<%@page import="com.forgon.disinfectsystem.entity.tousseitem.TousseItem"%> +<%@page import="java.util.Calendar"%> +<%@page import="com.forgon.disinfectsystem.packing.service.PackingManager,com.forgon.tools.SpringBeanManger"%> +<%@page import="com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan"%> +<%@page import="com.forgon.disinfectsystem.entity.basedatamanager.sterilisation.Sterilisation"%> +<%@page import="com.forgon.disinfectsystem.basedatamanager.sterilisation.service.SterilisationManager"%> +<%@ page contentType="text/html; charset=UTF-8"%> +<%@ include file="/common/taglibs.jsp"%> +<%@ include file="/common/includeExtJsAndCss.jsp"%> +<%@ include file="/common/includeExtJs4_2.jsp"%> + + + +发货计划单管理 + + + + +<% + request.setAttribute("userName",AcegiHelper.getLoginUser().getUserFullName()); +%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + \ No newline at end of file Index: ssts-web/src/main/webapp/systemmanage/system/activityView.js =================================================================== diff -u --- ssts-web/src/main/webapp/systemmanage/system/activityView.js (revision 0) +++ ssts-web/src/main/webapp/systemmanage/system/activityView.js (revision 23571) @@ -0,0 +1,110 @@ +var grid; + +function refreshList(isSetDateValue,isLoad){ + var store = grid.getStore(); + //刷新列表界面 + store.load(); + // } +} + +var ViewAppGridItem = Ext.data.Record.create([ + {name : 'showTousseName'}, + {name : 'count'}, + {name : 'urgentAmount'} + ]); + +Ext.onReady(function() { + + Ext4.tip.QuickTipManager.init(); + Ext4.apply(Ext4.tip.QuickTipManager.getQuickTip(), { + maxWidth: 1200, + minWidth: 100, + dismissDelay: 0, + showDelay: 0 + }); + + + var selectModel = new Ext.grid.CheckboxSelectionModel({ + + }); + var row_selectModel = new Ext.grid.RowSelectionModel({ + singleSelect:true, + listeners: { + selectionchange: function(sm){ + } + } + }); + grid = new Ext.grid.GridPanel({ + store : new Ext.data.Store({ + autoLoad: false, + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/system/activityAction!loadAllActivities.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'name'} + ,{name : 'startTime'} + ,{name : 'endTime'} + ,{name : 'startTimeStr'} + ,{name : 'endTimeStr'} + ] + }) + , sortInfo: { + field: 'startTime', + direction: 'DESC' // 'ASC'or 'DESC' + } + }), + height : 325, + width : 485, + bodyStyle : 'border:1px solid #afd7af', + sm : row_selectModel, + cm : new top.Ext.grid.ColumnModel([selectModel, + {id:'name',header : "名字",width : 20,dataIndex : 'name'}, + {header : "开始时间",width : 50,dataIndex : 'startTimeStr',menuDisabled:true}, + {header : "结束时间",width : 130,dataIndex : 'endTimeStr',menuDisabled:true} + ]), + autoExpandColumn : 'name', + frame : false, + viewConfig: { + forceFit:true, + //是否隔行换色 + stripeRows: false, + getRowClass : function(record,rowIndex,rowParams,store){ + + } + }, + loadMask:{msg:'正在加载,请稍候...'}, + title : '活动列表' + }); + + var viewport = new Ext.Viewport({ + layout:'border', + items:[{ + id:'container_panel', + region:'center', + margins:'0 5 5 0', + xtype : 'panel', + autoScroll:true, + layout:'border', + items: [{ + region:'center', + xtype : 'panel', + layout: 'fit', + items:grid + }], + tbar : [{ + text : '刷新列表', + iconCls : 'btn_ext_refresh1', + handler : function() { + refreshList(false,true); + } + }], + listeners: { + render : function() {} + } + }] + }); + window.focus(); + +}); \ No newline at end of file Index: forgon-core/src/main/java/com/forgon/system/activity/service/ActivityManager.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/system/activity/service/ActivityManager.java (revision 0) +++ forgon-core/src/main/java/com/forgon/system/activity/service/ActivityManager.java (revision 23571) @@ -0,0 +1,40 @@ +/** + * + */ +package com.forgon.system.activity.service; + +import java.util.concurrent.ConcurrentLinkedQueue; + +import com.forgon.system.activity.model.ActivityException; +import com.forgon.system.activity.model.ActivityInfo; + +/** + * @author dandan 2018年6月5日 下午8:07:12 + * + */ +public class ActivityManager { + + private ConcurrentLinkedQueue activityInfoList = new ConcurrentLinkedQueue(); + private ThreadLocal curActivityInfo = new ThreadLocal(); + + public ActivityInfo addActivity(String name) { + if (curActivityInfo.get() != null) { + throw new ActivityException("目前不支持同时执行多个活动!"); + } + ActivityInfo activityInfo = new ActivityInfo(name); + activityInfoList.add(activityInfo); + curActivityInfo.set(activityInfo); + return activityInfo; + } + + public void removeActivity(ActivityInfo activity) { + activityInfoList.remove(activity); + curActivityInfo.set(null); + } + + public ConcurrentLinkedQueue getActivityInfoList() { + return activityInfoList; + } + + +} Index: ssts-web/src/main/webapp/homepage/menuconfigure.js =================================================================== diff -u -r23468 -r23571 --- ssts-web/src/main/webapp/homepage/menuconfigure.js (.../menuconfigure.js) (revision 23468) +++ ssts-web/src/main/webapp/homepage/menuconfigure.js (.../menuconfigure.js) (revision 23571) @@ -629,7 +629,8 @@ {hidden :System_DBManage,text:"初始化演示数据",href:WWWROOT+'/systemmanage/initData.jsp',hrefTarget:linkTarget,leaf:true}, {hidden :System_DBManage,text:"导出邮件",href:WWWROOT+'/email/exportMailForm.mhtml',hrefTarget:linkTarget,leaf:true}, {hidden :System_DBManage,text:"备份数据库",href:WWWROOT+'/databaseBackupAndRestore/backup.jsp',hrefTarget:linkTarget,leaf:true}, - {hidden :System_DBManage,text:"还原数据库",href:WWWROOT+'/databaseBackupAndRestore/restore.jsp',hrefTarget:linkTarget,leaf:true} + {hidden :System_DBManage,text:"还原数据库",href:WWWROOT+'/databaseBackupAndRestore/restore.jsp',hrefTarget:linkTarget,leaf:true}, + {hidden :false,text:"活动管理",href:WWWROOT+'/systemmanage/system/activityView.jsp',hrefTarget:linkTarget,leaf:true} ] },{ text:"参数设置", Index: forgon-core/src/main/java/com/forgon/system/activity/model/ActivityException.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/system/activity/model/ActivityException.java (revision 0) +++ forgon-core/src/main/java/com/forgon/system/activity/model/ActivityException.java (revision 23571) @@ -0,0 +1,15 @@ +/** + * + */ +package com.forgon.system.activity.model; + +/** + * @author dandan 2018年6月12日 下午3:30:40 + * + */ +public class ActivityException extends RuntimeException { + + public ActivityException(String msg){ + super(msg); + } +} Index: forgon-core/src/main/java/com/forgon/system/activity/model/ActivityInfo.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/system/activity/model/ActivityInfo.java (revision 0) +++ forgon-core/src/main/java/com/forgon/system/activity/model/ActivityInfo.java (revision 23571) @@ -0,0 +1,81 @@ +/** + * + */ +package com.forgon.system.activity.model; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.forgon.Constants; + +/** + * @author dandan 2018年6月5日 下午7:39:35 + * + */ +public class ActivityInfo { + + public static final String STATUS_INPROGRESS = "进行中"; + public static final String STATUS_FINISHED = "已结束"; + + private String name; + private AmountControl type; + private String userName; + private Date startTime = new Date(); + private Date endTime; + private String status = STATUS_INPROGRESS; + + public ActivityInfo(String name) { + this.name = name; + } + + public AmountControl getType() { + return type; + } + + public String getName() { + return name; + } + + public String getStartTimeStr() { + if(startTime == null){ + return null; + } + return new SimpleDateFormat(Constants.DATEFORMAT_YYYYMMDDHHMMSS_SSS).format(startTime); + } + + public Date getStartTime() { + return startTime; + } + + public String getEndTimeStr() { + if(endTime == null){ + return null; + } + return new SimpleDateFormat(Constants.DATEFORMAT_YYYYMMDDHHMMSS_SSS).format(endTime); + } + + public Date getEndTime() { + return endTime; + } + + public String getStatus() { + return status; + } + + public void setType(AmountControl type) { + this.type = type; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public void setStatus(String status) { + this.status = status; + } + +} Index: forgon-core/src/main/java/com/forgon/system/activity/service/ActivityAspect.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/system/activity/service/ActivityAspect.java (revision 0) +++ forgon-core/src/main/java/com/forgon/system/activity/service/ActivityAspect.java (revision 23571) @@ -0,0 +1,102 @@ +/** + * + */ +package com.forgon.system.activity.service; + +import java.lang.reflect.Method; + +import net.sf.json.JSONObject; + +import org.apache.commons.lang3.StringUtils; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; + +import com.forgon.system.activity.model.Activity; +import com.forgon.system.activity.model.ActivityException; +import com.forgon.system.activity.model.ActivityInfo; +import com.forgon.system.activity.model.AmountControl; +import com.forgon.tools.StrutsResponseUtils; +import com.forgon.tools.json.JSONUtil; + +/** + * @author dandan 2018年6月11日 下午2:06:05 + * + */ +@Aspect +public class ActivityAspect { + + private ActivityManager activityManager; + + public void setActivityManager(ActivityManager activityManager) { + this.activityManager = activityManager; + } + + // @Pointcut("execution(* com.forgon.directory.action.UserAction.*(..))") + @Pointcut("@annotation(com.forgon.system.activity.model.Activity)") + public void activity() { + } + + @Around("activity()") + public Object watchPerformance(ProceedingJoinPoint jp) throws Throwable { + AmountControl amountControl = null; + boolean decrementAmount = false; + ActivityInfo activityInfo = null; + MethodSignature signature = (MethodSignature) jp.getSignature(); + Method method = signature.getMethod(); + Activity activity = method.getAnnotation(Activity.class); + try { + String name = activity.name(); + String methodName = method.getName(); + if (StringUtils.isBlank(name)) { + name = methodName; + } + amountControl = activity.amountControl(); + if (amountControl.incrementAmount()) { + decrementAmount = true; + activityInfo = activityManager.addActivity(name); + } else { + throw new ActivityException(String.format("同时只能执行%s个%s任务,当前正在执行%s个任务,请稍后重试!", + amountControl.getMaxAmount(),name, + amountControl.getCurAmount(),name)); + } + // System.out.println("start activity"); + return jp.proceed(); + // System.out.println("end activity"); + } catch (ActivityException e) { + return outputError(activity,method, e.getMessage()); + } catch (Throwable e) { + // System.out.println("activity exception"); + throw e; + } finally { + if (decrementAmount) { + amountControl.decrementAmount(); + } + if (activityInfo != null) { + activityManager.removeActivity(activityInfo); + } + } + } + + private Object outputError(Activity activity,Method method, String message) { + if (method == null) { + return null; + } + Class c = method.getDeclaringClass(); + String simpleClassName = c.getSimpleName(); + JSONObject json = new JSONObject(); + JSONUtil.addSuccess(json, false); + JSONUtil.addMessage(json, message); + json.put("msg", message);// 兼容旧页面 + if(activity != null && activity.name().equals("报表")){ + return "success"; + }else if (simpleClassName.endsWith("TableManager")) { + return json.toString(); + } else if (simpleClassName.endsWith("Action")) { + StrutsResponseUtils.output(json); + } + return null; + } +} Index: forgon-core/src/main/java/com/forgon/system/activity/model/AmountControl.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/system/activity/model/AmountControl.java (revision 0) +++ forgon-core/src/main/java/com/forgon/system/activity/model/AmountControl.java (revision 23571) @@ -0,0 +1,53 @@ +/** + * + */ +package com.forgon.system.activity.model; + +import java.util.concurrent.atomic.AtomicInteger; + +/** + * @author dandan 2018年6月12日 下午2:10:51 + * + */ +public enum AmountControl { + + RECYCLING("回收", 1), PACKING("装配", 1), REVIEW("审核", 1), INVOICE("发货", 1), STERILIZATION( + "灭菌", 1), REPORT("报表", 1), INFINITE("无限", -1); + private String name; + private int maxAmount = -1; + private AtomicInteger curAmount = new AtomicInteger(0); + + private AmountControl(String name) { + this.name = name; + } + + private AmountControl(String name, int maxAmount) { + this.name = name; + this.maxAmount = maxAmount; + } + + public boolean incrementAmount() { + int previous = curAmount.getAndIncrement(); + if (maxAmount < 0) { + return true; + } + if (previous < maxAmount) { + return true; + } + curAmount.getAndDecrement(); + return false; + } + + public void decrementAmount() { + curAmount.getAndDecrement(); + return; + } + + public int getMaxAmount() { + return maxAmount; + } + + public int getCurAmount() { + return curAmount.get(); + } +} Index: forgon-core/src/main/java/com/forgon/system/activity/model/Activity.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/system/activity/model/Activity.java (revision 0) +++ forgon-core/src/main/java/com/forgon/system/activity/model/Activity.java (revision 23571) @@ -0,0 +1,22 @@ +/** + * + */ +package com.forgon.system.activity.model; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * @author dandan 2018年6月12日 下午2:03:40 + * + */ +@Target(METHOD) +@Retention(RUNTIME) +public @interface Activity { + + String name(); + AmountControl amountControl() default AmountControl.INFINITE; +} Index: forgon-core/src/main/java/com/forgon/system/activity/action/ActivityAction.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/system/activity/action/ActivityAction.java (revision 0) +++ forgon-core/src/main/java/com/forgon/system/activity/action/ActivityAction.java (revision 23571) @@ -0,0 +1,41 @@ +/** + * + */ +package com.forgon.system.activity.action; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentLinkedQueue; + +import net.sf.json.JSONArray; + +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Namespace; +import org.apache.struts2.convention.annotation.ParentPackage; + +import com.forgon.system.activity.model.ActivityInfo; +import com.forgon.system.activity.service.ActivityManager; +import com.forgon.tools.StrutsResponseUtils; + +/** + * @author dandan 2018年6月12日 下午4:21:21 + * + */ +@ParentPackage(value = "default") +@Namespace(value = "/system") +@Action(value = "activityAction") +public class ActivityAction { + + private ActivityManager activityManager; + + public void setActivityManager(ActivityManager activityManager) { + this.activityManager = activityManager; + } + + public void loadAllActivities() { + ConcurrentLinkedQueue activityInfoList = activityManager + .getActivityInfoList(); + List list = new ArrayList(activityInfoList); + StrutsResponseUtils.output(JSONArray.fromObject(list)); + } +}