Explorar el Código

Merge remote-tracking branch 'origin/master'

周箭河 hace 5 años
padre
commit
ff4cd7b67a

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ExtracurricularExercisesMessageDao.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.dal.dao;
 import com.ym.mec.biz.dal.dto.StudentCourseHomeworkCommentDto;
 import com.ym.mec.biz.dal.entity.ExtracurricularExercisesMessage;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -12,4 +13,6 @@ public interface ExtracurricularExercisesMessageDao extends BaseDAO<Long, Extrac
     int countStudentExtraComments(Map<String, Object> params);
     List<StudentCourseHomeworkCommentDto> findStudentExtraComments(Map<String, Object> params);
 
+    List<ExtracurricularExercisesMessage> findReplyTeacherMessages(@Param("replyIds") List<Long> replyIds);
+
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ExtraExerciseStudentsDto.java

@@ -22,10 +22,20 @@ public class ExtraExerciseStudentsDto extends ExtracurricularExercisesReply {
 
     private java.util.Date expireDate;
 
+    private Integer repliedTimely;
+
     private String statusStr;
     private String isRepliedStr;
     private String isViewStr;
 
+    public Integer getRepliedTimely() {
+        return repliedTimely;
+    }
+
+    public void setRepliedTimely(Integer repliedTimely) {
+        this.repliedTimely = repliedTimely;
+    }
+
     public String getStatusStr() {
         return statusStr;
     }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ExtracurricularExercisesReply.java

@@ -41,6 +41,8 @@ public class ExtracurricularExercisesReply {
 	
 	/** 是否回复 */
 	private Integer isReplied;
+
+	private Integer isRepliedTimely;
 	
 	/** 是否已查看 */
 	private Integer isView;
@@ -49,6 +51,14 @@ public class ExtracurricularExercisesReply {
 
 	private Date submitTime;
 
+	public Integer getIsRepliedTimely() {
+		return isRepliedTimely;
+	}
+
+	public void setIsRepliedTimely(Integer isRepliedTimely) {
+		this.isRepliedTimely = isRepliedTimely;
+	}
+
 	public Date getSubmitTime() {
 		return submitTime;
 	}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentCourseHomework.java

@@ -84,9 +84,19 @@ public class StudentCourseHomework {
 	@ApiModelProperty(value = "是否已经回复",required = false)
 	private YesOrNoEnum isReplied;
 
+	private Integer isRepliedTimely;
+
 	@ApiModelProperty(value = "是否已查看")
 	private YesOrNoEnum isView;
 
+	public Integer getIsRepliedTimely() {
+		return isRepliedTimely;
+	}
+
+	public void setIsRepliedTimely(Integer isRepliedTimely) {
+		this.isRepliedTimely = isRepliedTimely;
+	}
+
 	public String getPhone() {
 		return phone;
 	}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/ExtraExercilseReplyQueryInfo.java

@@ -23,6 +23,8 @@ public class ExtraExercilseReplyQueryInfo extends QueryInfo {
 	
 	/** 是否回复 */
 	private Integer isReplied;
+
+	private Integer isRepliedTimely;
 	
 	/** 是否已查看 */
 	private Integer isView;
@@ -37,6 +39,14 @@ public class ExtraExercilseReplyQueryInfo extends QueryInfo {
 
 	private Date expireEndDate;
 
+	public Integer getIsRepliedTimely() {
+		return isRepliedTimely;
+	}
+
+	public void setIsRepliedTimely(Integer isRepliedTimely) {
+		this.isRepliedTimely = isRepliedTimely;
+	}
+
 	public Date getExpireStartDate() {
 		return expireStartDate;
 	}

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseReviewServiceImpl.java

@@ -231,6 +231,7 @@ public class CourseReviewServiceImpl extends BaseServiceImpl<Integer, CourseSche
                         studentCourseHomework.setStatus(YesOrNoEnum.NO);
                         studentCourseHomework.setIsView(YesOrNoEnum.NO);
                         studentCourseHomework.setIsReplied(YesOrNoEnum.NO);
+                        studentCourseHomework.setIsRepliedTimely(0);
                         studentCourseHomeworkDao.insert(studentCourseHomework);
                     }else{
                         studentCourseHomework = studentCourseHomeworkDao.findByStudentAndCourseHomewok(existHomework.getId(), courseScheduleStudentPayment.getUserId());

+ 17 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesMessageServiceImpl.java

@@ -21,6 +21,7 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
+import com.ym.mec.util.date.DateUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -63,9 +64,22 @@ public class ExtracurricularExercisesMessageServiceImpl extends BaseServiceImpl<
 		}
 		ExtracurricularExercises extracurricularExercises = extracurricularExercisesDao.get(extracurricularExercisesReply.getExtracurricularExercisesId());
 		if("TEACHER".equals(extracurricularExercisesMessage.getRole())){
-			if(extracurricularExercisesReply.getIsReplied()==0&&Objects.nonNull(extracurricularExercisesReply.getAttachments())){
-				extracurricularExercisesReply.setIsReplied(1);
-				extracurricularExercisesReplyDao.update(extracurricularExercisesReply);
+			if(Objects.nonNull(extracurricularExercisesReply.getAttachments())){
+				boolean change=false;
+				if(extracurricularExercisesReply.getIsRepliedTimely()!=Integer.valueOf(1)&&Objects.nonNull(extracurricularExercisesReply.getSubmitTime())){
+					int hours = DateUtil.hoursBetween(extracurricularExercisesReply.getSubmitTime(), new Date());
+					if(hours>=0&&hours<=12){
+						extracurricularExercisesReply.setIsRepliedTimely(1);
+						change=true;
+					}
+				}
+				if(extracurricularExercisesReply.getIsReplied()==0){
+					extracurricularExercisesReply.setIsReplied(1);
+					change=true;
+				}
+				if(change){
+					extracurricularExercisesReplyDao.update(extracurricularExercisesReply);
+				}
 			}
 
 			Map<Integer, String> userMap = new HashMap<>();

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesReplyServiceImpl.java

@@ -40,6 +40,8 @@ public class ExtracurricularExercisesReplyServiceImpl extends BaseServiceImpl<Lo
 	@Autowired
 	private ExtracurricularExercisesDao extracurricularExercisesDao;
 	@Autowired
+	private ExtracurricularExercisesMessageDao extracurricularExercisesMessageDao;
+	@Autowired
 	private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
 	@Autowired
 	private StudentExtracurricularExercisesSituationDao studentExtracurricularExercisesSituationDao;
@@ -168,11 +170,32 @@ public class ExtracurricularExercisesReplyServiceImpl extends BaseServiceImpl<Lo
 			pageInfo.setTotal(count);
 			params.put("offset", pageInfo.getOffset());
 			dataList = extracurricularExercisesReplyDao.findExtraExercises(params);
+			List<Long> replyIds = dataList.stream().map(ExtraExerciseStudentsDto::getId).collect(Collectors.toList());
 			List<Integer> teacherIds = dataList.stream().map(ExtraExerciseStudentsDto::getTeacherId).collect(Collectors.toList());
 			List<SimpleUserDto> teachers = teacherDao.findSimpleTeachers(teacherIds);
 			Map<Integer, String> idNameMap = teachers.stream().collect(Collectors.toMap(SimpleUserDto::getUserId, SimpleUserDto::getUserName));
+			List<ExtracurricularExercisesMessage> replyTeacherMessages = extracurricularExercisesMessageDao.findReplyTeacherMessages(replyIds);
+			Map<Long, List<ExtracurricularExercisesMessage>> replyMessagesMap = replyTeacherMessages.stream().collect(Collectors.groupingBy(ExtracurricularExercisesMessage::getExtracurricularExercisesReplyId));
+			if(Objects.isNull(replyMessagesMap)){
+				replyMessagesMap=new HashMap<>();
+			}
 			for (ExtraExerciseStudentsDto extraExerciseStudentsDto : dataList) {
 				extraExerciseStudentsDto.setTeacherName(idNameMap.get(extraExerciseStudentsDto.getTeacherId()));
+				extraExerciseStudentsDto.setRepliedTimely(0);
+				List<ExtracurricularExercisesMessage> replyMessages = replyMessagesMap.get(extraExerciseStudentsDto.getId());
+				if(CollectionUtils.isEmpty(replyMessages)){
+					continue;
+				}
+				for (ExtracurricularExercisesMessage replyMessage : replyMessages) {
+					if(replyMessage.getCreateTime().before(extraExerciseStudentsDto.getSubmitTime())){
+						continue;
+					}
+					int h = DateUtil.hoursBetween(extraExerciseStudentsDto.getSubmitTime(), replyMessage.getCreateTime());
+					if(h<=12){
+						extraExerciseStudentsDto.setRepliedTimely(1);
+					}
+					break;
+				}
 			}
 		}
 		if (count == 0) {

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesServiceImpl.java

@@ -75,6 +75,7 @@ public class ExtracurricularExercisesServiceImpl extends BaseServiceImpl<Long, E
 			studentExtraExercise.setStatus(0);
 			studentExtraExercise.setIsReplied(0);
 			studentExtraExercise.setIsView(0);
+			studentExtraExercise.setIsRepliedTimely(0);
 			extracurricularExercisesReplyDao.insert(studentExtraExercise);
 
 			String notifyUrl = "3?courseScheduleID=" + studentExtraExercise.getId() + "&studentCourseHomeworkId=" + studentExtraExercise.getId() + "&extra=1";

+ 9 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentCourseHomeworkServiceImpl.java

@@ -148,9 +148,17 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
         if (Objects.isNull(byStudentAndCourseHomewok)) {
             throw new BizException("作业记录不存在");
         }
-        if (byStudentAndCourseHomewok.getIsReplied() == YesOrNoEnum.YES) {
+
+        int hours = -1;
+        if(Objects.nonNull(byStudentAndCourseHomewok.getSubmitTime())){
+            hours = DateUtil.hoursBetween(byStudentAndCourseHomewok.getSubmitTime(), new Date());
+        }
+        if (byStudentAndCourseHomewok.getIsReplied() == YesOrNoEnum.YES && byStudentAndCourseHomewok.getIsRepliedTimely() == Integer.valueOf(1)) {
             return true;
         }
+        if(hours>=0&&hours<=12){
+            byStudentAndCourseHomewok.setIsRepliedTimely(1);
+        }
         CourseHomework byTeacherAndCourseHomewok = courseHomeworkDao.findByTeacherAndCourseHomewok(courseHomeworkId, teacherId);
         if (Objects.nonNull(byTeacherAndCourseHomewok)) {
             byStudentAndCourseHomewok.setIsReplied(YesOrNoEnum.YES);

+ 6 - 0
mec-biz/src/main/resources/config/mybatis/ExtracurricularExercisesMessageMapper.xml

@@ -114,4 +114,10 @@
 		ORDER BY eem.id_ DESC
 		<include refid="global.limit"/>
 	</select>
+    <select id="findReplyTeacherMessages" resultMap="ExtracurricularExercisesMessage">
+		SELECT * FROM extracurricular_exercises_message WHERE role_='TEACHER' AND extracurricular_exercises_reply_id_ IN
+		<foreach collection="replyIds" item="replyId" open="(" close=")" separator=",">
+			#{replyId}
+		</foreach>
+	</select>
 </mapper>

+ 11 - 5
mec-biz/src/main/resources/config/mybatis/ExtracurricularExercisesReplyMapper.xml

@@ -18,6 +18,7 @@
 		<result column="remark_" property="remark" />
 		<result column="status_" property="status" />
 		<result column="is_replied_" property="isReplied" />
+		<result column="is_replied_timely_" property="isRepliedTimely" />
 		<result column="is_view_" property="isView" />
 		<result column="organ_name_" property="organName" />
 		<result column="submit_time_" property="submitTime" />
@@ -87,16 +88,15 @@
 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
 		</selectKey>
 		-->
-		INSERT INTO extracurricular_exercises_reply (extracurricular_exercises_id_,user_id_,attachments_,create_time_,update_time_,remark_,status_,is_replied_,is_view_)
-		VALUES(#{extracurricularExercisesId},#{userId},#{attachments},NOW(),NOW(),#{remark},#{status},#{isReplied},#{isView})
+		INSERT INTO extracurricular_exercises_reply (extracurricular_exercises_id_,user_id_,attachments_,create_time_,update_time_,remark_,status_,is_replied_,is_view_,is_replied_timely_)
+		VALUES(#{extracurricularExercisesId},#{userId},#{attachments},NOW(),NOW(),#{remark},#{status},#{isReplied},#{isView},#{isRepliedTimely})
 	</insert>
 
-	<!-- 向数据库增加一条记录 -->
 	<insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		INSERT INTO extracurricular_exercises_reply (extracurricular_exercises_id_,user_id_,attachments_,create_time_,update_time_,remark_,status_,is_replied_,is_view_)
+		INSERT INTO extracurricular_exercises_reply (extracurricular_exercises_id_,user_id_,attachments_,create_time_,update_time_,remark_,status_,is_replied_,is_view_,is_replied_timely_)
 		VALUES
 		<foreach collection="replies" item="reply" separator=",">
-			(#{reply.extracurricularExercisesId},#{reply.userId},#{reply.attachments},NOW(),NOW(),#{reply.remark},#{reply.status},#{reply.isReplied},#{reply.isView})
+			(#{reply.extracurricularExercisesId},#{reply.userId},#{reply.attachments},NOW(),NOW(),#{reply.remark},#{reply.status},#{reply.isReplied},#{reply.isView},#{reply.isRepliedTimely})
 		</foreach>
 	</insert>
 
@@ -122,6 +122,9 @@
 			<if test="isReplied != null">
 			is_replied_ = #{isReplied},
 			</if>
+			<if test="isRepliedTimely != null">
+				is_replied_timely_ = #{isRepliedTimely},
+			</if>
 			<if test="extracurricularExercisesId != null">
 			extracurricular_exercises_id_ = #{extracurricularExercisesId},
 			</if>
@@ -273,6 +276,9 @@
 			<if test="expireStartDate != null and expireEndDate != null">
 				AND DATE_FORMAT(ee.expire_date_,"%Y%m%d") BETWEEN DATE_FORMAT(#{expireStartDate},"%Y%m%d") AND DATE_FORMAT(#{expireEndDate},"%Y%m%d")
 			</if>
+			<if test="isRepliedTimely!=null">
+				AND eer.is_replied_timely_=#{isRepliedTimely}
+			</if>
 		</where>
 	</sql>
 

+ 8 - 4
mec-biz/src/main/resources/config/mybatis/StudentCourseHomeworkMapper.xml

@@ -21,6 +21,7 @@
         <result column="remark_" property="remark"/>
         <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="is_replied_" property="isReplied" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="is_replied_timely_" property="isRepliedTimely" />
         <result column="is_view_" property="isView" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="submit_time_" property="submitTime"/>
     </resultMap>
@@ -66,17 +67,17 @@
         </selectKey>
         -->
         INSERT INTO student_course_homework
-        (user_id_,course_schedule_id_,course_homework_id_,attachments_,score_,create_time_,update_time_,remark_,status_,is_replied_,is_view_)
-        VALUES(#{userId},#{courseScheduleId},#{courseHomeworkId},#{attachments},#{score},now(),now(),#{remark},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
+        (user_id_,course_schedule_id_,course_homework_id_,attachments_,score_,create_time_,update_time_,remark_,status_,is_replied_,is_view_,is_replied_timely_)
+        VALUES(#{userId},#{courseScheduleId},#{courseHomeworkId},#{attachments},#{score},now(),now(),#{remark},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isRepliedTimely})
     </insert>
 
     <insert id="batchInsertStudentCourseHomeworkRecord" parameterType="java.util.List" useGeneratedKeys="true"
             keyColumn="id_">
         INSERT INTO student_course_homework
-        (user_id_,course_schedule_id_,course_homework_id_,attachments_,score_,create_time_,update_time_,remark_,status_,is_replied_,is_view_)
+        (user_id_,course_schedule_id_,course_homework_id_,attachments_,score_,create_time_,update_time_,remark_,status_,is_replied_,is_view_,is_replied_timely_)
         VALUE
         <foreach collection="list" item="homework" separator=",">
-            (#{homework.userId},#{homework.courseScheduleId},#{homework.courseHomeworkId},#{homework.attachments},#{homework.score},now(),now(),#{homework.remark},#{homework.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{homework.isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{homework.isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
+            (#{homework.userId},#{homework.courseScheduleId},#{homework.courseHomeworkId},#{homework.attachments},#{homework.score},now(),now(),#{homework.remark},#{homework.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{homework.isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{homework.isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{homework.isRepliedTimely})
         </foreach>
     </insert>
 
@@ -112,6 +113,9 @@
             <if test="isReplied != null">
                 is_replied_ = #{isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>
+            <if test="isRepliedTimely != null">
+                is_replied_timely_ = #{isRepliedTimely},
+            </if>
             <if test="isView != null">
                 is_view_ = #{isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>