张晓波
2023-12-12 d3e6773ef7cd0e11a444b41ec3da15938fabd85b
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?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.thhy.mobile.modules.biz.login.mapper.SysUserMapper">
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        user_id as userId,
        username as username,
        password as password,
        real_name as realName,
        telphone as telphone,
        photo_url as photoUrl,
        create_user as createUser,
        create_time as createTime,
        is_use as isUse,
        sex as sex,
        email as email,
        version as version,
            sub_admin as subAdmin
    </sql>
 
    <!-- 排除密码列 -->
    <sql id="Without_Pass_Column_List">
        user_id as userId,
        username as username,
        real_name as realName,
        telphone as telphone,
        photo_url as photoUrl,
        create_user as createUser,
        create_time as createTime,
        is_use as isUse,
        sex as sex,
        email as email,
        version as version
    </sql>
 
    <sql id="condition_query">
        <where>
            <trim suffixOverrides=" AND " >
                is_use = 1 AND
                <if test="username!=null and username!=''">
                    username LIKE  concat('%',#{username},'%') AND
                </if>
                <if test="realName!=null and realName!=''">
                    real_name = #{realName} AND
                </if>
                <if test="telphone!=null and telphone!=''">
                    telphone LIKE concat('%',#{telphone},'%') AND
                </if>
                <if test="createTime!=null">
                    create_time = #{createTime} AND
                </if>
                <!--<if test="isUse!=null">
                    is_use = #{isUse} AND
                </if>-->
                <if test="sex!=null">
                    sex = #{sex} AND
                </if>
                <if test="email!=null and email!=''">
                    email = #{email} AND
                </if>
            </trim>
        </where>
    </sql>
 
    <select id="queryByUsername" resultType="com.thhy.mobile.modules.biz.login.entity.SysUsers">
        SELECT
            su.user_id as userId,
            su.username as username,
            su.real_name as realName,
            su.password,
            su.telphone as telphone,
            su.photo_url as photoUrl,
            su.create_user as createUser,
            su.create_time as createTime,
            su.is_use as isUse,
            su.sex as sex,
            su.email as email,
            su.sub_admin as subAdmin,
            su.is_plat as isPlat
        FROM sys_users su
        WHERE (su.username = #{username} OR su.email = #{username} OR su.telphone = #{username})
          AND su.is_use = 1 and su.is_app = 1
    </select>
 
    <select id="queryCompanyByComAdmin" resultType="hashmap">
        select sc.company_id as companyId,sc.company_name as companyName
        from sys_com_su scs
                 left join sys_company sc on sc.company_id = scs.company_id
        where scs.user_id = #{userId}
    </select>
 
    <select id="queryCompanyByUser" resultType="hashmap">
        select sc.company_id as companyId,sc.company_name as companyName from sys_users su
         left join sys_plat_user spu on spu.user_id = su.plat_id
         left join sys_depart_user sdu on sdu.user_id = spu.user_id
         left join sys_com_depart scd on scd.depart_id = sdu.depart_id
         left join sys_company sc on sc.company_id = scd.company_id
        where su.user_id = #{userId} and su.is_use = 1
    </select>
 
    <select id="queryAllProLine" resultType="hashmap">
        select pro_line_id as proLineId,pro_line_name as proLineName from t_pro_line
    </select>
 
    <select id="queryProLineNameById" resultType="string">
        select pro_line_name as proLineName from t_pro_line where pro_line_id = #{proLineId},
    </select>
 
    <select id="countTodayLinePlanByLineId" resultType="int">
        select count(id)
        from t_pro_line_plan plp
        where plp.pro_line_id = #{proLineId} and sysdate() &gt;= plp.set_day_start and sysdate() &lt;= plp.set_day_end
    </select>
 
    <select id="checkPipeExitsByRingNums" resultType="string">
        select group_cancat(a.ringNum) as ringnums
        (select DISTINCT ring_num as ringNum,1 as wl
        from t_pipe_info
        <where>
            <foreach open="ring_num in (" separator="," close=")" collection="ringNumList" item="ringnum" index="ri">
                #{ringnum}
            </foreach>
        </where>
        ) a
        group by a.wl
    </select>
 
    <select id="checkPlanExitsByRingNums" resultType="string">
        select group_cancat(a.ringNum) as ringnums
        (select DISTINCT ring_num as ringNum,1 as wl
        from t_pro_line_plan
        <where>
            <trim suffixOverrides="and">
                <foreach open="ring_num in (" separator="," close=") and" collection="ringNumList" item="ringnum" index="ri">
                    #{ringnum}
                </foreach>
                pro_line_id != #{proLineId} and
                sysdate() &gt;= set_day_start and sysdate() &lt;= set_day_end and
            </trim>
        </where>
        ) a
        group by a.wl
    </select>
 
    <insert id="insertProLinePlan">
        insert into t_pro_line_plan
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id !=null and id !=''">
                id,
            </if>
            <if test="proLineId !=null and proLineId !=''">
                pro_line_id,
            </if>
            <if test="setDayStart != null">
                set_day_start,
            </if>
            <if test="setDayEnd != null">
                set_day_end,
            </if>
            <if test="ringNum != null and ringNum !=''">
                ring_num,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id !=null and id !=''">
                #{id},
            </if>
            <if test="proLineId !=null and proLineId !=''">
                #{proLineId},
            </if>
            <if test="setDayStart != null">
                #{setDayStart},
            </if>
            <if test="setDayEnd != null">
                #{setDayEnd},
            </if>
            <if test="ringNum != null and ringNum !=''">
                #{ringNum},
            </if>
        </trim>
    </insert>
</mapper>