<?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.engine.salary.mapper.InsuranceExportMapper">
    <select id="exportAccount" resultType="com.engine.salary.entity.siexport.po.AccountExportPO">
        SELECT a.*,
               a.department_name AS fixedDepartmentName,
               a.status         AS fixedUserStatus,
               e.lastname       AS userName,
               e.MOBILE         AS telephone,
               d.departmentname AS departmentName,
               e.STATUS         AS userStatus,
               e.certificatenum as idNo,
               e.workcode       AS workcode
        FROM (
                 SELECT *
                 from hrsa_bill_detail
                 WHERE delete_type = 0
                   AND bill_month = #{param.billMonth}
                   AND payment_status = #{paymentStatus}
                   AND payment_organization = #{param.paymentOrganization}
             ) a
                 LEFT JOIN hrmresource e ON e.ID = a.employee_id
                 LEFT JOIN hrmdepartment d ON d.id = e.departmentid
                 LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
        where e.status not in (7)

        <!-- 排序 -->
        <if test="param.orderRule != null">
            ORDER BY  ${param.orderRule.orderRule}  ${param.orderRule.ascOrDesc}
        </if>
    </select>
    <select id="exportAccount" resultType="com.engine.salary.entity.siexport.po.AccountExportPO" databaseId="oracle">
        SELECT a.*,
               a.department_name AS fixedDepartmentName,
               a.status         AS fixedUserStatus,
               e.lastname       AS userName,
               e.MOBILE         AS telephone,
               d.departmentname AS departmentName,
               e.STATUS         AS userStatus,
               e.certificatenum as idNo,
               e.workcode       AS workcode
        FROM (
                 SELECT *
                 from hrsa_bill_detail
                 WHERE delete_type = 0
                   AND bill_month = #{param.billMonth}
                   AND payment_status = #{paymentStatus}
                   AND payment_organization = #{param.paymentOrganization}
             ) a
                 LEFT JOIN hrmresource e ON e.ID = a.employee_id
                 LEFT JOIN hrmdepartment d ON d.id = e.departmentid
                 LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
        where e.status not in (7)

        <!-- 排序 -->
        <if test="param.orderRule != null">
            ORDER BY  ${param.orderRule.orderRule}  ${param.orderRule.ascOrDesc}
        </if>
    </select>
    <select id="exportAccount" resultType="com.engine.salary.entity.siexport.po.AccountExportPO" databaseId="sqlserver">
        SELECT a.*,
               a.department_name AS fixedDepartmentName,
               a.status         AS fixedUserStatus,
               e.lastname       AS userName,
               e.MOBILE         AS telephone,
               d.departmentname AS departmentName,
               e.STATUS         AS userStatus,
               e.certificatenum as idNo,
               e.workcode       AS workcode
        FROM (
                 SELECT *
                 from hrsa_bill_detail
                 WHERE delete_type = 0
                   AND bill_month = #{param.billMonth}
                   AND payment_status = #{paymentStatus}
                   AND payment_organization = #{param.paymentOrganization}
             ) a
                 LEFT JOIN hrmresource e ON e.ID = a.employee_id
                 LEFT JOIN hrmdepartment d ON d.id = e.departmentid
                 LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
        where e.status not in (7)

        <!-- 排序 -->
        <if test="param.orderRule != null">
            ORDER BY  ${param.orderRule.orderRule}  ${param.orderRule.ascOrDesc}
        </if>
    </select>

    <select id="exportExcelAccount" resultType="com.engine.salary.entity.siexport.po.ExcelAccountExportPO">
        SELECT
        a.*,e.lastname AS userName,e.MOBILE AS telephone,d.departmentname AS departmentName,e.STATUS AS userStatus,e.workcode AS workcode
        FROM(
        SELECT * from hrsa_excel_bill_detail
        WHERE  delete_type = 0 AND bill_month = #{param.billMonth} AND payment_status = #{param.paymentStatus} AND payment_organization = #{param.paymentOrganization}
        )a
        LEFT JOIN hrmresource e ON e.ID = a.employee_id
        LEFT JOIN hrmdepartment d ON d.id = e.departmentid
        where          e.status not in (7)

    </select>
    <select id="exportExcelAccount" resultType="com.engine.salary.entity.siexport.po.ExcelAccountExportPO" databaseId="oracle">
         SELECT
        a.*,e.lastname AS userName,e.MOBILE AS telephone,d.departmentname AS departmentName,e.STATUS AS userStatus,e.workcode AS workcode
        FROM(
        SELECT * from hrsa_excel_bill_detail
        WHERE  delete_type = 0 AND bill_month = #{param.billMonth} AND payment_status = #{param.paymentStatus} AND payment_organization = #{param.paymentOrganization}
        )a
        LEFT JOIN hrmresource e ON e.ID = a.employee_id
        LEFT JOIN hrmdepartment d ON d.id = e.departmentid
        where          e.status not in (7)

     </select>
    <select id="exportExcelAccount" resultType="com.engine.salary.entity.siexport.po.ExcelAccountExportPO" databaseId="sqlserver">
           SELECT
        a.*,e.lastname AS userName,e.MOBILE AS telephone,d.departmentname AS departmentName,e.STATUS AS userStatus,e.workcode AS workcode
        FROM(
        SELECT * from hrsa_excel_bill_detail
        WHERE  delete_type = 0 AND bill_month = #{param.billMonth} AND payment_status = #{param.paymentStatus} AND payment_organization = #{param.paymentOrganization}
        )a
        LEFT JOIN hrmresource e ON e.ID = a.employee_id
        LEFT JOIN hrmdepartment d ON d.id = e.departmentid
        where          e.status not in (7)

     </select>


    <select id="exportRecessionAccount" resultType="com.engine.salary.entity.siexport.po.AccountExportPO">
        SELECT a.*,
        a.department_name AS fixedDepartmentName,
        a.status         AS fixedUserStatus,
        e.lastname       AS userName,
        e.MOBILE         AS telephone,
        d.departmentname AS departmentName,
        e.STATUS         AS userStatus,
        e.certificatenum as idNo,
        e.workcode       AS workcode
        FROM (
        SELECT *
        from hrsa_bill_detail
        WHERE delete_type = 0
        AND bill_month = #{param.billMonth}
        AND payment_status = #{paymentStatus}
        AND creator = #{param.creator}
        AND payment_organization = #{param.paymentOrganization}
        ) a
        LEFT JOIN hrmresource e ON e.ID = a.employee_id
        LEFT JOIN hrmdepartment d ON d.id = e.departmentid
        LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
        where e.status not in (7)

        <!-- 排序 -->
        <if test="param.orderRule != null">
            ORDER BY  ${param.orderRule.orderRule}  ${param.orderRule.ascOrDesc}
        </if>
    </select>
    <select id="exportRecessionAccount" resultType="com.engine.salary.entity.siexport.po.AccountExportPO" databaseId="oracle">
        SELECT a.*,
        a.department_name AS fixedDepartmentName,
        a.status         AS fixedUserStatus,
        e.lastname       AS userName,
        e.MOBILE         AS telephone,
        d.departmentname AS departmentName,
        e.STATUS         AS userStatus,
        e.certificatenum as idNo,
        e.workcode       AS workcode
        FROM (
        SELECT *
        from hrsa_bill_detail
        WHERE delete_type = 0
        AND bill_month = #{param.billMonth}
        AND payment_status = #{paymentStatus}
        AND creator = #{param.creator}
        AND payment_organization = #{param.paymentOrganization}
        ) a
        LEFT JOIN hrmresource e ON e.ID = a.employee_id
        LEFT JOIN hrmdepartment d ON d.id = e.departmentid
        LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
        where e.status not in (7)

        <!-- 排序 -->
        <if test="param.orderRule != null">
            ORDER BY  ${param.orderRule.orderRule}  ${param.orderRule.ascOrDesc}
        </if>
    </select>
    <select id="exportRecessionAccount" resultType="com.engine.salary.entity.siexport.po.AccountExportPO" databaseId="sqlserver">
        SELECT a.*,
        a.department_name AS fixedDepartmentName,
        a.status         AS fixedUserStatus,
        e.lastname       AS userName,
        e.MOBILE         AS telephone,
        d.departmentname AS departmentName,
        e.STATUS         AS userStatus,
        e.certificatenum as idNo,
        e.workcode       AS workcode
        FROM (
        SELECT *
        from hrsa_bill_detail
        WHERE delete_type = 0
        AND bill_month = #{param.billMonth}
        AND payment_status = #{paymentStatus}
        AND creator = #{param.creator}
        AND payment_organization = #{param.paymentOrganization}
        ) a
        LEFT JOIN hrmresource e ON e.ID = a.employee_id
        LEFT JOIN hrmdepartment d ON d.id = e.departmentid
        LEFT JOIN hrmsubcompany c ON c.id = e.subcompanyid1
        where e.status not in (7)

        <!-- 排序 -->
        <if test="param.orderRule != null">
            ORDER BY  ${param.orderRule.orderRule}  ${param.orderRule.ascOrDesc}
        </if>
    </select>

    <select id="exportExtAccount" resultType="com.engine.salary.entity.siexport.po.AccountExportPO">
        SELECT a.*,
        a.department_name AS fixedDepartmentName,
        a.status         AS fixedUserStatus,
        e.username       AS userName,
        e.mobile         AS telephone,
        d.departmentname AS departmentName,
        e.status         AS userStatus,
        e.workcode       AS workcode
        FROM (
        SELECT *
        from hrsa_bill_detail
        WHERE delete_type = 0
        AND bill_month = #{param.billMonth}
        AND payment_status = #{paymentStatus}
        AND payment_organization = #{param.paymentOrganization}
        ) a
        LEFT JOIN hrsa_external_employee e ON e.ID = a.employee_id
        LEFT JOIN hrmdepartment d ON d.id = e.department_id
        LEFT JOIN hrmsubcompany c ON c.id = e.subcompany_id
        where e.status not in (7)
        <!-- 排序 -->
    </select>
    <select id="exportExtAccount" resultType="com.engine.salary.entity.siexport.po.AccountExportPO" databaseId="oracle">
        SELECT a.*,
        a.department_name AS fixedDepartmentName,
        a.status         AS fixedUserStatus,
        e.username       AS userName,
        e.mobile         AS telephone,
        d.departmentname AS departmentName,
        e.status         AS userStatus,
        e.workcode       AS workcode
        FROM (
        SELECT *
        from hrsa_bill_detail
        WHERE delete_type = 0
        AND bill_month = #{param.billMonth}
        AND payment_status = #{paymentStatus}
        AND payment_organization = #{param.paymentOrganization}
        ) a
        LEFT JOIN hrsa_external_employee e ON e.ID = a.employee_id
        LEFT JOIN hrmdepartment d ON d.id = e.department_id
        LEFT JOIN hrmsubcompany c ON c.id = e.subcompany_id
        where e.status not in (7)
        <!-- 排序 -->
    </select>
    <select id="exportExtAccount" resultType="com.engine.salary.entity.siexport.po.AccountExportPO" databaseId="sqlserver">
        SELECT a.*,
        a.department_name AS fixedDepartmentName,
        a.status         AS fixedUserStatus,
        e.username       AS userName,
        e.mobile         AS telephone,
        d.departmentname AS departmentName,
        e.status         AS userStatus,
        e.workcode       AS workcode
        FROM (
        SELECT *
        from hrsa_bill_detail
        WHERE delete_type = 0
        AND bill_month = #{param.billMonth}
        AND payment_status = #{paymentStatus}
        AND payment_organization = #{param.paymentOrganization}
        ) a
        LEFT JOIN hrsa_external_employee e ON e.ID = a.employee_id
        LEFT JOIN hrmdepartment d ON d.id = e.department_id
        LEFT JOIN hrmsubcompany c ON c.id = e.subcompany_id
        where e.status not in (7)
        <!-- 排序 -->
    </select>

    <select id="exportExtExcelAccount" resultType="com.engine.salary.entity.siexport.po.ExcelAccountExportPO">
        SELECT
        a.*,
        e.username AS userName,e.mobile AS telephone,d.departmentname AS departmentName,e.status AS userStatus,e.workcode AS workcode
        FROM(
        SELECT * from hrsa_excel_bill_detail
        WHERE  delete_type = 0 AND bill_month = #{param.billMonth} AND payment_status = #{param.paymentStatus} AND payment_organization = #{param.paymentOrganization}
        )a
        LEFT JOIN hrsa_external_employee e ON e.ID = a.employee_id
        LEFT JOIN hrmdepartment d ON d.id = e.department_id
        where          e.status not in (7)
    </select>
    <select id="exportExtExcelAccount" resultType="com.engine.salary.entity.siexport.po.ExcelAccountExportPO" databaseId="oracle">
         SELECT
        a.*,
        e.username AS userName,e.mobile AS telephone,d.departmentname AS departmentName,e.status AS userStatus,e.workcode AS workcode
        FROM(
        SELECT * from hrsa_excel_bill_detail
        WHERE  delete_type = 0 AND bill_month = #{param.billMonth} AND payment_status = #{param.paymentStatus} AND payment_organization = #{param.paymentOrganization}
        )a
        LEFT JOIN hrsa_external_employee e ON e.ID = a.employee_id
        LEFT JOIN hrmdepartment d ON d.id = e.department_id
        where          e.status not in (7)
     </select>
    <select id="exportExtExcelAccount" resultType="com.engine.salary.entity.siexport.po.ExcelAccountExportPO" databaseId="sqlserver">
           SELECT
        a.*,
        e.username AS userName,e.mobile AS telephone,d.departmentname AS departmentName,e.status AS userStatus,e.workcode AS workcode
        FROM(
        SELECT * from hrsa_excel_bill_detail
        WHERE  delete_type = 0 AND bill_month = #{param.billMonth} AND payment_status = #{param.paymentStatus} AND payment_organization = #{param.paymentOrganization}
        )a
        LEFT JOIN hrsa_external_employee e ON e.ID = a.employee_id
        LEFT JOIN hrmdepartment d ON d.id = e.department_id
        where          e.status not in (7)
     </select>
</mapper>
