InputReportOperation.jsp
15.5 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<%@ page language="java" contentType="text/html; charset=GBK" %>
<%@ include file="/systeminfo/init.jsp" %>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="RecordSetTrans" class="weaver.conn.RecordSetTrans" scope="page" />
<jsp:useBean id="InputReportModuleFile" class="weaver.datacenter.InputReportModuleFile" scope="page" />
<jsp:useBean id="LabelComInfo" class="weaver.systeminfo.label.LabelComInfo" scope="page" />
<jsp:useBean id="BillComInfo" class="weaver.workflow.workflow.BillComInfo" scope="page" />
<jsp:useBean id="InputReportComInfo" class="weaver.datacenter.InputReportComInfo" scope="page" />
<jsp:useBean id="WorkflowComInfo" class="weaver.workflow.workflow.WorkflowComInfo" scope="page" />
<%
String operation = Util.null2String(request.getParameter("operation"));
String inprepid = Util.null2String(request.getParameter("inprepid"));
String inprepname = Util.fromScreen(request.getParameter("inprepname"),user.getLanguage());
String inpreptablename = Util.null2String(request.getParameter("inpreptablename"));
String inprepfrequence = Util.null2String(request.getParameter("inprepfrequence"));
String inprepbudget = Util.null2String(request.getParameter("inprepbudget"));
String oldinprepbudget = Util.null2String(request.getParameter("oldinprepbudget"));
String inprepforecast = Util.null2String(request.getParameter("inprepforecast"));
String oldinprepforecast = Util.null2String(request.getParameter("oldinprepforecast"));
String crmid = Util.null2String(request.getParameter("crmid"));
String inprepcrmid = Util.null2String(request.getParameter("inprepcrmid"));
String startdate = Util.null2String(request.getParameter("startdate")) ;
String enddate = Util.null2String(request.getParameter("enddate")) ;
String modulefilename = Util.null2String(request.getParameter("modulefilename")); //模板文件名称
String helpdocid = Util.null2String(request.getParameter("helpdocid")); //帮助文档
String hastable = Util.null2String(request.getParameter("hastable")); //是否已经有同名的表
String isInputMultiLine = Util.null2String(request.getParameter("isInputMultiLine")); //是否填报多行
if(!("1".equals(isInputMultiLine))){
isInputMultiLine="0";
}
int billId = Util.getIntValue(request.getParameter("billId"),0); //单据id
String inprepbugtablename = "" ;
String inprepfortablename = "" ;
if(inprepbudget.equals("1")) inprepbugtablename = inpreptablename + "_buget" ;
else inprepbudget = "0" ;
if(inprepforecast.equals("1")) inprepfortablename = inpreptablename + "_forecast" ;
else inprepforecast = "0" ;
RecordSetTrans.setAutoCommit(false);
if(operation.equals("add")){
try{
//获取显示名的标签id
int nameLabelId=0;
String sql="select id from HtmlLabelIndex where indexdesc='"+inprepname+"'";
RecordSetTrans.executeSql(sql);
if(RecordSetTrans.next()){
nameLabelId = Util.getIntValue(RecordSetTrans.getString("id"),0);
}else{
sql="select min(id) as id from HtmlLabelIndex";
RecordSetTrans.executeSql(sql);
if(RecordSetTrans.next()){
nameLabelId = Util.getIntValue(RecordSetTrans.getString("id"),0);
}
if(nameLabelId>0){
nameLabelId = -1;
}
nameLabelId-=1;
sql="INSERT INTO HtmlLabelIndex values("+nameLabelId+",'"+inprepname+"')";
RecordSetTrans.executeSql(sql);
sql="INSERT INTO HtmlLabelInfo VALUES("+nameLabelId+",'"+inprepname+"',7)";
RecordSetTrans.executeSql(sql);
}
sql="select min(id) as id from workflow_bill";
RecordSetTrans.executeSql(sql);
if(RecordSetTrans.next()){
billId = Util.getIntValue(RecordSetTrans.getString("id"),0);
}
if(billId>0){
billId = -1;
}
billId-=1;
if("1".equals(isInputMultiLine)){
RecordSetTrans.executeSql("INSERT INTO workflow_bill ( id, namelabel, tablename, createpage, managepage, viewpage, detailtablename, detailkeyfield,operationpage,hasFileUp) VALUES("+billId+","+nameLabelId+",'"+inpreptablename+"_main','AddBillDataCenter.jsp','ManageBillDataCenter.jsp','','"+inpreptablename+"','mainId','BillDataCenterOperation.jsp','1')");
RecordSetTrans.executeSql("INSERT INTO workflow_billdetailtable (billid,tablename,orderid) values("+billId+",'"+inpreptablename+"',1)");
}else{
RecordSetTrans.executeSql("INSERT INTO workflow_bill ( id, namelabel, tablename, createpage, managepage, viewpage, detailtablename, detailkeyfield,operationpage,hasFileUp) VALUES("+billId+","+nameLabelId+",'"+inpreptablename+"','AddBillDataCenter.jsp','ManageBillDataCenter.jsp','','','','BillDataCenterOperation.jsp','1') ");
}
BillComInfo.removeBillCache();
RecordSetTrans.executeSql("INSERT INTO workflow_billfield ( billid, fieldname, fieldlabel, fielddbtype, fieldhtmltype, type, dsporder, viewtype,detailtable) VALUES ("+billId+",'reportUserId',20715,'int',3,1,-3,0,'')");
RecordSetTrans.executeSql("INSERT INTO workflow_billfield ( billid, fieldname, fieldlabel, fielddbtype, fieldhtmltype, type, dsporder, viewtype,detailtable) VALUES ("+billId+",'inprepDspDate',20716,'varchar(80)',1,1,-2,0,'')");
RecordSetTrans.executeSql("INSERT INTO workflow_billfield ( billid, fieldname, fieldlabel, fielddbtype, fieldhtmltype, type, dsporder, viewtype,detailtable) VALUES ("+billId+",'crmId',16902,'int',3,7,-1,0,'')");
char separator = Util.getSeparator() ;
String para = inprepname + separator + inpreptablename + separator + inprepbugtablename + separator + inprepfrequence + separator + inprepbudget + separator + inprepforecast + separator + startdate + separator + enddate + separator + modulefilename + separator + helpdocid + separator + isInputMultiLine + separator + billId ;
RecordSetTrans.executeProc("T_InputReport_Insert",para);
if(!hastable.equals("1")) {
String createSequence = "";
String createTrigger = "";
String createtable = "";
RecordSetTrans.setChecksql(false);
if("1".equals(isInputMultiLine)){
if("oracle".equals(RecordSet.getDBType())){
createtable=" create table " + inpreptablename +"_main" +
" (id integer , " +
" requestId integer ," +
" crmId integer ," +
" reportDate char(10) ," +
" inprepDspDate varchar2(80) ," +
" inputDate char(10) ," +
" inputStatus char(1) default '0', " +
" reportUserid integer , " +
" confirmUserId integer , " +
" modType char(1) default '0') " ;
createSequence = "create sequence "+inpreptablename+"_main_Id" +
" start with 1 increment by 1 nomaxvalue nocycle";
createTrigger = "CREATE OR REPLACE TRIGGER "+inpreptablename+"_mainIDT" +
" before insert on " +inpreptablename +"_main" +
" for each row begin select "+inpreptablename+"_main_Id.nextval into :new.id from dual; end;";
RecordSetTrans.executeSql(createtable);
RecordSetTrans.executeSql(createSequence);
RecordSetTrans.executeSql(createTrigger);
createtable =" create table " + inpreptablename +
" (inputid integer , " +
" mainId integer ," +
" crmId integer ," +
" reportDate char(10) ," +
" inprepDspDate varchar2(80) ," +
" inputDate char(10) ," +
" inputStatus char(1) default '0', " +
" reportUserid integer , " +
" confirmUserId integer , " +
" modType char(1) default '0') " ;
createSequence = "create sequence "+inpreptablename+"_Id " +
" start with 1 increment by 1 nomaxvalue nocycle";
createTrigger = "CREATE OR REPLACE TRIGGER "+inpreptablename+"_IdT" +
" before insert on " +inpreptablename +
" for each row begin select "+inpreptablename+"_Id.nextval into :new.inputid from dual; end;";
RecordSetTrans.executeSql(createtable);
RecordSetTrans.executeSql(createSequence);
RecordSetTrans.executeSql(createTrigger);
}else{
createtable=" create table " + inpreptablename +"_main" +
" (id int IDENTITY(1,1) primary key CLUSTERED, " +
" requestId int ," +
" crmId int ," +
" reportDate char(10) ," +
" inprepDspDate varchar(80) ," +
" inputDate char(10) ," +
" inputStatus char(1) default '0', " +
" reportUserid int , " +
" confirmUserId int , " +
" modType char(1) default '0') " ;
RecordSetTrans.executeSql(createtable);
createtable =" create table " + inpreptablename +
" (inputid int IDENTITY(1,1) primary key CLUSTERED, " +
" mainId int ," +
" crmId int ," +
" reportDate char(10) ," +
" inprepDspDate varchar(80) ," +
" inputDate char(10) ," +
" inputStatus char(1) default '0', " +
" reportUserid int , " +
" confirmUserId int , " +
" modType char(1) default '0') " ;
RecordSetTrans.executeSql(createtable);
}
}else{
if("oracle".equals(RecordSet.getDBType())){
createtable=" create table " + inpreptablename +
" (id integer , " +
" inputId integer ," +
" requestId integer ," +
" crmId integer ," +
" reportDate char(10) ," +
" inprepDspDate varchar2(80) ," +
" inputDate char(10) ," +
" inputStatus char(1) default '0', " +
" reportUserid integer , " +
" confirmUserId integer , " +
" modType char(1) default '0') " ;
createSequence = "create sequence "+inpreptablename+"_Id"+
" start with 1 increment by 1 nomaxvalue nocycle";
createTrigger = "CREATE OR REPLACE TRIGGER "+inpreptablename+"_IdT"+
" before insert on " +inpreptablename+
" for each row begin select "+inpreptablename+"_Id.nextval into :new.id from dual; end;";
RecordSetTrans.executeSql(createtable);
RecordSetTrans.executeSql(createSequence);
RecordSetTrans.executeSql(createTrigger);
}else{
createtable=" create table " + inpreptablename +
" (id int IDENTITY(1,1) primary key CLUSTERED, " +
" inputId int ," +
" requestId int ," +
" crmId int ," +
" reportDate char(10) ," +
" inprepDspDate varchar(80) ," +
" inputDate char(10) ," +
" inputStatus char(1) default '0', " +
" reportUserid int , " +
" confirmUserId int , " +
" modType char(1) default '0') " ;
RecordSetTrans.executeSql(createtable);
}
}
}
InputReportComInfo.removeConditionCache();
RecordSetTrans.commit();
LabelComInfo.addLabeInfoCache(String.valueOf(nameLabelId));
}catch(Exception exception){
RecordSetTrans.rollback();
}
response.sendRedirect("InputReport.jsp");
}
else if(operation.equals("edit")){
try{
char separator = Util.getSeparator() ;
String para = ""+inprepid + separator + inprepname + separator + inpreptablename + separator + inprepbugtablename + separator + inprepfrequence + separator + inprepbudget + separator + inprepforecast + separator + startdate + separator + enddate + separator + modulefilename + separator + helpdocid + separator + isInputMultiLine + separator + billId ;
RecordSetTrans.executeProc("T_InputReport_Update",para);
int nameLabelId=0;
String sql="select id from HtmlLabelIndex where indexdesc='"+inprepname+"'";
RecordSetTrans.executeSql(sql);
if(RecordSetTrans.next()){
nameLabelId = Util.getIntValue(RecordSetTrans.getString("id"),0);
}else{
sql="select min(id) as id from HtmlLabelIndex";
RecordSetTrans.executeSql(sql);
if(RecordSetTrans.next()){
nameLabelId = Util.getIntValue(RecordSetTrans.getString("id"),0);
}
if(nameLabelId>0){
nameLabelId = -1;
}
nameLabelId-=1;
sql="INSERT INTO HtmlLabelIndex values("+nameLabelId+",'"+inprepname+"')";
RecordSetTrans.executeSql(sql);
sql="INSERT INTO HtmlLabelInfo VALUES("+nameLabelId+",'"+inprepname+"',7)";
RecordSetTrans.executeSql(sql);
}
RecordSetTrans.executeSql("update workflow_bill set nameLabel="+nameLabelId+" where id="+billId);
InputReportComInfo.removeConditionCache();
BillComInfo.removeBillCache();
RecordSetTrans.commit();
LabelComInfo.addLabeInfoCache(String.valueOf(nameLabelId));
}catch(Exception exception){
RecordSetTrans.rollback();
}
response.sendRedirect("InputReport.jsp");
}
else if(operation.equals("delete")){
try{
RecordSetTrans.executeSql("update workflow_base set isValid='0' where formId="+billId+" and isBill='1'");
WorkflowComInfo.removeWorkflowCache();
RecordSetTrans.executeSql("update workflow_bill set inValid=1 where id="+billId);
RecordSetTrans.executeSql("update T_inputReport set deleted=1 where inprepId="+inprepid);
InputReportComInfo.removeConditionCache();
RecordSetTrans.commit();
}catch(Exception exception){
RecordSetTrans.rollback();
}
response.sendRedirect("InputReport.jsp");
}
else if(operation.equals("addcrm")){
char separator = Util.getSeparator() ;
String para = ""+inprepid + separator + crmid ;
RecordSet.executeProc("T_InputReportCrm_Insert",para);
response.sendRedirect("InputReportEdit.jsp?inprepid="+inprepid);
}
else if(operation.equals("deletecrm")){
char separator = Util.getSeparator() ;
String para = ""+inprepcrmid;
RecordSet.executeProc("T_InputReportCrm_Delete",para);
response.sendRedirect("InputReportEdit.jsp?inprepid="+inprepid);
}
else if(operation.equals("close")){
RecordSet.executeSql("update T_InputReport set inprepbudgetstatus = '2' where inprepid="+inprepid);
response.sendRedirect("InputReportEdit.jsp?inprepid="+inprepid);
}
else if(operation.equals("open")){
RecordSet.executeSql("update T_InputReport set inprepbudgetstatus = '1' where inprepid="+inprepid);
response.sendRedirect("InputReportEdit.jsp?inprepid="+inprepid);
}
else if(operation.equals("editcontactright")){
RecordSet.executeSql("delete T_InputReportCrmContacter where inprepcrmid="+inprepcrmid);
String contacterids[] = request.getParameterValues("contacterid") ;
if( contacterids != null ) {
for(int i=0 ; i<contacterids.length ; i++) {
RecordSet.executeSql("insert into T_InputReportCrmContacter( inprepcrmid, contacterid ) values("+inprepcrmid +" , " + contacterids[i]+" ) ");
}
}
RecordSet.executeSql("delete T_InputReportCrmModer where inprepcrmid="+inprepcrmid);
String contactmoderids[] = request.getParameterValues("contactmoderid") ;
if( contactmoderids != null ) {
for(int i=0 ; i<contactmoderids.length ; i++) {
RecordSet.executeSql("insert into T_InputReportCrmModer( inprepcrmid, contacterid ) values("+inprepcrmid +" , " + contactmoderids[i]+" ) ");
}
}
RecordSet.executeSql("delete T_InputReportCrmSel where inprepcrmid="+inprepcrmid);
String contactselcrms[] = request.getParameterValues("contactselcrm") ;
if( contactselcrms != null ) {
for(int i=0 ; i<contactselcrms.length ; i++) {
String contactselcrmid = Util.null2String(request.getParameter("crmid_"+contactselcrms[i]));
RecordSet.executeSql("insert into T_InputReportCrmSel( inprepcrmid, contacterid , selcrm) values("+inprepcrmid +" , " + contactselcrms[i]+" , '" + contactselcrmid + "' ) ");
}
}
response.sendRedirect("InputReportEdit.jsp?inprepid="+inprepid);
}
%>