码迷,mamicode.com
首页 > 数据库 > 详细

SQL

时间:2018-08-04 18:59:38      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:stc   change   serve   class   arc   java   user   cms   open   

插入语句

①:

void insertByProjectid(CmDynamicCostRemark cmDynamicCostRemark);
<insert id="insertByProjectid" parameterType="com.longfor.dragonshard.entity.CmDynamicCostRemark">
        <selectKey keyProperty="dynamiccostremarkid" order="BEFORE" resultType="java.math.BigDecimal">
            SELECT   CM_DYNAMICCOSTREMARK_SEQ.NEXTVAL   FROM   dual
        </selectKey>
        INSERT INTO CM_DYNAMICCOSTREMARK
        <trim prefix="(" suffix=")" suffixOverrides=",">
            dynamiccostremarkid,
            <if test="projectid != null and projectid != ‘‘">
                projectid,
            </if>
            <if test="createdate != null ">
                createdate,
            </if>
            <if test="modifydate != null ">
                modifydate,
            </if>
            <if test="flag != null and flag != ‘‘">
                flag,
            </if>
            <if test="remark != null and remark != ‘‘">
                remark,
            </if>
        </trim>
        <trim prefix=" values (" suffix=")" suffixOverrides=",">
            #{dynamiccostremarkid,jdbcType=DECIMAL},
            <if test="projectid != null and projectid != ‘‘">
                #{projectid,jdbcType=DECIMAL},
            </if>
            <if test="createdate != null ">
                #{createdate,jdbcType=DECIMAL},
            </if>
            <if test="modifydate != null ">
                #{modifydate,jdbcType=VARCHAR},
            </if>
            <if test="flag != null and flag != ‘‘">
                #{flag,jdbcType=VARCHAR},
            </if>
            <if test="remark != null and remark != ‘‘">
                #{remark,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>

②:

void insertByProjectid(CmCostSummary cmCostSummary);
<insert id="insertByProjectid" parameterType="com.longfor.dragonshard.entity.CmCostSummary">
        INSERT INTO CM_DYNAMICCOSTCHANGECURVE(
        DYNAMICCHANGEID, PROJECTID, COMPANYID, COSTCODEID, BUDGETAMT, DYNAMICCOST, PLANINGAMT,
        CONTRACTAMT, ESTIMATEVOAMT, MARGINAMT, PAYABLEAMT, PAYMENTAMT, PAIDAMT, RECORDSTATUS,
        CREATEUSERID, CREATEDATE, MODIFYDATE, MODIFYUSERID, OLDDATA, PLANINGUSEDAMT, RESERVEDBALANCE,
        ADJRESERVEDBALANCE, CONTROLMARGINAMT, ABLEAMT
        )
        VALUES(
        #{costsummaryid,jdbcType=DECIMAL},
        #{projectid,jdbcType=DECIMAL},
        #{companyid,jdbcType=DECIMAL},
        #{costcodeid,jdbcType=DECIMAL},
        #{budgetamt,jdbcType=DECIMAL},
        #{dynamiccost,jdbcType=DECIMAL},
        #{planingamt,jdbcType=DECIMAL},
        #{contractamt,jdbcType=DECIMAL},
        #{estimatevoamt,jdbcType=DECIMAL},
        #{marginamt,jdbcType=DECIMAL},
        #{payableamt,jdbcType=DECIMAL},
        #{paymentamt,jdbcType=DECIMAL},
        #{paidamt,jdbcType=DECIMAL},
        #{recordstatus,jdbcType=VARCHAR},
        #{createuserid,jdbcType=DECIMAL},

        #{createdate,jdbcType=TIMESTAMP},
        #{modifydate,jdbcType=TIMESTAMP},

        #{modifyuserid,jdbcType=DECIMAL},
        #{olddata,jdbcType=CHAR},
        #{planingusedamt,jdbcType=DECIMAL},
        #{reservedbalance,jdbcType=DECIMAL},
        #{adjreservedbalance,jdbcType=DECIMAL},
        #{controlmarginamt,jdbcType=DECIMAL},
        #{ableamt,jdbcType=DECIMAL}
        )
    </insert>

③:

<insert id="savaCmStandardCityConfig" parameterType="java.util.List">
    insert into CM_STANDARDCITYCONFIG
    ( STANDARDCITYCONFIGID, PRODUCTCONFIG, PROCONFIGLV, PRODUCTCONFIGID, PRODUCTCONFIGPARENTID,
    HASCHILD, PRICEBASEDATA, DATAUNIT, CONSTRUCTCONFIG, STANDARDCONFIG, REFERENCEPRICE,
    STANDARDCOSTID, CREATEDATE, MODIFYDATE, FLAG, PRODUCTTYPEID, PRODUCTTYPENAME, PRODUCTTYPECODE,
    CITYID,REMARK)
    select CM_STANDARDCITYCONFIG_SEQ.NEXTVAL,m.*from (
    <foreach close=")" collection="list" index="index" item="item" open="(" separator="union all">
      select
      #{item.productconfig,jdbcType=VARCHAR},
      #{item.proconfiglv,jdbcType=DECIMAL},
      #{item.productconfigid,jdbcType=VARCHAR},
      #{item.productconfigparentid,jdbcType=DECIMAL},
      #{item.haschild,jdbcType=VARCHAR},
      #{item.pricebasedata,jdbcType=VARCHAR},
      #{item.dataunit,jdbcType=VARCHAR},
      #{item.constructconfig,jdbcType=VARCHAR},
      #{item.standardconfig,jdbcType=VARCHAR},
      #{item.referenceprice,jdbcType=DECIMAL},
      #{item.standardcostid,jdbcType=DECIMAL},
      to_date(to_char(#{item.createdate,jdbcType=TIMESTAMP},yyyy-MM-dd),yyyy-MM-dd),
      to_date(to_char(#{item.modifydate,jdbcType=TIMESTAMP},yyyy-MM-dd),yyyy-MM-dd),
      #{item.flag,jdbcType=VARCHAR},
      #{item.producttypeid,jdbcType=DECIMAL},
      #{item.producttypename,jdbcType=VARCHAR},
      #{item.producttypecode,jdbcType=VARCHAR},
      #{item.cityid,jdbcType=DECIMAL},
      #{item.remark,jdbcType=VARCHAR}
      from dual
    </foreach>
    ) m
  </insert>

 

 

查找语句

①:根据字段查找

List<CmDynamicCostRemark> selectByProjectid(@Param("projectid")BigDecimal projectid);
    <select id="selectByProjectid" parameterType="java.math.BigDecimal" resultMap="BaseResultMap">
        SELECT * FROM
        CM_DYNAMICCOSTREMARK
        WHERE
        <if test="projectid != null and projectid != ‘‘">
            PROJECTID = #{projectid,jdbcType=DECIMAL}
        </if>
    </select>

②:根据集合查找

List<CmCostSummary> selectTotalDynamicBudge(@Param("list")List list);
    <select id="selectTotalDynamicBudge" parameterType="list" resultType="com.longfor.dragonshard.entity.CmCostSummary">
        SELECT * FROM cm_costsummary cs WHERE
        cs.PROJECTID IN
        <foreach collection="list" index="index" item="param" open="(" separator="," close=")">
            #{param.projectid}
        </foreach>
        AND
        cs.COSTCODEID = 79776
    </select>

 

SQL

标签:stc   change   serve   class   arc   java   user   cms   open   

原文地址:https://www.cnblogs.com/bockpecehhe/p/9392695.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!