|
@@ -31,58 +31,60 @@ public class hr extends Controller {
|
|
|
/*
|
|
|
过滤条件设置
|
|
|
*/
|
|
|
- StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
- if (content.containsKey("where")) {
|
|
|
- JSONObject whereObject = content.getJSONObject("where");
|
|
|
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
- where.append(" and(");
|
|
|
- where.append("t1.name like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t1.phonenumber like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t1.officetelephone like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t1.position like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t1.hrcode like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t2.depname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t3.accountno like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append(")");
|
|
|
- }
|
|
|
- if (whereObject.containsKey("isworker") && !"".equals(whereObject.getString("isworker"))) {
|
|
|
- where.append(" and t1.isworker ='").append(whereObject.getString("isworker")).append("' ");
|
|
|
- }
|
|
|
- }
|
|
|
- boolean containssub = content.getBoolean("containssub");
|
|
|
- JSONArray departmentidsArray = content.getJSONArray("departmentids");
|
|
|
- ArrayList<String> departmentidsList = new ArrayList<>();
|
|
|
- for (Object o : departmentidsArray) {
|
|
|
- String departmentid = o.toString();
|
|
|
- departmentidsList.add(departmentid);
|
|
|
- if (containssub) {
|
|
|
- departmentidsList.addAll(getSubDepartmentids(Long.parseLong(departmentid)));
|
|
|
- }
|
|
|
- }
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("t1.name like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.phonenumber like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.officetelephone like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.position like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.hrcode like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t2.depname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t3.accountno like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("isworker") && !"".equals(whereObject.getString("isworker"))) {
|
|
|
+ where.append(" and t1.isworker ='").append(whereObject.getString("isworker")).append("' ");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("addproxy") && !"".equals(whereObject.getString("addproxy"))) {
|
|
|
+ where.append(" and t1.userid !=").append(userid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean containssub = content.getBoolean("containssub");
|
|
|
+ JSONArray departmentidsArray = content.getJSONArray("departmentids");
|
|
|
+ ArrayList<Long> departmentidsList = new ArrayList<>();
|
|
|
+ for (Object o : departmentidsArray) {
|
|
|
+ long departmentid = Long.parseLong(o.toString());
|
|
|
+ departmentidsList.add(departmentid);
|
|
|
+ if (containssub) {
|
|
|
+ departmentidsList.addAll(Department.getSubDepartmentIds(this, departmentid));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (content.containsKey("isAll")) {
|
|
|
+ if (content.getBooleanValue("isAll")) {
|
|
|
+ departmentidsList = dbConnect.runSqlQuery("SELECT departmentid from sys_department WHERE siteid = '" + siteid + "' AND isused").toArrayList("departmentid", new ArrayList<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "员工列表查询", pageSize, pageNumber, pageSorting);
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter_in("departmentid", departmentidsList);
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
+ Rows rolerows = dbConnect.runSqlQuery("select t2.rolename,t1.userid from sys_userrole t1 inner join sys_role t2 on t1.siteid=t2.siteid and t1.roleid=t2.roleid where t1.siteid='" + siteid + "'");
|
|
|
+ RowsMap rolerowsMap = rolerows.toRowsMap("userid");
|
|
|
+ for (Row row : rows) {
|
|
|
+ if (!(rolerowsMap.get(row.getString("userid"))).isEmpty()) {
|
|
|
+ row.put("userrole", (rolerowsMap.get(row.getString("userid"))).toJsonArray("rolename"));
|
|
|
+ } else {
|
|
|
+ row.put("userrole", new JSONArray());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (content.containsKey("isAll")) {
|
|
|
- if (content.getBooleanValue("isAll")) {
|
|
|
- departmentidsList = dbConnect.runSqlQuery("SELECT departmentid from sys_department WHERE siteid = '" + siteid + "' AND isused").toArrayList("departmentid");
|
|
|
- }
|
|
|
- }
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "员工列表查询", pageSize, pageNumber, pageSorting);
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter_in("departmentid", departmentidsList);
|
|
|
- sqlFactory.addParameter_SQL("where", where);
|
|
|
- Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
- Rows rolerows = dbConnect.runSqlQuery("select t2.rolename,t1.userid from sys_userrole t1 inner join sys_role t2 on t1.siteid=t2.siteid and t1.roleid=t2.roleid where t1.siteid='" + siteid + "'");
|
|
|
- RowsMap rolerowsMap = rolerows.toRowsMap("userid");
|
|
|
- for (Row row : rows) {
|
|
|
- //System.out.println(row.getString("userid"));
|
|
|
- if(!(rolerowsMap.get(row.getString("userid"))).isEmpty()) {
|
|
|
- row.put("userrole", (rolerowsMap.get(row.getString("userid"))).toJsonArray("rolename"));
|
|
|
- } else {
|
|
|
- row.put("userrole", new JSONArray());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return getSucReturnObject().setData(rows).toString();
|
|
|
- }
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
|
|
|
@API(title = "员工详情查询")
|
|
|
@CACHEING
|
|
@@ -104,11 +106,11 @@ public class hr extends Controller {
|
|
|
Rows rolerows = dbConnect.runSqlQuery("select t2.rolename,t2.remarks from sys_userrole t1 inner join sys_role t2 on t1.siteid=t2.siteid and t1.roleid=t2.roleid where t1.userid='" + userid + "' and t1.siteid='" + siteid + "'");
|
|
|
row.put("userrole", rolerows);
|
|
|
}
|
|
|
- return getSucReturnObject().setData(rows.isNotEmpty()?rows.get(0):new Row()).toString();
|
|
|
+ return getSucReturnObject().setData(rows.isNotEmpty() ? rows.get(0) : new Row()).toString();
|
|
|
}
|
|
|
|
|
|
@API(title = "员工新增、修改")
|
|
|
- @CACHEING_CLEAN(cms = {@cm(clazz = hr.class, method = {"query_hrList", "query_hrMain"}),@cm(clazz = workorder.class, method = {"query_hrList"})})
|
|
|
+ @CACHEING_CLEAN(cms = {@cm(clazz = hr.class, method = {"query_hrList", "query_hrMain"}), @cm(clazz = workorder.class, method = {"query_hrList"})})
|
|
|
public String insertormodify_hr() throws YosException {
|
|
|
long hrid = content.getLongValue("hrid");//新增时传0
|
|
|
String hrcode = content.getString("hrcode", "sys_hr");
|
|
@@ -126,7 +128,7 @@ public class hr extends Controller {
|
|
|
long reporthrid = content.getLongValue("reporthrid");
|
|
|
long hruserid = content.getLongValue("userid");//绑定账号
|
|
|
long isworker = content.getLongValue("isworker");//是否工人(服务人员)
|
|
|
-
|
|
|
+
|
|
|
if (!idcard.equals("") && !idCard_validate(idcard)) {
|
|
|
return getErrReturnObject().setErrMsg("身份证号" + idcard + "无效").toString();
|
|
|
}
|
|
@@ -154,6 +156,7 @@ public class hr extends Controller {
|
|
|
addusersql.addParameter("createby", username);
|
|
|
addusersql.addParameter("changeuserid", userid);
|
|
|
addusersql.addParameter("isworker", isworker);
|
|
|
+ addusersql.addParameter("status", content.getStringValue("status", false, "0"));
|
|
|
|
|
|
content.put("hrid", hrid);
|
|
|
sqllist.add(addusersql.getSQL());
|
|
@@ -179,7 +182,8 @@ public class hr extends Controller {
|
|
|
modifyusersql.addParameter("changeby", username);
|
|
|
modifyusersql.addParameter("changeuserid", userid);
|
|
|
modifyusersql.addParameter("isworker", isworker);
|
|
|
-
|
|
|
+ modifyusersql.addParameter("status", content.getStringValue("status", false, "0"));
|
|
|
+
|
|
|
sqllist.add(modifyusersql.getSQL());
|
|
|
|
|
|
isrefresh = dbConnect.runSqlQuery("select * from sys_hr where siteid='" + siteid + "' and hrid='" + hrid + "' and departmentid='" + departmentid + "'").isEmpty();
|
|
@@ -192,7 +196,7 @@ public class hr extends Controller {
|
|
|
}
|
|
|
|
|
|
@API(title = "删除员工信息", apiversion = R.ID20221102090403.v1.class)
|
|
|
- @CACHEING_CLEAN(cms = {@cm(clazz = hr.class, method = {"query_hrList", "query_hrMain"}),@cm(clazz = workorder.class, method = {"query_hrList"})})
|
|
|
+ @CACHEING_CLEAN(cms = {@cm(clazz = hr.class, method = {"query_hrList", "query_hrMain"}), @cm(clazz = workorder.class, method = {"query_hrList"})})
|
|
|
public String deleteHr() throws YosException {
|
|
|
JSONArray hrids = content.getJSONArray("hrids");
|
|
|
StringBuffer str = new StringBuffer("(0");
|
|
@@ -206,7 +210,7 @@ public class hr extends Controller {
|
|
|
}
|
|
|
|
|
|
@API(title = "为员工创建新的账号")
|
|
|
- @CACHEING_CLEAN(cms = {@cm(clazz = hr.class, method = {"query_hrList", "query_hrMain"}),@cm(clazz = workorder.class, method = {"query_hrList"})})
|
|
|
+ @CACHEING_CLEAN(cms = {@cm(clazz = hr.class, method = {"query_hrList", "query_hrMain"}), @cm(clazz = workorder.class, method = {"query_hrList"})})
|
|
|
public String createUser() throws YosException {
|
|
|
long hrid = content.getLongValue("hrid");
|
|
|
Rows rows = dbConnect.runSqlQuery("select * from sys_hr where siteid='" + siteid + "' and hrid=" + hrid);
|
|
@@ -228,4 +232,4 @@ public class hr extends Controller {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-}
|
|
|
+}
|