<?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.sinata.system.mapper.MwCheckoutRecordMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.sinata.system.domain.MwCheckoutRecord">
|
<id column="ID" property="id" />
|
<result column="DEL_FLAG" property="delFlag" />
|
<result column="CREATE_BY" property="createBy" />
|
<result column="CREATE_TIME" property="createTime" />
|
<result column="UPDATE_BY" property="updateBy" />
|
<result column="UPDATE_TIME" property="updateTime" />
|
<result column="CHECKOUT_TIME" property="checkoutTime" />
|
<result column="DEPARTMENT_ID" property="departmentId" />
|
<result column="HOSPITAL_NAME" property="hospitalName" />
|
<result column="STAGING_ROOM_ID" property="stagingRoomId" />
|
<result column="HOSPITAL_SIGNATURE" property="hospitalSignature" />
|
<result column="DRIVER_ID" property="driverId" />
|
<result column="CAR_ID" property="carId" />
|
</resultMap>
|
<resultMap id="TransformVOMap" type="com.sinata.system.domain.vo.TransformVO">
|
<id column="ID" property="id"/>
|
<result column="CHECKOUT_TIME" property="checkoutTime"/>
|
<result column="HOSPITAL_NAME" property="hospitalName"/>
|
<result column="DEPARTMENT_ID" property="departmentId"/>
|
<result column="HOSPITAL_SIGNATURE" property="hospitalSignature"/>
|
<result column="driverName" property="driverName"/>
|
<collection property="collectRecordList" javaType="java.util.List"
|
ofType="com.sinata.system.domain.vo.MwMedicalWasteBoxVO">
|
<result column="WASTE_TYPE_STR" property="wasteTypeStr"/>
|
<result column="WASTE_TYPE" property="wasteType"/>
|
<result column="bagNum" property="bagNum"/>
|
<result column="totalWeight" property="totalWeight"/>
|
</collection>
|
</resultMap>
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
DEL_FLAG,
|
CREATE_BY,
|
CREATE_TIME,
|
UPDATE_BY,
|
UPDATE_TIME,
|
ID, CHECKOUT_TIME, DEPARTMENT_ID, HOSPITAL_NAME, STAGING_ROOM_ID, HOSPITAL_SIGNATURE, DRIVER_ID, CAR_ID
|
</sql>
|
<select id="pageHospitalTransitList" resultType="com.sinata.system.domain.vo.MwCheckoutRecordVO">
|
SELECT mcr.ID,
|
mcr.CHECKOUT_TIME,
|
mcr.HOSPITAL_NAME,
|
SUM(mcr.BOX_NUM) AS boxNum,
|
SUM(mcr.BAG_NUM) AS bagNum,
|
SUM(mcr.TOTAL_WEIGHT) AS totalWeight,
|
su.NICK_NAME AS driverName,
|
mtc.LICENSE_PLATE_NUMBER
|
FROM MW_CHECKOUT_RECORD mcr
|
LEFT JOIN SYS_USER su
|
ON mcr.DRIVER_ID = su.USER_ID
|
LEFT JOIN MW_TRANSIT_CAR mtc
|
ON mcr.CAR_ID = mtc.ID
|
LEFT JOIN SYS_DEPARTMENT sd
|
ON mcr.DEPARTMENT_ID = sd.ID
|
<where>
|
mcr.DEL_FLAG = 0
|
<if test="treeCode != null and treeCode != ''">
|
AND sd.TREE_CODE LIKE CONCAT(#{treeCode},'%')
|
</if>
|
<if test="query.checkoutTimeStart != null and query.checkoutTimeEnd!=null">
|
AND mcr.CHECKOUT_TIME BETWEEN #{query.checkoutTimeStart} AND #{query.checkoutTimeEnd}
|
</if>
|
</where>
|
GROUP BY mcr.DEPARTMENT_ID
|
ORDER BY mcr.CHECKOUT_TIME DESC
|
</select>
|
<select id="hospitalDetail" resultType="com.sinata.system.domain.vo.MwCheckoutRecordVO">
|
SELECT mcr.ID,
|
mcr.CHECKOUT_TIME,
|
mcr.HOSPITAL_NAME,
|
SUM(mcr.BOX_NUM) AS boxNum,
|
SUM(mcr.BAG_NUM) AS bagNum,
|
SUM(mcr.TOTAL_WEIGHT) AS totalWeight,
|
su.NICK_NAME AS driverName,
|
mtc.LICENSE_PLATE_NUMBER
|
FROM MW_CHECKOUT_RECORD mcr
|
LEFT JOIN SYS_USER su
|
ON mcr.DRIVER_ID = su.USER_ID
|
LEFT JOIN MW_TRANSIT_CAR mtc
|
ON mcr.CAR_ID = mtc.ID
|
LEFT JOIN SYS_DEPARTMENT sd
|
ON mcr.DEPARTMENT_ID = sd.ID
|
<where>
|
mcr.DEPARTMENT_ID = #{id}
|
</where>
|
</select>
|
<select id="hospitalDetailPage" resultType="com.sinata.system.domain.vo.MwMedicalWasteBoxVO">
|
SELECT
|
mcr.BOX_ID AS id,
|
mcr.BOX_NUMBER,
|
mcr.WASTE_TYPE_STR,
|
su.NICK_NAME AS COLLECT_USER_NAME,
|
COUNT(*) AS bagNum,
|
SUM(mcr.WEIGHT) AS totalWeight,
|
(SELECT MAX(mcr_inner.BOX_TIME)
|
FROM MW_COLLECT_RECORD mcr_inner
|
WHERE mcr_inner.BOX_ID = mcr.BOX_ID) AS BOX_TIME
|
FROM MW_COLLECT_RECORD mcr
|
LEFT JOIN SYS_USER su ON mcr.COLLECT_USER_ID = su.USER_ID
|
LEFT JOIN SYS_DEPARTMENT sd ON su.DEPARTMENT_ID = sd.ID
|
<where>
|
mcr.STATUS = 2 AND mcr.DEL_FLAG = 0
|
<if test="departmentId != null and departmentId != ''">
|
AND mcr.DEPARTMENT_ID = #{departmentId}
|
</if>
|
</where>
|
GROUP BY mcr.BOX_ID
|
ORDER BY mcr.CREATE_TIME DESC
|
</select>
|
<select id="transitPageList" resultType="com.sinata.system.domain.vo.MwTransitRecordVO">
|
SELECT
|
MTRC.ROUTE_ID AS id,
|
MDR.DISPOSAL_UNIT_NAME,
|
MTC.LICENSE_PLATE_NUMBER,
|
SU.NICK_NAME,
|
SUM(MCR.BOX_NUM) AS boxNum,
|
SUM(MCR.TOTAL_WEIGHT) AS weight,
|
MIN(MCR2.BOX_TIME) AS startTime,
|
MDR.RECEIVE_TIME AS endTime
|
FROM MW_CHECKOUT_RECORD MCR
|
LEFT JOIN MW_CHECKOUT_RECORD_ITEM MCRI ON MCRI.CHECKOUT_RECORD_ID = MCR.ID
|
LEFT JOIN MW_DISPOSAL_RECORD_ITEM MDRI ON MDRI.COLLECT_RECORD_ID = MCRI.COLLECT_RECORD_ID
|
LEFT JOIN MW_DISPOSAL_RECORD MDR ON MDR.ID = MDRI.DISPOSAL_RECORD_ID
|
LEFT JOIN MW_COLLECT_RECORD MCR2 ON MCRI.COLLECT_RECORD_ID = MCR2.ID
|
LEFT JOIN MW_TRANSIT_CAR MTC ON MCR.CAR_ID = MTC.ID
|
LEFT JOIN SYS_USER SU ON MCR.DRIVER_ID = SU.USER_ID
|
LEFT JOIN SYS_DEPARTMENT SD ON SD.ID = MDR.DEPARTMENT_ID
|
LEFT JOIN MW_TRANSIT_ROUTE_CAR MTRC ON MTRC.CAR_ID = MCR.CAR_ID
|
<where>
|
MCR.DEL_FLAG = 0
|
<if test="treeCode != null and treeCode != null">
|
AND SD.TREE_CODE LIKE CONCAT(#{treeCode},'%')
|
</if>
|
<if test="query.licensePlateNumber != null and query.licensePlateNumber != ''">
|
AND MTC.LICENSE_PLATE_NUMBER LIKE CONCAT('%',#{query.licensePlateNumber},'%')
|
</if>
|
<if test="query.status != null">
|
AND MCR2.STATUS = #{query.status}
|
</if>
|
<if test="query.startTime != null and query.endTime != null">
|
AND MDR.RECEIVE_TIME BETWEEN #{query.startTime} AND #{query.endTime}
|
</if>
|
</where>
|
GROUP BY MTRC.ROUTE_ID
|
ORDER BY startTime DESC
|
</select>
|
<select id="transitDetail" resultType="com.sinata.system.domain.vo.MwTransitRecordVO">
|
SELECT
|
MTRC.ROUTE_ID AS id,
|
MDR.DISPOSAL_UNIT_NAME,
|
MTC.LICENSE_PLATE_NUMBER,
|
SU.NICK_NAME,
|
SUM(MCR.BOX_NUM) AS boxNum,
|
SUM(MCR.TOTAL_WEIGHT) AS weight,
|
MIN(MCR2.BOX_TIME) AS startTime,
|
MDR.RECEIVE_TIME AS endTime
|
FROM MW_CHECKOUT_RECORD MCR
|
LEFT JOIN MW_CHECKOUT_RECORD_ITEM MCRI ON MCRI.CHECKOUT_RECORD_ID = MCR.ID
|
LEFT JOIN MW_DISPOSAL_RECORD_ITEM MDRI ON MDRI.COLLECT_RECORD_ID = MCRI.COLLECT_RECORD_ID
|
LEFT JOIN MW_DISPOSAL_RECORD MDR ON MDR.ID = MDRI.DISPOSAL_RECORD_ID
|
LEFT JOIN MW_COLLECT_RECORD MCR2 ON MCRI.COLLECT_RECORD_ID = MCR2.ID
|
LEFT JOIN MW_TRANSIT_CAR MTC ON MCR.CAR_ID = MTC.ID
|
LEFT JOIN SYS_USER SU ON MCR.DRIVER_ID = SU.USER_ID
|
LEFT JOIN SYS_DEPARTMENT SD ON SD.ID = MDR.DEPARTMENT_ID
|
LEFT JOIN MW_TRANSIT_ROUTE_CAR MTRC ON MTRC.CAR_ID = MCR.CAR_ID
|
<where>
|
MCR.DEL_FLAG = 0 AND MTRC.ROUTE_ID = #{id}
|
</where>
|
GROUP BY MTRC.ROUTE_ID
|
</select>
|
<select id="transitDetailPageList" resultType="com.sinata.system.domain.vo.MwMedicalWasteBoxVO">
|
SELECT MCR2.HOSPITAL_NAME,
|
MCR2.BOX_NUMBER,
|
MCR2.WASTE_TYPE_STR,
|
COUNT(MCR2.ID) AS bagNum,
|
SUM(MCR2.WEIGHT) AS totalWeight,
|
MAX(MCR.CHECKOUT_TIME) AS latestCheckoutTime
|
FROM MW_TRANSIT_ROUTE_CAR MTRC
|
LEFT JOIN MW_CHECKOUT_RECORD MCR on MTRC.CAR_ID = MCR.CAR_ID
|
LEFT JOIN MW_CHECKOUT_RECORD_ITEM MCRI on MCR.ID = MCRI.CHECKOUT_RECORD_ID
|
LEFT JOIN MW_COLLECT_RECORD MCR2 ON MCR2.ID = MCRI.COLLECT_RECORD_ID
|
<where>
|
MTRC.DEL_FLAG = 0 AND MTRC.ROUTE_ID = #{id}
|
</where>
|
GROUP BY MCR2.BOX_ID
|
ORDER BY latestCheckoutTime DESC
|
</select>
|
<select id="hospitalTransitList" resultType="com.sinata.system.domain.vo.MwCheckoutRecordVO">
|
SELECT mcr.ID,
|
mcr.CHECKOUT_TIME,
|
mcr.HOSPITAL_NAME,
|
SUM(mcr.BOX_NUM) AS boxNum,
|
SUM(mcr.BAG_NUM) AS bagNum,
|
SUM(mcr.TOTAL_WEIGHT) AS totalWeight,
|
su.NICK_NAME AS driverName,
|
mtc.LICENSE_PLATE_NUMBER
|
FROM MW_CHECKOUT_RECORD mcr
|
LEFT JOIN SYS_USER su
|
ON mcr.DRIVER_ID = su.USER_ID
|
LEFT JOIN MW_TRANSIT_CAR mtc
|
ON mcr.CAR_ID = mtc.ID
|
LEFT JOIN SYS_DEPARTMENT sd
|
ON mcr.DEPARTMENT_ID = sd.ID
|
<where>
|
mcr.DEL_FLAG = 0
|
<if test="treeCode != null and treeCode != ''">
|
AND sd.TREE_CODE LIKE CONCAT(#{treeCode},'%')
|
</if>
|
<if test="query.checkoutTimeStart != null and query.checkoutTimeEnd!=null">
|
AND mcr.CHECKOUT_TIME BETWEEN #{query.checkoutTimeStart} AND #{query.checkoutTimeEnd}
|
</if>
|
<if test="query.ids != null and ids.size() > 0">
|
AND mcr.ID IN
|
<foreach collection="query.ids" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
</where>
|
GROUP BY mcr.DEPARTMENT_ID
|
</select>
|
<select id="getCheckoutRecordList" resultMap="TransformVOMap">
|
SELECT MCR.ID,
|
MCR.CHECKOUT_TIME,
|
MCR.DEPARTMENT_ID,
|
MCR.HOSPITAL_NAME,
|
MCR.STAGING_ROOM_ID,
|
MCR.HOSPITAL_SIGNATURE,
|
SU.NICK_NAME AS driverName,
|
COUNT(MCR2.ID) AS bagNum,
|
SUM(MCR2.WEIGHT) AS totalWeight,
|
MCR2.WASTE_TYPE,
|
MCR2.WASTE_TYPE_STR
|
FROM MW_CHECKOUT_RECORD MCR
|
LEFT JOIN MW_CHECKOUT_RECORD_ITEM MCRI ON MCRI.CHECKOUT_RECORD_ID = MCR.ID
|
LEFT JOIN MW_COLLECT_RECORD MCR2 ON MCR2.ID = MCRI.COLLECT_RECORD_ID
|
LEFT JOIN SYS_DEPARTMENT SD ON SD.ID = MCR.DEPARTMENT_ID
|
LEFT JOIN SYS_USER SU ON SU.USER_ID = MCR.DRIVER_ID
|
<where>
|
<if test="treeCode != null and treeCode != ''">
|
AND SD.TREE_CODE LIKE CONCAT(#{treeCode},'%')
|
</if>
|
<if test="query.startTime != null and query.endTime != null">
|
AND MCR.CHECKOUT_TIME BETWEEN #{query.startTime} AND #{query.endTime}
|
</if>
|
<if test="query.wasteTypeList != null and query.wasteTypeList.size()>0">
|
AND MCR2.WASTE_TYPE IN
|
<foreach collection="query.wasteTypeList" item="wasteType" separator="," open="(" close=")">
|
#{wasteType}
|
</foreach>
|
</if>
|
</where>
|
GROUP BY MCR2.BOX_NUMBER
|
</select>
|
<select id="getRegulationReportList" resultType="com.sinata.system.domain.vo.MwCollectRecordVO">
|
SELECT MCR2.ID,
|
MCR2.WASTE_TYPE,
|
MCR2.WASTE_TYPE_STR,
|
MCR2.WEIGHT,
|
MCR.CHECKOUT_TIME
|
FROM MW_CHECKOUT_RECORD MCR
|
LEFT JOIN MW_CHECKOUT_RECORD_ITEM MCRI ON MCRI.CHECKOUT_RECORD_ID = MCR.ID
|
LEFT JOIN MW_COLLECT_RECORD MCR2 ON MCR2.ID = MCRI.COLLECT_RECORD_ID
|
LEFT JOIN SYS_DEPARTMENT SD ON SD.ID = MCR.DEPARTMENT_ID
|
<where>
|
MCR.DEL_FLAG = 0
|
<if test="treeCode != null and treeCode !=''">
|
AND SD.TREE_CODE LIKE CONCAT(#{treeCode},'%')
|
</if>
|
<if test="query.startTime != null and query.endTime != null">
|
AND MCR.CHECKOUT_TIME BETWEEN #{query.startTime} AND #{query.endTime}
|
</if>
|
<if test="query.wasteTypeList != null and query.wasteTypeList.size()>0">
|
AND MCR2.WASTE_TYPE IN
|
<foreach collection="query.wasteTypeList" item="wasteType" separator="," open="(" close=")">
|
#{wasteType}
|
</foreach>
|
</if>
|
</where>
|
</select>
|
|
</mapper>
|