You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

45 lines
1.2 KiB

<?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.ccsens.wisdomcar.persist.dao.WisdomCarDao">
<select id="queryFreeCar" resultType="com.ccsens.wisdomcar.bean.vo.WisdomCarVo$FreeCar">
( SELECT id, car_number FROM t_wisdom_car WHERE hospital_id = #{hospitalId} AND rec_status = 0 ) EXCEPT
(
SELECT
distinct c.id,
c.car_number
FROM
t_patient_wisdom_car pc,
t_wisdom_car c
WHERE
pc.car_id = c.id
AND c.hospital_id = #{hospitalId}
AND pc.end_time = 0
AND pc.start_time >= ( unix_timestamp( ) - 2 * 60 * 60 ) * 1000
AND pc.rec_status = 0
AND c.rec_status = 0
)
</select>
<select id="countUsed" resultType="java.lang.Long">
SELECT
count(*)
FROM
t_patient_wisdom_car
WHERE
car_id = #{carId}
AND
((end_time = 0
AND start_time &gt;= #{startTime} - 2 * 60 * 60 * 1000)
or
<choose>
<when test="endTime == null or endTime = 0">
(start_time &lt;= #{startTime} and end_time &gt;=#{startTime})
</when>
<otherwise>
(start_time &lt;= #{endTime} and end_time &gt;= #{startTime})
</otherwise>
</choose>
)
AND rec_status = 0
</select>
</mapper>