Reiskuchen 5 年之前
父节点
当前提交
9e6940a1a1

+ 4 - 10
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -25,18 +25,12 @@ public class ReportController {
     private ReportService reportService;
 
     /**
-     * 获取报告列表
-     * pageIndex 分页的页数
-     * pageSize 分页的大小
-     * userId 筛选的用户id 可传
-     * projectId 筛选的项目id 可传
-     * startDate 筛选时间段的开始时间 可传 yyyy-MM-dd
-     * endDate 筛选时间段的结束时间 可传 yyyy-MM-dd
+     * 根据时间 按照人分类 获取报告信息
+     * date 日期 格式yyyy-mm-dd
      */
     @RequestMapping("/getReportList")
-    public HttpRespMsg getReportList(@RequestParam Integer pageIndex, @RequestParam Integer pageSize,
-                                     Integer userId, Integer projectId, String startDate, String endDate) {
-        return reportService.getReportList(pageIndex, pageSize, userId, projectId, startDate, endDate);
+    public HttpRespMsg getReportList(@RequestParam String date) {
+        return reportService.getReportList(date);
     }
 
     /**

+ 3 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Report.java

@@ -1,6 +1,5 @@
 package com.management.platform.entity;
 
-import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import java.time.LocalDate;
@@ -11,7 +10,6 @@ import java.io.Serializable;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import org.springframework.format.annotation.DateTimeFormat;
 
 /**
  * <p>
@@ -19,7 +17,7 @@ import org.springframework.format.annotation.DateTimeFormat;
  * </p>
  *
  * @author 吴涛涛
- * @since 2020-01-03
+ * @since 2020-01-06
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -49,7 +47,6 @@ public class Report extends Model<Report> {
     /**
      * 日期
      */
-    @DateTimeFormat(pattern = "yyyy-MM-dd")
     @TableField("create_date")
     private LocalDate createDate;
 
@@ -57,12 +54,12 @@ public class Report extends Model<Report> {
      * 工作时间
      */
     @TableField("working_time")
-    private Integer workingTime;
+    private Double workingTime;
 
     /**
      * 报告内容
      */
-    @TableField(value = "content", insertStrategy = FieldStrategy.IGNORED)
+    @TableField("content")
     private String content;
 
     /**

+ 7 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportMapper.java

@@ -2,6 +2,11 @@ package com.management.platform.mapper;
 
 import com.management.platform.entity.Report;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.time.LocalDate;
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -12,5 +17,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @since 2019-12-31
  */
 public interface ReportMapper extends BaseMapper<Report> {
-
+    List<Map<String, Object>> getReportByDate(@Param("date")String date, @Param("id")Integer id);
+    List<Map<String, Object>> getReportNameByDate(@Param("date")String date);
 }

+ 1 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java

@@ -13,8 +13,7 @@ import com.management.platform.util.HttpRespMsg;
  * @since 2019-12-31
  */
 public interface ReportService extends IService<Report> {
-    HttpRespMsg getReportList(Integer pageIndex, Integer pageSize, Integer creatorId, Integer projectId,
-                              String startDate, String endDate);
+    HttpRespMsg getReportList(String date);
 
     HttpRespMsg editReport(Report report);
 

+ 10 - 15
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -10,7 +10,12 @@ import com.management.platform.util.HttpRespMsg;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 import javax.annotation.Resource;
 
@@ -30,23 +35,13 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
 
     //获取报告列表
     @Override
-    public HttpRespMsg getReportList(Integer pageIndex, Integer pageSize, Integer creatorId, Integer projectId,
-                                     String startDate, String endDate) {
+    public HttpRespMsg getReportList(String date) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
-        QueryWrapper<Report> queryWrapper = new QueryWrapper<>();
-        if (creatorId != null) {
-            queryWrapper.eq("creator_id", creatorId);
+        List<Map<String, Object>> nameList = reportMapper.getReportNameByDate(date);
+        for (Map<String, Object> map : nameList) {
+            map.put("data", reportMapper.getReportByDate(date, (Integer) map.get("id")));
         }
-        if (projectId != null) {
-            queryWrapper.eq("project_id", projectId);
-        }
-        if (startDate != null && endDate != null) {
-            queryWrapper.between("create_date",
-                    LocalDate.parse(startDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")),
-                    LocalDate.parse(endDate, DateTimeFormatter.ofPattern("yyyy-MM-dd"))
-            );
-        }
-        httpRespMsg.data = reportMapper.selectPage(new Page<>(pageIndex, pageSize), new QueryWrapper<>());
+        httpRespMsg.data = nameList;
         return httpRespMsg;
     }
 

+ 31 - 7
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml

@@ -4,13 +4,13 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.management.platform.entity.Report">
-        <id column="id" property="id" />
-        <result column="creator_id" property="creatorId" />
-        <result column="project_id" property="projectId" />
-        <result column="create_date" property="createDate" />
-        <result column="working_time" property="workingTime" />
-        <result column="content" property="content" />
-        <result column="create_time" property="createTime" />
+        <id column="id" property="id"/>
+        <result column="creator_id" property="creatorId"/>
+        <result column="project_id" property="projectId"/>
+        <result column="create_date" property="createDate"/>
+        <result column="working_time" property="workingTime"/>
+        <result column="content" property="content"/>
+        <result column="create_time" property="createTime"/>
     </resultMap>
 
     <!-- 通用查询结果列 -->
@@ -18,4 +18,28 @@
         id, creator_id, project_id, create_date, working_time, content, create_time
     </sql>
 
+    <!--根据日期获取报告信息-->
+    <select id="getReportByDate" resultType="java.util.Map">
+        SELECT b.project_name AS project, a.working_time AS time, a.content
+        FROM report AS a
+        JOIN project AS b ON a.project_id=b.id
+        WHERE 1=1 AND
+        <if test="date != null and date != ''">
+            a.create_date=#{date}
+        </if>
+        AND a.creator_id=#{id}
+        ORDER BY a.project_id ASC
+    </select>
+
+    <!--根据日期获取报告上传人-->
+    <select id="getReportNameByDate" resultType="java.util.Map">
+        SELECT DISTINCT c.id, c.name
+        FROM report AS a
+        JOIN user AS c ON a.creator_id=c.id
+        WHERE 1=1 AND
+        <if test="date != null and date != ''">
+            a.create_date=#{date}
+        </if>
+    </select>
+
 </mapper>