/** * 批量条件删除记录 * * @param queryMap 查询条件集合 */ public boolean delList(Map<String, Object> queryMap, Boolean delDev) { boolean result = false; if (queryMap == null) { queryMap = new HashMap<String, Object>(); } Object id = queryMap.get("id"); Object id_gt = queryMap.get("id_gt"); Object id_ge = queryMap.get("id_ge"); Object id_lt = queryMap.get("id_lt"); Object id_le = queryMap.get("id_le"); Object id_in = queryMap.get("id_in"); Object devId = queryMap.get("devId"); Object devId_gt = queryMap.get("devId_gt"); Object devId_ge = queryMap.get("devId_ge"); Object devId_lt = queryMap.get("devId_lt"); Object devId_le = queryMap.get("devId_le"); Object devId_in = queryMap.get("devId_in"); Object openclose = queryMap.get("openclose"); Object openclose_like = queryMap.get("openclose_like"); Object openclose_isNull = queryMap.get("openclose_isNull"); Object openclose_isNotNull = queryMap.get("openclose_isNotNull"); Object openclose_in = queryMap.get("openclose_in"); Object level = queryMap.get("level"); Object level_gt = queryMap.get("level_gt"); Object level_ge = queryMap.get("level_ge"); Object level_lt = queryMap.get("level_lt"); Object level_le = queryMap.get("level_le"); Object level_in = queryMap.get("level_in"); Object alarmupdatetime_gt = queryMap.get("alarmupdatetime_gt"); Object alarmupdatetime_ge = queryMap.get("alarmupdatetime_ge"); Object alarmupdatetime_lt = queryMap.get("alarmupdatetime_lt"); Object alarmupdatetime_le = queryMap.get("alarmupdatetime_le"); QueryCondition qc = new QueryCondition(HistoryDoorEntity.ID, QueryCondition.gt, "0"); if (id != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.ID, QueryCondition.eq, id)); } if (id_gt != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.ID, QueryCondition.gt, id_gt)); } if (id_ge != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.ID, QueryCondition.ge, id_ge)); } if (id_lt != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.ID, QueryCondition.lt, id_lt)); } if (id_le != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.ID, QueryCondition.le, id_le)); } if (id_in != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.ID, QueryCondition.in, id_in)); } if (devId != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.DEV_ID, QueryCondition.eq, devId)); } if (devId_gt != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.DEV_ID, QueryCondition.gt, devId_gt)); } if (devId_ge != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.DEV_ID, QueryCondition.ge, devId_ge)); } if (devId_lt != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.DEV_ID, QueryCondition.lt, devId_lt)); } if (devId_le != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.DEV_ID, QueryCondition.le, devId_le)); } if (devId_in != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.DEV_ID, QueryCondition.in, devId_in)); } if (openclose != null) { qc.andCondition( new QueryCondition(HistoryDoorEntity.OPENCLOSE, QueryCondition.eq, openclose)); } if (openclose_like != null) { qc.andCondition( new QueryCondition(HistoryDoorEntity.OPENCLOSE, QueryCondition.like, openclose_like)); } if (openclose_isNull != null) { qc.andCondition( new QueryCondition(HistoryDoorEntity.OPENCLOSE, QueryCondition.isNull, openclose_isNull)); } if (openclose_isNotNull != null) { qc.andCondition( new QueryCondition( HistoryDoorEntity.OPENCLOSE, QueryCondition.isNotNull, openclose_isNotNull)); } if (openclose_in != null) { qc.andCondition( new QueryCondition(HistoryDoorEntity.OPENCLOSE, QueryCondition.in, openclose_in)); } if (level != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.LEVEL, QueryCondition.eq, level)); } if (level_gt != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.LEVEL, QueryCondition.gt, level_gt)); } if (level_ge != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.LEVEL, QueryCondition.ge, level_ge)); } if (level_lt != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.LEVEL, QueryCondition.lt, level_lt)); } if (level_le != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.LEVEL, QueryCondition.le, level_le)); } if (level_in != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.LEVEL, QueryCondition.in, level_in)); } if (alarmupdatetime_gt != null) { qc.andCondition( new QueryCondition( HistoryDoorEntity.ALARMUPDATETIME, QueryCondition.gt, alarmupdatetime_gt)); } if (alarmupdatetime_ge != null) { qc.andCondition( new QueryCondition( HistoryDoorEntity.ALARMUPDATETIME, QueryCondition.ge, alarmupdatetime_ge)); } if (alarmupdatetime_lt != null) { qc.andCondition( new QueryCondition( HistoryDoorEntity.ALARMUPDATETIME, QueryCondition.lt, alarmupdatetime_lt)); } if (alarmupdatetime_le != null) { qc.andCondition( new QueryCondition( HistoryDoorEntity.ALARMUPDATETIME, QueryCondition.le, alarmupdatetime_le)); } if (qc.getQueryNextCondition() != null) { TransactionManager tx = DbUtils.getTranManager(); try { tx.beginTransaction(); // 删除关联信息 if (delDev != null && delDev.booleanValue()) { List<Object> list = dbManager.queryByCondition(HistoryDoorEntity.class, qc); String strIds = ""; if (list != null && list.size() > 0) { for (Object obj : list) { HistoryDoorEntity entity = (HistoryDoorEntity) obj; strIds += entity.getDevId() + ","; } strIds = strIds.substring(0, strIds.length() - 1); } if (strIds != null && !"".equals(strIds)) { QueryCondition qc1 = new QueryCondition(DevEntity.ID, QueryCondition.in, strIds); dbManager.delByConditionsNoTransaction(DevEntity.class, qc1); } } result = dbManager.delByConditionsNoTransaction(HistoryDoorEntity.class, qc); tx.commitAndClose(); } catch (Exception e) { logger.error("数据库提交失败!"); logger.error(e); result = false; try { tx.rollbackAndClose(); } catch (Exception ex) { logger.error("数据库回滚失败!"); logger.error(ex); } } } return result; }
/** * 根据条件查询记录集合(带分页 不带排序 不级联查询) * * @param queryMap 查询条件集合 * @param pageno 查询页码 * @param pagesize 查询每页记录条数 * @return */ public PageList getListByCondition(Map<String, Object> queryMap, int pageno, int pagesize) { PageList pagelist = null; if (queryMap == null) { queryMap = new HashMap<String, Object>(); } Object id = queryMap.get("id"); Object id_gt = queryMap.get("id_gt"); Object id_ge = queryMap.get("id_ge"); Object id_lt = queryMap.get("id_lt"); Object id_le = queryMap.get("id_le"); Object id_in = queryMap.get("id_in"); Object devId = queryMap.get("devId"); Object devId_gt = queryMap.get("devId_gt"); Object devId_ge = queryMap.get("devId_ge"); Object devId_lt = queryMap.get("devId_lt"); Object devId_le = queryMap.get("devId_le"); Object devId_in = queryMap.get("devId_in"); Object openclose = queryMap.get("openclose"); Object openclose_like = queryMap.get("openclose_like"); Object openclose_isNull = queryMap.get("openclose_isNull"); Object openclose_isNotNull = queryMap.get("openclose_isNotNull"); Object openclose_in = queryMap.get("openclose_in"); Object level = queryMap.get("level"); Object level_gt = queryMap.get("level_gt"); Object level_ge = queryMap.get("level_ge"); Object level_lt = queryMap.get("level_lt"); Object level_le = queryMap.get("level_le"); Object level_in = queryMap.get("level_in"); Object alarmupdatetime_gt = queryMap.get("alarmupdatetime_gt"); Object alarmupdatetime_ge = queryMap.get("alarmupdatetime_ge"); Object alarmupdatetime_lt = queryMap.get("alarmupdatetime_lt"); Object alarmupdatetime_le = queryMap.get("alarmupdatetime_le"); QueryCondition qc = new QueryCondition(HistoryDoorEntity.ID, QueryCondition.gt, "0"); if (id != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.ID, QueryCondition.eq, id)); } if (id_gt != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.ID, QueryCondition.gt, id_gt)); } if (id_ge != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.ID, QueryCondition.ge, id_ge)); } if (id_lt != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.ID, QueryCondition.lt, id_lt)); } if (id_le != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.ID, QueryCondition.le, id_le)); } if (id_in != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.ID, QueryCondition.in, id_in)); } if (devId != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.DEV_ID, QueryCondition.eq, devId)); } if (devId_gt != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.DEV_ID, QueryCondition.gt, devId_gt)); } if (devId_ge != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.DEV_ID, QueryCondition.ge, devId_ge)); } if (devId_lt != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.DEV_ID, QueryCondition.lt, devId_lt)); } if (devId_le != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.DEV_ID, QueryCondition.le, devId_le)); } if (devId_in != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.DEV_ID, QueryCondition.in, devId_in)); } if (openclose != null) { qc.andCondition( new QueryCondition(HistoryDoorEntity.OPENCLOSE, QueryCondition.eq, openclose)); } if (openclose_like != null) { qc.andCondition( new QueryCondition(HistoryDoorEntity.OPENCLOSE, QueryCondition.like, openclose_like)); } if (openclose_isNull != null) { qc.andCondition( new QueryCondition(HistoryDoorEntity.OPENCLOSE, QueryCondition.isNull, openclose_isNull)); } if (openclose_isNotNull != null) { qc.andCondition( new QueryCondition( HistoryDoorEntity.OPENCLOSE, QueryCondition.isNotNull, openclose_isNotNull)); } if (openclose_in != null) { qc.andCondition( new QueryCondition(HistoryDoorEntity.OPENCLOSE, QueryCondition.in, openclose_in)); } if (level != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.LEVEL, QueryCondition.eq, level)); } if (level_gt != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.LEVEL, QueryCondition.gt, level_gt)); } if (level_ge != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.LEVEL, QueryCondition.ge, level_ge)); } if (level_lt != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.LEVEL, QueryCondition.lt, level_lt)); } if (level_le != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.LEVEL, QueryCondition.le, level_le)); } if (level_in != null) { qc.andCondition(new QueryCondition(HistoryDoorEntity.LEVEL, QueryCondition.in, level_in)); } if (alarmupdatetime_gt != null) { qc.andCondition( new QueryCondition( HistoryDoorEntity.ALARMUPDATETIME, QueryCondition.gt, alarmupdatetime_gt)); } if (alarmupdatetime_ge != null) { qc.andCondition( new QueryCondition( HistoryDoorEntity.ALARMUPDATETIME, QueryCondition.ge, alarmupdatetime_ge)); } if (alarmupdatetime_lt != null) { qc.andCondition( new QueryCondition( HistoryDoorEntity.ALARMUPDATETIME, QueryCondition.lt, alarmupdatetime_lt)); } if (alarmupdatetime_le != null) { qc.andCondition( new QueryCondition( HistoryDoorEntity.ALARMUPDATETIME, QueryCondition.le, alarmupdatetime_le)); } pagelist = dbManager.queryByCondition(HistoryDoorEntity.class, qc, pageno, pagesize); return pagelist; }