<?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.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,
|
SD.DEPARTMENT_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,
|
MCR2.STATUS
|
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.startTimeStart != null and query.startTimeEnd != null">
|
AND MCR2.BOX_TIME BETWEEN #{query.startTimeStart} AND #{query.startTimeEnd}
|
</if>
|
<if test="query.endTimeStart != null and query.endTimeEnd != null">
|
AND MDR.RECEIVE_TIME BETWEEN #{query.endTimeStart} AND #{query.endTimeEnd}
|
</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
|
INNER 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.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="totalUp" resultType="com.sinata.system.domain.dto.CollectTotalUpDto">
|
SELECT WASTE_TYPE as wasteType,WASTE_TYPE_STR as wasteTypeStr,COUNT(DISTINCT BOX_NUMBER ) as boxNum ,COUNT(1)as num,sum(WEIGHT) as weight from MEDICAL_WASTE.MW_COLLECT_RECORD
|
<where>
|
CHECKOUT_TIME is not null AND DEPARTMENT_ID = #{departmentId} AND TRUNC(COLLECT_TIME, 'DAY') = TO_DATE(#{date},'YYYY-MM-DD')
|
</where>
|
GROUP BY WASTE_TYPE
|
</select>
|
|
<select id="totalUp4" resultType="com.sinata.system.domain.dto.CollectTotalUpDto">
|
SELECT WASTE_TYPE as wasteType,WASTE_TYPE_STR as wasteTypeStr,COUNT(DISTINCT BOX_NUMBER ) as boxNum ,COUNT(1)as num,sum(WEIGHT) as weight from MEDICAL_WASTE.MW_COLLECT_RECORD
|
<where>
|
CHECKOUT_TIME is not null AND DEPARTMENT_ID = #{departmentId}
|
</where>
|
GROUP BY WASTE_TYPE
|
</select>
|
|
|
<select id="totalUp2" resultType="com.sinata.system.domain.dto.CollectTotalUpDto">
|
SELECT WASTE_TYPE as wasteType,WASTE_TYPE_STR as wasteTypeStr,COUNT(DISTINCT BOX_NUMBER ) as boxNum ,COUNT(1)as num,sum(WEIGHT) as weight from MEDICAL_WASTE.MW_COLLECT_RECORD
|
<where>
|
RECEIVE_USER_ID is not null AND RECEIVE_USER_ID = #{departmentId}
|
<if test="date1 != null">
|
AND TRUNC(RECEIVE_TIME, 'DAY') >= TO_DATE(#{date1},'YYYY-MM-DD')
|
</if>
|
<if test="date2 != null">
|
AND TRUNC(RECEIVE_TIME, 'DAY') < TO_DATE(#{date2},'YYYY-MM-DD')
|
</if>
|
|
</where>
|
GROUP BY WASTE_TYPE
|
</select>
|
|
<select id="totalUp5" resultType="com.sinata.system.domain.dto.CollectTotalUpDto">
|
SELECT WASTE_TYPE as wasteType,WASTE_TYPE_STR as wasteTypeStr,COUNT(DISTINCT BOX_NUMBER ) as boxNum ,COUNT(1)as num,sum(WEIGHT) as weight from MEDICAL_WASTE.MW_COLLECT_RECORD
|
<where>
|
RECEIVE_DEPARTMENT_ID is not null AND RECEIVE_DEPARTMENT_ID = #{departmentId}
|
</where>
|
GROUP BY WASTE_TYPE
|
</select>
|
<select id="totalUp3" resultType="com.sinata.system.domain.dto.CollectTotalUpDto">
|
SELECT WASTE_TYPE as wasteType,WASTE_TYPE_STR as wasteTypeStr,COUNT(DISTINCT BOX_NUMBER ) as boxNum ,COUNT(1)as num,sum(WEIGHT) as weight from MEDICAL_WASTE.MW_COLLECT_RECORD
|
<where>
|
DISPOSAL_USER_ID is not null AND DISPOSAL_USER_ID = #{departmentId}
|
<if test="date1 != null">
|
AND TRUNC(DISPOSAL_TIME, 'DAY') >= TO_DATE(#{date1},'YYYY-MM-DD')
|
</if>
|
<if test="date2 != null">
|
AND TRUNC(DISPOSAL_TIME, 'DAY') < TO_DATE(#{date2},'YYYY-MM-DD') </if>
|
</where>
|
GROUP BY WASTE_TYPE
|
</select>
|
|
<select id="totalUp1" resultType="com.sinata.system.domain.dto.CollectTotalUpDto">
|
SELECT t2.WASTE_TYPE as wasteType,WASTE_TYPE_STR as wasteTypeStr,COUNT(DISTINCT t2.BOX_NUMBER ) as boxNum ,COUNT(t2.ID)as num,sum(t2.WEIGHT) as weight
|
from MEDICAL_WASTE.MW_CHECKOUT_RECORD_ITEM t1
|
left join MEDICAL_WASTE.MW_COLLECT_RECORD t2 on t1.COLLECT_RECORD_ID = t2.ID
|
where t1.CHECKOUT_RECORD_ID = #{outId}
|
GROUP BY t2.WASTE_TYPE
|
</select>
|
|
<select id="totalUp6" resultType="com.sinata.system.domain.dto.CollectTotalUpDto">
|
SELECT t2.WASTE_TYPE as wasteType,WASTE_TYPE_STR as wasteTypeStr,COUNT(DISTINCT t2.BOX_NUMBER ) as boxNum ,COUNT(t2.ID)as num,sum(t2.WEIGHT) as weight
|
from MEDICAL_WASTE.MW_DISPOSAL_RECORD_ITEM t1
|
left join MEDICAL_WASTE.MW_COLLECT_RECORD t2 on t1.COLLECT_RECORD_ID = t2.ID
|
where t1.DISPOSAL_RECORD_ID = #{outId}
|
GROUP BY t2.WASTE_TYPE
|
</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
|
LEFT JOIN MW_DISPOSAL_RECORD_ITEM MDRI ON MDRI.COLLECT_RECORD_ID = MCR.ID
|
LEFT JOIN MW_DISPOSAL_RECORD MDR ON MDR.ID = MDRI.DISPOSAL_RECORD_ID
|
<where>
|
<if test="query.departmentId != null">
|
AND MDR.DEPARTMENT_ID = #{query.departmentId}
|
</if>
|
<if test="query.startTime != null and query.endTime != null">
|
AND MCR.CHECKOUT_TIME BETWEEN #{query.startTime} AND #{query.endTime}
|
</if>
|
<if test="query.wasteTypeCodeList != null and query.wasteTypeCodeList.size()>0">
|
AND MCR2.WASTE_TYPE IN
|
<foreach collection="query.wasteTypeCodeList" 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.wasteTypeCodeList != null and query.wasteTypeCodeList.size()>0">
|
AND MCR2.WASTE_TYPE IN
|
<foreach collection="query.wasteTypeCodeList" item="wasteType" separator="," open="(" close=")">
|
#{wasteType}
|
</foreach>
|
</if>
|
</where>
|
</select>
|
<select id="queryWarningList" resultType="com.sinata.system.domain.vo.MwTransitCarWarningVO">
|
SELECT MTC.ID,
|
MTC.LICENSE_PLATE_NUMBER,
|
MTC.MAXIMUM_LOAD,
|
MTC.DEPARTMENT_ID, SD.DEPARTMENT_NAME, SUM(MCR.TOTAL_WEIGHT) AS currentLoad
|
FROM MW_TRANSIT_ROUTE_CAR MTRC
|
LEFT JOIN MW_CHECKOUT_RECORD MCR ON MCR.CAR_ID = MTRC.CAR_ID
|
LEFT JOIN MW_TRANSIT_CAR MTC ON MTC.ID = MCR.CAR_ID
|
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 = MTC.DEPARTMENT_ID
|
<where>
|
MCR.DEL_FLAG = 0
|
AND MCR2.STATUS = 2
|
</where>
|
GROUP BY MTRC.ROUTE_ID,MTRC.CAR_ID
|
</select>
|
|
</mapper>
|