<?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.finance.projectReport.mapper.CwProjectInfoMapper">
    <update id="updateSignById">
        update cw_project_report_new_line set delete_sign = #{sign} where id = #{id}
    </update>
    <update id="updateByReportId">
        update cw_project_report_new_line set report_no = #{reportNo}, report_number = #{reportNumber}
        where report_id = #{reportId}
    </update>
    <update id="updateReportNoByReportId">
        update cw_project_report_new_line set report_no = #{reportNo}
        where report_id = #{reportId}
    </update>
    <delete id="deleteByReportId">
        update cw_project_report_new_line set del_flag = '1' where report_id = #{id}
    </delete>
    <select id="selectIdByReportId" resultType="com.jeeplus.finance.projectReport.domain.CwProjectInfoData">
        select id,report_no from cw_project_report_new_line where report_id = #{id} and del_flag = '0'
    </select>
    <select id="selectByReportId" resultType="com.jeeplus.finance.projectReport.domain.CwProjectInfoData">
        select a.*,cw.name as servedUnitName from cw_project_report_new_line a
        left join cw_work_client_base cw
        on a.served_unit_id = cw.id
        where report_id = #{id} and a.del_flag = '0'
    </select>
    <select id="selectContainDelByReportId" resultType="com.jeeplus.finance.projectReport.domain.CwProjectInfoData">
        select a.*,cw.name as servedUnitName from cw_project_report_new_line a
        left join cw_work_client_base cw
        on a.served_unit_id = cw.id
        where report_id = #{id}
    </select>
    <select id="getReportNo" resultType="java.lang.String">
        select report_no from cw_project_report_cancel where del_flag = '0' order by create_date asc
    </select>
    <select id="selectInfoByReportId" resultType="com.jeeplus.finance.projectReport.domain.CwProjectInfoData">
        select * from cw_project_report_new_line where report_id = #{id} and del_flag = '0'
    </select>
    <select id="selectReportNumberByProjectNo" resultType="java.lang.String">
        SELECT DISTINCT report_number FROM `cw_project_report_new_line` WHERE report_number like CONCAT('%',#{projectNo},'%') ORDER BY report_number desc limit 1
    </select>
    <select id="getById" resultType="com.jeeplus.finance.projectReport.domain.CwProjectInfoData">
        select a.*,su.name as reportCreateName from cw_project_report_new_line a
        left join sys_user su on a.create_by_id = su.id and su.del_flag = '0'
        where a.id = #{id}
    </select>
    <select id="getId" resultType="java.lang.String">
        select id from cw_project_report_new_line where report_id = #{id} and del_flag = '0'
    </select>
    <select id="getNewLineInfoById" resultType="com.jeeplus.finance.projectReport.domain.CwProjectInfoData">
        select * from cw_project_report_new_line where id = #{reportNewLineId}
    </select>
    <select id="getCountByReportId" resultType="java.lang.Integer">
        select count(*) from cw_project_report_new_line where report_id = #{reportId} and del_flag = '0'
    </select>
    <select id="getByReportId" resultType="com.jeeplus.finance.projectReport.domain.CwProjectInfoData">
        select a.*,cw.name as servedUnitName from cw_project_report_new_line a
        left join cw_work_client_base cw
        on a.served_unit_id = cw.id
        where report_id = #{reportId} and a.del_flag = '0'
    </select>
    <select id="getContainDelByReportId" resultType="com.jeeplus.finance.projectReport.domain.CwProjectInfoData">
        select a.*,cw.name as servedUnitName from cw_project_report_new_line a
        left join cw_work_client_base cw
        on a.served_unit_id = cw.id
        where report_id = #{reportId}
    </select>
    <update id="saveById">
        update cw_project_report_new_line set del_flag = '0' where id = #{id}
    </update>

    <update id="updateCwProjectInfoDataById">
        update cw_project_report_new_line set
        <if test="delFlag != null and delFlag != ''">
            del_flag = #{delFlag},
        </if>
        <if test="reportId != null and reportId != ''">
            report_id = #{reportId},
        </if>
        <if test="servedUnitId != null and servedUnitId != ''">
            served_unit_id = #{servedUnitId},
        </if>
        <if test="reportDate != null">
            report_date = #{reportDate},
        </if>
        <if test="reportType != null and reportType != ''">
            report_type = #{reportType},
        </if>
        <if test="reportNumber != null and reportNumber != ''">
            report_number = #{reportNumber},
        </if>
        <if test="reportNo != null and reportNo != ''">
            report_no = #{reportNo},
        </if>
        <if test="issueReport != null and issueReport != ''">
            issue_report = #{issueReport},
        </if>
        <if test="opinionType != null and opinionType != ''">
            opinion_type = #{opinionType},
        </if>
        <if test="sealType != null and sealType != ''">
            seal_type = #{sealType},
        </if>
        <if test="fileNumber != null and fileNumber != ''">
            file_number = #{fileNumber},
        </if>
        <if test="deleteSign != null and deleteSign != ''">
            delete_sign = #{deleteSign},
        </if>
        <if test="approvedNoIncludingTax != null and approvedNoIncludingTax != ''">
            approved_no_including_tax = #{approvedNoIncludingTax},
        </if>
        <if test="approvedIncludingTax != null and approvedIncludingTax != ''">
            approved_including_tax = #{approvedIncludingTax},
        </if>
        <if test="tenantId != null and tenantId != ''">
            tenant_id = #{tenantId},
        </if>
        update_by_id = #{updateById},
        update_time = #{updateTime}
        where id = #{id}
    </update>
</mapper>
