AnalysisLogController.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package com.jiayue.biz.controller;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.jiayue.common.annotation.Log;
  6. import com.jiayue.common.core.controller.BaseController;
  7. import com.jiayue.common.core.domain.AjaxResult;
  8. import com.jiayue.common.enums.BusinessType;
  9. import com.jiayue.common.utils.poi.ExcelUtil;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.security.access.prepost.PreAuthorize;
  12. import org.springframework.web.bind.annotation.DeleteMapping;
  13. import org.springframework.web.bind.annotation.GetMapping;
  14. import org.springframework.web.bind.annotation.PathVariable;
  15. import org.springframework.web.bind.annotation.PostMapping;
  16. import org.springframework.web.bind.annotation.PutMapping;
  17. import org.springframework.web.bind.annotation.RequestBody;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.bind.annotation.RestController;
  20. import java.util.Arrays;
  21. import java.util.List;
  22. import javax.servlet.http.HttpServletResponse;
  23. import cn.hutool.core.util.ObjectUtil;
  24. import cn.hutool.core.util.StrUtil;
  25. import lombok.RequiredArgsConstructor;
  26. import com.jiayue.biz.domain.AnalysisLog;
  27. import com.jiayue.biz.service.IAnalysisLogService;
  28. import com.jiayue.common.core.page.TableDataInfo;
  29. /**
  30. * 【邮件解析日志】Controller
  31. *
  32. * @author L.ym
  33. * @date 2022-05-23
  34. */
  35. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  36. @RestController
  37. @RequestMapping("/dataQuery/log")
  38. public class AnalysisLogController extends BaseController {
  39. private final IAnalysisLogService iAnalysisLogService;
  40. /**
  41. * 查询邮件解析日志列表
  42. */
  43. @PreAuthorize("@ss.hasPermi('client:log:list')")
  44. @GetMapping("/list")
  45. public TableDataInfo list(AnalysisLog analysisLog) {
  46. startPage();
  47. LambdaQueryWrapper<AnalysisLog> queryWrapper = this.buildQueryParams(analysisLog);
  48. List<AnalysisLog> list = iAnalysisLogService.list(queryWrapper);
  49. return getDataTable(list);
  50. }
  51. /**
  52. * 查询邮件解析日志列表
  53. */
  54. @GetMapping("/dayLog")
  55. public TableDataInfo getDaylist() {
  56. return getDataTable(iAnalysisLogService.getAllList());
  57. }
  58. /**
  59. * 导出邮件解析日志列表
  60. */
  61. @PreAuthorize("@ss.hasPermi('client:log:export')")
  62. @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
  63. @PostMapping("/export")
  64. public void export(HttpServletResponse response, AnalysisLog analysisLog) {
  65. LambdaQueryWrapper<AnalysisLog> queryWrapper = this.buildQueryParams(analysisLog);
  66. List<AnalysisLog> list = iAnalysisLogService.list(queryWrapper);
  67. ExcelUtil<AnalysisLog> util = new ExcelUtil<>(AnalysisLog. class);
  68. util.exportExcel(response, list, "【请填写功能名称】数据");
  69. }
  70. /**
  71. * 获取邮件解析日志详细信息
  72. */
  73. @PreAuthorize("@ss.hasPermi('client:log:query')")
  74. @GetMapping(value = "/{id}")
  75. public AjaxResult getInfo(@PathVariable("id") String id) {
  76. return AjaxResult.success(iAnalysisLogService.getById(id));
  77. }
  78. /**
  79. * 新增邮件解析日志
  80. */
  81. @PreAuthorize("@ss.hasPermi('client:log:add')")
  82. @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
  83. @PostMapping
  84. public AjaxResult add(@RequestBody AnalysisLog analysisLog) {
  85. return toAjax(iAnalysisLogService.save(analysisLog) ? 1 : 0);
  86. }
  87. /**
  88. * 修改邮件解析日志
  89. */
  90. @PreAuthorize("@ss.hasPermi('client:log:edit')")
  91. @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
  92. @PutMapping
  93. public AjaxResult edit(@RequestBody AnalysisLog analysisLog) {
  94. return toAjax(iAnalysisLogService.updateById(analysisLog) ? 1 : 0);
  95. }
  96. /**
  97. * 删除邮件解析日志
  98. */
  99. @PreAuthorize("@ss.hasPermi('client:log:remove')")
  100. @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
  101. @DeleteMapping("/{ids}")
  102. public AjaxResult remove(@PathVariable String[]ids) {
  103. return toAjax(iAnalysisLogService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
  104. }
  105. /**
  106. * 根据时间邮件解析日志
  107. */
  108. @GetMapping("/findByTime")
  109. public Page findByTime(Integer current, Integer size , Long startTime, Long endTime, String equipmentId) {
  110. return iAnalysisLogService.findByTime(current, size, startTime, endTime, equipmentId);
  111. }
  112. /**
  113. * 构建查询条件
  114. **/
  115. private LambdaQueryWrapper<AnalysisLog> buildQueryParams(AnalysisLog analysisLog) {
  116. LambdaQueryWrapper<AnalysisLog> queryWrapper = Wrappers.lambdaQuery();
  117. if (StrUtil.isNotBlank(analysisLog.getEquipmentId())) {
  118. queryWrapper.eq(AnalysisLog::getEquipmentId ,analysisLog.getEquipmentId());
  119. }
  120. if (ObjectUtil.isNotNull(analysisLog.getStatus())) {
  121. queryWrapper.eq(AnalysisLog::getStatus ,analysisLog.getStatus());
  122. }
  123. if (ObjectUtil.isNotNull(analysisLog.getTime())) {
  124. queryWrapper.eq(AnalysisLog::getTime ,analysisLog.getTime());
  125. }
  126. return queryWrapper;
  127. }
  128. }