<?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="cn.besteam.modules.medical.mapper.MwCollectRecordMapper">
|
|
<!-- 收集记录 -->
|
<select id="queryPageCollectList" resultType="cn.besteam.modules.medical.vo.MwCollectRecordVO">
|
select
|
cr.id , cr.create_time , cr.store_time , cr.box_time , cr.checkout_time , cr.delete_time , cr.supply_time ,
|
cr.code , cr.warehouse_id , cr.warehouse_name ,
|
cr.hospital_name , cr.hospital_id , cr.department_id , cr.department_name ,
|
cr.department_user_name , cr.department_user_id ,
|
cr.waste_type_str ,
|
cr.waste_type ,
|
cr.weight ,
|
cr.status , cr.description ,
|
cr.creator , cr.store_user
|
FROM
|
mw_collect_record AS cr
|
WHERE
|
cr.id in (select id FROM mw_collect_record AS cr
|
<where>
|
<if test="dto.hospitalIdList != null and dto.hospitalIdList.size > 0 ">
|
and cr.hospital_id in
|
<foreach collection="dto.hospitalIdList" item="tempId" open="(" close=")" separator=",">
|
#{tempId}
|
</foreach>
|
</if>
|
<if test="dto.departmentId !=null ">
|
and (cr.department_id = #{dto.departmentId}
|
or cr.department_id in (select id from sys_department d where d.parent_id = #{dto.departmentId}))
|
</if>
|
<if test="dto.wasteType !=null ">
|
and cr.waste_type = #{dto.wasteType}
|
</if>
|
<if test="dto.code !=null and dto.code !='' ">
|
and cr.code like concat('%' , #{dto.code} , '%')
|
</if>
|
<if test="dto.keyWord !=null and dto.keyWord !='' ">
|
and (cr.code like concat('%' , #{dto.keyWord} , '%') or cr.store_user like concat('%' , #{dto.keyWord} , '%'))
|
</if>
|
<if test="dto.startTime !=null">
|
<![CDATA[
|
and date_format( cr.create_time, '%Y-%m-%d %H:%i:%s' ) >= date_format( #{dto.startTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="dto.endTime !=null">
|
<![CDATA[
|
and date_format( cr.create_time, '%Y-%m-%d %H:%i:%s' ) <= date_format( #{dto.endTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
and cr.status in ( 1 , 2 , 3 )
|
<if test="dto.status !=null">
|
and cr.status = #{dto.status}
|
</if>
|
<if test="dto.delFlag !=null">
|
and cr.del_flag = #{dto.delFlag}
|
</if>
|
<if test="dto.auditStatus !=null">
|
and cr.audit_status = #{dto.auditStatus}
|
</if>
|
<if test="dto.source !=null">
|
and cr.source = #{dto.source}
|
</if>
|
<if test="dto.wasteTypes != null and dto.wasteTypes.size > 0 ">
|
and cr.waste_type_str in
|
<foreach collection="dto.wasteTypes" item="wasteTypeStr" open="(" close=")" separator=",">
|
#{wasteTypeStr}
|
</foreach>
|
</if>
|
</where>
|
)
|
order by cr.create_time desc
|
</select>
|
|
<!-- 入库记录 -->
|
<select id="queryPageStoreList" resultType="cn.besteam.modules.medical.vo.MwCollectRecordVO">
|
select
|
cr.id , cr.create_time , cr.store_time , cr.box_time , cr.checkout_time , cr.delete_time , cr.supply_time ,
|
cr.code , cr.warehouse_id , cr.warehouse_name ,
|
cr.hospital_name , cr.hospital_id , cr.department_id , cr.department_name ,
|
cr.department_user_name , cr.department_user_id ,
|
cr.waste_type_str ,
|
cr.weight ,
|
cr.status , cr.description ,
|
b.code boxCode ,
|
cr.creator , cr.store_user
|
from mw_collect_record cr
|
left join mw_box_item bi on bi.collect_record_id = cr.id
|
left join mw_box b on b.id = bi.box_id
|
left join sys_dict_item sdi on sdi.id = cr.waste_type
|
<where>
|
<if test="dto.hospitalIdList != null and dto.hospitalIdList.size > 0 ">
|
and cr.hospital_id in
|
<foreach collection="dto.hospitalIdList" item="tempId" open="(" close=")" separator=",">
|
#{tempId}
|
</foreach>
|
</if>
|
<if test="dto.departmentId !=null ">
|
and (cr.department_id = #{dto.departmentId}
|
or cr.department_id in (select id from sys_department d where d.parent_id = #{dto.departmentId}))
|
</if>
|
<if test="dto.wasteType !=null ">
|
and cr.waste_type = #{dto.wasteType}
|
</if>
|
<if test="dto.code !=null and dto.code !='' ">
|
and cr.code like concat('%' , #{dto.code} , '%')
|
</if>
|
<if test="dto.keyWord !=null and dto.keyWord !='' ">
|
and (cr.code like concat('%' , #{dto.keyWord} , '%') or b.code like concat('%' , #{dto.keyWord} , '%'))
|
</if>
|
<if test="dto.startTime !=null">
|
<![CDATA[
|
and date_format( cr.store_time, '%Y-%m-%d %H:%i:%s' ) >= date_format( #{dto.startTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="dto.endTime !=null">
|
<![CDATA[
|
and date_format( cr.store_time, '%Y-%m-%d %H:%i:%s' ) <= date_format( #{dto.endTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
and cr.status in ( 2 , 3 )
|
<if test="dto.delFlag !=null">
|
and cr.del_flag = #{dto.delFlag}
|
</if>
|
<if test="dto.auditStatus !=null">
|
and cr.audit_status = #{dto.auditStatus}
|
</if>
|
<if test="dto.boxCode !=null and dto.boxCode != ''">
|
and b.code like concat('%' , #{dto.boxCode} , '%')
|
</if>
|
</where>
|
order by cr.store_time desc
|
</select>
|
|
<!-- 出库记录 -->
|
<select id="queryPageCheckoutList" resultType="cn.besteam.modules.medical.vo.MwCollectRecordVO">
|
select
|
cr.id , cr.create_time , cr.store_time , cr.box_time , cr.checkout_time , cr.delete_time , cr.supply_time ,
|
cr.code , cr.warehouse_id , cr.warehouse_name ,
|
cr.hospital_name , cr.hospital_id , cr.department_id , cr.department_name ,
|
cr.department_user_name , cr.department_user_id ,
|
cr.waste_type_str ,
|
cr.weight ,
|
cr.status , cr.description ,
|
b.code boxCode ,
|
cr.creator , cr.store_user ,
|
chr.creator checkoutUser,
|
chr.transit_company , chr.engine_driver , chr.license_plate
|
from mw_collect_record cr
|
left join mw_box_item bi on bi.collect_record_id = cr.id
|
left join mw_box b on b.id = bi.box_id
|
inner join mw_checkout_record_item chri on chri.collect_record_id = cr.id
|
inner join mw_checkout_record chr on chr.id = chri.checkout_record_id
|
left join mw_transit_config tr on tr.id = chr.transit_config_id
|
left join sys_dict_item sdi on sdi.id = cr.waste_type
|
<where>
|
<if test="dto.hospitalIdList != null and dto.hospitalIdList.size > 0 ">
|
and cr.hospital_id in
|
<foreach collection="dto.hospitalIdList" item="tempId" open="(" close=")" separator=",">
|
#{tempId}
|
</foreach>
|
</if>
|
<if test="dto.departmentId !=null ">
|
and (cr.department_id = #{dto.departmentId}
|
or cr.department_id in (select id from sys_department d where d.parent_id = #{dto.departmentId}))
|
</if>
|
<if test="dto.wasteType !=null ">
|
and cr.waste_type = #{dto.wasteType}
|
</if>
|
<if test="dto.code !=null and dto.code !='' ">
|
and cr.code like concat('%' , #{dto.code} , '%')
|
</if>
|
<if test="dto.keyWord !=null and dto.keyWord !='' ">
|
and (cr.code like concat('%' , #{dto.keyWord} , '%') or b.code like concat('%' , #{dto.keyWord} , '%'))
|
</if>
|
<if test="dto.startTime !=null">
|
<![CDATA[
|
and date_format( cr.checkout_time, '%Y-%m-%d %H:%i:%s' ) >= date_format( #{dto.startTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="dto.endTime !=null">
|
<![CDATA[
|
and date_format( cr.checkout_time, '%Y-%m-%d %H:%i:%s' ) <= date_format( #{dto.endTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
and cr.status = 3
|
<if test="dto.delFlag !=null">
|
and cr.del_flag = #{dto.delFlag}
|
</if>
|
<if test="dto.auditStatus !=null">
|
and cr.audit_status = #{dto.auditStatus}
|
</if>
|
<if test="dto.boxCode !=null and dto.boxCode !=''">
|
and b.code like concat('%' , #{dto.boxCode} , '%')
|
</if>
|
|
<if test="dto.transitConfigId !=null ">
|
and chr.transit_config_id = #{dto.transitConfigId}
|
</if>
|
<if test="dto.transitCompany != null and dto.transitCompany != ''">
|
AND chr.transit_company LIKE CONCAT(#{dto.transitCompany})
|
</if>
|
</where>
|
order by cr.checkout_time desc
|
</select>
|
|
<!-- 流转记录 -->
|
<select id="getRecordDetail" resultType="cn.besteam.modules.medical.vo.MwCollectRecordVO">
|
select
|
cr.id , cr.create_time , cr.store_time , cr.box_time , cr.checkout_time , cr.delete_time , cr.supply_time ,
|
cr.code , cr.warehouse_id , cr.warehouse_name ,
|
cr.hospital_name , cr.hospital_id , cr.department_id , cr.department_name ,
|
cr.department_user_name , cr.department_user_id ,
|
cr.waste_type_str ,
|
cr.weight ,
|
cr.status , cr.description ,
|
b.code boxCode ,
|
cr.creator , cr.store_user ,
|
chr.creator checkoutUser,
|
chr.transit_company , chr.engine_driver , chr.license_plate
|
from mw_collect_record cr
|
left join mw_box_item bi on bi.collect_record_id = cr.id
|
left join mw_box b on b.id = bi.box_id
|
left join mw_checkout_record_item chri on chri.collect_record_id = cr.id
|
left join mw_checkout_record chr on chr.id = chri.checkout_record_id
|
left join mw_transit_config tr on tr.id = chr.transit_config_id
|
left join sys_dict_item sdi on sdi.id = cr.waste_type
|
where cr.id = #{id}
|
limit 1
|
</select>
|
|
<!-- 补录记录 -->
|
<select id="queryPageSupplyList" resultType="cn.besteam.modules.medical.vo.MwCollectRecordVO">
|
select
|
cr.id , cr.create_time , cr.store_time , cr.box_time , cr.checkout_time , cr.delete_time , cr.supply_time ,
|
cr.code , cr.warehouse_id , cr.warehouse_name ,
|
cr.hospital_name , cr.hospital_id , cr.department_id , cr.department_name ,
|
cr.department_user_name , cr.department_user_id ,
|
cr.waste_type_str ,
|
cr.weight , cr.audit_status ,
|
cr.status , cr.description ,
|
cr.creator , cr.store_user
|
from mw_collect_record cr
|
left join sys_dict_item sdi on sdi.id = cr.waste_type
|
<where>
|
<if test="dto.hospitalIdList != null and dto.hospitalIdList.size > 0 ">
|
and cr.hospital_id in
|
<foreach collection="dto.hospitalIdList" item="tempId" open="(" close=")" separator=",">
|
#{tempId}
|
</foreach>
|
</if>
|
<if test="dto.departmentId !=null ">
|
and (cr.department_id = #{dto.departmentId}
|
or cr.department_id in (select id from sys_department d where d.parent_id = #{dto.departmentId}))
|
</if>
|
<if test="dto.wasteType !=null ">
|
and cr.waste_type = #{dto.wasteType}
|
</if>
|
<if test="dto.code !=null and dto.code !='' ">
|
and cr.code like concat('%' , #{dto.code} , '%')
|
</if>
|
<if test="dto.startTime !=null">
|
<![CDATA[
|
and date_format( cr.create_time, '%Y-%m-%d %H:%i:%s' ) >= date_format( #{dto.startTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="dto.endTime !=null">
|
<![CDATA[
|
and date_format( cr.create_time, '%Y-%m-%d %H:%i:%s' ) <= date_format( #{dto.endTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="dto.status !=null">
|
and cr.status = #{dto.status}
|
</if>
|
<if test="dto.delFlag !=null">
|
and cr.del_flag = #{dto.delFlag}
|
</if>
|
<if test="dto.auditStatus !=null">
|
and cr.audit_status = #{dto.auditStatus}
|
</if>
|
<if test="dto.source !=null">
|
and cr.source = #{dto.source}
|
</if>
|
</where>
|
order by cr.supply_time desc
|
</select>
|
|
<!-- 删除记录 -->
|
<select id="queryPageDeleteList" resultType="cn.besteam.modules.medical.vo.MwCollectRecordVO">
|
select
|
cr.id , cr.create_time , cr.store_time , cr.box_time , cr.checkout_time , cr.delete_time , cr.supply_time ,
|
cr.code , cr.warehouse_id , cr.warehouse_name ,
|
cr.hospital_name , cr.hospital_id , cr.department_id , cr.department_name ,
|
cr.department_user_name , cr.department_user_id ,
|
cr.waste_type_str ,
|
cr.weight ,
|
cr.status , cr.description ,
|
cr.creator , cr.store_user
|
from mw_collect_record cr
|
left join sys_dict_item sdi on sdi.id = cr.waste_type
|
<where>
|
<if test="dto.hospitalIdList != null and dto.hospitalIdList.size > 0 ">
|
and cr.hospital_id in
|
<foreach collection="dto.hospitalIdList" item="tempId" open="(" close=")" separator=",">
|
#{tempId}
|
</foreach>
|
</if>
|
<if test="dto.departmentId !=null ">
|
and (cr.department_id = #{dto.departmentId}
|
or cr.department_id in (select id from sys_department d where d.parent_id = #{dto.departmentId}))
|
</if>
|
<if test="dto.wasteType !=null ">
|
and cr.waste_type = #{dto.wasteType}
|
</if>
|
<if test="dto.code !=null and dto.code !='' ">
|
and cr.code like concat('%' , #{dto.code} , '%')
|
</if>
|
<if test="dto.startTime !=null">
|
<![CDATA[
|
and date_format( cr.delete_time, '%Y-%m-%d %H:%i:%s' ) >= date_format( #{dto.startTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="dto.endTime !=null">
|
<![CDATA[
|
and date_format( cr.delete_time, '%Y-%m-%d %H:%i:%s' ) <= date_format( #{dto.endTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
and cr.status in ( 1 , 2 , 3 )
|
<if test="dto.status !=null">
|
and cr.status = #{dto.status}
|
</if>
|
<if test="dto.delFlag !=null">
|
and cr.del_flag = #{dto.delFlag}
|
</if>
|
<if test="dto.auditStatus !=null">
|
and cr.audit_status = #{dto.auditStatus}
|
</if>
|
<if test="dto.source !=null">
|
and cr.source = #{dto.source}
|
</if>
|
</where>
|
order by cr.delete_time desc
|
</select>
|
|
<!-- 获取此次操作医废收集类型统计 -->
|
<select id="getStatistic" resultType="cn.besteam.modules.medical.vo.ApiMedicalStatisticsVO">
|
SELECT
|
COUNT( * ) AS count,
|
sum( weight ) AS weightSum
|
FROM
|
mw_collect_record
|
WHERE
|
id in
|
<foreach collection="idList" item="id" index="index" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
AND waste_type_str = #{wasteTypeStr}
|
AND status = #{status}
|
AND del_flag = #{delFlag}
|
AND audit_status = #{auditStatus}
|
</select>
|
|
<!-- 获取所有科室数量和重量 -->
|
<select id="getNumberAndWeightStatistics" resultType="cn.besteam.modules.medical.vo.ApiMedicalStatisticsVO">
|
SELECT
|
count(*) AS count,
|
SUM(weight) AS weightSum,
|
waste_type_str AS wasteTypeStr
|
FROM
|
mw_collect_record
|
WHERE
|
store_user_id = #{userId}
|
AND department_name = #{departmentName}
|
AND waste_type_str in
|
<foreach collection="wasteTypeStrSet" item="wasteTypeStr" index="index" open="(" separator="," close=")">
|
#{wasteTypeStr}
|
</foreach>
|
<if test="param.startTime != null">
|
AND create_time <![CDATA[ >= ]]> #{param.startTime}
|
</if>
|
<if test="param.endTime != null">
|
AND create_time <![CDATA[ <= ]]> #{param.endTime}
|
</if>
|
AND status = #{param.status}
|
AND del_flag = #{delFlag}
|
AND audit_status = #{auditStatus}
|
GROUP BY
|
waste_type_str
|
</select>
|
|
<!-- 获取当前登陆用户所有医废类型数量和重量统计 -->
|
<select id="getWasteNumberAndWeightStatistics" resultType="cn.besteam.modules.medical.vo.ApiMedicalStatisticsVO">
|
SELECT
|
count(*) AS count,
|
SUM(weight) AS weightSum,
|
waste_type_str AS wasteTypeStr
|
FROM
|
mw_collect_record
|
WHERE
|
store_user_id = #{userId}
|
AND waste_type_str in
|
<foreach collection="wasteTypeStrSet" item="wasteTypeStr" index="index" open="(" separator="," close=")">
|
#{wasteTypeStr}
|
</foreach>
|
<if test="param.startTime != null">
|
AND create_time <![CDATA[ >= ]]> #{param.startTime}
|
</if>
|
<if test="param.endTime != null">
|
AND create_time <![CDATA[ <= ]]> #{param.endTime}
|
</if>
|
AND status = #{param.status}
|
AND del_flag = #{delFlag}
|
AND audit_status = #{auditStatus}
|
GROUP BY
|
waste_type_str
|
</select>
|
|
<!-- 入库统计 -->
|
<select id="getStoreStatistics" resultType="cn.besteam.modules.medical.vo.ApiMedicalStatisticsVO">
|
SELECT
|
count(*) AS count,
|
SUM(weight) AS weightSum,
|
waste_type_str AS wasteTypeStr
|
FROM
|
mw_collect_record
|
WHERE
|
store_user_id = #{userId}
|
AND waste_type_str in
|
<foreach collection="wasteTypeStrSet" item="wasteTypeStr" index="index" open="(" separator="," close=")">
|
#{wasteTypeStr}
|
</foreach>
|
<if test="param.startTime != null">
|
AND store_time <![CDATA[ >= ]]> #{param.startTime}
|
</if>
|
<if test="param.endTime != null">
|
AND store_time <![CDATA[ <= ]]> #{param.endTime}
|
</if>
|
<if test="hospitalId!=null">
|
AND hospital_id = #{hospitalId}
|
</if>
|
and status in (2 , 3 )
|
AND del_flag = #{delFlag}
|
AND audit_status = #{auditStatus}
|
GROUP BY
|
waste_type_str
|
</select>
|
|
<!-- 出库统计 -->
|
<select id="getCheckoutStatistics" resultType="cn.besteam.modules.medical.vo.ApiMedicalStatisticsVO">
|
SELECT
|
count(*) AS count,
|
SUM(weight) AS weightSum,
|
waste_type_str AS wasteTypeStr
|
FROM
|
mw_collect_record
|
WHERE
|
checkout_user_id = #{userId}
|
AND waste_type_str in
|
<foreach collection="wasteTypeStrSet" item="wasteTypeStr" index="index" open="(" separator="," close=")">
|
#{wasteTypeStr}
|
</foreach>
|
<if test="param.startTime != null ">
|
AND checkout_time <![CDATA[ >= ]]> #{param.startTime}
|
</if>
|
<if test="param.endTime != null">
|
AND checkout_time <![CDATA[ <= ]]> #{param.endTime}
|
</if>
|
<if test="hospitalId!=null">
|
AND hospital_id = #{hospitalId}
|
</if>
|
and status = 3
|
AND del_flag = #{delFlag}
|
AND audit_status = #{auditStatus}
|
GROUP BY
|
waste_type_str
|
</select>
|
|
|
<!-- 获取未装箱清单列表 -->
|
<select id="getUnBoxingList" resultType="cn.besteam.modules.medical.entity.MwCollectRecord">
|
SELECT
|
mwc.*
|
FROM
|
mw_collect_record mwc
|
WHERE
|
mwc.warehouse_id = #{warehouseId}
|
AND NOT EXISTS ( SELECT collect_record_id FROM mw_box_item mwb WHERE mwc.id = mwb.collect_record_id )
|
AND mwc.status = 2
|
AND mwc.audit_status = 2
|
AND mwc.del_flag = 0
|
</select>
|
|
<!-- 获取未装箱清单列表 -->
|
<select id="getUnBoxingListNew" resultType="cn.besteam.modules.medical.entity.MwCollectRecord">
|
SELECT
|
mwc.*,(select b.code as boxCode from mw_box_item i left join mw_box b on i.box_id= b.id where i.collect_record_id = mwc.id) as boxCode
|
FROM
|
mw_collect_record mwc
|
WHERE
|
mwc.warehouse_id = #{warehouseId}
|
<if test="hospitalId!=null">
|
and mwc.hospital_id = #{hospitalId}
|
</if>
|
AND mwc.status = 2
|
AND mwc.audit_status = 2
|
AND mwc.del_flag = 0
|
order by mwc.store_time desc
|
</select>
|
|
<!--获取装箱列表-->
|
<select id="getUnBoxingListTotal" resultType="cn.besteam.modules.medical.entity.MwCollectRecord">
|
SELECT
|
mwc.*,(select b.code as boxCode from mw_box_item i left join mw_box b on i.box_id= b.id where i.collect_record_id = mwc.id) as boxCode,
|
b.box_weight as box_weight_total,b.boxAmount
|
FROM
|
mw_collect_record mwc
|
left join mw_box_item i on i.collect_record_id=mwc.id
|
left join
|
(
|
SELECT
|
sum( mwc.box_weight ) AS box_weight,count(1) as boxAmount,
|
box.box_id
|
FROM
|
mw_collect_record mwc
|
LEFT JOIN mw_box_item box ON box.collect_record_id = mwc.id
|
WHERE
|
mwc.warehouse_id = #{warehouseId}
|
<if test="hospitalId!=null">
|
and mwc.hospital_id = #{hospitalId}
|
</if>
|
AND mwc.STATUS = 2
|
AND mwc.audit_status = 2
|
AND mwc.del_flag = 0
|
GROUP BY
|
box.box_id
|
) b on b.box_id = i.box_id
|
WHERE
|
mwc.warehouse_id = #{warehouseId}
|
<if test="hospitalId!=null">
|
and mwc.hospital_id = #{hospitalId}
|
</if>
|
AND mwc.status = 2
|
AND mwc.audit_status = 2
|
AND mwc.del_flag = 0
|
AND b.box_weight is not null
|
order by mwc.store_time desc
|
</select>
|
|
|
<select id="getRankStatisticsList" resultType="cn.besteam.modules.report.vo.RankStatisticsVO">
|
select
|
s.depart_name as name , ifnull(A.weight,0) as data
|
from
|
sys_department s
|
<if test="startTime ==null and endTime == null">
|
left
|
</if>
|
<if test="startTime !=null or endTime != null">
|
inner
|
</if>
|
join (
|
select
|
hospital_id , ifnull(sum(weight),0) weight
|
from mw_collect_record
|
where del_flag = 0
|
and audit_status = 2
|
and hospital_id in
|
<foreach collection="departmentIdList" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
<if test="startTime !=null">
|
<![CDATA[
|
and date_format( create_time, '%Y-%m-%d %H:%i:%s' ) >= date_format( #{startTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="endTime !=null">
|
<![CDATA[
|
and date_format( create_time, '%Y-%m-%d %H:%i:%s' ) <= date_format( #{endTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
group by hospital_id
|
) A on A.hospital_id = s.id
|
where s.id in
|
<foreach collection="departmentIdList" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
<!--<if test="typeName!=null and typeName!=''">
|
<if test="typeName == 'today' or typeName == 'yesterday'">
|
and ifnull(A.weight,0) > 0
|
</if>
|
</if>-->
|
order by A.weight desc , convert(s.depart_name using 'gbk') asc
|
</select>
|
|
|
|
|
<select id="getRegionStatisticsList" resultType="cn.besteam.modules.report.vo.RankStatisticsVO">
|
|
select d.depart_name as name , ifnull(sum(b.weight),0) data ,
|
( select count(1)+1
|
from (
|
select td.id , sum(tb.weight) weight
|
from sys_department td
|
inner join (
|
select ttd.tree_code , sum(weight) weight ,count(1) c
|
from mw_collect_record tmcr
|
inner join sys_department ttd on ttd.id = tmcr.hospital_id
|
where tmcr.del_flag = 0
|
and tmcr.audit_status = 2
|
<if test="startTime !=null">
|
<![CDATA[
|
and date_format( tmcr.create_time, '%Y-%m-%d %H:%i:%s' ) >= date_format( #{startTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="endTime !=null">
|
<![CDATA[
|
and date_format( tmcr.create_time, '%Y-%m-%d %H:%i:%s' ) <= date_format( #{endTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
group by ttd.tree_code
|
) tb on tb.tree_code like concat(td.tree_code,'%')
|
where td.id in
|
<foreach collection="departmentIdList" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
group by td.id
|
order by weight asc
|
) S where S.weight > ifnull(sum(b.weight),0)
|
) ranks
|
from sys_department d
|
<if test="startTime ==null and endTime == null">
|
left
|
</if>
|
<if test="startTime !=null or endTime != null">
|
inner
|
</if>
|
join (
|
select d.tree_code , sum(weight) weight ,count(1) c
|
from mw_collect_record mcr
|
inner join sys_department d on d.id = mcr.hospital_id
|
where mcr.del_flag = 0
|
and mcr.audit_status = 2
|
<if test="startTime !=null">
|
<![CDATA[
|
and date_format( mcr.create_time, '%Y-%m-%d %H:%i:%s' ) >= date_format( #{startTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="endTime !=null">
|
<![CDATA[
|
and date_format( mcr.create_time, '%Y-%m-%d %H:%i:%s' ) <= date_format( #{endTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
group by d.tree_code
|
) b on b.tree_code like concat(d.tree_code,'%')
|
where d.id in
|
<foreach collection="departmentIdList" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
group by d.id
|
order by ranks asc , convert(d.depart_name using 'gbk') asc
|
</select>
|
|
|
<select id="getDepartmentLastCollectList" resultType="cn.besteam.modules.medical.vo.NonCollectMedicalWasteVO">
|
select
|
cr.id,
|
sd.depart_name as departmentName ,
|
cr.department_id ,
|
MAX(cr.create_time) as createTime ,
|
sc.id as hospital_id,
|
sc.depart_name as hospital_name
|
from mw_collect_record cr
|
inner join sys_department sd on sd.id = cr.department_id
|
left join sys_department sh on sh.id = sd.parent_id
|
left join sys_department sc on sc.id = sh.parent_id
|
where cr.del_flag = 0
|
and cr.audit_status = 2
|
and sd.del_flag = 0
|
and sh.status = 1
|
and sd.status = 1
|
group by sd.id
|
|
</select>
|
|
<select id="getHospitalLastCollectList" resultType="cn.besteam.modules.medical.vo.NonCollectMedicalWasteVO">
|
select
|
cr.department_id ,
|
max(cr.create_time) as createTime ,
|
cr.hospital_id ,
|
sh.depart_name as hospital_name,
|
st.id as area_id,
|
st.depart_name as area_name
|
from mw_collect_record cr
|
inner join sys_department sh on sh.id = cr.hospital_id
|
inner join sys_department st on sh.parent_id = st.id
|
where cr.del_flag = 0
|
and cr.audit_status = 2
|
and sh.del_flag = 0
|
and sh.status = 1
|
and st.del_flag = 0
|
and st.status = 1
|
group by cr.hospital_id
|
</select>
|
|
<select id="getDepartmentLastCollect" resultType="cn.besteam.modules.medical.vo.NonCollectMedicalWasteVO">
|
select
|
sd.depart_name as departmentName ,
|
cr.department_id ,
|
max(cr.create_time) as createTime ,
|
sc.id as hospital_id ,
|
sc.depart_name as hospital_name
|
from mw_collect_record cr
|
inner join sys_department sd on sd.id = cr.department_id
|
left join sys_department sh on sh.id = sd.parent_id
|
left join sys_department sc on sc.id = sh.parent_id
|
where cr.del_flag = 0
|
and cr.audit_status = 2
|
and sd.del_flag = 0
|
and sh.status = 1
|
and sd.status = 1
|
and cr.department_id in (${officeIds})
|
</select>
|
|
|
<select id="getOfficeRankStatistics" resultType="cn.besteam.modules.report.vo.RankStatisticsVO">
|
select d.id as 'key' ,
|
d.depart_name as name ,
|
ifnull(s.weight,0) as data
|
from sys_department d
|
inner join (
|
select department_id , sum(weight) weight
|
from mw_collect_record
|
where del_flag = 0
|
and audit_status = 2
|
<if test="startTime !=null">
|
<![CDATA[
|
and date_format( create_time, '%Y-%m-%d %H:%i:%s' ) >= date_format( #{startTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="endTime !=null">
|
<![CDATA[
|
and date_format( create_time, '%Y-%m-%d %H:%i:%s' ) <= date_format( #{endTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
group by department_id
|
) s on s.department_id=d.id
|
where d.id in
|
<foreach collection="departmentIdList" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
order by s.weight desc , convert(depart_name using 'gbk') asc
|
limit 10
|
</select>
|
|
<resultMap id="BaseResultMapInfo" type="cn.besteam.modules.medical.vo.MwCollectCollectTrajectoryVO">
|
<result column="creator" property="creator" />
|
<collection property="detailList" ofType="cn.besteam.modules.medical.vo.MwCollectCollectTrajectoryDetailVO">
|
<result column="id" property="id"/>
|
<result column="department_name" property="departmentName"/>
|
<result column="code" property="code"/>
|
<result column="create_time" property="createTime"/>
|
</collection>
|
</resultMap>
|
<!--获取收集轨迹-->
|
<select id="getCollectTrajectory" resultMap="BaseResultMapInfo">
|
SELECT
|
*
|
FROM
|
(
|
SELECT DISTINCT
|
creator
|
FROM
|
mw_collect_record
|
<where>
|
<if test="dto.hospitalIdList != null and dto.hospitalIdList.size > 0 ">
|
and hospital_id in
|
<foreach collection="dto.hospitalIdList" item="tempId" open="(" close=")" separator=",">
|
#{tempId}
|
</foreach>
|
</if>
|
<if test="dto.delFlag !=null">
|
and del_flag = #{dto.delFlag}
|
</if>
|
<if test="dto.auditStatus !=null">
|
and audit_status = #{dto.auditStatus}
|
</if>
|
</where>
|
) s
|
LEFT JOIN (
|
SELECT
|
cr.id,
|
cr.create_time,
|
cr. CODE,
|
cr.department_name,
|
cr.creator
|
FROM
|
mw_collect_record cr
|
<where>
|
<if test="dto.hospitalIdList != null and dto.hospitalIdList.size > 0 ">
|
and cr.hospital_id in
|
<foreach collection="dto.hospitalIdList" item="tempId" open="(" close=")" separator=",">
|
#{tempId}
|
</foreach>
|
</if>
|
<if test="dto.startTime !=null">
|
<![CDATA[
|
and date_format( cr.create_time, '%Y-%m-%d %H:%i:%s' ) >= date_format( #{dto.startTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="dto.endTime !=null">
|
<![CDATA[
|
and date_format( cr.create_time, '%Y-%m-%d %H:%i:%s' ) <= date_format( #{dto.endTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="dto.delFlag !=null">
|
and cr.del_flag = #{dto.delFlag}
|
</if>
|
<if test="dto.auditStatus !=null">
|
and cr.audit_status = #{dto.auditStatus}
|
</if>
|
</where>
|
) s1 ON s.creator = s1.creator
|
|
order by s1.create_time asc
|
</select>
|
<!--获取收集轨迹总数量-->
|
<select id="getCollectTrajectoryCount" resultType="int">
|
SELECT count(DISTINCT creator)
|
FROM
|
mw_collect_record
|
<where>
|
<if test="dto.hospitalIdList != null and dto.hospitalIdList.size > 0 ">
|
and hospital_id in
|
<foreach collection="dto.hospitalIdList" item="tempId" open="(" close=")" separator=",">
|
#{tempId}
|
</foreach>
|
</if>
|
<if test="dto.delFlag !=null">
|
and del_flag = #{dto.delFlag}
|
</if>
|
<if test="dto.auditStatus !=null">
|
and audit_status = #{dto.auditStatus}
|
</if>
|
</where>
|
</select>
|
<!--获取医废排行榜(小程序端)-->
|
<select id="getMedicalStatistics" resultType="map">
|
SELECT
|
DATE_FORMAT(cr.create_time,"%Y-%m") as month,sum(cr.weight) as weights,count(1) as couns
|
FROM
|
mw_collect_record cr
|
<where>
|
<if test="dto.hospitalIdList != null and dto.hospitalIdList.size > 0 ">
|
and cr.hospital_id in
|
<foreach collection="dto.hospitalIdList" item="tempId" open="(" close=")" separator=",">
|
#{tempId}
|
</foreach>
|
</if>
|
<if test="dto.startTime !=null">
|
<![CDATA[
|
and date_format( cr.create_time, '%Y-%m-%d %H:%i:%s' ) >= date_format( #{dto.startTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="dto.endTime !=null">
|
<![CDATA[
|
and date_format( cr.create_time, '%Y-%m-%d %H:%i:%s' ) <= date_format( #{dto.endTime} , '%Y-%m-%d %H:%i:%s' )
|
]]>
|
</if>
|
<if test="dto.delFlag !=null">
|
and cr.del_flag = #{dto.delFlag}
|
</if>
|
<if test="dto.auditStatus !=null">
|
and cr.audit_status = #{dto.auditStatus}
|
</if>
|
</where>
|
GROUP BY DATE_FORMAT(cr.create_time,"%Y-%m")
|
</select>
|
|
<!--获取出库运输信息-->
|
<select id="getTransitInfoList" resultType="cn.besteam.modules.medical.vo.MwTransitConfigSelectVO">
|
SELECT DISTINCT
|
transit_company AS transitCompany,
|
engine_driver AS engineDriver,
|
license_plate AS licensePlate
|
FROM
|
mw_checkout_record
|
WHERE
|
hospital_id IN
|
<foreach collection="hospitalIds" item="tempId" open="(" close=")" separator=",">
|
#{tempId}
|
</foreach>
|
</select>
|
|
<select id="getDisposalMonthlyReport" resultType="cn.besteam.modules.report.dto.DisposalMonthlyReportVoItemDto">
|
select
|
cc.id,
|
cc.`name`,
|
sum(cc.num1) as num1,
|
sum(cc.num2) as num2
|
from (
|
select
|
aa.id,
|
aa.`name`,
|
count(1) as num1,
|
0 as num2
|
from (
|
select
|
b.id,
|
b.depart_name as `name`,
|
c.id as num1
|
from (
|
select * from mw_collect_record where del_flag = 0 and audit_status = 2
|
<if test="null != hospitalIds">
|
and hospital_id in
|
<foreach collection="hospitalIds" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="null != startTime and '' != startTime and null != endTime and '' != endTime">
|
and DATE_FORMAT(checkout_time, '%Y-%m-%d') between #{startTime} and #{endTime}
|
</if>
|
<if test="null != dictTypeId">
|
and waste_type in
|
<foreach collection="dictTypeId" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
) a
|
left join sys_department b on (a.hospital_id = b.id)
|
left join (
|
select a.id from sys_department a
|
left join sys_dict_item b on (a.office_type = b.id)
|
where a.org_type = 4 and a.status = 1 and a.del_flag = 0 and b.dict_id = 5 and b.item_value != 1 and a.is_warehouse = 0
|
) c on (a.department_id = c.id)
|
left join sys_department e on(b.parent_id = e.id)
|
left join sys_department f on(e.parent_id = f.id)
|
left join sys_department g on(f.parent_id = g.id)
|
where 1 = 1
|
<if test="null != departmentId">
|
and (e.id = #{departmentId} or f.id = #{departmentId} or g.id = #{departmentId})
|
</if>
|
group by a.hospital_id, c.id
|
) as aa group by aa.id, aa.`name`
|
|
union all
|
|
select
|
bb.id,
|
bb.`name`,
|
0 as num1,
|
count(1) as num2
|
from (
|
select
|
b.id,
|
b.depart_name as `name`,
|
0 as num1,
|
count(d.id) as num2
|
from (
|
select * from mw_collect_record where del_flag = 0 and audit_status = 2
|
<if test="null != hospitalIds">
|
and hospital_id in
|
<foreach collection="hospitalIds" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="null != startTime and '' != startTime and null != endTime and '' != endTime">
|
and DATE_FORMAT(checkout_time, '%Y-%m-%d') between #{startTime} and #{endTime}
|
</if>
|
<if test="null != dictTypeId">
|
and waste_type in
|
<foreach collection="dictTypeId" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
) a
|
left join sys_department b on (a.hospital_id = b.id)
|
left join sys_department d on (a.department_id = d.id and d.is_warehouse = 1)
|
left join sys_department e on(b.parent_id = e.id)
|
left join sys_department f on(e.parent_id = f.id)
|
left join sys_department g on(f.parent_id = g.id)
|
where 1 = 1
|
<if test="null != departmentId">
|
and (e.id = #{departmentId} or f.id = #{departmentId} or g.id = #{departmentId})
|
</if>
|
group by a.hospital_id
|
) as bb
|
group by bb.id, bb.`name`
|
) as cc
|
<if test="null != keyWord">
|
where cc.id in (select hospital_id from mw_checkout_record where
|
<foreach collection="keyWord" item="item" index="index" open="(" separator="," close=")">
|
transit_company like CONCAT('%', #{item}, '%')
|
</foreach>
|
group by hospital_id
|
)
|
</if>
|
group by cc.id, cc.`name`
|
|
</select>
|
|
<!--<if test="null != startTime and '' != startTime and null != endTime and '' != endTime">
|
and DATE_FORMAT(checkout_time, '%Y-%m-%d') between #{startTime} and #{endTime}
|
</if>-->
|
<select id="getDisposalMonthlyReportSum" resultType="cn.besteam.modules.report.dto.DisposalMonthlyReportSumDto">
|
<if test="null != status and 1 == status">
|
select
|
ifnull(sum(weight), 0) as weight,waste_type as wasteType,hospital_id as hospitalId
|
from mw_collect_record
|
where audit_status = 2 and del_flag = 0
|
<if test="null != hospitalIds">
|
and hospital_id in
|
<foreach collection="hospitalIds" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="null != startTime and '' != startTime and null != endTime and '' != endTime">
|
and DATE_FORMAT(create_time, '%Y-%m-%d') between #{startTime} and #{endTime}
|
</if>
|
<if test="null != dictTypeId">
|
and waste_type = #{dictTypeId}
|
</if>
|
group by waste_type,hospital_id
|
</if>
|
<if test="null != status and 2 == status">
|
select
|
ifnull(sum(weight), 0) as weight,waste_type as wasteType,hospital_id as hospitalId
|
from mw_collect_record
|
where audit_status = 2 and del_flag = 0 and status =3
|
<if test="null != hospitalIds">
|
and hospital_id in
|
<foreach collection="hospitalIds" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="null != startTime and '' != startTime and null != endTime and '' != endTime">
|
and DATE_FORMAT(checkout_time, '%Y-%m-%d') between #{startTime} and #{endTime}
|
</if>
|
<if test="null != dictTypeId">
|
and waste_type = #{dictTypeId}
|
</if>
|
group by waste_type,hospital_id
|
</if>
|
<if test="null != status and 3 == status">
|
select
|
ifnull(sum(weight), 0) as weight,waste_type as wasteType,hospital_id as hospitalId
|
from mw_collect_record
|
where audit_status = 2 and del_flag = 0 and status = 2
|
<if test="null != hospitalIds">
|
and hospital_id in
|
<foreach collection="hospitalIds" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="null != dictTypeId">
|
and waste_type = #{dictTypeId}
|
</if>
|
group by waste_type,hospital_id
|
</if>
|
</select>
|
<select id="getTotalNonCheckout" resultType="java.lang.Double"
|
parameterType="java.util.List">
|
SELECT
|
COALESCE(SUM( store_weight ) ,0)
|
FROM
|
mw_collect_record
|
<where>
|
STATUS = 2
|
AND store_time IS NOT NULL
|
AND checkout_time IS NULL
|
AND del_flag = 0
|
AND audit_status = 2
|
<if test="null != departmentIdList">
|
and hospital_id in
|
<foreach collection="departmentIdList" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="null != wasteTypes">
|
and waste_type_str in
|
<foreach collection="wasteTypes" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
</where>
|
</select>
|
</mapper>
|