excelLayoutSave.jsp 3.75 KB
<%@page import="com.engine.fnaMulDimensions.util.constants.FnaAccTypeConstant"%>
<%@page import="weaver.conn.RecordSet"%>
<%@page import="com.engine.fnaMulDimensions.util.AccountInfoComInfo"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<%@ page import="weaver.file.FileUpload,java.io.File"%>
<%@ page import="weaver.workflow.workflow.WfRightManager"%>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="excelLayoutManager" class="weaver.fna.exceldesign.ExcelLayoutManager" scope="page"/>

<%   
FileUpload fu = new FileUpload(request, false, false, "filesystem/htmllayoutimages");

//int wfid = Util.getIntValue(fu.getParameter("wfid"), 0);
//WfRightManager wfrm = new WfRightManager();
//boolean haspermission = wfrm.hasPermission3(wfid, 0, user, WfRightManager.OPERATION_CREATEDIR);

if (!HrmUserVarify.checkUserRight("FnaMultiBudgetTempldate:Edit",user)) {
    response.sendRedirect("/notice/noright.jsp") ;
    return ;
}

String accountId = Util.null2String(fu.getParameter("accountId"));
String approvalId = Util.null2String(fu.getParameter("approvalId"));
String templateId = Util.null2String(fu.getParameter("templateId"));

AccountInfoComInfo accountInfoComInfo = new AccountInfoComInfo();
String numberCode = accountInfoComInfo.getNumberCode(accountId);

//生效模板不能保存
StringBuffer buffer = new StringBuffer();
buffer.append(" select approvaTypelstatus,nodeStatus from FnaBudgetApprovalType_").append(numberCode).append(" fat ");
buffer.append(" join FnaBudgetApproval_").append(numberCode).append(" fa ");
buffer.append(" on fat.id = fa.approvalTypeId ");
buffer.append(" where fa.id = ? ");
rs.executeQuery(buffer.toString(), approvalId);
if(rs.next()){
    int approvaTypelstatus = Util.getIntValue(rs.getString("approvaTypelstatus"));
    int nodeStatus = Util.getIntValue(rs.getString("nodeStatus"));
    if(approvaTypelstatus == 1 || nodeStatus == 1){
        String url = "excelMain.jsp?templateId="+templateId+"&accountId="+accountId+"&approvalId="+approvalId+"&approvaTypelstatus="+approvaTypelstatus;
        url += "&nodeStatus="+nodeStatus;
        response.sendRedirect(url);
        return;
    }
}

//两人同时新建,防止一个节点产生2个模板
String tableName = "";
rs.executeQuery(" select * from FnaAccountDtl where accountId = ? and tableType = ? ", accountId, FnaAccTypeConstant.BUDGET_TEMPLATE);
if(rs.next()){
    tableName = Util.null2String(rs.getString("tableName"));
}
if(!"".equals(tableName)){
    rs.executeQuery(" select id from Fnabudgettemplate_"+numberCode+" where approvalid = ? ", approvalId);
    if(rs.next()){
        String id = Util.null2String(rs.getString("id"));
        if(!templateId.equals(id)){
            String url = "excelMain.jsp?templateId="+templateId+"&accountId="+accountId+"&approvalId="+approvalId;
            url += "&hasCreate=1";
            response.sendRedirect(url);
            return;
        }
    }
}

//多人编辑,防止节点已被删除
rs.executeQuery(" select id from FnaBudgetApproval_"+numberCode+" where id = ? ", approvalId);
if(!rs.next()){
    String url = "excelMain.jsp?templateId="+templateId+"&accountId="+accountId+"&approvalId="+approvalId;
    url += "&nodeDelete=1";
    response.sendRedirect(url);
    return;
}

//保存Excel模板
excelLayoutManager.setFu(fu);
excelLayoutManager.setUser(user);
String operation = fu.getParameter("operation");
String isCheck = fu.getParameter("isCheck");
String number = fu.getParameter("number");
if("saveExcel".equalsIgnoreCase(operation)){
	templateId = excelLayoutManager.doSaveExcelInfo();
	String url = "excelMain.jsp?templateId="+templateId+"&accountId="+accountId+"&approvalId="+approvalId+"&isCheck="+isCheck+"&number="+number;
	response.sendRedirect(url);
}
	
		
%>