OdocSaveTextRequest.jsp 7.49 KB
<%@page import="weaver.hrm.HrmUserVarify"%>
<%@page import="weaver.hrm.User"%>
<%@page import="weaver.systeminfo.SystemEnv"%>
<%@page import="weaver.conn.RecordSet"%>
<%@page import="weaver.general.Util"%>
<%@page import="java.util.*"%>
<%@ page import="net.sf.json.JSONObject" %>
<%@ page import="weaver.workflow.workflow.WFManager" %>
<%@ page import="com.api.odoc.util.RequestIdUtil" %>
<%@ page import="weaver.docs.docs.DocCheckInOutUtil" %>
<%@ page import="weaver.general.BaseBean" %>
<jsp:useBean id="meetingSetInfo" class="weaver.meeting.Maint.MeetingSetInfo" scope="page"/>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>

<%
	JSONObject json = new JSONObject();
	String requestid = Util.null2String(request.getParameter("requestId"));
	String workflowid = Util.null2String(request.getParameter("workflowid"));
	new BaseBean().writeLog("----------------yjy----------requestid:"+requestid);
	new BaseBean().writeLog("----------------yjy----------workflowid:"+workflowid);
	String operation = Util.null2String(request.getParameter("operation"));
	String isbill = "";
	Integer formID = 0;
	String formTableName = "";
	String detailtable = "";
	String msg = "";
	String isDocForceCheckIn = "";
	int nodeUserId = RequestIdUtil.getCurrentUserByRequestId(requestid);
	new BaseBean().writeLog("----------------yjy----------nodeUserId:"+nodeUserId);

	User user = HrmUserVarify.getUser (request , response) ;
	if(user==null){
		response.sendRedirect("/notice/noright.jsp") ;
		return ;
	}
	RecordSet rs = new RecordSet();
	try {
		WFManager wfmanager = new WFManager();
		wfmanager.reset();
		wfmanager.setWfid(Util.getIntValue(workflowid));
		wfmanager.getWfInfo();
		isbill = wfmanager.getIsBill();
		formID = wfmanager.getFormid();
	} catch (Exception e) {
		e.printStackTrace();
	}
	new BaseBean().writeLog("----------------yjy----------isbill:"+isbill);
	new BaseBean().writeLog("----------------yjy----------formID:"+formID);
	if ("1".equals(isbill)){
		rs.executeQuery("select tablename from workflow_bill where id = ?",formID);
		if(rs.next()) {
			formTableName = rs.getString("tablename");
		}
	}else {
		formTableName = "workflow_form";
	}
	if ("1".equals(isbill)){
		rs.executeQuery(" select tablename from Workflow_billdetailtable where billid=? order by orderid",formID);
		if (rs.next()){
			detailtable = rs.getString("tablename");
		}
	}else {
		detailtable = "workflow_formdetail";
	}
	new BaseBean().writeLog("----------------yjy----------formTableName:"+formTableName);
	if(!"".equals(formTableName)) {
		//获得附件正文ID
		String sql_fieldname = "";
		String imageFileId = "";
		if (isbill.equals("1")) {
			sql_fieldname = "select distinct t.id,t.fieldname from workflow_billfield t, HtmlLabelInfo t2 where billid = ? and ((type in (9,37) and fieldhtmltype=3) or fieldhtmltype=6) and t.fieldlabel = t2.indexid and type <> 2 and t2.languageid=?";
		} else {
			sql_fieldname = "select fieldid,fieldname from workflow_fieldlable t,workflow_formdict wf where formid= ? and langurageid=? and wf.id = t.fieldid and type <> 2 and fieldid in (select id from workflow_formdict where ((type in (9,37) and fieldhtmltype=3) or fieldhtmltype=6))";
		}
		rs.executeQuery(sql_fieldname,formID,user.getLanguage());
		ArrayList extraFileList = new ArrayList();
		while (rs.next()) {
			String tmp_fieldName = Util.null2String(rs.getString("fieldname"));
			if (!tmp_fieldName.trim().equals("") && !"null".equalsIgnoreCase(tmp_fieldName)) {
				extraFileList.add(tmp_fieldName);
			}
		}
		int fieldCount = extraFileList.size();
		new BaseBean().writeLog("----------------yjy----------fieldCount:"+fieldCount);
		if (fieldCount > 0){
			rs.execute("select * from " + formTableName + " where requestid=" + requestid);
			if (rs.next()) {
				for (int i = 0; i < fieldCount; i++) {
					String tmp_fieldName = (String) extraFileList.get(i);
					String fieldValue = Util.null2String(rs.getString(tmp_fieldName));
					if (!"".equals(fieldValue.trim()) && !"null".equalsIgnoreCase(fieldValue)) {
						imageFileId += fieldValue + ",";
					}

				}
				if (!"".equals(imageFileId)){
					if(imageFileId.endsWith(",")) {
						imageFileId = imageFileId.substring(0, imageFileId.length()-1);
					}
				}
			}
			if (!"".equals(detailtable)){
			    if ("1".equals(isbill)){
					rs.executeQuery("select * from "+detailtable+"  where mainid = (select id from "+formTableName+" where requestid = ?)",requestid);
				}else {
					rs.executeQuery("select * from "+detailtable+" where requestid = ?",requestid);
				}
				while (rs.next()){
					for (int i = 0; i < fieldCount; i++) {
						String tmp_fieldName = (String) extraFileList.get(i);
						String fieldValue = Util.null2String(rs.getString(tmp_fieldName));
						if (!"".equals(fieldValue.trim()) && !"null".equalsIgnoreCase(fieldValue)) {
						    if (!"".equals(imageFileId)){
								imageFileId += "," + fieldValue;
							}else {
								imageFileId += fieldValue + ",";
							}

						}

					}
				}
				if (!"".equals(imageFileId)){
					if(imageFileId.endsWith(",")) {
						imageFileId = imageFileId.substring(0, imageFileId.length()-1);
					}
				}
			}
			new BaseBean().writeLog("----------------yjy----------imageFileId:"+imageFileId);
			if (!"".equals(imageFileId)){
			    RecordSet rs2 = new RecordSet();
				String[] imageFile = imageFileId.split(",");
				for (String docIds : imageFile) {
				    String sql = "select checkoutstatus,checkoutuserid,docsubject from docdetail where id = ?";
				    rs.executeQuery(sql,docIds);
				    if (rs.next()){
						new BaseBean().writeLog("----------------yjy----------checkoutstatus",rs.getString("checkoutstatus"));
						new BaseBean().writeLog("----------------yjy----------docsubject",rs.getString("docsubject"));
						new BaseBean().writeLog("----------------yjy----------checkoutuserid",rs.getString("checkoutuserid"));
						new BaseBean().writeLog("----------------yjy----------docIds",docIds);
						if (rs.getString("checkoutstatus").equals("1")){
							new BaseBean().writeLog("----------------yjy----------checkoutstatus==1");
							String sqlUserId = "select lastname from hrmresource where id = ?";
							rs2.executeQuery(sqlUserId,rs.getInt("checkoutuserid"));
							if (rs2.next()){
								msg += SystemEnv.getHtmlLabelName(58,user.getLanguage())+":"+rs.getString("docsubject")+" "+SystemEnv.getHtmlLabelName(83426,user.getLanguage())+
										rs2.getString("lastname")+SystemEnv.getHtmlLabelName(19692,user.getLanguage())+"\n";
							}
							//new DocCheckInOutUtil().docForceCheckIn(user.getUID(),Util.getIntValue(docIds));
						}
				    }
				}
				if (!"".equals(msg)){
				    //msg += SystemEnv.getHtmlLabelName(32874,user.getLanguage());
				    msg += "文档还未保存,不能提交!";
					isDocForceCheckIn = "false";
					new BaseBean().writeLog("----------------yjy----------false");
				}else{
					isDocForceCheckIn = "true";
					new BaseBean().writeLog("----------------yjy----------true");
				}
			}
		}
	}
	new BaseBean().writeLog("----------------yjy----------isDocForceCheckIn:"+isDocForceCheckIn);
	new BaseBean().writeLog("----------------yjy----------msg:"+msg);
	if ("submit".equals(operation)){
	    if ("".equals(isDocForceCheckIn)){
			json.put("result","success");
			json.put("isDocForceCheckIn","true");
			json.put("prompt","");
			new BaseBean().writeLog("----------------yjy----------json1:"+json.toString());
		}else {
			json.put("result","success");
			json.put("isDocForceCheckIn",isDocForceCheckIn);
			json.put("prompt",msg);
			new BaseBean().writeLog("----------------yjy----------json2:"+json.toString());
		}

	}
	out.print(json.toString());
%>