|
@@ -12,13 +12,16 @@ public class ClientUserInfo extends UserInfo {
|
|
|
public ClientUserInfo(Controller controller) {
|
|
|
super(controller);
|
|
|
}
|
|
|
+
|
|
|
public static Row setLoginReturn(long usersiteid, Row userrow) {
|
|
|
return userrow;
|
|
|
}
|
|
|
+
|
|
|
private Row hrRow = null;
|
|
|
private Row enterpriseRow = null;
|
|
|
private Row enterprise_HrRow = null;
|
|
|
private Row agentsRow = null;
|
|
|
+ private Row reportHrRow = null;
|
|
|
|
|
|
public Row getHrRow() throws YosException {
|
|
|
if (hrRow == null) {
|
|
@@ -30,6 +33,16 @@ public class ClientUserInfo extends UserInfo {
|
|
|
return hrRow;
|
|
|
}
|
|
|
|
|
|
+ public Row getHrRow(Long hrid) throws YosException {
|
|
|
+ Row hrRow = new Row();
|
|
|
+ Rows hrRows = controller.dbConnect.runSqlQuery("select * from sys_hr where siteid='" + getSiteId() + "' and hrid=" + hrid);
|
|
|
+ if (hrRows.isNotEmpty()) {
|
|
|
+ hrRow = hrRows.getRow(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ return hrRow;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public Row getEnterpriseRow() throws YosException {
|
|
|
if (enterpriseRow == null) {
|
|
@@ -43,7 +56,7 @@ public class ClientUserInfo extends UserInfo {
|
|
|
|
|
|
public long getEnterpriseId() throws YosException {
|
|
|
Row row = getEnterpriseRow();
|
|
|
- if(row==null||row.isEmpty()){
|
|
|
+ if (row == null || row.isEmpty()) {
|
|
|
return 0;
|
|
|
}
|
|
|
return row.getLong("sys_enterpriseid");
|
|
@@ -71,16 +84,24 @@ public class ClientUserInfo extends UserInfo {
|
|
|
|
|
|
public long getAgentsId() throws YosException {
|
|
|
Row row = getAgentsRow();
|
|
|
- if (row==null||row.isEmpty()) {
|
|
|
+ if (row == null || row.isEmpty()) {
|
|
|
return 0;
|
|
|
}
|
|
|
return row.getLong("sa_agentsid");
|
|
|
}
|
|
|
|
|
|
- public boolean isSaler() throws YosException {
|
|
|
+ public boolean isSaler() throws YosException {
|
|
|
return controller.dbConnect.runSqlQuery("select *from sa_salearea_hr where siteid='" + getSiteId() + "' and hrid=" + controller.hrid).isNotEmpty();
|
|
|
}
|
|
|
|
|
|
+ public boolean isSysAdministrator() throws YosException {
|
|
|
+ return controller.dbConnect.runSqlQuery("select * from sys_users where userid='" + getUserId() + "' and sysadministrator=1").isNotEmpty();
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isSiteAdministrator() throws YosException {
|
|
|
+ return getUserType() == 0;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取当前企业的营销区域id
|
|
|
*/
|
|
@@ -92,25 +113,30 @@ public class ClientUserInfo extends UserInfo {
|
|
|
return rows.toArrayList("sa_saleareaid", new ArrayList<>());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param userid
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Row getAgentByUserid(long userid) throws YosException {
|
|
|
- return getAgentByUserid(userid, getSiteId());
|
|
|
+ public Row getReportHrRow() throws YosException {
|
|
|
+ if (reportHrRow == null) {
|
|
|
+ Rows hrRows = controller.dbConnect.runSqlQuery("SELECT t2.*FROM sys_hr t1 INNER JOIN sys_hr t2 ON t2.hrid=t1.reporthrid AND t2.siteid=t1.siteid WHERE t1.siteid='" + getSiteId() + "' AND t1.userid=" + getUserId());
|
|
|
+ if (hrRows.isNotEmpty()) {
|
|
|
+ reportHrRow = hrRows.getRow(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return reportHrRow;
|
|
|
}
|
|
|
|
|
|
- public long getAgentID() throws YosException {
|
|
|
- return getAgentByUserid(getUserId()).getLong("sa_agentsid");
|
|
|
+ //返回汇报对象的userid
|
|
|
+ public Long getReportUserid() throws YosException {
|
|
|
+ reportHrRow = getReportHrRow();
|
|
|
+ if (reportHrRow != null && !reportHrRow.isEmpty()) {
|
|
|
+ return reportHrRow.getLong("userid");
|
|
|
+ }
|
|
|
+ return -1L;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param userid
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Row getAgentByUserid(long userid, String siteid) throws YosException {
|
|
|
- Rows rows = controller.dbConnect.runSqlQuery("select t2.* from sys_enterprise_hr t1 inner join sa_agents t2 on t1.siteid=t2.siteid and t1.sys_enterpriseid=t2.sys_enterpriseid where t1.siteid='" + siteid + "' and t1.userid=" + userid);
|
|
|
- return rows.isEmpty() ? new Row() : rows.get(0);
|
|
|
+ //返回部门的主管userid
|
|
|
+ public Long getLeaderUserid(Long departmentid) throws YosException {
|
|
|
+ Rows rows = controller.dbConnect.runSqlQuery("SELECT userid from sys_hr WHERE departmentid = " + departmentid + " and isleader=1 and siteid='" + getSiteId() + "'");
|
|
|
+ return rows.isEmpty() ? -1 : rows.get(0).getLong("userid");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|