yurk há 2 anos atrás
pai
commit
63eb687542

+ 110 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/UserMapper.xml

@@ -50,5 +50,115 @@
     <sql id="Base_Column_List">
         id, name, phone, password, portrait_url, create_time, role, company_id, department_id, department_cascade, cost, month_cost, salary_type, manage_dept_id, color, is_active, wx_openid, role_id, role_name, cost_apply_date, dingding_userid, dingding_unionid, corpwx_userid, induction_date, inactive_date, position, report_status, superior_id, plate1, plate2, plate3, plate4, plate5, is_ops, job_number, corpwx_deptid, corpwx_real_userid, is_first_login, is_mob_first_login, feishu_userid
     </sql>
+    <!--单独分页获取人员-->
+    <select id="getUserByDepartment" resultType="java.util.Map">
+        SELECT a.id, a.role_id as roleId, a.role_name as roleName, a.name, a.phone, a.portrait_url AS portraitUrl, a.role, a.company_id AS companyId, a.cost,
+        a.department_id AS departmentId, b.department_name AS departmentName, a.department_cascade AS departmentCascade,
+        a.month_cost as monthCost, a.salary_type as salaryType, a.is_active as isActive,date_format(a.`inactive_date`, '%Y-%m-%d') AS inactiveDate, a.cost_apply_date as costApplyDate,a.plate1,a.plate2,a.plate3,a.plate4,a.plate5,
+        a.job_number as jobNumber, DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%m')  as createTime
+        FROM user AS a
+        LEFT JOIN department AS b ON a.department_id = b.department_id
+        WHERE a.company_id = #{companyId}
+        <if test="departmentId != null and companyId != ''">
+            AND a.department_id = #{departmentId}
+        </if>
+        <if test="keyword != null and keyword != ''">
+            AND
+            <choose>
+                <when test="matchingType==0">
+                    a.name like '%${keyword}%'
+                </when>
+                <when test="matchingType==1">
+                    a.phone like '%${keyword}%'
+                </when>
+                <when test="matchingType==2">
+                    a.job_number like '%${keyword}%'
+                </when>
+            </choose>
+        </if>
+        <if test="status != null">
+            AND a.is_active = #{status}
+        </if>
+        <if test="roleId != null">
+            AND a.role_id = #{roleId}
+        </if>
+    </select>
 
+    <!--范围分页获取人员-->
+    <select id="getUserByDepartmentList" resultType="java.util.Map">
+        SELECT a.id,  a.role_id as roleId, a.role_name as roleName,  a.name, a.phone, a.portrait_url AS portraitUrl, a.role, a.company_id AS companyId, a.cost,
+        a.department_id AS departmentId, b.department_name AS departmentName, a.department_cascade AS departmentCascade,
+        a.month_cost as monthCost, a.salary_type as salaryType, a.is_active as isActive,date_format(a.`inactive_date`, '%Y-%m-%d') AS inactiveDate, a.cost_apply_date as costApplyDate,a.plate1,a.plate2,a.plate3,a.plate4,a.plate5,
+        a.job_number as jobNumber, DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%m')  as createTime
+        FROM user AS a
+        LEFT JOIN department AS b ON a.department_id = b.department_id
+        WHERE a.company_id = #{companyId} AND a.department_id IN
+        <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
+            #{departmentId}
+        </foreach>
+        <if test="keyword != null and keyword != ''">
+            AND a.name like '%${keyword}%'
+        </if>
+        <if test="status != null">
+            AND a.is_active = #{status}
+        </if>
+        <if test="roleId != null">
+            AND a.role_id = #{roleId}
+        </if>
+    </select>
+
+
+    <select id="getPushUserList" resultType="java.util.Map">
+        SELECT a.id, a.wx_openid as wxOpenid, a.corpwx_userid as corpwxUserid, a.name, a.phone, b.department_name AS departmentName
+        FROM user AS a LEFT JOIN  department b ON a.department_id = b.department_id
+        WHERE a.company_id = #{companyId}
+        AND (a.wx_openid IS NOT NULL or corpwx_userid is not null)
+        AND a.is_active = 1
+        AND a.report_status =0
+        <choose>
+            <when test="alertType!=null and alertType==1">
+                AND NOT EXISTS(SELECT 1 FROM report WHERE report.`creator_id` = a.id AND report.`create_date` = DATE_FORMAT(date_sub(NOW(),interval 1 day), '%Y-%m-%d'))
+            </when>
+            <otherwise>
+                AND NOT EXISTS(SELECT 1 FROM report WHERE report.`creator_id` = a.id AND report.`create_date` = DATE_FORMAT(NOW(), '%Y-%m-%d'))
+            </otherwise>
+        </choose>
+        <if test="date != null">
+            and not exists (select 1 from leave_sheet where owner_id = a.id and start_date &lt;= #{date} and end_date &gt;= #{date} and leave_sheet.status = 0)
+        </if>
+
+    </select>
+
+
+    <select id="getPushDingdingUserList" resultType="java.util.Map">
+        SELECT a.company_id as companyId, a.dingding_userid as dingdingUserid
+        FROM user AS a left join time_type on time_type.company_id = a.company_id
+        left join company on a.company_id = company.id
+        WHERE a.dingding_userid is not null and time_type.alert_time = #{alertTime}
+        AND a.is_active = 1
+        AND a.report_status=0
+        AND company.expiration_date >= NOW()
+        AND NOT EXISTS(SELECT 1 FROM report WHERE report.`creator_id` = a.id AND ((report.`create_date` = DATE_FORMAT(date_sub(NOW(),interval 1 day), '%Y-%m-%d') and time_type.alert_type=1)or(report.`create_date` = DATE_FORMAT(NOW(), '%Y-%m-%d') and time_type.alert_type=0)))
+        <if test="date != null">
+            and not exists (select 1 from leave_sheet where owner_id = a.id and start_date &lt;= #{date} and end_date &gt;= #{date} and leave_sheet.status = 0)
+        </if>
+        order by a.company_id
+    </select>
+    <!--获取项目的参与人的推送id -->
+    <select id="getProjectPushUserList" resultType="java.util.Map">
+        SELECT a.id, a.wx_openid as wxOpenid, a.corpwx_userid as corpwxUserid
+        FROM user AS a
+        WHERE a.wx_openid IS NOT NULL
+        AND a.is_active = 1
+        AND a.id in (select user_id from participation where project_id = #{projectId})
+    </select>
+    <select id="getSimpleNameList" resultType="java.util.HashMap">
+        select id, name, job_number as jobNumber from user
+        ${ew.customSqlSegment}
+    </select>
+
+    <select id="getUserWithDept" resultMap="BaseResultMap2">
+        select user.id, name, department.department_name from user left join department on department.department_id = user.department_id
+        ${ew.customSqlSegment}
+    </select>
 </mapper>