<?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.ruoyi.pay.mapper.PaySalaryReportMapper">

    <resultMap type="com.ruoyi.pay.domain.PaySalaryReport" id="PaySalaryReportResult">
        <result property="id" column="id"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="year" column="year"/>
        <result property="month" column="month"/>
        <result property="deptId" column="dept_id"/>
        <result property="deptName" column="dept_name"/>
        <result property="employeeId" column="employee_id"/>
        <result property="employeeName" column="employee_name"/>
        <result property="basicSalary" column="basic_salary"/>
        <result property="actuallyDays" column="actually_days"/>
        <result property="actuallyHours" column="actually_hours"/>
        <result property="dayWorkHours" column="day_work_hours"/>
        <result property="workOrderHours" column="work_order_hours"/>
        <result property="overtimeWorkHours" column="overtime_work_hours"/>
        <result property="rigongHelpHours" column="rigong_help_hours"/>
        <result property="dayWorkPay" column="day_work_pay"/>
        <result property="workOrderPay" column="work_order_pay"/>
        <result property="overtime" column="overtime"/>
        <result property="banggongPay" column="banggong_pay"/>
        <result property="zhibanOrLahuo" column="zhiban_or_lahuo"/>
        <result property="holiday" column="holiday"/>
        <result property="post" column="post"/>
        <result property="phoneCharge" column="phone_charge"/>
        <result property="contract" column="contract"/>
        <result property="fullTime" column="full_time"/>
        <result property="diffOfLastMonth" column="diff_of_last_month"/>
        <result property="shoudPayMoney" column="shoud_pay_money"/>
        <result property="late" column="late"/>
        <result property="insurance" column="insurance"/>
        <result property="actuallyPayMoney" column="actually_pay_money"/>
        <result property="allButieData" column="all_butie_data"/>
        <result property="note" column="note"/>
        <result property="empQuery" column="emp_query"/>
    </resultMap>

    <select id="queryLastMonthReport"  resultMap="PaySalaryReportResult">
        SELECT * FROM `pay_salary_report` s
       <where>
             s.`month`=(select max(month) from `pay_salary_report`  where
                              `year`= (select max(year) maxYear from `pay_salary_report` ${ew.customSqlSegment})
                                      <if test="ew.sqlSegment != null and ew.sqlSegment != ''"> and ${ew.sqlSegment} </if>  )
           <if test="ew.sqlSegment != null and ew.sqlSegment != ''"> and ${ew.sqlSegment} </if>
        </where>
        <!--${ew.customSqlSegment}-->

    </select>
</mapper>
