From 2826a6833d8df9677805af32265c64a47bb8500b Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 11 八月 2023 16:38:22 +0800
Subject: [PATCH] 1

---
 src/main/resources/mapper/XlsReportMapper.xml              |    2 
 src/main/java/com/yssh/controller/XlsReportController.java |   62 +++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/yssh/controller/XlsReportController.java b/src/main/java/com/yssh/controller/XlsReportController.java
new file mode 100644
index 0000000..0fa95fd
--- /dev/null
+++ b/src/main/java/com/yssh/controller/XlsReportController.java
@@ -0,0 +1,62 @@
+package com.yssh.controller;
+
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.yssh.entity.xls.XlsReport;
+import com.yssh.mapper.XlsReportMapper;
+import com.yssh.service.XlsReportService;
+import com.yssh.utils.DateUtils;
+import com.yssh.utils.Result;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+@Api(tags="Excel鎶ュ憡")
+@RestController
+@RequestMapping("/xlsReport")
+@SuppressWarnings("rawtypes")
+public class XlsReportController {
+    @Resource
+    XlsReportMapper xlsReportMapper;
+
+    @Resource
+    XlsReportService xlsReportService;
+
+    private static List<String> TYPES = new ArrayList<>(Arrays.asList("day", "week", "month"));
+
+    @ApiOperationSupport(order = 1)
+    @GetMapping("/selectByPage")
+    @ApiOperation(value = "鍒嗛〉鏌ヨ", notes = "鍒嗛〉鏌ヨ")
+    public Result selectByPage(@RequestParam(value = "type", required = false) String type,
+                               @RequestParam(value = "start", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date start,
+                               @RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date end,
+                               @RequestParam(value = "pageSize", required = false) Integer pageSize,
+                               @RequestParam(value = "pageIndex", required = false) Integer pageIndex) {
+        if (null == type || !TYPES.contains(type)) return Result.error("绫诲瀷鍙兘涓猴細day锛寃eek锛宮onth銆�");
+
+        if (null != start && null != end && start.getTime() > end.getTime()) {
+            Date tmp = start;
+            start = end;
+            end = tmp;
+        }
+        String strStart = null == start ? null : DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, start);
+        String strEnd = null == end ? null : DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, end);
+
+        pageSize = null == pageSize || pageSize < 1 ? 10 : pageSize;
+        pageIndex = null == pageIndex || pageIndex < 1 ? 1 : pageIndex;
+        Integer offset = pageSize * (pageIndex - 1);
+
+        List<XlsReport> list = xlsReportMapper.selectReportByPage(type, strStart, strEnd, pageSize, offset);
+
+        return Result.OK(list);
+    }
+}
diff --git a/src/main/resources/mapper/XlsReportMapper.xml b/src/main/resources/mapper/XlsReportMapper.xml
index f53c63a..3c5ef3b 100644
--- a/src/main/resources/mapper/XlsReportMapper.xml
+++ b/src/main/resources/mapper/XlsReportMapper.xml
@@ -14,7 +14,7 @@
                 and create_time >= #{start}
             </if>
             <if test="end != null">
-                and end &lt;= #{end}
+                and create_time &lt;= #{end}
             </if>
         </where>
         order by id desc

--
Gitblit v1.9.3