show_matrix_edit.jsp
13.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
<%@ page import="com.alibaba.fastjson.JSON" %>
<%@ page import="com.engine.hrm.cmd.matrix.biz.MatrixinfoComInfo" %>
<%@ page import="com.engine.hrm.cmd.matrix.biz.chain.MatrixCondition" %>
<%@ page import="com.engine.hrm.cmd.matrix.listnew.MatrixUtilToolCmd" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.hrm.moduledetach.ManageDetachComInfo" %>
<%@ page import="weaver.matrix.MatrixManager" %>
<%@ page import="weaver.systeminfo.systemright.CheckSubCompanyRight" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
try {
String userid = Util.null2String(request.getParameter("userid"));
if(userid.length() == 0){
out.println("param userid is null:<br/>");
return ;
}
String matrixid = Util.null2String(request.getParameter("matrixid"));
if(matrixid.length() == 0){
out.println("param matrixid is null:<br/>");
return ;
}
MatrixUtilToolCmd matrixUtilToolCmd = new MatrixUtilToolCmd();
User user = new User(Util.getIntValue(userid));
//可维护列和条件控制集合
Map<String,Object> condition_col_map = new HashMap<>();
//0表示没有操作按钮的权限,1表示有操作按钮的权限
String hasright = "0";
MatrixManager matrixManager = new MatrixManager();
MatrixinfoComInfo matrixinfoComInfo = new MatrixinfoComInfo();
MatrixCondition matrixCondition = matrixManager.getMatrixConditionByMaintUser(userid, matrixid);
out.print("getMatrixDataByMaintDetach:userid:"+userid+":matrixid:"+matrixid+"::"+ JSON
.toJSONString(matrixCondition)+"<br/>");
String issystemStr = matrixinfoComInfo.getIssystem(matrixid);
boolean isSystem = false;
if("1".equalsIgnoreCase(issystemStr) || "2".equalsIgnoreCase(issystemStr)){
isSystem = true;
}
out.print("getMatrixDataByMaintDetach:isSystem:"+isSystem+"<br/>");
//是否需要收到机构权限控制
boolean needDetachControll = false;
ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo();
boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权
CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight();
boolean hasMenuRight = HrmUserVarify.checkUserRight("Matrix:Maint", new User(Util.getIntValue(userid)));
out.print("getMatrixDataByMaintDetach:hasMenuRight:"+hasMenuRight+"<br/>");
String subcompanyids = "";
int operatelevel= -1;
int systemOperatelevel= -1;
out.print("getMatrixDataByMaintDetach:hrmdetachable:"+hrmdetachable+"<br/>");
if(hrmdetachable){
String subcompanyid = matrixinfoComInfo.getSubcompanyid(matrixid);
out.print("getMatrixDataByMaintDetach:matrixinfoComInfo:subcompanyid:"+subcompanyid+"<br/>");
//机构权限里有一个机构的级别是编辑,完全控制的,都表示按钮可操作
operatelevel=checkSubCompanyRight.ChkComRightByUserRightCompanyId(Util.getIntValue(userid),"Matrix:Maint",Util.getIntValue(subcompanyid,-1));
out.print("getMatrixDataByMaintDetach:operatelevel:"+operatelevel+"<br/>");
int[] arrSubcompanyids = checkSubCompanyRight.getSubComByUserRightId(Util.getIntValue(userid),"Matrix:Maint");
out.print("getMatrixDataByMaintDetach:arrSubcompanyids:"+JSON
.toJSONString(arrSubcompanyids)+"<br/>");
if(!"1".equalsIgnoreCase(userid)){
for(int i=0;arrSubcompanyids!=null&&i<arrSubcompanyids.length;i++){
int tmp_subid = arrSubcompanyids[i];
int tmp_operatelevel=checkSubCompanyRight.ChkComRightByUserRightCompanyId(Util.getIntValue(userid),"Matrix:Maint",tmp_subid);
if(tmp_operatelevel > systemOperatelevel){
// 系统矩阵的级别就是取所有可以维护的机构里的最大操作级别
systemOperatelevel = tmp_operatelevel;
}
if(subcompanyids.length()>0){
subcompanyids+=",";
}
subcompanyids += tmp_subid;
}
}else{
operatelevel = 2;
hasright = "1";
}
}else{
if(hasMenuRight){
hasright = "1";
}
}
out.print("getMatrixDataByMaintDetach:subcompanyids:"+subcompanyids+"<br/>");
if(subcompanyids.length() > 0){
needDetachControll = true;
condition_col_map.put("detach_subids",","+subcompanyids+",");
if(isSystem){
operatelevel = systemOperatelevel;
}
condition_col_map.put("operatelevel",operatelevel);
condition_col_map.put("needDetachControll",needDetachControll);
}
if(operatelevel > 0){
hasright = "1";
}
//根据feildname生成可维护列的map集合
Map<String, List<String>> fieldname_list_map = new HashMap<>();
boolean hasSetCol = false;
List<Map<String, String>> fieldInfos = MatrixUtilToolCmd.getMatrixJsonById(matrixid,true,false);
String condition_sql = "";
//条件字段是否有设置总部,只要有设置总部表示数据都可见
boolean isAll = false;
if(matrixCondition != null){
isAll = matrixCondition.isAll();
hasSetCol = true;
if(isAll){
condition_col_map.put("isAll", "1");
}else{
condition_col_map.put("isAll", "0");
}
condition_col_map.put("hasSetCol", true);
String colids = matrixCondition.getColids();
condition_col_map.put("colids", colids);
if(colids.length() > 0){
//如果设置了可维护列
if(operatelevel > 0){
//机构权限是可编辑+,那么就可以显示所有的列
condition_col_map.put("colids", "");
}
}
}
// 通过sql 来过滤数据 矩阵数据过滤
StringBuffer sql_col_where=new StringBuffer("");
//矩阵浏览按钮数据过滤,拼接sqlwhere
Map<String,String> sql_type_where= new HashMap<>();
if(fieldInfos.size() > 0) {
//条件字段数据是取合集的
for (int i = 0; i < fieldInfos.size(); i++) {
Map<String, String> fieldInfoMap = fieldInfos.get(i);
String htmltype = fieldInfoMap.get("htmltype");
String fieldname = fieldInfoMap.get("fieldlable");
String type = fieldInfoMap.get("type");
if("1".equalsIgnoreCase(type)){
//数据字段不考虑
continue;
}
out.print("getMatrixDataByMaintDetach:fieldname:"+fieldname+":sql_col_where:"+sql_col_where+"<br/>");
if("1".equalsIgnoreCase(htmltype)){
// 人力资源
if(hasSetCol && !isAll){
List<String> resids = matrixCondition.getResids();
if(resids != null && !resids.isEmpty()){
matrixUtilToolCmd.bindConditionSql(resids,fieldname,sql_col_where,htmltype,sql_type_where);
fieldname_list_map.put(fieldname, resids);
}
}else if(isAll){
if(sql_col_where.length() > 0){
sql_col_where.append(" or 1=1 ");
}else{
sql_col_where.append(" 1=1 ");
}
}
if(needDetachControll){
matrixUtilToolCmd.bindDetachSql(subcompanyids, fieldname, sql_col_where,"res",htmltype,sql_type_where);
}
}else if("4".equalsIgnoreCase(htmltype)){
// 部门
if(hasSetCol && !isAll){
List<String> deptids = matrixCondition.getDeptids();
if(deptids != null && !deptids.isEmpty()){
matrixUtilToolCmd.bindConditionSql(deptids,fieldname,sql_col_where, htmltype, sql_type_where);
fieldname_list_map.put(fieldname, deptids);
}
}else if(isAll){
if(sql_col_where.length() > 0){
sql_col_where.append(" or 1=1 ");
}else{
sql_col_where.append(" 1=1 ");
}
}
if(needDetachControll){
matrixUtilToolCmd.bindDetachSql(subcompanyids, fieldname, sql_col_where, "dept", "dept", sql_type_where);
}
}else if("164".equalsIgnoreCase(htmltype)){
// 分部
if(hasSetCol && !isAll){
List<String> subids = matrixCondition.getSubids();
if(subids != null && !subids.isEmpty()){
matrixUtilToolCmd.bindConditionSql(subids,fieldname,sql_col_where, htmltype, sql_type_where);
fieldname_list_map.put(fieldname, subids);
}
}else if(isAll){
if(sql_col_where.length() > 0){
sql_col_where.append(" or 1=1 ");
}else{
sql_col_where.append(" 1=1 ");
}
}
if(needDetachControll){
matrixUtilToolCmd.bindDetachSql(subcompanyids, fieldname, sql_col_where, "sub", htmltype, sql_type_where);
}
}else if("24".equalsIgnoreCase(htmltype)){
// 岗位
if(hasSetCol && !isAll){
List<String> jobids = matrixCondition.getJobids();
if(jobids != null && !jobids.isEmpty()){
matrixUtilToolCmd.bindConditionSql(jobids,fieldname,sql_col_where, htmltype, sql_type_where);
fieldname_list_map.put(fieldname, jobids);
}
}else if(isAll){
if(sql_col_where.length() > 0){
sql_col_where.append(" or 1=1 ");
}else{
sql_col_where.append(" 1=1 ");
}
}
}else if("8".equalsIgnoreCase(htmltype)){
// 项目
if(hasSetCol && !isAll){
List<String> prjids = matrixCondition.getPrjids();
if(prjids != null && !prjids.isEmpty()){
matrixUtilToolCmd.bindConditionSql(prjids,fieldname,sql_col_where, htmltype, sql_type_where);
fieldname_list_map.put(fieldname, prjids);
}
}else if(isAll){
if(sql_col_where.length() > 0){
sql_col_where.append(" or 1=1 ");
}else{
sql_col_where.append(" 1=1 ");
}
}
}else if("7".equalsIgnoreCase(htmltype)){
// 客户
if(hasSetCol && !isAll){
List<String> crmids = matrixCondition.getCrmids();
if(crmids != null && !crmids.isEmpty()){
matrixUtilToolCmd.bindConditionSql(crmids,fieldname,sql_col_where, htmltype, sql_type_where);
fieldname_list_map.put(fieldname, crmids);
}
}else if(isAll){
if(sql_col_where.length() > 0){
sql_col_where.append(" or 1=1 ");
}else{
sql_col_where.append(" 1=1 ");
}
}
}
}
}
if(sql_col_where.length() > 0){
condition_sql = "and ("+sql_col_where.toString()+")";
condition_col_map.put("condition_sql", condition_sql);
}
if(!sql_type_where.isEmpty()){
condition_col_map.put("sql_type_where", sql_type_where);
}
if(!hrmdetachable){
if(hasMenuRight){
condition_col_map.put("condition_sql", "");
condition_col_map.put("colids", "");
}
}
if("1".equalsIgnoreCase(hasright)){
condition_col_map.put("hassaveright", "1");
}else{
//如果维护者维护了,且有数据,那么就可以做保存
if(!fieldname_list_map.isEmpty()){
condition_col_map.put("hassaveright", "1");
}else if(hasSetCol){
condition_col_map.put("hassaveright", "1");
//如果条件字段是空的,表示是可以维护所有的
condition_col_map.put("isAll", "1");
}
}
condition_col_map.put("fieldname_list_map", fieldname_list_map);
condition_col_map.put("hasright", hasright);
condition_col_map.put("hrmdetachable", hrmdetachable);
condition_col_map.put("operatelevel", operatelevel);
condition_col_map.put("systemOperatelevel", systemOperatelevel);
out.print("getMatrixDataByMaintDetach:condition_col_map:"+condition_col_map+"<br/>");
} catch (Exception e) {
e.printStackTrace();
out.print(e.getMessage());
}
%>