医院废弃物信息化管理平台
“mitao”
2025-12-24 3763145f34d7706923d55edc32f5cfbc8bc08b92
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?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.MwServicePeriodMapper">
 
 
    <select id="getServicePeriodList" resultType="cn.besteam.modules.medical.vo.MwServicePeriodListDTO">
        select * from (
            select
            a.id,
            CONCAT(g.depart_name, '/', f.depart_name, '/', e.depart_name) as department,
            a.depart_name as hospital,
            DATE_FORMAT(a.expire_date, '%Y-%m-%d %H:%i:%s') as expireDate,
            if(now() > a.expire_date, 1, 0) as isExpire,
            if(DATE_ADD(now(), INTERVAL IFNULL(a.reminder_days, 0) DAY) > a.expire_date, 1, 0) as aboutToExpire,
            a.reminder_days as reminderDays,
            a.service_charge as serviceCharge,
            d.item_text as serviceUnit
            from sys_department a
            left join mw_service_period c on (a.id = c.department_id and c.pay_status = 1 and c.`status` = 1 and c.del_flag = 0)
            left join sys_dict_item d on (a.service_unit = d.id)
            left join sys_department e on(a.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 a.status = 1 and a.del_flag = 0 and a.org_type = 2
            <if test="null != dto.departmentId">
                and (e.id = #{dto.departmentId} or f.id = #{dto.departmentId} or g.id = #{dto.departmentId})
            </if>
            <if test="null != dto.serviceUnit">
                and a.service_unit = #{dto.serviceUnit}
            </if>
            order by a.create_time desc
        ) as aa where 1 = 1
        <if test="null != dto.isExpireexpired">
            and aa.isExpire = #{dto.isExpireexpired}
        </if>
        <if test="null != dto.aboutToExpire">
            and aa.aboutToExpire = #{dto.aboutToExpire}
        </if>
    </select>
 
 
 
    <select id="getServicePeriodHistoryRecord" resultType="cn.besteam.modules.medical.vo.MwServicePeriodListDTO">
        select
        DATE_FORMAT(a.update_time, '%Y-%m-%d %H:%i:%s') as createTime,
        DATE_FORMAT(a.expire_date, '%Y-%m-%d %H:%i:%s') as expireDate,
        a.reminder_days as reminderDays,
        a.service_charge as serviceCharge,
        b.`name` as createUser,
        a.note,
        c.item_text as serviceUnit
        from mw_service_period_log a
        left join sys_user b on (a.create_user_id = b.id)
        left join sys_dict_item c on (a.service_unit = c.id)
        where  a.department_id = #{id} order by a.create_time desc
    </select>
 
 
    <select id="getRenewOrderList" resultType="cn.besteam.modules.medical.dto.RenewOrderResponseVO">
        select
        a.id,
        c.depart_name as departmentName,
        b.depart_name as hospitalName,
        a.`code`,
        DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') as orderTime,
        a.pay_status as payStatus,
        b.service_charge as serviceCharge,
        DATE_FORMAT(a.pay_time, '%Y-%m-%d %H:%i:%s') as payTime,
        a.pay_type as payType,
        a.pay_amount as payMoney,
        a.order_number as orderNumber,
        a.is_invoiced as isInvoiced,
        if(a.is_invoiced in (0, 2) and b.service_unit is not null, 1, 0) as canVote
        from mw_service_period a
        left join sys_department b on (a.department_id = b.id)
        left join sys_department c on (b.parent_id = c.id)
        where a.`status` = 1 and a.del_flag = 0
        <if test="vo.hospitalIdList != null and vo.hospitalIdList.size > 0 ">
            and a.department_id in
            <foreach collection="vo.hospitalIdList" item="tempId" open="(" close=")" separator=",">
                #{tempId}
            </foreach>
        </if>
        <if test="null != vo.code and '' != vo.code">
            and a.`code` like CONCAT('%', #{vo.code}, '%')
        </if>
        <if test="null != vo.payStatus">
            and a.pay_status = #{vo.payStatus}
        </if>
        <if test="null != vo.isInvoiced">
            and a.is_invoiced = #{vo.isInvoiced}
        </if>
        <if test="null != vo.startTime and '' != vo.startTime and null != vo.endTime and '' != vo.endTime">
            and a.create_time between #{vo.startTime} and #{vo.endTime}
        </if>
        order by a.create_time desc
    </select>
 
 
    <select id="getRenewOrderOne" resultType="cn.besteam.modules.medical.dto.RenewOrderResponseVO">
        select
        a.id,
        c.depart_name as departmentName,
        b.depart_name as hospitalName,
        a.`code`,
        DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') as orderTime,
        a.pay_status as payStatus,
        a.service_charge as serviceCharge,
        DATE_FORMAT(a.pay_time, '%Y-%m-%d %H:%i:%s') as payTime,
        a.pay_type as payType,
        a.pay_amount as payMoney,
        a.order_number as orderNumber,
        a.is_invoiced as isInvoiced,
        if(a.is_invoiced in (0, 2) and a.service_unit is not null, 1, 0) as canVote
        from mw_service_period a
        left join sys_department b on (a.department_id = b.id)
        left join sys_department c on (b.parent_id = c.id)
        where a.id = #{id}
    </select>
</mapper>