| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- <?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.ktg.iscs.mapper.IsMaterialsLoanMapper">
- <resultMap type="IsMaterialsLoan" id="IsMaterialsLoanResult">
- <result property="materialsLoanId" column="materials_loan_id" />
- <result property="materialsId" column="materials_id" />
- <result property="loanUserId" column="loan_user_id" />
- <result property="loanFromId" column="loan_from_id" />
- <result property="loanTime" column="loan_time" />
- <result property="reminderTime" column="reminder_time" />
- <result property="restitutionUserId" column="restitution_user_id" />
- <result property="restitutionToId" column="restitution_to_id" />
- <result property="restitutionTime" column="restitution_time" />
- <result property="restitutionRequired" column="restitution_required" />
- <result property="remark" column="remark" />
- <result property="delFlag" column="del_flag" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateTime" column="update_time" />
- <result property="updateBy" column="update_by" />
- <result property="actualRestitutionTime" column="actual_restitution_time" />
- <result property="timeoutAlarm" column="timeout_alarm" />
- </resultMap>
- <sql id="selectIsMaterialsLoanVo">
- select materials_loan_id, materials_id, loan_user_id, loan_from_id, loan_time, reminder_time, restitution_user_id,
- restitution_to_id, restitution_time, remark, del_flag, create_by, create_time, update_time, update_by,
- actual_restitution_time, timeout_alarm
- from is_materials_loan
- </sql>
- <select id="selectIsMaterialsLoanList" parameterType="IsMaterialsLoan" resultMap="IsMaterialsLoanResult">
- <include refid="selectIsMaterialsLoanVo"/>
- <where>
- <if test="materialsId != null "> and materials_id = #{materialsId}</if>
- <if test="loanUserId != null "> and loan_user_id = #{loanUserId}</if>
- <if test="loanFromId != null "> and loan_from_id = #{loanFromId}</if>
- <if test="loanTime != null "> and loan_time = #{loanTime}</if>
- <if test="reminderTime != null "> and reminder_time = #{reminderTime}</if>
- <if test="restitutionUserId != null "> and restitution_user_id = #{restitutionUserId}</if>
- <if test="restitutionToId != null "> and restitution_to_id = #{restitutionToId}</if>
- <if test="restitutionTime != null "> and restitution_time = #{restitutionTime}</if>
- </where>
- </select>
- <select id="selectIsMaterialsLoanByMaterialsLoanId" parameterType="Long" resultMap="IsMaterialsLoanResult">
- <include refid="selectIsMaterialsLoanVo"/>
- where materials_loan_id = #{materialsLoanId}
- </select>
- <insert id="insertIsMaterialsLoan" parameterType="IsMaterialsLoan" useGeneratedKeys="true" keyProperty="materialsLoanId">
- insert into is_materials_loan
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="materialsId != null">materials_id,</if>
- <if test="loanUserId != null">loan_user_id,</if>
- <if test="loanFromId != null">loan_from_id,</if>
- <if test="loanTime != null">loan_time,</if>
- <if test="reminderTime != null">reminder_time,</if>
- <if test="restitutionUserId != null">restitution_user_id,</if>
- <if test="restitutionToId != null">restitution_to_id,</if>
- <if test="restitutionTime != null">restitution_time,</if>
- <if test="restitutionRequired != null">restitution_required,</if>
- <if test="remark != null">remark,</if>
- <if test="delFlag != null">del_flag,</if>
- <if test="createBy != null">create_by,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="actualRestitutionTime != null">actual_restitution_time,</if>
- <if test="timeoutAlarm != null">timeout_alarm,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="materialsId != null">#{materialsId},</if>
- <if test="loanUserId != null">#{loanUserId},</if>
- <if test="loanFromId != null">#{loanFromId},</if>
- <if test="loanTime != null">#{loanTime},</if>
- <if test="reminderTime != null">#{reminderTime},</if>
- <if test="restitutionUserId != null">#{restitutionUserId},</if>
- <if test="restitutionToId != null">#{restitutionToId},</if>
- <if test="restitutionTime != null">#{restitutionTime},</if>
- <if test="restitutionRequired != null">#{restitutionRequired},</if>
- <if test="remark != null">#{remark},</if>
- <if test="delFlag != null">#{delFlag},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="actualRestitutionTime != null">#{actualRestitutionTime},</if>
- <if test="timeoutAlarm != null">#{timeoutAlarm},</if>
- </trim>
- </insert>
- <update id="updateIsMaterialsLoan" parameterType="IsMaterialsLoan">
- update is_materials_loan
- <trim prefix="SET" suffixOverrides=",">
- <if test="materialsId != null">materials_id = #{materialsId},</if>
- <if test="loanUserId != null">loan_user_id = #{loanUserId},</if>
- <if test="loanFromId != null">loan_from_id = #{loanFromId},</if>
- <if test="loanTime != null">loan_time = #{loanTime},</if>
- <if test="reminderTime != null">reminder_time = #{reminderTime},</if>
- <if test="restitutionUserId != null">restitution_user_id = #{restitutionUserId},</if>
- <if test="restitutionToId != null">restitution_to_id = #{restitutionToId},</if>
- <if test="restitutionTime != null">restitution_time = #{restitutionTime},</if>
- <if test="restitutionRequired != null">restitution_required = #{restitutionRequired},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="delFlag != null">del_flag = #{delFlag},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="actualRestitutionTime != null">actual_restitution_time = #{actualRestitutionTime},</if>
- <if test="timeoutAlarm != null">timeout_alarm = #{timeoutAlarm},</if>
- </trim>
- where materials_loan_id = #{materialsLoanId}
- </update>
- <delete id="deleteIsMaterialsLoanByMaterialsLoanId" parameterType="Long">
- delete from is_materials_loan where materials_loan_id = #{materialsLoanId}
- </delete>
- <delete id="deleteIsMaterialsLoanByMaterialsLoanIds" parameterType="String">
- delete from is_materials_loan where materials_loan_id in
- <foreach item="materialsLoanId" collection="array" open="(" separator="," close=")">
- #{materialsLoanId}
- </foreach>
- </delete>
- <select id="getIsMaterialsLoanPage" resultType="com.ktg.iscs.domain.vo.materialsLoan.MaterialsLoanPageVO">
- SELECT
- l.*,
- m.materials_code,
- m.materials_name,
- c1.cabinet_name as loan_from_name,
- c2.cabinet_name as restitution_to_name,
- u.user_name as loan_user_name,
- u1.user_name as restitution_user_name,
- m.materials_type_id,
- mt.materials_type_name,
- mt.materials_type_icon,
- mt.materials_type_picture,
- CASE
- WHEN l.actual_restitution_time IS NOT NULL THEN
- CONCAT(
- FLOOR( DATEDIFF( SECOND, l.loan_time, l.actual_restitution_time ) / 3600 ),
- '小时 ',
- FLOOR( DATEDIFF( SECOND, l.loan_time, l.actual_restitution_time ) / 60 ) % 60,
- '分 ',
- DATEDIFF( SECOND, l.loan_time, l.actual_restitution_time ) % 60,
- '秒'
- ) ELSE null
- END AS loan_duration
- FROM
- is_materials_loan l
- LEFT JOIN is_materials m ON m.materials_id = l.materials_id
- LEFT JOIN is_materials_cabinet c1 ON c1.cabinet_id = l.loan_from_id
- LEFT JOIN is_materials_cabinet c2 ON c2.cabinet_id = l.restitution_to_id
- LEFT JOIN sys_user u ON u.user_id = l.loan_user_id
- LEFT JOIN sys_user u1 ON u1.user_id = l.restitution_user_id
- LEFT JOIN is_materials_type mt ON mt.materials_type_id = m.materials_type_id
- <where>
- <if test="dto.materialsName != null and dto.materialsName.trim != ''">
- and m.materials_name like concat('%',#{dto.materialsName},'%')
- </if>
- <if test="dto.restitutionRequired != null">
- and l.restitution_required = #{dto.restitutionRequired}
- </if>
- <if test="dto.loanFromId != null">
- and l.loan_from_id = #{dto.loanFromId}
- </if>
- <if test="dto.restitutionToId != null">
- and l.restitution_to_id = #{dto.restitutionToId}
- </if>
- <if test="dto.materialsTypeId != null">
- and m.materials_type_id = #{dto.materialsTypeId}
- </if>
- <if test="dto.loanUserName != null and dto.loanUserName.trim != ''">
- and u.user_name like concat('%',#{dto.loanUserName},'%')
- </if>
- <if test="dto.loanTimeStart != null and dto.loanTimeStart.trim != ''">
- and l.loan_time >= #{dto.loanTimeStart}
- </if>
- <if test="dto.loanTimeEnd != null and dto.loanTimeEnd.trim != ''">
- and l.loan_time <= #{dto.loanTimeEnd}
- </if>
- <if test="dto.restitutionUserName != null and dto.restitutionUserName.trim != ''">
- and u1.user_name like concat('%',#{dto.restitutionUserName},'%')
- </if>
- <if test="dto.restitutionTimeStart != null and dto.restitutionTimeStart.trim != ''">
- and l.actual_restitution_time >= #{dto.restitutionTimeStart}
- </if>
- <if test="dto.restitutionTimeEnd != null and dto.restitutionTimeEnd.trim != ''">
- and l.actual_restitution_time <= #{dto.restitutionTimeEnd}
- </if>
- <if test="dto.status != null and dto.status.trim != ''">
- and l.status = #{dto.status}
- </if>
- </where>
- ORDER BY l.materials_loan_id DESC
- </select>
- <select id="getReturnReminderPage" resultType="com.ktg.iscs.domain.vo.materialsLoan.ReminderPageVO">
- SELECT
- l.*,
- m.materials_code,
- m.materials_name,
- c1.cabinet_name as loan_from_name,
- c2.cabinet_name as restitution_to_name,
- u.user_name as loan_user_name
- FROM
- is_materials_loan l
- LEFT JOIN is_materials m ON m.materials_id = l.materials_id
- LEFT JOIN is_materials_cabinet c1 ON c1.cabinet_id = l.loan_from_id
- LEFT JOIN is_materials_cabinet c2 ON c2.cabinet_id = l.restitution_to_id
- LEFT JOIN sys_user u ON u.user_id = l.loan_user_id
- <where>
- l.reminder_time < NOW()
- and NOW() < l.timeout_alarm
- and actual_restitution_time is null
- <if test="dto.materialsCode != null and dto.materialsCode.trim != ''">
- and m.materials_code like concat('%',#{dto.materialsCode},'%')
- </if>
- <if test="dto.materialsName != null and dto.materialsName.trim != ''">
- and m.materials_name like concat('%',#{dto.materialsName},'%')
- </if>
- <if test="dto.loanUserName != null and dto.loanUserName.trim != ''">
- and u.user_name like concat('%',#{dto.loanUserName},'%')
- </if>
- <if test="dto.loanFromId != null">
- and l.loan_from_id = #{dto.loanFromId}
- </if>
- <if test="dto.loanFromName != null and dto.loanFromName.trim != ''">
- and c1.cabinet_name like concat('%',#{dto.loanFromName},'%')
- </if>
- <if test="dto.startTime != null and dto.startTime.trim != ''">
- and l.loan_time >= #{dto.startTime}
- </if>
- <if test="dto.endTime != null and dto.endTime.trim != ''">
- and l.loan_time <= #{dto.endTime}
- </if>
- </where>
- ORDER BY l.materials_loan_id DESC
- </select>
- <select id="getExpiredReminderPage" resultType="com.ktg.iscs.domain.vo.materialsLoan.ReminderPageVO">
- SELECT
- l.*,
- m.materials_code,
- m.materials_name,
- c1.cabinet_name as loan_from_name,
- c2.cabinet_name as restitution_to_name,
- u.user_name as loan_user_name
- FROM
- is_materials_loan l
- LEFT JOIN is_materials m ON m.materials_id = l.materials_id
- LEFT JOIN is_materials_cabinet c1 ON c1.cabinet_id = l.loan_from_id
- LEFT JOIN is_materials_cabinet c2 ON c2.cabinet_id = l.restitution_to_id
- LEFT JOIN sys_user u ON u.user_id = l.loan_user_id
- <where>
- l.timeout_alarm < NOW()
- and actual_restitution_time is null
- <if test="dto.materialsCode != null and dto.materialsCode.trim != ''">
- and m.materials_code like concat('%',#{dto.materialsCode},'%')
- </if>
- <if test="dto.materialsName != null and dto.materialsName.trim != ''">
- and m.materials_name like concat('%',#{dto.materialsName},'%')
- </if>
- <if test="dto.loanUserName != null and dto.loanUserName.trim != ''">
- and u.user_name like concat('%',#{dto.loanUserName},'%')
- </if>
- <if test="dto.loanFromId != null">
- and l.loan_from_id = #{dto.loanFromId}
- </if>
- <if test="dto.loanFromName != null and dto.loanFromName.trim != ''">
- and c1.cabinet_name like concat('%',#{dto.loanFromName},'%')
- </if>
- <if test="dto.startTime != null and dto.startTime.trim != ''">
- and l.timeout_alarm >= #{dto.startTime}
- </if>
- <if test="dto.endTime != null and dto.endTime.trim != ''">
- and l.timeout_alarm <= #{dto.endTime}
- </if>
- </where>
- ORDER BY l.materials_loan_id DESC
- </select>
- <select id="getLastLoanRecord" resultType="java.lang.Long">
- SELECT
- max(materials_loan_id)
- FROM
- is_materials_loan ml
- WHERE
- ml.materials_id IN
- <foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- AND ml.status != 1
- GROUP BY ml.materials_id
- </select>
- </mapper>
|