mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
<?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.dg.core.db.gen.mapper.GuideEvolveMapper">
 
    <resultMap type="com.dg.core.db.gen.entity.GuideEvolveEntity" id="GuideEvolveResult">
        <id     property="id"      column="id"      />
        <id     property="departmentalId"      column="departmental_id"      />
        <id     property="toUserId"      column="to_user_id"      />
        <id     property="fromUserId"      column="from_user_id"      />
        <id     property="state"      column="state"      />
        <id     property="remark"      column="remark"      />
        <id     property="guideId"      column="guide_id"      />
        <id     property="transactionId"      column="transaction_id"      />
        <id     property="accessoryId"      column="accessory_id"      />
        <id     property="accessoryName"      column="accessory_name"      />
        <id     property="accessoryUrl"      column="accessory_url"      />
        <id     property="createTime"      column="create_time"      />
        <id     property="updateTime"      column="update_time"      />
        <id     property="fromDepartmentalId"      column="from_departmental_id"      />
        <id     property="videoUrl"      column="video_url"      />
        <id     property="pictureUrl"      column="picture_url"      />
        <id     property="guideOrderNum"      column="guide_order_num"      />
        <id     property="isTimeout"      column="is_timeout"      />
 
    </resultMap>
 
    <sql id="selectGuideEvolveVo">
        SELECT
            id,
            departmental_id,
            (select user_name from automessage_sys_user where a.to_user_id=user_id)toUserName,
            (select user_name from automessage_sys_user where a.from_user_id=user_id)fromUserName,
            to_user_id,
            from_user_id,
            state,
            remark,
            guide_id,
            transaction_id,
            accessory_id,
            accessory_name,
            accessory_url,
            from_departmental_id,
            video_url,
            picture_url,
            create_time,
            update_time,
            guide_order_num,
            is_timeout
        FROM
            automessage_guide_evolve a
    </sql>
 
    <select id="selectConfigList"  resultMap="GuideEvolveResult">
        <include refid="selectGuideEvolveVo"/>
        <where>
            <if test="guideId != null and guideId != ''">
                AND guide_id=#{guideId}
            </if>
        </where>
        order by create_time desc
    </select>
 
    <select id="selectHideList" resultMap="GuideEvolveResult">
        SELECT
            id,
            departmental_id,
            IFNULL(
                    (select  concat(substring(user_name,1,1),'老师') from automessage_sys_user where a.to_user_id=user_id and (user_type in (1,2) or is_division_head=1)),
                    (select user_name from automessage_sys_user where a.to_user_id=user_id))toUserName,
            IFNULL(
                    (select  concat(substring(user_name,1,1),'老师') from automessage_sys_user where a.from_user_id=user_id and (user_type in (1,2) or is_division_head=1)),
                    (select user_name from automessage_sys_user where a.from_user_id=user_id))fromUserName,
            to_user_id,
            from_user_id,
            state,
            remark,
            guide_id,
            transaction_id,
            accessory_id,
            accessory_name,
            accessory_url,
            from_departmental_id,
            video_url,
            picture_url,
            create_time,
            update_time,
            guide_order_num,
            is_timeout
        FROM
            automessage_guide_evolve a
        <where>
            <if test="guideId != null and guideId != ''">
                AND guide_id=#{guideId}
            </if>
        </where>
        order by create_time desc
    </select>
 
 
    <insert id="insertConfig" parameterType="com.dg.core.db.gen.entity.GuideEvolveEntity">
        insert into automessage_guide_evolve (
        <if test="departmentalId != null and departmentalId != '' ">departmental_id,</if>
        <if test="toUserId != null and toUserId != '' ">to_user_id,</if>
        <if test="fromUserId != null and fromUserId != '' ">from_user_id,</if>
        <if test="state != null and state != '' ">state,</if>
        <if test="remark != null and remark != '' ">remark,</if>
        <if test="guideId != null and guideId != '' ">guide_id,</if>
        <if test="transactionId != null and transactionId != '' ">transaction_id,</if>
        <if test="accessoryId != null and accessoryId != '' ">accessory_id,</if>
        <if test="accessoryName != null and accessoryName != '' ">accessory_name,</if>
        <if test="accessoryUrl != null and accessoryUrl != '' ">accessory_url,</if>
        <if test="fromDepartmentalId != null and fromDepartmentalId != '' ">from_departmental_id,</if>
        <if test="videoUrl != null and videoUrl != '' ">video_url,</if>
        <if test="pictureUrl != null and pictureUrl != '' ">picture_url,</if>
        <if test="guidOrderNum != null and guidOrderNum != '' ">guide_order_num,</if>
        <if test="isTimeout != null and isTimeout != '' ">is_timeout,</if>
        update_time,
        create_time
        )values(
        <if test="departmentalId != null and departmentalId != '' ">#{departmentalId},</if>
        <if test="toUserId != null and toUserId != '' ">#{toUserId},</if>
        <if test="fromUserId != null and fromUserId != '' ">#{fromUserId},</if>
        <if test="state != null and state != '' ">#{state},</if>
        <if test="remark != null and remark != '' ">#{remark},</if>
        <if test="guideId != null and guideId != '' ">#{guideId},</if>
        <if test="transactionId != null and transactionId != '' ">#{transactionId},</if>
        <if test="accessoryId != null and accessoryId != '' ">#{accessoryId},</if>
        <if test="accessoryName != null and accessoryName != '' ">#{accessoryName},</if>
        <if test="accessoryUrl != null and accessoryUrl != '' ">#{accessoryUrl},</if>
        <if test="fromDepartmentalId != null and fromDepartmentalId != '' ">#{fromDepartmentalId},</if>
        <if test="videoUrl != null and videoUrl != '' ">#{videoUrl},</if>
        <if test="pictureUrl != null and pictureUrl != '' ">#{pictureUrl},</if>
        <if test="guidOrderNum != null and guidOrderNum != '' ">#{guidOrderNum},</if>
        <if test="isTimeout != null and isTimeout != '' ">#{isTimeout},</if>
        sysdate(),
        sysdate()
        )
    </insert>
 
    <update id="updateConfig" parameterType="com.dg.core.db.gen.entity.GuideEvolveEntity">
        update automessage_guide_evolve
        <set>
            <if test="departmentalId != null and departmentalId != '' ">departmental_id=#{departmentalId},</if>
            <if test="toUserId != null and toUserId != '' ">to_user_id=#{toUserId},</if>
            <if test="fromUserId != null and fromUserId != '' ">from_user_id=#{fromUserId},</if>
            <if test="state != null and state != '' ">state=#{state},</if>
            <if test="remark != null and remark != '' ">remark=#{remark},</if>
            <if test="guideId != null and guideId != '' ">guide_id=#{guideId},</if>
            <if test="transactionId != null and transactionId != '' ">transaction_id=#{transactionId},</if>
            <if test="accessoryId != null and accessoryId != '' ">accessory_id=#{accessoryId},</if>
            <if test="accessoryName != null and accessoryName != '' ">accessory_name=#{accessoryName},</if>
            <if test="accessoryUrl != null and accessoryUrl != '' ">accessory_url=#{accessoryUrl},</if>
            <if test="fromDepartmentalId != null and fromDepartmentalId != '' ">from_departmental_id=#{fromDepartmentalId},</if>
            <if test="videoUrl != null and videoUrl != '' ">video_url=#{videoUrl},</if>
            <if test="pictureUrl != null and pictureUrl != '' ">picture_url=#{pictureUrl},</if>
            <if test="isTimeout != null and isTimeout != '' ">is_timeout=#{isTimeout},</if>
            update_time=sysdate()
        </set>
        where  id= #{Id}
    </update>
 
    <update id="updateGuid" parameterType="com.dg.core.db.gen.entity.GuideEvolveEntity">
        UPDATE automessage_guide_evolve
        SET guide_id = (SELECT id from automessage_guide_repair_order where order_num=automessage_guide_evolve.guide_order_num )
        WHERE guide_id IS NULL
    </update>
 
    <delete id="deleteConfigById" parameterType="string">
        delete from automessage_guide_evolve where id= #{Id}
    </delete>
 
    <select id="countNum" resultType="integer">
        select count(id) from automessage_guide_evolve
    </select>
 
</mapper>