<?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.casic.missiles.mapper.meter.MeterFileMapper">
<select id="selectMaxFileNo" resultType="java.lang.Long">
SELECT IFNULL(max(RIGHT(file_no, 12)), 0) from meter_file
</select>
<update id="updateEffectiveStatusByTime">
UPDATE meter_file
SET effective_status =
CASE
WHEN DATE_FORMAT(NOW(), '%Y-%m-%d') < DATE_FORMAT(effectiveTime, '%Y-%m-%d') THEN 2
WHEN DATE_FORMAT(NOW(), '%Y-%m-%d') >= DATE_FORMAT(effectiveTime, '%Y-%m-%d') THEN 1
ELSE effective_status
END
WHERE effective_status <> 3
</update>
<select id="selectApprovalList" resultType="com.casic.missiles.dto.meter.FileApprovalListResponse">
SELECT id, file_no, file_name, file_code, file_type, publish_time, publisher, effective_time, effective_status,
create_user, minio_file_name, remark, approval_status, create_time
FROM meter_file
WHERE is_del = 0
<if test="request.approvalStatus != null and request.approvalStatus !=''">
and approval_status = #{request.approvalStatus}
</if>
<if test="request.fileNo != null and request.fileNo !=''">
and file_no like concat('%',#{request.fileNo},'%')
</if>
<if test="request.fileName != null and request.fileName !=''">
and file_name like concat('%',#{request.fileName},'%')
</if>
<if test="request.fileCode != null and request.fileCode !=''">
and file_code like concat('%',#{request.fileCode},'%')
</if>
<if test="request.fileType != null and request.fileType !=''">
and file_type = #{request.fileType}
</if>
<if test="request.createUser != null and request.createUser !=''">
and create_user like concat('%',#{request.createUser},'%')
</if>
<if test="request.createTime != null and request.createTime !=''">
and create_time <= #{request.createTime}
</if>
<if test="request.createUserId != null and request.createUserId !=''">
and create_user_id = #{request.createUserId}
</if>
</select>
</mapper>