WorkflowToModeAction.jsp 2.63 KB
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.*" %>
<%@ page import="weaver.hrm.User"%>
<%@ page import="net.sf.json.JSONObject"%>
<%@ page import="weaver.hrm.HrmUserVarify"%>
<%@ page import="weaver.workflow.action.WorkflowActionManager"%>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<%
out.clear();
User user = HrmUserVarify.getUser(request,response);
if(!HrmUserVarify.checkUserRight("ModeSetting:All", user)){
	response.sendRedirect("/notice/noright.jsp");
	return;
}
out.clear();
String action = Util.null2String(request.getParameter("action"));

if("changeIsEnable".equalsIgnoreCase(action)){
	String id = Util.null2String(request.getParameter("id"));
	int isEnable = Util.getIntValue(request.getParameter("isEnable"), 0);
	rs.executeSql("update mode_workflowtomodeset set isenable=" + isEnable +" where id=" + id);
	int actionid = 0;
	rs.executeSql("select actionid from mode_workflowtomodeset where id=" + id);
	if(rs.next()){
		actionid = Util.getIntValue(rs.getString("actionid"),0);
	}
	if(actionid>0){
		rs.executeSql(" select count(1) ct from mode_workflowtomodeset where actionid = "+actionid+" and isenable = '1' and id <> "+id);
		int ct = 0;
		if(rs.next()) {
			ct = rs.getInt("ct");
		}
		if(ct == 0 || isEnable == 1) {
			rs.executeSql("update workflowactionset set isused=" + isEnable + " where id=" + actionid);
		}
	}
	JSONObject jsonObject = new JSONObject();
	jsonObject.put("status", "1");
	out.print(jsonObject.toString());
	return;
}else if("delete".equalsIgnoreCase(action)){
	String id = Util.null2String(request.getParameter("id"));
	int actionid = 0;
	rs.executeSql("select actionid from mode_workflowtomodeset where id=" + id);
	if(rs.next()){
		actionid = Util.getIntValue(rs.getString("actionid"),0);
	}
	
	//删除主表数据
	String sql = "delete from mode_workflowtomodeset where id = " + id;
	rs.executeSql(sql);
	
	//删除明细表更新条件
	sql = "delete from mode_workflowtomodesetopt where mainid = " + id;
	rs.executeSql(sql);

	//删除明细表数据
	sql = "delete from mode_workflowtomodesetdetail where mainid = " + id;
	rs.executeSql(sql);
	if(actionid>0){
		rs.executeSql(" select count(1) ct from mode_workflowtomodeset where actionid = "+actionid+" and isenable = '1' and id <> "+id);
		int ct = 0;
		if(rs.next()) {
			ct = rs.getInt("ct");
		}
		if(ct == 0 ){
			WorkflowActionManager workflowActionManager = new WorkflowActionManager();
			workflowActionManager.doDeleteWsAction(actionid);
		}
	}
	JSONObject jsonObject = new JSONObject();
	jsonObject.put("status", "1");
	out.print(jsonObject.toString());
	return;
}

%>