@Test public void test() throws InterruptedException { for (int i = 0; i < 30; i++) { service.report1(i, new Date()); } Thread.sleep(1 * 1000); List<?> logs = permissionHelper.getEntities("from AccessLog"); Assert.assertTrue(logs.size() >= 0); AccessLog firstLog = (AccessLog) logs.get(0); Assert.assertEquals(firstLog.getId(), firstLog.getPK()); SQLExcutor ex = new SQLExcutor(); String sql = "select id, methodName as 方法名称 from dm_access_log"; ex.excuteQuery(sql); ex.excuteQuery( sql, new AbstractSO() { private static final long serialVersionUID = 1L; public String[] getParameterNames() { return null; } }); ex.excuteQuery("test1", 1, new HashMap<Integer, Object>()); ex.excuteQuery(sql, new HashMap<Integer, Object>()); Assert.assertTrue(ex.result.size() > 10); }
public List<Map<String, Object>> getAllCenterList() { String script = "select '-1' as id, -1 as pk, '-1' as code, '全部' as name from dual" + " union all " + " select t.name as id, t.id as pk, t.code as code, t.name as name from gt_site t " + " where type_code = '01' and status = 'ENABLE' "; SQLExcutor excutor = new SQLExcutor(false); excutor.excuteQuery(script); return excutor.result; }
public List<Map<String, Object>> getOrgList(Long userId) { String script = "select '-1' as id, -1 as pk, '-1' as code, '全网' as name from dual" + " union all " + " select t.name as id, t.id as pk, t.name as code, t.name as name " + " from um_group t " + " where t.parentId=(select g.id from um_group g where g.name='百世快运')"; SQLExcutor excutor = new SQLExcutor(false); excutor.excuteQuery(script, DMConstants.LOCAL_CONN_POOL); List<String> fatherGroups = ServiceList.getFatherGroups(); if (fatherGroups != null) { if (fatherGroups.size() == 1) { // 总部员工 return excutor.result; } else if (fatherGroups.size() >= 2) { // 分公司员工 & 分拨员工,只能看到其所在的分公司 for (Map<String, Object> temp : excutor.result) { if (temp.get("name").equals(fatherGroups.get(1))) { return Arrays.asList(temp); } } } } List<Map<String, Object>> emptyList = new ArrayList<Map<String, Object>>(); List<Object[]> groups = loginService.getGroupsByUserId(userId); for (Object[] group : groups) { if (group[1].toString().endsWith("分公司")) { Map<String, Object> temp = new HashMap<String, Object>(); temp.put("id", group[1]); temp.put("pk", group[0]); temp.put("code", group[1]); temp.put("name", group[1]); emptyList.add(temp); } } return emptyList; }
public List<Map<String, Object>> getCenterList(String org, Long userId) { String script = "select '-1' as id, -1 as pk, '-1' as code, '全部' as name from dual" + " union all " + " select t.name as id, t.id as pk, t.name as code, t.name as name " + " from um_group t " + " where t.parentId=(select g.id from um_group g where g.name='" + org + "')"; SQLExcutor excutor = new SQLExcutor(false); excutor.excuteQuery(script, DMConstants.LOCAL_CONN_POOL); List<String> fatherGroups = ServiceList.getFatherGroups(); if (fatherGroups != null && fatherGroups.size() >= 3) { // 分拨员工,只能看到其所在的分拨 for (Map<String, Object> temp : excutor.result) { if (temp.get("name").equals(fatherGroups.get(2))) { return Arrays.asList(temp); } } } return excutor.result; }