DepartmentOperation.jsp
24.9 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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
<%@ page import="weaver.general.Util,weaver.conn.*" %>
<%@ page import="weaver.hrm.definedfield.HrmDeptFieldManager"%>
<%@ page import="java.util.*" %>
<%@ page import="weaver.general.StaticObj"%>
<%@ page import="weaver.file.FileUpload" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@page import="weaver.hrm.common.DbFunctionUtil"%>
<%@ page import="weaver.matrix.MatrixUtil"%>
<%@ page import="weaver.hrm.definedfield.HrmFieldComInfo" %>
<%@ page import="weaver.interfaces.email.CoreMailAPI" %>
<%@ page import="weaver.interfaces.email.CoreMailTestAPI" %>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<jsp:useBean id="ResourceComInfo" class="weaver.hrm.resource.ResourceComInfo" scope="page" />
<jsp:useBean id="DepartmentComInfo" class="weaver.hrm.company.DepartmentComInfo" scope="page" />
<jsp:useBean id="SysMaintenanceLog" class="weaver.systeminfo.SysMaintenanceLog" scope="page" />
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="OrganisationCom" class="weaver.rtx.OrganisationCom" scope="page" />
<jsp:useBean id="HrmServiceManager" class="weaver.interfaces.hrm.HrmServiceManager" scope="page" />
<%!
/*
*Added by Charoes Huang
*Check if the department level equals 10, if true,this department can't have sub department
*
*/
private boolean ifDeptLevelEquals10(int departmentid){
boolean isEquals10 = false;
RecordSet rs = new RecordSet();
String sqlStr ="Select COUNT(d1.id) from HrmDepartment d1,HrmDepartment d2,HrmDepartment d3,HrmDepartment d4,HrmDepartment d5,HrmDepartment d6,HrmDepartment d7,HrmDepartment d8,HrmDepartment d9 WHERE d1.supdepid = d2.id and d2.supdepid = d3.id and d3.supdepid = d4.id and d4.supdepid = d5.id and d5.supdepid = d6.id and d6.supdepid = d7.id and d7.supdepid = d8.id and d8.supdepid = d9.id and d1.id <> d2.id and d1.id = "+departmentid ;
rs.executeSql(sqlStr);
if(rs.next()){
if(rs.getInt(1) > 0){
isEquals10 = true ;
}
}
return isEquals10;
}
%>
<%
application.removeAttribute("organlist");//update for hrm broser,xiaofeng
FileUpload fu = new FileUpload(request);
String operation = Util.fromScreen(fu.getParameter("operation"),user.getLanguage());
String departmentmark = Util.fromScreen(fu.getParameter("departmentmark"),user.getLanguage());
String departmentname = Util.fromScreen(fu.getParameter("departmentname"),user.getLanguage());
String subcompanyid1 = Util.fromScreen(fu.getParameter("subcompanyid1"),user.getLanguage());
if(Util.getIntValue(subcompanyid1,0)<=0&&!operation.equals("delete")){
subcompanyid1 = Util.fromScreen(fu.getParameter("subcompanyid1old"),user.getLanguage());
}
int supdepid = Util.getIntValue(fu.getParameter("supdepid"),0);
String showorder = Util.fromScreen(Util.null2s(fu.getParameter("showorder"),"0"),user.getLanguage());
if(Util.getIntValue(subcompanyid1,0)<=0&&!operation.equals("delete"))
throw new Exception("invalid subcompanyid:"+subcompanyid1);
String allsupdepid = "0";
String sURL="";
String departmentcode = Util.fromScreen(fu.getParameter("departmentcode"),user.getLanguage());
int coadjutant=Util.getIntValue(fu.getParameter("coadjutant"),0);
CoreMailAPI coremailapi = CoreMailAPI.getInstance();
CoreMailTestAPI testapi = CoreMailTestAPI.getInstance();
if(!HrmUserVarify.checkUserRight("HrmDepartmentAdd:Add", user)){
response.sendRedirect("/notice/noright.jsp");
return ;
}
if(operation.equals("add")){
/*
* Added by Charoes Huang
* 判断是否10级部门
*/
int supdepartmentid = supdepid;
if(supdepartmentid > 0){
if(ifDeptLevelEquals10(supdepartmentid)){
sURL="HrmDepartmentAdd.jsp?isdialog=1&subcompanyid="+subcompanyid1+"&supdepid="+supdepid+"&msgid=56&departmentmark="+departmentmark+"&departmentname="+departmentname+"&showorder="+showorder;
session.setAttribute("subcompanyid",subcompanyid1);
session.setAttribute("supdepid",""+supdepid);
session.setAttribute("departmentmark",departmentmark);
session.setAttribute("departmentname",departmentname);
session.setAttribute("showorder",""+showorder);
//sURL=new String(sURL.getBytes("GBK"),"ISO8859_1");
response.sendRedirect(sURL);
return;
}
}
if(!"".equals(departmentcode)){
String sql2="select id from hrmdepartment where departmentcode = '" + departmentcode + "' ";
RecordSet.executeSql(sql2);
if(RecordSet.next()){
sURL="HrmDepartmentAdd.jsp?isdialog=1&subcompanyid="+subcompanyid1+"&supdepid="+supdepid+"&msgid=177";
session.setAttribute("subcompanyid",subcompanyid1);
session.setAttribute("supdepid",""+supdepid);
session.setAttribute("departmentmark",departmentmark);
session.setAttribute("departmentname",departmentname);
session.setAttribute("showorder",""+showorder);
//sURL=new String(sURL.getBytes("GBK"),"ISO8859_1");
response.sendRedirect(sURL);
return;
}
}
char separator = Util.getSeparator() ;
//allsupdepid = DepartmentComInfo.getAllSupDepId(Util.getIntValue(supdepid))+supdepid+",";
if(supdepid > 0){//当选择了上级部门的时候,需要更改当前部门的上级分部
subcompanyid1 = DepartmentComInfo.getSubcompanyid1(supdepid+"");
}
String para = departmentmark + separator + departmentname + separator +
supdepid+separator+allsupdepid+separator+subcompanyid1 + separator+ showorder+separator+coadjutant;
RecordSet.executeProc("HrmDepartment_Insert",para);
int id=0;
if(RecordSet.next()){
id = RecordSet.getInt(1);
}
weaver.hrm.company.OrgOperationUtil OrgOperationUtil = new weaver.hrm.company.OrgOperationUtil();
OrgOperationUtil.updateDepartmentLevel(""+id,"0");
String sql3="update hrmdepartment set departmentcode = '" + departmentcode + "' ";
/*
String sqlUpdateField="";
rs3=FormFieldTransMethod.getDeptFieldRs();
if(rs3!=null){
while(rs3.next()){//取得部门所有开启的自定义字段
String idTemp=rs3.getString("id");
String fieldnameTemp=rs3.getString("fieldname");
int fieldlabelTemp=rs3.getInt("fieldlabel");
String fieldhtmltypeTemp=rs3.getString("fieldhtmltype");
String typeTemp=rs3.getString("type");
String viewtypeTemp=rs3.getString("viewtype");
if(fieldnameTemp!=null && !"".equals(fieldnameTemp)){
String fieldnameValueTemp = fu.getParameter(fieldnameTemp);
if("".equals(fieldnameValueTemp)|| "0".equals(fieldnameValueTemp)){
sqlUpdateField+=" ,"+fieldnameTemp+"=null ";
}else{
sqlUpdateField+=" ,"+fieldnameTemp+"='"+Util.null2String(fu.getParameter(fieldnameTemp))+"' ";
}
}
}
}
if(!"".equals(sqlUpdateField)){
sql3+=sqlUpdateField;
}
*/
HrmDeptFieldManager hrmDeptFieldManager = new HrmDeptFieldManager(5);
hrmDeptFieldManager.editCustomData(fu,id);
sql3+= ","+DbFunctionUtil.getInsertUpdateSetSql(RecordSet.getDBType(),user.getUID()) ;
sql3+=" where id = "+id;
//System.out.println(">>>>>>>>>>>>>>>>>>>>新增 sql3="+sql3);
//RecordSet.executeSql("update hrmdepartment set departmentcode = '" + departmentcode + "',zzjgbmfzr='"+zzjgbmfzr+"',zzjgbmfgld='"+zzjgbmfgld+"',jzglbmfzr='"+jzglbmfzr+"',jzglbmfgld='"+jzglbmfgld+"' where id = " + id);
RecordSet.executeSql(sql3);
//xiaofeng
int flag=RecordSet.getFlag();
//System.out.println(flag);
if(flag==2){
sURL="/hrm/company/HrmDepartmentAdd.jsp?isdialog=1&subcompanyid="+subcompanyid1+"&supdepid="+supdepid+"&msgid=41";
session.setAttribute("subcompanyid",subcompanyid1);
session.setAttribute("supdepid",""+supdepid);
session.setAttribute("departmentmark",departmentmark);
session.setAttribute("departmentname",departmentname);
session.setAttribute("showorder",""+showorder);
//sURL=new String(sURL.getBytes("GBK"),"ISO8859_1");
response.sendRedirect(sURL);
//response.sendRedirect("/hrm/company/HrmDepartmentAdd.jsp?msgid=41");
return;
}
if(flag==3){
sURL="/hrm/company/HrmDepartmentAdd.jsp?isdialog=1&subcompanyid="+subcompanyid1+"&supdepid="+supdepid+"&msgid=44";
session.setAttribute("subcompanyid",subcompanyid1);
session.setAttribute("supdepid",""+supdepid);
session.setAttribute("departmentmark",departmentmark);
session.setAttribute("departmentname",departmentname);
session.setAttribute("showorder",""+showorder);
//sURL=new String(sURL.getBytes("GBK"),"ISO8859_1");
response.sendRedirect(sURL);
//response.sendRedirect("/hrm/company/HrmDepartmentAdd.jsp?msgid=44");
return;
}
SysMaintenanceLog.resetParameter();
SysMaintenanceLog.setRelatedId(id);
SysMaintenanceLog.setRelatedName(departmentname);
SysMaintenanceLog.setOperateType("1");
SysMaintenanceLog.setOperateDesc("HrmDepartment_Insert,"+para);
SysMaintenanceLog.setOperateItem("12");
SysMaintenanceLog.setOperateUserid(user.getUID());
SysMaintenanceLog.setClientAddress(fu.getRemoteAddr());
SysMaintenanceLog.setSysLogInfo();
DepartmentComInfo.removeCompanyCache();
RecordSet.executeSql("update orgchartstate set needupdate=1");
//add by wjy
//同步RTX端部门信息
OrganisationCom.addDepartment(id);
//同步到CoreMail邮件系统开始
if(supdepid == 0) {
coremailapi.synOrg(""+id, departmentname, "parent_org_unit_id=com_"+subcompanyid1+"&org_unit_name="+departmentname, "0");
//testapi.synOrg(""+id, departmentname, "com_"+subcompanyid1, "0");
} else {
coremailapi.synOrg(""+id, departmentname, "parent_org_unit_id="+supdepid+"&org_unit_name="+departmentname, "0");
//testapi.synOrg(""+id, departmentname, ""+supdepid, "0");
}
//同步到CoreMail邮件系统结束
//OA与第三方接口单条数据同步方法开始
HrmServiceManager.SynInstantDepartment(""+id,"1");
//OA与第三方接口单条数据同步方法结束
//同步部门数据到矩阵
MatrixUtil.updateDepartmentData(""+id);
//初始化应用分权
new weaver.hrm.appdetach.AppDetachComInfo().initSubDepAppData();
//response.sendRedirect("HrmCompany_frm.jsp?subcomid="+subcompanyid1+"&deptid="+id);
String nodeid = "dept_"+subcompanyid1+"_"+id;
%>
<SCRIPT LANGUAGE='JavaScript'>
var parentPage = parent.location.href;
if(parentPage.indexOf("HrmCompany_frm") > -1){
parent.location.href = "HrmCompany_frm.jsp?nodeid=<%=nodeid%>&subcomid=<%=subcompanyid1%>&deptid=<%=id%>";
}else{
location.href = "HrmDepartmentAdd.jsp?isclose=1";
}
</SCRIPT>
<%
return;
}
else if(operation.equals("edit")){
int id = Util.getIntValue(fu.getParameter("id"),0);
HrmFieldComInfo hrmFieldComInfo = new HrmFieldComInfo();
String sql = "select * from HrmDepartment where id="+id;
rs.writeLog(sql);
rs.executeSql(sql);
while(rs.next()){
if(!hrmFieldComInfo.getIsused("73").equals("1"))departmentmark = rs.getString("departmentmark");
if(!hrmFieldComInfo.getIsused("74").equals("1"))departmentname = rs.getString("departmentname");
if(!hrmFieldComInfo.getIsused("75").equals("1"))subcompanyid1 = rs.getString("subcompanyid1");
if(!hrmFieldComInfo.getIsused("76").equals("1"))supdepid = rs.getInt("supdepid");
if(!hrmFieldComInfo.getIsused("77").equals("1"))coadjutant = rs.getInt("coadjutant");
if(!hrmFieldComInfo.getIsused("78").equals("1"))showorder = rs.getString("showorder");
//if(hfm.getIsUsed("79"))showid = rs.getString("showid");
if(!hrmFieldComInfo.getIsused("80").equals("1"))departmentcode = rs.getString("departmentcode");
}
/*
* Added by Charoes Huang
* 判断是否10级部门
*/
int supdepartmentid = supdepid;
if(supdepartmentid > 0){
if(ifDeptLevelEquals10(supdepartmentid)){
sURL="HrmDepartmentEdit.jsp?isdialog=1&subcompanyid="+subcompanyid1+"&supdepid="+supdepid+"&id="+id+"&msgid=56&departmentmark="+departmentmark+"&departmentname="+departmentname+"&showorder="+showorder;
session.setAttribute("subcompanyid",subcompanyid1);
session.setAttribute("supdepid",""+supdepid);
session.setAttribute("departmentmark",departmentmark);
session.setAttribute("departmentname",departmentname);
session.setAttribute("showorder",""+showorder);
//sURL=new String(sURL.getBytes("GBK"),"ISO8859_1");
response.sendRedirect(sURL);
//response.sendRedirect("HrmDepartmentEdit.jsp?id="+id+"&message=1");
return;
}
}
if(!"".equals(departmentcode)){
String sql2="select id from hrmdepartment where departmentcode = '" + departmentcode + "' and id !="+id;
RecordSet.executeSql(sql2);
if(RecordSet.next()){
sURL="HrmDepartmentEdit.jsp?isdialog=1&subcompanyid="+subcompanyid1+"&supdepid="+supdepid+"&id="+id+"&msgid=177";
session.setAttribute("subcompanyid",subcompanyid1);
session.setAttribute("supdepid",""+supdepid);
session.setAttribute("departmentmark",departmentmark);
session.setAttribute("departmentname",departmentname);
session.setAttribute("showorder",""+showorder);
//sURL=new String(sURL.getBytes("GBK"),"ISO8859_1");
response.sendRedirect(sURL);
//response.sendRedirect("/hrm/company/HrmDepartmentEdit.jsp?id="+id+"&msgid=41");
return;
}
}
char separator = Util.getSeparator() ;
if(supdepartmentid > 0){//当选择了上级部门的时候,需要更改当前部门的上级分部
subcompanyid1 = DepartmentComInfo.getSubcompanyid1(supdepartmentid+"");
}
String para = ""+id +separator+ departmentmark + separator + departmentname + separator +
supdepartmentid+separator+allsupdepid+separator+subcompanyid1 + separator+ showorder+separator+coadjutant;
RecordSet.executeProc("HrmDepartment_Update",para);
String sql3="update hrmdepartment set departmentcode = '" + departmentcode + "' ";
weaver.hrm.company.OrgOperationUtil OrgOperationUtil = new weaver.hrm.company.OrgOperationUtil();
OrgOperationUtil.updateDepartmentLevel(""+id,"0");
/*
String sqlUpdateField="";
rs3=FormFieldTransMethod.getDeptFieldRs();
if(rs3!=null){
while(rs3.next()){//取得部门所有开启的自定义字段
String idTemp=rs3.getString("id");
String fieldnameTemp=rs3.getString("fieldname");
int fieldlabelTemp=rs3.getInt("fieldlabel");
String fieldhtmltypeTemp=rs3.getString("fieldhtmltype");
String typeTemp=rs3.getString("type");
String viewtypeTemp=rs3.getString("viewtype");
if(fieldnameTemp!=null && !"".equals(fieldnameTemp)){
String fieldnameValueTemp = fu.getParameter(fieldnameTemp);
if("".equals(fieldnameValueTemp)|| "0".equals(fieldnameValueTemp)){
sqlUpdateField+=" ,"+fieldnameTemp+"=null ";
}else{
sqlUpdateField+=" ,"+fieldnameTemp+"='"+Util.null2String(fu.getParameter(fieldnameTemp))+"' ";
}
}
}
}
if(!"".equals(sqlUpdateField)){
sql3+=sqlUpdateField;
}
*/
HrmDeptFieldManager hrmDeptFieldManager = new HrmDeptFieldManager(5);
hrmDeptFieldManager.editCustomData(fu,id);
sql3 += ","+DbFunctionUtil.getUpdateSetSql(RecordSet.getDBType(),user.getUID()) ;
sql3+=" where id = "+id;
//System.out.println(">>>>>>>>>>>>>>>>>>>>编辑 sql3="+sql3);
//RecordSet.executeSql("update hrmdepartment set departmentcode = '" + departmentcode + "',zzjgbmfzr='"+zzjgbmfzr+"',zzjgbmfgld='"+zzjgbmfgld+"',jzglbmfzr='"+jzglbmfzr+"',jzglbmfgld='"+jzglbmfgld+"' where id = " + id);
RecordSet.executeSql(sql3);
//xiaofeng
int flag=RecordSet.getFlag();
//System.out.println(flag);
if(flag==2){
sURL="/hrm/company/HrmDepartmentEdit.jsp?isdialog=1&id="+id+"&msgid=41";
session.setAttribute("subcompanyid",subcompanyid1);
session.setAttribute("supdepid",""+supdepid);
session.setAttribute("departmentmark",departmentmark);
session.setAttribute("departmentname",departmentname);
session.setAttribute("showorder",""+showorder);
//sURL=new String(sURL.getBytes("GBK"),"ISO8859_1");
response.sendRedirect(sURL);
//response.sendRedirect("/hrm/company/HrmDepartmentEdit.jsp?id="+id+"&msgid=41");
return;
}
if(flag==3){
sURL="/hrm/company/HrmDepartmentEdit.jsp?isdialog=1&id="+id+"&msgid=44";
session.setAttribute("subcompanyid",subcompanyid1);
session.setAttribute("supdepid",""+supdepid);
session.setAttribute("departmentmark",departmentmark);
session.setAttribute("departmentname",departmentname);
session.setAttribute("showorder",""+showorder);
//sURL=new String(sURL.getBytes("GBK"),"ISO8859_1");
response.sendRedirect(sURL);
//response.sendRedirect("/hrm/company/HrmDepartmentEdit.jsp?id="+id+"&msgid=44");
return;
}
ArrayList departmentlist = new ArrayList();
//departmentlist.add(id+"");
//rs.execute("select id from HrmDepartment where supdepid="+id);
//while(rs.next()){
// int childdepartmenttmp = Util.getIntValue(rs.getString(1), 0);
// departmentlist.add(childdepartmenttmp+"");
// RecordSet.execute("update HrmDepartment set subcompanyid1="+subcompanyid1+" where id="+childdepartmenttmp);
//}
departmentlist = DepartmentComInfo.getAllChildDeptByDepId(departmentlist,id+"");
departmentlist.add(id+"");
for(int i=0;i<departmentlist.size();i++){
String listdepartmenttemp = (String)departmentlist.get(i);
RecordSet.execute("update HrmDepartment set subcompanyid1="+subcompanyid1+" where id="+listdepartmenttemp);
//TD16048改为逐条修改
rs.execute("select id, subcompanyid1,managerid,seclevel,managerstr from hrmresource where departmentid="+listdepartmenttemp);
while(rs.next()){
int resourceid_tmp = Util.getIntValue(rs.getString(1), 0);
int oldsubcompanyid1 = Util.getIntValue(rs.getString(2), 0);
int oldmanagerid = Util.getIntValue(rs.getString(3), 0);
int seclevel = Util.getIntValue(rs.getString(4), 0);
String oldmanagerstr = Util.null2String(rs.getString(5));
RecordSet.execute("update hrmresource set subcompanyid1="+subcompanyid1+" where id="+resourceid_tmp);
para = ""+resourceid_tmp + separator + listdepartmenttemp + separator + subcompanyid1 + separator + oldmanagerid + separator + seclevel + separator + oldmanagerstr + separator + listdepartmenttemp + separator + oldsubcompanyid1 + separator + oldmanagerid + separator + seclevel + separator + oldmanagerstr + separator + "1";
RecordSet.executeProc("HrmResourceShare",para);
}
//add by wjy
//同步RTX端部门信息
OrganisationCom.editDepartment(Util.getIntValue(listdepartmenttemp));
}
SysMaintenanceLog.resetParameter();
SysMaintenanceLog.setRelatedId(id);
SysMaintenanceLog.setRelatedName(departmentname);
SysMaintenanceLog.setOperateType("2");
SysMaintenanceLog.setOperateDesc("HrmDepartment_Update,"+para);
SysMaintenanceLog.setOperateItem("12");
SysMaintenanceLog.setOperateUserid(user.getUID());
SysMaintenanceLog.setClientAddress(fu.getRemoteAddr());
SysMaintenanceLog.setSysLogInfo();
DepartmentComInfo.removeCompanyCache();
ResourceComInfo.removeResourceCache();
RecordSet.executeSql("update orgchartstate set needupdate=1");
//同步到CoreMail邮件系统开始
if(supdepid == 0) {
coremailapi.synOrg(""+id, departmentname, "parent_org_unit_id=com_"+subcompanyid1+"&org_unit_name="+departmentname, "0");
//testapi.synOrg(""+id, departmentname, "com_"+subcompanyid1, "0");
} else {
coremailapi.synOrg(""+id, departmentname, "parent_org_unit_id="+supdepid+"&org_unit_name="+departmentname, "0");
//testapi.synOrg(""+id, departmentname, ""+supdepid, "0");
}
//同步到CoreMail邮件系统结束
//OA与第三方接口单条数据同步方法开始
HrmServiceManager.SynInstantDepartment(""+id,"2");
//OA与第三方接口单条数据同步方法结束
//同步部门数据到矩阵
MatrixUtil.updateDepartmentData(""+id);
String nodeid = "dept_"+subcompanyid1+"_"+id;
response.sendRedirect("/hrm/company/HrmDepartmentEdit.jsp?isclose=1&subcomid="+subcompanyid1+"&id="+id);
%>
<SCRIPT LANGUAGE='JavaScript'>
var parentPage = parent.location.href;
alert(location.href);
alert(parentPage.indexOf("HrmCompany_frm"));
if(parentPage.indexOf("HrmCompany_frm") > -1){
parent.location.href = "HrmCompany_frm.jsp?nodeid=<%=nodeid%>&subcomid=<%=subcompanyid1%>&deptid=<%=id%>";
}else{
location.href = "HrmCompany_frm.jsp?nodeid=<%=nodeid%>&subcomid=<%=subcompanyid1%>&deptid=<%=id%>";
}
</SCRIPT>
<%
return;
}
else if(operation.equals("delete")){
boolean canDelete = true;
int id = Util.getIntValue(fu.getParameter("id"),0);
RecordSet.executeSql("select departmentname, supdepid, subcompanyid1 from HrmDepartment where id = " + id);
if(RecordSet.next()) {
departmentname = Util.null2String(RecordSet.getString("departmentname"));
supdepid = Util.getIntValue(RecordSet.getString("supdepid"), 0);
subcompanyid1 = Util.null2String(RecordSet.getString("subcompanyid1"));
}
char separator = Util.getSeparator() ;
String para = ""+id;
/*
原有的判断数据中心删除部门去掉
String sql = "select count(id) from HrmCostcenter where departmentid = "+id;
RecordSet.executeSql(sql);
RecordSet.next();
if(RecordSet.getInt(1)>0){
canDelete = false;
response.sendRedirect("HrmDepartmentEdit.jsp?id="+id+"&msgid=20");
}
String sql = "select count(id) from HrmJobTitles where jobdepartmentid ="+id;
RecordSet.executeSql(sql);
RecordSet.next();
if(RecordSet.getInt(1)>0){
canDelete = false;
sURL="/hrm/company/HrmDepartmentEdit.jsp?isdialog=1&id="+id+"&msgid=20";
session.setAttribute("subcompanyid",subcompanyid1);
session.setAttribute("supdepid",""+supdepid);
session.setAttribute("departmentmark",departmentmark);
session.setAttribute("departmentname",departmentname);
session.setAttribute("showorder",""+showorder);
//sURL=new String(sURL.getBytes("GBK"),"ISO8859_1");
response.sendRedirect(sURL);
//response.sendRedirect("HrmDepartmentEdit.jsp?id="+id+"&msgid=20");
return ;
}*/
/*
原有的判断部门工作时间删除部门去掉
sql = "select count(id) from HrmSchedule where relatedid ="+id+" and scheduletype = 1";
RecordSet.executeSql(sql);
RecordSet.next();
if(RecordSet.getInt(1)>0){
canDelete = false;
response.sendRedirect("HrmDepartmentEdit.jsp?id="+id+"&msgid=20");
} */
/*
原有的判断部门下面人力资源删除部门去掉,由控制岗位来实现
sql = "select count(id) from HrmResource where departmentid ="+id;
RecordSet.executeSql(sql);
RecordSet.next();
if(RecordSet.getInt(1)>0){
canDelete = false;
response.sendRedirect("HrmDepartmentEdit.jsp?id="+id+"&msgid=20");
} */
if(canDelete){
RecordSet.executeProc("HrmDepartment_Delete",para);
//add by wjy
//同步RTX端部门信息
OrganisationCom.deleteDepartment(id);
//同步到CoreMail邮件系统开始
if(supdepid == 0) {
coremailapi.synOrg(""+id, departmentname, "parent_org_unit_id=com_"+subcompanyid1+"&org_unit_name="+departmentname, "1");
//testapi.synOrg(""+id, departmentname, "com_"+subcompanyid1, "1");
} else {
coremailapi.synOrg(""+id, departmentname, "parent_org_unit_id="+supdepid+"&org_unit_name="+departmentname, "1");
//testapi.synOrg(""+id, departmentname, ""+supdepid, "1");
}
//同步到CoreMail邮件系统结束
//OA与第三方接口单条数据同步方法开始
HrmServiceManager.SynInstantDepartment(""+id,"3");
//OA与第三方接口单条数据同步方法结束
}
SysMaintenanceLog.resetParameter();
SysMaintenanceLog.setRelatedId(id);
SysMaintenanceLog.setRelatedName(departmentname);
SysMaintenanceLog.setOperateType("3");
SysMaintenanceLog.setOperateDesc("HrmDepartment_Delete,"+para);
SysMaintenanceLog.setOperateItem("12");
SysMaintenanceLog.setOperateUserid(user.getUID());
SysMaintenanceLog.setClientAddress(fu.getRemoteAddr());
SysMaintenanceLog.setSysLogInfo();
String supid=DepartmentComInfo.getDepartmentsupdepid(""+id);
DepartmentComInfo.removeCompanyCache();
RecordSet.executeSql("update orgchartstate set needupdate=1");
//同步部门数据到矩阵
MatrixUtil.updateDepartmentData(""+id);
String nodeid = "";
//response.sendRedirect("/hrm/company/HrmDepartmentEdit.jsp?isclose=1&subcomid="+subcompanyid1+"&deptid="+supid);
%>
<SCRIPT LANGUAGE='JavaScript'>
var parentPage = parent.location.href;
if(parentPage.indexOf("HrmDepartmentDsp") > -1){
parent.parent.location.href = "HrmCompany_frm.jsp?nodeid=<%=nodeid%>&subcomid=<%=subcompanyid1%>&deptid=<%=id%>";
}else{
location.href = "HrmCompany_frm.jsp?nodeid=<%=nodeid%>&subcomid=<%=subcompanyid1%>&deptid=<%=id%>";
}
</SCRIPT>
<%
return;
}
%>