| | |
| | | <result column="update_user" property="updateUser" /> |
| | | <result column="tenant_id" property="tenantId" /> |
| | | </resultMap> |
| | | <sql id="trainingStateExpression"> |
| | | CASE |
| | | WHEN CURRENT_TIMESTAMP() < STR_TO_DATE(CONCAT(training_date, ' ', opening_time), '%Y-%m-%d %H:%i:%s') THEN 0 |
| | | WHEN CURRENT_TIMESTAMP() >= STR_TO_DATE(CONCAT(training_date, ' ', end_time), '%Y-%m-%d %H:%i:%s') THEN 2 |
| | | ELSE 1 |
| | | END |
| | | </sql> |
| | | <update id="refreshTrainingState"> |
| | | UPDATE safe_training |
| | | SET state = <include refid="trainingStateExpression"/> |
| | | WHERE training_date IS NOT NULL |
| | | AND opening_time IS NOT NULL |
| | | AND end_time IS NOT NULL |
| | | AND STR_TO_DATE(CONCAT(training_date, ' ', opening_time), '%Y-%m-%d %H:%i:%s') IS NOT NULL |
| | | AND STR_TO_DATE(CONCAT(training_date, ' ', end_time), '%Y-%m-%d %H:%i:%s') IS NOT NULL |
| | | AND ( |
| | | state IS NULL |
| | | OR state != <include refid="trainingStateExpression"/> |
| | | ) |
| | | </update> |
| | | <select id="pageSafeTraining" resultType="com.ruoyi.safe.dto.SafeTrainingDto"> |
| | | select st.*, |
| | | su.nick_name assessmentUserName, |
| | | count(std.id) nums |
| | | from safe_training st |
| | | left join safe_training_details std on std.safe_training_id = st.id |
| | | left join sys_user su on st.assessment_user_id = su.user_id |
| | | where st.state = #{c.state} |
| | | SELECT |
| | | st.*, |
| | | su.nick_name AS assessmentUserName, |
| | | EXISTS( |
| | | SELECT 1 |
| | | FROM safe_training_details signed_std |
| | | WHERE signed_std.safe_training_id = st.id |
| | | AND signed_std.user_id = #{c.currentUserId} |
| | | ) AS signed, |
| | | ( |
| | | SELECT COUNT(1) |
| | | FROM safe_training_details nums_std |
| | | WHERE nums_std.safe_training_id = st.id |
| | | ) AS nums |
| | | FROM safe_training st |
| | | LEFT JOIN sys_user su ON st.assessment_user_id = su.user_id |
| | | WHERE st.state = #{c.state} |
| | | <if test="c.placeTraining != null and c.placeTraining != ''"> |
| | | and st.place_training like concat('%', #{c.placeTraining}, '%') |
| | | AND st.place_training LIKE CONCAT('%', #{c.placeTraining}, '%') |
| | | </if> |
| | | <if test="c.trainingDate != null "> |
| | | and st.training_date = date_format(#{c.trainingDate},'%Y%m%d') |
| | | AND DATE_FORMAT(st.training_date, '%Y%m%d') = DATE_FORMAT(#{c.trainingDate}, '%Y%m%d') |
| | | </if> |
| | | order BY st.id desc |
| | | </select> |
| | | <select id="getSafeTraining" resultType="com.ruoyi.safe.dto.SafeTrainingDto"> |
| | | select st.*, |