240 lines
7.7 KiB
XML
Raw Normal View History

2026-03-10 16:40:19 +08:00
<?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._3e.dao.EssayAssignDao">
<insert id="doSave">
INSERT INTO essayassign(
assignmentId, teacherId, essayBaseId, title, wordcount, essayType,
style, demand, picture, description, created, startTime, endTime,status,areaId,assignTime,totalScore,type)
VALUES (
<if test="assignmentId == 0">
(SELECT NEXTVAL('seq_essayassignid')),
</if>
<if test="assignmentId != 0">
#{assignmentId},
</if>
#{teacherId}, #{essayBaseId}, #{title}, #{wordCount},#{essayType},
#{style}, #{demand}, #{picture},#{description}, #{created}, #{startTime}, #{endTime},#{status},#{areaId},#{assignTime},#{totalScore},#{type}
)
</insert>
<insert id="doSaveClassOwnEssay">
INSERT INTO classownessay(
classesId, assignmentId, areaId)
VALUES (
#{classesId}, #{assignmentId}, #{areaId}
)
</insert>
<update id="doSaveUpdate">
UPDATE essayassign
<set>
<if test="teacherId != null">
teacherId = #{teacherId},
</if>
<if test="essayBaseId != null">
essayBaseId = #{essayBaseId},
</if>
<if test="title != null">
title = #{title},
</if>
<if test="wordCount != null">
wordCount = #{wordCount},
</if>
<if test="essayType != null">
essayType = #{essayType},
</if>
<if test="style != null">
style = #{style},
</if>
<if test="demand != null">
demand = #{demand},
</if>
<if test="picture != null">
picture = #{picture},
</if>
<if test="description != null">
description = #{description},
</if>
<if test="created != null">
created = #{created},
</if>
<if test="startTime != null">
startTime = #{startTime},
</if>
<if test="endTime != null">
endTime = #{endTime},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="areaId != null">
areaId = #{areaId},
</if>
<if test="assignTime != null">
assignTime = #{assignTime},
</if>
<if test="totalScore != null">
totalScore = #{totalScore}
</if>
</set>
WHERE assignmentId = #{assignmentId}
</update>
<update id="doUpdateEssayAssign">
UPDATE essayassign
<set>
<if test="teacherId != null">
teacherId = #{teacherId},
</if>
<if test="essayBaseId != null">
essayBaseId = #{essayBaseId},
</if>
<if test="title != null">
title = #{title},
</if>
<if test="wordCount != null">
wordCount = #{wordCount},
</if>
<if test="essayType != null">
essayType = #{essayType},
</if>
<if test="style != null">
style = #{style},
</if>
<if test="demand != null">
demand = #{demand},
</if>
<if test="picture != null">
picture = #{picture},
</if>
<if test="description != null">
description = #{description},
</if>
<if test="created != null">
created = #{created},
</if>
<if test="startTime != null">
startTime = #{startTime},
</if>
<if test="endTime != null">
endTime = #{endTime},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="areaId != null">
areaId = #{areaId},
</if>
<if test="assignTime != null">
assignTime = #{assignTime},
</if>
<if test="totalScore != null">
totalScore = #{totalScore}
</if>
</set>
WHERE assignmentId = #{assignmentId}
</update>
<select id="getNextSeq" resultType="java.lang.Integer">
SELECT NEXTVAL('seq_essayassignid')
</select>
<select id="findAllEssayAssignByClassId" resultType="com._3e.entity.EssayAssign">
SELECT b.assignmentId , b.essayBaseId,b.teacherId , b.title ,b.demand,b.picture, b.description ,
b.created ,b.assignTime,b.totalScore,
b.startTime , b.endTime , b.status , b.areaId,c.className,c.classesId
FROM classownessay a
inner join classes c on a.classesId = c.classesId
INNER JOIN essayassign b ON a.assignmentId = b.assignmentId
and a.classesId = #{classesId} AND b.status = 1 and b.type = 1
<if test="status== '2'.toString()">
and b.endtime &lt; NOW()
</if>
<if test="status== '1'.toString()">
and b.endtime &gt; NOW()
</if>
ORDER BY b.assignmentId desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findAllEssayAssignByClassIds" resultType="com._3e.entity.EssayAssign">
SELECT b.assignmentId , b.essayBaseId,b.teacherId , b.title ,b.demand,b.picture, b.description ,
b.created ,b.assignTime,b.totalScore,
b.startTime , b.endTime , b.status , b.areaId,c.className,c.classesId
FROM classownessay a
inner join classes c on a.classesId = c.classesId
INNER JOIN essayassign b ON a.assignmentId = b.assignmentId
and a.classesId in
<foreach item="classesId" index="index" collection="classesIds"
open="(" separator="," close=")">
#{classesId}
</foreach>
AND b.status = 1 and b.type = 1
<if test="status== '2'.toString()">
and b.endtime &lt; NOW()
</if>
<if test="status== '1'.toString()">
and b.endtime &gt; NOW()
</if>
ORDER BY b.assignmentId desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findEssayAssign" resultType="com._3e.entity.EssayAssign">
SELECT * FROM essayassign WHERE assignmentId =#{assignmentId}
</select>
<select id="findEssayAssignTaskStatusV1" resultType="com._3e.http.essay.dto.ResClassEssayAssignStatus">
WITH temp1 as ( select soc.studentId
from StudentOwnClass soc inner join student s on soc.studentid=s.studentid
<if test="areaId != null and areaId != 0">
and s.areaid = #{areaId}
</if>
and s.status=1
where
<if test="areaId != null and areaId != 0">
soc.areaId = #{areaId}
</if>
and soc.classesId = #{classesId} and soc.status = 1 ),
ranked_answers AS(
SELECT a.studentId ,b.created as lastTime,b.score,b.origiScore,b.humanScore,b.trueScore,b.essayAnswerId,b.isExpire,
ROW_NUMBER() OVER (PARTITION BY a.studentId, b.assignmentId ORDER BY b.score DESC) AS rn
FROM temp1 as a
LEFT JOIN essayanswer as b
ON a.studentId = b.uid
<if test="areaId != null and areaId != 0">
and b.areaId = #{areaId}
</if>
AND b.assignmentId =#{assignmentId})
SELECT
studentId,origiScore AS aiScore,humanScore AS teacherScore,trueScore,lastTime,essayAnswerId,isExpire
FROM ranked_answers
WHERE rn = 1
ORDER BY score DESC NULLS LAST, studentId
</select>
<select id="findClassOwnEssay" resultType="com._3e.entity.ClassOwnEssay">
SELECT * FROM classownessay WHERE assignmentId = #{assignmentId}
</select>
<select id="findEssayAssignById" resultType="com._3e.http.essay.dto.ResEssayAssign">
select e.*, p_style.valuestr as styleName,p_essayType.valueStr as essayTypeName from essayassign e
LEFT JOIN parameter p_style ON p_style.paraId = e.style AND p_style.paraType = 38 AND p_style.paraInt = 2
LEFT JOIN parameter p_essayType ON p_essayType.paraId = e.essayType AND p_essayType.paraType = 38 AND p_essayType.paraInt = 1
where e.assignmentId = #{assignmentId}
</select>
<select id="findEssayBaseModel" resultType="com._3e.entity.EssayBaseModel">
select * from essaybasemodel where assignmentId = #{assignmentId}
</select>
<select id="findEssayAssignToClass" resultType="com._3e.entity.ClassOwnEssay">
select classesid AS classesId,
assignmentid AS assignmentId,
areaid AS areaId
from classownessay where assignmentId = #{assignmentId}
</select>
<select id="findEssayAssignByUidAndClassesList" resultType="com._3e.entity.EssayAssign">
SELECT * FROM essayassign WHERE uid = #{uid} and status = 1 AND classesId IN
<foreach item="classesId" index="index" collection="classesList"
open="(" separator="," close=")">
#{classesId}
</foreach>
order by created desc limit 1;
</select>
</mapper>