Joburgess 4 лет назад
Родитель
Сommit
b27ce1c52d

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/IndexBaseMonthDataDao.java

@@ -0,0 +1,9 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.IndexBaseMonthData;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface IndexBaseMonthDataDao extends BaseDAO<Long, IndexBaseMonthData> {
+
+	
+}

+ 5 - 5
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/IndexDao.java

@@ -1,6 +1,6 @@
 package com.ym.mec.biz.dal.dao;
 
-import com.ym.mec.biz.dal.dto.IndexBaseMonthDto;
+import com.ym.mec.biz.dal.entity.IndexBaseMonthData;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -21,9 +21,9 @@ public interface IndexDao {
      * @param endMonth:
      * @return java.util.List<com.ym.mec.biz.dal.dto.IndexBaseMonthDto>
      */
-    List<IndexBaseMonthDto> getStudentSignUpData(@Param("organIds") Set<Integer> organIds,
-                                                 @Param("startMonth") String startMonth,
-                                                 @Param("endMonth") String endMonth);
+    List<IndexBaseMonthData> getStudentSignUpData(@Param("organIds") Set<Integer> organIds,
+                                                  @Param("startMonth") String startMonth,
+                                                  @Param("endMonth") String endMonth);
 
     /**
      * @describe 统计作业布置数据
@@ -34,7 +34,7 @@ public interface IndexDao {
      * @param endMonth:
      * @return java.util.List<com.ym.mec.biz.dal.dto.IndexBaseMonthDto>
      */
-    List<IndexBaseMonthDto> getHomeworkDate(@Param("organIds") Set<Integer> organIds,
+    List<IndexBaseMonthData> getHomeworkDate(@Param("organIds") Set<Integer> organIds,
                                                   @Param("startMonth") String startMonth,
                                                   @Param("endMonth") String endMonth,
                                                   @Param("type") String type);

+ 7 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/IndexBaseDto.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.dto;
 
+import com.ym.mec.biz.dal.entity.IndexBaseMonthData;
 import com.ym.mec.common.constant.CommonConstants;
 import org.springframework.util.CollectionUtils;
 
@@ -16,7 +17,7 @@ public class IndexBaseDto {
 
     private BigDecimal percent;
 
-    private List<IndexBaseMonthDto> indexMonthData;
+    private List<IndexBaseMonthData> indexMonthData;
 
     public IndexBaseDto() {
     }
@@ -25,7 +26,7 @@ public class IndexBaseDto {
         this.title = title;
     }
 
-    public IndexBaseDto(String title, BigDecimal percent, List<IndexBaseMonthDto> indexMonthData) {
+    public IndexBaseDto(String title, BigDecimal percent, List<IndexBaseMonthData> indexMonthData) {
         this.title = title;
         this.percent = percent;
         this.indexMonthData = indexMonthData;
@@ -47,15 +48,15 @@ public class IndexBaseDto {
         this.percent = percent;
     }
 
-    public List<IndexBaseMonthDto> getIndexMonthData() {
+    public List<IndexBaseMonthData> getIndexMonthData() {
         return indexMonthData;
     }
 
-    public void setIndexMonthData(List<IndexBaseMonthDto> indexMonthData) {
+    public void setIndexMonthData(List<IndexBaseMonthData> indexMonthData) {
         this.indexMonthData = indexMonthData;
         if(!CollectionUtils.isEmpty(indexMonthData)){
-            BigDecimal total = indexMonthData.stream().map(IndexBaseMonthDto::getTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
-            BigDecimal activateNum = indexMonthData.stream().map(IndexBaseMonthDto::getActivateNum).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal total = indexMonthData.stream().map(IndexBaseMonthData::getTotalNum).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal activateNum = indexMonthData.stream().map(IndexBaseMonthData::getActivateNum).reduce(BigDecimal.ZERO, BigDecimal::add);
             this.percent = activateNum.divide(total, CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
         }
     }

+ 0 - 55
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/IndexBaseMonthDto.java

@@ -1,55 +0,0 @@
-package com.ym.mec.biz.dal.dto;
-
-import io.swagger.annotations.ApiModelProperty;
-
-import java.math.BigDecimal;
-
-/**
- * @Author Joburgess
- * @Date 2021/1/7 0007
- */
-public class IndexBaseMonthDto {
-
-    private String title;
-
-    //总数
-    private BigDecimal total;
-
-    //有效数量
-    private BigDecimal activateNum;
-
-    //最终结果
-    private BigDecimal percent;
-
-    public String getTitle() {
-        return title;
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-
-    public BigDecimal getTotal() {
-        return total;
-    }
-
-    public void setTotal(BigDecimal total) {
-        this.total = total;
-    }
-
-    public BigDecimal getActivateNum() {
-        return activateNum;
-    }
-
-    public void setActivateNum(BigDecimal activateNum) {
-        this.activateNum = activateNum;
-    }
-
-    public BigDecimal getPercent() {
-        return percent;
-    }
-
-    public void setPercent(BigDecimal percent) {
-        this.percent = percent;
-    }
-}

+ 98 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/IndexBaseMonthData.java

@@ -0,0 +1,98 @@
+package com.ym.mec.biz.dal.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 对应数据库表(index_base_month_data):
+ */
+public class IndexBaseMonthData {
+
+	/**  */
+	private Long id;
+	
+	/**  */
+	private java.util.Date month;
+	
+	/** 分部编号 */
+	private Integer organId;
+	
+	/** 总数量 */
+	private BigDecimal totalNum;
+	
+	/** 有效数量 */
+	private BigDecimal activateNum;
+	
+	/** 最终结果 */
+	private BigDecimal percent;
+
+	private Date createTime;
+
+	private Date updateTime;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Date getMonth() {
+		return month;
+	}
+
+	public void setMonth(Date month) {
+		this.month = month;
+	}
+
+	public Integer getOrganId() {
+		return organId;
+	}
+
+	public void setOrganId(Integer organId) {
+		this.organId = organId;
+	}
+
+	public BigDecimal getTotalNum() {
+		return totalNum;
+	}
+
+	public void setTotalNum(BigDecimal totalNum) {
+		this.totalNum = totalNum;
+	}
+
+	public BigDecimal getActivateNum() {
+		return activateNum;
+	}
+
+	public void setActivateNum(BigDecimal activateNum) {
+		this.activateNum = activateNum;
+	}
+
+	public BigDecimal getPercent() {
+		return percent;
+	}
+
+	public void setPercent(BigDecimal percent) {
+		this.percent = percent;
+	}
+
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+}

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/IndexBaseMonthDataService.java

@@ -0,0 +1,9 @@
+package com.ym.mec.biz.service;
+
+import java.util.List;
+import com.ym.mec.biz.dal.entity.IndexBaseMonthData;
+import com.ym.mec.common.service.BaseService;
+
+public interface IndexBaseMonthDataService extends BaseService<Long, IndexBaseMonthData> {
+
+}

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -0,0 +1,22 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.ym.mec.biz.dal.entity.IndexBaseMonthData;
+import com.ym.mec.biz.service.IndexBaseMonthDataService;
+import com.ym.mec.biz.dal.dao.IndexBaseMonthDataDao;
+import org.springframework.stereotype.Service;
+
+@Service
+public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBaseMonthData> implements IndexBaseMonthDataService {
+	
+	@Autowired
+	private IndexBaseMonthDataDao indexBaseMonthDataDao;
+
+	@Override
+	public BaseDAO<Long, IndexBaseMonthData> getDAO() {
+		return indexBaseMonthDataDao;
+	}
+	
+}

+ 0 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexServiceImpl.java

@@ -1,16 +1,12 @@
 package com.ym.mec.biz.service.impl;
 
-import com.sun.org.apache.xerces.internal.xs.StringList;
 import com.ym.mec.biz.dal.dao.IndexDao;
 import com.ym.mec.biz.dal.dto.IndexBaseDto;
-import com.ym.mec.biz.dal.dto.IndexBaseMonthDto;
 import com.ym.mec.biz.service.IndexService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
 
-import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;

+ 80 - 0
mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml

@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.ym.mec.biz.dal.dao.IndexBaseMonthDataDao">
+
+	<resultMap type="com.ym.mec.biz.dal.entity.IndexBaseMonthData" id="IndexBaseMonthData">
+		<result column="id_" property="id" />
+		<result column="month_" property="month" />
+		<result column="organ_id_" property="organId" />
+		<result column="total_num_" property="totalNum" />
+		<result column="activate_num_" property="activateNum" />
+		<result column="percent_" property="percent" />
+		<result column="create_time_" property="createTime" />
+		<result column="update_time_" property="updateTime" />
+	</resultMap>
+
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="IndexBaseMonthData" >
+		SELECT * FROM index_base_month_data WHERE id_ = #{id}
+	</select>
+
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="IndexBaseMonthData">
+		SELECT * FROM index_base_month_data ORDER BY id_
+	</select>
+
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		<!--
+		<selectKey resultClass="int" keyProperty="id" > 
+		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
+		</selectKey>
+		-->
+		INSERT INTO index_base_month_data (id_,month_,organ_id_,total_num_,activate_num_,percent_,create_time_,update_time_)
+		VALUES(#{id},#{month},#{organId},#{totalNum},#{activateNum},#{percent},NOW(),NOW())
+	</insert>
+
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData">
+		UPDATE index_base_month_data <set>
+		<if test="organId != null">
+			organ_id_ = #{organId},
+		</if>
+		<if test="id != null">
+			id_ = #{id},
+		</if>
+		<if test="activateNum != null">
+			activate_num_ = #{activateNum},
+		</if>
+		<if test="totalNum != null">
+			total_num_ = #{totalNum},
+		</if>
+		<if test="percent != null">
+			percent_ = #{percent},
+		</if>
+		<if test="month != null">
+			month_ = #{month},
+		</if>
+		update_time_ = NOW()
+	</set> WHERE id_ = #{id}
+	</update>
+
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete" >
+		DELETE FROM index_base_month_data WHERE id_ = #{id}
+	</delete>
+
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="IndexBaseMonthData" parameterType="map">
+		SELECT * FROM index_base_month_data ORDER BY id_ <include refid="global.limit"/>
+	</select>
+
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM index_base_month_data
+	</select>
+</mapper>

+ 12 - 14
mec-biz/src/main/resources/config/mybatis/IndexMapper.xml

@@ -6,10 +6,10 @@
 -->
 <mapper namespace="com.ym.mec.biz.dal.dao.IndexDao">
 
-    <select id="getStudentSignUpData" resultType="com.ym.mec.biz.dal.dto.IndexBaseMonthDto">
+    <select id="getStudentSignUpData" resultType="com.ym.mec.biz.dal.entity.IndexBaseMonthData">
         SELECT
-            DATE_FORMAT( create_time_, '%Y-%m' ) title,
-            COUNT( id_ ) total,
+            DATE_FORMAT( create_time_, '%Y-%m' ) month,
+            COUNT( id_ ) totalNum,
             COUNT(CASE WHEN password_ IS NOT NULL THEN id_ ELSE NULL END) activateNum,
             TRUNCATE(COUNT(CASE WHEN password_ IS NOT NULL THEN id_ ELSE NULL END)/COUNT( id_ )*100, 2) percent
         FROM
@@ -29,28 +29,26 @@
             <if test="endMonth!=null and endMonth!=''">
                 AND DATE_FORMAT(create_time_, '%Y-%m')&lt;=#{endMonth}
             </if>
-        GROUP BY
-            title
-        ORDER BY
-            title;
+        GROUP BY month
+        ORDER BY month;
     </select>
 
-    <select id="getHomeworkDate" resultType="com.ym.mec.biz.dal.dto.IndexBaseMonthDto">
+    <select id="getHomeworkDate" resultType="com.ym.mec.biz.dal.entity.IndexBaseMonthData">
         SELECT
-            DATE_FORMAT(sees.monday_, '%Y-%m') title,
+            DATE_FORMAT(sees.monday_, '%Y-%m') month,
             <choose>
                 <when test="type == 'submit'">
-                    SUM(sees.expect_exercises_num_) total,
+                    SUM(sees.expect_exercises_num_) totalNum,
                     SUM(sees.exercises_reply_num_) activateNum,
                     TRUNCATE(SUM(sees.exercises_reply_num_)/SUM(sees.expect_exercises_num_)*100, 2) percent
                 </when>
                 <when test="type == 'comment'">
-                    SUM(sees.expect_exercises_num_) total,
+                    SUM(sees.expect_exercises_num_) totalNum,
                     SUM(sees.exercises_reply_num_) activateNum,
                     TRUNCATE(SUM(sees.exercises_reply_num_)/SUM(sees.expect_exercises_num_)*100, 2) percent
                 </when>
                 <otherwise>
-                    SUM(sees.expect_exercises_num_) total,
+                    SUM(sees.expect_exercises_num_) totalNum,
                     SUM(sees.actual_exercises_num_) activateNum,
                     TRUNCATE(SUM(sees.actual_exercises_num_)/SUM(sees.expect_exercises_num_)*100, 2) percent
                 </otherwise>
@@ -70,8 +68,8 @@
             <if test="endMonth!=null and endMonth!=''">
                 AND DATE_FORMAT(sees.monday_, '%Y-%m')&lt;=#{endMonth}
             </if>
-        GROUP BY title
-        ORDER BY title
+        GROUP BY month
+        ORDER BY month
     </select>
 
 </mapper>