zouyu
2023-11-15 9bf01a5f04e5e1821d48b42706fb492e1bf21d86
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
<?xml version="1.0" encoding="UTF-8"?>
 
<!--
  ~
  ~      Copyright (c) 2018-2025, ztt All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the pig4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: ztt
  ~
  -->
 
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
<mapper namespace="com.chinaztt.mes.basic.mapper.StaffMapper">
 
    <resultMap id="staffMap" type="com.chinaztt.mes.basic.entity.Staff">
        <id property="id" column="id"/>
        <result property="staffNo" column="staff_no"/>
        <result property="staffName" column="staff_name"/>
        <result property="phone" column="phone"/>
        <result property="email" column="email"/>
        <result property="post" column="post"/>
        <result property="postId" column="post_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="createUser" column="create_user"/>
        <result property="updateUser" column="update_user"/>
        <result property="divisionName" column="division_name"/>
        <result property="personnelFactor" column="personnel_factor"/>
        <result property="crewId" column="crew_id"/>
        <result property="personNature" column="person_nature"/>
        <result property="trialDeadline" column="trial_deadline"/>
<!--        <result property="divisionName" column="division_name"/>-->
        <result property="factoryId" column="factory_id"/>
        <result property="factoryName" column="factory_name"/>
        <result property="companyId" column="company_id"/>
        <result property="companyName" column="company_name"/>
    </resultMap>
 
 
    <sql id="staffPage">
           SELECT
        staff."id",staff.division_id,staff.staff_no,staff.staff_name,
                staff.phone,staff.email,bp.post_name post,staff.create_time,staff.update_time,
                staff.create_user,staff.update_user,staff.active,staff.personnel_factor,staff.post_id,
        division.division_name division_name,staff.person_nature,staff.trial_deadline,staff.company_name,staff.factory_name
        FROM
        basic_staff staff
                left join basic_post bp on bp."id"=staff.post_id
        LEFT OUTER JOIN basic_division division ON staff.division_id = division.id
        where staff.active = true ORDER BY create_time DESC
        </sql>
    <select id="getStaffPage" resultMap="staffMap">
        select * from (<include refid="staffPage"/>) a
        <if test="ew.emptyOfWhere == false">
        <where>
            ${ew.SqlSegment}
        </where>
        </if>
    </select>
 
 
    <select id="toResource" resultMap="staffMap">
SELECT
basic_staff.*,
basic_division.division_name division_name
FROM
basic_staff ,
basic_division
WHERE
NOT EXISTS (
SELECT aps_resource.resource_no FROM aps_resource WHERE aps_resource.resource_no = basic_staff.staff_no
) AND
basic_division."id" = basic_staff.division_id
    </select>
    <select id="selectStaffByCrewId" resultMap="staffMap">
        select staff."id",staff.division_id,staff.staff_no,staff.staff_name,
        staff.phone,staff.email,bp.post_name post,staff.create_time,staff.update_time,
        staff.create_user,staff.update_user,staff.active,staff.personnel_factor,staff.post_id,
        bjcs.*,bd.division_name
        from basic_staff staff
        left join basic_join_crew_staff bjcs on bjcs.staff_id=staff."id"
        left join basic_division bd on bd."id"=staff.division_id
        left join basic_post bp on bp."id"=staff.post_id
        where staff.active=true
            <if test="ew.emptyOfWhere == false">
                and ${ew.SqlSegment}
            </if>
    </select>
    <select id="selectStaffById" resultMap="staffMap">
        select bs.*
        from basic_staff bs
        left join basic_join_crew_staff bjcs on bjcs.staff_id=bs."id"
        where bjcs.crew_id=#{id}
    </select>
 
    <select id="selectListAll" resultType="com.chinaztt.mes.basic.entity.Staff">
        select bs.* from basic_staff bs
    </select>
 
    <select id="getStaffByUserId" resultMap="staffMap">
        select bs.*
        from basic_staff bs
        left join sys_user u on u.staff_id = bs."id"
        where
        u.user_id = #{userId}
    </select>
    <select id="chooseStaff" resultType="java.util.Map">
        select id,staff_no "staffNo", staff_name "staffName"
        from basic_staff
    </select>
</mapper>