<?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.jeeplus.business.monthly.mapper.MonthlyMapper">

    <select id="findPageList" resultType="com.jeeplus.business.monthly.service.dto.MonthlyDTO">
        select distinct
            a.id,
            a.create_time,
            a.create_by_id,
            so.name as officeName,
            su.name as createName,
            a.name,
            a.year,
            a.month,
            a.ifsubmit,
            a.project_status
        from
            jy_monthly a
        left join sys_user su on a.create_by_id = su.id and su.del_flag = '0'
        left join sys_office so on su.office_id = so.id and so.del_flag = '0'
        left join sys_user_manage_office sumo on sumo.office_id = su.office_id
        ${ew.customSqlSegment}
        ORDER BY a.update_time DESC
    </select>

    <select id="findById" resultType="com.jeeplus.business.monthly.service.dto.MonthlyDTO">
        select
            a.id,
            a.create_time,
            a.create_by_id,
            so.name as officeName,
            su.name as createName,
            a.name,
            a.year,
            a.month,
            a.ifsubmit,
            a.remarks,
            a.project_status
        from
            jy_monthly a
        left join sys_user su on a.create_by_id = su.id and su.del_flag = '0'
        left join sys_office so on su.office_id = so.id and so.del_flag = '0'
        where a.id=#{id}
    </select>

    <select id="getList" resultType="com.jeeplus.business.monthly.service.dto.MonthlyDTO">
        SELECT a.id,
            a.create_time,
            a.create_by_id,
            a.name,
            a.year,
            a.month,
            a.ifsubmit,
            a.remarks,
            a.project_status
        FROM
            jy_monthly a
        WHERE
            YEAR(a.create_time) = YEAR(CURDATE()) AND MONTH(a.create_time) = MONTH(CURDATE())
            and a.del_flag = 0
            GROUP BY a.create_by_id
    </select>


</mapper>