<?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.simuwang.base.mapper.FundPositionDetailMapper">
    <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.FundPositionDetailDO">
        <id column="id" property="id"/>
        <result column="fund_id" property="fundId"/>
        <result column="valuation_date" property="valuationDate"/>
        <result column="level" property="level"/>
        <result column="currency" property="currency"/>
        <result column="exchange_rate " property="exchangeRate"/>
        <result column="subject_code" property="subjectCode"/>
        <result column="securities_code" property="securitiesCode"/>
        <result column="securities_name" property="securitiesName"/>
        <result column="sec_type" property="secType"/>
        <result column="securities_amount" property="securitiesAmount"/>
        <result column="market_value" property="marketValueRatio"/>
        <result column="market_value_ratio" property="marketValue"/>
        <result column="market_price" property="marketPrice"/>
        <result column="nature" property="nature"/>
        <result column="subject_type" property="subjectType"/>
        <result column="increment" property="increment"/>
        <result column="halt_info" property="haltInfo"/>
        <result column="net_cost" property="netCost"/>
        <result column="net_cost_ratio" property="netCostRatio"/>
        <result column="unit_cost" property="unitCost"/>
        <result column="isvalid" property="isvalid"/>
        <result column="creatorid" property="creatorId"/>
        <result column="createtime" property="createTime"/>
    </resultMap>

    <delete id="deleteUnUsed">
        delete
        from PPW_EMAIL.fund_position_detail
        where fund_id = #{fundId}
          and valuation_date = #{valuationDate}
    </delete>

    <insert id="insertMulti" parameterType="com.simuwang.base.pojo.dos.FundPositionDetailDO">
        INSERT INTO PPW_EMAIL.fund_position_detail (
        fund_id,valuation_date,LEVEL,currency,exchange_rate,subject_code,
        securities_amount, securities_code,securities_name, sec_type,market_value,
        market_value_ratio,nature,subject_type,increment,halt_info,net_cost,net_cost_ratio,market_price,
        unit_cost,isvalid,creatorid,createtime
        ) VALUES
        <foreach collection="details" index="index" item="detail" separator=",">
            (#{detail.fundId},#{detail.valuationDate},#{detail.level}, #{detail.currency}, #{detail.exchangeRate}, #{detail.subjectCode},
             #{detail.securitiesAmount},#{detail.securitiesCode}, #{detail.securitiesName}, #{detail.secType},#{detail.marketValue},
             #{detail.marketValueRatio}, #{detail.nature},
             #{detail.subjectType},#{detail.increment},#{detail.haltInfo},#{detail.netCost},#{detail.netCostRatio},#{detail.marketPrice},
             #{detail.unitCost},#{detail.isvalid},0,#{detail.createTime})
        </foreach>
    </insert>

</mapper>