AlarmServiceImpl.java 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package cn.com.lzt.alarm.service.impl;
  2. import cn.com.lzt.alarm.service.AlarmService;
  3. import cn.com.lzt.common.util.StringUtil;
  4. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  5. import com.baomidou.mybatisplus.core.metadata.IPage;
  6. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  7. import com.daju.common.util.DataPage;
  8. import com.daju.mix.dao.entity.TBAlarm;
  9. import com.daju.mix.dao.mapper.TBAlarmMapper;
  10. import com.daju.mix.dao.service.impl.BaseServiceImpl;
  11. import org.apache.commons.lang3.StringUtils;
  12. import org.jeecgframework.core.util.JeecgDataAutorUtils;
  13. import org.springframework.stereotype.Service;
  14. import java.util.Map;
  15. /**
  16. * @author :sahib.kio.m
  17. * @date :Created in 2021/8/3 上午10:37
  18. */
  19. @Service
  20. public class AlarmServiceImpl extends BaseServiceImpl<TBAlarmMapper, TBAlarm> implements AlarmService {
  21. public DataPage alarmList(Map<String, String> param) {
  22. DataPage result = new DataPage();
  23. int page = 1;
  24. if(param.containsKey("page")){
  25. page = Integer.valueOf(param.get("page"));
  26. }
  27. int rows = 999;
  28. if(param.containsKey("rows")){
  29. rows = Integer.valueOf(param.get("rows"));
  30. }
  31. String code = param.get("code");
  32. String context = param.get("context");
  33. String alarmFrom = param.get("alarm.from");
  34. String alarmType = param.get("alarm.type");
  35. String start = param.get("alarm_time_begin1");
  36. String end = param.get("alarm_time_end2");
  37. QueryWrapper<?> queryWrapper = new QueryWrapper<>();
  38. String selectSql = " SELECT TBA.* " +
  39. "FROM T_B_ALARM TBA WHERE 1 = 1\n";
  40. if(!StringUtil.isEmpty(code)){
  41. selectSql += "and TBA.code = '" + code + "'";
  42. }
  43. if(!StringUtil.isEmpty(context)){
  44. selectSql += "and TBA.context LIKE '%" + context + "%'";
  45. }
  46. String MENU_DATA_AUTHOR_RULE_SQL = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  47. if(StringUtils.isNotEmpty(MENU_DATA_AUTHOR_RULE_SQL)){
  48. if(MENU_DATA_AUTHOR_RULE_SQL.contains(",")){
  49. MENU_DATA_AUTHOR_RULE_SQL = MENU_DATA_AUTHOR_RULE_SQL.replaceAll(",","','");
  50. }
  51. selectSql += " " + MENU_DATA_AUTHOR_RULE_SQL + "";
  52. }
  53. if(!StringUtil.isEmpty(alarmFrom)){
  54. selectSql += "and TBA.alarm_From = '" + alarmFrom + "'";
  55. }
  56. if(!StringUtil.isEmpty(alarmType)){
  57. selectSql += "and TBA.alarm_Type = '" + alarmType + "'";
  58. }
  59. if(!StringUtil.isEmpty(start)){
  60. selectSql += "and TBA.alarm_time >= '" + start + "'";
  61. }
  62. if(!StringUtil.isEmpty(end)){
  63. selectSql += "and TBA.alarm_time <= '" + end + "'";
  64. }
  65. selectSql += " order by TBA.alarm_time desc ";
  66. IPage<Map<String, Object>> mapPage = getBaseMapper().queryMapPageBySql(new Page<>(page, rows), queryWrapper, selectSql);
  67. result.setList(mapPage.getRecords());
  68. result.setTotalCount((int) mapPage.getTotal());
  69. return result;
  70. }
  71. }