WuziSelectAction.java
3.81 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
package com.cntytz;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import weaver.conn.RecordSet;
import weaver.formmode.customjavacode.AbstractCustomSqlConditionJavaCode;
import weaver.hrm.User;
import java.util.Map;
/**
* @Description: 物资查询条件拼装
* 规则:1.项目经理和材料管理员只能看自己所管辖的
* 2.公司的材料设备部人员可以看所属公司的全部
* @ClassName: WuziSelectAction
* @author: xuBin
* @date: 2020/6/9 下午2:57
* @Version 1.0
*/
public class WuziSelectAction extends AbstractCustomSqlConditionJavaCode {
Log logger = LogFactory.getLog(WuziSelectAction.class);
/**
* 生成SQL查询限制条件
* @param param
* param包含(但不限于)以下数据
* user 当前用户
*
* @return
* 返回的查询限制条件的格式举例为: t1.a = '1' and t1.b = '3' and t1.c like '%22%'
* 其中t1为表单主表表名的别名
*/
@Override
public String generateSqlCondition(Map<String, Object> param) throws Exception {
RecordSet record1 = new RecordSet();
RecordSet record = new RecordSet();
String sqlCondition = "";
try {
User user = (User)param.get("user");
record.writeLog("=========用户信息======="+JSONObject.toJSONString(user));
//用户ID
int uid = user.getUID();
//用户部门
int userDepartmentId = user.getUserDepartment();
//公司id
int userSubCompanyId = user.getUserSubCompany1();
String sql = "";
//查询角色
sql = "select id from hrmrolemembers where (ROLEID=47 or ROLEID=53) and resourceid = "+uid+"";
record.writeLog("===========roleid -sql ======="+sql);
record.execute(sql);
record.next();
String id = record.getString("id");
Boolean isroler =null;
if ("".equals(id) || null == id){
isroler = false;
}else{
isroler = true;
}
record.writeLog("============isrolerisroler======",isroler);
if (!isroler){
//不属于物资调拨查看全部角色
sqlCondition = " t1.clgly = "+uid+" or t1.xmjl = "+uid+"";
record1.writeLog("===========sqlCondition ======="+sqlCondition);
}else{
//属于所属公司的物资调拨查看全部角色
sqlCondition =" t1.szfgs = "+userSubCompanyId+"";
}
// sql = "select id from hrmdepartment where id = "+ userDepartmentId +" and SUBCOMPANYID1 ="+userSubCompanyId+" and departmentname ='材料设备部'";
//// sql = "select id from hrmdepartment where id = "+ userDepartmentId +" and SUBCOMPANYID1 ="+userSubCompanyId+" and departmentname ='材料设备部'";
// record1.writeLog("===========sql ======="+sql);
// record1.execute(sql);
// record1.next();
// String id = record1.getString("id");
// record1.writeLog("=========用户ID======="+ id);
// if ("".equals(id) || null == id){
// //不属于材料设备部
// sqlCondition = " t1.clgly = "+uid+" or t1.xmjl = "+uid+"";
// record1.writeLog("===========sqlCondition ======="+sqlCondition);
// }else{
// //属于所属公司的材料设备部
// sqlCondition =" t1.szfgs = "+userSubCompanyId+"";
// }
record1.writeLog("=======sqlCondition======"+sqlCondition);
} catch (Exception e) {
e.printStackTrace();
record1.writeLog("=======执行失败======",e.getMessage());
}
return sqlCondition;
}
}