OdocSaveTextRequest.jsp
7.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<%@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());
%>