BillBaseInfoMapper.xml 10.3 KB
<?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="cn.com.polysoft.template.dao.BillBaseInfoMapper" >

    <insert id="saveBill" parameterType="cn.com.polysoft.template.dto.BillDTO" useGeneratedKeys="true" keyProperty="id">
        insert into t_bill_base_info(
        id,
        template_id,
        bill_type,
        bill_kind,
        bill_template_name,
        contract_code,
        contract_name,
        your_rep,
        rate_of_exchange,
        increment_rate,
        reinsurance_code,
        broker_code,
        separate_out,
        articlecode_ss,
        document_num,
        bill_start_time,
        bill_end_time,
        bill_period_type,
        bill_period_year,
        bill_period_code,
        added_tax_mark,
        remarks,
        reinsurance_policy_no,
        reinsurance_business_no,
        direct_business_no,
        risk_unit_num,
        receiver_type,
        ppw,
        insured_name,
        reinsurance_name,
        broker_name,
        separate_out_name,
        create_time,
        contract_code_other,
        com_code,
        file_id
        )values (
            #{id},
            #{templateId},
            #{billType},
            #{billKind},
            #{billTemplateName},
            #{contractCode},
            #{contractName},
            #{yourRep},
            #{rateOfExchange},
            #{incrementRate},
            #{reinsuranceCode},
            #{brokerCode},
            #{separateOut},
            #{articlecodeSs},
            #{documentNum},
            #{billStartTime},
            #{billEndTime},
            #{billPeriodType},
            #{billPeriodYear},
            #{billPeriodCode},
            #{addedTaxMark},
            #{remarks},
            #{reinsurancePolicyNo},
            #{reinsuranceBusinessNo},
            #{directBusinessNo},
            #{riskUnitNum},
            #{receiverType},
            #{ppw},
            #{insuredName},
            #{reinsuranceName},
            #{brokerName},
            #{separateOutName},
            now(),
            #{contractCodeOther},
            #{comCode},
            #{fileId}
        )
    </insert>

    <select id="getBillListByCondition" parameterType="cn.com.polysoft.template.dto.BillBaseInfoDTO" resultType="cn.com.polysoft.template.vo.BillBaseInfoVO">
        SELECT
        a.id,
        b.bill_num,
        case when
        a.bill_type = '1' then '合约账单'
        when a.bill_type = '0' then '临分账单' else ''
        end billType,
        case when
        a.bill_kind = 'G' then '正常账单'
        when a.bill_kind = 'K' then '合约超赔系统账单'
        when a.bill_kind = 'P' then '保单账单'
        when a.bill_kind = 'Z' then '纯益手续费账单'
        else ''
        end billKind,
        a.bill_template_name,
        case when
        b.status = '1' then '识别未提交'
        when b.status = '2' then '识别已提交'
        when b.status = '3' then '提交未成功'
        else ''
        end status,
        a.broker_name,
        a.separate_out_name,
        a.create_time,
        b.serial_number,
        b.status status_num,
        a.com_code
        FROM
        t_bill_sub_item b
        left join t_bill_base_info a on a.id = b.bill_id
        <where>
            <if test="brokerName!=null and brokerName!=''">AND a.broker_name like #{brokerName}</if>
            <if test="separateOutName!=null and separateOutName!=''">and a.separate_out_name like #{separateOutName}</if>
            <if test="status!=null and status!=''">AND b.status=#{status}</if>
            <if test="startTime!=null and startTime!=''">and to_char(a.create_time,'yyyy-MM-dd') &gt;= #{startTime}</if>
            <if test="endTime!=null and endTime!=''">and to_char(a.create_time,'yyyy-MM-dd') &lt;= #{endTime}</if>
            <if test="keywords!=null and keywords!=''">
                AND (a.broker_name like #{keywords} or a.separate_out_name like #{keywords} or b.bill_num like #{keywords})
            </if>
            <if test="brokerCode!=null and brokerCode!=''">AND a.broker_code like #{brokerCode}</if>
            <if test="separateOut!=null and separateOut!=''">AND a.separate_out like #{separateOut}</if>
            <if test="serialNumber!=null and serialNumber!=''">AND b.serial_number like #{serialNumber}</if>
            <if test="contractCode!=null and contractCode!=''">AND a.contract_code like #{contractCode}</if>
            <if test="contractName!=null and contractName!=''">AND a.contract_name like #{contractName}</if>
            and b.id is not null and a.com_code=#{comCode}
        </where>
        ORDER BY a.create_time DESC,b.serial_number DESC
    </select>

    <update id="modifyBill" parameterType="cn.com.polysoft.template.dto.BillDTO">
        update t_bill_base_info
        <set>
            <if test="templateId != null and templateId != ''">template_id = #{templateId},</if>
            <if test="billType != null and billType != ''">bill_type = #{billType},</if>
            <if test="billKind != null and billKind != ''">bill_kind = #{billKind},</if>
            <if test="billTemplateName != null and billTemplateName != ''">bill_template_name = #{billTemplateName},</if>
            <if test="contractCode != null and contractCode != ''">contract_code = #{contractCode},</if>
            <if test="contractCodeOther != null and contractCodeOther != ''">contract_code_other = #{contractCodeOther},</if>
            <if test="contractName != null and contractName != ''">contract_name = #{contractName},</if>
            <if test="yourRep != null and yourRep != ''">your_rep = #{yourRep},</if>
            <if test="rateOfExchange != null and rateOfExchange != ''">rate_of_exchange = #{rateOfExchange},</if>
            <if test="incrementRate != null and incrementRate != ''">increment_rate = #{incrementRate},</if>
            <if test="reinsuranceCode != null and reinsuranceCode != ''">reinsurance_code = #{reinsuranceCode},</if>
            <if test="brokerCode != null and brokerCode != ''">broker_code = #{brokerCode},</if>
            <if test="separateOut != null and separateOut != ''">separate_out = #{separateOut},</if>
            <if test="articlecodeSs != null and articlecodeSs != ''">articlecode_ss = #{articlecodeSs},</if>
            <if test="documentNum != null and documentNum != ''">document_num = #{documentNum},</if>
            <if test="billStartTime != null and billStartTime != ''">bill_start_time = #{billStartTime},</if>
            <if test="billEndTime != null and billEndTime != ''">bill_end_time = #{billEndTime},</if>
            <if test="billPeriodType != null and billPeriodType != ''">bill_period_type = #{billPeriodType},</if>
            <if test="billPeriodYear != null and billPeriodYear != ''">bill_period_year = #{billPeriodYear},</if>
            <if test="billPeriodCode != null and billPeriodCode != ''">bill_period_code = #{billPeriodCode},</if>
            <if test="addedTaxMark != null and addedTaxMark != ''">added_tax_mark = #{addedTaxMark},</if>
            <if test="remarks != null and remarks != ''">remarks = #{remarks},</if>
            <if test="reinsurancePolicyNo != null and reinsurancePolicyNo != ''">reinsurance_policy_no = #{reinsurancePolicyNo},</if>
            <if test="reinsuranceBusinessNo != null and reinsuranceBusinessNo != ''">reinsurance_business_no = #{reinsuranceBusinessNo},</if>
            <if test="directBusinessNo != null and directBusinessNo != ''">direct_business_no = #{directBusinessNo},</if>
            <if test="riskUnitNum != null and riskUnitNum != ''">risk_unit_num = #{riskUnitNum},</if>
            <if test="receiverType != null and receiverType != ''">receiver_type = #{receiverType},</if>
            <if test="ppw != null and ppw != ''">ppw = #{ppw},</if>
            <if test="insuredName != null and insuredName != ''">insured_name = #{insuredName},</if>
            <if test="reinsuranceName != null and reinsuranceName != ''">reinsurance_name = #{reinsuranceName},</if>
            <if test="brokerName != null and brokerName != ''">broker_name = #{brokerName},</if>
            <if test="separateOutName != null and separateOutName != ''">separate_out_name = #{separateOutName},</if>
            modify_time = now()
        </set>
        where id = #{id}
    </update>

    <select id="getBillInfo" parameterType="string" resultType="cn.com.polysoft.template.vo.BillInfoVO">
        select bi.*, t.billperiod as treatyBillPeriod
        from t_bill_base_info bi
                     left join inwardtreatyinfo t on bi.contract_code = t.treatyid
        where bi.id = #{id}
    </select>

    <select id="getSubmitBillInfo" parameterType="string" resultType="cn.com.polysoft.template.vo.RequestMessageBillInfoVO">
        select a.*,
        b.serial_number,b.sub_item_num,b.contract_sub_item,b.share_out as share_out_str,b.currency_orig as currency_orig_str,
        b.item_value_orig as item_value_orig_str,b.currency,b.currency_balance as currency_balance_str,b.outstanding_claims as outstanding_claims_str,
        b.happen_outstanding_claims as happen_outstanding_claims_str,b.premium_added_tax as premium_added_tax_str,b.broker_added_tax as broker_added_tax_str,
        b.broker_added_tax_additional as broker_added_tax_additional_str,b.premium_added_tax_deduction as premium_added_tax_deduction_str,b.premium_added_tax_additional as premium_added_tax_additional_str,
        b.broker_added_tax_deduction as broker_added_tax_deduction_str,b.broker_tax_add_deduction as broker_tax_add_deduction_str,b.id as sub_item_id,
		b.sepe_flag,b.settle_type,b.stage_num,b.document_num as document_num_sub,b.status,b.added_tax_mark added_tax_mark_sub
        from t_bill_base_info a
        inner join t_bill_sub_item b on a.id = b.bill_id
        where a.id = #{id}
    </select>

    <select id="whetherMark" resultType="int">
        select count(1) num from t_company c where c.company_code = #{brokerCode} and c.type = #{type} and c.mark = #{mark}
    </select>

    <select id="getFileInfo" parameterType="string"  resultType="cn.com.polysoft.template.vo.BillIFileInfo">
        SELECT
            f.file_path,
            f.server_address
        FROM
            t_bill_sub_item s
            LEFT JOIN t_bill_base_info b ON b.ID = s.bill_id
            LEFT JOIN t_file f ON b.file_id = f.ID
        WHERE
            s.bill_num = #{billNum}
    </select>
</mapper>